From patchwork Wed Feb 25 22:32:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 45148 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7638220502 for ; Wed, 25 Feb 2015 22:33:19 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id h11sf5620453wiw.1 for ; Wed, 25 Feb 2015 14:33:18 -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=fiKtXfmL1bUpsapaREqw7k43TIR2iIbcica21RndAXI=; b=VQIiyHGfKt96Ua9bumcZj2iq8sCZpf7aEnHm6BetWdauG9mC1eY6mHfJvGhsyrcyU8 SkuMnpiMcALjv7Zkj/cUP0jzjFCENzxaAq7u0dsuUeTiawtCB2kLFsjRKUDa2MkhHrWh rIm8e6HbSeWwfMoq6XIFIS5WIxDPFIjbyJKtP1QKLcPC2uAxYdwtS9enR7jR6RC/8YKw zUSKkKG1W+qTSZxQGBd8C26vmsp7GSvOGtchSPXiHlY9z7gf+toIsESIdNdC8PcGF8FQ mACL4yPWdIp2kRKJWqjgVDwixMWKOgpYTKaiSU2CFiUMzHnas64eusEZ+bUNt44CP+Y+ t5EQ== X-Gm-Message-State: ALoCoQmiQVxjU0cUdSLti5HCNU0nQTpJt1bxBqUUYOP6RyA6RvkjPx6OAkSiEKvCnaq605Mj/eoP X-Received: by 10.112.9.65 with SMTP id x1mr853557lba.16.1424903598782; Wed, 25 Feb 2015 14:33:18 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.205.99 with SMTP id lf3ls457703lac.4.gmail; Wed, 25 Feb 2015 14:33:18 -0800 (PST) X-Received: by 10.152.29.102 with SMTP id j6mr5038550lah.12.1424903598643; Wed, 25 Feb 2015 14:33:18 -0800 (PST) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id dc10si21062225lad.77.2015.02.25.14.33.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Feb 2015 14:33:18 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by lams18 with SMTP id s18so7190687lam.11 for ; Wed, 25 Feb 2015 14:33:18 -0800 (PST) X-Received: by 10.112.204.197 with SMTP id la5mr4782877lbc.29.1424903598549; Wed, 25 Feb 2015 14:33:18 -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 h5csp2925053lbj; Wed, 25 Feb 2015 14:33:17 -0800 (PST) X-Received: by 10.70.43.203 with SMTP id y11mr9208576pdl.143.1424903569158; Wed, 25 Feb 2015 14:32:49 -0800 (PST) Received: from mail-pa0-f54.google.com (mail-pa0-f54.google.com. [209.85.220.54]) by mx.google.com with ESMTPS id ku7si8866166pbc.172.2015.02.25.14.32.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Feb 2015 14:32:49 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.54 as permitted sender) client-ip=209.85.220.54; Received: by pablf10 with SMTP id lf10so8591337pab.12 for ; Wed, 25 Feb 2015 14:32:48 -0800 (PST) X-Received: by 10.68.194.38 with SMTP id ht6mr9528145pbc.36.1424903568286; Wed, 25 Feb 2015 14:32:48 -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.47 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Feb 2015 14:32:47 -0800 (PST) From: John Stultz To: Linux Kernel Mailing List Cc: John Stultz , Shuah Khan , Prarit Bhargava , Thomas Gleixner , Richard Cochran Subject: [PATCH 17/19] selftests/timers: Add set-tai from the timetest suite Date: Wed, 25 Feb 2015 14:32:22 -0800 Message-Id: <1424903544-26855-18-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.215.44 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 set-tai test which ensures the tai offset can be set properly from adjtimex. 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/set-tai.c | 67 ++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/timers/set-tai.c diff --git a/tools/testing/selftests/timers/Makefile b/tools/testing/selftests/timers/Makefile index e9486cd..3538d08 100644 --- a/tools/testing/selftests/timers/Makefile +++ b/tools/testing/selftests/timers/Makefile @@ -3,7 +3,7 @@ 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 skew_consistency clocksource-switch \ - leap-a-day leapcrash + leap-a-day leapcrash set-tai all: ${bins} @@ -30,6 +30,7 @@ run_destructive_tests: run_tests ./clocksource-switch ./leap-a-day -s -i 10 ./leapcrash + ./set-tai clean: rm -f ${bins} diff --git a/tools/testing/selftests/timers/set-tai.c b/tools/testing/selftests/timers/set-tai.c new file mode 100644 index 0000000..555e06d --- /dev/null +++ b/tools/testing/selftests/timers/set-tai.c @@ -0,0 +1,67 @@ +/* Set tai offset + * by: John Stultz + * (C) Copyright Linaro 2013 + * Licensed under the GPLv2 + * + * 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 + +int set_tai(int offset) +{ + struct timex tx; + + memset(&tx, 0, sizeof(tx)); + + tx.modes = ADJ_TAI; + tx.constant = offset; + + return adjtimex(&tx); +} + +int get_tai(void) +{ + struct timex tx; + + memset(&tx, 0, sizeof(tx)); + + adjtimex(&tx); + return tx.tai; +} + +int main(int argc, char **argv) +{ + int i, ret; + + ret = get_tai(); + printf("tai offset started at %i\n", ret); + + printf("Checking tai offsets can be properly set: "); + for (i = 1; i <= 60; i++) { + ret = set_tai(i); + ret = get_tai(); + if (ret != i) { + printf("[FAILED] expected: %i got %i\n", i, ret); + return -1; + } + } + printf("[OK]\n"); + return 0; +}