#7 Add lld-test sub-package
Merged 4 years ago by tstellar. Opened 4 years ago by tstellar.
rpms/ tstellar/lld lld-test  into  master

file added
+12
@@ -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)

file modified
+61 -2
@@ -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 @@ 

  %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 @@ 

  

  %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 @@ 

  %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 <tstellar@redhat.com> - 9.0.0-3

+ - Add lld-test package

+ 

  * Thu Nov 14 2019 Tom Stellard <tstellar@redhat.com> - 9.0.0-2

  - Add explicit lld-libs requires to fix rpmdiff errors

  

file added
+66
@@ -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

@@ -0,0 +1,6 @@ 

+ 

+ if ! `id -u lld`; then

+ 	useradd lld

+ fi

+ 

+ su lld -c /usr/libexec/tests/lld/run-lit-tests

file modified
+2
@@ -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

no initial comment

[nit] I personnaly prefer
```
cat << EOF
stuff
other stuff
EOF

should you bind to same version here? It's probably safer if changes occur in FileCheck etc.

should you bind to same version here? It's probably safer if changes occur in FileCheck etc.

That's a good idea. The problem now is that if we bind it to llvm-test-8.0.0 for example, then an upgrade to llvm-8.0.1 will break this dependency, which we don't want.

I can add a virtual provides for the major version to llvm, so we could version lock to llvm-test-8. We already do this for clang: https://src.fedoraproject.org/rpms/clang/blob/master/f/clang.spec#_130

rebased onto fb68855161808421de7bd0c513a2b2c5ed111030

4 years ago

rebased onto 986d2103c922c119bae51d7fea1e784618f866f9

4 years ago

rebased onto d96f882cf4f5c6d74ddbcc8db9b0bc7a27459546

4 years ago

rebased onto fed3aaea92ed3e038c07df4a45945873e39fa1fc

4 years ago

rebased onto d126f1b1718ddebf4520b40c780aca95d3c92edb

4 years ago

rebased onto 4b356773ffc2353194a3c9dd9db14c8051cc0d59

4 years ago

rebased onto 082ce89a038c92c1fb5ff310f4bec98c750b64b7

4 years ago

rebased onto 8e06ac165ee1af77386492b4e19e03f3c816e73f

4 years ago

rebased onto 40ade1554152db72566082ebc445207740f481e6

4 years ago

rebased onto 9747614

4 years ago

Pull-Request has been merged by tstellar

4 years ago