From ece4019ae8f92e65dcbb49faef81dfdc0c9db3b5 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 19 Aug 2020 14:39:12 +0000 Subject: [PATCH] Fix broken CI Backport a few fixes from rawhide concerning tests setup and CI integration. --- ...g-directory-when-running-llvm-mc-in-.patch | 26 +++++++++++++++++++ lit.fedora.cfg.py | 1 + llvm.spec | 20 +++++++++++--- run-lit-tests | 1 + tests/libllvm-size/runtest.sh | 5 ++++ tests/regression-tests/runtest.sh | 16 ++++++++++++ tests/tests.yml | 8 ++---- 7 files changed, 68 insertions(+), 9 deletions(-) create mode 100644 0001-Normalize-working-directory-when-running-llvm-mc-in-.patch create mode 100644 tests/libllvm-size/runtest.sh create mode 100755 tests/regression-tests/runtest.sh diff --git a/0001-Normalize-working-directory-when-running-llvm-mc-in-.patch b/0001-Normalize-working-directory-when-running-llvm-mc-in-.patch new file mode 100644 index 0000000..2fca972 --- /dev/null +++ b/0001-Normalize-working-directory-when-running-llvm-mc-in-.patch @@ -0,0 +1,26 @@ +From bab5908df544680ada0a3cf431f55aeccfbdb321 Mon Sep 17 00:00:00 2001 +From: serge-sans-paille +Date: Mon, 13 Apr 2020 13:44:15 +0200 +Subject: [PATCH] Normalize working directory when running llvm-mc in test + +Otherwise, depending on the lit location used to run the test, llvm-mc adds an +include_directories entry in the dwarf output, which breaks tests in some setup. + +Differential Revision: https://reviews.llvm.org/D77876 +--- + llvm/test/MC/MachO/gen-dwarf.s | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/llvm/test/MC/MachO/gen-dwarf.s b/llvm/test/MC/MachO/gen-dwarf.s +index 0813856d625..6d39d278e81 100644 +--- a/llvm/test/MC/MachO/gen-dwarf.s ++++ b/llvm/test/MC/MachO/gen-dwarf.s +@@ -1,4 +1,4 @@ +-// RUN: llvm-mc -g -triple i386-apple-darwin10 %s -filetype=obj -o %t ++// RUN: mkdir -p %t0 && cd %t0 && llvm-mc -g -triple i386-apple-darwin10 %s -filetype=obj -o %t + // RUN: llvm-dwarfdump -all %t | FileCheck %s + + .globl _bar +-- +2.25.2 + diff --git a/lit.fedora.cfg.py b/lit.fedora.cfg.py index 1c918b4..99bf867 100644 --- a/lit.fedora.cfg.py +++ b/lit.fedora.cfg.py @@ -1,5 +1,6 @@ config.llvm_tools_dir = '/usr/bin' +config.llvm_src_root = '/usr/share/llvm/src' config.llvm_shlib_dir = '%(llvm_shlib_dir)s' % lit_config.params if hasattr(config, 'host_triple'): diff --git a/llvm.spec b/llvm.spec index 710d355..d0f6e9f 100644 --- a/llvm.spec +++ b/llvm.spec @@ -65,6 +65,8 @@ Patch1: 0001-CMake-Split-test-binary-exports-into-their-own-expor.patch # https://bugzilla.redhat.com/show_bug.cgi?id=1862012 Patch2: 0001-PowerPC-PPCBoolRetToInt-Don-t-translate-Constant-s-o.patch +Patch4: 0001-Normalize-working-directory-when-running-llvm-mc-in-.patch + BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: cmake @@ -296,10 +298,21 @@ install -d %{install_srcdir} install -d %{install_srcdir}/utils/ cp -R utils/unittest %{install_srcdir}/utils/ -# Generate lit config files. Strip off the last line that initiates the +# Clang needs these for running lit tests. +for f in utils/*.py; do + sed '1 s|^.*$|#!/usr/bin/env python3|' $f > %{install_srcdir}/$f +done +cp -R utils/UpdateTestChecks %{install_srcdir}/utils/ + + +# One of the lit tests references this file +install -d %{install_srcdir}/docs/CommandGuide/ +install -m 0644 docs/CommandGuide/dsymutil.rst %{install_srcdir}/docs/CommandGuide/ + +# Generate lit config files. Strip off the last lines that initiates the # test run, so we can customize the configuration. -head -n -1 _build/test/lit.site.cfg.py >> %{lit_cfg} -head -n -1 _build/test/Unit/lit.site.cfg.py >> %{lit_unit_cfg} +head -n -2 _build/test/lit.site.cfg.py >> %{lit_cfg} +head -n -2 _build/test/Unit/lit.site.cfg.py >> %{lit_unit_cfg} # Install custom fedora config file cp %{SOURCE2} %{buildroot}%{lit_fedora_cfg} @@ -472,6 +485,7 @@ fi %{_datadir}/llvm/src/unittests %{_datadir}/llvm/src/test.tar.gz %{_datadir}/llvm/lit.fedora.cfg.py +%{_datadir}/llvm/src/docs/CommandGuide/dsymutil.rst %{_bindir}/not %{_bindir}/count %{_bindir}/yaml-bench diff --git a/run-lit-tests b/run-lit-tests index a0f27d8..676a770 100755 --- a/run-lit-tests +++ b/run-lit-tests @@ -48,6 +48,7 @@ esac cd $(mktemp -d) ln -s /usr/include include +ln -s /usr/share/llvm/src/docs docs tar -xzf /usr/share/llvm/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 diff --git a/tests/libllvm-size/runtest.sh b/tests/libllvm-size/runtest.sh new file mode 100644 index 0000000..ae58ef3 --- /dev/null +++ b/tests/libllvm-size/runtest.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +set -ex + +test `stat -L -c %s /usr/lib64/libLLVM.so` -lt 100000000 diff --git a/tests/regression-tests/runtest.sh b/tests/regression-tests/runtest.sh new file mode 100755 index 0000000..42aa9b5 --- /dev/null +++ b/tests/regression-tests/runtest.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -ex + +cmd='/usr/libexec/tests/llvm/run-lit-tests --threads 1' +if [ `id -u` -eq 0 ]; then + # lit tests can't be run as root, so we need to run as a different user + user='llvm-regression-tests' + if ! id -u $user; then + useradd $user + fi + su $user -c "$cmd" + cmd="su $user -c $cmd" +else + exec $cmd +fi diff --git a/tests/tests.yml b/tests/tests.yml index e17357f..2d67814 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -8,9 +8,7 @@ - rust - cargo tests: - - regression-tests: - dir: ./ - run: /usr/libexec/tests/llvm/run-lit-tests --threads 1 + - regression-tests - rust-sanity: dir: ./ run: cargo new hello && cd hello && cargo run @@ -20,9 +18,7 @@ # which breaks the nightly compose. So this test checks that libLLVM.so # is less than 100MB to ensure it was successfully stripped. # https://bugzilla.redhat.com/show_bug.cgi?id=1793250 - - libllvm-size: - dir: ./ - run: test `stat -L -c %s /usr/lib64/libLLVM.so` -lt 100000000 + - libllvm-size # This test ensures that the spec file still builds correctly with # %global compat_build 1 # FIXME: This fails, because the CI system has a hard-coded timeout of 4