commit: c2d7a07f2d320776754bc163f8a123c3667234f7
parent 65449f6f8436ecf585e5ea3952bcdf7216629b5f
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Sun, 13 Feb 2022 05:48:05 +0100
bin/basename: Fix check on puts()
Diffstat:
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/bin/basename.c b/bin/basename.c
@@ -44,7 +44,7 @@ main(int argc, char *argv[])
default: fprintf(stderr, "usage: basename string [suffix]\n"); return 1;
}
- if(ret <= 0)
+ if(ret < 0)
{
perror("basename: puts");
return 1;
diff --git a/test-bin/basename b/test-bin/basename
@@ -32,9 +32,11 @@ usage_body() {
atf_test_case devfull
devfull_body() {
- atf_check -s exit:1 -e 'inline:Error writing: No space left on device\n' sh -c '../bin/basename >/dev/full'
- atf_check -s exit:1 -e 'inline:Error writing: No space left on device\n' sh -c '../bin/basename "/usr/bin" >/dev/full'
- atf_check -s exit:1 -e 'inline:Error writing: No space left on device\n' sh -c '../bin/baename "/usr//bin-test" "-test" >/dev/full'
+ grep '#define\W__GLIBC__' /usr/include/features.h && atf_expect_fail "glibc ignoring write errors for puts()"
+
+ atf_check -s exit:1 -e 'inline:basename: puts: No space left on device\n' sh -c '../bin/basename >/dev/full'
+ atf_check -s exit:1 -e 'inline:basename: puts: No space left on device\n' sh -c '../bin/basename "/usr/bin" >/dev/full'
+ atf_check -s exit:1 -e 'inline:basename: puts: No space left on device\n' sh -c '../bin/baename "/usr//bin-test" "-test" >/dev/full'
}
atf_test_case nullarg
@@ -53,7 +55,7 @@ atf_init_test_cases() {
atf_add_test_case usage
# puts in glibc doesn't returns -1 on failure
- #atf_add_test_case devfull
+ atf_add_test_case devfull
# Broken behavior in ATF, might be caused by stripping out \x00
#atf_add_test_case nullarg