Back to home page

OSCL-LXR

 
 

    


0001 /* ADJ_FREQ Skew consistency test
0002  *      by: john stultz (johnstul@us.ibm.com)
0003  *      (C) Copyright IBM 2012
0004  *      Licensed under the GPLv2
0005  *
0006  *  NOTE: This is a meta-test which cranks the ADJ_FREQ knob back
0007  *  and forth and watches for consistency problems. Thus this test requires
0008  *  that the inconsistency-check tests be present in the same directory it
0009  *  is run from.
0010  *
0011  *  To build:
0012  *  $ gcc skew_consistency.c -o skew_consistency -lrt
0013  *
0014  *   This program is free software: you can redistribute it and/or modify
0015  *   it under the terms of the GNU General Public License as published by
0016  *   the Free Software Foundation, either version 2 of the License, or
0017  *   (at your option) any later version.
0018  *
0019  *   This program is distributed in the hope that it will be useful,
0020  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
0021  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0022  *   GNU General Public License for more details.
0023  */
0024 
0025 
0026 #include <stdio.h>
0027 #include <stdlib.h>
0028 #include <unistd.h>
0029 #include <sys/time.h>
0030 #include <sys/timex.h>
0031 #include <time.h>
0032 #include <sys/types.h>
0033 #include <sys/stat.h>
0034 #include <fcntl.h>
0035 #include <string.h>
0036 #include <sys/wait.h>
0037 #include "../kselftest.h"
0038 
0039 #define NSEC_PER_SEC 1000000000LL
0040 
0041 int main(int argc, char **argv)
0042 {
0043     struct timex tx;
0044     int ret, ppm;
0045     pid_t pid;
0046 
0047 
0048     printf("Running Asynchronous Frequency Changing Tests...\n");
0049 
0050     pid = fork();
0051     if (!pid)
0052         return system("./inconsistency-check -c 1 -t 600");
0053 
0054     ppm = 500;
0055     ret = 0;
0056 
0057     while (pid != waitpid(pid, &ret, WNOHANG)) {
0058         ppm = -ppm;
0059         tx.modes = ADJ_FREQUENCY;
0060         tx.freq = ppm << 16;
0061         adjtimex(&tx);
0062         usleep(500000);
0063     }
0064 
0065     /* Set things back */
0066     tx.modes = ADJ_FREQUENCY;
0067     tx.offset = 0;
0068     adjtimex(&tx);
0069 
0070 
0071     if (ret) {
0072         printf("[FAILED]\n");
0073         return ksft_exit_fail();
0074     }
0075     printf("[OK]\n");
0076     return ksft_exit_pass();
0077 }