annotate scripts/test/cp.test @ 259:b4fec0865d8e

Start of tests for cp.
author Rob Landley <rob@landley.net>
date Sat, 16 Feb 2008 20:00:11 -0600
parents
children 70f36d9c5387
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
259
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
1 #!/bin/bash
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
2
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
3 [ -f testing.sh ] && . testing.sh
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
4
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
5 # Create test file
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
6 dd if=/dev/urandom of=random bs=64 count=1 > /dev/null
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
7
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
8 #testing "name" "command" "result" "infile" "stdin"
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
9
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
10 testing "cp not enough arguments [fail]" "cp one 2>/dev/null || echo yes" \
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
11 "yes\n" "" ""
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
12 testing "cp -missing source [fail]" "cp missing two 2>/dev/null || echo yes" \
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
13 "yes\n" "" ""
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
14 testing "cp file->file" "cp random two && cmp random two && echo yes" \
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
15 "yes\n" "" ""
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
16 rm two
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
17
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
18 mkdir two
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
19 testing "cp file->dir" "cp random two && cmp random two/random && echo yes" \
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
20 "yes\n" "" ""
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
21 rm two/random
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
22 testing "cp file->dir/file" \
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
23 "cp random two/random && cmp random two/random && echo yes" \
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
24 "yes\n" "" ""
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
25 testing "cp -r dir->missing" \
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
26 "cp -r two three && cmp random three/random && echo yes" \
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
27 "yes\n" "" ""
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
28 touch walrus
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
29 testing "cp -r dir->file [fail]" \
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
30 "cp -r two walrus 2>/dev/null || echo yes" "yes\n" "" ""
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
31 touch two/three
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
32 testing "cp -r dir hits file." \
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
33 "cp -r three two 2>/dev/null || echo yes" "yes\n" "" ""
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
34 rm -rf two three walrus
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
35
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
36 touch two
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
37 chmod 000 two
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
38 testing "cp file->inaccessable [fail]" \
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
39 "cp random two 2>/dev/null || echo yes" "yes\n" "" ""
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
40 rm -f two
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
41
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
42 touch two
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
43 chmod 000 two
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
44 testing "cp -f file->inaccessable" \
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
45 "cp -f random two && cmp random two && echo yes" "yes\n" "" ""
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
46 mkdir sub
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
47 chmod 000 sub
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
48 testing "cp file->inaccessable_dir [fail]" \
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
49 "cp random sub 2>/dev/null || echo yes" "yes\n" "" ""
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
50 rm two
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
51 rmdir sub
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
52
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
53 mkdir dir
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
54 touch file
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
55 testing "cp -rf dir file [fail]" "cp -rf dir file 2>/dev/null || echo yes" \
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
56 "yes\n" "" ""
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
57 rm -rf dir file
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
58
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
59 touch one two
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
60 testing "cp file1 file2 missing [fail]" \
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
61 "cp one two missing 2>/dev/null || echo yes" "yes\n" "" ""
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
62 mkdir dir
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
63 testing "cp dir file missing [fail]" \
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
64 "cp dir two missing 2>/dev/null || echo yes" "yes\n" "" ""
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
65 testing "cp -rf dir file missing [fail]" \
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
66 "cp dir two missing 2>/dev/null || echo yes" "yes\n" "" ""
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
67 testing "cp file1 file2 file [fail]" \
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
68 "cp random one two 2>/dev/null || echo yes" "yes\n" "" ""
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
69 testing "cp file1 file2 dir" \
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
70 "cp random one dir && cmp random dir/random && cmp one dir/one && echo yes" \
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
71 "yes\n" "" ""
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
72 rm one two random
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
73 rm -rf dir
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
74
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
75 # cp file1 file2 dir
b4fec0865d8e Start of tests for cp.
Rob Landley <rob@landley.net>
parents:
diff changeset
76 # cp file1 missing file2 -> dir