1# $NetBSD: t_readdir.sh,v 1.1 2007/11/12 15:18:25 jmmv Exp $ 2# 3# Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: 9# 1. Redistributions of source code must retain the above copyright 10# notice, this list of conditions and the following disclaimer. 11# 2. Redistributions in binary form must reproduce the above copyright 12# notice, this list of conditions and the following disclaimer in the 13# documentation and/or other materials provided with the distribution. 14# 3. All advertising materials mentioning features or use of this software 15# must display the following acknowledgement: 16# This product includes software developed by the NetBSD 17# Foundation, Inc. and its contributors. 18# 4. Neither the name of The NetBSD Foundation nor the names of its 19# contributors may be used to endorse or promote products derived 20# from this software without specific prior written permission. 21# 22# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 23# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 24# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 26# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32# POSSIBILITY OF SUCH DAMAGE. 33# 34 35# 36# Verifies that the readdir operation works. 37# 38 39atf_test_case dots 40dots_head() { 41 atf_set "descr" "Verifies that readdir returns the '.' and '..'" \ 42 "entries" 43 atf_set "require.user" "root" 44} 45dots_body() { 46 test_mount 47 48 atf_check '/bin/ls -a' 0 stdout null 49 atf_check "grep '^\.$' ../stdout" 0 ignore null 50 atf_check "grep '^\..$' ../stdout" 0 ignore null 51 52 test_unmount 53} 54 55atf_test_case types 56types_head() { 57 atf_set "descr" "Verifies that readdir works for all different" \ 58 "file types" 59 atf_set "require.user" "root" 60} 61types_body() { 62 test_mount 63 64 atf_check 'mkdir dir' 0 null null 65 atf_check 'touch reg' 0 null null 66 atf_check 'ln -s reg lnk' 0 null null 67 atf_check 'mknod blk b 0 0' 0 null null 68 atf_check 'mknod chr c 0 0' 0 null null 69 atf_check 'mknod fifo p' 0 null null 70 atf_check "$(atf_get_srcdir)/h_tools sockets sock" 0 null null 71 72 atf_check 'ls' 0 ignore null 73 atf_check 'rm -rf *' 0 null null 74 75 test_unmount 76} 77 78atf_test_case caching 79caching_head() { 80 atf_set "descr" "Catch a bug caused by incorrect invalidation of" \ 81 "readdir caching variables" 82 atf_set "require.user" "root" 83} 84caching_body() { 85 test_mount 86 87 atf_check 'touch $(jot 10)' 0 null null 88 atf_check 'rm *' 0 null null 89 atf_check 'touch $(jot 20)' 0 null null 90 atf_check 'ls >/dev/null' 0 null null 91 92 test_unmount 93} 94 95atf_test_case many 96many_head() { 97 atf_set "descr" "Verifies that readdir works with many files" 98 atf_set "require.user" "root" 99} 100many_body() { 101 test_mount 102 103 atf_check 'mkdir a' 0 null null 104 echo "Creating 500 files" 105 for f in $(jot 500); do 106 touch a/$f 107 done 108 atf_check 'rm a/*' 0 null null 109 atf_check 'rmdir a' 0 null null 110 111 test_unmount 112} 113 114atf_init_test_cases() { 115 . $(atf_get_srcdir)/../h_funcs.subr 116 . $(atf_get_srcdir)/h_funcs.subr 117 118 atf_add_test_case dots 119 atf_add_test_case types 120 atf_add_test_case caching 121 atf_add_test_case many 122} 123