summaryrefslogtreecommitdiffstats
path: root/tests.sh
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2022-02-11 12:16:52 -0500
committerTavian Barnes <tavianator@tavianator.com>2022-02-11 12:32:34 -0500
commit695ea13d191c903b86b0d5795a2686a8c6e18015 (patch)
tree92bdf1115f88cec1e41b5e08bea8bce02dd43981 /tests.sh
parent6ef15e033f997a41c783f87a7084e0aee05c42f9 (diff)
downloadbfs-695ea13d191c903b86b0d5795a2686a8c6e18015.tar.xz
exec: Flush I/O streams before executing anything
Otherwise output from commands may appear unexpectedly earlier than output from bfs. We use fflush(NULL) to flush all streams, which is more than GNU find does, but seems to be a useful extension.
Diffstat (limited to 'tests.sh')
-rwxr-xr-xtests.sh38
1 files changed, 37 insertions, 1 deletions
diff --git a/tests.sh b/tests.sh
index 25517ca..ed502fd 100755
--- a/tests.sh
+++ b/tests.sh
@@ -2,7 +2,7 @@
############################################################################
# bfs #
-# Copyright (C) 2015-2021 Tavian Barnes <tavianator@tavianator.com> #
+# Copyright (C) 2015-2022 Tavian Barnes <tavianator@tavianator.com> #
# #
# Permission to use, copy, modify, and/or distribute this software for any #
# purpose with or without fee is hereby granted. #
@@ -492,6 +492,12 @@ gnu_tests=(
test_exec_nothing
test_exec_substring
+ test_exec_flush
+ test_exec_flush_fail
+ test_exec_flush_fprint
+ test_exec_flush_fprint_fail
+ test_exec_plus_flush
+ test_exec_plus_flush_fail
test_execdir
test_execdir_substring
@@ -1754,6 +1760,36 @@ function test_exec_substring() {
bfs_diff basic -exec echo '-{}-' ';'
}
+function test_exec_flush() {
+ # IO streams should be flushed before executing programs
+ bfs_diff basic -printf '%p ' -exec echo found \;
+}
+
+function test_exec_flush_fail() {
+ # Failure to flush streams before exec should be caught
+ skip_if test ! -e /dev/full
+ fail quiet invoke_bfs basic -printf '%p ' -exec true \; >/dev/full
+}
+
+function test_exec_flush_fprint() {
+ # Even non-stdstreams should be flushed
+ bfs_diff basic/a -fprint scratch/foo -exec cat scratch/foo \;
+}
+
+function test_exec_flush_fprint_fail() {
+ skip_if test ! -e /dev/full
+ fail quiet invoke_bfs basic/a -fprint /dev/full -exec true \;
+}
+
+function test_exec_plus_flush() {
+ bfs_diff basic/a -printf '%p ' -exec echo found {} +
+}
+
+function test_exec_plus_flush_fail() {
+ skip_if test ! -e /dev/full
+ fail quiet invoke_bfs basic/a -printf '%p ' -exec echo found {} + >/dev/full
+}
+
function test_execdir() {
bfs_diff basic -execdir echo '{}' ';'
}