Add the ZFS Test Suite

Add the ZFS Test Suite and test-runner framework from illumos.
This is a continuation of the work done by Turbo Fredriksson to
port the ZFS Test Suite to Linux.  While this work was originally
conceived as a stand alone project integrating it directly with
the ZoL source tree has several advantages:

  * Allows the ZFS Test Suite to be packaged in zfs-test package.
    * Facilitates easy integration with the CI testing.
    * Users can locally run the ZFS Test Suite to validate ZFS.
      This testing should ONLY be done on a dedicated test system
      because the ZFS Test Suite in its current form is destructive.
  * Allows the ZFS Test Suite to be run directly in the ZoL source
    tree enabled developers to iterate quickly during development.
  * Developers can easily add/modify tests in the framework as
    features are added or functionality is changed.  The tests
    will then always be in sync with the implementation.

Full documentation for how to run the ZFS Test Suite is available
in the tests/README.md file.

Warning: This test suite is designed to be run on a dedicated test
system.  It will make modifications to the system including, but
not limited to, the following.

  * Adding new users
  * Adding new groups
  * Modifying the following /proc files:
    * /proc/sys/kernel/core_pattern
    * /proc/sys/kernel/core_uses_pid
  * Creating directories under /

Notes:
  * Not all of the test cases are expected to pass and by default
    these test cases are disabled.  The failures are primarily due
    to assumption made for illumos which are invalid under Linux.
  * When updating these test cases it should be done in as generic
    a way as possible so the patch can be submitted back upstream.
    Most existing library functions have been updated to be Linux
    aware, and the following functions and variables have been added.
    * Functions:
      * is_linux          - Used to wrap a Linux specific section.
      * block_device_wait - Waits for block devices to be added to /dev/.
    * Variables:            Linux          Illumos
      * ZVOL_DEVDIR         "/dev/zvol"    "/dev/zvol/dsk"
      * ZVOL_RDEVDIR        "/dev/zvol"    "/dev/zvol/rdsk"
      * DEV_DSKDIR          "/dev"         "/dev/dsk"
      * DEV_RDSKDIR         "/dev"         "/dev/rdsk"
      * NEWFS_DEFAULT_FS    "ext2"         "ufs"
  * Many of the disabled test cases fail because 'zfs/zpool destroy'
    returns EBUSY.  This is largely causes by the asynchronous nature
    of device handling on Linux and is expected, the impacted test
    cases will need to be updated to handle this.
  * There are several test cases which have been disabled because
    they can trigger a deadlock.  A primary example of this is to
    recursively create zpools within zpools.  These tests have been
    disabled until the root issue can be addressed.
  * Illumos specific utilities such as (mkfile) should be added to
    the tests/zfs-tests/cmd/ directory.  Custom programs required by
    the test scripts can also be added here.
  * SELinux should be either is permissive mode or disabled when
    running the tests.  The test cases should be updated to conform
    to a standard policy.
  * Redundant test functionality has been removed (zfault.sh).
  * Existing test scripts (zconfig.sh) should be migrated to use
    the framework for consistency and ease of testing.
  * The DISKS environment variable currently only supports loopback
    devices because of how the ZFS Test Suite expects partitions to
    be named (p1, p2, etc).  Support must be added to generate the
    correct partition name based on the device location and name.
  * The ZFS Test Suite is part of the illumos code base at:
    https://github.com/illumos/illumos-gate/tree/master/usr/src/test

Original-patch-by: Turbo Fredriksson <turbo@bayour.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Olaf Faaland <faaland1@llnl.gov>
Closes #6
Closes #1534
This commit is contained in:
Brian Behlendorf
2015-07-01 15:23:09 -07:00
parent 887d1e60ef
commit 6bb24f4dc7
1243 changed files with 89497 additions and 1042 deletions
@@ -0,0 +1,18 @@
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/xattr
dist_pkgdata_SCRIPTS = \
xattr_common.kshlib \
setup.ksh \
cleanup.ksh \
xattr_001_pos.ksh \
xattr_002_neg.ksh \
xattr_003_neg.ksh \
xattr_004_pos.ksh \
xattr_005_pos.ksh \
xattr_006_pos.ksh \
xattr_007_neg.ksh \
xattr_008_pos.ksh \
xattr_009_neg.ksh \
xattr_010_neg.ksh \
xattr_011_pos.ksh \
xattr_012_pos.ksh \
xattr_013_pos.ksh
+45
View File
@@ -0,0 +1,45 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
ZFS_USER=$($CAT /tmp/zfs-xattr-test-user.txt)
$RM /tmp/zfs-xattr-test-user.txt
USES_NIS=$($CAT /tmp/zfs-xattr-test-nis.txt)
$RM /tmp/zfs-xattr-test-nis.txt
del_user $ZFS_USER
if [ "${USES_NIS}" == "true" ]
then
$SVCADM enable svc:/network/nis/client:default
fi
default_cleanup
+64
View File
@@ -0,0 +1,64 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
# if we're running NIS, turn it off until we clean up
# (it can cause useradd to take a long time, hitting our TIMEOUT)
USES_NIS=FALSE
$SVCS svc:/network/nis/client:default | $GREP online > /dev/null
if [ $? -eq 0 ]
then
$SVCADM disable -t svc:/network/nis/client:default
USES_NIS=true
fi
# Make sure we use a brand new user for this
ZFS_USER=zxtr
ZFS_GROUP=staff
while [ -z "${FOUND}" ]
do
COUNT=0
USER_EXISTS=$( $GREP $ZFS_USER /etc/passwd )
if [ ! -z "${USER_EXISTS}" ]
then
ZFS_USER="${ZFS_USER}${COUNT}"
COUNT=$(( $COUNT + 1 ))
else
FOUND="true"
fi
done
log_must add_user $ZFS_GROUP $ZFS_USER
$ECHO $ZFS_USER > /tmp/zfs-xattr-test-user.txt
$ECHO $USES_NIS > /tmp/zfs-xattr-test-nis.txt
DISK=${DISKS%% *}
default_setup $DISK
+63
View File
@@ -0,0 +1,63 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/xattr/xattr_common.kshlib
#
# DESCRIPTION:
#
# Creating, reading and writing xattrs on ZFS filesystems works as expected
#
# STRATEGY:
# 1. Create an xattr on a ZFS-based file using runat
# 2. Read an empty xattr directory
# 3. Write the xattr using runat and cat
# 3. Read the xattr using runat
# 4. Delete the xattr
# 5. List the xattr namespace successfully, checking for deletion
#
function cleanup {
if [ -f $TESTDIR/myfile.$$ ]
then
log_must $RM $TESTDIR/myfile.$$
fi
}
log_assert "Create/read/write/append of xattrs works"
log_onexit cleanup
log_must $TOUCH $TESTDIR/myfile.$$
create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
verify_write_xattr $TESTDIR/myfile.$$ passwd
delete_xattr $TESTDIR/myfile.$$ passwd
log_pass "Create/read/write of xattrs works"
+56
View File
@@ -0,0 +1,56 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/xattr/xattr_common.kshlib
#
# DESCRIPTION:
#
# Trying to read a non-existent xattr should fail.
#
# STRATEGY:
# 1. Create a file
# 2. Try to read a non-existent xattr, check that an error is returned.
#
function cleanup {
log_must $RM $TESTDIR/myfile.$$
}
log_assert "A read of a non-existent xattr fails"
log_onexit cleanup
# create a file
log_must $TOUCH $TESTDIR/myfile.$$
log_mustnot eval "$CAT $TESTDIR/myfile.$$ not-here.txt > /dev/null 2>&1"
log_pass "A read of a non-existent xattr fails"
+62
View File
@@ -0,0 +1,62 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/xattr/xattr_common.kshlib
#
# DESCRIPTION:
#
# Attempting to read an xattr on a file for which we have no permissions
# should fail.
#
# STRATEGY:
# 1. Create a file, and set an with an xattr
# 2. Set the octal file permissions to 000 on the file.
# 3. Check that we're unable to read the xattr as a non-root user
# 4. Check that we're unable to write an xattr as a non-root user
#
function cleanup {
log_must $RM $TESTDIR/myfile.$$
}
log_assert "read/write xattr on a file with no permissions fails"
log_onexit cleanup
log_must $TOUCH $TESTDIR/myfile.$$
create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
log_must $CHMOD 000 $TESTDIR/myfile.$$
log_mustnot $SU $ZFS_USER -c "$RUNAT $TESTDIR/myfile.$$ $CAT passwd"
log_mustnot $SU $ZFS_USER -c "$RUNAT $TESTDIR/myfile.$$ $CP /etc/passwd ."
log_pass "read/write xattr on a file with no permissions fails"
+87
View File
@@ -0,0 +1,87 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/xattr/xattr_common.kshlib
#
# DESCRIPTION:
#
# Creating files on ufs|ext2 and tmpfs, and copying those files to ZFS with
# appropriate cp flags, the xattrs will still be readable.
#
# STRATEGY:
# 1. Create files in ufs|ext2 and tmpfs with xattrs
# 2. Copy those files to zfs
# 3. Ensure the xattrs can be read and written
# 4. Do the same in reverse.
#
# we need to be able to create zvols to hold our test
# ufs|ext2 filesystem.
verify_runnable "global"
# Make sure we clean up properly
function cleanup {
if [ $( ismounted /tmp/$NEWFS_DEFAULT_FS.$$ $NEWFS_DEFAULT_FS ) ]
then
log_must $UMOUNT /tmp/$NEWFS_DEFAULT_FS.$$
log_must $RM -rf /tmp/$NEWFS_DEFAULT_FS.$$
fi
}
log_assert "Files from $NEWFS_DEFAULT_FS,tmpfs with xattrs copied to zfs retain xattr info."
log_onexit cleanup
# Create a UFS|EXT2 file system that we can work in
log_must $ZFS create -V128m $TESTPOOL/$TESTFS/zvol
block_device_wait
log_must eval "$ECHO y | $NEWFS $ZVOL_DEVDIR/$TESTPOOL/$TESTFS/zvol > /dev/null 2>&1"
log_must $MKDIR /tmp/$NEWFS_DEFAULT_FS.$$
log_must $MOUNT $ZVOL_DEVDIR/$TESTPOOL/$TESTFS/zvol /tmp/$NEWFS_DEFAULT_FS.$$
# Create files in ufs|ext2 and tmpfs, and set some xattrs on them.
log_must $TOUCH /tmp/$NEWFS_DEFAULT_FS.$$/$NEWFS_DEFAULT_FS-file.$$
log_must $TOUCH /tmp/tmpfs-file.$$
log_must $RUNAT /tmp/$NEWFS_DEFAULT_FS.$$/$NEWFS_DEFAULT_FS-file.$$ $CP /etc/passwd .
log_must $RUNAT /tmp/tmpfs-file.$$ $CP /etc/group .
# copy those files to ZFS
log_must $CP -@ /tmp/$NEWFS_DEFAULT_FS.$$/$NEWFS_DEFAULT_FS-file.$$ $TESTDIR
log_must $CP -@ /tmp/tmpfs-file.$$ $TESTDIR
# ensure the xattr information has been copied correctly
log_must $RUNAT $TESTDIR/$NEWFS_DEFAULT_FS-file.$$ $DIFF passwd /etc/passwd
log_must $RUNAT $TESTDIR/tmpfs-file.$$ $DIFF group /etc/group
log_must $UMOUNT /tmp/$NEWFS_DEFAULT_FS.$$
log_pass "Files from $NEWFS_DEFAULT_FS,tmpfs with xattrs copied to zfs retain xattr info."
+78
View File
@@ -0,0 +1,78 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/xattr/xattr_common.kshlib
#
# DESCRIPTION:
# read/write/create/delete xattr on a clone filesystem
#
#
# STRATEGY:
# 1. Create an xattr on a filesystem
# 2. Snapshot the filesystem and clone it
# 3. Verify the xattr can still be read, written, deleted
# 4. Verify we can create new xattrs on new files created on the clone
#
function cleanup {
log_must $ZFS destroy $TESTPOOL/$TESTFS/clone
log_must $ZFS destroy $TESTPOOL/$TESTFS@snapshot1
log_must $RM $TESTDIR/myfile.$$
}
log_assert "read/write/create/delete xattr on a clone filesystem"
log_onexit cleanup
# create a file, and an xattr on it
log_must $TOUCH $TESTDIR/myfile.$$
create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
# snapshot & clone the filesystem
log_must $ZFS snapshot $TESTPOOL/$TESTFS@snapshot1
log_must $ZFS clone $TESTPOOL/$TESTFS@snapshot1 $TESTPOOL/$TESTFS/clone
log_must $ZFS set mountpoint=$TESTDIR/clone $TESTPOOL/$TESTFS/clone
# check for the xattrs on the clone
verify_xattr $TESTDIR/clone/myfile.$$ passwd /etc/passwd
# check we can create xattrs on the clone
create_xattr $TESTDIR/clone/myfile.$$ foo /etc/passwd
delete_xattr $TESTDIR/clone/myfile.$$ foo
# delete the original dataset xattr
delete_xattr $TESTDIR/myfile.$$ passwd
# verify it's still there on the clone
verify_xattr $TESTDIR/clone/myfile.$$ passwd /etc/passwd
delete_xattr $TESTDIR/clone/myfile.$$ passwd
log_pass "read/write/create/delete xattr on a clone filesystem"
+63
View File
@@ -0,0 +1,63 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/xattr/xattr_common.kshlib
#
# DESCRIPTION:
# Xattrs present on a file in a snapshot should be visible.
#
# STRATEGY:
# 1. Create a file and give it an xattr
# 2. Take a snapshot of the filesystem
# 3. Verify that we can take a snapshot of it.
#
function cleanup {
log_must $ZFS destroy $TESTPOOL/$TESTFS@snap
log_must $RM $TESTDIR/myfile.$$
}
log_assert "read xattr on a snapshot"
log_onexit cleanup
# create a file, and an xattr on it
log_must $TOUCH $TESTDIR/myfile.$$
create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
# snapshot the filesystem
log_must $ZFS snapshot $TESTPOOL/$TESTFS@snap
# check for the xattr on the snapshot
verify_xattr $TESTDIR/.zfs/snapshot/snap/myfile.$$ passwd /etc/passwd
log_pass "read xattr on a snapshot"
+81
View File
@@ -0,0 +1,81 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/xattr/xattr_common.kshlib
#
# DESCRIPTION:
# Creating and writing xattrs on files in snapshot directories fails. Also,
# we shouldn't be able to list the xattrs of files in snapshots who didn't have
# xattrs when the snapshot was created (the xattr namespace wouldn't have been
# created yet, and snapshots are read-only) See fsattr(5) for more details.
#
# STRATEGY:
# 1. Create a file and add an xattr to it.
# 2. Create another file, but don't add an xattr to it.
# 3. Snapshot the filesystem
# 4. Verify we're unable to alter the xattr on the first file
# 5. Verify we're unable to list the xattrs on the second file
#
function cleanup {
log_must $ZFS destroy $TESTPOOL/$TESTFS@snap
log_must $RM $TESTDIR/myfile2.$$
log_must $RM $TESTDIR/myfile.$$
log_must $RM /tmp/output.$$
[[ -e /tmp/expected_output.$$ ]] && log_must $RM \
/tmp/expected_output.$$
}
log_assert "create/write xattr on a snapshot fails"
log_onexit cleanup
# create a file, and an xattr on it
log_must $TOUCH $TESTDIR/myfile.$$
create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
# create another file that doesn't have an xattr
log_must $TOUCH $TESTDIR/myfile2.$$
# snapshot the filesystem
log_must $ZFS snapshot $TESTPOOL/$TESTFS@snap
# we shouldn't be able to alter the first file's xattr
log_mustnot eval " $RUNAT $TESTDIR/.zfs/snapshot/snap/myfile.$$ \
$CP /etc/passwd . >/tmp/output.$$ 2>&1"
log_must $GREP -i Read-only /tmp/output.$$
log_must eval "$RUNAT $TESTDIR/.zfs/snapshot/snap/myfile2.$$ \
$LS >/tmp/output.$$ 2>&1"
create_expected_output /tmp/expected_output.$$ SUNWattr_ro SUNWattr_rw
log_must $DIFF /tmp/output.$$ /tmp/expected_output.$$
log_pass "create/write xattr on a snapshot fails"
+80
View File
@@ -0,0 +1,80 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/xattr/xattr_common.kshlib
#
# DESCRIPTION:
# We verify that the special . and .. dirs work as expected for xattrs.
#
# STRATEGY:
# 1. Create a file and an xattr on that file
# 2. List the . directory, verifying the output
# 3. Verify we're unable to list the ../ directory
#
function cleanup {
typeset file
for file in /tmp/output.$$ /tmp/expected-output.$$ \
$TESTDIR/myfile.$$ ; do
log_must $RM -f $file
done
}
log_assert "special . and .. dirs work as expected for xattrs"
log_onexit cleanup
# create a file, and an xattr on it
log_must $TOUCH $TESTDIR/myfile.$$
create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
# listing the directory .
log_must eval "$RUNAT $TESTDIR/myfile.$$ $LS . > /tmp/output.$$"
create_expected_output /tmp/expected-output.$$ \
SUNWattr_ro SUNWattr_rw passwd
log_must $DIFF /tmp/output.$$ /tmp/expected-output.$$
# list the directory . long form
log_must eval "$RUNAT $TESTDIR/myfile.$$ $LS -a . > /tmp/output.$$"
create_expected_output /tmp/expected-output.$$ . .. \
SUNWattr_ro SUNWattr_rw passwd
log_must $DIFF /tmp/output.$$ /tmp/expected-output.$$
# list the directory .. expecting one file
OUTPUT=$($RUNAT $TESTDIR/myfile.$$ $LS ..)
if [ "$OUTPUT" != ".." ]
then
log_fail "Listing the .. directory doesn't show \"..\" as expected."
fi
# verify we can't list ../
log_mustnot eval "$RUNAT $TESTDIR/myfile.$$ $LS ../ > /dev/null 2>&1"
log_pass "special . and .. dirs work as expected for xattrs"
+62
View File
@@ -0,0 +1,62 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/xattr/xattr_common.kshlib
#
# DESCRIPTION:
# links between xattr and normal file namespace fail
#
# STRATEGY:
# 1. Create a file and add an xattr to it (to ensure the namespace exists)
# 2. Verify we're unable to create a symbolic link
# 3. Verify we're unable to create a hard link
#
function cleanup {
log_must $RM $TESTDIR/myfile.$$
}
log_assert "links between xattr and normal file namespace fail"
log_onexit cleanup
# create a file, and an xattr on it
log_must $TOUCH $TESTDIR/myfile.$$
create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
# Try to create a soft link from the xattr namespace to the default namespace
log_mustnot $RUNAT $TESTDIR/myfile.$$ $LN -s /etc/passwd foo
# Try to create a hard link from the xattr namespace to the default namespace
log_mustnot $RUNAT $TESTDIR/myfile.$$ $LN /etc/passwd foo
log_pass "links between xattr and normal file namespace fail"
+66
View File
@@ -0,0 +1,66 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/xattr/xattr_common.kshlib
#
# DESCRIPTION:
# Verify that mkdir and various mknods fail inside the xattr namespace
#
# STRATEGY:
# 1. Create a file and add an xattr to it (to ensure the namespace exists)
# 2. Verify that mkdir fails inside the xattr namespace
# 3. Verify that various mknods fails inside the xattr namespace
#
#
function cleanup {
log_must $RM $TESTDIR/myfile.$$
}
log_assert "mkdir, mknod fail"
log_onexit cleanup
# create a file, and an xattr on it
log_must $TOUCH $TESTDIR/myfile.$$
create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
# Try to create directory in the xattr namespace
log_mustnot $RUNAT $TESTDIR/myfile.$$ $MKDIR foo
# Try to create a range of different filetypes in the xattr namespace
log_mustnot $RUNAT $TESTDIR/myfile.$$ $MKNOD block b 888 888
log_mustnot $RUNAT $TESTDIR/myfile.$$ $MKNOD char c
log_mustnot $RUNAT $TESTDIR/myfile.$$ $MKNOD fifo p
log_pass "mkdir, mknod fail"
+193
View File
@@ -0,0 +1,193 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2012 by Delphix. All rights reserved.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/xattr/xattr_common.kshlib
#
# DESCRIPTION:
#
# Basic applications work with xattrs: cpio cp find mv pax tar
#
# STRATEGY:
# 1. For each application
# 2. Create an xattr and archive/move/copy/find files with xattr support
# 3. Also check that when appropriate flag is not used, the xattr
# doesn't get copied
#
function cleanup {
log_must $RM $TESTDIR/myfile.$$
}
log_assert "Basic applications work with xattrs: cpio cp find mv pax tar"
log_onexit cleanup
# Create a file, and set an xattr on it. This file is used in several of the
# test scenarios below.
log_must $TOUCH $TESTDIR/myfile.$$
create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
# For the archive applications below (tar, cpio, pax)
# we create two archives, one with xattrs, one without
# and try various cpio options extracting the archives
# with and without xattr support, checking for correct behaviour
log_note "Checking cpio"
log_must $TOUCH $TESTDIR/cpio.$$
create_xattr $TESTDIR/cpio.$$ passwd /etc/passwd
$ECHO $TESTDIR/cpio.$$ | $CPIO -o@ > /tmp/xattr.$$.cpio
$ECHO $TESTDIR/cpio.$$ | $CPIO -o > /tmp/noxattr.$$.cpio
# we should have no xattr here
log_must $CPIO -iu < /tmp/xattr.$$.cpio
log_mustnot eval "$RUNAT $TESTDIR/cpio.$$ $CAT passwd > /dev/null 2>&1"
# we should have an xattr here
log_must $CPIO -iu@ < /tmp/xattr.$$.cpio
log_must eval "$RUNAT $TESTDIR/cpio.$$ $CAT passwd > /dev/null 2>&1"
# we should have no xattr here
log_must $CPIO -iu < /tmp/noxattr.$$.cpio
log_mustnot eval "$RUNAT $TESTDIR/cpio.$$ $CAT passwd > /dev/null 2>&1"
# we should have no xattr here
log_must $CPIO -iu@ < /tmp/noxattr.$$.cpio
log_mustnot eval "$RUNAT $TESTDIR/cpio.$$ $CAT passwd > /dev/null 2>&1"
log_must $RM $TESTDIR/cpio.$$ /tmp/xattr.$$.cpio /tmp/noxattr.$$.cpio
log_note "Checking cp"
# check that with the right flag, the xattr is preserved
log_must $CP -@ $TESTDIR/myfile.$$ $TESTDIR/myfile2.$$
compare_xattrs $TESTDIR/myfile.$$ $TESTDIR/myfile2.$$ passwd
log_must $RM $TESTDIR/myfile2.$$
# without the right flag, there should be no xattr
log_must $CP $TESTDIR/myfile.$$ $TESTDIR/myfile2.$$
log_mustnot eval "$RUNAT $TESTDIR/myfile2.$$ $LS passwd > /dev/null 2>&1"
log_must $RM $TESTDIR/myfile2.$$
log_note "Checking find"
# create a file without xattrs, and check that find -xattr only finds
# our test file that has an xattr.
log_must $MKDIR $TESTDIR/noxattrs
log_must $TOUCH $TESTDIR/noxattrs/no-xattr
$FIND $TESTDIR -xattr | $GREP myfile.$$
[[ $? -ne 0 ]] && \
log_fail "find -xattr didn't find our file that had an xattr."
$FIND $TESTDIR -xattr | $GREP no-xattr
[[ $? -eq 0 ]] && \
log_fail "find -xattr found a file that didn't have an xattr."
log_must $RM -rf $TESTDIR/noxattrs
log_note "Checking mv"
# mv doesn't have any flags to preserve/ommit xattrs - they're
# always moved.
log_must $TOUCH $TESTDIR/mvfile.$$
create_xattr $TESTDIR/mvfile.$$ passwd /etc/passwd
log_must $MV $TESTDIR/mvfile.$$ $TESTDIR/mvfile2.$$
verify_xattr $TESTDIR/mvfile2.$$ passwd /etc/passwd
log_must $RM $TESTDIR/mvfile2.$$
log_note "Checking pax"
log_must $TOUCH $TESTDIR/pax.$$
create_xattr $TESTDIR/pax.$$ passwd /etc/passwd
log_must $PAX -w -f $TESTDIR/noxattr.pax $TESTDIR/pax.$$
log_must $PAX -w@ -f $TESTDIR/xattr.pax $TESTDIR/pax.$$
log_must $RM $TESTDIR/pax.$$
# we should have no xattr here
log_must $PAX -r -f $TESTDIR/noxattr.pax
log_mustnot eval "$RUNAT $TESTDIR/pax.$$ $CAT passwd > /dev/null 2>&1"
log_must $RM $TESTDIR/pax.$$
# we should have no xattr here
log_must $PAX -r@ -f $TESTDIR/noxattr.pax
log_mustnot eval "$RUNAT $TESTDIR/pax.$$ $CAT passwd > /dev/null 2>&1"
log_must $RM $TESTDIR/pax.$$
# we should have an xattr here
log_must $PAX -r@ -f $TESTDIR/xattr.pax
verify_xattr $TESTDIR/pax.$$ passwd /etc/passwd
log_must $RM $TESTDIR/pax.$$
# we should have no xattr here
log_must $PAX -r -f $TESTDIR/xattr.pax $TESTDIR
log_mustnot eval "$RUNAT $TESTDIR/pax.$$ $CAT passwd > /dev/null 2>&1"
log_must $RM $TESTDIR/pax.$$ $TESTDIR/noxattr.pax $TESTDIR/xattr.pax
log_note "Checking tar"
log_must $TOUCH $TESTDIR/tar.$$
create_xattr $TESTDIR/tar.$$ passwd /etc/passwd
log_must cd $TESTDIR
log_must $TAR cf noxattr.tar tar.$$
log_must $TAR c@f xattr.tar tar.$$
log_must $RM $TESTDIR/tar.$$
# we should have no xattr here
log_must $TAR xf xattr.tar
log_mustnot eval "$RUNAT $TESTDIR/tar.$$ $CAT passwd > /dev/null 2>&1"
log_must $RM $TESTDIR/tar.$$
# we should have an xattr here
log_must $TAR x@f xattr.tar
verify_xattr tar.$$ passwd /etc/passwd
log_must $RM $TESTDIR/tar.$$
# we should have no xattr here
log_must $TAR xf $TESTDIR/noxattr.tar
log_mustnot eval "$RUNAT $TESTDIR/tar.$$ $CAT passwd > /dev/null 2>&1"
log_must $RM $TESTDIR/tar.$$
# we should have no xattr here
log_must $TAR x@f $TESTDIR/noxattr.tar
log_mustnot eval "$RUNAT $TESTDIR/tar.$$ $CAT passwd > /dev/null 2>&1"
log_must $RM $TESTDIR/tar.$$ $TESTDIR/noxattr.tar $TESTDIR/xattr.tar
log_assert "Basic applications work with xattrs: cpio cp find mv pax tar"
+103
View File
@@ -0,0 +1,103 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2012 by Delphix. All rights reserved.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/xattr/xattr_common.kshlib
#
# DESCRIPTION:
# xattr file sizes count towards normal disk usage
#
# STRATEGY:
# 1. Create a file, and check pool and filesystem usage
# 2. Create a 200mb xattr in that file
# 3. Check pool and filesystem usage, to ensure it reflects the size
# of the xattr
#
function cleanup {
log_must $RM $TESTDIR/myfile.$$
}
function get_pool_size {
poolname=$1
psize=$($ZPOOL list -H -o allocated $poolname)
if [[ $psize == *[mM] ]]
then
returnvalue=$($ECHO $psize | $SED -e 's/m//g' -e 's/M//g')
returnvalue=$((returnvalue * 1024))
else
returnvalue=$($ECHO $psize | $SED -e 's/k//g' -e 's/K//g')
fi
echo $returnvalue
}
log_assert "xattr file sizes count towards normal disk usage"
log_onexit cleanup
log_must $TOUCH $TESTDIR/myfile.$$
POOL_SIZE=0
NEW_POOL_SIZE=0
if is_global_zone
then
# get pool and filesystem sizes. Since we're starting with an empty
# pool, the usage should be small - a few k.
POOL_SIZE=$(get_pool_size $TESTPOOL)
fi
FS_SIZE=$($ZFS get -p -H -o value used $TESTPOOL/$TESTFS)
log_must $RUNAT $TESTDIR/myfile.$$ $MKFILE 200m xattr
#Make sure the newly created file is counted into zpool usage
log_must $SYNC
# now check to see if our pool disk usage has increased
if is_global_zone
then
NEW_POOL_SIZE=$(get_pool_size $TESTPOOL)
(($NEW_POOL_SIZE <= $POOL_SIZE)) && \
log_fail "The new pool size $NEW_POOL_SIZE was less \
than or equal to the old pool size $POOL_SIZE."
fi
# also make sure our filesystem usage has increased
NEW_FS_SIZE=$($ZFS get -p -H -o value used $TESTPOOL/$TESTFS)
(($NEW_FS_SIZE <= $FS_SIZE)) && \
log_fail "The new filesystem size $NEW_FS_SIZE was less \
than or equal to the old filesystem size $FS_SIZE."
log_pass "xattr file sizes count towards normal disk usage"
+88
View File
@@ -0,0 +1,88 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/xattr/xattr_common.kshlib
#
# DESCRIPTION:
# The noxattr mount option functions as expected
#
# STRATEGY:
# 1. Create a file on a filesystem and add an xattr to it
# 2. Unmount the filesystem, and mount it -o noxattr
# 3. Verify that the xattr cannot be read and new files
# cannot have xattrs set on them.
# 4. Unmount and mount the filesystem normally
# 5. Verify that xattrs can be set and accessed again
#
function cleanup {
log_must $RM $TESTDIR/myfile.$$
}
log_assert "The noxattr mount option functions as expected"
log_onexit cleanup
$ZFS set 2>&1 | $GREP xattr > /dev/null
if [ $? -ne 0 ]
then
log_unsupported "noxattr mount option not supported on this release."
fi
log_must $TOUCH $TESTDIR/myfile.$$
create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
log_must $UMOUNT $TESTDIR
log_must $ZFS mount -o noxattr $TESTPOOL/$TESTFS
# check that we can't perform xattr operations
log_mustnot eval "$RUNAT $TESTDIR/myfile.$$ $CAT passwd > /dev/null 2>&1"
log_mustnot eval "$RUNAT $TESTDIR/myfile.$$ $RM passwd > /dev/null 2>&1"
log_mustnot eval "$RUNAT $TESTDIR/myfile.$$ $CP /etc/passwd . > /dev/null 2>&1"
log_must $TOUCH $TESTDIR/new.$$
log_mustnot eval "$RUNAT $TESTDIR/new.$$ $CP /etc/passwd . > /dev/null 2>&1"
log_mustnot eval "$RUNAT $TESTDIR/new.$$ $RM passwd > /dev/null 2>&1"
# now mount the filesystem again as normal
log_must $UMOUNT $TESTDIR
log_must $ZFS mount $TESTPOOL/$TESTFS
# we should still have an xattr on the first file
verify_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
# there should be no xattr on the file we created while the fs was mounted
# -o noxattr
log_mustnot eval "$RUNAT $TESTDIR/new.$$ $CAT passwd > /dev/null 2>&1"
create_xattr $TESTDIR/new.$$ passwd /etc/passwd
log_pass "The noxattr mount option functions as expected"
@@ -0,0 +1,107 @@
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
# a function that takes a file, then creates and verifies
# an xattr on that file. The xattr_contents is the file
# that should appear in the xattr namespace.
function create_xattr { # filename xattr_name xattr_contents
typeset FILE=$1
typeset XATTR_NAME=$2
typeset XATTR_CONTENTS=$3
# read any empty xattr on that file
log_must $RUNAT $FILE $LS
# create the xattr
log_must $RUNAT $FILE $CP $XATTR_CONTENTS $XATTR_NAME
verify_xattr $FILE $XATTR_NAME $XATTR_CONTENTS
}
# a function that compares the a single xattr between two files
# and checks to see if their contents are identical
function compare_xattrs { # filename1 filename2 xattr_name
typeset FILE1=$1
typeset FILE2=$2
typeset XATTR_NAME=$3
$RUNAT $FILE1 $CAT $XATTR_NAME > /tmp/file1.$$
$RUNAT $FILE2 $CAT $XATTR_NAME > /tmp/file2.$$
log_must $DIFF /tmp/file1.$$ /tmp/file2.$$
log_must $RM /tmp/file1.$$ /tmp/file2.$$
}
function verify_xattr { # filename xattr_name xattr_contents
typeset FILE=$1
typeset XATTR_NAME=$2
typeset XATTR_CONTENTS=$3
# read the xattr, writing it to a temp file
log_must eval "$RUNAT $FILE $CAT $XATTR_NAME > /tmp/$XATTR_NAME.$$ 2>&1"
log_must $DIFF $XATTR_CONTENTS /tmp/$XATTR_NAME.$$
$RM /tmp/$XATTR_NAME.$$
}
function delete_xattr { # filename xattr_name
typeset FILE=$1
typeset XATTR_NAME=$2
# delete the xattr
log_must $RUNAT $FILE $RM $XATTR_NAME
log_mustnot eval "$RUNAT $FILE $LS $XATTR_NAME > /dev/null 2>&1"
}
# not sure about this : really this should be testing write/append
function verify_write_xattr { # filename xattr_name
typeset FILE=$1
typeset XATTR_NAME=$2
log_must eval "$RUNAT $FILE $DD if=/etc/passwd of=$XATTR_NAME"
log_must eval "$RUNAT $FILE $CAT $XATTR_NAME > /tmp/$XATTR_NAME.$$ 2>&1"
log_must $DD if=/etc/passwd of=/tmp/passwd_dd.$$
log_must $DIFF /tmp/passwd_dd.$$ /tmp/$XATTR_NAME.$$
log_must $RM /tmp/passwd_dd.$$ /tmp/$XATTR_NAME.$$
}
# this function is to create the expected output
function create_expected_output { # expected_output_file contents_of_the_output
typeset FILE=$1
shift
if [[ -f $FILE ]]; then
log_must $RM $FILE
fi
for line in $@
do
log_must eval "$ECHO $line >> $FILE"
done
}