fix incorrect stat flags on linux in metadata test scripts

Thu, 23 May 2024 23:19:06 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 23 May 2024 23:19:06 +0200
changeset 817
22257f6d06a3
parent 815
1f40ca07ae1b
child 818
bc782cca0759

fix incorrect stat flags on linux in metadata test scripts

test/bin-test/test-dav-sync-metadata1.sh file | annotate | diff | comparison | revisions
test/bin-test/test-dav-sync-metadata3.sh file | annotate | diff | comparison | revisions
--- a/test/bin-test/test-dav-sync-metadata1.sh	Sat Apr 20 13:01:58 2024 +0200
+++ b/test/bin-test/test-dav-sync-metadata1.sh	Thu May 23 23:19:06 2024 +0200
@@ -38,12 +38,16 @@
 	exit 1
 fi
 
-TEST=`uname | grep BSD`
-if [ $? -eq 0 ];
+# stat parameter for getting unix time
+STAT_TIME_FMT="-c %Y"
+
+if uname -a | grep BSD > /dev/null;
 then
-	alias stat_="stat -f %m"
-else
-	alias stat_="stat -c %Y"
+	STAT_TIME_FMT="-f %m"
+fi
+if uname -a | grep Darwin >  /dev/null;
+then
+	STAT_TIME_FMT="-f %m"
 fi
 
 XATTR=../../build/bin/xattrtool
@@ -159,11 +163,11 @@
 check_tmpout "0 conflicts" "test 2: wrong conflict counter (pull)"
 check_tmpout "0 errors" "test 2: wrong error counter (pull)"
 
-MTIMEA1=`stat_ tmp-sync/test4a/file1`
-MTIMEB1=`stat_ tmp-sync/test4b/file1`
+MTIMEA1=`stat $STAT_TIME_FMT tmp-sync/test4a/file1`
+MTIMEB1=`stat $STAT_TIME_FMT tmp-sync/test4b/file1`
 
-MTIMEA2=`stat_ tmp-sync/test4a/dir1/file2`
-MTIMEB2=`stat_ tmp-sync/test4b/dir1/file2`
+MTIMEA2=`stat $STAT_TIME_FMT tmp-sync/test4a/dir1/file2`
+MTIMEB2=`stat $STAT_TIME_FMT tmp-sync/test4b/dir1/file2`
 
 if [ $MTIMEA1 != $MTIMEB1 ]; then
 	echo "file1: mtime not synced"
@@ -190,8 +194,8 @@
 check_tmpout "0 conflicts" "test 3: wrong conflict counter (pull)"
 check_tmpout "0 errors" "test 3: wrong error counter (pull)"
 
-MTIMEA1=`stat_ tmp-sync/test4a/file1`
-MTIMEB1=`stat_ tmp-sync/test4b/file1`
+MTIMEA1=`stat $STAT_TIME_FMT tmp-sync/test4a/file1`
+MTIMEB1=`stat $STAT_TIME_FMT tmp-sync/test4b/file1`
 
 if [ $MTIMEA1 != $MTIMEB1 ]; then
 	echo "file1: mtime not synced"
--- a/test/bin-test/test-dav-sync-metadata3.sh	Sat Apr 20 13:01:58 2024 +0200
+++ b/test/bin-test/test-dav-sync-metadata3.sh	Thu May 23 23:19:06 2024 +0200
@@ -43,13 +43,11 @@
 # stat parameter for getting unix time
 STAT_TIME_FMT="-c %Y"
 
-TEST=`uname -a | grep BSD`
-if [ $? -ne 0 ];
+if uname -a | grep BSD > /dev/null;
 then
 	STAT_TIME_FMT="-f %m"
 fi
-TEST=`uname -a | grep Darwin`
-if [ $? -ne 0 ];
+if uname -a | grep Darwin >  /dev/null;
 then
 	STAT_TIME_FMT="-f %m"
 fi

mercurial