Mercurial > hg > toybox
annotate scripts/test/cp.test @ 447:0cc0c0e879d1
Correct cksum parameters and clarify -N option
author | Elie De Brauwer <eliedebrauwer@gmail.com> |
---|---|
date | Sat, 11 Feb 2012 13:48:04 +0100 |
parents | 7126df2ae342 |
children | 786841fdb1e0 |
rev | line source |
---|---|
259 | 1 #!/bin/bash |
2 | |
3 [ -f testing.sh ] && . testing.sh | |
4 | |
5 # Create test file | |
286 | 6 dd if=/dev/urandom of=random bs=64 count=1 2> /dev/null |
259 | 7 |
8 #testing "name" "command" "result" "infile" "stdin" | |
9 | |
10 testing "cp not enough arguments [fail]" "cp one 2>/dev/null || echo yes" \ | |
11 "yes\n" "" "" | |
12 testing "cp -missing source [fail]" "cp missing two 2>/dev/null || echo yes" \ | |
13 "yes\n" "" "" | |
14 testing "cp file->file" "cp random two && cmp random two && echo yes" \ | |
15 "yes\n" "" "" | |
16 rm two | |
17 | |
18 mkdir two | |
19 testing "cp file->dir" "cp random two && cmp random two/random && echo yes" \ | |
20 "yes\n" "" "" | |
21 rm two/random | |
22 testing "cp file->dir/file" \ | |
23 "cp random two/random && cmp random two/random && echo yes" \ | |
24 "yes\n" "" "" | |
25 testing "cp -r dir->missing" \ | |
26 "cp -r two three && cmp random three/random && echo yes" \ | |
27 "yes\n" "" "" | |
28 touch walrus | |
29 testing "cp -r dir->file [fail]" \ | |
30 "cp -r two walrus 2>/dev/null || echo yes" "yes\n" "" "" | |
31 touch two/three | |
32 testing "cp -r dir hits file." \ | |
33 "cp -r three two 2>/dev/null || echo yes" "yes\n" "" "" | |
34 rm -rf two three walrus | |
35 | |
36 touch two | |
37 chmod 000 two | |
38 testing "cp file->inaccessable [fail]" \ | |
39 "cp random two 2>/dev/null || echo yes" "yes\n" "" "" | |
40 rm -f two | |
41 | |
42 touch two | |
43 chmod 000 two | |
44 testing "cp -f file->inaccessable" \ | |
45 "cp -f random two && cmp random two && echo yes" "yes\n" "" "" | |
46 mkdir sub | |
47 chmod 000 sub | |
48 testing "cp file->inaccessable_dir [fail]" \ | |
49 "cp random sub 2>/dev/null || echo yes" "yes\n" "" "" | |
50 rm two | |
51 rmdir sub | |
52 | |
53 mkdir dir | |
54 touch file | |
55 testing "cp -rf dir file [fail]" "cp -rf dir file 2>/dev/null || echo yes" \ | |
56 "yes\n" "" "" | |
57 rm -rf dir file | |
58 | |
59 touch one two | |
60 testing "cp file1 file2 missing [fail]" \ | |
61 "cp one two missing 2>/dev/null || echo yes" "yes\n" "" "" | |
62 mkdir dir | |
63 testing "cp dir file missing [fail]" \ | |
64 "cp dir two missing 2>/dev/null || echo yes" "yes\n" "" "" | |
65 testing "cp -rf dir file missing [fail]" \ | |
66 "cp dir two missing 2>/dev/null || echo yes" "yes\n" "" "" | |
67 testing "cp file1 file2 file [fail]" \ | |
68 "cp random one two 2>/dev/null || echo yes" "yes\n" "" "" | |
69 testing "cp file1 file2 dir" \ | |
70 "cp random one dir && cmp random dir/random && cmp one dir/one && echo yes" \ | |
71 "yes\n" "" "" | |
72 rm one two random | |
73 rm -rf dir | |
74 | |
271
7d625cbdde25
Update cp -r to work better, add relevant tests to test suite.
Rob Landley <rob@landley.net>
parents:
262
diff
changeset
|
75 mkdir -p one/two/three/four |
7d625cbdde25
Update cp -r to work better, add relevant tests to test suite.
Rob Landley <rob@landley.net>
parents:
262
diff
changeset
|
76 touch one/two/three/five |
7d625cbdde25
Update cp -r to work better, add relevant tests to test suite.
Rob Landley <rob@landley.net>
parents:
262
diff
changeset
|
77 touch one/{six,seven,eight} |
7d625cbdde25
Update cp -r to work better, add relevant tests to test suite.
Rob Landley <rob@landley.net>
parents:
262
diff
changeset
|
78 testing "cp -r /abspath dest" \ |
7d625cbdde25
Update cp -r to work better, add relevant tests to test suite.
Rob Landley <rob@landley.net>
parents:
262
diff
changeset
|
79 "cp -r \"$(readlink -f one)\" dir && diff -r one dir && echo yes" \ |
7d625cbdde25
Update cp -r to work better, add relevant tests to test suite.
Rob Landley <rob@landley.net>
parents:
262
diff
changeset
|
80 "yes\n" "" "" |
272
a5652aa22f38
Another cp -r fix, another test case...
Rob Landley <rob@landley.net>
parents:
271
diff
changeset
|
81 testing "cp -r dir again" "cp -r one/. dir && diff -r one dir && echo yes" \ |
a5652aa22f38
Another cp -r fix, another test case...
Rob Landley <rob@landley.net>
parents:
271
diff
changeset
|
82 "yes\n" "" "" |
271
7d625cbdde25
Update cp -r to work better, add relevant tests to test suite.
Rob Landley <rob@landley.net>
parents:
262
diff
changeset
|
83 mkdir dir2 |
7d625cbdde25
Update cp -r to work better, add relevant tests to test suite.
Rob Landley <rob@landley.net>
parents:
262
diff
changeset
|
84 testing "cp -r dir1/* dir2" \ |
7d625cbdde25
Update cp -r to work better, add relevant tests to test suite.
Rob Landley <rob@landley.net>
parents:
262
diff
changeset
|
85 "cp -r one/* dir2 && diff -r one dir2 && echo yes" "yes\n" "" "" |
272
a5652aa22f38
Another cp -r fix, another test case...
Rob Landley <rob@landley.net>
parents:
271
diff
changeset
|
86 rm -rf one dir dir2 |
271
7d625cbdde25
Update cp -r to work better, add relevant tests to test suite.
Rob Landley <rob@landley.net>
parents:
262
diff
changeset
|
87 |
262
70f36d9c5387
Add first pass at cp, totally untested, unlikely to work yet. :)
Rob Landley <rob@landley.net>
parents:
259
diff
changeset
|
88 # cp -r ../source destdir |
271
7d625cbdde25
Update cp -r to work better, add relevant tests to test suite.
Rob Landley <rob@landley.net>
parents:
262
diff
changeset
|
89 # cp -r one/two/three missing |
7d625cbdde25
Update cp -r to work better, add relevant tests to test suite.
Rob Landley <rob@landley.net>
parents:
262
diff
changeset
|
90 # cp -r one/two/three two |
7d625cbdde25
Update cp -r to work better, add relevant tests to test suite.
Rob Landley <rob@landley.net>
parents:
262
diff
changeset
|
91 # mkdir one; touch one/two; ln -s two one/three |
259 | 92 # cp file1 file2 dir |
93 # cp file1 missing file2 -> dir | |
271
7d625cbdde25
Update cp -r to work better, add relevant tests to test suite.
Rob Landley <rob@landley.net>
parents:
262
diff
changeset
|
94 |
7d625cbdde25
Update cp -r to work better, add relevant tests to test suite.
Rob Landley <rob@landley.net>
parents:
262
diff
changeset
|
95 # Make sure it's truncating existing file |
7d625cbdde25
Update cp -r to work better, add relevant tests to test suite.
Rob Landley <rob@landley.net>
parents:
262
diff
changeset
|
96 # copy with -d at top level, with -d in directory, without -d at top level, |
7d625cbdde25
Update cp -r to work better, add relevant tests to test suite.
Rob Landley <rob@landley.net>
parents:
262
diff
changeset
|
97 # without -d in directory |