lib: add fileutils file with stream error checking facility
The close_stream() is copied from GNU lib. Inspiration to do this is talk by Jim Meyering - Goodbye World! The perils of relying on output streams in C. Reference: http://www.irill.org/events/ghm-gnu-hackers-meeting/videos/jim-meyering-goodbye-world-the-perils-of-relying-on-output-streams-in-c Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
19
testsuite/lib.test/fileutils.exp
Normal file
19
testsuite/lib.test/fileutils.exp
Normal file
@ -0,0 +1,19 @@
|
||||
#
|
||||
# Testsuite for lib/fileutils program
|
||||
#
|
||||
|
||||
set noarg "${topdir}lib/test_fileutils"
|
||||
|
||||
set test "without argument"
|
||||
spawn $noarg
|
||||
expect_pass "$test" "Hello, World!"
|
||||
|
||||
set badfd "${topdir}testsuite/lib.test/fileutils_badfd.sh"
|
||||
set test "test bad file descriptor"
|
||||
spawn $badfd
|
||||
expect_pass "$test" "test_fileutils: write error: Bad file descriptor"
|
||||
|
||||
set full "${topdir}testsuite/lib.test/fileutils_full.sh"
|
||||
set test "test no space left on device"
|
||||
spawn $full
|
||||
expect_pass "$test" "test_fileutils: write error: No space left on device"
|
4
testsuite/lib.test/fileutils_badfd.sh
Executable file
4
testsuite/lib.test/fileutils_badfd.sh
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
BASEDIR=$(dirname ${0})
|
||||
${BASEDIR}/../../lib/test_fileutils >&-
|
4
testsuite/lib.test/fileutils_full.sh
Executable file
4
testsuite/lib.test/fileutils_full.sh
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
BASEDIR=$(dirname ${0})
|
||||
${BASEDIR}/../../lib/test_fileutils > /dev/full
|
Reference in New Issue
Block a user