xref: /freebsd/contrib/netbsd-tests/fs/cd9660/t_high_ino_big_file.sh (revision 02e9120893770924227138ba49df1edb3896112a)
1# $NetBSD: t_high_ino_big_file.sh,v 1.4 2014/07/07 22:06:02 pgoyette Exp $
2#
3# Copyright (c) 2014 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#
15# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25# POSSIBILITY OF SUCH DAMAGE.
26#
27
28# The image used in these tests has been provided by Thomas Schmitt under
29# the following license (see PR kern/48787 for details how to recreate it):
30#
31# Copyright (c) 1999 - 2008, Thomas Schmitt (scdbackup@gmx.net)
32#
33# Redistribution and use in source and binary forms, with or without
34# modification, are permitted provided that the following conditions are met:
35#
36# Redistributions of source code must retain the above copyright notice,
37# this list of conditions and the following disclaimer.
38#
39# Redistributions in binary form must reproduce the above copyright notice,
40# this list of conditions and the following disclaimer in the documentation
41# and/or other materials provided with the distribution.
42#
43# Neither the name of Thomas Schmitt nor the names of his contributors
44# may be used to endorse or promote products derived from this software without
45# specific prior written permission.
46#
47#       THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
48#       CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
49#       INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
50#       MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
51#       DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
52#       LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
53#       CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
54#       PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
55#       PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
56#       THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
57#       (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
58#       USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
59#       DAMAGE.
60#
61# ------------------------------------------------------------------------
62# This is the BSD license as stated July 22 1999 with
63#  <OWNER>="Thomas Schmitt (scdbackup@gmx.net)",
64#  <ORGANIZATION>="Thomas Schmitt" and <YEAR>="1999"
65# an Open Source license approved by opensource.org
66#
67
68mntpnt=""
69
70atf_test_case pr_kern_48787 cleanup
71pr_kern_48787_head() {
72	atf_set "descr" "Verifies 32bit overflow isssues from PR kern/48787 are fixed"
73	atf_set "require.user" "root"
74	atf_set "require.progs" "rump_cd9660 bunzip2 stat"
75	atf_set "timeout" 6000
76}
77
78pr_kern_48787_body() {
79	avail=$( df -Pk . | awk '{if (NR==2) print $4}' )
80	if [ $avail -lt 4500000 ]; then
81		atf_skip "not enough free disk space, have ${avail} Kbytes, need ~ 4500000 Kbytes"
82	fi
83	bunzip2 < $(atf_get_srcdir)/pr_48787.image.bz2 > pr_48787.image
84	mntpnt=$(pwd)/mnt
85	mkdir ${mntpnt}
86	rump_cd9660 -o norrip ./pr_48787.image ${mntpnt}
87	if [ ! -r ${mntpnt}/small_file ]; then
88		atf_fail "${mntpnt}/small_file does not exist"
89	fi
90	if [ ! -r ${mntpnt}/my/large_file ]; then
91		atf_fail "${mntpnt}/my/large_file does not exist"
92	fi
93	umount ${mntpnt}
94	rump_cd9660 ./pr_48787.image ${mntpnt}
95	if [ ! -r ${mntpnt}/small_file ]; then
96		atf_fail "${mntpnt}/small_file does not exist"
97	fi
98	if [ ! -r ${mntpnt}/my/large_file ]; then
99		atf_fail "${mntpnt}/my/large_file does not exist"
100	fi
101	echo "this assumes current cd9660 inode encoding - adapt on changes"
102	atf_check -o match:"^4329541966$" stat -f "%i" ${mntpnt}/small_file
103	atf_check -o match:"^4329545920$" stat -f "%i" ${mntpnt}/my/large_file
104	umount ${mntpnt}
105	touch "done"
106}
107
108pr_kern_48787_cleanup() {
109	if [ ! -f done ]; then
110		if [ "x${mntpnt}" != "x" ]; then
111			umount -f ${mntpnt} || true
112		fi
113	fi
114}
115
116atf_init_test_cases() {
117	atf_add_test_case pr_kern_48787
118}
119