t_read_write.sh revision 1.1
11.1Sjmmv# $NetBSD: t_read_write.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 read and write operations work. 371.1Sjmmv# 381.1Sjmmv 391.1Sjmmvatf_test_case basic 401.1Sjmmvbasic_head() { 411.1Sjmmv atf_set "descr" "Checks that file removal works" 421.1Sjmmv atf_set "require.user" "root" 431.1Sjmmv} 441.1Sjmmvbasic_body() { 451.1Sjmmv test_mount 461.1Sjmmv 471.1Sjmmv echo "Testing write to a small file" 481.1Sjmmv echo foo >a || atf_fail "Failed to write to file" 491.1Sjmmv [ $(md5 a | cut -d ' ' -f 4) = d3b07384d113edec49eaa6238ad5ff00 ] || \ 501.1Sjmmv atf_fail "Invalid file contents" 511.1Sjmmv 521.1Sjmmv echo "Testing appending to a small file" 531.1Sjmmv echo bar >>a || atf_fail "Failed to append data to file" 541.1Sjmmv [ $(md5 a | cut -d ' ' -f 4) = f47c75614087a8dd938ba4acff252494 ] || \ 551.1Sjmmv atf_fail "Invalid file contents" 561.1Sjmmv 571.1Sjmmv echo "Testing write to a big file (bigger than a page)" 581.1Sjmmv jot 10000 >b || atf_fail "Failed to create a big file" 591.1Sjmmv [ $(md5 b | cut -d ' ' -f 4) = 72d4ff27a28afbc066d5804999d5a504 ] || \ 601.1Sjmmv atf_fail "Invalid file contents" 611.1Sjmmv 621.1Sjmmv test_unmount 631.1Sjmmv} 641.1Sjmmv 651.1Sjmmvatf_test_case kqueue 661.1Sjmmvkqueue_head() { 671.1Sjmmv atf_set "descr" "Checks that writing to a file raises the" \ 681.1Sjmmv "appropriate kqueue events" 691.1Sjmmv atf_set "require.user" "root" 701.1Sjmmv} 711.1Sjmmvkqueue_body() { 721.1Sjmmv test_mount 731.1Sjmmv 741.1Sjmmv atf_check 'dd if=/dev/zero of=c bs=1k count=10' 0 ignore ignore 751.1Sjmmv echo 'dd if=/dev/zero of=c seek=2 bs=1k count=1 conv=notrunc' \ 761.1Sjmmv '>/dev/null 2>&1' | kqueue_monitor 1 c 771.1Sjmmv kqueue_check c NOTE_WRITE 781.1Sjmmv 791.1Sjmmv echo foo >d 801.1Sjmmv echo 'echo bar >>d' | kqueue_monitor 2 d 811.1Sjmmv kqueue_check d NOTE_EXTEND 821.1Sjmmv kqueue_check d NOTE_WRITE 831.1Sjmmv 841.1Sjmmv test_unmount 851.1Sjmmv} 861.1Sjmmv 871.1Sjmmvatf_init_test_cases() { 881.1Sjmmv . $(atf_get_srcdir)/../h_funcs.subr 891.1Sjmmv . $(atf_get_srcdir)/h_funcs.subr 901.1Sjmmv 911.1Sjmmv atf_add_test_case basic 921.1Sjmmv atf_add_test_case kqueue 931.1Sjmmv} 94