aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2008-02-16 20:00:11 -0600
committerRob Landley <rob@landley.net>2008-02-16 20:00:11 -0600
commitdd282026714cb3bf4a1b98f0ecd360c980bc65b0 (patch)
tree5756454b5a921d892c92f2b2f1da65026bfbfed5 /scripts
parent7bc7971c0b876b2074ede82327edeaaffa56eb01 (diff)
downloadtoybox-dd282026714cb3bf4a1b98f0ecd360c980bc65b0.tar.gz
Start of tests for cp.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/test/cp.test76
1 files changed, 76 insertions, 0 deletions
diff --git a/scripts/test/cp.test b/scripts/test/cp.test
new file mode 100755
index 00000000..5e67d3fb
--- /dev/null
+++ b/scripts/test/cp.test
@@ -0,0 +1,76 @@
+#!/bin/bash
+
+[ -f testing.sh ] && . testing.sh
+
+# Create test file
+dd if=/dev/urandom of=random bs=64 count=1 > /dev/null
+
+#testing "name" "command" "result" "infile" "stdin"
+
+testing "cp not enough arguments [fail]" "cp one 2>/dev/null || echo yes" \
+ "yes\n" "" ""
+testing "cp -missing source [fail]" "cp missing two 2>/dev/null || echo yes" \
+ "yes\n" "" ""
+testing "cp file->file" "cp random two && cmp random two && echo yes" \
+ "yes\n" "" ""
+rm two
+
+mkdir two
+testing "cp file->dir" "cp random two && cmp random two/random && echo yes" \
+ "yes\n" "" ""
+rm two/random
+testing "cp file->dir/file" \
+ "cp random two/random && cmp random two/random && echo yes" \
+ "yes\n" "" ""
+testing "cp -r dir->missing" \
+ "cp -r two three && cmp random three/random && echo yes" \
+ "yes\n" "" ""
+touch walrus
+testing "cp -r dir->file [fail]" \
+ "cp -r two walrus 2>/dev/null || echo yes" "yes\n" "" ""
+touch two/three
+testing "cp -r dir hits file." \
+ "cp -r three two 2>/dev/null || echo yes" "yes\n" "" ""
+rm -rf two three walrus
+
+touch two
+chmod 000 two
+testing "cp file->inaccessable [fail]" \
+ "cp random two 2>/dev/null || echo yes" "yes\n" "" ""
+rm -f two
+
+touch two
+chmod 000 two
+testing "cp -f file->inaccessable" \
+ "cp -f random two && cmp random two && echo yes" "yes\n" "" ""
+mkdir sub
+chmod 000 sub
+testing "cp file->inaccessable_dir [fail]" \
+ "cp random sub 2>/dev/null || echo yes" "yes\n" "" ""
+rm two
+rmdir sub
+
+mkdir dir
+touch file
+testing "cp -rf dir file [fail]" "cp -rf dir file 2>/dev/null || echo yes" \
+ "yes\n" "" ""
+rm -rf dir file
+
+touch one two
+testing "cp file1 file2 missing [fail]" \
+ "cp one two missing 2>/dev/null || echo yes" "yes\n" "" ""
+mkdir dir
+testing "cp dir file missing [fail]" \
+ "cp dir two missing 2>/dev/null || echo yes" "yes\n" "" ""
+testing "cp -rf dir file missing [fail]" \
+ "cp dir two missing 2>/dev/null || echo yes" "yes\n" "" ""
+testing "cp file1 file2 file [fail]" \
+ "cp random one two 2>/dev/null || echo yes" "yes\n" "" ""
+testing "cp file1 file2 dir" \
+ "cp random one dir && cmp random dir/random && cmp one dir/one && echo yes" \
+ "yes\n" "" ""
+rm one two random
+rm -rf dir
+
+# cp file1 file2 dir
+# cp file1 missing file2 -> dir