]> arthur.barton.de Git - bup.git/blob - t/test-ls.sh
5f351caa173566472a5b33bed51aaee77e55995f
[bup.git] / t / test-ls.sh
1 #!/usr/bin/env bash
2 . ./wvtest-bup.sh
3
4 set -o pipefail
5
6 top="$(WVPASS pwd)" || exit $?
7 tmpdir="$(WVPASS wvmktempdir)" || exit $?
8
9 export BUP_DIR="$tmpdir/bup"
10 export GIT_DIR="$tmpdir/bup"
11
12 bup() { "$top/bup" "$@"; }
13
14 export TZ=UTC
15
16 WVPASS bup init
17 WVPASS cd "$tmpdir"
18
19 WVPASS mkdir src
20 WVPASS touch -t 196907202018 src/.dotfile
21 WVPASS bup random 1k > src/file
22 WVPASS touch -t 196907202018 src/file
23 (WVPASS cd src; WVPASS ln -s file symlink) || exit $?
24 WVPASS mkfifo src/fifo
25 WVPASS touch -t 196907202018 src/fifo
26 WVPASS "$top"/t/mksock src/socket
27 WVPASS touch -t 196907202018 src/socket
28 WVPASS touch -t 196907202018 src/executable
29 WVPASS chmod u+x src/executable
30 WVPASS touch -t 196907202018 src/executable
31 WVPASS touch -t 196907202018 src
32 WVPASS touch -t 196907202018 .
33 WVPASS chmod -R u=rwX,g-rwx,o-rwx .
34 WVPASS bup index src
35 WVPASS bup save -n src src
36
37 WVSTART "ls (short)"
38
39 WVPASSEQ "$(WVPASS bup ls /)" "src"
40
41 WVPASSEQ "$(WVPASS bup ls -A /)" ".commit
42 .tag
43 src"
44
45 WVPASSEQ "$(WVPASS bup ls -AF /)" ".commit/
46 .tag/
47 src/"
48
49 WVPASSEQ "$(WVPASS bup ls -a /)" ".
50 ..
51 .commit
52 .tag
53 src"
54
55 WVPASSEQ "$(WVPASS bup ls -aF /)" "./
56 ../
57 .commit/
58 .tag/
59 src/"
60
61 WVPASSEQ "$(WVPASS bup ls src/latest/"$tmpdir"/src)" "executable
62 fifo
63 file
64 socket
65 symlink"
66
67 WVPASSEQ "$(WVPASS bup ls -A src/latest/"$tmpdir"/src)" ".dotfile
68 executable
69 fifo
70 file
71 socket
72 symlink"
73
74 WVPASSEQ "$(WVPASS bup ls -a src/latest/"$tmpdir"/src)" ".
75 ..
76 .dotfile
77 executable
78 fifo
79 file
80 socket
81 symlink"
82
83 WVPASSEQ "$(WVPASS bup ls -F src/latest/"$tmpdir"/src)" "executable*
84 fifo|
85 file
86 socket=
87 symlink@"
88
89 WVPASSEQ "$(WVPASS bup ls --file-type src/latest/"$tmpdir"/src)" "executable
90 fifo|
91 file
92 socket=
93 symlink@"
94
95 WVSTART "ls (long)"
96
97 WVPASSEQ "$(WVPASS bup ls -l / | tr -s ' ' ' ')" \
98 "d--------- ?/? 0 1970-01-01 00:00 src"
99
100 WVPASSEQ "$(WVPASS bup ls -lA / | tr -s ' ' ' ')" \
101 "d--------- ?/? 0 1970-01-01 00:00 .commit
102 d--------- ?/? 0 1970-01-01 00:00 .tag
103 d--------- ?/? 0 1970-01-01 00:00 src"
104
105 WVPASSEQ "$(WVPASS bup ls -lAF / | tr -s ' ' ' ')" \
106 "d--------- ?/? 0 1970-01-01 00:00 .commit/
107 d--------- ?/? 0 1970-01-01 00:00 .tag/
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 .
112 d--------- ?/? 0 1970-01-01 00:00 ..
113 d--------- ?/? 0 1970-01-01 00:00 .commit
114 d--------- ?/? 0 1970-01-01 00:00 .tag
115 d--------- ?/? 0 1970-01-01 00:00 src"
116
117 WVPASSEQ "$(WVPASS bup ls -laF / | tr -s ' ' ' ')" \
118 "d--------- ?/? 0 1970-01-01 00:00 ./
119 d--------- ?/? 0 1970-01-01 00:00 ../
120 d--------- ?/? 0 1970-01-01 00:00 .commit/
121 d--------- ?/? 0 1970-01-01 00:00 .tag/
122 d--------- ?/? 0 1970-01-01 00:00 src/"
123
124 symlink_size="$(python -c "import os; print os.lstat('src/symlink').st_size")"
125 symlink_date="$(bup ls -l src/latest"$tmpdir"/src | grep symlink)"
126 symlink_date="$(echo "$symlink_date" \
127   | perl -ne 'm/.*? (\d+) (\d\d\d\d-\d\d-\d\d \d\d:\d\d)/ and print $2')"
128 uid="$(id -u)" || exit $?
129 gid="$(id -g)" || exit $?
130 user="$(id -un)" || exit $?
131 group="$(id -gn)" || exit $?
132
133 WVPASSEQ "$(bup ls -l src/latest"$tmpdir"/src | tr -s ' ' ' ')" \
134 "-rwx------ $user/$group 0 1969-07-20 20:18 executable
135 prw------- $user/$group 0 1969-07-20 20:18 fifo
136 -rw------- $user/$group 1024 1969-07-20 20:18 file
137 srwx------ $user/$group 0 1969-07-20 20:18 socket
138 lrwxrwxrwx $user/$group $symlink_size $symlink_date symlink -> file"
139
140 WVPASSEQ "$(bup ls -la src/latest"$tmpdir"/src | tr -s ' ' ' ')" \
141 "drwx------ $user/$group 0 1969-07-20 20:18 .
142 drwx------ $user/$group 0 1969-07-20 20:18 ..
143 -rw------- $user/$group 0 1969-07-20 20:18 .dotfile
144 -rwx------ $user/$group 0 1969-07-20 20:18 executable
145 prw------- $user/$group 0 1969-07-20 20:18 fifo
146 -rw------- $user/$group 1024 1969-07-20 20:18 file
147 srwx------ $user/$group 0 1969-07-20 20:18 socket
148 lrwxrwxrwx $user/$group $symlink_size $symlink_date symlink -> file"
149
150 WVPASSEQ "$(bup ls -lA src/latest"$tmpdir"/src | tr -s ' ' ' ')" \
151 "-rw------- $user/$group 0 1969-07-20 20:18 .dotfile
152 -rwx------ $user/$group 0 1969-07-20 20:18 executable
153 prw------- $user/$group 0 1969-07-20 20:18 fifo
154 -rw------- $user/$group 1024 1969-07-20 20:18 file
155 srwx------ $user/$group 0 1969-07-20 20:18 socket
156 lrwxrwxrwx $user/$group $symlink_size $symlink_date symlink -> file"
157
158 WVPASSEQ "$(bup ls -lF src/latest"$tmpdir"/src | tr -s ' ' ' ')" \
159 "-rwx------ $user/$group 0 1969-07-20 20:18 executable*
160 prw------- $user/$group 0 1969-07-20 20:18 fifo|
161 -rw------- $user/$group 1024 1969-07-20 20:18 file
162 srwx------ $user/$group 0 1969-07-20 20:18 socket=
163 lrwxrwxrwx $user/$group $symlink_size $symlink_date symlink@ -> file"
164
165 WVPASSEQ "$(bup ls -l --file-type src/latest"$tmpdir"/src | tr -s ' ' ' ')" \
166 "-rwx------ $user/$group 0 1969-07-20 20:18 executable
167 prw------- $user/$group 0 1969-07-20 20:18 fifo|
168 -rw------- $user/$group 1024 1969-07-20 20:18 file
169 srwx------ $user/$group 0 1969-07-20 20:18 socket=
170 lrwxrwxrwx $user/$group $symlink_size $symlink_date symlink@ -> file"
171
172 WVPASSEQ "$(bup ls -ln src/latest"$tmpdir"/src | tr -s ' ' ' ')" \
173 "-rwx------ $uid/$gid 0 1969-07-20 20:18 executable
174 prw------- $uid/$gid 0 1969-07-20 20:18 fifo
175 -rw------- $uid/$gid 1024 1969-07-20 20:18 file
176 srwx------ $uid/$gid 0 1969-07-20 20:18 socket
177 lrwxrwxrwx $uid/$gid $symlink_size $symlink_date symlink -> file"
178
179 WVSTART "ls (backup set - long)"
180 WVPASSEQ "$(bup ls -l src | cut -d' ' -f 1-2)" \
181 "l--------- ?/?
182 l--------- ?/?"
183
184 WVSTART "ls (dates TZ != UTC)"
185 export TZ=US/Central
186 symlink_date_central="$(bup ls -l src/latest"$tmpdir"/src | grep symlink)"
187 symlink_date_central="$(echo "$symlink_date_central" \
188   | perl -ne 'm/.*? (\d+) (\d\d\d\d-\d\d-\d\d \d\d:\d\d)/ and print $2')"
189 WVPASSEQ "$(bup ls -ln src/latest"$tmpdir"/src | tr -s ' ' ' ')" \
190 "-rwx------ $uid/$gid 0 1969-07-20 15:18 executable
191 prw------- $uid/$gid 0 1969-07-20 15:18 fifo
192 -rw------- $uid/$gid 1024 1969-07-20 15:18 file
193 srwx------ $uid/$gid 0 1969-07-20 15:18 socket
194 lrwxrwxrwx $uid/$gid $symlink_size $symlink_date_central symlink -> file"
195 unset TZ
196
197 WVPASS rm -rf "$tmpdir"