1eda14cbcSMatt Macy# 2eda14cbcSMatt Macy# CDDL HEADER START 3eda14cbcSMatt Macy# 4eda14cbcSMatt Macy# The contents of this file are subject to the terms of the 5eda14cbcSMatt Macy# Common Development and Distribution License (the "License"). 6eda14cbcSMatt Macy# You may not use this file except in compliance with the License. 7eda14cbcSMatt Macy# 8eda14cbcSMatt Macy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*271171e0SMartin Matuska# or https://opensource.org/licenses/CDDL-1.0. 10eda14cbcSMatt Macy# See the License for the specific language governing permissions 11eda14cbcSMatt Macy# and limitations under the License. 12eda14cbcSMatt Macy# 13eda14cbcSMatt Macy# When distributing Covered Code, include this CDDL HEADER in each 14eda14cbcSMatt Macy# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15eda14cbcSMatt Macy# If applicable, add the following below this CDDL HEADER, with the 16eda14cbcSMatt Macy# fields enclosed by brackets "[]" replaced with your own identifying 17eda14cbcSMatt Macy# information: Portions Copyright [yyyy] [name of copyright owner] 18eda14cbcSMatt Macy# 19eda14cbcSMatt Macy# CDDL HEADER END 20eda14cbcSMatt Macy# 21eda14cbcSMatt Macy 22eda14cbcSMatt Macy# 23eda14cbcSMatt Macy# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24eda14cbcSMatt Macy# Use is subject to license terms. 25eda14cbcSMatt Macy# 26eda14cbcSMatt Macy 27eda14cbcSMatt Macy# 28eda14cbcSMatt Macy# Copyright (c) 2016 by Delphix. All rights reserved. 29eda14cbcSMatt Macy# 30eda14cbcSMatt Macy 31eda14cbcSMatt Macy. $STF_SUITE/tests/functional/atime/atime.cfg 32eda14cbcSMatt Macy. $STF_SUITE/include/libtest.shlib 33eda14cbcSMatt Macy 34eda14cbcSMatt Macy# 35eda14cbcSMatt Macy# Check if the access time for specified file is updated. 36eda14cbcSMatt Macy# 37eda14cbcSMatt Macy# $1 Given an absolute path to a file name 38eda14cbcSMatt Macy# 39eda14cbcSMatt Macy# Return value: 40eda14cbcSMatt Macy# 0 -> The access time is updated. 41eda14cbcSMatt Macy# 1 -> The access time is not updated. 42eda14cbcSMatt Macy# 43eda14cbcSMatt Macyfunction check_atime_updated 44eda14cbcSMatt Macy{ 45eda14cbcSMatt Macy typeset filename=$1 46eda14cbcSMatt Macy 47eda14cbcSMatt Macy if is_linux; then 48eda14cbcSMatt Macy typeset before=$(stat -c %X $filename) 49eda14cbcSMatt Macy sleep 2 50eda14cbcSMatt Macy elif is_freebsd; then 51eda14cbcSMatt Macy typeset before=$(stat -f %a $filename) 52eda14cbcSMatt Macy sleep 2 53eda14cbcSMatt Macy else 54eda14cbcSMatt Macy typeset before=$(ls -Eu $filename | awk '{print $7}') 55eda14cbcSMatt Macy fi 56eda14cbcSMatt Macy 57eda14cbcSMatt Macy log_must cat $filename 58eda14cbcSMatt Macy 59eda14cbcSMatt Macy if is_linux; then 60eda14cbcSMatt Macy typeset after=$(stat -c %X $filename) 61eda14cbcSMatt Macy elif is_freebsd; then 62eda14cbcSMatt Macy typeset after=$(stat -f %a $filename) 63eda14cbcSMatt Macy else 64eda14cbcSMatt Macy typeset after=$(ls -Eu $filename | awk '{print $7}') 65eda14cbcSMatt Macy fi 66eda14cbcSMatt Macy 67eda14cbcSMatt Macy if [[ $before != $after ]]; then 68eda14cbcSMatt Macy return 0 69eda14cbcSMatt Macy else 70eda14cbcSMatt Macy return 1 71eda14cbcSMatt Macy fi 72eda14cbcSMatt Macy} 73eda14cbcSMatt Macy 74eda14cbcSMatt Macyfunction setup_snap_clone 75eda14cbcSMatt Macy{ 76eda14cbcSMatt Macy if [ -d "/$TESTPOOL/$TESTFS" ]; then 77eda14cbcSMatt Macy # No mountpoint case (default). 78eda14cbcSMatt Macy log_must touch /$TESTPOOL/$TESTFS/$TESTFILE 79eda14cbcSMatt Macy else 80eda14cbcSMatt Macy # Create two file to verify snapshot. 81eda14cbcSMatt Macy log_must touch $TESTDIR/$TESTFILE 82eda14cbcSMatt Macy fi 83eda14cbcSMatt Macy 84eda14cbcSMatt Macy create_snapshot $TESTPOOL/$TESTFS $TESTSNAP 85eda14cbcSMatt Macy create_clone $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTCLONE 86eda14cbcSMatt Macy} 87eda14cbcSMatt Macy 88eda14cbcSMatt Macyfunction reset_atime 89eda14cbcSMatt Macy{ 90eda14cbcSMatt Macy zfs inherit atime $TESTPOOL 91eda14cbcSMatt Macy zfs inherit atime $TESTPOOL/$TESTFS 92eda14cbcSMatt Macy zfs inherit atime $TESTPOOL/$TESTCLONE 93eda14cbcSMatt Macy zfs inherit relatime $TESTPOOL 94eda14cbcSMatt Macy zfs inherit relatime $TESTPOOL/$TESTFS 95eda14cbcSMatt Macy zfs inherit relatime $TESTPOOL/$TESTCLONE 96eda14cbcSMatt Macy} 97eda14cbcSMatt Macy 98eda14cbcSMatt Macyfunction cleanup 99eda14cbcSMatt Macy{ 100eda14cbcSMatt Macy destroy_clone $TESTPOOL/$TESTCLONE 101eda14cbcSMatt Macy destroy_snapshot $TESTPOOL/$TESTFS@$TESTSNAP 102eda14cbcSMatt Macy} 103