[Openmp-commits] [openmp] 81bc7cf - [OpenMP][NFC] lit: Allow setting default environment variables for test
Joachim Jenke via Openmp-commits
openmp-commits at lists.llvm.org
Tue Jul 11 06:00:52 PDT 2023
Author: Joachim Jenke
Date: 2023-07-11T15:00:40+02:00
New Revision: 81bc7cf609c09374a62793d74fa33709828377b6
URL: https://github.com/llvm/llvm-project/commit/81bc7cf609c09374a62793d74fa33709828377b6
DIFF: https://github.com/llvm/llvm-project/commit/81bc7cf609c09374a62793d74fa33709828377b6.diff
LOG: [OpenMP][NFC] lit: Allow setting default environment variables for test
Add CHECK_OPENMP_ENV environment variable which will be passed to environment
variables for test (make check-* target). This provides a handy way to
exercise various openmp code with different settings during development.
For example, to change default barrier pattern:
```
$ env CHECK_OPENMP_ENV="KMP_FORKJOIN_BARRIER_PATTERN=hier,hier \
KMP_PLAIN_BARRIER_PATTERN=hier,hier \
KMP_REDUCTION_BARRIER_PATTERN=hier,hier" \
ninja check-openmp
```
Even with this, each test can set appropriate environment variables if needed
as before.
Also, this commit adds missing documention about how to run tests in README.
Patch provided by t-msn
Differential Revision: https://reviews.llvm.org/D122645
Added:
Modified:
openmp/README.rst
openmp/libomptarget/test/lit.cfg
openmp/runtime/test/lit.cfg
openmp/tools/archer/tests/lit.cfg
openmp/tools/multiplex/tests/lit.cfg
Removed:
################################################################################
diff --git a/openmp/README.rst b/openmp/README.rst
index f5d0cefbd01734..2cdd38220d52a8 100644
--- a/openmp/README.rst
+++ b/openmp/README.rst
@@ -363,3 +363,35 @@ Advanced Builds with Various Options
**Footnotes**
.. [*] Other names and brands may be claimed as the property of others.
+
+How to Run Tests
+================
+
+There are following check-* make targets for tests.
+
+- ``check-ompt`` (ompt tests under runtime/test/ompt)
+- ``check-ompt-multiplex`` (ompt multiplex tests under tools/multiplex/tests)
+- ``check-libarcher`` (libarcher tests under tools/archer/tests)
+- ``check-libomp`` (libomp tests under runtime/test. This includes check-ompt tests too)
+- ``check-libomptarget-*`` (libomptarget tests for specific target under libomptarget/test)
+- ``check-libomptarget`` (all check-libomptarget-* tests)
+- ``check-openmp`` (combination of all above tests excluding duplicates)
+
+For example, to run all available tests, use ``make check-openmp``.
+
+Options for Tests
+------------------
+Tests use lit framework.
+See `lit documentation <https://llvm.org/docs/CommandGuide/lit.html>`_ for lit options.
+
+**CHECK_OPENMP_ENV** = ``""``
+ Default environment variables which test process uses for ``check-openmp``
+ separated by space. This can be used for individual targets (``check-ompt``,
+ ``check-ompt-multiplex``, ``check-libarcher``, ``check-libomp`` and
+ ``check-libomptarget-*``) too. Note that each test still overrides
+ environment variables if needed. For example, to change barrier pattern to be
+ used from default hyper barrier to hierarchical barrier, run:
+
+.. code-block:: console
+
+ $ CHECK_OPENMP_ENV="KMP_PLAIN_BARRIER_PATTERN=hier,hier KMP_FORKJOIN_BARRIER_PATTERN=hier,hier KMP_REDUCTION_BARRIER_PATTERN=hier,hier" make check-openmp
diff --git a/openmp/libomptarget/test/lit.cfg b/openmp/libomptarget/test/lit.cfg
index 2bb48b16d51a29..080ed197e8c00d 100644
--- a/openmp/libomptarget/test/lit.cfg
+++ b/openmp/libomptarget/test/lit.cfg
@@ -35,6 +35,14 @@ if 'LIBOMPTARGET_LOCK_MAPPED_HOST_BUFFERS' in os.environ:
if 'OMP_TARGET_OFFLOAD' in os.environ:
config.environment['OMP_TARGET_OFFLOAD'] = os.environ['OMP_TARGET_OFFLOAD']
+# set default environment variables for test
+if 'CHECK_OPENMP_ENV' in os.environ:
+ test_env = os.environ['CHECK_OPENMP_ENV'].split()
+ for env in test_env:
+ name = env.split('=')[0]
+ value = env.split('=')[1]
+ config.environment[name] = value
+
def append_dynamic_library_path(name, value, sep):
if name in config.environment:
config.environment[name] = value + sep + config.environment[name]
diff --git a/openmp/runtime/test/lit.cfg b/openmp/runtime/test/lit.cfg
index a9399288e550ad..ab69819530d4a0 100644
--- a/openmp/runtime/test/lit.cfg
+++ b/openmp/runtime/test/lit.cfg
@@ -134,6 +134,14 @@ except NotImplementedError:
if 'INTEL_LICENSE_FILE' in os.environ:
config.environment['INTEL_LICENSE_FILE'] = os.environ['INTEL_LICENSE_FILE']
+# set default environment variables for test
+if 'CHECK_OPENMP_ENV' in os.environ:
+ test_env = os.environ['CHECK_OPENMP_ENV'].split()
+ for env in test_env:
+ name = env.split('=')[0]
+ value = env.split('=')[1]
+ config.environment[name] = value
+
# substitutions
config.substitutions.append(("%libomp-compile-and-run", \
"%libomp-compile && %libomp-run"))
diff --git a/openmp/tools/archer/tests/lit.cfg b/openmp/tools/archer/tests/lit.cfg
index 3caa3ea2d3cbd9..692cbfe97cf1e1 100644
--- a/openmp/tools/archer/tests/lit.cfg
+++ b/openmp/tools/archer/tests/lit.cfg
@@ -90,6 +90,14 @@ if config.has_tsan == True:
if 'INTEL_LICENSE_FILE' in os.environ:
config.environment['INTEL_LICENSE_FILE'] = os.environ['INTEL_LICENSE_FILE']
+# set default environment variables for test
+if 'CHECK_OPENMP_ENV' in os.environ:
+ test_env = os.environ['CHECK_OPENMP_ENV'].split()
+ for env in test_env:
+ name = env.split('=')[0]
+ value = env.split('=')[1]
+ config.environment[name] = value
+
config.environment['ARCHER_OPTIONS'] = "report_data_leak=1"
# Race Tests
diff --git a/openmp/tools/multiplex/tests/lit.cfg b/openmp/tools/multiplex/tests/lit.cfg
index 69df2fd944cb45..a637d6f72f5525 100644
--- a/openmp/tools/multiplex/tests/lit.cfg
+++ b/openmp/tools/multiplex/tests/lit.cfg
@@ -54,6 +54,14 @@ config.test_flags = " -I " + config.test_source_root + "/.."\
if 'INTEL_LICENSE_FILE' in os.environ:
config.environment['INTEL_LICENSE_FILE'] = os.environ['INTEL_LICENSE_FILE']
+# set default environment variables for test
+if 'CHECK_OPENMP_ENV' in os.environ:
+ test_env = os.environ['CHECK_OPENMP_ENV'].split()
+ for env in test_env:
+ name = env.split('=')[0]
+ value = env.split('=')[1]
+ config.environment[name] = value
+
# Allow XFAIL to work
config.target_triple = [ ]
for feature in config.test_compiler_features:
More information about the Openmp-commits
mailing list