Return-Path: From: Wang Mingyu Date: Thu, 4 Apr 2019 03:34:21 -0700 Message-ID: <1554374062-75879-2-git-send-email-wangmy@cn.fujitsu.com> In-Reply-To: <1554374062-75879-1-git-send-email-wangmy@cn.fujitsu.com> References: <1554374062-75879-1-git-send-email-wangmy@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Fuego] [PATCH v2] keyctl: Add test cases for command keyctl. 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 add/show/clear the data of key. Signed-off-by: Wang Mingyu --- tests/Functional.keyctl/fuego_test.sh | 17 +++++++++++++++++ tests/Functional.keyctl/keyctl_test.sh | 4 ++++ tests/Functional.keyctl/parser.py | 20 ++++++++++++++++++++ tests/Functional.keyctl/spec.json | 6 ++++++ tests/Functional.keyctl/tests/keyctl_add.sh | 14 ++++++++++++++ tests/Functional.keyctl/tests/keyctl_clear.sh | 14 ++++++++++++++ tests/Functional.keyctl/tests/keyctl_show.sh | 13 +++++++++++++ tests/Functional.keyctl/tests/keyctl_version.sh | 13 +++++++++++++ 8 files changed, 101 insertions(+) create mode 100644 tests/Functional.keyctl/fuego_test.sh create mode 100755 tests/Functional.keyctl/keyctl_test.sh create mode 100644 tests/Functional.keyctl/parser.py create mode 100644 tests/Functional.keyctl/spec.json create mode 100644 tests/Functional.keyctl/tests/keyctl_add.sh create mode 100644 tests/Functional.keyctl/tests/keyctl_clear.sh create mode 100644 tests/Functional.keyctl/tests/keyctl_show.sh create mode 100644 tests/Functional.keyctl/tests/keyctl_version.sh diff --git a/tests/Functional.keyctl/fuego_test.sh b/tests/Functional.keyctl/fuego_test.sh new file mode 100644 index 0000000..63aaeb8 --- /dev/null +++ b/tests/Functional.keyctl/fuego_test.sh @@ -0,0 +1,17 @@ +function test_pre_check { + assert_has_program keyctl +} + +function test_deploy { + put $TEST_HOME/keyctl_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/ + put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/ +} + +function test_run { + report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\ + ./keyctl_test.sh" +} + +function test_processing { + log_compare "$TESTDIR" "0" "TEST-FAIL" "n" +} diff --git a/tests/Functional.keyctl/keyctl_test.sh b/tests/Functional.keyctl/keyctl_test.sh new file mode 100755 index 0000000..dd5ce37 --- /dev/null +++ b/tests/Functional.keyctl/keyctl_test.sh @@ -0,0 +1,4 @@ +#!/bin/sh +for i in tests/*.sh; do + sh $i +done diff --git a/tests/Functional.keyctl/parser.py b/tests/Functional.keyctl/parser.py new file mode 100644 index 0000000..f25a608 --- /dev/null +++ b/tests/Functional.keyctl/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.keyctl/spec.json b/tests/Functional.keyctl/spec.json new file mode 100644 index 0000000..ff0b8dd --- /dev/null +++ b/tests/Functional.keyctl/spec.json @@ -0,0 +1,6 @@ +{ + "testName": "Functional.keyctl", + "specs": { + "default": {} + } +} diff --git a/tests/Functional.keyctl/tests/keyctl_add.sh b/tests/Functional.keyctl/tests/keyctl_add.sh new file mode 100644 index 0000000..98f6472 --- /dev/null +++ b/tests/Functional.keyctl/tests/keyctl_add.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +# The testscript checks the command keyctl. +# option: add + +test="add" + +keyctl add user _display data @u +if keyctl show | grep "user: _display" +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi; diff --git a/tests/Functional.keyctl/tests/keyctl_clear.sh b/tests/Functional.keyctl/tests/keyctl_clear.sh new file mode 100644 index 0000000..c93b26c --- /dev/null +++ b/tests/Functional.keyctl/tests/keyctl_clear.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +# The testscript checks the command keyctl. +# option: clear + +test="clear" + +keyctl clear @u +if keyctl show | grep "Session Keyring" +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi; diff --git a/tests/Functional.keyctl/tests/keyctl_show.sh b/tests/Functional.keyctl/tests/keyctl_show.sh new file mode 100644 index 0000000..31cce30 --- /dev/null +++ b/tests/Functional.keyctl/tests/keyctl_show.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# The testscript checks the command keyctl. +# option: show + +test="show" + +if keyctl show | grep "_ses" +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi; diff --git a/tests/Functional.keyctl/tests/keyctl_version.sh b/tests/Functional.keyctl/tests/keyctl_version.sh new file mode 100644 index 0000000..eca4e63 --- /dev/null +++ b/tests/Functional.keyctl/tests/keyctl_version.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# The testscript checks the command keyctl. +# option: --version + +test="version" + +if keyctl --version | grep "keyctl" +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi; -- 1.8.3.1