From patchwork Fri Aug 18 18:50:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 110426 Delivered-To: patches@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1287459qge; Fri, 18 Aug 2017 11:51:13 -0700 (PDT) X-Received: by 10.84.209.169 with SMTP id y38mr10585571plh.230.1503082273077; Fri, 18 Aug 2017 11:51:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503082273; cv=none; d=google.com; s=arc-20160816; b=ZtBzim27v99cuJxe6HUTzEgl2HgaA7D7+0CK+/rvlexios39QJfh6j7ADGBWs6fsXo gPxzcDpGPuCOCjEJWj6hTLnP7NUsfyP6Yg82LpZC0XslJy87TEYTUbeAZ/doLT1/7d8l /yvCPHd14ftmCVY3M6AdXwZmPNnXbiyHFgqP/yI2KYIYrw4cyxNs9ALvad8ve13FQIlM xOTBD6qiHQxdswFpvOB6amuSliq0vKfJht5a+mythavcgIprIKyJOxDY4H1bOLLRNAka PLpEn4Wg4ZVDVjSOETtfg6djWzCgIHLeBWYHeCgg7d+GogUv+Ud7xaimITH7hryBfvvd lCOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=QfVHqPUFBghSkG6sK7geAV3zGjuR7j4SFAPl/ZGobkA=; b=m5VgMtZ5xKXJu+6Jmxhrdk7mzYAJd1q4muqyZ+N/RybjRNPZ0nuA+Vq840OnLsn0m6 O5jEafAN2Q5oapZkkOpnzr+dRsm01BK7VMwT2VaxnxJHOfBAuQAg3fpsid/6TBhufyxc ETllA1P8SPEoEf/PIpSsEoIdTITCzDcadUJWat1J9APujqlIugV/EnZSRXz9C/sU2vXN njFn8RxeUsgRI/bdAYG2IiM9hjdRAoAt+DJNpV/lvBQNrJcPQEGDxNYvVzLRU2j6ggkS s60w9H8sGilK8w854I70MrwNRVX98T9W9IHtFmvMO/Wi2T1bkWj8Y/FUf4fwT1zaewPQ Mjuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G+fAw19A; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::22d as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-pg0-x22d.google.com (mail-pg0-x22d.google.com. [2607:f8b0:400e:c05::22d]) by mx.google.com with ESMTPS id g68si3861191pgc.734.2017.08.18.11.51.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Aug 2017 11:51:13 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::22d as permitted sender) client-ip=2607:f8b0:400e:c05::22d; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G+fAw19A; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::22d as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-pg0-x22d.google.com with SMTP id v189so69362662pgd.2 for ; Fri, 18 Aug 2017 11:51:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QfVHqPUFBghSkG6sK7geAV3zGjuR7j4SFAPl/ZGobkA=; b=G+fAw19A49IIiPIg1YQvrbWPXxkgn/SsS68apZiXtDG5yfUWSkBi9vVAxKoQBnhbbt 2Ty8Zq+3JEfhU6ETc7ZGLSdwZSb0/ftY751UTJfByIost9EnB0TAAVmux+9jVwe5xOoi /sIztn07iTeg+Zb5jJSlTPlsOTFQc7mODUXoY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QfVHqPUFBghSkG6sK7geAV3zGjuR7j4SFAPl/ZGobkA=; b=BKLbDSQnkHfxDBpR89mGFXbkH+Kgm1jVwyMc+drK0coxcmtIIS/tizcB+dmqZdhCAg BRF0Rka/meXaVUfb1VuTwm/VbwJ6yQGSzTLcr23IyThgwO/chA/Q4EketDmKKkwIttNc WTIFMP1/JL12bGcG2I8eB6Ue7WJZf95CLFHmZ9VCY1qSvb57AdnhjEN+eikDTfDeIgUY 2Gdrcd1NiX1JdrIhyFFoRNqYoBIkUwXkcC8MzTOLZ+ol91Y3dJ4vxIv5Tiei+z5K2rrU IuwUjkHLpas/XnCDh5flyLuwsfdbyd1xXEj3gX36mANfo5q3fKuA/g3VCEOeSIbhU3lA uo6Q== X-Gm-Message-State: AHYfb5gqR+OBkl8v6y5/O76UpPfVxU5i8s7Q53mHZeiUxA9PhOsG58n6 +JhE/mRTsyW2Kld00rs= X-Received: by 10.98.35.82 with SMTP id j79mr9746535pfj.56.1503082272796; Fri, 18 Aug 2017 11:51:12 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id l132sm12518790pfc.150.2017.08.18.11.51.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Aug 2017 11:51:11 -0700 (PDT) From: John Stultz To: lkml Cc: Greg Hackmann , Thomas Gleixner , Ingo Molnar , Miroslav Lichvar , Richard Cochran , Prarit Bhargava , Stephen Boyd , Shuah Khan , linux-kselftest@vger.kernel.org, John Stultz Subject: [PATCH 3/6] kselftests: timers: set-timer-lat: Tweak reporting when timer fires early Date: Fri, 18 Aug 2017 11:50:59 -0700 Message-Id: <1503082262-29450-4-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503082262-29450-1-git-send-email-john.stultz@linaro.org> References: <1503082262-29450-1-git-send-email-john.stultz@linaro.org> From: Greg Hackmann Rather than printing an error inside the alarm signal handler, set a flag that we check later. This keeps the test from spamming the console every time the alarm fires early. It also fixes the test exiting with error code 0 if this was the only test failure. Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Miroslav Lichvar Cc: Richard Cochran Cc: Prarit Bhargava Cc: Stephen Boyd Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Signed-off-by: Greg Hackmann Signed-off-by: John Stultz --- tools/testing/selftests/timers/set-timer-lat.c | 33 +++++++++++++++++++------- 1 file changed, 25 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/tools/testing/selftests/timers/set-timer-lat.c b/tools/testing/selftests/timers/set-timer-lat.c index 4fc98c5..10c2e18 100644 --- a/tools/testing/selftests/timers/set-timer-lat.c +++ b/tools/testing/selftests/timers/set-timer-lat.c @@ -63,6 +63,7 @@ int alarmcount; int clock_id; struct timespec start_time; long long max_latency_ns; +int timer_fired_early; char *clockstring(int clockid) { @@ -115,12 +116,19 @@ void sigalarm(int signo) delta_ns -= NSEC_PER_SEC * TIMER_SECS * alarmcount; if (delta_ns < 0) - printf("%s timer fired early: FAIL\n", clockstring(clock_id)); + timer_fired_early = 1; if (delta_ns > max_latency_ns) max_latency_ns = delta_ns; } +void describe_timer(int flags) +{ + printf("%-22s %s ", + clockstring(clock_id), + flags ? "ABSTIME":"RELTIME"); +} + int do_timer(int clock_id, int flags) { struct sigevent se; @@ -136,6 +144,7 @@ int do_timer(int clock_id, int flags) max_latency_ns = 0; alarmcount = 0; + timer_fired_early = 0; err = timer_create(clock_id, &se, &tm1); if (err) { @@ -170,18 +179,26 @@ int do_timer(int clock_id, int flags) while (alarmcount < 5) sleep(1); - printf("%-22s %s max latency: %10lld ns : ", - clockstring(clock_id), - flags ? "ABSTIME":"RELTIME", - max_latency_ns); + describe_timer(flags); + printf("timer fired early: %7d : ", timer_fired_early); + if (!timer_fired_early) { + printf("[OK]\n"); + } else { + printf("[FAILED]\n"); + err = -1; + } + + describe_timer(flags); + printf("max latency: %10lld ns : ", max_latency_ns); timer_delete(tm1); if (max_latency_ns < UNRESONABLE_LATENCY) { printf("[OK]\n"); - return 0; + } else { + printf("[FAILED]\n"); + err = -1; } - printf("[FAILED]\n"); - return -1; + return err; } int main(void)