From patchwork Wed Feb 25 22:32:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 45145 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f198.google.com (mail-we0-f198.google.com [74.125.82.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7E6F320502 for ; Wed, 25 Feb 2015 22:33:11 +0000 (UTC) Received: by wesq59 with SMTP id q59sf5045358wes.2 for ; Wed, 25 Feb 2015 14:33:10 -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=LG20JBiubwaDn8ddq/0LKcmQ4m20zyCHwV0jL6nnNlk=; b=htygYjE1mKB2yPa+9DRMkrqNmrTcODwkeYxvNVejC4imKgcDca/DUM2xWjlBXknBZp aaDO4D9xrhOjcK8gDdGrh0R8rRc2XUmvybwOdOrls5mUvfvYBsHaKYMKiuJ55x60SUEO Ldikvf+8gnJyN/AFCcfq2BYv+s08MEEiErn0RJUvqjbnLWZZ0wgGjbezEoi6idIEdv5G AZp1YAUBTQY/W2eHS1u60xlPbvaE5hruJHITrU62/4FRqbukOMhvkwyXvkKBotpLdEXH LNYiI7OF3kp2JuWuSjdMr5OBOAMC+Q9/KXLjYW6vCSQ21F0fxpHog7Adm3OdX7qZ6Xd3 GrUw== X-Gm-Message-State: ALoCoQk+FMZcBEmZT66TMsxMnyw2f1UK3ZIcP5QGLpBeG9AVLbb5c0KbqpZ3VkqkpWBFTJoqOMwj X-Received: by 10.180.83.168 with SMTP id r8mr870414wiy.6.1424903590849; Wed, 25 Feb 2015 14:33:10 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.44.136 with SMTP id e8ls410708lam.91.gmail; Wed, 25 Feb 2015 14:33:10 -0800 (PST) X-Received: by 10.152.25.132 with SMTP id c4mr4874035lag.101.1424903590691; Wed, 25 Feb 2015 14:33:10 -0800 (PST) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id sv11si17867159lbc.129.2015.02.25.14.33.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Feb 2015 14:33:10 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by lbdu10 with SMTP id u10so7122004lbd.7 for ; Wed, 25 Feb 2015 14:33:10 -0800 (PST) X-Received: by 10.112.118.211 with SMTP id ko19mr4903444lbb.19.1424903590601; Wed, 25 Feb 2015 14:33:10 -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 h5csp2924999lbj; Wed, 25 Feb 2015 14:33:09 -0800 (PST) X-Received: by 10.68.226.69 with SMTP id rq5mr9501348pbc.116.1424903564478; Wed, 25 Feb 2015 14:32:44 -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 pq5si5090060pbb.42.2015.02.25.14.32.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Feb 2015 14:32:44 -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 pdbfp1 with SMTP id fp1so8072025pdb.5 for ; Wed, 25 Feb 2015 14:32:43 -0800 (PST) X-Received: by 10.68.218.202 with SMTP id pi10mr9398599pbc.13.1424903563578; Wed, 25 Feb 2015 14:32:43 -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 qm12sm43160405pdb.36.2015.02.25.14.32.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Feb 2015 14:32:42 -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: Wed, 25 Feb 2015 14:32:18 -0800 Message-Id: <1424903544-26855-14-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1424903544-26855-1-git-send-email-john.stultz@linaro.org> References: <1424903544-26855-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.173 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 | 75 +++++++++++++++++++++++ 2 files changed, 77 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 c3e32f1..68b5253 100644 --- a/tools/testing/selftests/timers/Makefile +++ b/tools/testing/selftests/timers/Makefile @@ -2,7 +2,7 @@ CFLAGS += -O3 -Wl,-no-as-needed 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} @@ -25,6 +25,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..5c4b53a --- /dev/null +++ b/tools/testing/selftests/timers/skew_consistency.c @@ -0,0 +1,75 @@ +/* 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 + +#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); + } + + if (ret) + printf("[FAILED]\n"); + else + printf("[OK]\n"); + + + /* Set things back */ + tx.modes = ADJ_FREQUENCY; + tx.offset = 0; + adjtimex(&tx); + + return ret; +}