Just ignore me if I'm out of line 8-)
It's more about style than anything else.
`...` and $(...) are posix and equivalent. I find $(...) easier to use
and cleaner, as nesting is much easier when using $(...). Mixing the two
in one and the same script easily leads to controversy. Picking on
testsuite/runtest this time ;-) See for example this line in the named
script:
[ -n "$bindir" ] || bindir=$(dirname $(pwd))
Can someone provide a backtick equivalent example?
That could even be simplified to:
["$bindir" ] || bindir=$(dirname $(pwd))
without loosing anything. The attached patch is attemting to make
testsuite/runtest more style consistent.
Cheers,
--
Cristian
Index: testsuite/runtest
===================================================================
--- testsuite/runtest (revision 21848)
+++ testsuite/runtest (working copy)
@@ -14,7 +14,7 @@
local status
local uc_applet=$(echo $applet | tr a-z A-Z)
- local testname=`basename "$testcase"`
+ local testname=$(basename "$testcase")
if grep -q "^# CONFIG_${uc_applet} is not set$" $bindir/.config; then
echo "UNTESTED: $testname"
@@ -22,7 +22,7 @@
fi
if grep -q "^# FEATURE: " "$testcase"; then
- local feature=`sed -ne 's/^# FEATURE: //p' "$testcase"`
+ local feature=$(sed -ne 's/^# FEATURE: //p' "$testcase")
if grep -q "^# ${feature} is not set$" $bindir/.config; then
echo "UNTESTED: $testname"
@@ -35,9 +35,9 @@
cd ".tmpdir.$applet" || return 1
# echo "Running testcase $testcase"
- d="$tsdir" sh -x -e "$testcase" >"$testname.stdout.txt" 2>&1
+ d="$tsdir" sh -x -e "$testcase" > "$testname.stdout.txt" 2>&1
status=$?
- if [ $status != 0 ]; then
+ if [ $status -ne 0 ]; then
echo "FAIL: $testname"
if [ x"$VERBOSE" != x ]; then
cat "$testname.stdout.txt"
@@ -58,7 +58,7 @@
local applet=$1
local status=0
for testcase in $tsdir/$applet/*; do
- case `basename "$testcase"` in
+ case "$(basename "$testcase")" in
\#*)
continue
;;
@@ -77,7 +77,6 @@
}
-
[ -n "$tsdir" ] || tsdir=$(pwd)
[ -n "$bindir" ] || bindir=$(dirname $(pwd))
PATH="$bindir:$PATH"
@@ -91,15 +90,14 @@
shift
fi
-implemented=$(
- $bindir/busybox 2>&1 |
- while read line; do
+implemented=$($bindir/busybox 2>&1 | \
+ while read line; do
if [ x"$line" = x"Currently defined functions:" ]; then
xargs | sed 's/,//g'
break
fi
- done
- )
+ done
+ )
applets="$implemented"
if [ $# -ne 0 ]; then
@@ -116,11 +114,14 @@
done
# Set up option flags so tests can be selective.
-export OPTIONFLAGS=:$(sed -nr 's/^CONFIG_//p' $bindir/.config | sed 's/=.*//' | xargs | sed 's/ /:/g')
+export OPTIONFLAGS=:$(sed -nr 's/^CONFIG_//p' $bindir/.config | \
+ sed 's/=.*//' | xargs | sed 's/ /:/g')
status=0
for applet in $applets; do
- if [ "$applet" = "links" ]; then continue; fi
+ if [ "$applet" = "links" ]; then
+ continue
+ fi
# Any old-style tests for this applet?
if [ "$applet" != "CVS" -a -d "$tsdir/$applet" ]; then
@@ -130,20 +131,20 @@
# Is this a new-style test?
if [ -f "${applet}.tests" ]; then
- if [ ! -h "$LINKSDIR/$applet" ] && [ "${applet:0:4}" != "all_" ]; then
+ if [ ! -h "$LINKSDIR/$applet" ] &&
+ [ "${applet:0:4}" != "all_" ]; then
echo "SKIPPED: $applet (not built)"
continue
fi
-# echo "Running test ${tsdir:-.}/${applet}.tests"
PATH="$LINKSDIR:$tsdir:$bindir:$PATH" "${tsdir:-.}/${applet}.tests"
test $? = 0 || status=1
fi
done
# Leaving the dir makes it somewhat easier to run failed test by hand
-#rm -rf "$LINKSDIR"
-if [ $status != 0 -a x"$VERBOSE" = x ]; then
+if [ $status != 0 ] && [ x"$VERBOSE" = x ]; then
echo "Failures detected, running with -v (verbose) will give more info"
fi
+
exit $status
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox