[Fuego] [PATCH] ltrace: Add test cases for command ltrace.
Wang Mingyu <[email protected]>
| Newsgroups | dev.linux.lists.fuego |
|---|---|
| Message-ID | <[email protected]> |
ltrace is a program that simply runs the specified command until it exits. This test set is used to check the ountput syscall/time/count/help of command to trace and check if can be saved to file. Signed-off-by: Wang Mingyu <[email protected]> --- tests/Functional.ltrace/fuego_test.sh | 17 +++++++++++++++++ tests/Functional.ltrace/ltrace_test.sh | 4 ++++ tests/Functional.ltrace/spec.json | 6 ++++++ tests/Functional.ltrace/tests/ltrace_count.sh | 15 +++++++++++++++ tests/Functional.ltrace/tests/ltrace_help.sh | 13 +++++++++++++ tests/Functional.ltrace/tests/ltrace_output.sh | 15 +++++++++++++++ tests/Functional.ltrace/tests/ltrace_syscall.sh | 15 +++++++++++++++ tests/Functional.ltrace/tests/ltrace_time.sh | 15 +++++++++++++++ 8 files changed, 100 insertions(+) create mode 100644 tests/Functional.ltrace/fuego_test.sh create mode 100755 tests/Functional.ltrace/ltrace_test.sh create mode 100644 tests/Functional.ltrace/spec.json create mode 100644 tests/Functional.ltrace/tests/ltrace_count.sh create mode 100644 tests/Functional.ltrace/tests/ltrace_help.sh create mode 100644 tests/Functional.ltrace/tests/ltrace_output.sh create mode 100644 tests/Functional.ltrace/tests/ltrace_syscall.sh create mode 100644 tests/Functional.ltrace/tests/ltrace_time.sh diff --git a/tests/Functional.ltrace/fuego_test.sh b/tests/Functional.ltrace/fuego_test.sh new file mode 100644 index 0000000..ecfc4e7 --- /dev/null +++ b/tests/Functional.ltrace/fuego_test.sh @@ -0,0 +1,17 @@ +function test_pre_check { + assert_has_program ltrace +} + +function test_deploy { + put $TEST_HOME/ltrace_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/ + put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/ +} + +function test_run { + report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\ + ./ltrace_test.sh" +} + +function test_processing { + log_compare "$TESTDIR" "0" "TEST-FAIL" "n" +} diff --git a/tests/Functional.ltrace/ltrace_test.sh b/tests/Functional.ltrace/ltrace_test.sh new file mode 100755 index 0000000..dd5ce37 --- /dev/null +++ b/tests/Functional.ltrace/ltrace_test.sh @@ -0,0 +1,4 @@ +#!/bin/sh +for i in tests/*.sh; do + sh $i +done diff --git a/tests/Functional.ltrace/spec.json b/tests/Functional.ltrace/spec.json new file mode 100644 index 0000000..fce7a19 --- /dev/null +++ b/tests/Functional.ltrace/spec.json @@ -0,0 +1,6 @@ +{ + "testName": "Functional.ltrace", + "specs": { + "default": {} + } +} diff --git a/tests/Functional.ltrace/tests/ltrace_count.sh b/tests/Functional.ltrace/tests/ltrace_count.sh new file mode 100644 index 0000000..5a277fc --- /dev/null +++ b/tests/Functional.ltrace/tests/ltrace_count.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# In target, run comannd ltrace to count time and calls. +# option: -c + +test="count" + +ltrace -c dd if=/dev/urandom of=/dev/null count=1000 > log 2>&1 +if cat log | grep "usecs/call" +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi +rm log diff --git a/tests/Functional.ltrace/tests/ltrace_help.sh b/tests/Functional.ltrace/tests/ltrace_help.sh new file mode 100644 index 0000000..ea45a7e --- /dev/null +++ b/tests/Functional.ltrace/tests/ltrace_help.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# In target, run comannd ltrace to display help message. +# option: -h/--help + +test="help" + +if ltrace -h | grep [uU]sage +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi diff --git a/tests/Functional.ltrace/tests/ltrace_output.sh b/tests/Functional.ltrace/tests/ltrace_output.sh new file mode 100644 index 0000000..2d941b0 --- /dev/null +++ b/tests/Functional.ltrace/tests/ltrace_output.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Write the trace output to the file filename rather than to stderr. +# option: -o/--output + +test="output" + +ltrace -o log ls +if cat log | grep "+++ exited (status 0) +++" +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi +rm log diff --git a/tests/Functional.ltrace/tests/ltrace_syscall.sh b/tests/Functional.ltrace/tests/ltrace_syscall.sh new file mode 100644 index 0000000..34d1dc5 --- /dev/null +++ b/tests/Functional.ltrace/tests/ltrace_syscall.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# In target, run comannd ltrace to display system calls. +# option: -S + +test="syscall" + +ltrace -S ls > log 2>&1 +if cat log | grep "+++ exited (status 0) +++" +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi +rm log diff --git a/tests/Functional.ltrace/tests/ltrace_time.sh b/tests/Functional.ltrace/tests/ltrace_time.sh new file mode 100644 index 0000000..fc09108 --- /dev/null +++ b/tests/Functional.ltrace/tests/ltrace_time.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# In target, run comannd ltrace to show the time spent inside each call. +# option: -T + +test="time" + +ltrace -T ls > log 2>&1 +if cat log | grep "<[0-9].[0-9]\{6\}>" +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi +rm log -- 2.17.1