ZTS: path cleanup

Removing hardcoded paths in many scripts.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: bernie1995 <bernie.pikes@gmail.com>
Issue #7507 
Closes #7843
This commit is contained in:
bernie1995 2018-08-30 22:46:55 +02:00 committed by Brian Behlendorf
parent 6c6949acae
commit 0fe7c953b3
63 changed files with 184 additions and 166 deletions

View File

@ -114,9 +114,11 @@ def draw_graph(kstats_dict):
dnode_limit = f_bytes(arc_stats['arc_dnode_limit']) dnode_limit = f_bytes(arc_stats['arc_dnode_limit'])
dnode_size = f_bytes(arc_stats['dnode_size']) dnode_size = f_bytes(arc_stats['dnode_size'])
info_form = 'ARC: {0} ({1}) MFU: {2} MRU: {3} META: {4} ({5}) DNODE {6} ({7})' info_form = ('ARC: {0} ({1}) MFU: {2} MRU: {3} META: {4} ({5}) '
'DNODE {6} ({7})')
info_line = info_form.format(arc_size, arc_perc, mfu_size, mru_size, info_line = info_form.format(arc_size, arc_perc, mfu_size, mru_size,
meta_size, meta_limit, dnode_size, dnode_limit) meta_size, meta_limit, dnode_size,
dnode_limit)
info_spc = ' '*int((GRAPH_WIDTH-len(info_line))/2) info_spc = ' '*int((GRAPH_WIDTH-len(info_line))/2)
info_line = GRAPH_INDENT+info_spc+info_line info_line = GRAPH_INDENT+info_spc+info_line

View File

@ -32,7 +32,7 @@ log_assert "Verify zdb accurately counts feature refcounts."
log_onexit cleanup log_onexit cleanup
typeset errstr="feature refcount mismatch" typeset errstr="feature refcount mismatch"
typeset tmpfile="/var/tmp/zdb-feature-mismatch" typeset tmpfile="$TEST_BASE_DIR/zdb-feature-mismatch"
function cleanup function cleanup
{ {
datasetexists $TESTPOOL && destroy_pool $TESTPOOL datasetexists $TESTPOOL && destroy_pool $TESTPOOL

View File

@ -156,7 +156,7 @@ done
typeset -i fspropnum=27 typeset -i fspropnum=27
typeset -i snappropnum=8 typeset -i snappropnum=8
typeset -i volpropnum=15 typeset -i volpropnum=15
propfile=/var/tmp/allpropfile.$$ propfile=$TEST_BASE_DIR/allpropfile.$$
typeset -i i=0 typeset -i i=0
typeset -i propnum=0 typeset -i propnum=0

View File

@ -41,8 +41,8 @@ function cleanup
log_must rm -f $streamfile_incr log_must rm -f $streamfile_incr
log_must rm -f $streamfile_repl log_must rm -f $streamfile_repl
log_must rm -f $streamfile_trun log_must rm -f $streamfile_trun
log_must zfs destroy -r -f $orig destroy_dataset "$orig" "-rf"
log_must zfs destroy -r -f $dest destroy_dataset "$dest" "-rf"
} }
log_assert "ZFS receive property override and exclude options work as expected." log_assert "ZFS receive property override and exclude options work as expected."

View File

@ -76,7 +76,7 @@ log_assert "Verifying 'zfs receive [<filesystem|snapshot>] -d <filesystem>' work
log_onexit cleanup log_onexit cleanup
typeset datasets="$TESTPOOL/$TESTFS $TESTPOOL" typeset datasets="$TESTPOOL/$TESTFS $TESTPOOL"
set -A bkup "/var/tmp/fullbkup" "/var/tmp/incbkup" set -A bkup "$TEST_BASE_DIR/fullbkup" "$TEST_BASE_DIR/incbkup"
orig_sum="" orig_sum=""
rst_sum="" rst_sum=""
rst_root=$TESTPOOL/rst_ctr rst_root=$TESTPOOL/rst_ctr

View File

@ -70,7 +70,7 @@ log_assert "Verifying 'zfs receive <volume>' works."
log_onexit cleanup log_onexit cleanup
set -A orig_snap "$TESTPOOL/$TESTVOL@init_snap" "$TESTPOOL/$TESTVOL@inc_snap" set -A orig_snap "$TESTPOOL/$TESTVOL@init_snap" "$TESTPOOL/$TESTVOL@inc_snap"
set -A bkup "/var/tmp/fullbkup" "/var/tmp/incbkup" set -A bkup "$TEST_BASE_DIR/fullbkup" "$TEST_BASE_DIR/incbkup"
rst_root=$TESTPOOL/rst_ctr rst_root=$TESTPOOL/rst_ctr
rst_vol=$rst_root/$TESTVOL rst_vol=$rst_root/$TESTVOL
set -A rst_snap "${rst_vol}@init_snap" "${rst_vol}@inc_snap" set -A rst_snap "${rst_vol}@init_snap" "${rst_vol}@inc_snap"

View File

@ -59,7 +59,7 @@ function cleanup
log_assert "'zfs recv -F' to force rollback." log_assert "'zfs recv -F' to force rollback."
log_onexit cleanup log_onexit cleanup
ibackup=/var/tmp/ibackup.$$ ibackup=$TEST_BASE_DIR/ibackup.$$
fs=$TESTPOOL/$TESTFS; snap1=$fs@snap1; snap2=$fs@snap2 fs=$TESTPOOL/$TESTFS; snap1=$fs@snap1; snap2=$fs@snap2
mntpnt=$(get_prop mountpoint $fs) || log_fail "get_prop mountpoint $fs" mntpnt=$(get_prop mountpoint $fs) || log_fail "get_prop mountpoint $fs"

View File

@ -64,13 +64,13 @@ log_onexit cleanup
init_snap=$TESTPOOL/$TESTFS@initsnap init_snap=$TESTPOOL/$TESTFS@initsnap
inc_snap=$TESTPOOL/$TESTFS@incsnap inc_snap=$TESTPOOL/$TESTFS@incsnap
full_bkup=/var/tmp/full_bkup.$$ full_bkup=$TEST_BASE_DIR/full_bkup.$$
inc_bkup=/var/tmp/inc_bkup.$$ inc_bkup=$TEST_BASE_DIR/inc_bkup.$$
init_topsnap=$TESTPOOL@initsnap init_topsnap=$TESTPOOL@initsnap
inc_topsnap=$TESTPOOL@incsnap inc_topsnap=$TESTPOOL@incsnap
full_topbkup=/var/tmp/full_topbkup.$$ full_topbkup=$TEST_BASE_DIR/full_topbkup.$$
inc_topbkup=/var/tmp/inc_topbkup.$$ inc_topbkup=$TEST_BASE_DIR/inc_topbkup.$$
log_must zfs snapshot $init_topsnap log_must zfs snapshot $init_topsnap
log_must eval "zfs send $init_topsnap > $full_topbkup" log_must eval "zfs send $init_topsnap > $full_topbkup"

View File

@ -74,8 +74,8 @@ inc_snap=$TESTPOOL/$TESTFS@incsnap
rst_root=$TESTPOOL/rst_ctr rst_root=$TESTPOOL/rst_ctr
rst_init_snap=$rst_root/$TESTFS@init_snap rst_init_snap=$rst_root/$TESTFS@init_snap
rst_inc_snap=$rst_root/$TESTFS@inc_snap rst_inc_snap=$rst_root/$TESTFS@inc_snap
full_bkup=/var/tmp/full_bkup.$$ full_bkup=$TEST_BASE_DIR/full_bkup.$$
inc_bkup=/var/tmp/inc_bkup.$$ inc_bkup=$TEST_BASE_DIR/inc_bkup.$$
log_must zfs create $rst_root log_must zfs create $rst_root
log_must zfs snapshot $init_snap log_must zfs snapshot $init_snap

View File

@ -75,8 +75,8 @@ ancestor_fs=$TESTPOOL/$TESTFS
fs=$TESTPOOL/$TESTFS/$TESTFS1 fs=$TESTPOOL/$TESTFS/$TESTFS1
snap1=$fs@snap1 snap1=$fs@snap1
snap2=$fs@snap2 snap2=$fs@snap2
fbackup1=/var/tmp/fbackup1.$$ fbackup1=$TEST_BASE_DIR/fbackup1.$$
fbackup2=/var/tmp/fbackup2.$$ fbackup2=$TEST_BASE_DIR/fbackup2.$$
datasetexists $ancestor_fs || \ datasetexists $ancestor_fs || \
log_must zfs create $ancestor_fs log_must zfs create $ancestor_fs

View File

@ -60,7 +60,7 @@ log_onexit cleanup
fs=$TESTPOOL/$TESTFS fs=$TESTPOOL/$TESTFS
snap1=$fs@snap1 snap1=$fs@snap1
snap2=$fs@snap2 snap2=$fs@snap2
ibackup=/var/tmp/ibackup.$$ ibackup=$TEST_BASE_DIR/ibackup.$$
datasetexists $fs || log_must zfs create $fs datasetexists $fs || log_must zfs create $fs

View File

@ -73,8 +73,8 @@ log_onexit cleanup
typeset datasets="$TESTPOOL/$TESTFS $TESTPOOL" typeset datasets="$TESTPOOL/$TESTFS $TESTPOOL"
typeset rst_fs=$TESTPOOL/$TESTFS/$TESTFS typeset rst_fs=$TESTPOOL/$TESTFS/$TESTFS
typeset fbackup=/var/tmp/fbackup.$$ typeset fbackup=$TEST_BASE_DIR/fbackup.$$
typeset tmp_out=/var/tmp/tmpout.$$ typeset tmp_out=$TEST_BASE_DIR/tmpout.$$
for orig_fs in $datasets ; do for orig_fs in $datasets ; do
typeset rst_snap=$rst_fs@snap typeset rst_snap=$rst_fs@snap

View File

@ -43,7 +43,7 @@
verify_runnable "both" verify_runnable "both"
typeset streamfile=/var/tmp/streamfile.$$ typeset streamfile=$TEST_BASE_DIR/streamfile.$$
function cleanup function cleanup
{ {

View File

@ -40,7 +40,7 @@
verify_runnable "both" verify_runnable "both"
typeset streamfile=/var/tmp/streamfile.$$ typeset streamfile=$TEST_BASE_DIR/streamfile.$$
function cleanup function cleanup
{ {

View File

@ -33,8 +33,8 @@
src_fs=$TESTPOOL/drecvsrc src_fs=$TESTPOOL/drecvsrc
temppool=recvtank temppool=recvtank
dst_fs=$temppool/drecvdest dst_fs=$temppool/drecvdest
streamfile=/var/tmp/drecvstream.$$ streamfile=$TEST_BASE_DIR/drecvstream.$$
tpoolfile=/temptank.$$ tpoolfile=$TEST_BASE_DIR/temptank.$$
function cleanup function cleanup
{ {

View File

@ -36,8 +36,8 @@
verify_runnable "both" verify_runnable "both"
typeset streamfile_full=/var/tmp/streamfile_full.$$ typeset streamfile_full=$TEST_BASE_DIR/streamfile_full.$$
typeset streamfile_incr=/var/tmp/streamfile_incr.$$ typeset streamfile_incr=$TEST_BASE_DIR/streamfile_incr.$$
orig=$TESTPOOL/$TESTFS1 orig=$TESTPOOL/$TESTFS1
dest=$TESTPOOL/$TESTFS2 dest=$TESTPOOL/$TESTFS2
typeset user_prop=$(valid_user_property 8) typeset user_prop=$(valid_user_property 8)

View File

@ -74,7 +74,7 @@ log_onexit cleanup
init_snap=$TESTPOOL/$TESTFS@init_snap init_snap=$TESTPOOL/$TESTFS@init_snap
inc_snap=$TESTPOOL/$TESTFS@inc_snap inc_snap=$TESTPOOL/$TESTFS@inc_snap
full_bkup=/var/tmp/fullbkup.$$ full_bkup=$TEST_BASE_DIR/fullbkup.$$
inc_bkup=/var/tmp/incbkup.$$ inc_bkup=/var/tmp/incbkup.$$
init_data=$TESTDIR/$TESTFILE1 init_data=$TESTDIR/$TESTFILE1
inc_data=$TESTDIR/$TESTFILE2 inc_data=$TESTDIR/$TESTFILE2

View File

@ -116,7 +116,7 @@ origfile=$TESTDIR/$TESTFILE1
rstfile=/$rstfs/$TESTFILE1 rstfile=/$rstfs/$TESTFILE1
origsnapfile=$TESTDIR/$snapdir/$TESTFILE1 origsnapfile=$TESTDIR/$snapdir/$TESTFILE1
rstsnapfile=/$rstfs/$snapdir/$TESTFILE1 rstsnapfile=/$rstfs/$snapdir/$TESTFILE1
stream=/var/tmp/streamfile.$$ stream=$TEST_BASE_DIR/streamfile.$$
set -A props "compression" "checksum" "recordsize" set -A props "compression" "checksum" "recordsize"
set -A propval "on lzjb" "on fletcher2 fletcher4 sha256" \ set -A propval "on lzjb" "on fletcher2 fletcher4 sha256" \

View File

@ -33,7 +33,7 @@
# #
# DESCRIPTION: # DESCRIPTION:
# 'zfs set mountpoint/sharenfs' should fail when the mountpoint is invlid # 'zfs set mountpoint/sharenfs' should fail when the mountpoint is invalid
# #
# STRATEGY: # STRATEGY:
# 1. Create invalid scenarios # 1. Create invalid scenarios
@ -56,7 +56,7 @@ function cleanup
log_assert "'zfs set mountpoint/sharenfs' fails with invalid scenarios" log_assert "'zfs set mountpoint/sharenfs' fails with invalid scenarios"
log_onexit cleanup log_onexit cleanup
badpath=/tmp/foo1.$$ badpath=$TEST_BASE_DIR/foo1.$$
touch $badpath touch $badpath
longpath=$(gen_dataset_name 1030 "abcdefg") longpath=$(gen_dataset_name 1030 "abcdefg")

View File

@ -66,8 +66,8 @@ log_assert "Executing 'zfs upgrade' command succeeds."
log_onexit cleanup log_onexit cleanup
rootfs=$TESTPOOL/$TESTFS rootfs=$TESTPOOL/$TESTFS
typeset output=/tmp/zfs-versions.$$ typeset output=$TEST_BASE_DIR/zfs-versions.$$
typeset oldoutput=/tmp/zfs-versions-old.$$ typeset oldoutput=$TEST_BASE_DIR/zfs-versions-old.$$
typeset expect_str1="This system is currently running ZFS filesystem version" typeset expect_str1="This system is currently running ZFS filesystem version"
typeset expect_str2="All filesystems are formatted with the current version" typeset expect_str2="All filesystems are formatted with the current version"
typeset expect_str3="The following filesystems are out of date, and can be upgraded" typeset expect_str3="The following filesystems are out of date, and can be upgraded"

View File

@ -54,7 +54,7 @@ function cleanup
log_assert "Executing 'zfs upgrade -v' command succeeds." log_assert "Executing 'zfs upgrade -v' command succeeds."
log_onexit cleanup log_onexit cleanup
typeset output=/tmp/zfs-versions.$$ typeset output=$TEST_BASE_DIR/zfs-versions.$$
typeset expect_str1="Initial ZFS filesystem version" typeset expect_str1="Initial ZFS filesystem version"
typeset expect_str2="Enhanced directory entries" typeset expect_str2="Enhanced directory entries"

View File

@ -99,7 +99,6 @@ export ZFS_ABORT=yes
for subcmd in "${cmds[@]}" "${badparams[@]}"; do for subcmd in "${cmds[@]}" "${badparams[@]}"; do
corefile=${corepath}/core.zpool corefile=${corepath}/core.zpool
zpool $subcmd >/dev/null 2>&1 zpool $subcmd >/dev/null 2>&1
ls -l $corepath >>/tmp/CORE
if [[ ! -e $corefile ]]; then if [[ ! -e $corefile ]]; then
log_fail "zpool $subcmd cannot generate core file with ZFS_ABORT set." log_fail "zpool $subcmd cannot generate core file with ZFS_ABORT set."
fi fi

View File

@ -42,10 +42,10 @@ function find_vfstab_dev
if is_linux; then if is_linux; then
vfstab="/etc/fstab" vfstab="/etc/fstab"
tmpfile="/tmp/fstab.tmp" tmpfile="$TEST_BASE_DIR/fstab.tmp"
else else
vfstab="/etc/vfstab" vfstab="/etc/vfstab"
tmpfile="/tmp/vfstab.tmp" tmpfile="$TEST_BASE_DIR/vfstab.tmp"
fi fi
cat $vfstab | grep "^${DEV_DSKDIR}" >$tmpfile cat $vfstab | grep "^${DEV_DSKDIR}" >$tmpfile
@ -71,10 +71,10 @@ function find_mnttab_dev
if is_linux; then if is_linux; then
typeset mnttab="/etc/mtab" typeset mnttab="/etc/mtab"
typeset tmpfile="/tmp/mtab.tmp" typeset tmpfile="$TEST_BASE_DIR/mtab.tmp"
else else
typeset mnttab="/etc/mnttab" typeset mnttab="/etc/mnttab"
typeset tmpfile="/tmp/mnttab.tmp" typeset tmpfile="$TEST_BASE_DIR/mnttab.tmp"
fi fi
cat $mnttab | grep "^${DEV_DSKDIR}" >$tmpfile cat $mnttab | grep "^${DEV_DSKDIR}" >$tmpfile

View File

@ -97,7 +97,6 @@ eval set -A mirrorarray $mirrordevs
eval set -A raidzarray $raidzdevs eval set -A raidzarray $raidzdevs
while (( $i < ${#keywords[*]} )); do while (( $i < ${#keywords[*]} )); do
echo "I=$i keyword=${keywords[i]}" >>/tmp/LOG
case ${keywords[i]} in case ${keywords[i]} in
""|spare) ""|spare)

View File

@ -61,7 +61,7 @@ log_assert "'zpool add -n <pool> <vdev> ...' can display the configuration" \
log_onexit cleanup log_onexit cleanup
tmpfile="/var/tmp/zpool_add_003.tmp$$" tmpfile="$TEST_BASE_DIR/zpool_add_003.tmp$$"
create_pool "$TESTPOOL" "${disk}${SLICE_PREFIX}${SLICE0}" create_pool "$TESTPOOL" "${disk}${SLICE_PREFIX}${SLICE0}"
log_must poolexists "$TESTPOOL" log_must poolexists "$TESTPOOL"

View File

@ -85,7 +85,7 @@ function check_err # <pool> [<vdev>]
typeset c_read=0 typeset c_read=0
typeset c_write=0 typeset c_write=0
typeset c_cksum=0 typeset c_cksum=0
typeset tmpfile=/var/tmp/file.$$ typeset tmpfile=$TEST_BASE_DIR/file.$$
typeset healthstr="pool '$pool' is healthy" typeset healthstr="pool '$pool' is healthy"
typeset output="`zpool status -x $pool`" typeset output="`zpool status -x $pool`"

View File

@ -111,4 +111,4 @@ export TESTPOOL4=testpool4.create
export TESTPOOL5=testpool5.create export TESTPOOL5=testpool5.create
export TESTPOOL6=testpool6.create export TESTPOOL6=testpool6.create
export CPATH="/var/tmp/cachefile.create" export CPATH="$TEST_BASE_DIR/cachefile.create"

View File

@ -127,10 +127,10 @@ function find_vfstab_dev
if is_linux; then if is_linux; then
vfstab="/etc/fstab" vfstab="/etc/fstab"
tmpfile="/tmp/fstab.tmp" tmpfile="$TEST_BASE_DIR/fstab.tmp"
else else
vfstab="/etc/vfstab" vfstab="/etc/vfstab"
tmpfile="/tmp/vfstab.tmp" tmpfile="$TEST_BASE_DIR/vfstab.tmp"
fi fi
cat $vfstab | grep "^${DEV_DSKDIR}" >$tmpfile cat $vfstab | grep "^${DEV_DSKDIR}" >$tmpfile

View File

@ -49,7 +49,7 @@ function cleanup
[[ -e $tmpfile ]] && log_must rm -f $tmpfile [[ -e $tmpfile ]] && log_must rm -f $tmpfile
} }
tmpfile="/var/tmp/zpool_create_003.tmp$$" tmpfile="$TEST_BASE_DIR/zpool_create_003.tmp$$"
log_assert "'zpool create -n <pool> <vspec> ...' can display the configuration" \ log_assert "'zpool create -n <pool> <vspec> ...' can display the configuration" \
"without actually creating the pool." "without actually creating the pool."

View File

@ -89,7 +89,7 @@ function cleanup
# #
function create_overlap_slice function create_overlap_slice
{ {
typeset format_file=/var/tmp/format_overlap.$$ typeset format_file=$TEST_BASE_DIR/format_overlap.$$
typeset disk=$1 typeset disk=$1
echo "partition" >$format_file echo "partition" >$format_file

View File

@ -57,7 +57,7 @@ function cleanup
fi fi
#recover swap devices #recover swap devices
FSTAB=/tmp/fstab_$$ FSTAB=$TEST_BASE_DIR/fstab_$$
rm -f $FSTAB rm -f $FSTAB
for sdisk in $swap_disks; do for sdisk in $swap_disks; do
echo "$sdisk - - swap - no -" >> $FSTAB echo "$sdisk - - swap - no -" >> $FSTAB

View File

@ -53,12 +53,15 @@ function cleanup
then then
log_must rmdir /${TESTPOOL}.root log_must rmdir /${TESTPOOL}.root
fi fi
[[ -e $values ]] && log_must rm -f $values
} }
log_onexit cleanup log_onexit cleanup
log_assert "zpool create -R works as expected" log_assert "zpool create -R works as expected"
typeset values=$TEST_BASE_DIR/values.$$
if [[ -n $DISK ]]; then if [[ -n $DISK ]]; then
disk=$DISK disk=$DISK
else else
@ -80,23 +83,23 @@ then
fi fi
log_must zpool get all $TESTPOOL log_must zpool get all $TESTPOOL
zpool get all $TESTPOOL > /tmp/values.$$ zpool get all $TESTPOOL > $values
# check for the cachefile property, verifying that it's set to 'none' # check for the cachefile property, verifying that it's set to 'none'
grep "$TESTPOOL[ ]*cachefile[ ]*none" /tmp/values.$$ > /dev/null 2>&1 grep "$TESTPOOL[ ]*cachefile[ ]*none" $values > /dev/null 2>&1
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
log_fail "zpool property \'cachefile\' was not set to \'none\'." log_fail "zpool property \'cachefile\' was not set to \'none\'."
fi fi
# check that the root = /mountpoint property is set correctly # check that the root = /mountpoint property is set correctly
grep "$TESTPOOL[ ]*altroot[ ]*/${TESTPOOL}.root" /tmp/values.$$ > /dev/null 2>&1 grep "$TESTPOOL[ ]*altroot[ ]*/${TESTPOOL}.root" $values > /dev/null 2>&1
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
log_fail "zpool property root was not found in pool output." log_fail "zpool property root was not found in pool output."
fi fi
rm /tmp/values.$$ rm $values
# finally, check that the pool has no reference in /etc/zfs/zpool.cache # finally, check that the pool has no reference in /etc/zfs/zpool.cache
if [[ -f /etc/zfs/zpool.cache ]] ; then if [[ -f /etc/zfs/zpool.cache ]] ; then
@ -108,5 +111,4 @@ if [[ -f /etc/zfs/zpool.cache ]] ; then
fi fi
fi fi
log_pass "zpool create -R works as expected" log_pass "zpool create -R works as expected"

View File

@ -48,19 +48,25 @@
# default values are sane, or whether they can be changed with zpool set. # default values are sane, or whether they can be changed with zpool set.
# #
function cleanup
{
rm -f $values
}
log_onexit cleanup
log_assert "Zpool get all works as expected" log_assert "Zpool get all works as expected"
typeset -i i=0; typeset -i i=0;
typeset values=$TEST_BASE_DIR/values.$$
if ! is_global_zone ; then if ! is_global_zone ; then
TESTPOOL=${TESTPOOL%%/*} TESTPOOL=${TESTPOOL%%/*}
fi fi
log_must zpool get all $TESTPOOL log_must zpool get all $TESTPOOL
zpool get all $TESTPOOL > /tmp/values.$$ zpool get all $TESTPOOL > $values
log_note "Checking zpool get all output for a header." log_note "Checking zpool get all output for a header."
grep ^"NAME " /tmp/values.$$ > /dev/null 2>&1 grep ^"NAME " $values > /dev/null 2>&1
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
log_fail "The header was not printed from zpool get all" log_fail "The header was not printed from zpool get all"
@ -70,7 +76,7 @@ fi
while [ $i -lt "${#properties[@]}" ] while [ $i -lt "${#properties[@]}" ]
do do
log_note "Checking for ${properties[$i]} property" log_note "Checking for ${properties[$i]} property"
grep "$TESTPOOL *${properties[$i]}" /tmp/values.$$ > /dev/null 2>&1 grep "$TESTPOOL *${properties[$i]}" $values > /dev/null 2>&1
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
log_fail "zpool property ${properties[$i]} was not found\ log_fail "zpool property ${properties[$i]} was not found\
@ -82,13 +88,10 @@ done
# increment the counter to include the header line # increment the counter to include the header line
i=$(( $i + 1 )) i=$(( $i + 1 ))
COUNT=$(wc /tmp/values.$$ | awk '{print $1}') COUNT=$(wc $values | awk '{print $1}')
if [ $i -ne $COUNT ] if [ $i -ne $COUNT ]
then then
log_fail "Found zpool features not in the zpool_get test config $i/$COUNT." log_fail "Found zpool features not in the zpool_get test config $i/$COUNT."
fi fi
rm /tmp/values.$$
log_pass "Zpool get all works as expected" log_pass "Zpool get all works as expected"

View File

@ -41,24 +41,31 @@
# 1. For all properties, verify zpool get retrieves a value # 1. For all properties, verify zpool get retrieves a value
# #
function cleanup
{
rm -f $values
}
log_assert "Zpool get returns values for all known properties" log_assert "Zpool get returns values for all known properties"
log_onexit cleanup
if ! is_global_zone ; then if ! is_global_zone ; then
TESTPOOL=${TESTPOOL%%/*} TESTPOOL=${TESTPOOL%%/*}
fi fi
typeset -i i=0; typeset -i i=0;
typeset values=$TEST_BASE_DIR/values.$$
while [ $i -lt "${#properties[@]}" ] while [ $i -lt "${#properties[@]}" ]
do do
log_note "Checking for ${properties[$i]} property" log_note "Checking for ${properties[$i]} property"
log_must eval "zpool get ${properties[$i]} $TESTPOOL > /tmp/value.$$" log_must eval "zpool get ${properties[$i]} $TESTPOOL > $values"
grep "${properties[$i]}" /tmp/value.$$ > /dev/null 2>&1 grep "${properties[$i]}" $values > /dev/null 2>&1
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
log_fail "${properties[$i]} not seen in output" log_fail "${properties[$i]} not seen in output"
fi fi
grep "^NAME " /tmp/value.$$ > /dev/null 2>&1 grep "^NAME " $values > /dev/null 2>&1
# only need to check this once. # only need to check this once.
if [ $i -eq 0 ] && [ $? -ne 0 ] if [ $i -eq 0 ] && [ $? -ne 0 ]
then then
@ -67,5 +74,4 @@ do
i=$(( $i + 1 )) i=$(( $i + 1 ))
done done
rm /tmp/value.$$
log_pass "Zpool get returns values for all known properties" log_pass "Zpool get returns values for all known properties"

View File

@ -45,7 +45,15 @@
verify_runnable "global" verify_runnable "global"
function cleanup
{
rm -f $versions
}
log_assert "Executing 'zpool upgrade -v' command succeeds" log_assert "Executing 'zpool upgrade -v' command succeeds"
log_onexit cleanup
typeset versions=$TEST_BASE_DIR/zpool-versions.$$
log_must zpool upgrade -v log_must zpool upgrade -v
@ -54,7 +62,7 @@ log_must zpool upgrade -v
log_must eval "zpool upgrade -v | head -1 | grep 'feature flags'" log_must eval "zpool upgrade -v | head -1 | grep 'feature flags'"
zpool upgrade -v > /tmp/zpool-versions.$$ zpool upgrade -v > $versions
# #
# Current output for 'zpool upgrade -v' has different indent space # Current output for 'zpool upgrade -v' has different indent space
@ -64,8 +72,7 @@ zpool upgrade -v > /tmp/zpool-versions.$$
# #
for version in {1..28}; do for version in {1..28}; do
log_note "Checking for a description of pool version $version" log_note "Checking for a description of pool version $version"
log_must eval "awk '/^ $version / { print $1 }' /tmp/zpool-versions.$$ | grep $version" log_must eval "awk '/^ $version / { print $1 }' $versions | grep $version"
done done
rm /tmp/zpool-versions.$$
log_pass "Executing 'zpool upgrade -v' command succeeds" log_pass "Executing 'zpool upgrade -v' command succeeds"

View File

@ -42,9 +42,9 @@ then
log_must zpool destroy v1-pool log_must zpool destroy v1-pool
fi fi
if [[ -f /tmp/zfstest_datastream.dat ]] if [[ -f $TEST_BASE_DIR/zfstest_datastream.dat ]]
then then
log_must rm -f /tmp/zfstest_datastream.dat log_must rm -f $TEST_BASE_DIR/zfstest_datastream.dat
fi fi
default_cleanup default_cleanup

View File

@ -69,12 +69,12 @@ log_must zfs unmount $TESTPOOL/$TESTFS/$TESTFS2.unmounted
# send our snapshot to a known file in /tmp # send our snapshot to a known file in /tmp
zfs send $TESTPOOL/$TESTFS@snap > /tmp/zfstest_datastream.dat zfs send $TESTPOOL/$TESTFS@snap > $TEST_BASE_DIR/zfstest_datastream.dat
if [ ! -s /tmp/zfstest_datastream.dat ] if [ ! -s $TEST_BASE_DIR/zfstest_datastream.dat ]
then then
log_fail "ZFS send datafile was not created!" log_fail "ZFS send datafile was not created!"
fi fi
log_must chmod 644 /tmp/zfstest_datastream.dat log_must chmod 644 $TEST_BASE_DIR/zfstest_datastream.dat
# create a filesystem that has particular properties to test set/get # create a filesystem that has particular properties to test set/get

View File

@ -44,21 +44,21 @@
function check_zdb function check_zdb
{ {
$@ > /tmp/zdb.$$ $@ > $TEST_BASE_DIR/zdb.$$
grep "Dataset mos" /tmp/zdb.$$ grep "Dataset mos" $TEST_BASE_DIR/zdb.$$
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
log_fail "$@ exited 0 when run as a non root user!" log_fail "$@ exited 0 when run as a non root user!"
fi fi
rm /tmp/zdb.$$ rm $TEST_BASE_DIR/zdb.$$
} }
function cleanup function cleanup
{ {
if [ -e /tmp/zdb_001_neg.$$.txt ] if [ -e $TEST_BASE_DIR/zdb_001_neg.$$.txt ]
then then
rm /tmp/zdb_001_neg.$$.txt rm $TEST_BASE_DIR/zdb_001_neg.$$.txt
fi fi
} }
@ -68,10 +68,10 @@ verify_runnable "global"
log_assert "zdb can't run as a user on datasets, but can run without arguments" log_assert "zdb can't run as a user on datasets, but can run without arguments"
log_onexit cleanup log_onexit cleanup
log_must eval "zdb > /tmp/zdb_001_neg.$$.txt" log_must eval "zdb > $TEST_BASE_DIR/zdb_001_neg.$$.txt"
# verify the output looks okay # verify the output looks okay
log_must grep pool_guid /tmp/zdb_001_neg.$$.txt log_must grep pool_guid $TEST_BASE_DIR/zdb_001_neg.$$.txt
log_must rm /tmp/zdb_001_neg.$$.txt log_must rm $TEST_BASE_DIR/zdb_001_neg.$$.txt
# we shouldn't able to run it on any dataset # we shouldn't able to run it on any dataset
check_zdb zdb $TESTPOOL check_zdb zdb $TESTPOOL

View File

@ -44,16 +44,16 @@
function cleanup function cleanup
{ {
if [ -e /tmp/zfs_001_neg.$$.txt ] if [ -e $TEST_BASE_DIR/zfs_001_neg.$$.txt ]
then then
rm /tmp/zfs_001_neg.$$.txt rm $TEST_BASE_DIR/zfs_001_neg.$$.txt
fi fi
} }
log_onexit cleanup log_onexit cleanup
log_assert "zfs shows a usage message when run as a user" log_assert "zfs shows a usage message when run as a user"
eval "zfs > /tmp/zfs_001_neg.$$.txt 2>&1" eval "zfs > $TEST_BASE_DIR/zfs_001_neg.$$.txt 2>&1"
log_must grep "usage: zfs command args" /tmp/zfs_001_neg.$$.txt log_must grep "usage: zfs command args" $TEST_BASE_DIR/zfs_001_neg.$$.txt
log_pass "zfs shows a usage message when run as a user" log_pass "zfs shows a usage message when run as a user"

View File

@ -46,7 +46,7 @@
log_assert "zfs receive returns an error when run as a user" log_assert "zfs receive returns an error when run as a user"
log_mustnot eval "zfs receive -d $TESTPOOL/$TESTFS/$TESTFS2 \ log_mustnot eval "zfs receive -d $TESTPOOL/$TESTFS/$TESTFS2 \
< /tmp/zfstest_datastream.dat" < $TEST_BASE_DIR/zfstest_datastream.dat"
# verify that command actually did nothing # verify that command actually did nothing

View File

@ -45,23 +45,23 @@
function cleanup function cleanup
{ {
if [ -e /tmp/zfstest_datastream.$$ ] if [ -e $TEST_BASE_DIR/zfstest_datastream.$$ ]
then then
log_must rm /tmp/zfstest_datastream.$$ log_must rm $TEST_BASE_DIR/zfstest_datastream.$$
fi fi
} }
log_assert "zfs send returns an error when run as a user" log_assert "zfs send returns an error when run as a user"
log_onexit cleanup log_onexit cleanup
log_mustnot eval "zfs send $TESTPOOL/$TESTFS@snap > /tmp/zfstest_datastream.$$" log_mustnot eval "zfs send $TESTPOOL/$TESTFS@snap > $TEST_BASE_DIR/zfstest_datastream.$$"
# Now check that the above command actually did nothing # Now check that the above command actually did nothing
# We should have a non-zero-length file in /tmp # We should have a non-zero-length file in /tmp
if [ -s /tmp/zfstest_datastream.$$ ] if [ -s $TEST_BASE_DIR/zfstest_datastream.$$ ]
then then
log_fail "A zfs send file was created in /tmp/zfstest_datastream.$$ !" log_fail "A zfs send file was created in $TEST_BASE_DIR/zfstest_datastream.$$ !"
fi fi
log_pass "zfs send returns an error when run as a user" log_pass "zfs send returns an error when run as a user"

View File

@ -45,16 +45,16 @@
function cleanup function cleanup
{ {
if [ -e /tmp/zpool_001_neg.$$.txt ] if [ -e $TEST_BASE_DIR/zpool_001_neg.$$.txt ]
then then
rm /tmp/zpool_001_neg.$$.txt rm $TEST_BASE_DIR/zpool_001_neg.$$.txt
fi fi
} }
log_onexit cleanup log_onexit cleanup
log_assert "zpool shows a usage message when run as a user" log_assert "zpool shows a usage message when run as a user"
eval "zpool > /tmp/zpool_001_neg.$$.txt 2>&1" eval "zpool > $TEST_BASE_DIR/zpool_001_neg.$$.txt 2>&1"
log_must grep "usage: zpool command args" /tmp/zpool_001_neg.$$.txt log_must grep "usage: zpool command args" $TEST_BASE_DIR/zpool_001_neg.$$.txt
log_pass "zpool shows a usage message when run as a user" log_pass "zpool shows a usage message when run as a user"

View File

@ -45,28 +45,28 @@
function check_pool_status function check_pool_status
{ {
RESULT=$(grep "pool:" /tmp/pool-status.$$) RESULT=$(grep "pool:" $TEST_BASE_DIR/pool-status.$$)
if [ -z "$RESULT" ] if [ -z "$RESULT" ]
then then
log_fail "No pool: string found in zpool status output!" log_fail "No pool: string found in zpool status output!"
fi fi
rm /tmp/pool-status.$$ rm $TEST_BASE_DIR/pool-status.$$
} }
verify_runnable "global" verify_runnable "global"
log_assert "zpool status works when run as a user" log_assert "zpool status works when run as a user"
log_must eval "zpool status > /tmp/pool-status.$$" log_must eval "zpool status > $TEST_BASE_DIR/pool-status.$$"
check_pool_status check_pool_status
log_must eval "zpool status -v > /tmp/pool-status.$$" log_must eval "zpool status -v > $TEST_BASE_DIR/pool-status.$$"
check_pool_status check_pool_status
log_must eval "zpool status $TESTPOOL> /tmp/pool-status.$$" log_must eval "zpool status $TESTPOOL> $TEST_BASE_DIR/pool-status.$$"
check_pool_status check_pool_status
log_must eval "zpool status -v $TESTPOOL > /tmp/pool-status.$$" log_must eval "zpool status -v $TESTPOOL > $TEST_BASE_DIR/pool-status.$$"
check_pool_status check_pool_status
log_pass "zpool status works when run as a user" log_pass "zpool status works when run as a user"

View File

@ -54,7 +54,7 @@ log_onexit cleanup
log_assert "Verify 'zfs list -r' could display any children recursively." log_assert "Verify 'zfs list -r' could display any children recursively."
tmpfile=/var/tmp/zfslist.out.$$ tmpfile=$TEST_BASE_DIR/zfslist.out.$$
children="$TESTPOOL/$TESTFS" children="$TESTPOOL/$TESTFS"
for fs in $DATASETS ; do for fs in $DATASETS ; do

View File

@ -43,7 +43,7 @@
verify_runnable "both" verify_runnable "both"
typeset tmpfile=/var/tmp/zfsiostat.out.$$ typeset tmpfile=$TEST_BASE_DIR/zfsiostat.out.$$
typeset -i stat_count=0 typeset -i stat_count=0
function cleanup function cleanup

View File

@ -111,7 +111,7 @@ done
run_and_verify -p "$MPOOL" "zpool split $MPOOL ${MPOOL}_split" run_and_verify -p "$MPOOL" "zpool split $MPOOL ${MPOOL}_split"
import_dir=/var/tmp/import_dir.$$ import_dir=$TEST_BASE_DIR/import_dir.$$
log_must mkdir $import_dir log_must mkdir $import_dir
log_must cp $STF_SUITE/tests/functional/history/zfs-pool-v4.dat.Z $import_dir log_must cp $STF_SUITE/tests/functional/history/zfs-pool-v4.dat.Z $import_dir
log_must uncompress $import_dir/zfs-pool-v4.dat.Z log_must uncompress $import_dir/zfs-pool-v4.dat.Z

View File

@ -61,7 +61,7 @@ fs=$TESTPOOL/$TESTFS1; newfs=$TESTPOOL/newfs; fsclone=$TESTPOOL/clone
vol=$TESTPOOL/$TESTVOL ; newvol=$TESTPOOL/newvol; volclone=$TESTPOOL/volclone vol=$TESTPOOL/$TESTVOL ; newvol=$TESTPOOL/newvol; volclone=$TESTPOOL/volclone
fssnap=$fs@fssnap; fssnap2=$fs@fssnap2 fssnap=$fs@fssnap; fssnap2=$fs@fssnap2
volsnap=$vol@volsnap; volsnap2=$vol@volsnap2 volsnap=$vol@volsnap; volsnap2=$vol@volsnap2
tmpfile=/tmp/tmpfile.$$ ; tmpfile2=/tmp/tmpfile2.$$ tmpfile=$TEST_BASE_DIR/tmpfile.$$ ; tmpfile2=$TEST_BASE_DIR/tmpfile2.$$
if is_linux; then if is_linux; then
# property value property value # property value property value

View File

@ -79,7 +79,7 @@ while ((i < 300)); do
((i += 1)) ((i += 1))
done done
TMPFILE=/tmp/spool.$$ TMPFILE=$TEST_BASE_DIR/spool.$$
zpool history $spool >$TMPFILE zpool history $spool >$TMPFILE
typeset -i entry_count=$(wc -l $TMPFILE | awk '{print $1}') typeset -i entry_count=$(wc -l $TMPFILE | awk '{print $1}')
typeset final_md5=$(head -2 $TMPFILE | md5sum | awk '{print $1}') typeset final_md5=$(head -2 $TMPFILE | md5sum | awk '{print $1}')

View File

@ -125,7 +125,7 @@ ln $DEV_RDSKDIR/$SDISK $REALDISK
log_must zpool create $TESTPOOL2 $REALDISK log_must zpool create $TESTPOOL2 $REALDISK
# Backup the contents of the disk image # Backup the contents of the disk image
BACKUP=/tmp/kstat-state-realdisk.gz BACKUP=$TEST_BASE_DIR/kstat-state-realdisk.gz
log_must [ ! -e $BACKUP ] log_must [ ! -e $BACKUP ]
gzip -c $REALDISK > $BACKUP gzip -c $REALDISK > $BACKUP

View File

@ -34,10 +34,10 @@
verify_runnable "global" verify_runnable "global"
[[ -f /var/tmp/exitsZero.ksh ]] && \ [[ -f $TEST_BASE_DIR/exitsZero.ksh ]] && \
log_must rm -f /var/tmp/exitsZero.ksh log_must rm -f $TEST_BASE_DIR/exitsZero.ksh
[[ -f /var/tmp/testbackgprocs.ksh ]] && \ [[ -f $TEST_BASE_DIR/testbackgprocs.ksh ]] && \
log_must rm -f /var/tmp/testbackgprocs.ksh log_must rm -f $TEST_BASE_DIR/testbackgprocs.ksh
ismounted $TESTPOOL/$TESTFS_TGT ismounted $TESTPOOL/$TESTFS_TGT
(( $? == 0 )) && log_must zfs umount $TESTPOOL/$TESTFS_TGT (( $? == 0 )) && log_must zfs umount $TESTPOOL/$TESTFS_TGT

View File

@ -37,11 +37,11 @@
# #
function check_bg_procs_limit_num function check_bg_procs_limit_num
{ {
echo "#!/bin/ksh" > /var/tmp/exitsZero.ksh echo "#!/bin/ksh" > $TEST_BASE_DIR/exitsZero.ksh
echo "exit 0" >> /var/tmp/exitsZero.ksh echo "exit 0" >> $TEST_BASE_DIR/exitsZero.ksh
chmod 777 /var/tmp/exitsZero.ksh chmod 777 $TEST_BASE_DIR/exitsZero.ksh
cat <<EOF > /var/tmp/testbackgprocs.ksh cat <<EOF > $TEST_BASE_DIR/testbackgprocs.ksh
#!/bin/ksh #!/bin/ksh
# #
# exitsZero.ksh is a one line script # exitsZero.ksh is a one line script
@ -52,7 +52,7 @@ PIDS=""
typeset -i i=1 typeset -i i=1
while [ \$i -le 50 ] while [ \$i -le 50 ]
do do
/var/tmp/exitsZero.ksh & $TEST_BASE_DIR/exitsZero.ksh &
PIDS="\$PIDS \$!" PIDS="\$PIDS \$!"
(( i = i + 1 )) (( i = i + 1 ))
done done
@ -67,7 +67,7 @@ done
exit 0 exit 0
EOF EOF
ksh /var/tmp/testbackgprocs.ksh ksh $TEST_BASE_DIR/testbackgprocs.ksh
if [[ $? -eq 1 ]]; then if [[ $? -eq 1 ]]; then
# #
# Current ksh being executed has a limit # Current ksh being executed has a limit

View File

@ -50,7 +50,7 @@ log_must zfs clone $origin@a $origin/clone
for rs in 512 1024 2048 4096 8192 16384 32768 65536 131072 ; do for rs in 512 1024 2048 4096 8192 16384 32768 65536 131072 ; do
log_must zfs set recsize=$rs $origin/clone log_must zfs set recsize=$rs $origin/clone
dd if=/$TESTDIR/file of=/$TESTDIR/clone/file bs=1024k count=$MEGS \ dd if=/$TESTDIR/file of=/$TESTDIR/clone/file bs=1024k count=$MEGS \
conv=notrunc >/tmp/null 2>&1 || log_fail "dd failed." conv=notrunc > $TEST_BASE_DIR/null 2>&1 || log_fail "dd failed."
log_must verify_nopwrite $origin $origin@a $origin/clone log_must verify_nopwrite $origin $origin@a $origin/clone
done done

View File

@ -28,7 +28,7 @@
# Copyright (c) 2013, 2015 by Delphix. All rights reserved. # Copyright (c) 2013, 2015 by Delphix. All rights reserved.
# #
export BASEDIR=/var/tmp/basedir.$$ export BASEDIR=$TEST_BASE_DIR/basedir.$$
export TESTFILE=testfile.$$ export TESTFILE=testfile.$$
export PRE_RECORD_FILE=$BASEDIR/pre-record-file.$$ export PRE_RECORD_FILE=$BASEDIR/pre-record-file.$$

View File

@ -48,7 +48,7 @@ verify_runnable "global"
log_assert "zpool/zfs destroy <rootpool> should fail" log_assert "zpool/zfs destroy <rootpool> should fail"
typeset rootpool=$(get_rootpool) typeset rootpool=$(get_rootpool)
typeset tmpfile="/tmp/mounted-datasets.$$" typeset tmpfile="$TEST_BASE_DIR/mounted-datasets.$$"
# Collect the currently mounted ZFS filesystems, so that we can repair any # Collect the currently mounted ZFS filesystems, so that we can repair any
# damage done by the attempted pool destroy. The destroy itself should fail, # damage done by the attempted pool destroy. The destroy itself should fail,

View File

@ -30,7 +30,7 @@
. $STF_SUITE/include/libtest.shlib . $STF_SUITE/include/libtest.shlib
export TMPDEV=/tmp/zpool_upgrade_test.dat export TMPDEV=$TEST_BASE_DIR/zpool_upgrade_test.dat
function cleanup_upgrade function cleanup_upgrade
{ {

View File

@ -59,7 +59,7 @@ log_onexit cleanup
log_assert \ log_assert \
"the userquota and groupquota can be set during zpool,zfs creation" "the userquota and groupquota can be set during zpool,zfs creation"
typeset pool_vdev=/var/tmp/pool_dev.$$ typeset pool_vdev=$TEST_BASE_DIR/pool_dev.$$
log_must mkfile 500m $pool_vdev log_must mkfile 500m $pool_vdev

View File

@ -33,8 +33,8 @@
del_user $ZFS_USER del_user $ZFS_USER
del_group $ZFS_GROUP del_group $ZFS_GROUP
USES_NIS=$(cat /tmp/zfs-xattr-test-nis.txt) USES_NIS=$(cat $TEST_BASE_DIR/zfs-xattr-test-nis.txt)
rm /tmp/zfs-xattr-test-nis.txt rm $TEST_BASE_DIR/zfs-xattr-test-nis.txt
if [ "${USES_NIS}" == "true" ] if [ "${USES_NIS}" == "true" ]
then then

View File

@ -48,8 +48,8 @@ fi
log_must add_group $ZFS_GROUP log_must add_group $ZFS_GROUP
log_must add_user $ZFS_GROUP $ZFS_USER log_must add_user $ZFS_GROUP $ZFS_USER
echo $ZFS_USER > /tmp/zfs-xattr-test-user.txt echo $ZFS_USER > $TEST_BASE_DIR/zfs-xattr-test-user.txt
echo $USES_NIS > /tmp/zfs-xattr-test-nis.txt echo $USES_NIS > $TEST_BASE_DIR/zfs-xattr-test-nis.txt
DISK=${DISKS%% *} DISK=${DISKS%% *}
default_setup $DISK default_setup $DISK

View File

@ -24,7 +24,7 @@
# Use is subject to license terms. # Use is subject to license terms.
# #
export NISSTAFILE=/var/tmp/nis_state export NISSTAFILE=$TEST_BASE_DIR/nis_state
export ZFS_USER=zxtr export ZFS_USER=zxtr
export ZFS_GROUP=zfsgrp export ZFS_GROUP=zfsgrp

View File

@ -49,9 +49,9 @@ function cleanup {
log_must zfs destroy $TESTPOOL/$TESTFS@snap log_must zfs destroy $TESTPOOL/$TESTFS@snap
log_must rm $TESTDIR/myfile2.$$ log_must rm $TESTDIR/myfile2.$$
log_must rm $TESTDIR/myfile.$$ log_must rm $TESTDIR/myfile.$$
log_must rm /tmp/output.$$ log_must rm $TEST_BASE_DIR/output.$$
[[ -e /tmp/expected_output.$$ ]] && log_must rm \ [[ -e $TEST_BASE_DIR/expected_output.$$ ]] && log_must rm \
/tmp/expected_output.$$ $TEST_BASE_DIR/expected_output.$$
} }
@ -71,20 +71,20 @@ log_must zfs snapshot $TESTPOOL/$TESTFS@snap
# we shouldn't be able to alter the first file's xattr # we shouldn't be able to alter the first file's xattr
if is_linux; then if is_linux; then
log_mustnot eval "attr -s cp $TESTDIR/.zfs/snapshot/snap/myfile.$$ \ log_mustnot eval "attr -s cp $TESTDIR/.zfs/snapshot/snap/myfile.$$ \
</etc/passwd >/tmp/output.$$ 2>&1" </etc/passwd > $TEST_BASE_DIR/output.$$ 2>&1"
log_must grep -i Read-only /tmp/output.$$ log_must grep -i Read-only $TEST_BASE_DIR/output.$$
log_must eval "attr -q -l $TESTDIR/.zfs/snapshot/snap/myfile2.$$ \ log_must eval "attr -q -l $TESTDIR/.zfs/snapshot/snap/myfile2.$$ \
>/tmp/output.$$ 2>&1" > $TEST_BASE_DIR/output.$$ 2>&1"
log_must eval "attr -q -l $TESTDIR/myfile2.$$ >/tmp/expected_output.$$" log_must eval "attr -q -l $TESTDIR/myfile2.$$ > $TEST_BASE_DIR/expected_output.$$"
else else
log_mustnot eval " runat $TESTDIR/.zfs/snapshot/snap/myfile.$$ \ log_mustnot eval " runat $TESTDIR/.zfs/snapshot/snap/myfile.$$ \
cp /etc/passwd . >/tmp/output.$$ 2>&1" cp /etc/passwd . > $TEST_BASE_DIR/output.$$ 2>&1"
log_must grep -i Read-only /tmp/output.$$ log_must grep -i Read-only $TEST_BASE_DIR/output.$$
log_must eval "runat $TESTDIR/.zfs/snapshot/snap/myfile2.$$ \ log_must eval "runat $TESTDIR/.zfs/snapshot/snap/myfile2.$$ \
ls >/tmp/output.$$ 2>&1" ls > $TEST_BASE_DIR/output.$$ 2>&1"
create_expected_output /tmp/expected_output.$$ SUNWattr_ro SUNWattr_rw create_expected_output $TEST_BASE_DIR/expected_output.$$ SUNWattr_ro SUNWattr_rw
fi fi
log_must diff /tmp/output.$$ /tmp/expected_output.$$ log_must diff $TEST_BASE_DIR/output.$$ $TEST_BASE_DIR/expected_output.$$
log_pass "create/write xattr on a snapshot fails" log_pass "create/write xattr on a snapshot fails"

View File

@ -43,7 +43,7 @@
function cleanup { function cleanup {
typeset file typeset file
for file in /tmp/output.$$ /tmp/expected-output.$$ \ for file in $TEST_BASE_DIR/output.$$ $TEST_BASE_DIR/expected-output.$$ \
$TESTDIR/myfile.$$ ; do $TESTDIR/myfile.$$ ; do
log_must rm -f $file log_must rm -f $file
done done
@ -61,15 +61,15 @@ log_must touch $TESTDIR/myfile.$$
create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
# listing the directory . # listing the directory .
log_must eval "runat $TESTDIR/myfile.$$ ls . > /tmp/output.$$" log_must eval "runat $TESTDIR/myfile.$$ ls . > $TEST_BASE_DIR/output.$$"
create_expected_output /tmp/expected-output.$$ \ create_expected_output $TEST_BASE_DIR/expected-output.$$ \
SUNWattr_ro SUNWattr_rw passwd SUNWattr_ro SUNWattr_rw passwd
log_must diff /tmp/output.$$ /tmp/expected-output.$$ log_must diff $TEST_BASE_DIR/output.$$ $TEST_BASE_DIR/expected-output.$$
# list the directory . long form # list the directory . long form
log_must eval "runat $TESTDIR/myfile.$$ ls -a . > /tmp/output.$$" log_must eval "runat $TESTDIR/myfile.$$ ls -a . > $TEST_BASE_DIR/output.$$"
create_expected_output /tmp/expected-output.$$ . .. \ create_expected_output $TEST_BASE_DIR/expected-output.$$ . .. \
SUNWattr_ro SUNWattr_rw passwd SUNWattr_ro SUNWattr_rw passwd
log_must diff /tmp/output.$$ /tmp/expected-output.$$ log_must diff $TEST_BASE_DIR/output.$$ $TEST_BASE_DIR/expected-output.$$
# list the directory .. expecting one file # list the directory .. expecting one file
OUTPUT=$(runat $TESTDIR/myfile.$$ ls ..) OUTPUT=$(runat $TESTDIR/myfile.$$ ls ..)

View File

@ -71,25 +71,25 @@ else
log_note "Checking cpio" log_note "Checking cpio"
log_must touch $TESTDIR/cpio.$$ log_must touch $TESTDIR/cpio.$$
create_xattr $TESTDIR/cpio.$$ passwd /etc/passwd create_xattr $TESTDIR/cpio.$$ passwd /etc/passwd
echo $TESTDIR/cpio.$$ | cpio -o@ > /tmp/xattr.$$.cpio echo $TESTDIR/cpio.$$ | cpio -o@ > $TEST_BASE_DIR/xattr.$$.cpio
echo $TESTDIR/cpio.$$ | cpio -o > /tmp/noxattr.$$.cpio echo $TESTDIR/cpio.$$ | cpio -o > $TEST_BASE_DIR/noxattr.$$.cpio
# we should have no xattr here # we should have no xattr here
log_must cpio -iu < /tmp/xattr.$$.cpio log_must cpio -iu < $TEST_BASE_DIR/xattr.$$.cpio
log_mustnot eval "runat $TESTDIR/cpio.$$ cat passwd > /dev/null 2>&1" log_mustnot eval "runat $TESTDIR/cpio.$$ cat passwd > /dev/null 2>&1"
# we should have an xattr here # we should have an xattr here
log_must cpio -iu@ < /tmp/xattr.$$.cpio log_must cpio -iu@ < $TEST_BASE_DIR/xattr.$$.cpio
log_must eval "runat $TESTDIR/cpio.$$ cat passwd > /dev/null 2>&1" log_must eval "runat $TESTDIR/cpio.$$ cat passwd > /dev/null 2>&1"
# we should have no xattr here # we should have no xattr here
log_must cpio -iu < /tmp/noxattr.$$.cpio log_must cpio -iu < $TEST_BASE_DIR/noxattr.$$.cpio
log_mustnot eval "runat $TESTDIR/cpio.$$ cat passwd > /dev/null 2>&1" log_mustnot eval "runat $TESTDIR/cpio.$$ cat passwd > /dev/null 2>&1"
# we should have no xattr here # we should have no xattr here
log_must cpio -iu@ < /tmp/noxattr.$$.cpio log_must cpio -iu@ < $TEST_BASE_DIR/noxattr.$$.cpio
log_mustnot eval "runat $TESTDIR/cpio.$$ cat passwd > /dev/null 2>&1" log_mustnot eval "runat $TESTDIR/cpio.$$ cat passwd > /dev/null 2>&1"
log_must rm $TESTDIR/cpio.$$ /tmp/xattr.$$.cpio /tmp/noxattr.$$.cpio log_must rm $TESTDIR/cpio.$$ $TEST_BASE_DIR/xattr.$$.cpio $TEST_BASE_DIR/noxattr.$$.cpio
fi fi
log_note "Checking cp" log_note "Checking cp"

View File

@ -60,15 +60,15 @@ function compare_xattrs { # filename1 filename2 xattr_name
typeset XATTR_NAME=$3 typeset XATTR_NAME=$3
if is_linux; then if is_linux; then
attr -q -g $XATTR_NAME $FILE1 >/tmp/file1.$$ attr -q -g $XATTR_NAME $FILE1 > $TEST_BASE_DIR/file1.$$
attr -q -g $XATTR_NAME $FILE2 >/tmp/file2.$$ attr -q -g $XATTR_NAME $FILE2 > $TEST_BASE_DIR/file2.$$
else else
runat $FILE1 cat $XATTR_NAME > /tmp/file1.$$ runat $FILE1 cat $XATTR_NAME > $TEST_BASE_DIR/file1.$$
runat $FILE2 cat $XATTR_NAME > /tmp/file2.$$ runat $FILE2 cat $XATTR_NAME > $TEST_BASE_DIR/file2.$$
fi fi
log_must diff /tmp/file1.$$ /tmp/file2.$$ log_must diff $TEST_BASE_DIR/file1.$$ $TEST_BASE_DIR/file2.$$
log_must rm /tmp/file1.$$ /tmp/file2.$$ log_must rm $TEST_BASE_DIR/file1.$$ $TEST_BASE_DIR/file2.$$
} }
function verify_xattr { # filename xattr_name xattr_contents function verify_xattr { # filename xattr_name xattr_contents
@ -79,14 +79,14 @@ function verify_xattr { # filename xattr_name xattr_contents
# read the xattr, writing it to a temp file # read the xattr, writing it to a temp file
if is_linux; then if is_linux; then
log_must eval \ log_must eval \
"attr -q -g $XATTR_NAME $FILE >/tmp/$XATTR_NAME.$$" "attr -q -g $XATTR_NAME $FILE > $TEST_BASE_DIR/$XATTR_NAME.$$"
else else
log_must eval \ log_must eval \
"runat $FILE cat $XATTR_NAME >/tmp/$XATTR_NAME.$$ 2>&1" "runat $FILE cat $XATTR_NAME > $TEST_BASE_DIR/$XATTR_NAME.$$ 2>&1"
fi fi
log_must diff $XATTR_CONTENTS /tmp/$XATTR_NAME.$$ log_must diff $XATTR_CONTENTS $TEST_BASE_DIR/$XATTR_NAME.$$
rm /tmp/$XATTR_NAME.$$ rm $TEST_BASE_DIR/$XATTR_NAME.$$
} }
function delete_xattr { # filename xattr_name function delete_xattr { # filename xattr_name
@ -111,15 +111,15 @@ function verify_write_xattr { # filename xattr_name
if is_linux; then if is_linux; then
log_must attr -q -s $XATTR_NAME $FILE < /etc/passwd log_must attr -q -s $XATTR_NAME $FILE < /etc/passwd
log_must eval \ log_must eval \
"attr -q -g $XATTR_NAME $FILE >/tmp/$XATTR_NAME.$$" "attr -q -g $XATTR_NAME $FILE > $TEST_BASE_DIR/$XATTR_NAME.$$"
else else
log_must eval "runat $FILE dd if=/etc/passwd of=$XATTR_NAME" log_must eval "runat $FILE dd if=/etc/passwd of=$XATTR_NAME"
log_must eval \ log_must eval \
"runat $FILE cat $XATTR_NAME > /tmp/$XATTR_NAME.$$ 2>&1" "runat $FILE cat $XATTR_NAME > $TEST_BASE_DIR/$XATTR_NAME.$$ 2>&1"
fi fi
log_must dd if=/etc/passwd of=/tmp/passwd_dd.$$ log_must dd if=/etc/passwd of=$TEST_BASE_DIR/passwd_dd.$$
log_must diff /tmp/passwd_dd.$$ /tmp/$XATTR_NAME.$$ log_must diff $TEST_BASE_DIR/passwd_dd.$$ $TEST_BASE_DIR/$XATTR_NAME.$$
log_must rm /tmp/passwd_dd.$$ /tmp/$XATTR_NAME.$$ log_must rm $TEST_BASE_DIR/passwd_dd.$$ $TEST_BASE_DIR/$XATTR_NAME.$$
} }
# this function is to create the expected output # this function is to create the expected output