summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2020-06-06 14:02:18 +0000
committerrillig <rillig@pkgsrc.org>2020-06-06 14:02:18 +0000
commitd54f59f2c2a533deb68d1fee7b1be1fe3b4b8155 (patch)
tree5212f57aa04fdb906137e9ec777ace17ab3ff6f0 /regress
parentede28e2ba83902057226a8b5c33b787907312112 (diff)
downloadpkgsrc-d54f59f2c2a533deb68d1fee7b1be1fe3b4b8155.tar.gz
regress/infra-unittests: add test for larger_symbol_version.awk
Diffstat (limited to 'regress')
-rw-r--r--regress/infra-unittests/scripts-larger_symbol_version.sh92
1 files changed, 92 insertions, 0 deletions
diff --git a/regress/infra-unittests/scripts-larger_symbol_version.sh b/regress/infra-unittests/scripts-larger_symbol_version.sh
new file mode 100644
index 00000000000..d0e203d7d5a
--- /dev/null
+++ b/regress/infra-unittests/scripts-larger_symbol_version.sh
@@ -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