t_times.sh revision 1.1 1 1.1 jmmv # $NetBSD: t_times.sh,v 1.1 2007/11/12 15:18:28 jmmv Exp $
2 1.1 jmmv #
3 1.1 jmmv # Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
4 1.1 jmmv # All rights reserved.
5 1.1 jmmv #
6 1.1 jmmv # Redistribution and use in source and binary forms, with or without
7 1.1 jmmv # modification, are permitted provided that the following conditions
8 1.1 jmmv # are met:
9 1.1 jmmv # 1. Redistributions of source code must retain the above copyright
10 1.1 jmmv # notice, this list of conditions and the following disclaimer.
11 1.1 jmmv # 2. Redistributions in binary form must reproduce the above copyright
12 1.1 jmmv # notice, this list of conditions and the following disclaimer in the
13 1.1 jmmv # documentation and/or other materials provided with the distribution.
14 1.1 jmmv # 3. All advertising materials mentioning features or use of this software
15 1.1 jmmv # must display the following acknowledgement:
16 1.1 jmmv # This product includes software developed by the NetBSD
17 1.1 jmmv # Foundation, Inc. and its contributors.
18 1.1 jmmv # 4. Neither the name of The NetBSD Foundation nor the names of its
19 1.1 jmmv # contributors may be used to endorse or promote products derived
20 1.1 jmmv # from this software without specific prior written permission.
21 1.1 jmmv #
22 1.1 jmmv # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23 1.1 jmmv # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24 1.1 jmmv # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 1.1 jmmv # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26 1.1 jmmv # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 1.1 jmmv # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 1.1 jmmv # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 1.1 jmmv # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 1.1 jmmv # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 1.1 jmmv # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 1.1 jmmv # POSSIBILITY OF SUCH DAMAGE.
33 1.1 jmmv #
34 1.1 jmmv
35 1.1 jmmv #
36 1.1 jmmv # Verifies that node times are properly handled.
37 1.1 jmmv #
38 1.1 jmmv
39 1.1 jmmv atf_test_case empty
40 1.1 jmmv empty_head() {
41 1.1 jmmv atf_set "descr" "Tests that creating an empty file and later" \
42 1.1 jmmv "manipulating it updates times correctly"
43 1.1 jmmv atf_set "require.user" "root"
44 1.1 jmmv }
45 1.1 jmmv empty_body() {
46 1.1 jmmv test_mount
47 1.1 jmmv
48 1.1 jmmv atf_check 'touch a' 0 null null
49 1.1 jmmv eval $(stat -s a | sed -e 's|st_|ost_|g') || atf_fail "stat failed"
50 1.1 jmmv [ ${ost_birthtime} -eq ${ost_atime} ] || atf_fail "Incorrect atime"
51 1.1 jmmv [ ${ost_birthtime} -eq ${ost_ctime} ] || atf_fail "Incorrect ctime"
52 1.1 jmmv [ ${ost_birthtime} -eq ${ost_mtime} ] || atf_fail "Incorrect mtime"
53 1.1 jmmv
54 1.1 jmmv sleep 1
55 1.1 jmmv atf_check 'cat a' 0 ignore null
56 1.1 jmmv eval $(stat -s a) || atf_fail "stat failed"
57 1.1 jmmv [ ${st_atime} -gt ${ost_atime} ] || atf_fail "Incorrect atime"
58 1.1 jmmv [ ${st_ctime} -eq ${ost_ctime} ] || atf_fail "Incorrect ctime"
59 1.1 jmmv [ ${st_mtime} -eq ${ost_mtime} ] || atf_fail "Incorrect mtime"
60 1.1 jmmv
61 1.1 jmmv sleep 1
62 1.1 jmmv echo foo >a || atf_fail "Write failed"
63 1.1 jmmv eval $(stat -s a) || atf_fail "stat failed"
64 1.1 jmmv [ ${st_atime} -gt ${ost_atime} ] || atf_fail "Incorrect atime"
65 1.1 jmmv [ ${st_ctime} -gt ${ost_ctime} ] || atf_fail "Incorrect ctime"
66 1.1 jmmv [ ${st_mtime} -gt ${ost_mtime} ] || atf_fail "Incorrect mtime"
67 1.1 jmmv
68 1.1 jmmv test_unmount
69 1.1 jmmv }
70 1.1 jmmv
71 1.1 jmmv atf_test_case non_empty
72 1.1 jmmv non_empty_head() {
73 1.1 jmmv atf_set "descr" "Tests that creating a non-empty file and later" \
74 1.1 jmmv "manipulating it updates times correctly"
75 1.1 jmmv atf_set "require.user" "root"
76 1.1 jmmv }
77 1.1 jmmv non_empty_body() {
78 1.1 jmmv test_mount
79 1.1 jmmv
80 1.1 jmmv echo foo >b || atf_fail "Non-empty creation failed"
81 1.1 jmmv eval $(stat -s b | sed -e 's|st_|ost_|g') || atf_fail "stat failed"
82 1.1 jmmv
83 1.1 jmmv sleep 1
84 1.1 jmmv atf_check 'cat b' 0 ignore null
85 1.1 jmmv eval $(stat -s b) || atf_fail "stat failed"
86 1.1 jmmv [ ${st_atime} -gt ${ost_atime} ] || atf_fail "Incorrect atime"
87 1.1 jmmv [ ${st_ctime} -eq ${ost_ctime} ] || atf_fail "Incorrect ctime"
88 1.1 jmmv [ ${st_mtime} -eq ${ost_mtime} ] || atf_fail "Incorrect mtime"
89 1.1 jmmv
90 1.1 jmmv test_unmount
91 1.1 jmmv }
92 1.1 jmmv
93 1.1 jmmv atf_test_case link
94 1.1 jmmv link_head() {
95 1.1 jmmv atf_set "descr" "Tests that linking to an existing file updates" \
96 1.1 jmmv "times correctly"
97 1.1 jmmv atf_set "require.user" "root"
98 1.1 jmmv }
99 1.1 jmmv link_body() {
100 1.1 jmmv test_mount
101 1.1 jmmv
102 1.1 jmmv echo foo >c || atf_fail "Non-empty creation failed"
103 1.1 jmmv eval $(stat -s c | sed -e 's|st_|ost_|g') || atf_fail "stat failed"
104 1.1 jmmv
105 1.1 jmmv sleep 1
106 1.1 jmmv atf_check 'ln c d' 0 null null
107 1.1 jmmv eval $(stat -s c) || atf_fail "stat failed"
108 1.1 jmmv [ ${st_atime} -eq ${ost_atime} ] || atf_fail "Incorrect atime"
109 1.1 jmmv [ ${st_ctime} -gt ${ost_ctime} ] || atf_fail "Incorrect ctime"
110 1.1 jmmv [ ${st_mtime} -eq ${ost_mtime} ] || atf_fail "Incorrect mtime"
111 1.1 jmmv
112 1.1 jmmv test_unmount
113 1.1 jmmv }
114 1.1 jmmv
115 1.1 jmmv atf_test_case rename
116 1.1 jmmv rename_head() {
117 1.1 jmmv atf_set "descr" "Tests that renaming an existing file updates" \
118 1.1 jmmv "times correctly"
119 1.1 jmmv atf_set "require.user" "root"
120 1.1 jmmv }
121 1.1 jmmv rename_body() {
122 1.1 jmmv test_mount
123 1.1 jmmv
124 1.1 jmmv atf_check 'mkdir e' 0 null null
125 1.1 jmmv echo foo >e/a || atf_fail "Creation failed"
126 1.1 jmmv eval $(stat -s e | sed -e 's|st_|dost_|g') || atf_fail "stat failed"
127 1.1 jmmv eval $(stat -s e/a | sed -e 's|st_|ost_|g') || atf_fail "stat failed"
128 1.1 jmmv sleep 1
129 1.1 jmmv atf_check 'mv e/a e/b' 0 null null
130 1.1 jmmv eval $(stat -s e | sed -e 's|st_|dst_|g') || atf_fail "stat failed"
131 1.1 jmmv eval $(stat -s e/b) || atf_fail "stat failed"
132 1.1 jmmv [ ${st_atime} -eq ${ost_atime} ] || atf_fail "Incorrect atime"
133 1.1 jmmv [ ${st_ctime} -gt ${ost_ctime} ] || atf_fail "Incorrect ctime"
134 1.1 jmmv [ ${st_mtime} -eq ${ost_mtime} ] || atf_fail "Incorrect mtime"
135 1.1 jmmv [ ${dst_mtime} -gt ${dost_mtime} ] || atf_fail "Incorrect mtime"
136 1.1 jmmv
137 1.1 jmmv test_unmount
138 1.1 jmmv }
139 1.1 jmmv
140 1.1 jmmv atf_init_test_cases() {
141 1.1 jmmv . $(atf_get_srcdir)/../h_funcs.subr
142 1.1 jmmv . $(atf_get_srcdir)/h_funcs.subr
143 1.1 jmmv
144 1.1 jmmv atf_add_test_case empty
145 1.1 jmmv atf_add_test_case non_empty
146 1.1 jmmv atf_add_test_case link
147 1.1 jmmv atf_add_test_case rename
148 1.1 jmmv }
149