1196938Strasz#!/bin/sh
2196938Strasz#
3219877Strasz# Copyright (c) 2011 Edward Tomasz Napiera��a <trasz@FreeBSD.org>
4196938Strasz# All rights reserved.
5196938Strasz#
6196938Strasz# Redistribution and use in source and binary forms, with or without
7196938Strasz# modification, are permitted provided that the following conditions
8196938Strasz# are met:
9196938Strasz# 1. Redistributions of source code must retain the above copyright
10196938Strasz#    notice, this list of conditions and the following disclaimer.
11196938Strasz# 2. Redistributions in binary form must reproduce the above copyright
12196938Strasz#    notice, this list of conditions and the following disclaimer in the
13196938Strasz#    documentation and/or other materials provided with the distribution.
14196938Strasz#
15196938Strasz# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16196938Strasz# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17196938Strasz# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18196938Strasz# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19196938Strasz# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20196938Strasz# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21196938Strasz# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22196938Strasz# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23196938Strasz# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24196938Strasz# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25196938Strasz# SUCH DAMAGE.
26196938Strasz#
27196938Strasz# $FreeBSD$
28196938Strasz#
29196938Strasz
30219877Strasz# This is a wrapper script to run tools-nfs4-trivial.test on ZFS filesystem.
31196938Strasz#
32196938Strasz# WARNING: It uses hardcoded ZFS pool name "acltools"
33196938Strasz
34288680Sngieif ! sysctl vfs.zfs.version.spa >/dev/null 2>&1; then
35288680Sngie	echo "1..0 # SKIP system doesn't have ZFS loaded"
36288680Sngie	exit 0
37288680Sngiefi
38288680Sngieif [ $(id -u) -ne 0 ]; then
39288680Sngie	echo "1..0 # SKIP you must be root"
40288680Sngie	exit 0
41288680Sngiefi
42288680Sngie
43219877Straszecho "1..3"
44196938Strasz
45219266StraszTESTDIR=$(dirname $(realpath $0))
46196938Strasz
47196938Strasz# Set up the test filesystem.
48196938StraszMD=`mdconfig -at swap -s 64m`
49196938StraszMNT=`mktemp -dt acltools`
50271459Straszzpool create -m $MNT acltools /dev/$MD
51196938Straszif [ $? -ne 0 ]; then
52196938Strasz	echo "not ok 1 - 'zpool create' failed."
53305913Sngie	echo 'Bail out!'
54196938Strasz	exit 1
55196938Straszfi
56196938Strasz
57196938Straszecho "ok 1"
58196938Strasz
59196938Straszcd $MNT
60196938Strasz
61305227Sngieperl $TESTDIR/run $TESTDIR/tools-nfs4-trivial.test >&2
62196938Strasz
63196938Straszif [ $? -eq 0 ]; then
64219877Strasz	echo "ok 2"
65196938Straszelse
66219877Strasz	echo "not ok 2"
67196938Straszfi
68196938Strasz
69196938Straszcd /
70196938Straszzpool destroy -f acltools
71196938Straszrmdir $MNT
72196938Straszmdconfig -du $MD
73196938Strasz
74219877Straszecho "ok 3"
75