Skip to contentSkip to conversation

Add a new test suite called Functional.busybox.

PATCH In review Wang Mingyu 2 participants 2 messages May 22, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add a new test suite called Functional.busybox.

---
 engine/tests/Functional.busybox/fuego_test.sh | 51 +++++++++++++++++++++++++++
 engine/tests/Functional.busybox/parser.py     | 22 ++++++++++++
 engine/tests/Functional.busybox/spec.json     |  7 ++++
 3 files changed, 80 insertions(+)
 create mode 100755 engine/tests/Functional.busybox/fuego_test.sh
 create mode 100755 engine/tests/Functional.busybox/parser.py
 create mode 100644 engine/tests/Functional.busybox/spec.json
engine/tests/Functional.busybox/fuego_test.sh new file +51 -0
new file mode 100755
index 0000000..3140680
@@ -0,0 +1,51 @@
+# $1: string with tests to skip separated by spaces
+# $2: absolute path to the skipfile (default: ${LOGDIR}/skiplist.txt)
+function skip_tests {
+    # split $1 on whitespace, without file globbing
+    set -f
+    local TESTS=($1)
+    local SKIPFILE="${LOGDIR}/skiplist.txt"
+    set +f
+    echo "Skipping tests: ${TESTS[@]}."
+    for testname in "${TESTS[@]}"; do
+        echo "$testname" >> ${SKIPFILE}
+    done
+}
+
+# $1: command/program to look for
+# $2: string with busybox test names separated by spaces
+# $3: This function may also be used in other tests, which can be considered as a general function of fuego.
+function skip_if_command_unavailable {
+    local PROGRAM="$1"
+    local TESTS="$2"
+    export FOUND=""
+
+    is_on_target ${PROGRAM} FOUND /bin:/usr/bin:/usr/sbin:/usr/local/bin
+    if [ -z "${FOUND}" ]; then
+        echo "WARNING: ${PROGRAM} is not installed on the target."
+        skip_tests "${TESTS}"
+    fi
+}
+
+function test_pre_check {
+    echo "Tests skipped depending on the availability of a command on the target"
+    touch ${LOGDIR}/skiplist.txt
+    skip_if_command_unavailable expect "busybox_ash.sh"
+}
+
+function test_deploy {
+    put $TEST_HOME/busybox_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/testsuits $BOARD_TESTDIR/fuego.$TESTDIR/
+    put ${LOGDIR}/skiplist.txt $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    export test_tcpip_host=$SRV_IP;\
+    export test_port_host=$SRV_PORT;\
+    sh -v busybox_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "4" "TEST-PASS" "p"
+}
engine/tests/Functional.busybox/parser.py new file +22 -0
new file mode 100755
index 0000000..d85abd7
@@ -0,0 +1,22 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+
+sys.path.insert(0, os.environ['FUEGO_CORE'] + '/engine/scripts/parser')
+import common as plib
+
+measurements = {}
+measurements = collections.OrderedDict()
+
+regex_string = '^ -> (.*): TEST-(.*)$'
+matches = plib.parse_log(regex_string)
+
+if matches:
+    for m in matches:
+        measurements['default.' + m[0]] = 'PASS' if m[1] == 'PASS' else 'FAIL'
+
+# split the output for each testcase
+plib.split_output_per_testcase(regex_string, measurements)
+
+sys.exit(plib.process(measurements))
engine/tests/Functional.busybox/spec.json new file +7 -0
new file mode 100644
index 0000000..a71218a
@@ -0,0 +1,7 @@
+{
+    "testName": "Functional.busybox",
+    "specs": {
+        "default": {}
+    }
+}
+
Signature · 1 line
1.8.3.1
#1 lore raw

Please see comments inline below.

Quoted 42 lines

-----Original Message-----
From: Wang Mingyu
Sent: Tuesday, May 22, 2018 8:59 AM
To: [email protected]
Subject: [Fuego] [PATCH] Add a new test suite called Functional.busybox.

---
 engine/tests/Functional.busybox/fuego_test.sh | 51
+++++++++++++++++++++++++++
 engine/tests/Functional.busybox/parser.py     | 22 ++++++++++++
 engine/tests/Functional.busybox/spec.json     |  7 ++++
 3 files changed, 80 insertions(+)
 create mode 100755 engine/tests/Functional.busybox/fuego_test.sh
 create mode 100755 engine/tests/Functional.busybox/parser.py
 create mode 100644 engine/tests/Functional.busybox/spec.json
engine/tests/Functional.busybox/fuego_test.sh new file +17 -0
new file mode 100755
index 0000000..3140680
@@ -0,0 +1,51 @@
+# $1: string with tests to skip separated by spaces
+# $2: absolute path to the skipfile (default: ${LOGDIR}/skiplist.txt)
+function skip_tests {
+    # split $1 on whitespace, without file globbing
+    set -f
+    local TESTS=($1)
+    local SKIPFILE="${LOGDIR}/skiplist.txt"
+    set +f
+    echo "Skipping tests: ${TESTS[@]}."
+    for testname in "${TESTS[@]}"; do
+        echo "$testname" >> ${SKIPFILE}
+    done
+}
+
+# $1: command/program to look for
+# $2: string with busybox test names separated by spaces
+# $3: This function may also be used in other tests, which can be considered

as a general function of fuego.

engine/tests/Functional.busybox/fuego_test.sh line 23

Quoted 6 lines
engine/tests/Functional.busybox/fuego_test.sh new file +6 -0
+function skip_if_command_unavailable {
+    local PROGRAM="$1"
+    local TESTS="$2"
+    export FOUND=""
+
+    is_on_target ${PROGRAM} FOUND /bin:/usr/bin:/usr/sbin:/usr/local/bin

You should use is_on_target_path here, which uses the search PATH on the board. This is more reliable than specifying your own path.
See http://fuegotest.org/wiki/function_is_on_target_path

engine/tests/Functional.busybox/fuego_test.sh line 28

Quoted 5 lines
engine/tests/Functional.busybox/fuego_test.sh new file +5 -0
+    if [ -z "${FOUND}" ]; then
+        echo "WARNING: ${PROGRAM} is not installed on the target."
+        skip_tests "${TESTS}"
+    fi
+}

This is a nice way to handle this automatically. Thanks.

engine/tests/Functional.busybox/fuego_test.sh line 38

Quoted 11 lines
engine/tests/Functional.busybox/fuego_test.sh new file +3 -0
+
+function test_pre_check {
+    echo "Tests skipped depending on the availability of a command on the

target"

engine/tests/Functional.busybox/fuego_test.sh new file +7 -0
+    touch ${LOGDIR}/skiplist.txt
+    skip_if_command_unavailable expect "busybox_ash.sh"
+}
+
+function test_deploy {
+    put $TEST_HOME/busybox_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/testsuits $BOARD_TESTDIR/fuego.$TESTDIR/

Sorry I didn't catch this earlier. 'testsuits' is mis-spelled. It should be 'testsuites'. Or you could just use 'tests'. This should be renamed everywhere it is used.

Quoted 57 lines
engine/tests/Functional.busybox/fuego_test.sh new file +13 -0
+    put ${LOGDIR}/skiplist.txt $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    export test_tcpip_host=$SRV_IP;\
+    export test_port_host=$SRV_PORT;\
+    sh -v busybox_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "4" "TEST-PASS" "p"
+}
engine/tests/Functional.busybox/parser.py new file +22 -0
new file mode 100755
index 0000000..d85abd7
@@ -0,0 +1,22 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+
+sys.path.insert(0, os.environ['FUEGO_CORE'] + '/engine/scripts/parser')
+import common as plib
+
+measurements = {}
+measurements = collections.OrderedDict()
+
+regex_string = '^ -> (.*): TEST-(.*)$'
+matches = plib.parse_log(regex_string)
+
+if matches:
+    for m in matches:
+        measurements['default.' + m[0]] = 'PASS' if m[1] == 'PASS' else 'FAIL'
+
+# split the output for each testcase
+plib.split_output_per_testcase(regex_string, measurements)
+
+sys.exit(plib.process(measurements))
engine/tests/Functional.busybox/spec.json new file +7 -1
new file mode 100644
index 0000000..a71218a
@@ -0,0 +1,7 @@
+{
+    "testName": "Functional.busybox",
+    "specs": {
+        "default": {}
+    }
+}
+
--
Quoted 1 line

1.8.3.1

Looks good. Please fix the two issues mentioned, and I think it will be good to go.
-- Tim