From 0d79d8ca035035706ee2b259791113db929a680c Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Thu, 25 Apr 2019 02:52:11 +0000 Subject: [PATCH] Simplify libomp-test package + Rename test script to run-lit-tests and move to libexec to match llvm-test. + Move most of the configuration out of the spec file and into the test script and a custom lit config file. + Stop testing libomp with gcc. Most of the complication in the spec file was to enable testing with gcc. A user would have to go way out of their way to make libomp work with gcc, so I don't think there is much value in keeping the complexity in order to test this. --- libomp.spec | 48 +++++++++++++++----------------------- lit.fedora.cfg.py | 15 ++++++++++++ run-lit-tests | 59 +++++++++++++++++++++++++++++++++++++++++++++++ runtest.sh | 33 -------------------------- tests/tests.yml | 2 +- 5 files changed, 94 insertions(+), 63 deletions(-) create mode 100644 lit.fedora.cfg.py create mode 100644 run-lit-tests delete mode 100644 runtest.sh diff --git a/libomp.spec b/libomp.spec index 5bb36d3..aa810cd 100644 --- a/libomp.spec +++ b/libomp.spec @@ -10,13 +10,14 @@ Name: libomp Version: 8.0.0 -Release: 1%{?rc_ver:.rc%{rc_ver}}%{?dist} +Release: 2%{?rc_ver:.rc%{rc_ver}}%{?dist} Summary: OpenMP runtime for clang License: NCSA URL: http://openmp.llvm.org Source0: http://%{?rc_ver:pre}releases.llvm.org/%{version}/%{?rc_ver:rc%{rc_ver}}/%{libomp_srcdir}.tar.xz -Source1: runtest.sh +Source1: run-lit-tests +Source2: lit.fedora.cfg.py Patch0: 0001-CMake-Make-LIBOMP_HEADERS_INSTALL_PATH-a-cache-varia.patch @@ -80,41 +81,26 @@ cd _build # Test package setup %global libomp_srcdir %{_datadir}/libomp/src/ %global libomp_testdir %{libomp_srcdir}/runtime/test/ -%global gcc_lit_cfg %{buildroot}%{libomp_testdir}/gcc.site.cfg -%global clang_lit_cfg %{buildroot}%{libomp_testdir}/clang.site.cfg +%global lit_cfg %{libomp_testdir}/%{_arch}.site.cfg.py +%global lit_fedora_cfg %{_datadir}/libomp/lit.fedora.cfg.py install -d %{buildroot}%{libomp_srcdir}/runtime cp -R runtime/test %{buildroot}%{libomp_srcdir}/runtime cp -R runtime/src %{buildroot}%{libomp_srcdir}/runtime -# Add symlinks to the libomp headers/library so gcc can find them. -ln -s %{_libdir}/clang/%{version}/include/omp.h %{buildroot}%{libomp_testdir}/omp.h -ln -s %{_libdir}/clang/%{version}/include/ompt.h %{buildroot}%{libomp_testdir}/ompt.h -ln -s %{_libdir}/libomp.so %{buildroot}%{libomp_testdir}/libgomp.so +# Generate lit config files. Strip off the last line that initiates the +# test run, so we can customize the configuration. +head -n -1 _build/runtime/test/lit.site.cfg >> %{buildroot}%{lit_cfg} -# Generic test config -echo "import tempfile" > %{gcc_lit_cfg} -cat _build/runtime/test/lit.site.cfg >> %{gcc_lit_cfg} -sed -i 's~\(config.test_filecheck = \)""~\1"%{_libdir}/llvm/FileCheck"~' %{gcc_lit_cfg} -sed -i 's~\(config.omp_header_directory = \)"[^"]\+"~\1"%{_includedir}"~' %{gcc_lit_cfg} -sed -i 's~\(config.libomp_obj_root = \)"[^"]\+"~\1tempfile.mkdtemp()[1]~' %{gcc_lit_cfg} -sed -i 's~\(lit_config.load_config(config, \)"[^"]\+"~\1"%{libomp_testdir}/lit.cfg"~' %{gcc_lit_cfg} +# Install custom fedora config file +cp %{SOURCE2} %{buildroot}%{lit_fedora_cfg} -# GCC config -# test_compiler_features was already populated with gcc information if gcc was used -# to compile libomp. -sed -i 's~\(config.test_c_compiler = \)"[^"]\+"~\1"%{_bindir}/gcc"~' %{gcc_lit_cfg} -sed -i 's~\(config.test_cxx_compiler = \)"[^"]\+"~\1"%{_bindir}/g++"~' %{gcc_lit_cfg} -sed -i 's~\(config.library_dir = \)"[^"]\+"~\1"%{libomp_testdir}"~' %{gcc_lit_cfg} +# Patch lit config files to load custom fedora config +echo "lit_config.load_config(config, '%{lit_fedora_cfg}')" >> %{buildroot}%{lit_cfg} -# Clang config -cp %{gcc_lit_cfg} %{clang_lit_cfg} -sed -i 's~\(config.test_compiler_features = \)\[[^\[]\+]~\1["clang"]~' %{clang_lit_cfg} -sed -i 's~\(config.test_c_compiler = \)"[^"]\+"~\1"%{_bindir}/clang"~' %{clang_lit_cfg} -sed -i 's~\(config.test_cxx_compiler = \)"[^"]\+"~\1"%{_bindir}/clang++"~' %{clang_lit_cfg} -sed -i 's~\(config.library_dir = \)"[^"]\+"~\1"%{_libdir}"~' %{clang_lit_cfg} - -install -m 0755 %{SOURCE1} %{buildroot}%{_datadir}/libomp +# Install test script +install -d %{buildroot}%{_libexecdir}/tests/libomp +install -m 0755 %{SOURCE1} %{buildroot}%{_libexecdir}/tests/libomp %files @@ -133,8 +119,12 @@ install -m 0755 %{SOURCE1} %{buildroot}%{_datadir}/libomp %files test %{_datadir}/libomp +%{_libexecdir}/tests/libomp/ %changelog +* Thu Apr 25 2019 Tom Stellard - 8.0.0-2 +- Simplify libomp-test package + * Wed Mar 20 2019 sguelton@redhat.com - 8.0.0-1 - 8.0.0 final diff --git a/lit.fedora.cfg.py b/lit.fedora.cfg.py new file mode 100644 index 0000000..10d1f1f --- /dev/null +++ b/lit.fedora.cfg.py @@ -0,0 +1,15 @@ +import tempfile + +compiler = '%(libomp_compiler)s' % lit_config.params +config.test_filecheck = '%(bindir)s/FileCheck' % lit_config.params +config.omp_header_directory = '%(includedir)s' % lit_config.params +config.libomp_obj_root = tempfile.mkdtemp() +config.library_dir = '%(libdir)s' % lit_config.params +test_root = '%(libomp_test_root)s' % lit_config.params + +# Lit will default to the compiler used to build openmp, which is gcc, but we +# want to run the tests using clang. +config.test_compiler_features = ['clang'] +config.test_c_compiler = 'clang' +config.test_cxx_compiler = 'clang++' +lit_config.load_config(config, '%(libomp_test_root)s/lit.cfg' % lit_config.params) diff --git a/run-lit-tests b/run-lit-tests new file mode 100644 index 0000000..18dbec5 --- /dev/null +++ b/run-lit-tests @@ -0,0 +1,59 @@ +#!/usr/bin/bash + +usage() { + echo "usage: `basename $0` [OPTIONS]" + echo " --threads NUM The number of threads to use for running tests." +} + + +threads_arg='' + +while [ $# -gt 0 ]; do + case $1 in + --threads) + shift + threads_arg="--threads $1" + ;; + --multilib-arch) + shift + ARCH=$1 + ;; + * ) + echo "unknown option: $1" + echo "" + usage + exit 1 + ;; + esac + shift +done + + +set -xe + +if [ -z "$ARCH" ]; then + ARCH=`rpm --eval '%_arch'` +fi + +case $ARCH in + arm) + ;& + i686) + LIB_DIR="/usr/lib/" + ;; + *) + LIB_DIR="/usr/lib64/" + ;; +esac + +BIN_DIR="/usr/bin/" +INCLUDE_DIR="/usr/include/" + +lit $threads_arg -v \ + --config-prefix $ARCH \ + -Dlibomp_compiler=clang \ + -Dbindir=$BIN_DIR \ + -Dlibdir=$LIB_DIR \ + -Dincludedir=$INCLUDE_DIR \ + -Dlibomp_test_root=/usr/share/libomp/src/runtime/test \ + /usr/share/libomp/src/runtime/test diff --git a/runtest.sh b/runtest.sh deleted file mode 100644 index 1e66f29..0000000 --- a/runtest.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -usage() { - echo "usage: `basename $0` [OPTIONS]" - echo " --threads NUM The number of threads to use for running tests." -} - - -threads_arg='' - -while [ $# -gt 0 ]; do - case $1 in - --threads) - shift - threads_arg="--threads $1" - ;; - * ) - echo "unknown option: $1" - echo "" - usage - exit 1 - ;; - esac - shift -done - - -set -x - -lit $threads_arg -v --config-prefix clang /usr/share/libomp/src/runtime/test -fail=$? -lit $threads_arg -v --config-prefix gcc /usr/share/libomp/src/runtime/test -exit $fail || $? diff --git a/tests/tests.yml b/tests/tests.yml index 073fba6..959ae53 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -8,4 +8,4 @@ tests: - libomp-regression-tests: dir: ./ - run: /usr/share/libomp/runtest.sh --threads 8 + run: /usr/libexec/tests/libomp/run-lit-tests --threads 8