0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #include <stdio.h>
0019 #include <stdlib.h>
0020 #include <time.h>
0021 #include <sys/time.h>
0022 #include <sys/timex.h>
0023 #include <string.h>
0024 #include <signal.h>
0025 #include <unistd.h>
0026 #include "../kselftest.h"
0027
0028 int set_tai(int offset)
0029 {
0030 struct timex tx;
0031
0032 memset(&tx, 0, sizeof(tx));
0033
0034 tx.modes = ADJ_TAI;
0035 tx.constant = offset;
0036
0037 return adjtimex(&tx);
0038 }
0039
0040 int get_tai(void)
0041 {
0042 struct timex tx;
0043
0044 memset(&tx, 0, sizeof(tx));
0045
0046 adjtimex(&tx);
0047 return tx.tai;
0048 }
0049
0050 int main(int argc, char **argv)
0051 {
0052 int i, ret;
0053
0054 ret = get_tai();
0055 printf("tai offset started at %i\n", ret);
0056
0057 printf("Checking tai offsets can be properly set: ");
0058 fflush(stdout);
0059 for (i = 1; i <= 60; i++) {
0060 ret = set_tai(i);
0061 ret = get_tai();
0062 if (ret != i) {
0063 printf("[FAILED] expected: %i got %i\n", i, ret);
0064 return ksft_exit_fail();
0065 }
0066 }
0067 printf("[OK]\n");
0068 return ksft_exit_pass();
0069 }