t_readdir.sh revision 1.1
11.1Sjmmv# $NetBSD: t_readdir.sh,v 1.1 2007/11/12 15:18:25 jmmv Exp $
21.1Sjmmv#
31.1Sjmmv# Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
41.1Sjmmv# All rights reserved.
51.1Sjmmv#
61.1Sjmmv# Redistribution and use in source and binary forms, with or without
71.1Sjmmv# modification, are permitted provided that the following conditions
81.1Sjmmv# are met:
91.1Sjmmv# 1. Redistributions of source code must retain the above copyright
101.1Sjmmv#    notice, this list of conditions and the following disclaimer.
111.1Sjmmv# 2. Redistributions in binary form must reproduce the above copyright
121.1Sjmmv#    notice, this list of conditions and the following disclaimer in the
131.1Sjmmv#    documentation and/or other materials provided with the distribution.
141.1Sjmmv# 3. All advertising materials mentioning features or use of this software
151.1Sjmmv#    must display the following acknowledgement:
161.1Sjmmv#        This product includes software developed by the NetBSD
171.1Sjmmv#        Foundation, Inc. and its contributors.
181.1Sjmmv# 4. Neither the name of The NetBSD Foundation nor the names of its
191.1Sjmmv#    contributors may be used to endorse or promote products derived
201.1Sjmmv#    from this software without specific prior written permission.
211.1Sjmmv#
221.1Sjmmv# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
231.1Sjmmv# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
241.1Sjmmv# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
251.1Sjmmv# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
261.1Sjmmv# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
271.1Sjmmv# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
281.1Sjmmv# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
291.1Sjmmv# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
301.1Sjmmv# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
311.1Sjmmv# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
321.1Sjmmv# POSSIBILITY OF SUCH DAMAGE.
331.1Sjmmv#
341.1Sjmmv
351.1Sjmmv#
361.1Sjmmv# Verifies that the readdir operation works.
371.1Sjmmv#
381.1Sjmmv
391.1Sjmmvatf_test_case dots
401.1Sjmmvdots_head() {
411.1Sjmmv	atf_set "descr" "Verifies that readdir returns the '.' and '..'" \
421.1Sjmmv	                "entries"
431.1Sjmmv	atf_set "require.user" "root"
441.1Sjmmv}
451.1Sjmmvdots_body() {
461.1Sjmmv	test_mount
471.1Sjmmv
481.1Sjmmv	atf_check '/bin/ls -a' 0 stdout null
491.1Sjmmv	atf_check "grep '^\.$' ../stdout" 0 ignore null
501.1Sjmmv	atf_check "grep '^\..$' ../stdout" 0 ignore null
511.1Sjmmv
521.1Sjmmv	test_unmount
531.1Sjmmv}
541.1Sjmmv
551.1Sjmmvatf_test_case types
561.1Sjmmvtypes_head() {
571.1Sjmmv	atf_set "descr" "Verifies that readdir works for all different" \
581.1Sjmmv	                "file types"
591.1Sjmmv	atf_set "require.user" "root"
601.1Sjmmv}
611.1Sjmmvtypes_body() {
621.1Sjmmv	test_mount
631.1Sjmmv
641.1Sjmmv	atf_check 'mkdir dir' 0 null null
651.1Sjmmv	atf_check 'touch reg' 0 null null
661.1Sjmmv	atf_check 'ln -s reg lnk' 0 null null
671.1Sjmmv	atf_check 'mknod blk b 0 0' 0 null null
681.1Sjmmv	atf_check 'mknod chr c 0 0' 0 null null
691.1Sjmmv	atf_check 'mknod fifo p' 0 null null
701.1Sjmmv	atf_check "$(atf_get_srcdir)/h_tools sockets sock" 0 null null
711.1Sjmmv
721.1Sjmmv	atf_check 'ls' 0 ignore null
731.1Sjmmv	atf_check 'rm -rf *' 0 null null
741.1Sjmmv
751.1Sjmmv	test_unmount
761.1Sjmmv}
771.1Sjmmv
781.1Sjmmvatf_test_case caching
791.1Sjmmvcaching_head() {
801.1Sjmmv	atf_set "descr" "Catch a bug caused by incorrect invalidation of" \
811.1Sjmmv	                "readdir caching variables"
821.1Sjmmv	atf_set "require.user" "root"
831.1Sjmmv}
841.1Sjmmvcaching_body() {
851.1Sjmmv	test_mount
861.1Sjmmv
871.1Sjmmv	atf_check 'touch $(jot 10)' 0 null null
881.1Sjmmv	atf_check 'rm *' 0 null null
891.1Sjmmv	atf_check 'touch $(jot 20)' 0 null null
901.1Sjmmv	atf_check 'ls >/dev/null' 0 null null
911.1Sjmmv
921.1Sjmmv	test_unmount
931.1Sjmmv}
941.1Sjmmv
951.1Sjmmvatf_test_case many
961.1Sjmmvmany_head() {
971.1Sjmmv	atf_set "descr" "Verifies that readdir works with many files"
981.1Sjmmv	atf_set "require.user" "root"
991.1Sjmmv}
1001.1Sjmmvmany_body() {
1011.1Sjmmv	test_mount
1021.1Sjmmv
1031.1Sjmmv	atf_check 'mkdir a' 0 null null
1041.1Sjmmv	echo "Creating 500 files"
1051.1Sjmmv	for f in $(jot 500); do
1061.1Sjmmv		touch a/$f
1071.1Sjmmv	done
1081.1Sjmmv	atf_check 'rm a/*' 0 null null
1091.1Sjmmv	atf_check 'rmdir a' 0 null null
1101.1Sjmmv
1111.1Sjmmv	test_unmount
1121.1Sjmmv}
1131.1Sjmmv
1141.1Sjmmvatf_init_test_cases() {
1151.1Sjmmv	. $(atf_get_srcdir)/../h_funcs.subr
1161.1Sjmmv	. $(atf_get_srcdir)/h_funcs.subr
1171.1Sjmmv
1181.1Sjmmv	atf_add_test_case dots
1191.1Sjmmv	atf_add_test_case types
1201.1Sjmmv	atf_add_test_case caching
1211.1Sjmmv	atf_add_test_case many
1221.1Sjmmv}
123