From patchwork Thu May 23 22:42:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Belloni X-Patchwork-Id: 10958913 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5465A112C for ; Thu, 23 May 2019 22:42:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FA3928747 for ; Thu, 23 May 2019 22:42:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 321E52874B; Thu, 23 May 2019 22:42:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B540028747 for ; Thu, 23 May 2019 22:42:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387546AbfEWWm5 (ORCPT ); Thu, 23 May 2019 18:42:57 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:52213 "EHLO relay9-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387616AbfEWWm4 (ORCPT ); Thu, 23 May 2019 18:42:56 -0400 X-Originating-IP: 90.66.53.80 Received: from localhost (lfbn-1-3034-80.w90-66.abo.wanadoo.fr [90.66.53.80]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id D4023FF804; Thu, 23 May 2019 22:42:41 +0000 (UTC) From: Alexandre Belloni To: Shuah Khan Cc: Kees Cook , Jeffrin Thalakkottoor , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, Alexandre Belloni Subject: [PATCH 1/2] selftests/harness: Allow test to configure timeout Date: Fri, 24 May 2019 00:42:22 +0200 Message-Id: <20190523224223.11054-2-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190523224223.11054-1-alexandre.belloni@bootlin.com> References: <20190523224223.11054-1-alexandre.belloni@bootlin.com> MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- tools/testing/selftests/kselftest_harness.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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"); From patchwork Thu May 23 22:42:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Belloni X-Patchwork-Id: 10958915 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 620C215A6 for ; Thu, 23 May 2019 22:43:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D61228747 for ; Thu, 23 May 2019 22:43:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 415572874B; Thu, 23 May 2019 22:43:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E200928747 for ; Thu, 23 May 2019 22:42:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388520AbfEWWm7 (ORCPT ); Thu, 23 May 2019 18:42:59 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:48695 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387616AbfEWWm6 (ORCPT ); Thu, 23 May 2019 18:42:58 -0400 X-Originating-IP: 90.66.53.80 Received: from localhost (lfbn-1-3034-80.w90-66.abo.wanadoo.fr [90.66.53.80]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 9B0D71C0008; Thu, 23 May 2019 22:42:52 +0000 (UTC) From: Alexandre Belloni To: Shuah Khan Cc: Kees Cook , Jeffrin Thalakkottoor , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, Alexandre Belloni Subject: [PATCH 2/2] selftests: rtc: rtctest: specify timeouts Date: Fri, 24 May 2019 00:42:23 +0200 Message-Id: <20190523224223.11054-3-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190523224223.11054-1-alexandre.belloni@bootlin.com> References: <20190523224223.11054-1-alexandre.belloni@bootlin.com> MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Kees Cook --- tools/testing/selftests/rtc/rtctest.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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;