aboutsummaryrefslogtreecommitdiff
path: root/tests/find.test
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-09-20 13:09:14 -0500
committerRob Landley <rob@landley.net>2014-09-20 13:09:14 -0500
commit387edf547eb09b27ca6d49772eb048d729f09cf4 (patch)
tree59d482f33735690cab6d90723393afa1e2c8dce5 /tests/find.test
parentd3df423a6cde0c6282658ff628574771d3824d71 (diff)
downloadtoybox-387edf547eb09b27ca6d49772eb048d729f09cf4.tar.gz
Move testsuite out of scripts/test into its own top level tests directory, and make ctrl-c kill "make test" more reliably.
Diffstat (limited to 'tests/find.test')
-rw-r--r--tests/find.test42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/find.test b/tests/find.test
new file mode 100644
index 00000000..cbbce5fd
--- /dev/null
+++ b/tests/find.test
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+[ -f testing.sh ] && . testing.sh
+
+mkdir dir
+cd dir
+touch file
+mkfifo fifo
+ln -s fifo link
+cd ..
+
+#testing "name" "command" "result" "infile" "stdin"
+
+# Testing operators
+
+testing "find -type l -a -type d -o -type p" \
+ "find dir -type l -a -type d -o -type p" "dir/fifo\n" "" ""
+testing "find -type l -type d -o -type p" "find dir -type l -type d -o -type p" \
+ "dir/fifo\n" "" ""
+testing "find -type l -o -type d -a -type p" \
+ "find dir -type l -o -type d -a -type p" "dir/link\n" "" ""
+testing "find -type l -o -type d -type p" "find dir -type l -o -type d -type p" \
+ "dir/link\n" "" ""
+testing "find -type l ( -type d -o -type l )" \
+ "find dir -type l \( -type d -o -type l \)" "dir/link\n" "" ""
+testing "find extra parantheses" \
+ "find dir \( \( -type l \) \( -type d -o \( \( -type l \) \) \) \)" \
+ "dir/link\n" "" ""
+testing "find ( -type p -o -type d ) -type p" \
+ "find dir \( -type p -o -type d \) -type p" "dir/fifo\n" "" ""
+testing "find -type l -o -type d -type p -o -type f" \
+ "find dir -type l -o -type d -type p -o -type f | sort" \
+ "dir/file\ndir/link\n" "" ""
+
+# Testing short-circuit evaluations
+
+testing "find -type f -a -print" \
+ "find dir -type f -a -print" "dir/file\n" "" ""
+testing "find -print -o -print" \
+ "find dir -type f -a \( -print -o -print \)" "dir/file\n" "" ""
+
+rm -rf dir