[Fuego] [PATCH] bmaptool: Add test cases of command bmaptool.

Yuan Chao yuanc.fnst at cn.fujitsu.com
Tue Jun 4 06:46:58 UTC 2019


This is a simple test to check the option copy/help/version of command bmaptool.

Signed-off-by: Yuan Chao <yuanc.fnst at cn.fujitsu.com>
---
 tests/Functional.bmaptool/bmaptool_test.sh         |  4 ++++
 tests/Functional.bmaptool/fuego_test.sh            | 18 +++++++++++++++
 tests/Functional.bmaptool/parser.py                | 20 ++++++++++++++++
 tests/Functional.bmaptool/spec.json                |  6 +++++
 tests/Functional.bmaptool/test.yaml                | 19 +++++++++++++++
 tests/Functional.bmaptool/tests/bmaptool_copy.sh   | 27 ++++++++++++++++++++++
 tests/Functional.bmaptool/tests/bmaptool_help.sh   | 13 +++++++++++
 .../Functional.bmaptool/tests/bmaptool_version.sh  | 13 +++++++++++
 8 files changed, 120 insertions(+)
 create mode 100644 tests/Functional.bmaptool/bmaptool_test.sh
 create mode 100644 tests/Functional.bmaptool/fuego_test.sh
 create mode 100644 tests/Functional.bmaptool/parser.py
 create mode 100644 tests/Functional.bmaptool/spec.json
 create mode 100644 tests/Functional.bmaptool/test.yaml
 create mode 100644 tests/Functional.bmaptool/tests/bmaptool_copy.sh
 create mode 100644 tests/Functional.bmaptool/tests/bmaptool_help.sh
 create mode 100644 tests/Functional.bmaptool/tests/bmaptool_version.sh

diff --git a/tests/Functional.bmaptool/bmaptool_test.sh b/tests/Functional.bmaptool/bmaptool_test.sh
new file mode 100644
index 0000000..dd5ce37
--- /dev/null
+++ b/tests/Functional.bmaptool/bmaptool_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/tests/Functional.bmaptool/fuego_test.sh b/tests/Functional.bmaptool/fuego_test.sh
new file mode 100644
index 0000000..0fd3249
--- /dev/null
+++ b/tests/Functional.bmaptool/fuego_test.sh
@@ -0,0 +1,18 @@
+function test_pre_check {
+    assert_has_program bmaptool
+}
+
+function test_deploy {
+    put $TEST_HOME/bmaptool_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./bmaptool_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
+
diff --git a/tests/Functional.bmaptool/parser.py b/tests/Functional.bmaptool/parser.py
new file mode 100644
index 0000000..f25a608
--- /dev/null
+++ b/tests/Functional.bmaptool/parser.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+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/tests/Functional.bmaptool/spec.json b/tests/Functional.bmaptool/spec.json
new file mode 100644
index 0000000..f1215b3
--- /dev/null
+++ b/tests/Functional.bmaptool/spec.json
@@ -0,0 +1,6 @@
+{
+    "testName": "Functional.bmaptool",
+    "specs": {
+        "default": {}
+    }
+}
diff --git a/tests/Functional.bmaptool/test.yaml b/tests/Functional.bmaptool/test.yaml
new file mode 100644
index 0000000..f6a6e48
--- /dev/null
+++ b/tests/Functional.bmaptool/test.yaml
@@ -0,0 +1,19 @@
+fuego_package_version: 1
+name: Functional.bmaptool
+description: |
+        Bmaptool a tool for creating block maps (bmap) and copying disk images using bmap files.
+        This is a simple test to check the option copy/help/version of command bmaptool.
+license: BSD-3-Clause
+author: Yuan Chao <yuanc.fnst at cn.fujitsu.com>
+maintainer: Wang Mingyu <wangmy at cn.fujitsu.com>
+version: 1.00
+fuego_release: 1
+type: Functional
+tags: ['bmap']
+data_files:
+ - bmaptool_test.sh
+ - fuego_test.sh
+ - parser.py
+ - spec.json
+ - test.yaml
+ - tests
diff --git a/tests/Functional.bmaptool/tests/bmaptool_copy.sh b/tests/Functional.bmaptool/tests/bmaptool_copy.sh
new file mode 100644
index 0000000..220517e
--- /dev/null
+++ b/tests/Functional.bmaptool/tests/bmaptool_copy.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+#  In target, run command bmaptool, and check if copy option can execute.
+#  1) Option: copy
+
+test="bmaptool"
+
+test_file="test_bmaptool_copy"
+output_file="test_bmaptool_copy_output"
+
+if [ -f $test_file ]
+then
+    rm -f $test_file
+fi
+
+test_string="bmaptool copy success"
+echo "$test_string" > $test_file
+
+bmaptool copy --nobmap $test_file $output_file
+
+if [ "$(cat $output_file)" = "$test_string" ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm -f $test_file $output_file
diff --git a/tests/Functional.bmaptool/tests/bmaptool_help.sh b/tests/Functional.bmaptool/tests/bmaptool_help.sh
new file mode 100644
index 0000000..0d9950d
--- /dev/null
+++ b/tests/Functional.bmaptool/tests/bmaptool_help.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  In target, run command bmaptool, and check if help option can execute.
+#  1) Option: -h
+
+test="bmaptool"
+
+if bmaptool -h | grep "[uU]sage"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
diff --git a/tests/Functional.bmaptool/tests/bmaptool_version.sh b/tests/Functional.bmaptool/tests/bmaptool_version.sh
new file mode 100644
index 0000000..a70b520
--- /dev/null
+++ b/tests/Functional.bmaptool/tests/bmaptool_version.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  In target, run command bmaptool, and check if version option can execute.
+#  1) Option: --version
+
+test="bmaptool"
+
+if bmaptool --version | grep "bmaptool"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
-- 
1.8.3.1





More information about the Fuego mailing list