2
2
set -e
3
3
4
4
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>"
6
6
exit 1
7
7
fi
8
8
@@ -11,35 +11,37 @@ source_dir="$2"
11
11
binary_name=" $3 "
12
12
arch=" $4 "
13
13
api=" $5 "
14
+ test_dir=" $( dirname $1 ) /tests"
14
15
15
16
progname=" $( basename " $elf_cleaner " ) "
16
17
basefile=" $source_dir /tests/$binary_name -$arch "
17
18
origfile=" $basefile -original"
18
- testfile=" $basefile -api$api .test"
19
19
expectedfile=" $basefile -api$api -cleaned"
20
+ testfile=" $( basename $origfile ) "
20
21
21
22
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 '"
30
31
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 '"
32
33
else
33
34
echo " Unknown API level $api "
34
35
exit 1
35
36
fi
36
37
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
39
41
echo " Logs do not match for $testfile "
40
42
exit 1
41
43
fi
42
- if not cmp -s " $testfile " " $expectedfile " ; then
44
+ if not cmp -s " $test_dir / $ testfile" " $expectedfile " ; then
43
45
echo " Expected and actual files differ for $testfile "
44
46
exit 1
45
47
fi
0 commit comments