]> arthur.barton.de Git - bup.git/blobdiff - t/test-ls.sh
Change remaining uses of python to bup-python
[bup.git] / t / test-ls.sh
index db5772a0d23bf84b7a793d8c10c41cb484d53ff2..4a1b2106df046479fd60a27f4ba6baf3ea9e7a61 100755 (executable)
@@ -1,5 +1,6 @@
 #!/usr/bin/env bash
-. ./wvtest-bup.sh
+. ./wvtest-bup.sh || exit $?
+. t/lib.sh || exit $?
 
 set -o pipefail
 
@@ -11,26 +12,26 @@ export GIT_DIR="$tmpdir/bup"
 
 bup() { "$top/bup" "$@"; }
 
+export TZ=UTC
+
 WVPASS bup init
 WVPASS cd "$tmpdir"
 
 WVPASS mkdir src
-WVPASS touch -t 191111111111 src/.dotfile
-WVPASS date > src/file
-WVPASS touch -t 191111111111 src/file
-(WVPASS cd src; WVPASS ln -s file symlink) || exit $?
+WVPASS touch src/.dotfile src/executable
 WVPASS mkfifo src/fifo
-WVPASS touch -t 191111111111 src/fifo
 WVPASS "$top"/t/mksock src/socket
-WVPASS touch -t 191111111111 src/socket
-WVPASS touch -t 191111111111 src/executable
+WVPASS bup random 1k > src/file
 WVPASS chmod u+x src/executable
-WVPASS touch -t 191111111111 src/executable
-WVPASS touch -t 191111111111 src
-WVPASS touch -t 191111111111 .
 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 bup index src
-WVPASS bup save -n src src
+WVPASS bup save -n src -d 242312160 src
+WVPASS bup tag some-tag src
+
 
 WVSTART "ls (short)"
 
@@ -56,6 +57,12 @@ WVPASSEQ "$(WVPASS bup ls -aF /)" "./
 .tag/
 src/"
 
+WVPASSEQ "$(WVPASS bup ls /.tag)" "some-tag"
+
+WVPASSEQ "$(WVPASS bup ls /src)" \
+"1977-09-05-125600
+latest"
+
 WVPASSEQ "$(WVPASS bup ls src/latest/"$tmpdir"/src)" "executable
 fifo
 file
@@ -90,92 +97,130 @@ 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 ' ' ' ')" \
-"d--------- ?/? - 1969-12-31 18:00 src"
+"d--------- ?/? 0 1970-01-01 00:00 src"
 
 WVPASSEQ "$(WVPASS bup ls -lA / | tr -s ' ' ' ')" \
-"d--------- ?/? - 1969-12-31 18:00 .commit
-d--------- ?/? - 1969-12-31 18:00 .tag
-d--------- ?/? - 1969-12-31 18:00 src"
+"d--------- ?/? 0 1970-01-01 00:00 .commit
+d--------- ?/? 0 1970-01-01 00:00 .tag
+d--------- ?/? 0 1970-01-01 00:00 src"
 
 WVPASSEQ "$(WVPASS bup ls -lAF / | tr -s ' ' ' ')" \
-"d--------- ?/? - 1969-12-31 18:00 .commit/
-d--------- ?/? - 1969-12-31 18:00 .tag/
-d--------- ?/? - 1969-12-31 18:00 src/"
+"d--------- ?/? 0 1970-01-01 00:00 .commit/
+d--------- ?/? 0 1970-01-01 00:00 .tag/
+d--------- ?/? 0 1970-01-01 00:00 src/"
 
 WVPASSEQ "$(WVPASS bup ls -la / | tr -s ' ' ' ')" \
-"d--------- ?/? - 1969-12-31 18:00 .
-d--------- ?/? - 1969-12-31 18:00 ..
-d--------- ?/? - 1969-12-31 18:00 .commit
-d--------- ?/? - 1969-12-31 18:00 .tag
-d--------- ?/? - 1969-12-31 18:00 src"
+"d--------- ?/? 0 1970-01-01 00:00 .
+d--------- ?/? 0 1970-01-01 00:00 ..
+d--------- ?/? 0 1970-01-01 00:00 .commit
+d--------- ?/? 0 1970-01-01 00:00 .tag
+d--------- ?/? 0 1970-01-01 00:00 src"
 
 WVPASSEQ "$(WVPASS bup ls -laF / | tr -s ' ' ' ')" \
-"d--------- ?/? - 1969-12-31 18:00 ./
-d--------- ?/? - 1969-12-31 18:00 ../
-d--------- ?/? - 1969-12-31 18:00 .commit/
-d--------- ?/? - 1969-12-31 18:00 .tag/
-d--------- ?/? - 1969-12-31 18:00 src/"
-
-symlink_date="$(bup ls -l src/latest"$tmpdir"/src | grep symlink)"
-symlink_date="$(echo "$symlink_date" \
-  | perl -ne 'm/.*? - (\d\d\d\d-\d\d-\d\d \d\d:\d\d)/ and print $1')"
+"d--------- ?/? 0 1970-01-01 00:00 ./
+d--------- ?/? 0 1970-01-01 00:00 ../
+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 -b -10)" || exit $?
+
+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 bup-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="$(bup-python -c 'import os; print os.stat("src").st_gid')" || exit $?
 user="$(id -un)" || exit $?
-group="$(id -gn)" || exit $?
+group="$(bup-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 - 1911-11-11 11:11 executable
-prw------- $user/$group - 1911-11-11 11:11 fifo
--rw------- $user/$group - 1911-11-11 11:11 file
-srwx------ $user/$group - 1911-11-11 11:11 socket
-lrwxrwxrwx $user/$group - $symlink_date symlink -> file"
+"-rwx------ $user/$group 0 1969-07-20 20:18 executable
+prw------- $user/$group 0 1969-07-20 20:18 fifo
+-rw------- $user/$group 1024 1969-07-20 20:18 file
+srwx------ $user/$group 0 1969-07-20 20:18 socket
+$symlink_mode $user/$group $symlink_size $symlink_date symlink -> file"
 
 WVPASSEQ "$(bup ls -la src/latest"$tmpdir"/src | tr -s ' ' ' ')" \
-"drwx------ $user/$group - 1911-11-11 11:11 .
-drwx------ $user/$group - 1911-11-11 11:11 ..
--rw------- $user/$group - 1911-11-11 11:11 .dotfile
--rwx------ $user/$group - 1911-11-11 11:11 executable
-prw------- $user/$group - 1911-11-11 11:11 fifo
--rw------- $user/$group - 1911-11-11 11:11 file
-srwx------ $user/$group - 1911-11-11 11:11 socket
-lrwxrwxrwx $user/$group - $symlink_date symlink -> file"
+"drwx------ $user/$group 0 1969-07-20 20:18 .
+drwx------ $user/$group 0 1969-07-20 20:18 ..
+-rw------- $user/$group 0 1969-07-20 20:18 .dotfile
+-rwx------ $user/$group 0 1969-07-20 20:18 executable
+prw------- $user/$group 0 1969-07-20 20:18 fifo
+-rw------- $user/$group 1024 1969-07-20 20:18 file
+srwx------ $user/$group 0 1969-07-20 20:18 socket
+$symlink_mode $user/$group $symlink_size $symlink_date symlink -> file"
 
 WVPASSEQ "$(bup ls -lA src/latest"$tmpdir"/src | tr -s ' ' ' ')" \
-"-rw------- $user/$group - 1911-11-11 11:11 .dotfile
--rwx------ $user/$group - 1911-11-11 11:11 executable
-prw------- $user/$group - 1911-11-11 11:11 fifo
--rw------- $user/$group - 1911-11-11 11:11 file
-srwx------ $user/$group - 1911-11-11 11:11 socket
-lrwxrwxrwx $user/$group - $symlink_date symlink -> file"
+"-rw------- $user/$group 0 1969-07-20 20:18 .dotfile
+-rwx------ $user/$group 0 1969-07-20 20:18 executable
+prw------- $user/$group 0 1969-07-20 20:18 fifo
+-rw------- $user/$group 1024 1969-07-20 20:18 file
+srwx------ $user/$group 0 1969-07-20 20:18 socket
+$symlink_mode $user/$group $symlink_size $symlink_date symlink -> file"
 
 WVPASSEQ "$(bup ls -lF src/latest"$tmpdir"/src | tr -s ' ' ' ')" \
-"-rwx------ $user/$group - 1911-11-11 11:11 executable*
-prw------- $user/$group - 1911-11-11 11:11 fifo|
--rw------- $user/$group - 1911-11-11 11:11 file
-srwx------ $user/$group - 1911-11-11 11:11 socket=
-lrwxrwxrwx $user/$group - $symlink_date symlink@ -> file"
+"-rwx------ $user/$group 0 1969-07-20 20:18 executable*
+prw------- $user/$group 0 1969-07-20 20:18 fifo|
+-rw------- $user/$group 1024 1969-07-20 20:18 file
+srwx------ $user/$group 0 1969-07-20 20:18 socket=
+$symlink_mode $user/$group $symlink_size $symlink_date symlink@ -> file"
 
 WVPASSEQ "$(bup ls -l --file-type src/latest"$tmpdir"/src | tr -s ' ' ' ')" \
-"-rwx------ $user/$group - 1911-11-11 11:11 executable
-prw------- $user/$group - 1911-11-11 11:11 fifo|
--rw------- $user/$group - 1911-11-11 11:11 file
-srwx------ $user/$group - 1911-11-11 11:11 socket=
-lrwxrwxrwx $user/$group - $symlink_date symlink@ -> file"
+"-rwx------ $user/$group 0 1969-07-20 20:18 executable
+prw------- $user/$group 0 1969-07-20 20:18 fifo|
+-rw------- $user/$group 1024 1969-07-20 20:18 file
+srwx------ $user/$group 0 1969-07-20 20:18 socket=
+$symlink_mode $user/$group $symlink_size $symlink_date symlink@ -> file"
 
 WVPASSEQ "$(bup ls -ln src/latest"$tmpdir"/src | tr -s ' ' ' ')" \
-"-rwx------ $uid/$gid - 1911-11-11 11:11 executable
-prw------- $uid/$gid - 1911-11-11 11:11 fifo
--rw------- $uid/$gid - 1911-11-11 11:11 file
-srwx------ $uid/$gid - 1911-11-11 11:11 socket
-lrwxrwxrwx $uid/$gid - $symlink_date symlink -> file"
+"-rwx------ $uid/$gid 0 1969-07-20 20:18 executable
+prw------- $uid/$gid 0 1969-07-20 20:18 fifo
+-rw------- $uid/$gid 1024 1969-07-20 20:18 file
+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=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')"
+WVPASSEQ "$(bup ls -ln src/latest"$tmpdir"/src | tr -s ' ' ' ')" \
+"-rwx------ $uid/$gid 0 1969-07-20 15:18 executable
+prw------- $uid/$gid 0 1969-07-20 15:18 fifo
+-rw------- $uid/$gid 1024 1969-07-20 15:18 file
+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"