]> arthur.barton.de Git - bup.git/blobdiff - t/test-ls.sh
cleanup-mounts-under: Don't fail when /proc/mounts isn't readable
[bup.git] / t / test-ls.sh
index d91f1d32d6ecec67320aeeb50bfa2077924f4ac3..77c5d096a7bb788cd3a6e469b76c32c22027ad8f 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/env bash
-. ./wvtest-bup.sh
+. ./wvtest-bup.sh || exit $?
 
 set -o pipefail
 
@@ -17,23 +17,20 @@ WVPASS bup init
 WVPASS cd "$tmpdir"
 
 WVPASS mkdir src
-WVPASS touch -t 196907202018 src/.dotfile
-WVPASS bup random 1k > src/file
-WVPASS touch -t 196907202018 src/file
-(WVPASS cd src; WVPASS ln -s file symlink) || exit $?
+WVPASS touch src/.dotfile src/executable
 WVPASS mkfifo src/fifo
-WVPASS touch -t 196907202018 src/fifo
 WVPASS "$top"/t/mksock src/socket
-WVPASS touch -t 196907202018 src/socket
-WVPASS touch -t 196907202018 src/executable
+WVPASS bup random 1k > src/file
 WVPASS chmod u+x src/executable
-WVPASS touch -t 196907202018 src/executable
+WVPASS chmod -R u=rwX,g-rwx,o-rwx .
+WVPASS touch -t 196907202018 src/.dotfile src/*
+(WVPASS cd src; WVPASS ln -s file symlink) || exit $?
 WVPASS touch -t 196907202018 src
 WVPASS touch -t 196907202018 .
-WVPASS chmod -R u=rwX,g-rwx,o-rwx .
 WVPASS bup index src
 WVPASS bup save -n src src
 
+
 WVSTART "ls (short)"
 
 WVPASSEQ "$(WVPASS bup ls /)" "src"
@@ -92,6 +89,9 @@ file
 socket=
 symlink@"
 
+WVPASSEQ "$(WVPASS bup ls -d src/latest/"$tmpdir"/src)" "src/latest$tmpdir/src"
+
+
 WVSTART "ls (long)"
 
 WVPASSEQ "$(WVPASS bup ls -l / | tr -s ' ' ' ')" \
@@ -121,20 +121,29 @@ d--------- ?/? 0 1970-01-01 00:00 .commit/
 d--------- ?/? 0 1970-01-01 00:00 .tag/
 d--------- ?/? 0 1970-01-01 00:00 src/"
 
-symlink_mode="$(WVPASS ls -l src/symlink | cut -d' ' -f 1)" || exit $?
+symlink_mode="$(WVPASS ls -l src/symlink | cut -b -10)" || exit $?
 
-symlink_size="$(WVPASS python -c "import os
-print os.lstat('src/symlink').st_size")" || exit $?
-
-symlink_date="$(WVPASS bup ls -l src/latest"$tmpdir"/src | grep symlink)" || exit $?
-symlink_date="$(WVPASS echo "$symlink_date" \
+symlink_bup_info="$(WVPASS bup ls -l src/latest"$tmpdir"/src | grep symlink)" \
+    || exit $?
+symlink_date="$(WVPASS echo "$symlink_bup_info" \
   | WVPASS perl -ne 'm/.*? (\d+) (\d\d\d\d-\d\d-\d\d \d\d:\d\d)/ and print $2')" \
     || exit $?
 
+if test "$(uname -s)" != NetBSD; then
+    symlink_size="$(WVPASS python -c "import os
+print os.lstat('src/symlink').st_size")" || exit $?
+else
+    # NetBSD appears to return varying sizes, so for now, just ignore it.
+    symlink_size="$(WVPASS echo "$symlink_bup_info" \
+      | WVPASS perl -ne 'm/.*? (\d+) (\d\d\d\d-\d\d-\d\d \d\d:\d\d)/ and print $1')" \
+        || exit $?
+fi
+
 uid="$(id -u)" || exit $?
-gid="$(id -g)" || exit $?
+gid="$(python -c 'import os; print os.stat("src").st_gid')" || exit $?
 user="$(id -un)" || exit $?
-group="$(id -gn)" || exit $?
+group="$(python -c 'import grp, os;
+print grp.getgrgid(os.stat("src").st_gid)[0]')" || exit $?
 
 WVPASSEQ "$(bup ls -l src/latest"$tmpdir"/src | tr -s ' ' ' ')" \
 "-rwx------ $user/$group 0 1969-07-20 20:18 executable
@@ -182,13 +191,18 @@ prw------- $uid/$gid 0 1969-07-20 20:18 fifo
 srwx------ $uid/$gid 0 1969-07-20 20:18 socket
 $symlink_mode $uid/$gid $symlink_size $symlink_date symlink -> file"
 
+WVPASSEQ "$(bup ls -ld "src/latest$tmpdir/src" | tr -s ' ' ' ')" \
+"drwx------ $user/$group 0 1969-07-20 20:18 src/latest$tmpdir/src"
+
+
 WVSTART "ls (backup set - long)"
 WVPASSEQ "$(bup ls -l src | cut -d' ' -f 1-2)" \
 "l--------- ?/?
 l--------- ?/?"
 
+
 WVSTART "ls (dates TZ != UTC)"
-export TZ=US/Central
+export TZ=America/Chicago
 symlink_date_central="$(bup ls -l src/latest"$tmpdir"/src | grep symlink)"
 symlink_date_central="$(echo "$symlink_date_central" \
   | perl -ne 'm/.*? (\d+) (\d\d\d\d-\d\d-\d\d \d\d:\d\d)/ and print $2')"
@@ -200,4 +214,5 @@ srwx------ $uid/$gid 0 1969-07-20 15:18 socket
 $symlink_mode $uid/$gid $symlink_size $symlink_date_central symlink -> file"
 unset TZ
 
+
 WVPASS rm -rf "$tmpdir"