]> arthur.barton.de Git - bup.git/blob - t/test-ls.sh
mips64el can't conceive of lunar landing; adjust
[bup.git] / t / test-ls.sh
1 #!/usr/bin/env bash
2 . ./wvtest-bup.sh || exit $?
3 . t/lib.sh || exit $?
4
5 set -o pipefail
6
7 top="$(WVPASS pwd)" || exit $?
8 tmpdir="$(WVPASS wvmktempdir)" || exit $?
9
10 export BUP_DIR="$tmpdir/bup"
11 export GIT_DIR="$tmpdir/bup"
12
13 bup() { "$top/bup" "$@"; }
14
15 export TZ=UTC
16
17 WVPASS bup init
18 WVPASS cd "$tmpdir"
19
20 WVPASS mkdir src
21 WVPASS touch src/.dotfile src/executable
22 WVPASS mkfifo src/fifo
23 WVPASS "$top"/t/mksock src/socket
24 WVPASS bup random 1k > src/file
25 WVPASS chmod u+x src/executable
26 WVPASS chmod -R u=rwX,g-rwx,o-rwx .
27 WVPASS touch -t 200910032348 src/.dotfile src/*
28 (WVPASS cd src; WVPASS ln -s file symlink) || exit $?
29 WVPASS touch -t 200910032348 src
30 WVPASS touch -t 200910032348 .
31 WVPASS bup index src
32 WVPASS bup save -n src -d 242312160 src
33 WVPASS bup tag some-tag src
34
35
36 WVSTART "ls (short)"
37
38 (export BUP_FORCE_TTY=1; WVPASSEQ "$(WVPASS bup ls | tr -d ' ')" src)
39
40 WVPASSEQ "$(WVPASS bup ls /)" "src"
41
42 WVPASSEQ "$(WVPASS bup ls -A /)" ".commit
43 .tag
44 src"
45
46 WVPASSEQ "$(WVPASS bup ls -AF /)" ".commit/
47 .tag/
48 src/"
49
50 WVPASSEQ "$(WVPASS bup ls -a /)" ".
51 ..
52 .commit
53 .tag
54 src"
55
56 WVPASSEQ "$(WVPASS bup ls -aF /)" "./
57 ../
58 .commit/
59 .tag/
60 src/"
61
62 WVPASSEQ "$(WVPASS bup ls /.tag)" "some-tag"
63
64 WVPASSEQ "$(WVPASS bup ls /src)" \
65 "1977-09-05-125600
66 latest"
67
68 WVPASSEQ "$(WVPASS bup ls src/latest/"$tmpdir"/src)" "executable
69 fifo
70 file
71 socket
72 symlink"
73
74 WVPASSEQ "$(WVPASS bup ls -A src/latest/"$tmpdir"/src)" ".dotfile
75 executable
76 fifo
77 file
78 socket
79 symlink"
80
81 WVPASSEQ "$(WVPASS bup ls -a src/latest/"$tmpdir"/src)" ".
82 ..
83 .dotfile
84 executable
85 fifo
86 file
87 socket
88 symlink"
89
90 WVPASSEQ "$(WVPASS bup ls -F src/latest/"$tmpdir"/src)" "executable*
91 fifo|
92 file
93 socket=
94 symlink@"
95
96 WVPASSEQ "$(WVPASS bup ls --file-type src/latest/"$tmpdir"/src)" "executable
97 fifo|
98 file
99 socket=
100 symlink@"
101
102 WVPASSEQ "$(WVPASS bup ls -d src/latest/"$tmpdir"/src)" "src/latest$tmpdir/src"
103
104
105 WVSTART "ls (long)"
106
107 WVPASSEQ "$(WVPASS bup ls -l / | tr -s ' ' ' ')" \
108 "d--------- ?/? 0 1970-01-01 00:00 src"
109
110 WVPASSEQ "$(WVPASS bup ls -lA / | tr -s ' ' ' ')" \
111 "d--------- ?/? 0 1970-01-01 00:00 .commit
112 d--------- ?/? 0 1970-01-01 00:00 .tag
113 d--------- ?/? 0 1970-01-01 00:00 src"
114
115 WVPASSEQ "$(WVPASS bup ls -lAF / | tr -s ' ' ' ')" \
116 "d--------- ?/? 0 1970-01-01 00:00 .commit/
117 d--------- ?/? 0 1970-01-01 00:00 .tag/
118 d--------- ?/? 0 1970-01-01 00:00 src/"
119
120 WVPASSEQ "$(WVPASS bup ls -la / | tr -s ' ' ' ')" \
121 "d--------- ?/? 0 1970-01-01 00:00 .
122 d--------- ?/? 0 1970-01-01 00:00 ..
123 d--------- ?/? 0 1970-01-01 00:00 .commit
124 d--------- ?/? 0 1970-01-01 00:00 .tag
125 d--------- ?/? 0 1970-01-01 00:00 src"
126
127 WVPASSEQ "$(WVPASS bup ls -laF / | tr -s ' ' ' ')" \
128 "d--------- ?/? 0 1970-01-01 00:00 ./
129 d--------- ?/? 0 1970-01-01 00:00 ../
130 d--------- ?/? 0 1970-01-01 00:00 .commit/
131 d--------- ?/? 0 1970-01-01 00:00 .tag/
132 d--------- ?/? 0 1970-01-01 00:00 src/"
133
134 symlink_mode="$(WVPASS ls -l src/symlink | cut -b -10)" || exit $?
135
136 symlink_bup_info="$(WVPASS bup ls -l src/latest"$tmpdir"/src | grep symlink)" \
137     || exit $?
138 symlink_date="$(WVPASS echo "$symlink_bup_info" \
139   | WVPASS perl -ne 'm/.*? (\d+) (\d\d\d\d-\d\d-\d\d \d\d:\d\d)/ and print $2')" \
140     || exit $?
141
142 if test "$(uname -s)" != NetBSD; then
143     symlink_size="$(WVPASS bup-python -c "import os
144 print os.lstat('src/symlink').st_size")" || exit $?
145 else
146     # NetBSD appears to return varying sizes, so for now, just ignore it.
147     symlink_size="$(WVPASS echo "$symlink_bup_info" \
148       | WVPASS perl -ne 'm/.*? (\d+) (\d\d\d\d-\d\d-\d\d \d\d:\d\d)/ and print $1')" \
149         || exit $?
150 fi
151
152 uid="$(WVPASS id -u)" || exit $?
153 gid="$(WVPASS bup-python -c 'import os; print os.stat("src").st_gid')" || exit $?
154 user="$(WVPASS id -un)" || exit $?
155 group="$(WVPASS bup-python -c 'import grp, os;
156 print grp.getgrgid(os.stat("src").st_gid)[0]')" || exit $?
157
158 WVPASSEQ "$(bup ls -l src/latest"$tmpdir"/src | tr -s ' ' ' ')" \
159 "-rwx------ $user/$group 0 2009-10-03 23:48 executable
160 prw------- $user/$group 0 2009-10-03 23:48 fifo
161 -rw------- $user/$group 1024 2009-10-03 23:48 file
162 srwx------ $user/$group 0 2009-10-03 23:48 socket
163 $symlink_mode $user/$group $symlink_size $symlink_date symlink -> file"
164
165 WVPASSEQ "$(bup ls -la src/latest"$tmpdir"/src | tr -s ' ' ' ')" \
166 "drwx------ $user/$group 0 2009-10-03 23:48 .
167 drwx------ $user/$group 0 2009-10-03 23:48 ..
168 -rw------- $user/$group 0 2009-10-03 23:48 .dotfile
169 -rwx------ $user/$group 0 2009-10-03 23:48 executable
170 prw------- $user/$group 0 2009-10-03 23:48 fifo
171 -rw------- $user/$group 1024 2009-10-03 23:48 file
172 srwx------ $user/$group 0 2009-10-03 23:48 socket
173 $symlink_mode $user/$group $symlink_size $symlink_date symlink -> file"
174
175 WVPASSEQ "$(bup ls -lA src/latest"$tmpdir"/src | tr -s ' ' ' ')" \
176 "-rw------- $user/$group 0 2009-10-03 23:48 .dotfile
177 -rwx------ $user/$group 0 2009-10-03 23:48 executable
178 prw------- $user/$group 0 2009-10-03 23:48 fifo
179 -rw------- $user/$group 1024 2009-10-03 23:48 file
180 srwx------ $user/$group 0 2009-10-03 23:48 socket
181 $symlink_mode $user/$group $symlink_size $symlink_date symlink -> file"
182
183 WVPASSEQ "$(bup ls -lF src/latest"$tmpdir"/src | tr -s ' ' ' ')" \
184 "-rwx------ $user/$group 0 2009-10-03 23:48 executable*
185 prw------- $user/$group 0 2009-10-03 23:48 fifo|
186 -rw------- $user/$group 1024 2009-10-03 23:48 file
187 srwx------ $user/$group 0 2009-10-03 23:48 socket=
188 $symlink_mode $user/$group $symlink_size $symlink_date symlink@ -> file"
189
190 WVPASSEQ "$(bup ls -l --file-type src/latest"$tmpdir"/src | tr -s ' ' ' ')" \
191 "-rwx------ $user/$group 0 2009-10-03 23:48 executable
192 prw------- $user/$group 0 2009-10-03 23:48 fifo|
193 -rw------- $user/$group 1024 2009-10-03 23:48 file
194 srwx------ $user/$group 0 2009-10-03 23:48 socket=
195 $symlink_mode $user/$group $symlink_size $symlink_date symlink@ -> file"
196
197 WVPASSEQ "$(bup ls -ln src/latest"$tmpdir"/src | tr -s ' ' ' ')" \
198 "-rwx------ $uid/$gid 0 2009-10-03 23:48 executable
199 prw------- $uid/$gid 0 2009-10-03 23:48 fifo
200 -rw------- $uid/$gid 1024 2009-10-03 23:48 file
201 srwx------ $uid/$gid 0 2009-10-03 23:48 socket
202 $symlink_mode $uid/$gid $symlink_size $symlink_date symlink -> file"
203
204 WVPASSEQ "$(bup ls -ld "src/latest$tmpdir/src" | tr -s ' ' ' ')" \
205 "drwx------ $user/$group 0 2009-10-03 23:48 src/latest$tmpdir/src"
206
207
208 WVSTART "ls (backup set - long)"
209 WVPASSEQ "$(bup ls -l src | cut -d' ' -f 1-2)" \
210 "l--------- ?/?
211 l--------- ?/?"
212
213
214 WVSTART "ls (dates TZ != UTC)"
215 export TZ=America/Chicago
216 symlink_date_central="$(bup ls -l src/latest"$tmpdir"/src | grep symlink)"
217 symlink_date_central="$(echo "$symlink_date_central" \
218   | perl -ne 'm/.*? (\d+) (\d\d\d\d-\d\d-\d\d \d\d:\d\d)/ and print $2')"
219 WVPASSEQ "$(bup ls -ln src/latest"$tmpdir"/src | tr -s ' ' ' ')" \
220 "-rwx------ $uid/$gid 0 2009-10-03 18:48 executable
221 prw------- $uid/$gid 0 2009-10-03 18:48 fifo
222 -rw------- $uid/$gid 1024 2009-10-03 18:48 file
223 srwx------ $uid/$gid 0 2009-10-03 18:48 socket
224 $symlink_mode $uid/$gid $symlink_size $symlink_date_central symlink -> file"
225 unset TZ
226
227
228 WVPASS rm -rf "$tmpdir"