Add error injection library

This commit is contained in:
Nicolas Williams committed 2015-05-11 21:36:46 -05:00
1 parent e3cb1f76cd
commit 821d6404b6
4 files changed
+141 -1

No files matched your search

+16
View File
@@ -31,6 +31,22 @@ if [ -z "$d" ]; then
exit 0
fi
if [ -f $PWD/.libs/libinject_errors.so ]; then
# Do some simple error injection tests to check that we're handling
# I/O errors correctly.
(
jq=$PWD/jq
libinject=$PWD/.libs/libinject_errors.so
cd $d
LD_PRELOAD=$libinject $jq . /dev/null
touch fail_read
LD_PRELOAD=$libinject $jq . fail_read && exit 2
touch fail_close
LD_PRELOAD=$libinject $jq . fail_close && exit 2
true
)
fi
printf 'a\0b\nc\0d\ne' > $d/input
$VALGRIND $Q ./jq -Rse '. == "a\u0000b\nc\u0000d\ne"' $d/input
$VALGRIND $Q ./jq -Rne '[inputs] == ["a\u0000b", "c\u0000d", "e"]' $d/input