btrfs-progs/tests/convert-tests/019-ext4-copy-timestamps/test.sh
David Sterba f6bbe06c08 btrfs-progs: tests: add protection against running out of test suite
Executing the script inside the directories as './test.sh' is not
supposed to work but could happen accidentally. With an exit after
attempting to source the we can fix that.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-04-25 16:59:41 +02:00

46 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# Check if [acm]time values are copied from ext4 with full precision
source "$TEST_TOP/common" || exit
source "$TEST_TOP/common.convert" || exit
check_prereq btrfs-convert
check_global_prereq mke2fs
setup_root_helper
prepare_test_dev
convert_test_prep_fs ext4 mke2fs -t ext4 -b 4096
features=$(run_check_stdout dumpe2fs "$TEST_DEV" | grep "Filesystem features")
if ! echo "$features" | grep -q "extra_isize"; then
_not_run "extended inode size not supported, no 64bit timestamp check possible"
fi
run_check $SUDO_HELPER touch "$TEST_MNT/file"
# Read time values
run_check stat "$TEST_MNT/file"
atime=$(run_check_stdout stat --format=%x "$TEST_MNT/file")
mtime=$(run_check_stdout stat --format=%y "$TEST_MNT/file")
ctime=$(run_check_stdout stat --format=%z "$TEST_MNT/file")
run_check_umount_test_dev
convert_test_do_convert
run_check_mount_test_dev
run_check stat "$TEST_MNT/file"
# Verify
time=$(run_check_stdout stat --format=%x "$TEST_MNT/file")
if [ "$time" != "$atime" ]; then
_fail "atime on converted inode does not match"
fi
time=$(run_check_stdout stat --format=%y "$TEST_MNT/file")
if [ "$time" != "$mtime" ]; then
_fail "mtime on converted inoded does not match"
fi
time=$(run_check_stdout stat --format=%z "$TEST_MNT/file")
if [ "$time" != "$mtime" ]; then
_fail "ctime on converted inoded does not match"
fi
run_check_umount_test_dev