public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 1/3] fstests: _require_chattr() must get an input arg
@ 2017-04-06  5:49 Amir Goldstein
  2017-04-06  5:49 ` [PATCH v4 2/3] generic/079: use _require_test_program Amir Goldstein
  2017-04-06  5:49 ` [PATCH v4 3/3] overlay/030: test immutable and append-only upper files Amir Goldstein
  0 siblings, 2 replies; 3+ messages in thread
From: Amir Goldstein @ 2017-04-06  5:49 UTC (permalink / raw)
  To: Eryu Guan; +Cc: Miklos Szeredi, Xiong Zhou, linux-unionfs, fstests

_require_chattr() was never intended to be called without an input
argument (specifiying the required attribute to set).

However, calling it without input arguments did work and error
was silently discarded into full test output.

Fix the function to abort on missing input argument and fix the
only test that called _require_chattr() with no input argument.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 common/rc         | 25 ++++++++++++++-----------
 tests/overlay/027 |  2 +-
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/common/rc b/common/rc
index e1ab2c6..ae3add3 100644
--- a/common/rc
+++ b/common/rc
@@ -3134,18 +3134,21 @@ _require_test_lsattr()
 
 _require_chattr()
 {
-    attribute=$1
-
-    touch $TEST_DIR/syscalltest
-    chattr "+$attribute" $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1
-    status=$?
-    chattr "-$attribute" $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1
-    if [ "$status" -ne 0 ]; then
-      _notrun "file system doesn't support chattr +$attribute"
-    fi
-    cat $TEST_DIR/syscalltest.out >> $seqres.full
+	if [ -z "$1" ]; then
+		echo "Usage: _require_chattr <attr>"
+		exit 1
+	fi
+	local attribute=$1
 
-    rm -f $TEST_DIR/syscalltest.out
+	touch $TEST_DIR/syscalltest
+	chattr "+$attribute" $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1
+	status=$?
+	chattr "-$attribute" $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1
+	if [ "$status" -ne 0 ]; then
+		_notrun "file system doesn't support chattr +$attribute"
+	fi
+	cat $TEST_DIR/syscalltest.out >> $seqres.full
+	rm -f $TEST_DIR/syscalltest.out
 }
 
 _get_total_inode()
diff --git a/tests/overlay/027 b/tests/overlay/027
index 10111b7..90da4e7 100755
--- a/tests/overlay/027
+++ b/tests/overlay/027
@@ -57,7 +57,7 @@ rm -f $seqres.full
 _supported_fs overlay
 _supported_os Linux
 _require_scratch
-_require_chattr
+_require_chattr i
 
 # Remove all files from previous tests
 _scratch_mkfs
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-06  5:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-06  5:49 [PATCH v4 1/3] fstests: _require_chattr() must get an input arg Amir Goldstein
2017-04-06  5:49 ` [PATCH v4 2/3] generic/079: use _require_test_program Amir Goldstein
2017-04-06  5:49 ` [PATCH v4 3/3] overlay/030: test immutable and append-only upper files Amir Goldstein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox