1f8c94cecSXin LI#!/bin/sh 2f8c94cecSXin LI# 3f8c94cecSXin LI# $NetBSD: t_times,v 1.6 2006/11/09 16:20:06 jmmv Exp $ 4f8c94cecSXin LI# 5f8c94cecSXin LI# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. 6f8c94cecSXin LI# All rights reserved. 7f8c94cecSXin LI# 8f8c94cecSXin LI# This code is derived from software contributed to The NetBSD Foundation 9f8c94cecSXin LI# by Julio M. Merino Vidal, developed as part of Google's Summer of Code 10f8c94cecSXin LI# 2005 program. 11f8c94cecSXin LI# 12f8c94cecSXin LI# Redistribution and use in source and binary forms, with or without 13f8c94cecSXin LI# modification, are permitted provided that the following conditions 14f8c94cecSXin LI# are met: 15f8c94cecSXin LI# 1. Redistributions of source code must retain the above copyright 16f8c94cecSXin LI# notice, this list of conditions and the following disclaimer. 17f8c94cecSXin LI# 2. Redistributions in binary form must reproduce the above copyright 18f8c94cecSXin LI# notice, this list of conditions and the following disclaimer in the 19f8c94cecSXin LI# documentation and/or other materials provided with the distribution. 20f8c94cecSXin LI# 21f8c94cecSXin LI# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 22f8c94cecSXin LI# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 23f8c94cecSXin LI# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24f8c94cecSXin LI# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 25f8c94cecSXin LI# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26f8c94cecSXin LI# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27f8c94cecSXin LI# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28f8c94cecSXin LI# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29f8c94cecSXin LI# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30f8c94cecSXin LI# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31f8c94cecSXin LI# POSSIBILITY OF SUCH DAMAGE. 32f8c94cecSXin LI# 33f8c94cecSXin LI# 34f8c94cecSXin LI 35f8c94cecSXin LI# 36f8c94cecSXin LI# Verifies that node times are properly handled. 37f8c94cecSXin LI# 38f8c94cecSXin LI 39f8c94cecSXin LItest_run() { 40f8c94cecSXin LI test_mount 41f8c94cecSXin LI 42f8c94cecSXin LI test_name "Creation of empty file" 43f8c94cecSXin LI touch a || die 44f8c94cecSXin LI eval $(stat -s a | sed -e 's|st_|ost_|g') || die 45f8c94cecSXin LI [ ${ost_birthtime} -eq ${ost_atime} ] || die 46f8c94cecSXin LI [ ${ost_birthtime} -eq ${ost_ctime} ] || die 47f8c94cecSXin LI [ ${ost_birthtime} -eq ${ost_mtime} ] || die 48f8c94cecSXin LI 49f8c94cecSXin LI test_name "Read of empty file" 50f8c94cecSXin LI sleep 1 51f8c94cecSXin LI cat a >/dev/null || die 52f8c94cecSXin LI eval $(stat -s a) || die 53f8c94cecSXin LI [ ${st_atime} -gt ${ost_atime} ] || die 54f8c94cecSXin LI [ ${st_ctime} -eq ${ost_ctime} ] || die 55f8c94cecSXin LI [ ${st_mtime} -eq ${ost_mtime} ] || die 56f8c94cecSXin LI 57f8c94cecSXin LI test_name "Write to (and extension of) empty file" 58f8c94cecSXin LI sleep 1 59f8c94cecSXin LI echo foo >a || die 60f8c94cecSXin LI eval $(stat -s a) || die 61f8c94cecSXin LI [ ${st_atime} -gt ${ost_atime} ] || die 62f8c94cecSXin LI [ ${st_ctime} -gt ${ost_ctime} ] || die 63f8c94cecSXin LI [ ${st_mtime} -gt ${ost_mtime} ] || die 64f8c94cecSXin LI 65f8c94cecSXin LI test_name "Creation of non-empty file" 66f8c94cecSXin LI echo foo >b || die 67f8c94cecSXin LI eval $(stat -s b | sed -e 's|st_|ost_|g') || die 68f8c94cecSXin LI 69f8c94cecSXin LI test_name "Read of non-empty file" 70f8c94cecSXin LI sleep 1 71f8c94cecSXin LI cat b >/dev/null || die 72f8c94cecSXin LI eval $(stat -s b) || die 73f8c94cecSXin LI [ ${st_atime} -gt ${ost_atime} ] || die 74f8c94cecSXin LI [ ${st_ctime} -eq ${ost_ctime} ] || die 75f8c94cecSXin LI [ ${st_mtime} -eq ${ost_mtime} ] || die 76f8c94cecSXin LI 77f8c94cecSXin LI test_name "Creation of non-empty file" 78f8c94cecSXin LI echo foo >c || die 79f8c94cecSXin LI eval $(stat -s c | sed -e 's|st_|ost_|g') || die 80f8c94cecSXin LI 81f8c94cecSXin LI test_name "New link to non-empty file" 82f8c94cecSXin LI sleep 1 83f8c94cecSXin LI ln c d || die 84f8c94cecSXin LI eval $(stat -s c) || die 85f8c94cecSXin LI [ ${st_atime} -eq ${ost_atime} ] || die 86f8c94cecSXin LI [ ${st_ctime} -gt ${ost_ctime} ] || die 87f8c94cecSXin LI [ ${st_mtime} -eq ${ost_mtime} ] || die 88f8c94cecSXin LI 89f8c94cecSXin LI test_name "File renaming does not change times" 90f8c94cecSXin LI mkdir e || die 91f8c94cecSXin LI echo foo >e/a || die 92f8c94cecSXin LI eval $(stat -s e | sed -e 's|st_|dost_|g') || die 93f8c94cecSXin LI eval $(stat -s e/a | sed -e 's|st_|ost_|g') || die 94f8c94cecSXin LI sleep 1 95f8c94cecSXin LI mv e/a e/b || die 96f8c94cecSXin LI eval $(stat -s e | sed -e 's|st_|dst_|g') || die 97f8c94cecSXin LI eval $(stat -s e/b) || die 98f8c94cecSXin LI [ ${st_atime} -eq ${ost_atime} ] || die 99f8c94cecSXin LI [ ${st_ctime} -gt ${ost_ctime} ] || die 100f8c94cecSXin LI [ ${st_mtime} -eq ${ost_mtime} ] || die 101f8c94cecSXin LI [ ${dst_mtime} -gt ${dost_mtime} ] || die 102f8c94cecSXin LI 103f8c94cecSXin LI test_unmount 104f8c94cecSXin LI} 105f8c94cecSXin LI 106f8c94cecSXin LI. ${SUBRDIR}/h_funcs.subr 107