Skip to content

Commit b29e7eb

Browse files
committed
tests: put test files in builddir/tests/ instead of srcdir/tests/
To make folder structure cleaner. Also change help message from .. termux-elf-cleaner .. to just .. elf-cleaner .., to make the tool even more general.
1 parent 99e14ec commit b29e7eb

File tree

3 files changed

+33
-26
lines changed

3 files changed

+33
-26
lines changed

tests/test-dynamic-section.sh

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -e
33

44
if [ $# != 5 ]; then
5-
echo "Usage path/to/test-dynamic-section.sh <termux-elf-cleaner> <source-dir> <binary-name> <arch> <api>"
5+
echo "Usage path/to/test-dynamic-section.sh <elf-cleaner> <source-dir> <binary-name> <arch> <api>"
66
exit 1
77
fi
88

@@ -11,35 +11,37 @@ source_dir="$2"
1111
binary_name="$3"
1212
arch="$4"
1313
api="$5"
14+
test_dir="$(dirname $1)/tests"
1415

1516
progname="$(basename "$elf_cleaner")"
1617
basefile="$source_dir/tests/$binary_name-$arch"
1718
origfile="$basefile-original"
18-
testfile="$basefile-api$api.test"
1919
expectedfile="$basefile-api$api-cleaned"
20+
testfile="$(basename $origfile)"
2021

2122
if [ "$api" = "21" ]; then
22-
expected_logs="$progname: Removing version section from '$testfile'
23-
$progname: Removing version section from '$testfile'
24-
$progname: Removing the DT_RUNPATH dynamic section entry from '$testfile'
25-
$progname: Removing the DT_VERNEEDNUM dynamic section entry from '$testfile'
26-
$progname: Removing the DT_VERNEED dynamic section entry from '$testfile'
27-
$progname: Removing the DT_VERSYM dynamic section entry from '$testfile'
28-
$progname: Replacing unsupported DF_1_* flags 134217737 with 1 in '$testfile'
29-
$progname: Removing the DT_GNU_HASH dynamic section entry from '$testfile'"
23+
expected_logs="$progname: Removing VERSYM section from '$test_dir/$testfile'
24+
$progname: Removing VERNEED section from '$test_dir/$testfile'
25+
$progname: Removing the DT_RUNPATH dynamic section entry from '$test_dir/$testfile'
26+
$progname: Removing the DT_VERNEEDNUM dynamic section entry from '$test_dir/$testfile'
27+
$progname: Removing the DT_VERNEED dynamic section entry from '$test_dir/$testfile'
28+
$progname: Removing the DT_VERSYM dynamic section entry from '$test_dir/$testfile'
29+
$progname: Replacing unsupported DF_1_* flags 134217737 with 1 in '$test_dir/$testfile'
30+
$progname: Removing the DT_GNU_HASH dynamic section entry from '$test_dir/$testfile'"
3031
elif [ "$api" = "24" ]; then
31-
expected_logs="$progname: Replacing unsupported DF_1_* flags 134217737 with 9 in '$testfile'"
32+
expected_logs="$progname: Replacing unsupported DF_1_* flags 134217737 with 9 in '$test_dir/$testfile'"
3233
else
3334
echo "Unknown API level $api"
3435
exit 1
3536
fi
3637

37-
cp "$origfile" "$testfile"
38-
if [ "$("$elf_cleaner" --api-level "$api" "$testfile")" != "$expected_logs" ]; then
38+
mkdir -p "$test_dir"
39+
cp "$origfile" "$test_dir/"
40+
if [ "$("$elf_cleaner" --api-level "$api" "$test_dir/$testfile")" != "$expected_logs" ]; then
3941
echo "Logs do not match for $testfile"
4042
exit 1
4143
fi
42-
if not cmp -s "$testfile" "$expectedfile"; then
44+
if not cmp -s "$test_dir/$testfile" "$expectedfile"; then
4345
echo "Expected and actual files differ for $testfile"
4446
exit 1
4547
fi

tests/test-threads.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,32 @@
22
set -e
33

44
if [ $# != 2 ]; then
5-
echo "Usage path/to/test-threads.sh <termux-elf-cleaner> <source-dir>"
5+
echo "Usage path/to/test-threads.sh <elf-cleaner> <source-dir>"
66
exit 1
77
fi
88

99
elf_cleaner="$1"
1010
source_dir="$2"
11+
test_dir="$(dirname $1)/tests"
1112

13+
mkdir -p "$test_dir"
1214
for i in {1..100}; do
1315
for arch in aarch64 arm i686 x86_64; do
1416
for api in 21 24; do
15-
cp "$source_dir/tests/curl-7.83.1-$arch-original" "$source_dir/tests/curl-8.83.1-$arch-api$api-threads-$i.test"
17+
cp "$source_dir/tests/curl-7.83.1-$arch-original" "$test_dir/curl-7.83.1-$arch-api$api-threads-$i.test"
1618
done
1719
done
1820
done
1921

2022
for api in 21 24; do
21-
"$elf_cleaner" --api-level "$api" --quiet --jobs 4 "$source_dir/tests/curl-8.83.1-"*"-api$api-threads"*".test"
23+
"$elf_cleaner" --api-level "$api" --quiet --jobs 4 "$test_dir/curl-7.83.1-"*"-api$api-threads"*".test"
2224
done
2325

2426
for i in {1..100}; do
2527
for arch in aarch64 arm i686 x86_64; do
2628
for api in 21 24; do
27-
if not cmp -s "$source_dir/tests/curl-7.83.1-$arch-api$api-cleaned" "$source_dir/tests/curl-8.83.1-$arch-api$api-threads-$i.test"; then
28-
echo "Expected and actual files differ for $source_dir/tests/curl-8.83.1-$arch-threads-$i.test"
29+
if not cmp -s "$source_dir/tests/curl-7.83.1-$arch-api$api-cleaned" "$test_dir/curl-7.83.1-$arch-api$api-threads-$i.test"; then
30+
echo "Expected and actual files differ for curl-7.83.1-$arch"
2931
exit 1
3032
fi
3133
done

tests/test-tls-alignment.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -e
33

44
if [ $# != 4 ]; then
5-
echo "Usage path/to/test-dynamic-section.sh <termux-elf-cleaner> <source-dir> <binary-name> <arch>"
5+
echo "Usage path/to/test-dynamic-section.sh <elf-cleaner> <source-dir> <binary-name> <arch>"
66
exit 1
77
fi
88

@@ -14,24 +14,27 @@ arch="$4"
1414
progname="$(basename "$elf_cleaner")"
1515
basefile="$source_dir/tests/$binary_name-$arch"
1616
origfile="$basefile-original"
17-
testfile="$basefile.test"
17+
testfile="$(basename $basefile).test"
1818
expectedfile="$basefile-tls-aligned"
19+
test_dir="$(dirname $1)/tests"
1920

2021
if [ "$arch" = "aarch64" ] || [ "$arch" = "x86_64" ]; then
21-
expected_logs="$progname: Changing TLS alignment for '$testfile' to 64, instead of 8"
22+
expected_logs="$progname: Changing TLS alignment for '$test_dir/$testfile' to 64, instead of 8"
2223
elif [ "$arch" = "arm" ] || [ "$arch" = "i686" ]; then
23-
expected_logs="$progname: Changing TLS alignment for '$testfile' to 32, instead of 8"
24+
expected_logs="$progname: Changing TLS alignment for '$test_dir/$testfile' to 32, instead of 8"
2425
else
2526
echo "Unknown architecture $arch"
2627
exit 1
2728
fi
2829

29-
cp "$origfile" "$testfile"
30-
if [ "$("$elf_cleaner" "$testfile")" != "$expected_logs" ]; then
30+
mkdir -p "$test_dir"
31+
cp "$origfile" "$test_dir/$testfile"
32+
# echo "$elf_cleaner" "$test_dir/$testfile"
33+
if [ "$("$elf_cleaner" "$test_dir/$testfile")" != "$expected_logs" ]; then
3134
echo "Logs do not match for $testfile"
3235
exit 1
3336
fi
34-
if not cmp -s "$testfile" "$expectedfile"; then
37+
if not cmp -s "$test_dir/$testfile" "$expectedfile"; then
3538
echo "Expected and actual files differ for $testfile"
3639
exit 1
3740
fi

0 commit comments

Comments
 (0)