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