From patchwork Mon Mar 2 21:10:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 45328 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 73132214B5 for ; Mon, 2 Mar 2015 21:11:20 +0000 (UTC) Received: by wibbs8 with SMTP id bs8sf11701606wib.2 for ; Mon, 02 Mar 2015 13:11:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=JmP1pLgZGJhq88cywL2mUuNqfF5E40l52FGJz56ZJPI=; b=eCkzIdXESpbB1adNisRGPiAJXxUuZX2O+X7xEFes3Iuyi7Y2LJkJXRKwt/Fz/oMqI/ 6Xm76rm3KQmTJVbk1IrvanD6sjmWguGbHltXSd7ddIDvn98UlZQU6fFN6gAfOOT1WbuV yV7/wSx8tIfLr/e3zwuz+Dsz8/C7xKpTRQN43DVouIDkjdNT3dAAE+h9jiA5+6SHKbD7 oc+GvOPez8EsIRfCL65+2lZ6ENCz3LuZjfZvScftVWoOveBGdZGiyoXphsVOMoWB6XsK JQ+hEn8AJRIy+cXPmIgHMDF9pOAtdSVE7w9GWMR0BOLUvVxcX8TQseOjG2ABQ3JQqXMe /ohA== X-Gm-Message-State: ALoCoQmoqabDH0EO8SUckFlLxSozMrGrHRxRTiktl/8uk+XAM3M5H2kTt7REyWuRZBiOLE0qeDmc X-Received: by 10.112.167.98 with SMTP id zn2mr4015101lbb.6.1425330679712; Mon, 02 Mar 2015 13:11:19 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.165 with SMTP id g5ls405725lae.68.gmail; Mon, 02 Mar 2015 13:11:19 -0800 (PST) X-Received: by 10.112.235.38 with SMTP id uj6mr26540673lbc.9.1425330679572; Mon, 02 Mar 2015 13:11:19 -0800 (PST) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id z9si9657621lbw.159.2015.03.02.13.11.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Mar 2015 13:11:19 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by lbiw7 with SMTP id w7so32939578lbi.10 for ; Mon, 02 Mar 2015 13:11:19 -0800 (PST) X-Received: by 10.152.26.201 with SMTP id n9mr8530260lag.29.1425330679480; Mon, 02 Mar 2015 13:11:19 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.35.133 with SMTP id h5csp158623lbj; Mon, 2 Mar 2015 13:11:18 -0800 (PST) X-Received: by 10.70.19.165 with SMTP id g5mr21333086pde.83.1425330658687; Mon, 02 Mar 2015 13:10:58 -0800 (PST) Received: from mail-pd0-f182.google.com (mail-pd0-f182.google.com. [209.85.192.182]) by mx.google.com with ESMTPS id cl4si6272327pbb.221.2015.03.02.13.10.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Mar 2015 13:10:58 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.192.182 as permitted sender) client-ip=209.85.192.182; Received: by pdbft15 with SMTP id ft15so16674218pdb.2 for ; Mon, 02 Mar 2015 13:10:57 -0800 (PST) X-Received: by 10.69.12.234 with SMTP id et10mr50140854pbd.65.1425330657810; Mon, 02 Mar 2015 13:10:57 -0800 (PST) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id ym10sm11765258pac.10.2015.03.02.13.10.55 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Mar 2015 13:10:57 -0800 (PST) From: John Stultz To: Linux Kernel Mailing List Cc: John Stultz , Shuah Khan , Prarit Bhargava , Thomas Gleixner , Richard Cochran Subject: [PATCH 13/19] selftests/timers: Add skew_consistency test from the timetests suite Date: Mon, 2 Mar 2015 13:10:06 -0800 Message-Id: <1425330612-24280-14-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1425330612-24280-1-git-send-email-john.stultz@linaro.org> References: <1425330612-24280-1-git-send-email-john.stultz@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This change adds the skew_consistency test, which twists the ADJ_FREQUENCY knob back and forth and watches for timekeeping inconsistencies. Cc: Shuah Khan Cc: Prarit Bhargava Cc: Thomas Gleixner Cc: Richard Cochran Signed-off-by: John Stultz --- tools/testing/selftests/timers/Makefile | 3 +- tools/testing/selftests/timers/skew_consistency.c | 89 +++++++++++++++++++++++ 2 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/timers/skew_consistency.c diff --git a/tools/testing/selftests/timers/Makefile b/tools/testing/selftests/timers/Makefile index 55b74cc..4b6b5c3 100644 --- a/tools/testing/selftests/timers/Makefile +++ b/tools/testing/selftests/timers/Makefile @@ -4,7 +4,7 @@ CFLAGS += -O3 -Wl,-no-as-needed -Wall $(BUILD_FLAGS) LDFLAGS += -lrt -lpthread bins = posix_timers nanosleep inconsistency-check nsleep-lat raw_skew \ set-timer-lat threadtest mqueue-lat valid-adjtimex \ - alarmtimer-suspend change_skew + alarmtimer-suspend change_skew skew_consistency all: ${bins} @@ -27,6 +27,7 @@ run_destructive_tests: run_tests ./alarmtimer-suspend ./valid-adjtimex ./change_skew + ./skew_consistency clean: rm -f ${bins} diff --git a/tools/testing/selftests/timers/skew_consistency.c b/tools/testing/selftests/timers/skew_consistency.c new file mode 100644 index 0000000..5562f84 --- /dev/null +++ b/tools/testing/selftests/timers/skew_consistency.c @@ -0,0 +1,89 @@ +/* ADJ_FREQ Skew consistency test + * by: john stultz (johnstul@us.ibm.com) + * (C) Copyright IBM 2012 + * Licensed under the GPLv2 + * + * NOTE: This is a meta-test which cranks the ADJ_FREQ knob back + * and forth and watches for consistency problems. Thus this test requires + * that the inconsistency-check tests be present in the same directory it + * is run from. + * + * To build: + * $ gcc skew_consistency.c -o skew_consistency -lrt + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef KTEST +#include "../kselftest.h" +#else +static inline int ksft_exit_pass(void) +{ + exit(0); +} +static inline int ksft_exit_fail(void) +{ + exit(1); +} +#endif + +#define NSEC_PER_SEC 1000000000LL + +int main(int argv, char **argc) +{ + struct timex tx; + int ret, ppm; + pid_t pid; + + + printf("Running Asyncrhonous Frequency Changing Tests...\n"); + + pid = fork(); + if (!pid) + return system("./inconsistency-check -c 1 -t 600"); + + ppm = 500; + ret = 0; + + while (pid != waitpid(pid, &ret, WNOHANG)) { + ppm = -ppm; + tx.modes = ADJ_FREQUENCY; + tx.freq = ppm << 16; + adjtimex(&tx); + usleep(500000); + } + + /* Set things back */ + tx.modes = ADJ_FREQUENCY; + tx.offset = 0; + adjtimex(&tx); + + + if (ret) { + printf("[FAILED]\n"); + return ksft_exit_fail(); + } + printf("[OK]\n"); + return ksft_exit_pass(); +}