aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRyan Moeller <[email protected]>2021-07-26 16:08:52 -0400
committerBrian Behlendorf <[email protected]>2021-08-17 10:25:58 -0700
commit8ae86e2edc736483c1530fd689525aa2460eaec8 (patch)
tree4d0edf8998d40598c124c295b14599d7601eeb2f /tests
parentabbf0bd4eba8c44e370c343b1a3ab74f13fd0840 (diff)
ZTS: Add tests for creation time
Reviewed-by: Tony Nguyen <[email protected]> Reviewed-by: Allan Jude <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes #12432
Diffstat (limited to 'tests')
-rw-r--r--tests/runfiles/common.run4
-rwxr-xr-xtests/test-runner/bin/zts-report.py.in7
-rw-r--r--tests/zfs-tests/include/libtest.shlib28
-rw-r--r--tests/zfs-tests/tests/functional/Makefile.am1
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_timestamp.ksh6
-rw-r--r--tests/zfs-tests/tests/functional/crtime/Makefile.am5
-rwxr-xr-xtests/zfs-tests/tests/functional/crtime/cleanup.ksh34
-rwxr-xr-xtests/zfs-tests/tests/functional/crtime/crtime_001_pos.ksh71
-rwxr-xr-xtests/zfs-tests/tests/functional/crtime/setup.ksh35
9 files changed, 186 insertions, 5 deletions
diff --git a/tests/runfiles/common.run b/tests/runfiles/common.run
index 536788f2e..895e70552 100644
--- a/tests/runfiles/common.run
+++ b/tests/runfiles/common.run
@@ -575,6 +575,10 @@ tags = ['functional', 'compression']
tests = ['cp_files_001_pos']
tags = ['functional', 'cp_files']
+[tests/functional/crtime]
+tests = ['crtime_001_pos' ]
+tags = ['functional', 'crtime']
+
[tests/functional/ctime]
tests = ['ctime_001_pos' ]
tags = ['functional', 'ctime']
diff --git a/tests/test-runner/bin/zts-report.py.in b/tests/test-runner/bin/zts-report.py.in
index 4661a47f5..f5a43c66f 100755
--- a/tests/test-runner/bin/zts-report.py.in
+++ b/tests/test-runner/bin/zts-report.py.in
@@ -76,6 +76,12 @@ python_deps_reason = 'Python modules missing: python-cffi'
tmpfile_reason = 'Kernel O_TMPFILE support required'
#
+# Some tests require the statx(2) system call on Linux which was first
+# introduced in the 4.11 kernel.
+#
+statx_reason = 'Kernel statx(2) system call required on Linux'
+
+#
# Some tests require that the NFS client and server utilities be installed.
#
share_reason = 'NFS client and server utilities required'
@@ -193,6 +199,7 @@ elif sys.platform.startswith('linux'):
#
maybe = {
'chattr/setup': ['SKIP', exec_reason],
+ 'crtime/crtime_001_pos': ['SKIP', statx_reason],
'cli_root/zdb/zdb_006_pos': ['FAIL', known_reason],
'cli_root/zfs_destroy/zfs_destroy_dev_removal_condense':
['FAIL', known_reason],
diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib
index 5a360bd5e..1dc6881b6 100644
--- a/tests/zfs-tests/include/libtest.shlib
+++ b/tests/zfs-tests/include/libtest.shlib
@@ -4024,6 +4024,34 @@ function stat_size #<path>
esac
}
+function stat_ctime #<path>
+{
+ typeset path=$1
+
+ case $(uname) in
+ FreeBSD)
+ stat -f %c "$path"
+ ;;
+ *)
+ stat -c %Z "$path"
+ ;;
+ esac
+}
+
+function stat_crtime #<path>
+{
+ typeset path=$1
+
+ case $(uname) in
+ FreeBSD)
+ stat -f %B "$path"
+ ;;
+ *)
+ stat -c %W "$path"
+ ;;
+ esac
+}
+
# Run a command as if it was being run in a TTY.
#
# Usage:
diff --git a/tests/zfs-tests/tests/functional/Makefile.am b/tests/zfs-tests/tests/functional/Makefile.am
index 3a5b7b0b9..137cddd5f 100644
--- a/tests/zfs-tests/tests/functional/Makefile.am
+++ b/tests/zfs-tests/tests/functional/Makefile.am
@@ -16,6 +16,7 @@ SUBDIRS = \
cli_user \
compression \
cp_files \
+ crtime \
ctime \
deadman \
delegate \
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_timestamp.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_timestamp.ksh
index a4cedca49..62c4e768c 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_timestamp.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_timestamp.ksh
@@ -84,11 +84,7 @@ do
continue;
fi
- if is_freebsd; then
- filetime="$(stat -f "%c" $file)"
- else
- filetime="$(stat -c '%Z' $file)"
- fi
+ filetime=$(stat_ctime $file)
if [[ "$filetime" != "$ctime" ]]; then
log_fail "Unexpected ctime for file $file ($filetime != $ctime)"
else
diff --git a/tests/zfs-tests/tests/functional/crtime/Makefile.am b/tests/zfs-tests/tests/functional/crtime/Makefile.am
new file mode 100644
index 000000000..13e1c2dde
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/crtime/Makefile.am
@@ -0,0 +1,5 @@
+pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/crtime
+dist_pkgdata_SCRIPTS = \
+ cleanup.ksh \
+ setup.ksh \
+ crtime_001_pos.ksh
diff --git a/tests/zfs-tests/tests/functional/crtime/cleanup.ksh b/tests/zfs-tests/tests/functional/crtime/cleanup.ksh
new file mode 100755
index 000000000..3166bd6ec
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/crtime/cleanup.ksh
@@ -0,0 +1,34 @@
+#!/bin/ksh -p
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#
+# Copyright (c) 2013 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/include/libtest.shlib
+
+default_cleanup
diff --git a/tests/zfs-tests/tests/functional/crtime/crtime_001_pos.ksh b/tests/zfs-tests/tests/functional/crtime/crtime_001_pos.ksh
new file mode 100755
index 000000000..4f9810553
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/crtime/crtime_001_pos.ksh
@@ -0,0 +1,71 @@
+#!/bin/ksh -p
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Portions Copyright 2021 iXsystems, Inc.
+#
+
+. $STF_SUITE/include/libtest.shlib
+
+#
+# DESCRIPTION:
+#
+# Verify crtime is functional with xattr=on|sa
+
+verify_runnable "both"
+
+#
+# The statx system call was first added in the 4.11 Linux kernel. Prior to this
+# change there was no mechanism to obtain birth time on Linux. Therefore, this
+# test is expected to fail on older kernels and is skipped.
+#
+if is_linux; then
+ if [[ $(linux_version) -lt $(linux_version "4.11") ]]; then
+ log_unsupported "Requires statx(2) system call on Linux"
+ fi
+ typeset stat_version=$(stat --version | awk '{ print $NF; exit }')
+ if compare_version_gte "8.30" "${stat_version}"; then
+ log_unsupported "Requires coreutils stat(1) > 8.30 on Linux"
+ fi
+fi
+
+log_assert "Verify crtime is functional."
+
+set -A args "sa" "on"
+typeset TESTFILE=$TESTDIR/testfile
+
+for arg in ${args[*]}; do
+ log_note "Testing with xattr set to $arg"
+ log_must zfs set xattr=$arg $TESTPOOL
+ rm -f $TESTFILE
+ log_must touch $TESTFILE
+ typeset -i crtime=$(stat_crtime $TESTFILE)
+ typeset -i ctime=$(stat_ctime $TESTFILE)
+ if (( crtime != ctime )); then
+ log_fail "Incorrect crtime ($crtime != $ctime)"
+ fi
+ log_must touch $TESTFILE
+ typeset -i crtime1=$(stat_crtime $TESTFILE)
+ if (( crtime1 != crtime )); then
+ log_fail "touch modified crtime ($crtime1 != $crtime)"
+ fi
+done
+
+log_pass "Verified crtime is functional."
diff --git a/tests/zfs-tests/tests/functional/crtime/setup.ksh b/tests/zfs-tests/tests/functional/crtime/setup.ksh
new file mode 100755
index 000000000..fc5cec306
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/crtime/setup.ksh
@@ -0,0 +1,35 @@
+#!/bin/ksh -p
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#
+# Copyright (c) 2013 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/include/libtest.shlib
+
+DISK=${DISKS%% *}
+default_setup $DISK