Skip to contentSkip to conversation

Fix some bashisms

PATCH Subrata Modak 3 participants 9 messages Oct 26, 2009 – Nov 1, 2009 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 8 lines · Jiri Palecek

Hello,

this is another patch fixing bashisms in LTP tests (the fixes are more or less the same as in the previous patches, except for a few exceptions). Note that the patch is not complete, in the sense that there may remain further bashisms in the source even after applying the patch (like use of arrays, which is visible even from this patch).

Regards
Jiri Palecek

Hmm,. Some of them failed to apply. Can you please resend only the error part(s):

patching file testcases/kernel/fs/fs-bench/modaltr.sh Hunk #1 FAILED at 43.
1 out of 1 hunk FAILED -- saving rejects to file testcases/kernel/fs/fs-bench/modaltr.sh.rej patching file testcases/kernel/fs/fs_di/fs_di patching file testcases/kernel/fs/mongo/test.sh Hunk #1 FAILED at 26.
Hunk #2 FAILED at 52.
Hunk #3 FAILED at 70.
3 out of 3 hunks FAILED -- saving rejects to file testcases/kernel/fs/mongo/test.sh.rej
patching file testcases/network/tcp_cmds/netstat/netstat01 Hunk #1 FAILED at 77.
1 out of 1 hunk FAILED -- saving rejects to file testcases/network/tcp_cmds/netstat/netstat01.rej

Regards--
Subrata

Quoted 612 lines
---
 .../controllers/cgroup_fj/cgroup_fj_utility.sh     |    2 +-
 .../controllers/cgroup_fj/run_cgroup_test_fj.sh    |    8 ++--
 .../controllers/cpuctl_fj/run_cpuctl_test_fj.sh    |   51 ++++++++++----------
 .../memcg/functional/memcg_function_test.sh        |    6 +-
 .../controllers/memcg/stress/memcg_stress_test.sh  |   18 ++++----
 testcases/kernel/fs/acls/acl_test01                |   12 ++--
 testcases/kernel/fs/fs-bench/modaltr.sh            |    2 +-
 testcases/kernel/fs/fs_di/fs_di                    |    4 +-
 testcases/kernel/fs/mongo/test.sh                  |    8 +--
 .../hotplug/cpu_hotplug/functional/hotplug02.sh    |    6 +-
 .../hotplug/cpu_hotplug/functional/hotplug03.sh    |   16 +++---
 .../hotplug/cpu_hotplug/functional/hotplug04.sh    |   10 ++--
 .../cpu_hotplug/functional/hotplug06.sar.sh        |    6 +-
 .../cpu_hotplug/functional/hotplug06.top.sh        |    6 +-
 .../hotplug/cpu_hotplug/functional/hotplug07.sh    |    6 +-
 .../network/can/filter-tests/run_ltp-can_tests.sh  |    2 +-
 testcases/network/tcp_cmds/netstat/netstat01       |    2 +-
 17 files changed, 82 insertions(+), 83 deletions(-)
testcases/kernel/controllers/cgroup_fj/cgroup_fj_utility.sh +1 -1
index 4ba15d6..ed161fa 100755
@@ -547,7 +547,7 @@ reclaim_foundling()
 		if [ -e /proc/$cur_pid/ ];then
 			echo "ERROR: pid $cur_pid reclaimed"
 			do_echo 0 1 "$cur_pid" "/dev/cgroup/tasks"
-			let "foundlings = $foundlings + 1"
+			: $((foundlings += 1))
 		fi
 	done
 
testcases/kernel/controllers/cgroup_fj/run_cgroup_test_fj.sh +4 -4
index 70e4078..eb2d1db 100755
@@ -33,7 +33,7 @@ export TMPFILE=$TESTROOT/tmp_tasks
 export CASENO1=0
 export CASENO2=0
 
-if [ "$UID" -ne 0 ]; then
+if [ "$(id -ru)" -ne 0 ]; then
 	echo "***error***:you must use root to test"
 	exit -1
 fi
@@ -107,17 +107,17 @@ do
 	if [ $? -ne 0 ]; then
 		case $CASETYPE in
 		"function" )
-			let "CASENO1 = $CASENO1 + 1"
+			: $(( CASENO1 += 1 ))
 			export CASENO1=$CASENO1
 			$TESTROOT/cgroup_fj_function.sh $CASECMD
 			;;
 		"function2" )
-			let "CASENO1 = $CASENO1 + 1"
+			: $(( CASENO1 += 1 ))
 			export CASENO1=$CASENO1
 			$TESTROOT/cgroup_fj_function2.sh $CASECMD
 			;;
 		"stress" )
-			let "CASENO2 = $CASENO2 + 1"
+			: $(( CASENO2 += 1 ))
 			export CASENO2=$CASENO2
 			$TESTROOT/cgroup_fj_stress.sh $CASECMD
 			;;
testcases/kernel/controllers/cpuctl_fj/run_cpuctl_test_fj.sh +26 -25
index 6ab0f65..f02f59a 100755
@@ -58,8 +58,8 @@ setup()
 # Write the cleanup function
 cleanup()
 {
-	mount | grep "$CPUCTL" &> /dev/null || {
-		rm -rf "$CPUCTL" &> /dev/null
+	mount | grep "$CPUCTL" > /dev/null 2>&1 || {
+		rm -rf "$CPUCTL" > /dev/null 2>&1
 		return 0
 	}
 
@@ -73,22 +73,19 @@ cleanup()
 	done
 
 	umount $CPUCTL || return 1
-	rmdir $CPUCTL &> /dev/null
+	rmdir $CPUCTL > /dev/null 2>&1
 }
 
 creat_process()
 {
 	cat /dev/zero > /dev/null 2>/dev/null &
-	taskset -p 1 $! &>/dev/null
+	taskset -p 1 $! >/dev/null 2>&1
 	echo $!
 }
 
 get_cpu_usage()
 {
-	top=($(top -b -n 1 -p $1 | tail -2 | head -1))
-	top=${top[8]}
-	top=`echo $top | awk -F "." '{print $1}'`
-	echo "$top"
+	top -b -n 1 -p $1 | tail -2 | head -1 | awk 'print $9' | awk -F "." '{print $1}'
 }
 
 kill_all_pid()
@@ -424,7 +421,7 @@ case12 ()
 	wait $pid
 }
 
-max_shares=$((2**18))
+max_shares=$((1 << 18))
 
 # echo MAX_SHARES into shares
 case13 ()
@@ -589,7 +586,7 @@ case19()
 	echo "pid $pid cpu_usage $cpu_usage"
 
 	kill -9 $pid $pid_other
-	expr 96 \< "$cpu_usage" \& "$cpu_usage" \< 103 &> /dev/null || return 1
+	expr 96 \< "$cpu_usage" \& "$cpu_usage" \< 103 > /dev/null 2>&1 || return 1
 	return 0
 }
 
@@ -605,7 +602,7 @@ case20()
 	echo "pid $pid cpu_usage $cpu_usage"
 
 	kill -9 $pid $pid_other
-	expr 96 \< "$cpu_usage" \& "$cpu_usage" \< 103 &> /dev/null || return 1
+	expr 96 \< "$cpu_usage" \& "$cpu_usage" \< 103 > /dev/null 2>&1 || return 1
 	return 0
 }
 
@@ -615,7 +612,7 @@ case21()
 	pid=$(creat_process)
 	echo $pid > "$CPUCTL/1/tasks"
 
-	while ((1))
+	while true
 	do
 		creat_process > "$CPUCTL/1/2/tasks"
 		sleep 1
@@ -625,18 +622,20 @@ case21()
 	sleep 10
 	ret=0
 
-	for ((top_times=0; top_times<10 && ret==0; top_times++))
+	top_times=0
+	while [ "$top_times" -lt 10 -a "$ret" = 0 ]
 	do
 		cpu_usage=$(get_cpu_usage $pid)
 		echo "pid $pid cpu_usage $cpu_usage"
-		expr 44 \< "$cpu_usage" \& "$cpu_usage" \< 56 &> /dev/null
+		expr 44 \< "$cpu_usage" \& "$cpu_usage" \< 56 > /dev/null 2>&1
 		ret=$?
+		: $(( top_times+=1 ))
 	done
 
-	kill -9 $pid $loop_pid &> /dev/null
-	wait $pid $loop_pid &>/dev/null
+	kill -9 $pid $loop_pid > /dev/null 2>&1
+	wait $pid $loop_pid >/dev/null 2>&1
 	sleep 2
-	kill_all_pid < "$CPUCTL/1/2/tasks" &>/dev/null
+	kill_all_pid < "$CPUCTL/1/2/tasks"  >/dev/null 2>&1
 	sleep 2
 	return $ret
 }
@@ -645,7 +644,7 @@ case22()
 {
 	mkdir "$CPUCTL/1" "$CPUCTL/1/2"
 	pid=$(creat_process)
-	while ((1))
+	while true
 	do
 		echo $pid > "$CPUCTL/1/tasks"
 		echo $pid > "$CPUCTL/1/2/tasks"
@@ -656,26 +655,28 @@ case22()
 	sleep 10
 	ret=0
 
-	for ((top_times=0; top_times<10 && ret==0; top_times++))
+	top_times=0
+	while [ "$top_times" -lt 10 -a "$ret" = 0 ]
 	do
 		cpu_usage=$(get_cpu_usage $pid)
 		echo "pid $pid cpu_usage $cpu_usage"
-		expr 94 \< "$cpu_usage" \& "$cpu_usage" \< 106 &> /dev/null
+		expr 94 \< "$cpu_usage" \& "$cpu_usage" \< 106 > /dev/null 2>&1
 		ret=$?
+		: $(( top_times+=1 ))
 	done
 
-	kill -9 $pid $loop_pid &> /dev/null
-	wait $pid $loop_pid &>/dev/null
+	kill -s KILL $pid $loop_pid > /dev/null 2>&1
+	wait $pid $loop_pid >/dev/null 2>&1
 	return $ret
 }
 
-rm -rf "$CPUCTL_TMP" &>/dev/null || exit 1
+rm -rf "$CPUCTL_TMP" >/dev/null 2>&1 || exit 1
 mkdir -p "$CPUCTL_TMP" || exit 1
 
 # test
 do_test ()
 {
-	for (( i=1; i<=$TST_TOTAL; i++ ))
+	for i in $(seq 1 $TST_TOTAL)
 	do
 		setup || {
 			tst_resm TFAIL "case$i    FAIL"
@@ -698,5 +699,5 @@ do_test ()
 
 do_test
 
-rm -rf "$CPUCTL_TMP" &>/dev/null
+rm -rf "$CPUCTL_TMP" >/dev/null 2>&1
 
testcases/kernel/controllers/memcg/functional/memcg_function_test.sh +3 -3
index 0f11835..003af1c 100755
@@ -536,8 +536,8 @@ do_mount()
 }
 
 # Run all the test cases
-for ((i = 1; i <= $TST_TOTAL; i++))
-{
+for i in $(seq 1 $TST_TOTAL)
+do
 	export TST_COUNT=$(( $TST_COUNT + 1 ))
 	cur_id=$i
 
@@ -556,7 +556,7 @@ for ((i = 1; i <= $TST_TOTAL; i++))
 	rmdir /dev/memcg/$i
 
 	cleanup;
-}
+done
 
 echo $shmmax > /proc/sys/kernel/shmmax
 
testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh +9 -9
index 86b8cb9..6c9cd75 100755
@@ -66,29 +66,29 @@ run_stress()
 {
 	do_mount;
 
-	for ((i = 0; i < $1; i++))
-	{
+	for i in $(seq 0 $(($1-1)))
+	do
 		mkdir /dev/memcg/$i 2> /dev/null
 		./memcg_process_stress $2 $3 &
 		pid[$i]=$!
 
 		echo ${pid[$i]} > /dev/memcg/$i/tasks
-	}
+	done
 
-	for ((i = 0; i < $1; i++))
-	{
+	for i in $(seq 0 $(($1-1)))
+	do
 		/bin/kill -s SIGUSR1 ${pid[$i]} 2> /dev/null
-	}
+	done
 
 	sleep $4
 
-	for ((i = 0; i < $1; i++))
-	{
+	for i in $(seq 0 $(($1-1)))
+	do
 		/bin/kill -s SIGINT ${pid[$i]} 2> /dev/null
 		wait ${pid[$i]}
 
 		rmdir /dev/memcg/$i 2> /dev/null
-	}
+	done
 
 	cleanup;
 }
testcases/kernel/fs/acls/acl_test01 +6 -6
index c892b0e..20cd1ac 100755
@@ -51,7 +51,7 @@ if [ "z$iam" = "z$TEST_USER1" ]
 then
 	echo ""
 else
-if [ $UID != 0 ]
+if [ $(id -ru) != 0 ]
 then
         echo "FAILED: Must have root access to execute this script"
         exit 1
@@ -76,7 +76,7 @@ if [ $? != 0 ]
 then
         echo ""
         echo "FAILED:  [ losetup ] Must have loop device support by kernel"
-        echo -e "\t to execute this script"
+        printf "\t to execute this script\n"
         exit 1
 fi
 
@@ -90,8 +90,8 @@ then
         then
                 echo ""
                 echo "FAILED: [ mount ] Make sure that ACL (Access Control List)"
-                echo -e "\t and Extended Attribute are built into the kernel"
-                echo -e "\t Can not mount ext3 file system with acl and user_xattr options"
+                printf "\t and Extended Attribute are built into the kernel\n"
+                printf "\t Can not mount ext3 file system with acl and user_xattr options\n"
                 exit 1
         fi
 else
@@ -102,8 +102,8 @@ else
         then
                 echo ""
                 echo "FAILED: [ mount ] Make sure that ACL (Access Control List)"
-                echo -e "\t and Extended Attribute are built into the kernel"
-                echo -e "\t Can not mount ext2 file system with acl and user_xattr options"
+                printf "\t and Extended Attribute are built into the kernel\n"
+                printf "\t Can not mount ext2 file system with acl and user_xattr options\n"
                 exit 1
         fi
 fi
testcases/kernel/fs/fs-bench/modaltr.sh +1 -1
index 85d2c30..36e6f0c 100755
@@ -43,7 +43,7 @@ LOG_DIR1=/tmp/log1
 HOME_DIR=/home
 BLOCK_DIR=/dev/mtdblock
 export PATH=$PATH:/sbin
-	if [ $UID -ne 0 ]; 
+	if [ $(id -ru) -ne 0 ]; 
 then 
 	echo "must be root to run this"
 	exit
testcases/kernel/fs/fs_di/fs_di +2 -2
index 54dd8b4..c6447ef 100755
@@ -201,10 +201,10 @@ $trace_logic
 		end_testcase "Could not create testfile of size ${SIZE}Mb"
 	  fi
 	RANDOM_DEPTH=$RANDOM
-	let "RANDOM_DEPTH %= 500"
+	: $(( RANDOM_DEPTH %= 500 ))
 
 	RANDOM_LENGTH=$RANDOM
-	let "RANDOM_LENGTH %= 500"
+	: $(( RANDOM_LENGTH %= 500 ))
 	RANDOM_LENGTH=$(( $RANDOM_LENGTH / 10 ))
 
 	NameCount=0
testcases/kernel/fs/mongo/test.sh +3 -5
index fe75664..eccb079 100755
@@ -26,7 +26,7 @@ TEST_DIR=testdir
 
 
    		#should be root  to execute this script .
-	if [ $UID -ne 0 ]; then
+	if [ $(id -ru) -ne 0 ]; then
 		echo "This script must be run as root"
 		exit
 	fi
@@ -52,8 +52,7 @@ modprobe loop
 	fi
 
 	#run the mongo test on reiserfs file system type 
-function reiserfs
-
+reiserfs()
 {
 cat > fs.sh <<EOF
 echo "performing mongo on reiserfs"
@@ -71,8 +70,7 @@ EOF
 
 
 #To run on jfs file system type 
-function  JFS
-
+JFS()
 {
 cat >> fs.sh <<EOF
 echo "performing mongo on jfs file system"
testcases/kernel/hotplug/cpu_hotplug/functional/hotplug02.sh +3 -3
index 08e9301..7f1c5b1 100755
@@ -15,8 +15,8 @@ fi
 
 # Includes:
 LHCS_PATH=${LHCS_PATH:-".."}
-source $LHCS_PATH/include/testsuite.fns
-source $LHCS_PATH/include/hotplug.fns
+. $LHCS_PATH/include/testsuite.fns
+. $LHCS_PATH/include/hotplug.fns
 
 echo "Name:   $CASE"
 echo "Date:   `date`"
@@ -73,7 +73,7 @@ until [ $loop = 0 ]; do
 
     # Turn the CPU back online just to see what happens.
     online_cpu ${CPU_TO_TEST}
-    let "loop = loop - 1"
+    : $(( loop -= 1 ))
 done
 
 sleep 2
testcases/kernel/hotplug/cpu_hotplug/functional/hotplug03.sh +8 -8
index c550890..97d5205 100755
@@ -15,8 +15,8 @@ fi
 
 # Includes:
 LHCS_PATH=${LHCS_PATH:-".."}
-source $LHCS_PATH/include/testsuite.fns
-source $LHCS_PATH/include/hotplug.fns
+. $LHCS_PATH/include/testsuite.fns
+. $LHCS_PATH/include/hotplug.fns
 
 echo "Name:   $CASE"
 echo "Date:   `date`"
@@ -48,7 +48,7 @@ do_clean()
     # Turn off the CPUs that were off before the test start
     until [ $cpu = 0 ];do
         offline_cpu ${on[${cpu}]}
-        let "cpu = cpu - 1"
+        : $(( cpu -= 1 ))
     done
 }
 
@@ -60,10 +60,10 @@ until [ $loop = 0 ]; do
     for i in $( get_all_cpus ); do 
         online_cpu $1
         if [ $? = 0 ]; then
-            let "cpu = cpu + 1"
+            : $(( cpu += 1 ))
             on[${cpu}]=$i
         fi
-        let "number_of_cpus = number_of_cpus + 1"
+        : $(( number_of_cpus += 1 ))
     done
 
     offline_cpu ${CPU_TO_TEST}
@@ -76,11 +76,11 @@ until [ $loop = 0 ]; do
     # CPUs we have.  This is to help ensure we've got enough processes
     # that at least one will migrate to the new CPU.  Store the PIDs 
     # so we can kill them later.
-    let "number_of_cpus = number_of_cpus * 2"
+    : $(( number_of_cpus *= 2 ))
     until [ $number_of_cpus = 0 ]; do
         $LHCS_PATH/tools/do_spin_loop > /dev/null 2>&1 &
         echo $! >> /var/run/hotplug4_$$.pid
-        let "number_of_cpus = number_of_cpus - 1"
+        : $(( number_of_cpus -= 1 ))
     done
 
     ps aux | head -n 1
@@ -111,7 +111,7 @@ until [ $loop = 0 ]; do
 
     do_clean
 
-    let "loop = loop -1"
+    : $(( loop -=1 ))
 done
 
 exit_clean
testcases/kernel/hotplug/cpu_hotplug/functional/hotplug04.sh +5 -5
index b147286..00a634b 100755
@@ -9,8 +9,8 @@ loop=${HOTPLUG04_LOOPS:-1}
 
 # Includes:
 LHCS_PATH=${LHCS_PATH:-".."}
-source $LHCS_PATH/include/testsuite.fns
-source $LHCS_PATH/include/hotplug.fns
+. $LHCS_PATH/include/testsuite.fns
+. $LHCS_PATH/include/hotplug.fns
 
 echo "Name:   $CASE"
 echo "Date:   `date`"
@@ -26,7 +26,7 @@ until [ $loop = 0 ]; do
         online_cpu $i
         RC=$?
         if [ $RC != 0 ]; then
-            let "cpu = cpu + 1"
+            : $(( cpu += 1 ))
             on[${cpu}]=$i
             echo "${on[${cpu}]}"
         fi
@@ -51,7 +51,7 @@ until [ $loop = 0 ]; do
     # Online the ones that were on initially
     until [ $cpu = 0 ]; do
         online_cpu ${on[${cpu}]}
-        let "cpu = cpu - 1"
+        : $(( cpu -= 1 ))
     done
 
     # Return CPU 0 to its initial state
@@ -61,7 +61,7 @@ until [ $loop = 0 ]; do
         offline_cpu 0
     fi
 
-    let "loop = loop -1"
+    : $(( loop -=1 ))
 done
 
 exit_clean
\ No newline at end of file
testcases/kernel/hotplug/cpu_hotplug/functional/hotplug06.sar.sh +3 -3
index d6f4601..aba658a 100755
@@ -15,8 +15,8 @@ fi
 
 # Includes:
 LHCS_PATH=${LHCS_PATH:-".."}
-source $LHCS_PATH/include/testsuite.fns
-source $LHCS_PATH/include/hotplug.fns
+. $LHCS_PATH/include/testsuite.fns
+. $LHCS_PATH/include/hotplug.fns
 
 echo "Name:   $CASE"
 echo "Date:   `date`"
@@ -81,7 +81,7 @@ until [ $loop = 0 ]; do
 
     # Check that SAR registered the change in CPU online/offline states
     NEW_NUMBER_CPU_OFF=`cat /tmp/log_$$ | grep ${time} | grep -i nan | wc -l`
-    let "NUMBER_CPU_OFF = NUMBER_CPU_OFF - 1"
+    : $(( NUMBER_CPU_OFF -= 1 ))
     if [ $NUMBER_CPU_OFF = $NEW_NUMBER_CPU_OFF ]; then
         echo "$CASE     PASS: CPU was found after turned on."
     else
testcases/kernel/hotplug/cpu_hotplug/functional/hotplug06.top.sh +3 -3
index a9bf17e..f9efe2a 100755
@@ -15,8 +15,8 @@ fi
 
 # Includes:
 LHCS_PATH=${LHCS_PATH:-".."}
-source $LHCS_PATH/include/testsuite.fns
-source $LHCS_PATH/include/hotplug.fns
+. $LHCS_PATH/include/testsuite.fns
+. $LHCS_PATH/include/hotplug.fns
 
 echo "Name:   $CASE"
 echo "Date:   `date`"
@@ -76,7 +76,7 @@ until [ $loop = 0 ]; do
         exit_clean -1
     fi
 
-    let "loop = loop - 1"
+    : $(( loop -= 1 ))
 
 done
 
testcases/kernel/hotplug/cpu_hotplug/functional/hotplug07.sh +3 -3
index d57c561..8f5ca44 100755
@@ -11,8 +11,8 @@ loop_one=${HOTPLUG07_LOOPS:-1}
 
 # Includes:
 LHCS_PATH=${LHCS_PATH:-".."}
-source $LHCS_PATH/include/testsuite.fns
-source $LHCS_PATH/include/hotplug.fns
+. $LHCS_PATH/include/testsuite.fns
+. $LHCS_PATH/include/hotplug.fns
 
 echo "Name:   HotPlug Test - Test Case 7"
 echo "Date:   `date`"
@@ -89,7 +89,7 @@ do
   RC=$?
   echo "Onlining cpu${CPU_TO_TEST}: Return Code = ${RC}"
 
-  let "loop_one = loop_one - 1"
+  : $(( loop_one -= 1 ))
 
 done
 
testcases/network/can/filter-tests/run_ltp-can_tests.sh +1 -1
index aefcbe1..6d7aafc 100644
@@ -19,7 +19,7 @@
 ##                                                                            ##
 ################################################################################
 
-if [ $UID -ne 0 ]; then
+if [ $(id -ru) -ne 0 ]; then
      echo You need to be root to execute these tests
      exit 1
 fi
testcases/network/tcp_cmds/netstat/netstat01 +0 -0
index 1cf0d9d..f0b2462 100755

testcases/network/tcp_cmds/netstat/netstat01 do_test() { · line 83

Quoted 8 lines
testcases/network/tcp_cmds/netstat/netstat01 +1 -1
@@ -77,7 +77,7 @@ do_test() {
    do
       for COMMAND in "netstat -s" "netstat -rn" "netstat -i" "netstat -gn" "netstat -apn"
       do
-         $COMMAND 2>&1 1>/dev/null
+         $COMMAND 1>/dev/null 2>&1
          [ $? -eq 0 ] || end_testcase "$COMMAND failed" 
       done
 

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#2 lore raw
Quoted 5 lines · Subrata Modak
Quoted 4 lines · Jiri Palecek

Hello,

this is another patch fixing bashisms in LTP tests (the fixes are more or less the same as in the previous patches, except for a few exceptions). Note that the patch is not complete, in the sense that there may remain further bashisms in the source even after applying the patch (like use of arrays, which is visible even from this patch).

Quoted 7 lines
Quoted 4 lines

Regards
    Jiri Palecek

Hmm,. Some of them failed to apply. Can you please resend only the error part(s):

Sorry for not catching this sooner. netstat01 (and a lot of other items under tcp_cmds) were rewritten to 1) remove bashisms, 2) make the testing procedures more uniform, and 3) (the most important) remove duplicate code in ipv6 and tcp_cmds.
Thanks,
-Garrett

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#3 lore raw
In reply to Subrata Modak

Hello,

Quoted 5 lines · Subrata Modak
Quoted 3 lines · Jiri Palecek

Hello,

this is another patch fixing bashisms in LTP tests (the fixes are more or

less the same as in the previous

Quoted 1 line

patches, except for a few exceptions). Note that the patch is not complete,

in the sense that there may

Quoted 1 line

remain further bashisms in the source even after applying the patch (like use

of arrays, which is visible

Quoted 10 lines

even from this patch).

Quoted 5 lines

Regards
Jiri Palecek

Hmm,. Some of them failed to apply. Can you please resend only the error part(s):

according to my git repository. these are the missing parts:

---
 testcases/kernel/fs/fs-bench/modaltr.sh      |    2 +-
 testcases/kernel/fs/mongo/test.sh            |    8 +++-----
 testcases/network/tcp_cmds/netstat/netstat01 |    2 +-
 3 files changed, 5 insertions(+), 7 deletions(-)
testcases/kernel/fs/fs- renamed from testcases/kernel/fs/fs-bench/modaltr.sh +0 -0

bench/modaltr.sh
index 85d2c30..36e6f0c 100755

testcases/kernel/fs/fs-bench/modaltr.sh +1 -1
@@ -43,7 +43,7 @@ LOG_DIR1=/tmp/log1
 HOME_DIR=/home
 BLOCK_DIR=/dev/mtdblock
 export PATH=$PATH:/sbin
-	if [ $UID -ne 0 ]; 
+	if [ $(id -ru) -ne 0 ]; 
 then 
 	echo "must be root to run this"
 	exit
testcases/kernel/fs/mongo/ renamed from testcases/kernel/fs/mongo/test.sh +0 -0

test.sh
index fe75664..eccb079 100755

testcases/kernel/fs/mongo/test.sh +3 -5
@@ -26,7 +26,7 @@ TEST_DIR=testdir
 
 
    		#should be root  to execute this script .
-	if [ $UID -ne 0 ]; then
+	if [ $(id -ru) -ne 0 ]; then
 		echo "This script must be run as root"
 		exit
 	fi
@@ -52,8 +52,7 @@ modprobe loop
 	fi
 
 	#run the mongo test on reiserfs file system type 
-function reiserfs
-
+reiserfs()
 {
 cat > fs.sh <<EOF
 echo "performing mongo on reiserfs"
@@ -71,8 +70,7 @@ EOF
 	
 
 #To run on jfs file system type 
-function  JFS
-
+JFS()
 {
 cat >> fs.sh <<EOF
 echo "performing mongo on jfs file system"
testcases/network/ renamed from testcases/network/tcp_cmds/netstat/netstat01 +0 -0

tcp_cmds/netstat/netstat01
index 6a197de..365c142 100755

testcases/network/tcp_cmds/netstat/netstat01 +1 -1
@@ -58,7 +58,7 @@ do_test() {
     while [ $TST_COUNT -le $NUMLOOPS ]; do
 
         for flag in "-s" "-rn" "-i" "-gn" "-apn"; do
-            if ! netstat $flag 2>&1 1>/dev/null; then
+            if ! netstat $flag 1>/dev/null 2>&1; then
                 end_testcase "$COMMAND failed"
             fi
         done
Signature · 15 lines
1.6.4.3




------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#4 lore raw
Quoted 21 lines · JiříPaleček

Hello,

Quoted 5 lines · Subrata Modak
Quoted 3 lines · Jiri Palecek

Hello,

this is another patch fixing bashisms in LTP tests (the fixes are more or

less the same as in the previous

Quoted 1 line

patches, except for a few exceptions). Note that the patch is not complete,

in the sense that there may

Quoted 1 line

remain further bashisms in the source even after applying the patch (like use

of arrays, which is visible

Quoted 7 lines

even from this patch).

Quoted 5 lines

Regards
Jiri Palecek

Quoted 7 lines
Quoted 3 lines

Hmm,. Some of them failed to apply. Can you please resend only the error part(s):

according to my git repository. these are the missing parts:

Then something wrong with my CVS:

patching file testcases/kernel/fs/fs-bench/modaltr.sh Hunk #1 FAILED at 43.
1 out of 1 hunk FAILED -- saving rejects to file testcases/kernel/fs/fs-bench/modaltr.sh.rej patching file testcases/kernel/fs/mongo/test.sh Hunk #1 FAILED at 26.
Hunk #2 FAILED at 52.
Hunk #3 FAILED at 70.
3 out of 3 hunks FAILED -- saving rejects to file testcases/kernel/fs/mongo/test.sh.rej
patching file testcases/network/tcp_cmds/netstat/netstat01

Can you please verify ?

Regards--
Subrata

Quoted 60 lines
---
 testcases/kernel/fs/fs-bench/modaltr.sh      |    2 +-
 testcases/kernel/fs/mongo/test.sh            |    8 +++-----
 testcases/network/tcp_cmds/netstat/netstat01 |    2 +-
 3 files changed, 5 insertions(+), 7 deletions(-)
testcases/kernel/fs/fs- renamed from testcases/kernel/fs/fs-bench/modaltr.sh +0 -0

bench/modaltr.sh
index 85d2c30..36e6f0c 100755

testcases/kernel/fs/fs-bench/modaltr.sh +1 -1
@@ -43,7 +43,7 @@ LOG_DIR1=/tmp/log1
 HOME_DIR=/home
 BLOCK_DIR=/dev/mtdblock
 export PATH=$PATH:/sbin
-	if [ $UID -ne 0 ]; 
+	if [ $(id -ru) -ne 0 ]; 
 then 
 	echo "must be root to run this"
 	exit
testcases/kernel/fs/mongo/ renamed from testcases/kernel/fs/mongo/test.sh +0 -0

test.sh
index fe75664..eccb079 100755

testcases/kernel/fs/mongo/test.sh +3 -5
@@ -26,7 +26,7 @@ TEST_DIR=testdir
 
 
    		#should be root  to execute this script .
-	if [ $UID -ne 0 ]; then
+	if [ $(id -ru) -ne 0 ]; then
 		echo "This script must be run as root"
 		exit
 	fi
@@ -52,8 +52,7 @@ modprobe loop
 	fi
 
 	#run the mongo test on reiserfs file system type 
-function reiserfs
-
+reiserfs()
 {
 cat > fs.sh <<EOF
 echo "performing mongo on reiserfs"
@@ -71,8 +70,7 @@ EOF
 
 
 #To run on jfs file system type 
-function  JFS
-
+JFS()
 {
 cat >> fs.sh <<EOF
 echo "performing mongo on jfs file system"
testcases/network/ renamed from testcases/network/tcp_cmds/netstat/netstat01 +0 -0

tcp_cmds/netstat/netstat01
index 6a197de..365c142 100755

testcases/network/tcp_cmds/netstat/netstat01 do_test() { · line 64

Quoted 8 lines
testcases/network/tcp_cmds/netstat/netstat01 +1 -1
@@ -58,7 +58,7 @@ do_test() {
     while [ $TST_COUNT -le $NUMLOOPS ]; do
 
         for flag in "-s" "-rn" "-i" "-gn" "-apn"; do
-            if ! netstat $flag 2>&1 1>/dev/null; then
+            if ! netstat $flag 1>/dev/null 2>&1; then
                 end_testcase "$COMMAND failed"
             fi
         done

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#5 lore raw
Quoted 48 lines · Subrata Modak
Quoted 24 lines · JiříPaleček

Hello,

Quoted 5 lines · Subrata Modak
Quoted 3 lines · Jiri Palecek

Hello,

this is another patch fixing bashisms in LTP tests (the fixes are

more or
less the same as in the previous

Quoted 1 line

patches, except for a few exceptions). Note that the patch is not

complete,
in the sense that there may

Quoted 1 line

remain further bashisms in the source even after applying the patch

(like use
of arrays, which is visible

Quoted 7 lines

even from this patch).

Quoted 5 lines

Regards
Jiri Palecek

Quoted 8 lines
Quoted 1 line

Hmm,. Some of them failed to apply. Can you please resend only the

error

Quoted 2 lines

part(s):

according to my git repository. these are the missing parts:

Then something wrong with my CVS:

patching file testcases/kernel/fs/fs-bench/modaltr.sh Hunk #1 FAILED at 43.
1 out of 1 hunk FAILED -- saving rejects to file testcases/kernel/fs/fs-bench/modaltr.sh.rej patching file testcases/kernel/fs/mongo/test.sh Hunk #1 FAILED at 26.
Hunk #2 FAILED at 52.
Hunk #3 FAILED at 70.
3 out of 3 hunks FAILED -- saving rejects to file testcases/kernel/fs/mongo/test.sh.rej
patching file testcases/network/tcp_cmds/netstat/netstat01

Quoted 1 line

Can you please verify ?

It works for me in CVS, so I guess it was just a linewrap, whitespace or something issue. See attachment for the original (uncrippled) patch.

Regards
Jiri Palecek

Quoted 69 lines
Quoted 68 lines
---
 testcases/kernel/fs/fs-bench/modaltr.sh      |    2 +-
 testcases/kernel/fs/mongo/test.sh            |    8 +++-----
 testcases/network/tcp_cmds/netstat/netstat01 |    2 +-
 3 files changed, 5 insertions(+), 7 deletions(-)
testcases/kernel/fs/fs- renamed from testcases/kernel/fs/fs-bench/modaltr.sh +0 -0

bench/modaltr.sh
index 85d2c30..36e6f0c 100755

testcases/kernel/fs/fs-bench/modaltr.sh +1 -1
@@ -43,7 +43,7 @@ LOG_DIR1=/tmp/log1
 HOME_DIR=/home
 BLOCK_DIR=/dev/mtdblock
 export PATH=$PATH:/sbin
-	if [ $UID -ne 0 ];
+	if [ $(id -ru) -ne 0 ];
 then
 	echo "must be root to run this"
 	exit
testcases/kernel/fs/mongo/ renamed from testcases/kernel/fs/mongo/test.sh +0 -0

test.sh
index fe75664..eccb079 100755

testcases/kernel/fs/mongo/test.sh +3 -5
@@ -26,7 +26,7 @@ TEST_DIR=testdir
 
 
    		#should be root  to execute this script .
-	if [ $UID -ne 0 ]; then
+	if [ $(id -ru) -ne 0 ]; then
 		echo "This script must be run as root"
 		exit
 	fi
@@ -52,8 +52,7 @@ modprobe loop
 	fi
 
 	#run the mongo test on reiserfs file system type
-function reiserfs
-
+reiserfs()
 {
 cat > fs.sh <<EOF
 echo "performing mongo on reiserfs"
@@ -71,8 +70,7 @@ EOF
 
 
 #To run on jfs file system type
-function  JFS
-
+JFS()
 {
 cat >> fs.sh <<EOF
 echo "performing mongo on jfs file system"
testcases/network/ renamed from testcases/network/tcp_cmds/netstat/netstat01 +0 -0

tcp_cmds/netstat/netstat01
index 6a197de..365c142 100755

testcases/network/tcp_cmds/netstat/netstat01 +1 -1
@@ -58,7 +58,7 @@ do_test() {
     while [ $TST_COUNT -le $NUMLOOPS ]; do
 
         for flag in "-s" "-rn" "-i" "-gn" "-apn"; do
-            if ! netstat $flag 2>&1 1>/dev/null; then
+            if ! netstat $flag 1>/dev/null 2>&1; then
                 end_testcase "$COMMAND failed"
             fi
         done
Signature · 1 line
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

From 8ba003dbc80f0280f1d68bf512329ddbe1a07dd0 Mon Sep 17 00:00:00 2001
From: Jiri Palecek <[email protected]>
Date: Wed, 21 Oct 2009 02:19:58 +0200
Subject: [PATCH] Fix some bashisms

---
 testcases/kernel/fs/fs-bench/modaltr.sh      |    2 +-
 testcases/kernel/fs/mongo/test.sh            |    8 +++-----
 testcases/network/tcp_cmds/netstat/netstat01 |    2 +-
 3 files changed, 5 insertions(+), 7 deletions(-)
testcases/kernel/fs/fs-bench/modaltr.sh +1 -1
index 85d2c30..36e6f0c 100755
@@ -43,7 +43,7 @@ LOG_DIR1=/tmp/log1
 HOME_DIR=/home
 BLOCK_DIR=/dev/mtdblock
 export PATH=$PATH:/sbin
-	if [ $UID -ne 0 ]; 
+	if [ $(id -ru) -ne 0 ]; 
 then 
 	echo "must be root to run this"
 	exit
testcases/kernel/fs/mongo/test.sh +3 -5
index fe75664..eccb079 100755
@@ -26,7 +26,7 @@ TEST_DIR=testdir
 
 
    		#should be root  to execute this script .
-	if [ $UID -ne 0 ]; then
+	if [ $(id -ru) -ne 0 ]; then
 		echo "This script must be run as root"
 		exit
 	fi
@@ -52,8 +52,7 @@ modprobe loop
 	fi
 
 	#run the mongo test on reiserfs file system type 
-function reiserfs
-
+reiserfs()
 {
 cat > fs.sh <<EOF
 echo "performing mongo on reiserfs"
@@ -71,8 +70,7 @@ EOF
 	
 
 #To run on jfs file system type 
-function  JFS
-
+JFS()
 {
 cat >> fs.sh <<EOF
 echo "performing mongo on jfs file system"
testcases/network/tcp_cmds/netstat/netstat01 +1 -1
index 6a197de..365c142 100755
@@ -58,7 +58,7 @@ do_test() {
     while [ $TST_COUNT -le $NUMLOOPS ]; do
 
         for flag in "-s" "-rn" "-i" "-gn" "-apn"; do
-            if ! netstat $flag 2>&1 1>/dev/null; then
+            if ! netstat $flag 1>/dev/null 2>&1; then
                 end_testcase "$COMMAND failed"
             fi
         done
Signature · 1 line
1.6.4.3

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#6 lore raw
Quoted 51 lines · Jiří Paleček
Quoted 48 lines · Subrata Modak
Quoted 24 lines · JiříPaleček

Hello,

Quoted 5 lines · Subrata Modak
Quoted 3 lines · Jiri Palecek

Hello,

this is another patch fixing bashisms in LTP tests (the fixes are

more or
less the same as in the previous

Quoted 1 line

patches, except for a few exceptions). Note that the patch is not

complete,
in the sense that there may

Quoted 1 line

remain further bashisms in the source even after applying the patch

(like use
of arrays, which is visible

Quoted 7 lines

even from this patch).

Quoted 5 lines

Regards
Jiri Palecek

Quoted 8 lines
Quoted 1 line

Hmm,. Some of them failed to apply. Can you please resend only the

error

Quoted 2 lines

part(s):

according to my git repository. these are the missing parts:

Then something wrong with my CVS:

patching file testcases/kernel/fs/fs-bench/modaltr.sh Hunk #1 FAILED at 43.
1 out of 1 hunk FAILED -- saving rejects to file testcases/kernel/fs/fs-bench/modaltr.sh.rej patching file testcases/kernel/fs/mongo/test.sh Hunk #1 FAILED at 26.
Hunk #2 FAILED at 52.
Hunk #3 FAILED at 70.
3 out of 3 hunks FAILED -- saving rejects to file testcases/kernel/fs/mongo/test.sh.rej
patching file testcases/network/tcp_cmds/netstat/netstat01

Quoted 4 lines
Quoted 1 line

Can you please verify ?

It works for me in CVS, so I guess it was just a linewrap, whitespace or something issue. See attachment for the original (uncrippled) patch.

Yes, it works fine now :-)
patching file testcases/kernel/fs/fs-bench/modaltr.sh patching file testcases/kernel/fs/mongo/test.sh patching file testcases/network/tcp_cmds/netstat/netstat01

Regards--
Subrata

Quoted 69 lines

Regards
Jiri Palecek

Quoted 65 lines
Quoted 65 lines
---
 testcases/kernel/fs/fs-bench/modaltr.sh      |    2 +-
 testcases/kernel/fs/mongo/test.sh            |    8 +++-----
 testcases/network/tcp_cmds/netstat/netstat01 |    2 +-
 3 files changed, 5 insertions(+), 7 deletions(-)
testcases/kernel/fs/fs- renamed from testcases/kernel/fs/fs-bench/modaltr.sh +0 -0

bench/modaltr.sh
index 85d2c30..36e6f0c 100755

testcases/kernel/fs/fs-bench/modaltr.sh +1 -1
@@ -43,7 +43,7 @@ LOG_DIR1=/tmp/log1
 HOME_DIR=/home
 BLOCK_DIR=/dev/mtdblock
 export PATH=$PATH:/sbin
-	if [ $UID -ne 0 ];
+	if [ $(id -ru) -ne 0 ];
 then
 	echo "must be root to run this"
 	exit
testcases/kernel/fs/mongo/ renamed from testcases/kernel/fs/mongo/test.sh +0 -0

test.sh
index fe75664..eccb079 100755

testcases/kernel/fs/mongo/test.sh +3 -5
@@ -26,7 +26,7 @@ TEST_DIR=testdir
 
 
    		#should be root  to execute this script .
-	if [ $UID -ne 0 ]; then
+	if [ $(id -ru) -ne 0 ]; then
 		echo "This script must be run as root"
 		exit
 	fi
@@ -52,8 +52,7 @@ modprobe loop
 	fi
 
 	#run the mongo test on reiserfs file system type
-function reiserfs
-
+reiserfs()
 {
 cat > fs.sh <<EOF
 echo "performing mongo on reiserfs"
@@ -71,8 +70,7 @@ EOF
 
 
 #To run on jfs file system type
-function  JFS
-
+JFS()
 {
 cat >> fs.sh <<EOF
 echo "performing mongo on jfs file system"
testcases/network/ renamed from testcases/network/tcp_cmds/netstat/netstat01 +0 -0

tcp_cmds/netstat/netstat01
index 6a197de..365c142 100755

testcases/network/tcp_cmds/netstat/netstat01 +0 -0
@@ -58,7 +58,7 @@ do_test() {
     while [ $TST_COUNT -le $NUMLOOPS ]; do
 
Quoted 12 lines
Quoted 7 lines
Quoted 6 lines
testcases/network/tcp_cmds/netstat/netstat01 +1 -1
         for flag in "-s" "-rn" "-i" "-gn" "-apn"; do
-            if ! netstat $flag 2>&1 1>/dev/null; then
+            if ! netstat $flag 1>/dev/null 2>&1; then
                 end_testcase "$COMMAND failed"
             fi
         done
Signature · 1 line
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#7 lore raw
Quoted 54 lines · Subrata Modak
Quoted 53 lines · Jiří Paleček
Quoted 49 lines · Subrata Modak
Quoted 24 lines · JiříPaleček

Hello,

Quoted 5 lines · Subrata Modak
Quoted 3 lines · Jiri Palecek

Hello,

this is another patch fixing bashisms in LTP tests (the fixes are

more or
less the same as in the previous

Quoted 1 line

patches, except for a few exceptions). Note that the patch is not

complete,
in the sense that there may

Quoted 1 line

remain further bashisms in the source even after applying the patch

(like use
of arrays, which is visible

Quoted 7 lines

even from this patch).

Quoted 5 lines

Regards
    Jiri Palecek

Quoted 8 lines
Quoted 1 line

Hmm,. Some of them failed to apply. Can you please resend only the

error

Quoted 2 lines

part(s):

according to my git repository. these are the missing parts:

Then something wrong with my CVS:

patching file testcases/kernel/fs/fs-bench/modaltr.sh Hunk #1 FAILED at 43.
1 out of 1 hunk FAILED -- saving rejects to file testcases/kernel/fs/fs-bench/modaltr.sh.rej patching file testcases/kernel/fs/mongo/test.sh Hunk #1 FAILED at 26.
Hunk #2 FAILED at 52.
Hunk #3 FAILED at 70.
3 out of 3 hunks FAILED -- saving rejects to file testcases/kernel/fs/mongo/test.sh.rej
patching file testcases/network/tcp_cmds/netstat/netstat01

Can you please verify ?

Quoted 7 lines
Quoted 2 lines

It works for me in CVS, so I guess it was just a linewrap, whitespace or something issue. See attachment for the original (uncrippled) patch.

Yes, it works fine now :-)
patching file testcases/kernel/fs/fs-bench/modaltr.sh patching file testcases/kernel/fs/mongo/test.sh patching file testcases/network/tcp_cmds/netstat/netstat01

Sorry for replying late again, but just for future reference, there's a function called is_root in $(abs_top_srcdir)/testcases/lib/cmdlib.sh [in the install tree -- it gets put in $(abs_top_builddir)/testcases/bin] that can be leveraged s.t. you don't have to do $(id -ru) -eq 0 everywhere. There are some other handy constructs and functions too that can be used for expediting setup, execution, and teardown. The only thing that might be a detractor for some legacy scripts is that I explicitly did set -u to avoid QA issues with unset variables, so all variables must be defined before including the cmd library.

Using that script though would be helpful as it cuts down on a lot of duplicate code and aims to be completely POSIX compliant. Some other pluses:

1. incr_tst_count - increments $TST_COUNT appropriately.
2. TCID is automatically set if not already provided.
3. exists is a function which ensures that commands exist on a given system before executing a test.
4. Common SHELL_DEBUG logic.

Just trying to make life a little easier for test writers and maintainers if possible :]...

Cheers,
-Garrett

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#8 lore raw
Quoted 82 lines · Garrett Cooper
Quoted 56 lines · Subrata Modak
Quoted 55 lines · Jiří Paleček
Quoted 10 lines · Subrata Modak
Quoted 9 lines · JiříPaleček

Hello,

Quoted 5 lines · Subrata Modak
Quoted 3 lines · Jiri Palecek

Hello,

this is another patch fixing bashisms in LTP tests (the fixes

are

Quoted 6 lines
Quoted 6 lines

more or
less the same as in the previous

Quoted 1 line

patches, except for a few exceptions). Note that the patch is not

complete,
in the sense that there may

Quoted 1 line

remain further bashisms in the source even after applying the

patch

Quoted 33 lines
Quoted 9 lines

(like use
of arrays, which is visible

Quoted 7 lines

even from this patch).

Quoted 5 lines

Regards
    Jiri Palecek

Quoted 8 lines
Quoted 1 line

Hmm,. Some of them failed to apply. Can you please resend only the

error

Quoted 2 lines

part(s):

according to my git repository. these are the missing parts:

Then something wrong with my CVS:

patching file testcases/kernel/fs/fs-bench/modaltr.sh Hunk #1 FAILED at 43.
1 out of 1 hunk FAILED -- saving rejects to file testcases/kernel/fs/fs-bench/modaltr.sh.rej patching file testcases/kernel/fs/mongo/test.sh Hunk #1 FAILED at 26.
Hunk #2 FAILED at 52.
Hunk #3 FAILED at 70.
3 out of 3 hunks FAILED -- saving rejects to file testcases/kernel/fs/mongo/test.sh.rej
patching file testcases/network/tcp_cmds/netstat/netstat01

Can you please verify ?

Quoted 8 lines
Quoted 3 lines

It works for me in CVS, so I guess it was just a linewrap, whitespace or
something issue. See attachment for the original (uncrippled) patch.

Yes, it works fine now :-)
patching file testcases/kernel/fs/fs-bench/modaltr.sh patching file testcases/kernel/fs/mongo/test.sh patching file testcases/network/tcp_cmds/netstat/netstat01

Sorry for replying late again, but just for future reference, there's a function called is_root in $(abs_top_srcdir)/testcases/lib/cmdlib.sh [in the install tree -- it gets put in $(abs_top_builddir)/testcases/bin] that can be leveraged s.t. you don't have to do $(id -ru) -eq 0 everywhere. There are some other handy constructs and functions too that can be used for expediting setup, execution, and teardown. The only thing that might be a detractor for some legacy scripts is that I explicitly did set -u to avoid QA issues with unset variables, so all variables must be defined before including the cmd library.

Using that script though would be helpful as it cuts down on a lot of duplicate code and aims to be completely POSIX compliant. Some other pluses:

Quoted 8 lines

1. incr_tst_count - increments $TST_COUNT appropriately.
2. TCID is automatically set if not already provided.
3. exists is a function which ensures that commands exist on a given system before executing a test.
4. Common SHELL_DEBUG logic.

Just trying to make life a little easier for test writers and maintainers if possible :]...

Thanks for noting it. I think, however, that it would be much morer valuable to create exact duplicate of the C test API (or a subset of it) for shell scripts, as this would permit to remove much of the hacky stuff about maintaining TST_COUNT and return value from the shell scripts.

Looking at the file you mentioned, I have just a few remarks:

tst_cleanup()
{
# Disable the trap EXIT handler.
trap '' EXIT
# To ensure set -u passes...
TCtmp=${TCtmp:=}

Why? Shouldn't it catch invalid use (eg. without doing tst_setup first)?

# Nuke the testcase temporary directory if it exists.
[ -d "$TCtmp" ] && rm -rf "$TCtmp" (1)
}

tst_setup() {

     TST_COUNT=1
     TST_TOTAL=${TST_TOTAL:=1}                                    (2)
     export TCID TST_COUNT TST_TOTAL

     for varname in TST_TOTAL; do
         if eval "test -z \"\$${varname}\""; then
             end_testcase "You must set ${varname} before calling setup()."
         fi
     done

What is the sense of doing "test -z "$TST_TOTAL"" in such an elaborate way, especially when you reset TST_TOTAL in (2) so test -z $TST_TOTAL can never be true here?

...

     TCtmp=${TCtmp:=$TEMPDIR/$TC$$}
     # User wants a temporary sandbox to play with.
     if [ -n "$TCtmp" -a "$TCtmp" != "$TEMPDIR/$$" ] ; then
         test -d "$TCtmp" || mkdir -p "$TCtmp"

What is so special about "$TEMPDIR/$$" that you refuse to create a directory with this name, but still delete it in (1)?

...
}

incr_tst_count()

{
     : $(( TST_COUNT + 1 ))
}

Was this really meant this way (ie. as a code with no effect), or should it be "+="?

Regards
Jiri Palecek

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#9 lore raw

Hi Jiri!

2009/10/31 Jiří Paleček <[email protected]>:

Quoted 90 lines
Quoted 87 lines · Garrett Cooper
Quoted 56 lines · Subrata Modak
Quoted 54 lines · Jiří Paleček
Quoted 49 lines · Subrata Modak
Quoted 24 lines · JiříPaleček

Hello,

Quoted 5 lines · Subrata Modak
Quoted 3 lines · Jiri Palecek

Hello,

this is another patch fixing bashisms in LTP tests (the fixes are

more or
less the same as in the previous

Quoted 1 line

patches, except for a few exceptions). Note that the patch is not

complete,
in the sense that there may

Quoted 1 line

remain further bashisms in the source even after applying the patch

(like use
of arrays, which is visible

Quoted 7 lines

even from this patch).

Quoted 5 lines

Regards
    Jiri Palecek

Quoted 8 lines
Quoted 1 line

Hmm,. Some of them failed to apply. Can you please resend only the

error

Quoted 2 lines

part(s):

according to my git repository. these are the missing parts:

Then something wrong with my CVS:

patching file testcases/kernel/fs/fs-bench/modaltr.sh Hunk #1 FAILED at 43.
1 out of 1 hunk FAILED -- saving rejects to file testcases/kernel/fs/fs-bench/modaltr.sh.rej patching file testcases/kernel/fs/mongo/test.sh Hunk #1 FAILED at 26.
Hunk #2 FAILED at 52.
Hunk #3 FAILED at 70.
3 out of 3 hunks FAILED -- saving rejects to file testcases/kernel/fs/mongo/test.sh.rej
patching file testcases/network/tcp_cmds/netstat/netstat01

Can you please verify ?

Quoted 7 lines
Quoted 2 lines

It works for me in CVS, so I guess it was just a linewrap, whitespace or something issue. See attachment for the original (uncrippled) patch.

Yes, it works fine now :-)
patching file testcases/kernel/fs/fs-bench/modaltr.sh patching file testcases/kernel/fs/mongo/test.sh patching file testcases/network/tcp_cmds/netstat/netstat01

Sorry for replying late again, but just for future reference, there's a function called is_root in $(abs_top_srcdir)/testcases/lib/cmdlib.sh [in the install tree -- it gets put in $(abs_top_builddir)/testcases/bin] that can be leveraged s.t. you don't have to do $(id -ru) -eq 0 everywhere. There are some other handy constructs and functions too that can be used for expediting setup, execution, and teardown. The only thing that might be a detractor for some legacy scripts is that I explicitly did set -u to avoid QA issues with unset variables, so all variables must be defined before including the cmd library.

Using that script though would be helpful as it cuts down on a lot of duplicate code and aims to be completely POSIX compliant. Some other pluses:

1. incr_tst_count - increments $TST_COUNT appropriately.
2. TCID is automatically set if not already provided.
3. exists is a function which ensures that commands exist on a given system before executing a test.
4. Common SHELL_DEBUG logic.

Quoted 7 lines
Quoted 2 lines

Just trying to make life a little easier for test writers and maintainers if possible :]...

Thanks for noting it. I think, however, that it would be much more valuable to create exact duplicate of the C test API (or a subset of it) for shell scripts, as this would permit to remove much of the hacky stuff about maintaining TST_COUNT and return value from the shell scripts.

Ok. I'll definitely take that into consideration, but it's up to the test writer to determine how many `subtestcases' are being executed in a master testcase.

Quoted 10 lines

Looking at the file you mentioned, I have just a few remarks:

tst_cleanup()
{
   # Disable the trap EXIT handler.
   trap '' EXIT
   # To ensure set -u passes...
   TCtmp=${TCtmp:=}

Why? Shouldn't it catch invalid use (eg. without doing tst_setup first)?

Yeah, that's useless if TCtmp is exported in tst_setup and tst_setup is executed to completion (or at least this variable is exported there) first. I may need to adjust the trap(1) to get this to function in a better way.

Quoted 16 lines

   # Nuke the testcase temporary directory if it exists. [ -d "$TCtmp" ] && rm -rf "$TCtmp"                           (1) }

tst_setup() {

   TST_COUNT=1
   TST_TOTAL=${TST_TOTAL:=1}                                    (2) export TCID TST_COUNT TST_TOTAL

   for varname in TST_TOTAL; do
       if eval "test -z \"\$${varname}\""; then
           end_testcase "You must set ${varname} before calling setup()." fi
   done

Quoted 3 lines

What is the sense of doing "test -z "$TST_TOTAL"" in such an elaborate way, especially when you reset TST_TOTAL in (2) so test -z $TST_TOTAL can never be true here?

I was trying to avoid duplicate logic, but if it makes sense to do:

if test "x$foo" = x ; then

fi
if test "x$foo" = x ; then

fi

and do some basic arithmetic on the values to ensure they're in range, then I'll gladly rewrite it :]. The point was to avoid the nasty `you need to defined variable X.Y.Z' message from tst_res*(3), etc, because this is quick and resolves coding issues with the underlying testcases.

Quoted 9 lines

...

   TCtmp=${TCtmp:=$TEMPDIR/$TC$$}
   # User wants a temporary sandbox to play with. if [ -n "$TCtmp" -a "$TCtmp" != "$TEMPDIR/$$" ] ; then test -d "$TCtmp" || mkdir -p "$TCtmp"

What is so special about "$TEMPDIR/$$" that you refuse to create a directory with this name, but still delete it in (1)?

Good point; this is not very well thought-out logic that I implemented on impulse a while ago (I think that the original logic test was `"$TCtmp" != "$TEMPDIR"').

Quoted 10 lines

...
}

incr_tst_count()
{
   : $(( TST_COUNT + 1 ))
}

Was this really meant this way (ie. as a code with no effect), or should it be "+="?

That's a really stupid mistake that I made. Fixed now (thanks!).

Thanks for the review!
-Garrett

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list