Return-Path: From: Wang Mingyu Date: Tue, 21 May 2019 04:06:39 -0700 Message-ID: <1558436802-7323-1-git-send-email-wangmy@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Fuego] [PATCH v2] Add test cases of command ecryptfs-manager. 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 ask key modules to generate new keys. Signed-off-by: Wang Mingyu --- .../ecryptfs_manager_test.sh | 4 ++++ tests/Functional.ecryptfs_manager/fuego_test.sh | 17 ++++++++++++++++ tests/Functional.ecryptfs_manager/parser.py | 20 +++++++++++++++++++ tests/Functional.ecryptfs_manager/spec.json | 6 ++++++ .../tests/ecryptfs-manager01.sh | 23 ++++++++++++++++++++++ .../tests/ecryptfs-manager02.sh | 23 ++++++++++++++++++++++ 6 files changed, 93 insertions(+) create mode 100644 tests/Functional.ecryptfs_manager/ecryptfs_manager_test.sh create mode 100644 tests/Functional.ecryptfs_manager/fuego_test.sh create mode 100644 tests/Functional.ecryptfs_manager/parser.py create mode 100644 tests/Functional.ecryptfs_manager/spec.json create mode 100644 tests/Functional.ecryptfs_manager/tests/ecryptfs-manager01.sh create mode 100644 tests/Functional.ecryptfs_manager/tests/ecryptfs-manager02.sh diff --git a/tests/Functional.ecryptfs_manager/ecryptfs_manager_test.sh b/tests/Functional.ecryptfs_manager/ecryptfs_manager_test.sh new file mode 100644 index 0000000..dd5ce37 --- /dev/null +++ b/tests/Functional.ecryptfs_manager/ecryptfs_manager_test.sh @@ -0,0 +1,4 @@ +#!/bin/sh +for i in tests/*.sh; do + sh $i +done diff --git a/tests/Functional.ecryptfs_manager/fuego_test.sh b/tests/Functional.ecryptfs_manager/fuego_test.sh new file mode 100644 index 0000000..8e34104 --- /dev/null +++ b/tests/Functional.ecryptfs_manager/fuego_test.sh @@ -0,0 +1,17 @@ +function test_pre_check { + assert_has_program ecryptfs-manager +} + +function test_deploy { + put $TEST_HOME/ecryptfs_manager_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/ + put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/ +} + +function test_run { + report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\ + ./ecryptfs_manager_test.sh" +} + +function test_processing { + log_compare "$TESTDIR" "0" "TEST-FAIL" "n" +} diff --git a/tests/Functional.ecryptfs_manager/parser.py b/tests/Functional.ecryptfs_manager/parser.py new file mode 100644 index 0000000..f25a608 --- /dev/null +++ b/tests/Functional.ecryptfs_manager/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.ecryptfs_manager/spec.json b/tests/Functional.ecryptfs_manager/spec.json new file mode 100644 index 0000000..88816ec --- /dev/null +++ b/tests/Functional.ecryptfs_manager/spec.json @@ -0,0 +1,6 @@ +{ + "testName": "Functional.ecryptfs_manager", + "specs": { + "default": {} + } +} diff --git a/tests/Functional.ecryptfs_manager/tests/ecryptfs-manager01.sh b/tests/Functional.ecryptfs_manager/tests/ecryptfs-manager01.sh new file mode 100644 index 0000000..57bf971 --- /dev/null +++ b/tests/Functional.ecryptfs_manager/tests/ecryptfs-manager01.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +# The testscript execute the command ecryptfs-manager and check the passphrase. +# option: none + +test="ecryptfs-manager01" + +expect <<-EOF +spawn ecryptfs-manager +expect "Make selection:" +send "1\r" +expect "Mount-wide passphrase:" +send "test123\r" +expect ".*Confirm passphrase:" +send "test123\r" +expect { + -re ".*Using the default salt value.*" { + send_user " -> $test: TEST-PASS\n" + } +default { send_user " -> $test: TEST-FAIL\n" } } +send "4\r" +expect eof +EOF diff --git a/tests/Functional.ecryptfs_manager/tests/ecryptfs-manager02.sh b/tests/Functional.ecryptfs_manager/tests/ecryptfs-manager02.sh new file mode 100644 index 0000000..b6dd802 --- /dev/null +++ b/tests/Functional.ecryptfs_manager/tests/ecryptfs-manager02.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +# The testscript execute the command ecryptfs-manager and check the passphrase. +# option: none + +test="ecryptfs-manager02" + +expect <<-EOF +spawn ecryptfs-manager +expect "Make selection:" +send "1\r" +expect "Mount-wide passphrase:" +send "test123\r" +expect ".*Confirm passphrase:" +send "test123\r" +expect { + -re "That key was already" { + send_user " -> $test: TEST-PASS\n" + } +default { send_user " -> $test: TEST-FAIL\n" } } +send "4\r" +expect eof +EOF -- 1.8.3.1