[Fuego] [PATCH v2] Add test cases for command ethtool.

Wang Mingyu wangmy at cn.fujitsu.com
Tue Sep 18 15:57:29 UTC 2018


Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
---
 engine/tests/Functional.ethtool/ethtool_test.sh    |  4 ++++
 engine/tests/Functional.ethtool/fuego_test.sh      | 18 +++++++++++++++
 engine/tests/Functional.ethtool/parser.py          | 22 ++++++++++++++++++
 engine/tests/Functional.ethtool/spec.json          |  7 ++++++
 .../Functional.ethtool/tests/ethtool_driver.sh     | 25 +++++++++++++++++++++
 .../tests/Functional.ethtool/tests/ethtool_help.sh | 13 +++++++++++
 .../tests/Functional.ethtool/tests/ethtool_show.sh | 26 ++++++++++++++++++++++
 7 files changed, 115 insertions(+)
 create mode 100755 engine/tests/Functional.ethtool/ethtool_test.sh
 create mode 100644 engine/tests/Functional.ethtool/fuego_test.sh
 create mode 100644 engine/tests/Functional.ethtool/parser.py
 create mode 100644 engine/tests/Functional.ethtool/spec.json
 create mode 100644 engine/tests/Functional.ethtool/tests/ethtool_driver.sh
 create mode 100644 engine/tests/Functional.ethtool/tests/ethtool_help.sh
 create mode 100644 engine/tests/Functional.ethtool/tests/ethtool_show.sh

diff --git a/engine/tests/Functional.ethtool/ethtool_test.sh b/engine/tests/Functional.ethtool/ethtool_test.sh
new file mode 100755
index 0000000..dd5ce37
--- /dev/null
+++ b/engine/tests/Functional.ethtool/ethtool_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/engine/tests/Functional.ethtool/fuego_test.sh b/engine/tests/Functional.ethtool/fuego_test.sh
new file mode 100644
index 0000000..233d367
--- /dev/null
+++ b/engine/tests/Functional.ethtool/fuego_test.sh
@@ -0,0 +1,18 @@
+function test_pre_check {
+    is_on_target_path ethtool PROGRAM_ETHTOOL
+    assert_define PROGRAM_ETHTOOL "Missing 'ethtool' program on target board"
+}
+
+function test_deploy {
+    put $TEST_HOME/ethtool_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./ethtool_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/engine/tests/Functional.ethtool/parser.py b/engine/tests/Functional.ethtool/parser.py
new file mode 100644
index 0000000..d85abd7
--- /dev/null
+++ b/engine/tests/Functional.ethtool/parser.py
@@ -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))
diff --git a/engine/tests/Functional.ethtool/spec.json b/engine/tests/Functional.ethtool/spec.json
new file mode 100644
index 0000000..c16b2d5
--- /dev/null
+++ b/engine/tests/Functional.ethtool/spec.json
@@ -0,0 +1,7 @@
+{
+    "testName": "Functional.ethtool",
+    "specs": {
+        "default": {}
+    }
+}
+
diff --git a/engine/tests/Functional.ethtool/tests/ethtool_driver.sh b/engine/tests/Functional.ethtool/tests/ethtool_driver.sh
new file mode 100644
index 0000000..6f6d576
--- /dev/null
+++ b/engine/tests/Functional.ethtool/tests/ethtool_driver.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+#  In target, run command ethtool.
+#  option: -i
+
+test="driver"
+
+ETHERNET_DEVICE_NAME="have no Ethernet device"
+ifconfig | cut -d' ' -f1 | sed '/^$/d' > driver_list
+
+for line in $(cat driver_list)
+do
+    if ethtool $line | grep "baseT"
+    then
+        ETHERNET_DEVICE_NAME=$line
+        break
+    fi
+done
+
+if ethtool -i $ETHERNET_DEVICE_NAME | grep driver
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
diff --git a/engine/tests/Functional.ethtool/tests/ethtool_help.sh b/engine/tests/Functional.ethtool/tests/ethtool_help.sh
new file mode 100644
index 0000000..4554de3
--- /dev/null
+++ b/engine/tests/Functional.ethtool/tests/ethtool_help.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  In target, run command ethtool.
+#  option: help
+
+test="help"
+
+if ethtool -h | grep Usage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
diff --git a/engine/tests/Functional.ethtool/tests/ethtool_show.sh b/engine/tests/Functional.ethtool/tests/ethtool_show.sh
new file mode 100644
index 0000000..98abe40
--- /dev/null
+++ b/engine/tests/Functional.ethtool/tests/ethtool_show.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+#  In target, run command ethtool.
+#  option: none
+
+test="show"
+
+ETHERNET_DEVICE_NAME="have no Ethernet device"
+ifconfig | cut -d' ' -f1 | sed '/^$/d' > driver_list
+
+for line in $(cat driver_list)
+do
+    if ethtool $line | grep "baseT"
+    then
+        ETHERNET_DEVICE_NAME=$line
+        break
+    fi
+done
+
+
+if ethtool $ETHERNET_DEVICE_NAME | grep "Settings for"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
-- 
1.8.3.1





More information about the Fuego mailing list