1319339Sasomers# 2319339Sasomers# Copyright (c) 2017 Spectra Logic Corporation 3319339Sasomers# All rights reserved. 4319339Sasomers# 5319339Sasomers# Redistribution and use in source and binary forms, with or without 6319339Sasomers# modification, are permitted provided that the following conditions 7319339Sasomers# are met: 8319339Sasomers# 1. Redistributions of source code must retain the above copyright 9319339Sasomers# notice, this list of conditions and the following disclaimer. 10319339Sasomers# 2. Redistributions in binary form must reproduce the above copyright 11319339Sasomers# notice, this list of conditions and the following disclaimer in the 12319339Sasomers# documentation and/or other materials provided with the distribution. 13319339Sasomers# 14319339Sasomers# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 15319339Sasomers# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 16319339Sasomers# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17319339Sasomers# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 18319339Sasomers# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19319339Sasomers# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20319339Sasomers# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21319339Sasomers# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22319339Sasomers# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23319339Sasomers# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24319339Sasomers# POSSIBILITY OF SUCH DAMAGE. 25319339Sasomers# 26319339Sasomers# $FreeBSD: stable/10/bin/dd/tests/dd2_test.sh 321140 2017-07-18 17:36:25Z ngie $ 27319339Sasomers 28319339Sasomers 29321140Sngieatf_test_case max_seek 30321140Sngiemax_seek_head() 31321140Sngie{ 32321140Sngie atf_set "descr" "dd(1) can seek by the maximum amount" 33319339Sasomers} 34321140Sngiemax_seek_body() 35321140Sngie{ 36321140Sngie case `df -T . | tail -n 1 | cut -wf 2` in 37321140Sngie "ufs") 38321140Sngie atf_skip "UFS's maximum file size is too small";; 39321140Sngie "zfs") ;; # ZFS is fine 40321140Sngie "tmpfs") 41321140Sngie atf_skip "tmpfs can't create arbitrarily large spare files";; 42321140Sngie *) atf_skip "Unknown file system";; 43321140Sngie esac 44321140Sngie 45319339Sasomers touch f.in 46319339Sasomers seek=`echo "2^63 / 4096 - 1" | bc` 47319339Sasomers atf_check -s exit:0 -e ignore dd if=f.in of=f.out bs=4096 seek=$seek 48321140Sngie} 49319339Sasomers 50321140Sngieatf_test_case seek_overflow 51321140Sngieseek_overflow_head() 52321140Sngie{ 53321140Sngie atf_set "descr" "dd(1) should reject too-large seek values" 54321140Sngie} 55321140Sngieseek_overflow_body() 56321140Sngie{ 57321140Sngie touch f.in 58319339Sasomers seek=`echo "2^63 / 4096" | bc` 59319339Sasomers atf_check -s not-exit:0 -e match:"seek offsets cannot be larger than" \ 60319339Sasomers dd if=f.in of=f.out bs=4096 seek=$seek 61319339Sasomers atf_check -s not-exit:0 -e match:"seek offsets cannot be larger than" \ 62319339Sasomers dd if=f.in of=f.out bs=4096 seek=-1 63319339Sasomers} 64319339Sasomers 65319339Sasomersatf_init_test_cases() 66319339Sasomers{ 67321140Sngie atf_add_test_case max_seek 68321140Sngie atf_add_test_case seek_overflow 69319339Sasomers} 70