Return-Path: From: Wang Mingyu Date: Mon, 25 Mar 2019 02:19:25 -0700 Message-ID: <1553505567-3221-7-git-send-email-wangmy@cn.fujitsu.com> In-Reply-To: <1553505567-3221-1-git-send-email-wangmy@cn.fujitsu.com> References: <1553505567-3221-1-git-send-email-wangmy@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Fuego] [PATCH v2] parted: Add test cases for command parted. List-Id: Mailing list for the Fuego test framework List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: fuego@lists.linuxfoundation.org This test set is used to display machine parseable output, help message and version of command parted. Signed-off-by: Wang Mingyu --- tests/Functional.parted/fuego_test.sh | 18 ++++++++++++++++++ tests/Functional.parted/parser.py | 20 ++++++++++++++++++++ tests/Functional.parted/parted_test.sh | 4 ++++ tests/Functional.parted/spec.json | 6 ++++++ tests/Functional.parted/tests/parted_help.sh | 13 +++++++++++++ tests/Functional.parted/tests/parted_machine.sh | 19 +++++++++++++++++++ tests/Functional.parted/tests/parted_summary.sh | 13 +++++++++++++ tests/Functional.parted/tests/parted_version.sh | 13 +++++++++++++ 8 files changed, 106 insertions(+) create mode 100644 tests/Functional.parted/fuego_test.sh create mode 100644 tests/Functional.parted/parser.py create mode 100755 tests/Functional.parted/parted_test.sh create mode 100644 tests/Functional.parted/spec.json create mode 100644 tests/Functional.parted/tests/parted_help.sh create mode 100644 tests/Functional.parted/tests/parted_machine.sh create mode 100644 tests/Functional.parted/tests/parted_summary.sh create mode 100644 tests/Functional.parted/tests/parted_version.sh diff --git a/tests/Functional.parted/fuego_test.sh b/tests/Functional.parted/fuego_test.sh new file mode 100644 index 0000000..3c94d6a --- /dev/null +++ b/tests/Functional.parted/fuego_test.sh @@ -0,0 +1,18 @@ +function test_pre_check { + assert_has_program parted + assert_has_program partprobe +} + +function test_deploy { + put $TEST_HOME/parted_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/ + put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/ +} + +function test_run { + report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\ + ./parted_test.sh" +} + +function test_processing { + log_compare "$TESTDIR" "0" "TEST-FAIL" "n" +} diff --git a/tests/Functional.parted/parser.py b/tests/Functional.parted/parser.py new file mode 100644 index 0000000..f25a608 --- /dev/null +++ b/tests/Functional.parted/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.parted/parted_test.sh b/tests/Functional.parted/parted_test.sh new file mode 100755 index 0000000..dd5ce37 --- /dev/null +++ b/tests/Functional.parted/parted_test.sh @@ -0,0 +1,4 @@ +#!/bin/sh +for i in tests/*.sh; do + sh $i +done diff --git a/tests/Functional.parted/spec.json b/tests/Functional.parted/spec.json new file mode 100644 index 0000000..f44c21e --- /dev/null +++ b/tests/Functional.parted/spec.json @@ -0,0 +1,6 @@ +{ + "testName": "Functional.parted", + "specs": { + "default": {} + } +} diff --git a/tests/Functional.parted/tests/parted_help.sh b/tests/Functional.parted/tests/parted_help.sh new file mode 100644 index 0000000..1460cfe --- /dev/null +++ b/tests/Functional.parted/tests/parted_help.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# In target, run command parted. +# option: --help. + +test="help" + +if parted --help | grep Usage +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi; diff --git a/tests/Functional.parted/tests/parted_machine.sh b/tests/Functional.parted/tests/parted_machine.sh new file mode 100644 index 0000000..6cdca7e --- /dev/null +++ b/tests/Functional.parted/tests/parted_machine.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# In target, run command parted to displays machine parseable output. +# option: --machine. + +test="machine" + +expect <<-EOF +spawn parted --machine +expect { + -re ".*GNU Parted.*" { + send_user " -> $test: TEST-PASS\n" + } + default { + send_user " -> can't displays machine parseable output.\n" + send_user " -> $test: TEST-FAIL\n"} } +send "q\n" +expect eof +EOF diff --git a/tests/Functional.parted/tests/parted_summary.sh b/tests/Functional.parted/tests/parted_summary.sh new file mode 100644 index 0000000..2df576a --- /dev/null +++ b/tests/Functional.parted/tests/parted_summary.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# In target, run command partprobe. +# option: -s + +test="summary" + +if partprobe -s +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi diff --git a/tests/Functional.parted/tests/parted_version.sh b/tests/Functional.parted/tests/parted_version.sh new file mode 100644 index 0000000..5fb7136 --- /dev/null +++ b/tests/Functional.parted/tests/parted_version.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# In target, run command partprobe. +# option: -v + +test="version" + +if partprobe -v | grep Copyright +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi -- 1.8.3.1