#7 Add lld-test sub-package
Opened 2 months ago by tstellar. Modified 2 months ago
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
+56 -1

@@ -1,14 +1,20 @@ 

  #%%global rc_ver 4

  %global lld_srcdir lld-%{version}%{?rc_ver:rc%{rc_ver}}.src

  

+ # Don't include unittests in automatic generation of provides or requires.

+ %global __provides_exclude_from ^%{_libdir}/lld/.*$

+ %global __requires_exclude ^libgtest.*$

+ 

  Name:		lld

  Version:	8.0.0

- Release:	1%{?rc_ver:.rc%{rc_ver}}%{?dist}

+ Release:	2%{?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.fedora.cfg.py

  

  Patch0:		0001-CMake-Check-for-gtest-headers-even-if-lit.py-is-not-.patch

  Patch1:		0001-lld-Prefer-using-the-newest-installed-python-version.patch

@@ -43,6 +49,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) = 8

+ 

+ %description test

+ LLVM regression tests.

+ 

  %prep

  %autosetup -n %{name}-%{version}%{?rc_ver:rc%{rc_ver}}.src -p1

  

@@ -68,7 +83,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_fedora_cfg_install_path %{_datadir}/lld/lit.fedora.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 fedora config:

+ for f in %{lit_cfg} %{lit_unit_cfg}; do

+   echo "lit_config.load_config(config, '%{lit_fedora_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

  

@@ -99,6 +148,12 @@ 

  %files libs

  %{_libdir}/liblld*.so.*

  

+ %files test

+ %{_libexecdir}/tests/lld/

+ %{_libdir}/lld/

+ %{_datadir}/lld/src/test.tar.gz

+ %{_datadir}/lld/lit.fedora.cfg.py

+ 

  %changelog

  * Wed Mar 20 2019 sguelton@redhat.com - 8.0.0-1

  - 8.0.0 final

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

file modified
+4

@@ -7,6 +7,7 @@ 

        - lld

        - clang

        - gcc

+       - lld-test

      tests:

        - basic:

            dir: ./

@@ -14,3 +15,6 @@ 

        - gcc-compat-basic:

            dir: ./

            run: echo "int main(){ return 0; }" | gcc -x c -fuse-ld=lld -

+       - lit-tests:

+           dir: ./

+           run: /usr/libexec/tests/lld/run-lit-tests --threads 1

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 fb68855

2 months ago

rebased onto 986d210

2 months ago