xref: /titanic_44/usr/src/test/zfs-tests/tests/functional/atime/atime_common.kshlib (revision d583b39bfb4e2571d3e41097c5c357ffe353ad45)
1#
2# CDDL HEADER START
3#
4# The contents of this file are subject to the terms of the
5# Common Development and Distribution License (the "License").
6# You may not use this file except in compliance with the License.
7#
8# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9# or http://www.opensolaris.org/os/licensing.
10# See the License for the specific language governing permissions
11# and limitations under the License.
12#
13# When distributing Covered Code, include this CDDL HEADER in each
14# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15# If applicable, add the following below this CDDL HEADER, with the
16# fields enclosed by brackets "[]" replaced with your own identifying
17# information: Portions Copyright [yyyy] [name of copyright owner]
18#
19# CDDL HEADER END
20#
21
22#
23# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24# Use is subject to license terms.
25#
26
27. $STF_SUITE/tests/functional/atime/atime.cfg
28. $STF_SUITE/include/libtest.shlib
29
30#
31# Check if the access time for specified file is updated.
32#
33# $1 Given an absolute path to a file name
34#
35# Return value:
36#	0 -> The access time is updated.
37#	1 -> The access time is not updated.
38#
39function check_atime_updated
40{
41	typeset filename=$1
42
43	typeset before=$($LS -Eu $filename | $AWK '{print $7}')
44	log_must $CAT $filename
45	typeset after=$($LS -Eu $filename | $AWK '{print $7}')
46
47	if [[ $before != $after ]]; then
48		return 0
49	else
50		return 1
51	fi
52}
53
54function setup_snap_clone
55{
56	# Create two file to verify snapshot.
57	log_must $TOUCH $TESTDIR/$TESTFILE
58
59	create_snapshot $TESTPOOL/$TESTFS $TESTSNAP
60	create_clone $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTCLONE
61}
62
63function cleanup
64{
65	destroy_clone $TESTPOOL/$TESTCLONE
66	destroy_snapshot $TESTPOOL/$TESTFS@$TESTSNAP
67}
68