diff --git a/lit.lld-test.cfg.py b/lit.lld-test.cfg.py new file mode 100644 index 0000000..10d165b --- /dev/null +++ b/lit.lld-test.cfg.py @@ -0,0 +1,12 @@ +#Clear lld_tools_dir so we don't accidently pick up tools from somewhere else +config.lld_tools_dir = "" + +if hasattr(config, 'have_zlib'): + # Regression tests write output to this directory, so we need to be able to specify + # a temp directory when invoking lit. e.g. lit -Dlld_obj_root=/tmp/lit + config.lld_obj_root = "%(lld_obj_root)s" % lit_config.params + lit_config.load_config(config, '%(lld_test_root)s/lit.cfg.py' % lit_config.params) +else: + # For unit tests, llvm_obj_root is used to find the unit test binaries. + config.lld_obj_root = '%(lld_unittest_bindir)s' % lit_config.params + lit_config.load_config(config, '%(lld_test_root)s/Unit/lit.cfg.py' % lit_config.params) diff --git a/lld.spec b/lld.spec index 8d8589e..7a1a7e0 100644 --- a/lld.spec +++ b/lld.spec @@ -1,15 +1,22 @@ #%%global rc_ver 3 -%global baserelease 2 +%global baserelease 3 %global lld_srcdir lld-%{version}%{?rc_ver:rc%{rc_ver}}.src +%global maj_ver 9 + +# Don't include unittests in automatic generation of provides or requires. +%global __provides_exclude_from ^%{_libdir}/lld/.*$ +%global __requires_exclude ^libgtest.*$ Name: lld -Version: 9.0.0 +Version: %{maj_ver}.0.0 Release: %{baserelease}%{?rc_ver:.rc%{rc_ver}}%{?dist} Summary: The LLVM Linker License: NCSA URL: http://llvm.org Source0: http://%{?rc_ver:pre}releases.llvm.org/%{version}/%{?rc_ver:rc%{rc_ver}}/%{lld_srcdir}.tar.xz +Source1: run-lit-tests +Source2: lit.lld-test.cfg.py Patch0: 0001-CMake-Check-for-gtest-headers-even-if-lit.py-is-not-.patch @@ -49,6 +56,15 @@ Summary: LLD shared libraries %description libs Shared libraries for LLD. +%package test +Summary: LLD regression tests +Requires: %{name}%{?_isa} = %{version}-%{release} +Requires: python3-lit +Requires: llvm-test(major) = %{maj_ver} + +%description test +LLVM regression tests. + %prep %autosetup -n %{name}-%{version}%{?rc_ver:rc%{rc_ver}}.src -p1 @@ -74,7 +90,41 @@ cd %{_target_platform} %make_build +# Build the unittests so we can install them. +%make_build lld-test-depends + %install + +%global lit_cfg test/%{_arch}.site.cfg.py +%global lit_unit_cfg test/Unit/%{_arch}.site.cfg.py +%global lit_lld_test_cfg_install_path %{_datadir}/lld/lit.lld-test.cfg.py + +# Generate lit config files. Strip off the last line that initiates the +# test run, so we can customize the configuration. +head -n -1 %{_target_platform}/test/lit.site.cfg.py >> %{lit_cfg} +head -n -1 %{_target_platform}/test/Unit/lit.site.cfg.py >> %{lit_unit_cfg} + +# Patch lit config files to load custom config: +for f in %{lit_cfg} %{lit_unit_cfg}; do + echo "lit_config.load_config(config, '%{lit_lld_test_cfg_install_path}')" >> $f +done + +# Install test files +install -d %{buildroot}%{_datadir}/lld/src +cp %{SOURCE2} %{buildroot}%{_datadir}/lld/ + +tar -czf %{buildroot}%{_datadir}/lld/src/test.tar.gz test/ +install -d %{buildroot}%{_libexecdir}/tests/lld +cp %{SOURCE1} %{buildroot}%{_libexecdir}/tests/lld + +# Install unit test binaries +install -d %{buildroot}%{_libdir}/lld/ +cp -R %{_target_platform}/unittests %{buildroot}%{_libdir}/lld/ + +# Install gtest libraries +cp %{_target_platform}/%{_lib}/libgtest*so* %{buildroot}%{_libdir}/lld/ + +# Install libraries and binaries cd %{_target_platform} %make_install @@ -117,7 +167,16 @@ make -C %{_target_platform} %{?_smp_mflags} check-lld %files libs %{_libdir}/liblld*.so.* +%files test +%{_libexecdir}/tests/lld/ +%{_libdir}/lld/ +%{_datadir}/lld/src/test.tar.gz +%{_datadir}/lld/lit.lld-test.cfg.py + %changelog +* Thu Dec 05 2019 Tom Stellard - 9.0.0-3 +- Add lld-test package + * Thu Nov 14 2019 Tom Stellard - 9.0.0-2 - Add explicit lld-libs requires to fix rpmdiff errors diff --git a/run-lit-tests b/run-lit-tests new file mode 100755 index 0000000..7b92d2e --- /dev/null +++ b/run-lit-tests @@ -0,0 +1,66 @@ +#!/bin/bash + +usage() { + cat << EOF +usage: `basename $0` [OPTIONS] + --threads NUM The number of threads to use for running tests. + --multilib-arch ARCH Use this option to test 32-bit libs/binaries on + 64-bit hosts. +EOF +} + +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 + +if [ `whoami` = "root" ]; then + echo "error: lld tests do not support running as root." + exit 1 +fi + +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 + +cd $(mktemp -d) +ln -s /usr/include include +tar -xzf /usr/share/lld/src/test.tar.gz +ln -s $ARCH.site.cfg.py test/lit.site.cfg.py +ln -s $ARCH.site.cfg.py test/Unit/lit.site.cfg.py + +LD_LIBRARY_PATH=$LIB_DIR/lld:$LD_LIBRARY_PATH \ +lit -v -s $threads_arg test \ + -Dlld_obj_root=`pwd` \ + -Dlld_test_root=`pwd`/test \ + -Dlld_unittest_bindir=$LIB_DIR/lld diff --git a/tests/lit-tests/runtest.sh b/tests/lit-tests/runtest.sh new file mode 100644 index 0000000..28d4389 --- /dev/null +++ b/tests/lit-tests/runtest.sh @@ -0,0 +1,6 @@ + +if ! `id -u lld`; then + useradd lld +fi + +su lld -c /usr/libexec/tests/lld/run-lit-tests diff --git a/tests/tests.yml b/tests/tests.yml index 2b4b0eb..8bc1fc9 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -7,6 +7,7 @@ - lld - clang - gcc + - lld-test tests: - basic: dir: ./ @@ -14,3 +15,4 @@ - gcc-compat-basic: dir: ./ run: echo "int main(){ return 0; }" | gcc -x c -fuse-ld=lld - + - lit-tests