commit: f1473139472b77885d17792cb588d6cb56bd63e7
parent 6d2b67b1652288039271c29082b2bfe71ee28f7f
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Tue, 15 Feb 2022 01:56:39 +0100
test-bin/strings: devfull + noperm
Diffstat:
1 file changed, 27 insertions(+), 0 deletions(-)
diff --git a/test-bin/strings b/test-bin/strings
@@ -27,6 +27,30 @@ devnull_body() {
atf_check ../bin/strings - </dev/null
}
+atf_test_case devfull
+devfull_body() {
+ if test -f /usr/include/features.h && grep -q '#define\W__GLIBC__' /usr/include/features.h
+ then
+ atf_expect_fail "glibc ignoring write errors for puts()"
+ fi
+ [ "$(uname -s)" = "NetBSD" ] && atf_expect_fail "NetBSD ignoring write errors for puts()"
+ [ "$(uname -s)" = "FreeBSD" ] && atf_expect_fail "FreeBSD ignoring write errors for puts()"
+
+ atf_check -s exit:1 -e 'inline:\nError writing: No space left on device\n' sh -c '../bin/strings inputs/strings/true >/dev/full'
+}
+
+atf_test_case noperm cleanup
+noperm_body() {
+ touch inputs/chmod_000 || atf_fail "touching chmod_000"
+ chmod 0000 inputs/chmod_000 || atf_fail "chmod 0000 chmod_000"
+ # shellcheck disable=SC1112
+ atf_check -s exit:1 -e 'inline:\nError opening ‘inputs/chmod_000’: Permission denied\n' ../bin/strings inputs/chmod_000
+}
+noperm_cleanup() {
+ chmod 0600 inputs/chmod_000 || atf_fail "chmod 0600 chmod_000"
+ rm inputs/chmod_000 || atf_fail "rm chmod_000"
+}
+
atf_test_case octalformat
octalformat_body() {
atf_check -o file:outputs/strings/all_bytes_to ../bin/strings -to inputs/all_bytes
@@ -59,6 +83,9 @@ atf_init_test_cases() {
atf_add_test_case true8elf
atf_add_test_case devnull
+ atf_add_test_case devfull
+ atf_add_test_case noperm
+
atf_add_test_case octalformat
atf_add_test_case hexformat
atf_add_test_case decformat