diff --git a/tests/broken-symlinks/main.fmf b/tests/broken-symlinks/main.fmf new file mode 100644 index 0000000..ddb3fe5 --- /dev/null +++ b/tests/broken-symlinks/main.fmf @@ -0,0 +1,23 @@ +summary: Test that compiler-rt does not contain broken symlinks +tier: 1 +framework: beakerlib +require+: + - yum-utils + - python3-dnf + +link+: + - verifies: https://issues.redhat.com/browse/RHEL-7375 + +adjust+: + # Broken symlinks were fixed with Clang Resource directory moving in LLVM 17: + # https://fedoraproject.org/wiki/Changes/LLVM-17#Detailed_Description + # There are no plans to backport that, so we disable the test + # in distros where LLVM < 17. + - enabled: false + when: distro < rhel-8 + - enabled: false + when: distro == rhel-8 and distro <= rhel-8.9 + - enabled: false + when: distro == rhel-9 and distro <= rhel-9.3 + - enabled: false + when: distro == fedora and distro <= fedora-38 diff --git a/tests/broken-symlinks/test.sh b/tests/broken-symlinks/test.sh new file mode 100755 index 0000000..be1b66c --- /dev/null +++ b/tests/broken-symlinks/test.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +rlJournalStart + rlPhaseStartSetup + declare tmp + rlRun "tmp=$(mktemp -d)" 0 "Create a temp dir" + # Get the compiler-rt package name from the tmt required packages, which should + # address the issue of getting the correct name regardless it's a compat package + # or not. The package can be named either compiler-rt or compiler-rt[0-9]+ + rlRun "COMPILER_RT=$(rlGetYAMLdeps | tr ' ' '\n' | grep -E "compiler-rt[[:digit:]]*$")" + # Make sure to get only the main arch, so we can deal with multilib issues. + rlRun "COMPILER_RT_NVR=$(rpm -q "${COMPILER_RT}" | grep "$(uname -m)")" + # Use dnf repoquery --installed so we *don't* query any repos but the + # local rpm database instead. That should handle packages installed + # using rpm, that are not in repos, and avoid timeouts if repo connection + # is slow. + # dnf5 drops support of --resolve in favor of --providers-of= + # but --installed does query the repos anyway. In systems with dnf5 we + # fall back to dnf4 python bindings (using dnf-3) to workaround this. + # Check https://src.fedoraproject.org/tests/compiler-rt/issue/16 + rlRun "dnf-3 repoquery --installed --depends --resolve $COMPILER_RT_NVR > $tmp/dependencies.log" + rlPhaseEnd + + rlPhaseStartTest + for file in $(rpm -ql "$COMPILER_RT_NVR"); do + # Skip iteration if the file is not a symlink + [[ -L $file ]] || continue + + # Check if the symlink resolves to a valid file. If not, it's a failure + if [[ ! -e $file ]]; then + rlFail "$file is a dangling symlink" + continue + fi + + # Up to this point, the linked file exists. + # If the owner of the target compiler-rt package itself that's + # correct and we can skip to the next file. + target=$(readlink -f "$file") + OWNER_NVR=$(rpm -qf "$target") + [[ "$OWNER_NVR" == "$COMPILER_RT_NVR" ]] && continue + + # The target exists but it's not owned by compiler-rt. It must be + # owned by one of its dependencies, else flag a failure. + if ! grep "$OWNER_NVR" "$tmp/dependencies.log"; then + rlFail "$file pointing to $target is a dangling symlink owned by $OWNER_NVR" + fi + done + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "rm -rf $tmp" 0 "Removing temp dir" + rlPhaseEnd +rlJournalEnd diff --git a/tests/cross-compile-i686/main.fmf b/tests/cross-compile-i686/main.fmf new file mode 100644 index 0000000..3863a8c --- /dev/null +++ b/tests/cross-compile-i686/main.fmf @@ -0,0 +1,22 @@ +summary: compiler-rt test for rhbz#1678240 +description: > + Test that clang -m32 -fsanitize looks for compiler-rt library in the + proper directory +tier: 1 + +require+: + - compiler-rt.i686 + - glibc-devel.i686 +adjust+: + # Common requirements when LLVM is not SCL-ized + - enabled: false + because: "Test applicable only on x86_64 arch" + when: arch != x86_64 + + - enabled: false + because: "compiler-rt.i686 packages not shipped in RHEL/CentOS" + when: distro == rhel or distro == centos + + - enabled: false + because: "compiler-rt.i686 may not be available in snapshot builds when x86_64 tests are executed" + when: snapshot is defined diff --git a/tests/cross-compile-i686/test.c b/tests/cross-compile-i686/test.c new file mode 100644 index 0000000..2c99a52 --- /dev/null +++ b/tests/cross-compile-i686/test.c @@ -0,0 +1 @@ +int main(){return 0;} diff --git a/tests/cross-compile-i686/test.sh b/tests/cross-compile-i686/test.sh new file mode 100755 index 0000000..52a9e1f --- /dev/null +++ b/tests/cross-compile-i686/test.sh @@ -0,0 +1,3 @@ +#!/bin/sh -eux + +clang -m32 -fsanitize=address test.c diff --git a/tests/fp16-abi/main.fmf b/tests/fp16-abi/main.fmf new file mode 100644 index 0000000..30f884a --- /dev/null +++ b/tests/fp16-abi/main.fmf @@ -0,0 +1,7 @@ +summary: Test that Float16 ABI matches with clang +tier: 1 + +adjust+: + - because: "Float16 not supported on s390x or ppc64le" + enabled: false + when: arch == s390x or arch == ppc64le diff --git a/tests/fp16-abi/test.cpp b/tests/fp16-abi/test.cpp new file mode 100644 index 0000000..3c15ea1 --- /dev/null +++ b/tests/fp16-abi/test.cpp @@ -0,0 +1,14 @@ +// Reproducer based on this code from Steve Leung (evetsso): +// https://github.com/ROCmSoftwarePlatform/rocFFT/issues/439#issuecomment-1693835987 + +#include +#include +#include + +int main() +{ + _Float16 one_f16 = 0.123; + float one_f32 = one_f16; + std::cout << one_f32 << std::endl; + return 0; +} diff --git a/tests/fp16-abi/test.sh b/tests/fp16-abi/test.sh new file mode 100755 index 0000000..9079123 --- /dev/null +++ b/tests/fp16-abi/test.sh @@ -0,0 +1,15 @@ +#!/bin/bash -ux +# Do NOT set exit after error flag (set -e). Let all the optimizations to be run + +tmp=$(mktemp -d) +result=0 +# Test the reproducer with all the optimization levels +for opt_level in 0 1 2 3; do + clang++ --rtlib=compiler-rt -O$opt_level test.cpp -o "${tmp}/test_O${opt_level}" + "${tmp}/test_O${opt_level}" | grep '0.122986' || result=1 +done + +rm -rf "$tmp" +if [[ "$result" == 1 ]]; then + exit 1 +fi diff --git a/tests/sanity/main.fmf b/tests/sanity/main.fmf new file mode 100644 index 0000000..03ea1be --- /dev/null +++ b/tests/sanity/main.fmf @@ -0,0 +1,5 @@ +summary: compiler-rt sanity test with signed int overflow +tier: 1 +extra-summary: /tools/compiler-rt/sanity +extra-task: /tools/compiler-rt/sanity +extra-nitrate: TC#0614247 diff --git a/tests/sanity/test.sh b/tests/sanity/test.sh new file mode 100755 index 0000000..c91953b --- /dev/null +++ b/tests/sanity/test.sh @@ -0,0 +1,6 @@ +#!/bin/sh -eux + +clang -fsanitize=undefined -o test1 test1.c +./test1 2> test1.stderr +cat test1.stderr +grep "test1.c:3:5: runtime error: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'" test1.stderr diff --git a/tests/sanity/test1.c b/tests/sanity/test1.c new file mode 100644 index 0000000..3a3e5a4 --- /dev/null +++ b/tests/sanity/test1.c @@ -0,0 +1,5 @@ +int main(int argc, char **argv) { + int k = 0x7fffffff; + k += argc; + return 0; +}