Mesa (staging/20.0): tests: Make tests aware of meson test wrapper

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu May 28 18:58:03 UTC 2020


Module: Mesa
Branch: staging/20.0
Commit: 0cbeea6f8a52c885e9751cd84d1663c48351b952
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0cbeea6f8a52c885e9751cd84d1663c48351b952

Author: Dylan Baker <dylan.c.baker at intel.com>
Date:   Thu May 14 15:36:36 2020 -0700

tests: Make tests aware of meson test wrapper

Meson 0.55.0 will set the MESON_EXE_WRAPPER environment variable to the
joined version of that wrapper if it is needed. Our tests that take
compiled targets as arguments can use that information to run cross
built binaries, or if there isn't a wrapper and we get an ENOEXEC, we
can skip the tests gracefully.

We try to use mesonlib.split_args, which handles windows arguments
better than python's builtin shlex module, but fall back to that if the
meson module isn't available for some reason.

Cc: 20.0 20.1 <mesa-stable at lists.freedesktop.org>
Reviewed-by: Eric Engestrom <eric at engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5103>
(cherry picked from commit 55803224865d735f060c55cc8940946da725cb0b)

---

 .pick_status.json                            |  2 +-
 src/compiler/glsl/glcpp/tests/glcpp_test.py  | 45 ++++++++++++++++++++--------
 src/compiler/glsl/tests/optimization_test.py | 16 ++++++----
 src/compiler/glsl/tests/warnings_test.py     | 16 ++++++----
 4 files changed, 56 insertions(+), 23 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 0fe839ed909..94436f2edaa 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -2947,7 +2947,7 @@
         "description": "tests: Make tests aware of meson test wrapper",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": null
     },
diff --git a/src/compiler/glsl/glcpp/tests/glcpp_test.py b/src/compiler/glsl/glcpp/tests/glcpp_test.py
index b024300522f..c11a7c2105b 100644
--- a/src/compiler/glsl/glcpp/tests/glcpp_test.py
+++ b/src/compiler/glsl/glcpp/tests/glcpp_test.py
@@ -24,12 +24,20 @@
 from __future__ import print_function
 import argparse
 import difflib
+import errno
 import io
 import os
 import subprocess
 import sys
 import tempfile
 
+# The meson version handles windows paths better, but if it's not available
+# fall back to shlex
+try:
+    from meson.mesonlib import split_args
+except ImportError:
+    from shlex import split as split_args
+
 
 def arg_parser():
     parser = argparse.ArgumentParser()
@@ -61,7 +69,7 @@ def test_output(glcpp, filename, expfile, nl_format='\n'):
 
     with open(filename, 'rb') as f:
         proc = subprocess.Popen(
-            [glcpp] + extra_args,
+            glcpp + extra_args,
             stdout=subprocess.PIPE,
             stderr=subprocess.STDOUT,
             stdin=subprocess.PIPE)
@@ -85,7 +93,7 @@ def _valgrind(glcpp, filename):
         os.close(fd)
         with open(filename, 'rb') as f:
             proc = subprocess.Popen(
-                ['valgrind', '--error-exitcode=31', '--log-file', tmpfile, glcpp] + extra_args,
+                ['valgrind', '--error-exitcode=31', '--log-file', tmpfile] + glcpp + extra_args,
                 stdout=subprocess.PIPE,
                 stderr=subprocess.STDOUT,
                 stdin=subprocess.PIPE)
@@ -216,17 +224,30 @@ def test_valgrind(args):
 def main():
     args = arg_parser()
 
+    wrapper = os.environ.get('MESON_EXE_WRAPPER')
+    if wrapper is not None:
+        args.glcpp = split_args(wrapper) + [args.glcpp]
+    else:
+        args.glcpp = [args.glcpp]
+
     success = True
-    if args.unix:
-        success = success and test_unix(args)
-    if args.windows:
-        success = success and test_windows(args)
-    if args.oldmac:
-        success = success and test_oldmac(args)
-    if args.bizarro:
-        success = success and test_bizarro(args)
-    if args.valgrind:
-        success = success and test_valgrind(args)
+    try:
+        if args.unix:
+            success = success and test_unix(args)
+        if args.windows:
+            success = success and test_windows(args)
+        if args.oldmac:
+            success = success and test_oldmac(args)
+        if args.bizarro:
+            success = success and test_bizarro(args)
+        if args.valgrind:
+            success = success and test_valgrind(args)
+    except OSError as e:
+        if e.errno == errno.ENOEXEC:
+            print('Skipping due to inability to run host binaries.',
+                  file=sys.stderr)
+            sys.exit(77)
+        raise
 
     exit(0 if success else 1)
 
diff --git a/src/compiler/glsl/tests/optimization_test.py b/src/compiler/glsl/tests/optimization_test.py
index a02dcd31a05..a413370a5e7 100644
--- a/src/compiler/glsl/tests/optimization_test.py
+++ b/src/compiler/glsl/tests/optimization_test.py
@@ -32,6 +32,13 @@ import sys
 import sexps
 import lower_jump_cases
 
+# The meson version handles windows paths better, but if it's not available
+# fall back to shlex
+try:
+    from meson.mesonlib import split_args
+except ImportError:
+    from shlex import split as split_args
+
 
 def arg_parser():
     parser = argparse.ArgumentParser()
@@ -58,10 +65,10 @@ def compare(actual, expected):
 
 def get_test_runner(runner):
     """Wrap the test runner in the exe wrapper if necessary."""
-    wrapper =  os.environ.get('MESON_EXE_WRAPPER', None)
+    wrapper = os.environ.get('MESON_EXE_WRAPPER', None)
     if wrapper is None:
         return [runner]
-    return [wrapper, runner]
+    return split_args(wrapper) + [runner]
 
 
 def main():
@@ -109,7 +116,6 @@ if __name__ == '__main__':
         main()
     except OSError as e:
         if e.errno == errno.ENOEXEC:
-            print('Skipping due to lack of exe_wrapper.', file=sys.stderr)
+            print('Skipping due to inability to run host binaries', file=sys.stderr)
             sys.exit(77)
-        else:
-            raise
+        raise
diff --git a/src/compiler/glsl/tests/warnings_test.py b/src/compiler/glsl/tests/warnings_test.py
index 6cd3fbf294f..e587bc9ba2d 100644
--- a/src/compiler/glsl/tests/warnings_test.py
+++ b/src/compiler/glsl/tests/warnings_test.py
@@ -26,6 +26,13 @@ import os
 import subprocess
 import sys
 
+# The meson version handles windows paths better, but if it's not available
+# fall back to shlex
+try:
+    from meson.mesonlib import split_args
+except ImportError:
+    from shlex import split as split_args
+
 
 def arg_parser():
     parser = argparse.ArgumentParser()
@@ -42,10 +49,10 @@ def arg_parser():
 
 def get_test_runner(runner):
     """Wrap the test runner in the exe wrapper if necessary."""
-    wrapper =  os.environ.get('MESON_EXE_WRAPPER', None)
+    wrapper = os.environ.get('MESON_EXE_WRAPPER', None)
     if wrapper is None:
         return [runner]
-    return [wrapper, runner]
+    return split_args(wrapper) + [runner]
 
 
 def main():
@@ -86,7 +93,6 @@ if __name__ == '__main__':
         main()
     except OSError as e:
         if e.errno == errno.ENOEXEC:
-            print('Skipping due to lack of exe_wrapper.', file=sys.stderr)
+            print('Skipping due to inability to run host binaries', file=sys.stderr)
             sys.exit(77)
-        else:
-            raise
+        raise



More information about the mesa-commit mailing list