Merge remote-tracking branch 'compiler-rt/main' into merge-test-repos

This commit is contained in:
Jesus Checa Hidalgo 2024-12-20 11:17:57 +01:00
commit 4ff8a6a55f
11 changed files with 156 additions and 0 deletions

View file

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

55
tests/broken-symlinks/test.sh Executable file
View file

@ -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=<attribute>
# 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

View file

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

View file

@ -0,0 +1 @@
int main(){return 0;}

View file

@ -0,0 +1,3 @@
#!/bin/sh -eux
clang -m32 -fsanitize=address test.c

7
tests/fp16-abi/main.fmf Normal file
View file

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

14
tests/fp16-abi/test.cpp Normal file
View file

@ -0,0 +1,14 @@
// Reproducer based on this code from Steve Leung (evetsso):
// https://github.com/ROCmSoftwarePlatform/rocFFT/issues/439#issuecomment-1693835987
#include <iostream>
#include <algorithm>
#include <vector>
int main()
{
_Float16 one_f16 = 0.123;
float one_f32 = one_f16;
std::cout << one_f32 << std::endl;
return 0;
}

15
tests/fp16-abi/test.sh Executable file
View file

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

5
tests/sanity/main.fmf Normal file
View file

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

6
tests/sanity/test.sh Executable file
View file

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

5
tests/sanity/test1.c Normal file
View file

@ -0,0 +1,5 @@
int main(int argc, char **argv) {
int k = 0x7fffffff;
k += argc;
return 0;
}