From c10fee45ef615621f1fe293e1e52970e5df83bc7 Mon Sep 17 00:00:00 2001
From: yury <yury>
Date: Wed, 16 Apr 2008 08:38:20 +0000
Subject: [PATCH] b=14901 r=grev - fixes using check_runas_id(). Adds check for
 used runas id in test_72.

---
 lustre/tests/acceptance-small.sh | 6 +++---
 lustre/tests/sanity.sh           | 6 ++++++
 lustre/tests/test-framework.sh   | 6 +++---
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/lustre/tests/acceptance-small.sh b/lustre/tests/acceptance-small.sh
index 9551ba6bde..728be10dd4 100755
--- a/lustre/tests/acceptance-small.sh
+++ b/lustre/tests/acceptance-small.sh
@@ -103,7 +103,7 @@ for NAME in $CONFIGS; do
 		$DEBUG_OFF
 		myUID=$RUNAS_ID
 		myRUNAS=$RUNAS
-		FAIL_ON_ERROR=false check_runas_id $myUID $myRUNAS || { myRUNAS="" && myUID=$UID; }
+		FAIL_ON_ERROR=false check_runas_id_ret $myUID $myRUNAS || { myRUNAS="" && myUID=$UID; }
 		chown $myUID:$myUID $DBENCHDIR
 		duration=""
 		[ "$SLOW" = "no" ] && duration=" -t 120"
@@ -138,7 +138,7 @@ for NAME in $CONFIGS; do
 		$DEBUG_OFF
 		myUID=$RUNAS_ID
 		myRUNAS=$RUNAS
-		FAIL_ON_ERROR=false check_runas_id $myUID $myRUNAS || { myRUNAS="" && myUID=$UID; }
+		FAIL_ON_ERROR=false check_runas_id_ret $myUID $myRUNAS || { myRUNAS="" && myUID=$UID; }
 		chown $myUID:$myUID $BONDIR		
 		$myRUNAS bonnie++ -f -r 0 -s$((SIZE / 1024)) -n 10 -u$myUID:$myUID -d$BONDIR
 		$DEBUG_ON
@@ -167,7 +167,7 @@ for NAME in $CONFIGS; do
 		$DEBUG_OFF
 		myUID=$RUNAS_ID
 		myRUNAS=$RUNAS
-		FAIL_ON_ERROR=false check_runas_id $myUID $myRUNAS || { myRUNAS="" && myUID=$UID; }
+		FAIL_ON_ERROR=false check_runas_id_ret $myUID $myRUNAS || { myRUNAS="" && myUID=$UID; }
 		chown $myUID:$myUID $IOZDIR
 		$myRUNAS iozone $IOZONE_OPTS -f $IOZFILE
 		$DEBUG_ON
diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh
index b181c5d1f7..9d291c27bb 100644
--- a/lustre/tests/sanity.sh
+++ b/lustre/tests/sanity.sh
@@ -2959,6 +2959,12 @@ run_test 71 "Running dbench on lustre (don't segment fault) ===="
 test_72() { # bug 5695 - Test that on 2.6 remove_suid works properly
 	check_kernel_version 43 || return 0
 	[ "$RUNAS_ID" = "$UID" ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
+
+        # Check that testing environment is properly set up. Skip if not
+        FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS || {
+                skip "User $RUNAS_ID does not exist - skipping"
+                return 0
+        }
 	touch $DIR/f72
 	chmod 777 $DIR/f72
 	chmod ug+s $DIR/f72
diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh
index b21d661bed..3b7f839413 100644
--- a/lustre/tests/test-framework.sh
+++ b/lustre/tests/test-framework.sh
@@ -1338,7 +1338,7 @@ is_patchless ()
 }
 
 check_runas_id_ret() {
-    RC=0
+    local myRC=0
     local myRUNAS_ID=$1
     shift
     local myRUNAS=$@
@@ -1348,9 +1348,9 @@ check_runas_id_ret() {
     mkdir $DIR/d0_runas_test
     chmod 0755 $DIR
     chown $myRUNAS_ID:$myRUNAS_ID $DIR/d0_runas_test
-    $myRUNAS touch $DIR/d0_runas_test/f$$ || RC=1
+    $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=1
     rm -rf $DIR/d0_runas_test
-    return $RC
+    return $myRC
 }
 
 check_runas_id() {
-- 
GitLab