-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
regress/infra-unittests: add test for larger_symbol_version.awk
- Loading branch information
Showing
1 changed file
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#! /bin/sh | ||
# $NetBSD: scripts-larger_symbol_version.sh,v 1.1 2020/06/06 14:02:18 rillig Exp $ | ||
# | ||
# Tests for mk/scripts/larger_symbol_version.awk. | ||
# | ||
|
||
set -eu | ||
|
||
. './test.subr' | ||
|
||
test_case_set_up() { | ||
# nm -D /usr/lib/libgcc_s.so, on NetBSD 8.0. | ||
create_file 'nm-output' <<-EOF | ||
... | ||
0000000000000000 A GCC_3.0 | ||
0000000000000000 A GCC_3.3 | ||
0000000000000000 A GCC_3.3.1 | ||
0000000000000000 A GCC_3.4 | ||
0000000000000000 A GCC_3.4.2 | ||
0000000000000000 A GCC_3.4.4 | ||
... | ||
0000000000000000 A GCC_4.0.0 | ||
0000000000000000 A GCC_4.7.0 | ||
... | ||
w _Jv_RegisterClasses | ||
000000000000b852 T _Unwind_Backtrace | ||
000000000000b83e T _Unwind_DeleteException | ||
0000000000009a45 T _Unwind_FindEnclosingFunction | ||
U abort | ||
U calloc | ||
... | ||
EOF | ||
|
||
nm_cmd=$(mock_cmd mock-nm \ | ||
--when-args '-D /usr/lib/libgcc_s.so' \ | ||
--then-output "$(cat nm-output)" | ||
) | ||
} | ||
|
||
|
||
if test_case_begin 'library newer than target'; then | ||
|
||
create_file_lines 'shared-libs' \ | ||
'/usr/lib/libgcc_s.so 3.5' | ||
|
||
env NM="$nm_cmd" \ | ||
awk -f "$pkgsrcdir/mk/scripts/larger_symbol_version.awk" \ | ||
0<'shared-libs' 1>"$tmpdir/output" 2>&1 \ | ||
&& exitcode=0 || exitcode=$? | ||
|
||
assert_that "$tmpdir/output" --file-is-lines \ | ||
'the version of /usr/lib/libgcc_s.so is newer than target version 3.5' | ||
assert_that "$exitcode" --equals '0' | ||
|
||
test_case_end | ||
fi | ||
|
||
|
||
if test_case_begin 'library equal to target'; then | ||
|
||
create_file_lines 'shared-libs' \ | ||
'/usr/lib/libgcc_s.so 4.7' | ||
|
||
env NM="$nm_cmd" \ | ||
awk -f "$pkgsrcdir/mk/scripts/larger_symbol_version.awk" \ | ||
0<'shared-libs' 1>"$tmpdir/output" 2>&1 \ | ||
&& exitcode=0 || exitcode=$? | ||
|
||
assert_that "$tmpdir/output" --file-is-lines \ | ||
'the version of /usr/lib/libgcc_s.so is older or equal to target version 4.7' | ||
assert_that "$exitcode" --equals '0' | ||
|
||
test_case_end | ||
fi | ||
|
||
|
||
if test_case_begin 'library older than target'; then | ||
|
||
create_file_lines 'shared-libs' \ | ||
'/usr/lib/libgcc_s.so 8.0' | ||
|
||
env NM="$nm_cmd" \ | ||
awk -f "$pkgsrcdir/mk/scripts/larger_symbol_version.awk" \ | ||
0<'shared-libs' 1>"$tmpdir/output" 2>&1 \ | ||
&& exitcode=0 || exitcode=$? | ||
|
||
assert_that "$tmpdir/output" --file-is-lines \ | ||
'the version of /usr/lib/libgcc_s.so is older or equal to target version 8.0' | ||
assert_that "$exitcode" --equals '0' | ||
|
||
test_case_end | ||
fi |