1*11be35a1SLionel Sambuc# $NetBSD: t_disk.sh,v 1.5 2013/02/19 21:08:25 joerg Exp $ 2*11be35a1SLionel Sambuc# 3*11be35a1SLionel Sambuc# Copyright (c) 2011 The NetBSD Foundation, Inc. 4*11be35a1SLionel Sambuc# All rights reserved. 5*11be35a1SLionel Sambuc# 6*11be35a1SLionel Sambuc# Redistribution and use in source and binary forms, with or without 7*11be35a1SLionel Sambuc# modification, are permitted provided that the following conditions 8*11be35a1SLionel Sambuc# are met: 9*11be35a1SLionel Sambuc# 1. Redistributions of source code must retain the above copyright 10*11be35a1SLionel Sambuc# notice, this list of conditions and the following disclaimer. 11*11be35a1SLionel Sambuc# 2. Redistributions in binary form must reproduce the above copyright 12*11be35a1SLionel Sambuc# notice, this list of conditions and the following disclaimer in the 13*11be35a1SLionel Sambuc# documentation and/or other materials provided with the distribution. 14*11be35a1SLionel Sambuc# 15*11be35a1SLionel Sambuc# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16*11be35a1SLionel Sambuc# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17*11be35a1SLionel Sambuc# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18*11be35a1SLionel Sambuc# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19*11be35a1SLionel Sambuc# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20*11be35a1SLionel Sambuc# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21*11be35a1SLionel Sambuc# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22*11be35a1SLionel Sambuc# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23*11be35a1SLionel Sambuc# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24*11be35a1SLionel Sambuc# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25*11be35a1SLionel Sambuc# POSSIBILITY OF SUCH DAMAGE. 26*11be35a1SLionel Sambuc# 27*11be35a1SLionel Sambuc 28*11be35a1SLionel Sambucserver='rump_server -lrumpvfs' 29*11be35a1SLionel Sambucexport RUMP_SERVER='unix://commsock' 30*11be35a1SLionel Sambuc 31*11be35a1SLionel Sambucstartsrv() 32*11be35a1SLionel Sambuc{ 33*11be35a1SLionel Sambuc 34*11be35a1SLionel Sambuc atf_check -s exit:0 ${server} $@ ${RUMP_SERVER} 35*11be35a1SLionel Sambuc} 36*11be35a1SLionel Sambuc 37*11be35a1SLionel Sambuctest_case() 38*11be35a1SLionel Sambuc{ 39*11be35a1SLionel Sambuc local name="${1}"; shift 40*11be35a1SLionel Sambuc 41*11be35a1SLionel Sambuc atf_test_case "${name}" cleanup 42*11be35a1SLionel Sambuc eval "${name}_head() { \ 43*11be35a1SLionel Sambuc atf_set "require.progs" "rump_server" ; \ 44*11be35a1SLionel Sambuc }" 45*11be35a1SLionel Sambuc eval "${name}_body() { \ 46*11be35a1SLionel Sambuc ${name}_prefun ; \ 47*11be35a1SLionel Sambuc startsrv $@ ; \ 48*11be35a1SLionel Sambuc ${name} ; \ 49*11be35a1SLionel Sambuc }" 50*11be35a1SLionel Sambuc eval "${name}_cleanup() { \ 51*11be35a1SLionel Sambuc [ -f halted ] && return 0 ; rump.halt ; 52*11be35a1SLionel Sambuc }" 53*11be35a1SLionel Sambuc} 54*11be35a1SLionel Sambuc 55*11be35a1SLionel Sambuctest_case size -d key=/img,hostpath=the.img,size=32k 56*11be35a1SLionel Sambucsize() 57*11be35a1SLionel Sambuc{ 58*11be35a1SLionel Sambuc atf_check -s exit:0 -o inline:'32768\n' stat -f %z the.img 59*11be35a1SLionel Sambuc} 60*11be35a1SLionel Sambuc 61*11be35a1SLionel Sambuctest_case offset -d key=/img,hostpath=the.img,size=32k,offset=16k 62*11be35a1SLionel Sambucoffset() 63*11be35a1SLionel Sambuc{ 64*11be35a1SLionel Sambuc atf_check -s exit:0 -o inline:'49152\n' stat -f %z the.img 65*11be35a1SLionel Sambuc} 66*11be35a1SLionel Sambuc 67*11be35a1SLionel Sambuctest_case notrunc -d key=/img,hostpath=the.img,size=8k,offset=16k 68*11be35a1SLionel Sambucnotrunc_prefun() 69*11be35a1SLionel Sambuc{ 70*11be35a1SLionel Sambuc dd if=/dev/zero of=the.img bs=1 oseek=65535 count=1 71*11be35a1SLionel Sambuc} 72*11be35a1SLionel Sambucnotrunc() 73*11be35a1SLionel Sambuc{ 74*11be35a1SLionel Sambuc atf_check -s exit:0 -o inline:'65536\n' stat -f %z the.img 75*11be35a1SLionel Sambuc} 76*11be35a1SLionel Sambuc 77*11be35a1SLionel Sambuctest_case data -d key=/img,hostpath=the.img,size=8k,offset=16k 78*11be35a1SLionel Sambucdata() 79*11be35a1SLionel Sambuc{ 80*11be35a1SLionel Sambuc echo 'test string' | dd of=testfile ibs=512 count=1 conv=sync 81*11be35a1SLionel Sambuc atf_check -s exit:0 -e ignore -x \ 82*11be35a1SLionel Sambuc "dd if=testfile | rump.dd of=/img bs=512 count=1" 83*11be35a1SLionel Sambuc 84*11be35a1SLionel Sambuc # cheap fsync 85*11be35a1SLionel Sambuc atf_check -s exit:0 rump.halt 86*11be35a1SLionel Sambuc touch halted 87*11be35a1SLionel Sambuc atf_check -s exit:0 -e ignore -o file:testfile \ 88*11be35a1SLionel Sambuc dd if=the.img iseek=16k bs=1 count=512 89*11be35a1SLionel Sambuc} 90*11be35a1SLionel Sambuc 91*11be35a1SLionel Sambuctest_case type_chr -d key=/img,hostpath=the.img,size=32k,type=chr 92*11be35a1SLionel Sambuctype_chr() 93*11be35a1SLionel Sambuc{ 94*11be35a1SLionel Sambuc atf_check -s exit:0 -o inline:'Character Device\n' \ 95*11be35a1SLionel Sambuc env LD_PRELOAD=/usr/lib/librumphijack.so stat -f %HT /rump/img 96*11be35a1SLionel Sambuc} 97*11be35a1SLionel Sambuc 98*11be35a1SLionel Sambuctest_case type_reg -d key=/img,hostpath=the.img,size=32k,type=reg 99*11be35a1SLionel Sambuctype_reg() 100*11be35a1SLionel Sambuc{ 101*11be35a1SLionel Sambuc atf_check -s exit:0 -o inline:'Regular File\n' \ 102*11be35a1SLionel Sambuc env LD_PRELOAD=/usr/lib/librumphijack.so stat -f %HT /rump/img 103*11be35a1SLionel Sambuc} 104*11be35a1SLionel Sambuc 105*11be35a1SLionel Sambuctest_case type_blk -d key=/img,hostpath=the.img,size=32k,type=blk 106*11be35a1SLionel Sambuctype_blk() 107*11be35a1SLionel Sambuc{ 108*11be35a1SLionel Sambuc atf_check -s exit:0 -o inline:'Block Device\n' \ 109*11be35a1SLionel Sambuc env LD_PRELOAD=/usr/lib/librumphijack.so stat -f %HT /rump/img 110*11be35a1SLionel Sambuc} 111*11be35a1SLionel Sambuc 112*11be35a1SLionel Sambuctest_case type_blk_default -d key=/img,hostpath=the.img,size=32k 113*11be35a1SLionel Sambuctype_blk_default() 114*11be35a1SLionel Sambuc{ 115*11be35a1SLionel Sambuc atf_check -s exit:0 -o inline:'Block Device\n' \ 116*11be35a1SLionel Sambuc env LD_PRELOAD=/usr/lib/librumphijack.so stat -f %HT /rump/img 117*11be35a1SLionel Sambuc} 118*11be35a1SLionel Sambuc 119*11be35a1SLionel Sambucatf_init_test_cases() 120*11be35a1SLionel Sambuc{ 121*11be35a1SLionel Sambuc 122*11be35a1SLionel Sambuc atf_add_test_case size 123*11be35a1SLionel Sambuc atf_add_test_case offset 124*11be35a1SLionel Sambuc atf_add_test_case notrunc 125*11be35a1SLionel Sambuc atf_add_test_case data 126*11be35a1SLionel Sambuc atf_add_test_case type_chr 127*11be35a1SLionel Sambuc atf_add_test_case type_reg 128*11be35a1SLionel Sambuc atf_add_test_case type_blk 129*11be35a1SLionel Sambuc atf_add_test_case type_blk_default 130*11be35a1SLionel Sambuc} 131