This merges the shared bits from ts_tc() and ts_ip() into a common
function for being wrapped by the first ones and adds a third ts_ss()
for testing ss commands.

Signed-off-by: Phil Sutter <p...@nwl.cc>
---
 testsuite/Makefile       |  2 +-
 testsuite/lib/generic.sh | 37 ++++++++++++++-----------------------
 2 files changed, 15 insertions(+), 24 deletions(-)

diff --git a/testsuite/Makefile b/testsuite/Makefile
index 2a54e5c845e65..8fcbc557ff9a7 100644
--- a/testsuite/Makefile
+++ b/testsuite/Makefile
@@ -65,7 +65,7 @@ endif
                TMP_ERR=`mktemp /tmp/tc_testsuite.XXXXXX`; \
                TMP_OUT=`mktemp /tmp/tc_testsuite.XXXXXX`; \
                STD_ERR="$$TMP_ERR" STD_OUT="$$TMP_OUT" \
-               TC="$$i/tc/tc" IP="$$i/ip/ip" DEV="$(DEV)" IPVER="$@" 
SNAME="$$i" \
+               TC="$$i/tc/tc" IP="$$i/ip/ip" SS=$$i/misc/ss DEV="$(DEV)" 
IPVER="$@" SNAME="$$i" \
                ERRF="$(RESULTS_DIR)/$@.$$o.err" $(KENV) $(PREFIX) tests/$@ > 
$(RESULTS_DIR)/$@.$$o.out; \
                if [ "$$?" = "127" ]; then \
                        echo "SKIPPED"; \
diff --git a/testsuite/lib/generic.sh b/testsuite/lib/generic.sh
index 8cef20fa1b280..f92260fc40cf3 100644
--- a/testsuite/lib/generic.sh
+++ b/testsuite/lib/generic.sh
@@ -26,16 +26,17 @@ ts_skip()
     exit 127
 }
 
-ts_tc()
+__ts_cmd()
 {
+       CMD=$1; shift
        SCRIPT=$1; shift
        DESC=$1; shift
 
-       $TC $@ 2> $STD_ERR > $STD_OUT
+       $CMD $@ 2> $STD_ERR > $STD_OUT
 
        if [ -s $STD_ERR ]; then
                ts_err "${SCRIPT}: ${DESC} failed:"
-               ts_err "command: $TC $@"
+               ts_err "command: $CMD $@"
                ts_err "stderr output:"
                ts_err_cat $STD_ERR
                if [ -s $STD_OUT ]; then
@@ -50,29 +51,19 @@ ts_tc()
        fi
 }
 
-ts_ip()
+ts_tc()
 {
-       SCRIPT=$1; shift
-       DESC=$1; shift
+       __ts_cmd "$TC" "$@"
+}
 
-       $IP $@ 2> $STD_ERR > $STD_OUT
-        RET=$?
+ts_ip()
+{
+       __ts_cmd "$IP" "$@"
+}
 
-       if [ -s $STD_ERR ] || [ "$RET" != "0" ]; then
-               ts_err "${SCRIPT}: ${DESC} failed:"
-               ts_err "command: $IP $@"
-               ts_err "stderr output:"
-               ts_err_cat $STD_ERR
-               if [ -s $STD_OUT ]; then
-                       ts_err "stdout output:"
-                       ts_err_cat $STD_OUT
-               fi
-       elif [ -s $STD_OUT ]; then
-               echo "${SCRIPT}: ${DESC} succeeded with output:"
-               cat $STD_OUT
-       else
-               echo "${SCRIPT}: ${DESC} succeeded"
-       fi
+ts_ss()
+{
+       __ts_cmd "$SS" "$@"
 }
 
 ts_qdisc_available()
-- 
2.18.0

Reply via email to