Linux Audio

Check our new training course

Loading...
v6.13.7
 1/* ADJ_FREQ Skew consistency test
 2 *		by: john stultz (johnstul@us.ibm.com)
 3 *		(C) Copyright IBM 2012
 4 *		Licensed under the GPLv2
 5 *
 6 *  NOTE: This is a meta-test which cranks the ADJ_FREQ knob back
 7 *  and forth and watches for consistency problems. Thus this test requires
 8 *  that the inconsistency-check tests be present in the same directory it
 9 *  is run from.
10 *
11 *  To build:
12 *	$ gcc skew_consistency.c -o skew_consistency -lrt
13 *
14 *   This program is free software: you can redistribute it and/or modify
15 *   it under the terms of the GNU General Public License as published by
16 *   the Free Software Foundation, either version 2 of the License, or
17 *   (at your option) any later version.
18 *
19 *   This program is distributed in the hope that it will be useful,
20 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
21 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 *   GNU General Public License for more details.
23 */
24
25
26#include <stdio.h>
27#include <stdlib.h>
28#include <unistd.h>
29#include <sys/time.h>
30#include <sys/timex.h>
31#include <time.h>
32#include <sys/types.h>
33#include <sys/stat.h>
34#include <fcntl.h>
 
35#include <string.h>
36#include <sys/wait.h>
37#include "../kselftest.h"
38
39int main(int argc, char **argv)
 
 
40{
41	struct timex tx;
42	int ret, ppm;
43	pid_t pid;
44
45
46	printf("Running Asynchronous Frequency Changing Tests...\n");
47
48	pid = fork();
49	if (!pid)
50		return system("./inconsistency-check -c 1 -t 600");
51
52	ppm = 500;
53	ret = 0;
54
55	while (pid != waitpid(pid, &ret, WNOHANG)) {
56		ppm = -ppm;
57		tx.modes = ADJ_FREQUENCY;
58		tx.freq = ppm << 16;
59		adjtimex(&tx);
60		usleep(500000);
61	}
62
63	/* Set things back */
64	tx.modes = ADJ_FREQUENCY;
65	tx.offset = 0;
66	adjtimex(&tx);
67
68
69	if (ret) {
70		printf("[FAILED]\n");
71		ksft_exit_fail();
72	}
73	printf("[OK]\n");
74	ksft_exit_pass();
75}
v4.17
 1/* ADJ_FREQ Skew consistency test
 2 *		by: john stultz (johnstul@us.ibm.com)
 3 *		(C) Copyright IBM 2012
 4 *		Licensed under the GPLv2
 5 *
 6 *  NOTE: This is a meta-test which cranks the ADJ_FREQ knob back
 7 *  and forth and watches for consistency problems. Thus this test requires
 8 *  that the inconsistency-check tests be present in the same directory it
 9 *  is run from.
10 *
11 *  To build:
12 *	$ gcc skew_consistency.c -o skew_consistency -lrt
13 *
14 *   This program is free software: you can redistribute it and/or modify
15 *   it under the terms of the GNU General Public License as published by
16 *   the Free Software Foundation, either version 2 of the License, or
17 *   (at your option) any later version.
18 *
19 *   This program is distributed in the hope that it will be useful,
20 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
21 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 *   GNU General Public License for more details.
23 */
24
25
26#include <stdio.h>
27#include <stdlib.h>
28#include <unistd.h>
29#include <sys/time.h>
30#include <sys/timex.h>
31#include <time.h>
32#include <sys/types.h>
33#include <sys/stat.h>
34#include <fcntl.h>
35#include <stdlib.h>
36#include <string.h>
37#include <sys/wait.h>
38#include "../kselftest.h"
39
40#define NSEC_PER_SEC 1000000000LL
41
42int main(int argv, char **argc)
43{
44	struct timex tx;
45	int ret, ppm;
46	pid_t pid;
47
48
49	printf("Running Asynchronous Frequency Changing Tests...\n");
50
51	pid = fork();
52	if (!pid)
53		return system("./inconsistency-check -c 1 -t 600");
54
55	ppm = 500;
56	ret = 0;
57
58	while (pid != waitpid(pid, &ret, WNOHANG)) {
59		ppm = -ppm;
60		tx.modes = ADJ_FREQUENCY;
61		tx.freq = ppm << 16;
62		adjtimex(&tx);
63		usleep(500000);
64	}
65
66	/* Set things back */
67	tx.modes = ADJ_FREQUENCY;
68	tx.offset = 0;
69	adjtimex(&tx);
70
71
72	if (ret) {
73		printf("[FAILED]\n");
74		return ksft_exit_fail();
75	}
76	printf("[OK]\n");
77	return ksft_exit_pass();
78}