Skip to contentSkip to conversation

tests: Map WORKDIR to W: to shorten paths

PATCH New Joshua Watt 1 participant 1 message Dec 8, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests: Map WORKDIR to W: to shorten paths

In some cases Wine (and Windows proper) struggle with very long paths; in particular the way that gcc invokes the 'cc1' subprogram is limited in how deep the path to the subprogram can be. This can cause issues when testing the SDK under wine, as the paths can easily get quite long and exceed this limit. In order to work around this, setup the Wine test context so that the W: drive maps to the SDK image ${WORKDIR}, which allows wine to effectively use paths relative to this directory making them significantly shorter.

---
 lib/oeqa/sdkmingw/case.py    |  4 ++--
 lib/oeqa/sdkmingw/context.py | 11 ++++++++++-
 lib/oeqa/sdkmingw/testsdk.py |  5 ++++-
 3 files changed, 16 insertions(+), 4 deletions(-)
lib/oeqa/sdkmingw/case.py +2 -2
index 169c143..dee7d3d 100644
@@ -56,7 +56,7 @@ class OESDKMinGWTestCase(OESDKTestCase):
                 return s[1:-1]
             return s
 
-        command = ['wine', 'cmd', '/c', self.tc.wine_sdk_env, '>', 'NUL', '&&', 'cd', self.wine_test_dir, '&&']
+        command = ['wine', 'cmd', '/c', self.tc.wine_sdk_env, '>', 'NUL', '&&']
 
         # Perform some massaging so that commands can be written naturally in
         # test cases. shlex.split() in Non-posix mode gets us most of the way
@@ -65,7 +65,7 @@ class OESDKMinGWTestCase(OESDKTestCase):
         command.extend(strip_quotes(s) for s in shlex.split(cmd, posix=False))
 
         return subprocess.check_output(command, env=self.tc.get_wine_env(),
-                stderr=subprocess.STDOUT, universal_newlines=True)
+                stderr=subprocess.STDOUT, universal_newlines=True, cwd=self.test_dir)
 
     def assertIsTargetElf(self, path):
         import oe.qa
lib/oeqa/sdkmingw/context.py +10 -1
index edabcbd..5319223 100644
@@ -12,10 +12,19 @@ class OESDKMinGWTestContext(OESDKTestContext):
     sdk_files_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "files")
 
     def __init__(self, td=None, logger=None, sdk_dir=None, sdk_env=None, wine_prefix=None,
-            wine_arch=None, target_pkg_manifest=None, host_pkg_manifest=None):
+            wine_arch=None, wine_devices={}, target_pkg_manifest=None, host_pkg_manifest=None):
         super(OESDKMinGWTestContext, self).__init__(td, logger, sdk_dir, sdk_env, target_pkg_manifest, host_pkg_manifest)
         self.wine_prefix = wine_prefix
         self.wine_arch = wine_arch
+        # Create the wine environment
+        subprocess.check_output(["wine", "cmd", "/c", "echo 1"], env=self.get_wine_env())
+
+        device_dir  = "%s/dosdevices" % wine_prefix
+        bb.utils.mkdirhier(device_dir)
+        for device, path in wine_devices.items():
+            device_path = "%s/%s" % (device_dir, device)
+            os.symlink(os.path.relpath(path, device_dir), device_path)
+
         self.wine_sdk_dir = self.wine_path(sdk_dir)
         self.wine_sdk_env = self.wine_path(sdk_env)
 
lib/oeqa/sdkmingw/testsdk.py +4 -1
index 173cfd9..5c80bb4 100644
@@ -44,6 +44,9 @@ class TestSDKMinGW(TestSDK):
 
         return {
             'wine_prefix': wine_prefix,
-            'wine_arch': d.getVar('TESTSDK_WINEARCH') or 'win64'
+            'wine_arch': d.getVar('TESTSDK_WINEARCH') or 'win64',
+            'wine_devices': {
+                'w:': d.getVar("WORKDIR"),
             }
+        }
 
Signature · 1 line
2.33.0