Skip to contentSkip to conversation

atmtcp: Add test cases for command atmtcp.

PATCH In review Wang Mingyu 2 participants 2 messages Aug 5, 2019 – Aug 7, 2019

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 atmtcp: Add test cases for command atmtcp.

This test set is used to check option help and subcommand virtual of atmtcp.

---
 tests/Functional.atmtcp/atmtcp_test.sh        |  4 +++
 tests/Functional.atmtcp/fuego_test.sh         | 20 +++++++++++++
 tests/Functional.atmtcp/spec.json             |  7 +++++
 tests/Functional.atmtcp/tests/atmtcp_help.sh  | 15 ++++++++++
 .../Functional.atmtcp/tests/atmtcp_virtual.sh | 29 +++++++++++++++++++
 5 files changed, 75 insertions(+)
 create mode 100644 tests/Functional.atmtcp/atmtcp_test.sh
 create mode 100644 tests/Functional.atmtcp/fuego_test.sh
 create mode 100644 tests/Functional.atmtcp/spec.json
 create mode 100644 tests/Functional.atmtcp/tests/atmtcp_help.sh
 create mode 100644 tests/Functional.atmtcp/tests/atmtcp_virtual.sh
tests/Functional.atmtcp/atmtcp_test.sh new file +4 -0
new file mode 100644
index 0000000..dd5ce37
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
tests/Functional.atmtcp/fuego_test.sh new file +20 -0
new file mode 100644
index 0000000..2d42527
@@ -0,0 +1,20 @@
+function test_pre_check {
+    assert_has_program atmtcp
+    assert_has_program lsmod
+    assert_has_program modprobe
+    assert_has_module atmtcp
+}
+
+function test_deploy {
+    put $TEST_HOME/atmtcp_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./atmtcp_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
tests/Functional.atmtcp/spec.json new file +7 -0
new file mode 100644
index 0000000..aff88cd
@@ -0,0 +1,7 @@
+{
+    "testName": "Functional.atmtcp",
+    "specs": {
+        "default": {}
+    }
+}
+
tests/Functional.atmtcp/tests/atmtcp_help.sh new file +15 -0
new file mode 100644
index 0000000..327fcdb
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+#  In target, run command atmtcp to check the output of help.
+#  option: -h
+
+test="help"
+
+atmtcp -h &> atmtcp_log
+if cat atmtcp_log | grep [Uu]sage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm atmtcp_log
tests/Functional.atmtcp/tests/atmtcp_virtual.sh new file +29 -0
new file mode 100644
index 0000000..4aad2a1
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+#  In target, run command atmtcp.
+#  option: virtual
+
+test="virtual"
+
+if lsmod | grep atmtcp
+then
+    echo " -> $test: atmtcp is already loaded."
+else
+    if modprobe -v atmtcp
+    then
+        echo " -> $test: load atmtcp succeeded."
+    else
+        echo " -> $test: load atmtcp failed."
+        echo " -> $test: TEST-FAIL"
+        exit
+    fi
+fi
+
+if [ ! -n "$(atmtcp virtual connect 127.0.0.1 | grep "virtual interface 0")" ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+killall atmtcp
Signature · 1 line
2.17.1
#1 lore raw

I found a few problems. However, this was applied to my 'next' branch in the fuegotest repository.

See details below.
-- Tim

Quoted 6 lines

-----Original Message-----
From: Wang Mingyu

This test set is used to check option help and subcommand virtual of atmtcp.

Quoted 8 lines
---
 tests/Functional.atmtcp/atmtcp_test.sh        |  4 +++
 tests/Functional.atmtcp/fuego_test.sh         | 20 +++++++++++++
 tests/Functional.atmtcp/spec.json             |  7 +++++
 tests/Functional.atmtcp/tests/atmtcp_help.sh  | 15 ++++++++++
 .../Functional.atmtcp/tests/atmtcp_virtual.sh | 29 +++++++++++++++++++
 5 files changed, 75 insertions(+)
 create mode 100644 tests/Functional.atmtcp/atmtcp_test.sh

this should be 100755 mode (executable)

tests/Functional.atmtcp/atmtcp_test.sh

Quoted 8 lines
 create mode 100644 tests/Functional.atmtcp/fuego_test.sh
 create mode 100644 tests/Functional.atmtcp/spec.json
 create mode 100644 tests/Functional.atmtcp/tests/atmtcp_help.sh
 create mode 100644 tests/Functional.atmtcp/tests/atmtcp_virtual.sh
tests/Functional.atmtcp/atmtcp_test.sh new file +0 -0
new file mode 100644

This should be file mode 100755 (user, group and world executable)

Quoted 15 lines

index 0000000..dd5ce37

tests/Functional.atmtcp/atmtcp_test.sh new file +4 -0
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
tests/Functional.atmtcp/fuego_test.sh new file +0 -0
new file mode 100644
index 0000000..2d42527

tests/Functional.atmtcp/fuego_test.sh line 6

Quoted 6 lines
tests/Functional.atmtcp/fuego_test.sh new file +6 -0
@@ -0,0 +1,20 @@
+function test_pre_check {
+    assert_has_program atmtcp
+    assert_has_program lsmod
+    assert_has_program modprobe
+    assert_has_module atmtcp
+}

These asserts take a long time. This is not a problem with this test, but it indicates that I need to take a look at optimizing the assert_has_program code, I think.

Quoted 35 lines
tests/Functional.atmtcp/fuego_test.sh new file +14 -0
+
+function test_deploy {
+    put $TEST_HOME/atmtcp_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./atmtcp_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
tests/Functional.atmtcp/spec.json new file +7 -0
new file mode 100644
index 0000000..aff88cd
@@ -0,0 +1,7 @@
+{
+    "testName": "Functional.atmtcp",
+    "specs": {
+        "default": {}
+    }
+}
+
tests/Functional.atmtcp/tests/atmtcp_help.sh new file +0 -0
new file mode 100644
index 0000000..327fcdb

tests/Functional.atmtcp/tests/atmtcp_help.sh line 8

Quoted 8 lines
tests/Functional.atmtcp/tests/atmtcp_help.sh new file +8 -0
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+#  In target, run command atmtcp to check the output of help.
+#  option: -h
+
+test="help"
+
+atmtcp -h &> atmtcp_log

'&>' is a bash-ism, I replaced this with 2>&1, which is posix-compliant. This didn't work on a machine here that used dash for /bin/sh.

tests/Functional.atmtcp/tests/atmtcp_help.sh line 9

Quoted 1 line
tests/Functional.atmtcp/tests/atmtcp_help.sh new file +1 -0
+if cat atmtcp_log | grep [Uu]sage

This could be simplified to remove the 'cat'
if grep [Uu]sage atmtcp_log ;

Quoted 32 lines
tests/Functional.atmtcp/tests/atmtcp_help.sh new file +6 -0
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm atmtcp_log
tests/Functional.atmtcp/tests/atmtcp_virtual.sh new file +19 -0
new file mode 100644
index 0000000..4aad2a1
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+#  In target, run command atmtcp.
+#  option: virtual
+
+test="virtual"
+
+if lsmod | grep atmtcp
+then
+    echo " -> $test: atmtcp is already loaded."
+else
+    if modprobe -v atmtcp
+    then
+        echo " -> $test: load atmtcp succeeded."
+    else
+        echo " -> $test: load atmtcp failed."
+        echo " -> $test: TEST-FAIL"
+        exit
+    fi

tests/Functional.atmtcp/tests/atmtcp_virtual.sh line 29

Quoted 10 lines
tests/Functional.atmtcp/tests/atmtcp_virtual.sh new file +10 -0
+fi
+
+if [ ! -n "$(atmtcp virtual connect 127.0.0.1 | grep "virtual interface 0")" ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+killall atmtcp

This returned non-zero (meaning failure),when atmtcp exited cleanly.

I added an:
exit 0

Thanks.
-- Tim