1// SPDX-License-Identifier: GPL-2.0 2 3/* 4 * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved. 5 * AUTHOR: Saji Kumar.V.R <saji.kumar@wipro.com> 6 */ 7 8#include <errno.h> 9#include <sys/timex.h> 10#include "tst_test.h" 11 12#define SET_MODE (ADJ_OFFSET | ADJ_FREQUENCY | ADJ_MAXERROR | ADJ_ESTERROR | \ 13 ADJ_STATUS | ADJ_TIMECONST | ADJ_TICK) 14 15static struct timex *tim_save; 16static struct timex *buf; 17 18void verify_adjtimex(void) 19{ 20 *buf = *tim_save; 21 buf->modes = SET_MODE; 22 TEST(adjtimex(buf)); 23 if ((TST_RET >= TIME_OK) && (TST_RET <= TIME_ERROR)) { 24 tst_res(TPASS, "adjtimex() with mode 0x%x ", SET_MODE); 25 } else { 26 tst_res(TFAIL | TTERRNO, "adjtimex() with mode 0x%x ", 27 SET_MODE); 28 } 29 30 buf->modes = ADJ_OFFSET_SINGLESHOT; 31 TEST(adjtimex(buf)); 32 if ((TST_RET >= TIME_OK) && (TST_RET <= TIME_ERROR)) { 33 tst_res(TPASS, "adjtimex() with mode 0x%x ", 34 ADJ_OFFSET_SINGLESHOT); 35 } else { 36 tst_res(TFAIL | TTERRNO, 37 "adjtimex() with mode 0x%x ", 38 ADJ_OFFSET_SINGLESHOT); 39 } 40} 41 42static void setup(void) 43{ 44 tim_save->modes = 0; 45 46 /* Save current parameters */ 47 if ((adjtimex(tim_save)) == -1) { 48 tst_brk(TBROK | TERRNO, 49 "adjtimex(): failed to save current params"); 50 } 51} 52 53static struct tst_test test = { 54 .needs_root = 1, 55 .setup = setup, 56 .test_all = verify_adjtimex, 57 .bufs = (struct tst_buffers []) { 58 {&buf, .size = sizeof(*buf)}, 59 {&tim_save, .size = sizeof(*tim_save)}, 60 {}, 61 } 62}; 63