xref: /freebsd/tests/sys/acl/01.sh (revision ea82362219ee715cfbb195b2114e73fdc8599fa5)
1b3af24b4SEnji Cooper#!/bin/sh
2b3af24b4SEnji Cooper#
3b3af24b4SEnji Cooper# Copyright (c) 2008, 2009 Edward Tomasz Napierała <trasz@FreeBSD.org>
4b3af24b4SEnji Cooper#
5b3af24b4SEnji Cooper# Redistribution and use in source and binary forms, with or without
6b3af24b4SEnji Cooper# modification, are permitted provided that the following conditions
7b3af24b4SEnji Cooper# are met:
8b3af24b4SEnji Cooper# 1. Redistributions of source code must retain the above copyright
9b3af24b4SEnji Cooper#    notice, this list of conditions and the following disclaimer.
10b3af24b4SEnji Cooper# 2. Redistributions in binary form must reproduce the above copyright
11b3af24b4SEnji Cooper#    notice, this list of conditions and the following disclaimer in the
12b3af24b4SEnji Cooper#    documentation and/or other materials provided with the distribution.
13b3af24b4SEnji Cooper#
14b3af24b4SEnji Cooper# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15b3af24b4SEnji Cooper# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16b3af24b4SEnji Cooper# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17b3af24b4SEnji Cooper# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18b3af24b4SEnji Cooper# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19b3af24b4SEnji Cooper# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20b3af24b4SEnji Cooper# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21b3af24b4SEnji Cooper# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22b3af24b4SEnji Cooper# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23b3af24b4SEnji Cooper# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24b3af24b4SEnji Cooper# SUCH DAMAGE.
25b3af24b4SEnji Cooper#
26b3af24b4SEnji Cooper#
27b3af24b4SEnji Cooper
28b3af24b4SEnji Cooper# This is a wrapper script to run tools-nfs4.test on ZFS filesystem.
29b3af24b4SEnji Cooper#
30b3af24b4SEnji Cooper# WARNING: It uses hardcoded ZFS pool name "acltools"
31b3af24b4SEnji Cooper#
32b3af24b4SEnji Cooper# If any of the tests fails, here is how to debug it: go to
33b3af24b4SEnji Cooper# the directory with problematic filesystem mounted on it,
34b3af24b4SEnji Cooper# and do /path/to/test run /path/to/test tools-nfs4.test, e.g.
35b3af24b4SEnji Cooper#
36b3af24b4SEnji Cooper# /usr/src/tools/regression/acltools/run /usr/src/tools/regression/acltools/tools-nfs4.test
37b3af24b4SEnji Cooper#
38b3af24b4SEnji Cooper# Output should be obvious.
39b3af24b4SEnji Cooper
40b3af24b4SEnji Cooperif ! sysctl vfs.zfs.version.spa >/dev/null 2>&1; then
41b3af24b4SEnji Cooper	echo "1..0 # SKIP system doesn't have ZFS loaded"
42b3af24b4SEnji Cooper	exit 0
43b3af24b4SEnji Cooperfi
44b3af24b4SEnji Cooperif [ $(id -u) -ne 0 ]; then
45b3af24b4SEnji Cooper	echo "1..0 # SKIP you must be root"
46b3af24b4SEnji Cooper	exit 0
47b3af24b4SEnji Cooperfi
48*ea823622SWarner Loshif [ ! -c /dev/mdctl ]; then
49*ea823622SWarner Losh	echo "1..0 # SKIP no /dev/mdctl to create md devices"
50*ea823622SWarner Losh	exit 0
51*ea823622SWarner Loshfi
52b3af24b4SEnji Cooper
53b3af24b4SEnji Cooperecho "1..4"
54b3af24b4SEnji Cooper
55b3af24b4SEnji CooperTESTDIR=$(dirname $(realpath $0))
56b3af24b4SEnji Cooper
57b3af24b4SEnji Cooper# Set up the test filesystem.
58b3af24b4SEnji CooperMD=`mdconfig -at swap -s 64m`
59b3af24b4SEnji CooperMNT=`mktemp -dt acltools`
60b3af24b4SEnji Coopertrap "cd /; zpool destroy -f acltools; rmdir $MNT; mdconfig -d -u $MD" EXIT
61b3af24b4SEnji Cooperzpool create -m $MNT acltools /dev/$MD
62b3af24b4SEnji Cooperif [ $? -ne 0 ]; then
63b3af24b4SEnji Cooper	echo "not ok 1 - 'zpool create' failed."
64b3af24b4SEnji Cooper	echo 'Bail out!'
65b3af24b4SEnji Cooper	exit 1
66b3af24b4SEnji Cooperfi
67b3af24b4SEnji Cooper
68b3af24b4SEnji Cooperecho "ok 1"
69b3af24b4SEnji Cooper
70b3af24b4SEnji Coopercd $MNT
71b3af24b4SEnji Cooper
72b3af24b4SEnji Cooper# First, check whether we can crash the kernel by creating too many
73b3af24b4SEnji Cooper# entries.  For some reason this won't work in the test file.
74b3af24b4SEnji Coopertouch xxx
75b3af24b4SEnji Coopersetfacl -x2 xxx
76b3af24b4SEnji Cooperwhile :; do setfacl -a0 u:42:rwx:allow xxx 2> /dev/null; if [ $? -ne 0 ]; then break; fi; done
77b3af24b4SEnji Cooperchmod 600 xxx
78b3af24b4SEnji Cooperrm xxx
79b3af24b4SEnji Cooperecho "ok 2"
80b3af24b4SEnji Cooper
81708cc995SEnji Cooperperl $TESTDIR/run $TESTDIR/tools-nfs4-psarc.test >&2
82b3af24b4SEnji Cooper
83b3af24b4SEnji Cooperif [ $? -eq 0 ]; then
84b3af24b4SEnji Cooper	echo "ok 3"
85b3af24b4SEnji Cooperelse
863d77b88dSEnji Cooper	echo "not ok 3 # TODO: fails due to ACL changes in ZFS; bug 212323"
87b3af24b4SEnji Cooperfi
88b3af24b4SEnji Cooper
89b3af24b4SEnji Cooperecho "ok 4"
90