From 3fda9b33d60820eb2e3cc6f1c18fa5327c1c1921 Mon Sep 17 00:00:00 2001 From: Masami Hiramatsu Date: Fri, 22 Feb 2019 10:26:57 +0900 Subject: selftests/ftrace: Make a script checkbashisms clean Make kprobe_ftrace.tc checkbashisms clean. Since "grep function available_tracers" causes an error on checkbashisms, fix it by explicitly escaping with double-quotations. Signed-off-by: Masami Hiramatsu Signed-off-by: Shuah Khan --- tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc index 492426e95e09..7650a82db3f5 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc @@ -3,7 +3,7 @@ # description: Kprobe dynamic event with function tracer [ -f kprobe_events ] || exit_unsupported # this is configurable -grep function available_tracers || exit_unsupported # this is configurable +grep "function" available_tracers || exit_unsupported # this is configurable # prepare echo nop > current_tracer -- cgit v1.2.3 From 4a075bd4e13f6dd07a8438e0580629a3fba3f58e Mon Sep 17 00:00:00 2001 From: Masami Hiramatsu Date: Fri, 22 Feb 2019 10:27:25 +0900 Subject: selftests/ftrace: Add checkbashisms meta-testcase Add a meta-testcase which tests ftracetest itself with checkbasisms. This helps us to keep our test script bashisms clean. Signed-off-by: Masami Hiramatsu Signed-off-by: Shuah Khan --- tools/testing/selftests/ftrace/ftracetest | 1 + .../selftests/ftrace/test.d/selftest/bashisms.tc | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/selftest/bashisms.tc (limited to 'tools') diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest index 136387422b00..7da5e31fa0ed 100755 --- a/tools/testing/selftests/ftrace/ftracetest +++ b/tools/testing/selftests/ftrace/ftracetest @@ -318,6 +318,7 @@ run_test() { # testfile local testlog=/proc/self/fd/1 fi export TMPDIR=`mktemp -d /tmp/ftracetest-dir.XXXXXX` + export FTRACETEST_ROOT=$TOP_DIR echo "execute$INSTANCE: "$1 > $testlog SIG_RESULT=0 if [ $VERBOSE -eq -1 ]; then diff --git a/tools/testing/selftests/ftrace/test.d/selftest/bashisms.tc b/tools/testing/selftests/ftrace/test.d/selftest/bashisms.tc new file mode 100644 index 000000000000..1b081e910e14 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/selftest/bashisms.tc @@ -0,0 +1,21 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Meta-selftest: Checkbashisms + +if [ ! -f $FTRACETEST_ROOT/ftracetest ]; then + echo "Hmm, we can not find ftracetest" + exit_unresolved +fi + +if ! which checkbashisms > /dev/null 2>&1 ; then + echo "No checkbashisms found. skipped." + exit_unresolved +fi + +checkbashisms $FTRACETEST_ROOT/ftracetest +checkbashisms $FTRACETEST_ROOT/test.d/functions +for t in $(find $FTRACETEST_ROOT/test.d -name \*.tc); do + checkbashisms $t +done + +exit 0 -- cgit v1.2.3 From d51f1f14870a3401dbcab0b737773bdc70f54a25 Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Fri, 24 May 2019 00:42:22 +0200 Subject: selftests/harness: Allow test to configure timeout Commit a745f7af3cbd ("selftests/harness: Add 30 second timeout per test") adds an hardcoded 30s timeout to all tests. Unfortunately, rtctest has two tests taking up to 60s. Allow for individual tests to define their own timeout. Signed-off-by: Alexandre Belloni Reviewed-by: Kees Cook Signed-off-by: Shuah Khan --- tools/testing/selftests/kselftest_harness.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'tools') diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h index 941d9391377f..2067c6b0e8a1 100644 --- a/tools/testing/selftests/kselftest_harness.h +++ b/tools/testing/selftests/kselftest_harness.h @@ -62,6 +62,7 @@ #include #include +#define TEST_TIMEOUT_DEFAULT 30 /* Utilities exposed to the test definitions */ #ifndef TH_LOG_STREAM @@ -169,7 +170,8 @@ static void test_name(struct __test_metadata *_metadata); \ static struct __test_metadata _##test_name##_object = \ { .name = "global." #test_name, \ - .fn = &test_name, .termsig = _signal }; \ + .fn = &test_name, .termsig = _signal, \ + .timeout = TEST_TIMEOUT_DEFAULT, }; \ static void __attribute__((constructor)) _register_##test_name(void) \ { \ __register_test(&_##test_name##_object); \ @@ -280,12 +282,15 @@ */ /* TODO(wad) register fixtures on dedicated test lists. */ #define TEST_F(fixture_name, test_name) \ - __TEST_F_IMPL(fixture_name, test_name, -1) + __TEST_F_IMPL(fixture_name, test_name, -1, TEST_TIMEOUT_DEFAULT) #define TEST_F_SIGNAL(fixture_name, test_name, signal) \ - __TEST_F_IMPL(fixture_name, test_name, signal) + __TEST_F_IMPL(fixture_name, test_name, signal, TEST_TIMEOUT_DEFAULT) -#define __TEST_F_IMPL(fixture_name, test_name, signal) \ +#define TEST_F_TIMEOUT(fixture_name, test_name, timeout) \ + __TEST_F_IMPL(fixture_name, test_name, -1, timeout) + +#define __TEST_F_IMPL(fixture_name, test_name, signal, tmout) \ static void fixture_name##_##test_name( \ struct __test_metadata *_metadata, \ FIXTURE_DATA(fixture_name) *self); \ @@ -307,6 +312,7 @@ .name = #fixture_name "." #test_name, \ .fn = &wrapper_##fixture_name##_##test_name, \ .termsig = signal, \ + .timeout = tmout, \ }; \ static void __attribute__((constructor)) \ _register_##fixture_name##_##test_name(void) \ @@ -632,6 +638,7 @@ struct __test_metadata { int termsig; int passed; int trigger; /* extra handler after the evaluation */ + int timeout; __u8 step; bool no_print; /* manual trigger when TH_LOG_STREAM is not available */ struct __test_metadata *prev, *next; @@ -696,7 +703,7 @@ void __run_test(struct __test_metadata *t) t->passed = 1; t->trigger = 0; printf("[ RUN ] %s\n", t->name); - alarm(30); + alarm(t->timeout); child_pid = fork(); if (child_pid < 0) { printf("ERROR SPAWNING TEST CHILD\n"); -- cgit v1.2.3 From eff82a263b5cfa3427fd9dbfedd96da94fdc9f19 Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Fri, 24 May 2019 00:42:23 +0200 Subject: selftests: rtc: rtctest: specify timeouts uie_read is a commonly failing test that will block forever on buggy rtc drivers. Shorten its timeout so it fails earlier. Also increase the timeout for the two alarm test on a minute boundary. Signed-off-by: Alexandre Belloni Signed-off-by: Shuah Khan --- tools/testing/selftests/rtc/rtctest.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/testing/selftests/rtc/rtctest.c b/tools/testing/selftests/rtc/rtctest.c index b2065536d407..66af608fb4c6 100644 --- a/tools/testing/selftests/rtc/rtctest.c +++ b/tools/testing/selftests/rtc/rtctest.c @@ -49,7 +49,7 @@ TEST_F(rtc, date_read) { rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec); } -TEST_F(rtc, uie_read) { +TEST_F_TIMEOUT(rtc, uie_read, NUM_UIE + 2) { int i, rc, irq = 0; unsigned long data; @@ -211,7 +211,7 @@ TEST_F(rtc, alarm_wkalm_set) { ASSERT_EQ(new, secs); } -TEST_F(rtc, alarm_alm_set_minute) { +TEST_F_TIMEOUT(rtc, alarm_alm_set_minute, 65) { struct timeval tv = { .tv_sec = 62 }; unsigned long data; struct rtc_time tm; @@ -264,7 +264,7 @@ TEST_F(rtc, alarm_alm_set_minute) { ASSERT_EQ(new, secs); } -TEST_F(rtc, alarm_wkalm_set_minute) { +TEST_F_TIMEOUT(rtc, alarm_wkalm_set_minute, 65) { struct timeval tv = { .tv_sec = 62 }; struct rtc_wkalrm alarm = { 0 }; struct rtc_time tm; -- cgit v1.2.3