From f639371af7d98fb1c41e81dc5dd938f97ef842b8 Mon Sep 17 00:00:00 2001 From: Johannes Schauer Marin Rodrigues Date: Sun, 21 Apr 2024 09:04:34 +0200 Subject: [PATCH] tests: stat -c %Y is not portable, replace with perl stat in m_rootgnutar Signed-off-by: Theodore Ts'o --- tests/m_rootgnutar/script | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/m_rootgnutar/script b/tests/m_rootgnutar/script index c213b5a..3d5cd79 100644 --- a/tests/m_rootgnutar/script +++ b/tests/m_rootgnutar/script @@ -14,6 +14,7 @@ MKFS_TAR="$TMPFILE.tar" MKFS_DIR="$TMPFILE.dir" OUT="$test_name.log" EXP="$test_dir/expect" +DEBUGFS_EXE_MTIME=$(perl -e 'print((stat ($ARGV[0]))[9])' "$DEBUGFS_EXE") # we put everything in a subdir because we cannot rdump the root as that would # require permissions to changing ownership of /lost+found @@ -44,15 +45,15 @@ if false; then tar --sort=name -C "$MKFS_DIR" --mtime="$DEBUGFS_EXE" --clamp-mtime --format=gnu -cf "$MKFS_TAR.uniq" test else # same as above but without using GNU tar - perl $test_dir/mkgnutar.pl --nopadding --directory="$MKFS_DIR" --mtime "$(stat -c %Y $DEBUGFS_EXE)" test > "$MKFS_TAR.dupl" + perl $test_dir/mkgnutar.pl --nopadding --directory="$MKFS_DIR" --mtime "$DEBUGFS_EXE_MTIME" test > "$MKFS_TAR.dupl" echo "Test me" > "$MKFS_DIR/test/dir/file" - perl $test_dir/mkgnutar.pl --nopadding --directory="$MKFS_DIR" --mtime "$(stat -c %Y $DEBUGFS_EXE)" test/dir/file >> "$MKFS_TAR.dupl" - perl $test_dir/mkgnutar.pl --nopadding --directory="$MKFS_DIR" --mtime "$(stat -c %Y $DEBUGFS_EXE)" --no-recursion test/ >> "$MKFS_TAR.dupl" + perl $test_dir/mkgnutar.pl --nopadding --directory="$MKFS_DIR" --mtime "$DEBUGFS_EXE_MTIME" test/dir/file >> "$MKFS_TAR.dupl" + perl $test_dir/mkgnutar.pl --nopadding --directory="$MKFS_DIR" --mtime "$DEBUGFS_EXE_MTIME" --no-recursion test/ >> "$MKFS_TAR.dupl" # add end-of-archive entry truncate -s +1024 "$MKFS_TAR.dupl" # pad to a multiple of the record size truncate -s %10240 "$MKFS_TAR.dupl" - perl $test_dir/mkgnutar.pl --directory="$MKFS_DIR" --mtime "$(stat -c %Y $DEBUGFS_EXE)" test > "$MKFS_TAR.uniq" + perl $test_dir/mkgnutar.pl --directory="$MKFS_DIR" --mtime "$DEBUGFS_EXE_MTIME" test > "$MKFS_TAR.uniq" fi rm -r "$MKFS_DIR" @@ -105,7 +106,7 @@ for ext in uniq dupl; do if false; then tar --sort=name -C "$MKFS_DIR" --mtime="$DEBUGFS_EXE" --clamp-mtime --format=gnu -cvf "$TMPFILE.new.tar" test 2>&1; else - perl $test_dir/mkgnutar.pl --verbose --directory="$MKFS_DIR" --mtime "$(stat -c %Y $DEBUGFS_EXE)" test 2>&1 > "$TMPFILE.new.tar"; + perl $test_dir/mkgnutar.pl --verbose --directory="$MKFS_DIR" --mtime "$DEBUGFS_EXE_MTIME" test 2>&1 > "$TMPFILE.new.tar"; fi; echo Exit status is $?; $FSCK -f -n "$TMPFILE.$ext" 2>&1; -- 1.8.3.1