From patchwork Wed Feb 25 22:32:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 45144 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3659420502 for ; Wed, 25 Feb 2015 22:33:09 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id r20sf5621393wiv.3 for ; Wed, 25 Feb 2015 14:33:08 -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=igaNZrJu743BO87TWowXf0LN7IuWRgAhLwgpSo67D8o=; b=GzPFJrMeHHWgDdKwI/NybmW7JqbkuxhS9AbLFyRHNpdaYmg8NxItDgIggzqGg5X83M g77+BwWnSf8MEm81DyxpPzJxKNnD2+F979ugi2umN19SZvIj3LuSUHk8ZKwX8pvekxf9 2QttZTCBUkHcYqdTWx8ntTve8WYM05q+wy9cd8ONqoMDW3OSMZgCmrlB3ea1m/2QTu7j vTwQ2SHgxDLvtekaGq0pJp8e5Ie1GZJZ6E8l6lNB9bDLrtIXN9t6pzTP84P1VHi8OTMb BFyTFc6q6cab15Zn7HyzHKRc7c1i2xOxVgO4pu3mQXV4/TOOgEJg9gDGCt5V98GShE8q KShg== X-Gm-Message-State: ALoCoQmiUVNe02u1qsv92lC5uwKQHscH8B8bUW0kSEt8vAeckXa9ayQIptjgEEs3dULPkAuIS64h X-Received: by 10.112.131.106 with SMTP id ol10mr847058lbb.20.1424903588419; Wed, 25 Feb 2015 14:33:08 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.197.2 with SMTP id iq2ls5625lac.100.gmail; Wed, 25 Feb 2015 14:33:08 -0800 (PST) X-Received: by 10.112.171.65 with SMTP id as1mr4865391lbc.45.1424903588277; Wed, 25 Feb 2015 14:33:08 -0800 (PST) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id s4si6954579lbb.65.2015.02.25.14.33.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Feb 2015 14:33:08 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by lbiz11 with SMTP id z11so7137322lbi.5 for ; Wed, 25 Feb 2015 14:33:08 -0800 (PST) X-Received: by 10.112.56.139 with SMTP id a11mr4920174lbq.36.1424903587994; Wed, 25 Feb 2015 14:33:07 -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 h5csp2924983lbj; Wed, 25 Feb 2015 14:33:07 -0800 (PST) X-Received: by 10.67.23.101 with SMTP id hz5mr9413859pad.47.1424903563309; Wed, 25 Feb 2015 14:32:43 -0800 (PST) Received: from mail-pd0-f180.google.com (mail-pd0-f180.google.com. [209.85.192.180]) by mx.google.com with ESMTPS id hy3si4198029pac.96.2015.02.25.14.32.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Feb 2015 14:32:43 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.192.180 as permitted sender) client-ip=209.85.192.180; Received: by pdbfl12 with SMTP id fl12so8101276pdb.4 for ; Wed, 25 Feb 2015 14:32:42 -0800 (PST) X-Received: by 10.68.241.102 with SMTP id wh6mr9370661pbc.18.1424903562408; Wed, 25 Feb 2015 14:32:42 -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.41 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Feb 2015 14:32:41 -0800 (PST) From: John Stultz To: Linux Kernel Mailing List Cc: John Stultz , Shuah Khan , Prarit Bhargava , Thomas Gleixner , Richard Cochran Subject: [PATCH 12/19] selftests/timers: Add change_skew test from timetest suite Date: Wed, 25 Feb 2015 14:32:17 -0800 Message-Id: <1424903544-26855-13-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.178 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 patch adds the change_skew test which validates the adjtimex freq can be set to various values and then using the inconsistency-check, raw_skew, and nanosleep tests ensures time behaves properly. 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/change_skew.c | 93 ++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/timers/change_skew.c diff --git a/tools/testing/selftests/timers/Makefile b/tools/testing/selftests/timers/Makefile index 4e3eef6..c3e32f1 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 + alarmtimer-suspend change_skew all: ${bins} @@ -24,6 +24,7 @@ run_tests: all run_destructive_tests: run_tests ./alarmtimer-suspend ./valid-adjtimex + ./change_skew clean: rm -f ${bins} diff --git a/tools/testing/selftests/timers/change_skew.c b/tools/testing/selftests/timers/change_skew.c new file mode 100644 index 0000000..454cfca --- /dev/null +++ b/tools/testing/selftests/timers/change_skew.c @@ -0,0 +1,93 @@ +/* ADJ_FREQ Skew change 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 and + * then uses other tests to detect problems. Thus this test requires + * that the raw_skew, inconsistency-check and nanosleep tests be + * present in the same directory it is run from. + * + * To build: + * $ gcc change_skew.c -o change_skew -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 + +#define NSEC_PER_SEC 1000000000LL + + +int change_skew_test(int ppm) +{ + struct timex tx; + int ret; + + tx.modes = ADJ_FREQUENCY; + tx.freq = ppm << 16; + + ret = adjtimex(&tx); + if (ret < 0) { + printf("Error adjusting freq\n"); + return ret; + } + + ret = system("./raw_skew"); + ret |= system("./inconsistency-check"); + ret |= system("./nanosleep"); + + return ret; +} + + +int main(int argv, char** argc) +{ + struct timex tx; + int i, ret; + + int ppm[5] = {0, 250, 500, -250, -500}; + + /* Kill ntpd */ + system("killall -9 ntpd"); + + /* Make sure there's no offset adjustment going on */ + tx.modes = ADJ_OFFSET; + tx.offset = 0; + ret = adjtimex(&tx); + + if (ret < 0) { + printf("Maybe you're not running as root?\n"); + return -1; + } + + for (i=0; i < 5; i++) { + printf("Using %i ppm adjustment\n", ppm[i]); + ret = change_skew_test(ppm[i]); + if (ret) + break; + } + + /* Set things back */ + tx.modes = ADJ_FREQUENCY; + tx.offset = 0; + adjtimex(&tx); + + if (ret) + printf("[FAIL]"); + else + printf("[OK]"); + return ret; +}