tools/testing/selftests/timers/inconsistency-check.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/timers/inconsistency-check.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/timers/inconsistency-check.c- Extension
.c- Size
- 4710 bytes
- Lines
- 187
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdio.hunistd.hstdlib.htime.hsys/time.hsys/timex.hstring.hsignal.hinclude/vdso/time64.hkselftest.h
Detected Declarations
function in_orderfunction consistency_testfunction main
Annotated Snippet
if (inconsistent >= 0) {
unsigned long long delta;
ksft_print_msg("\%s\n", start_str);
for (i = 0; i < CALLS_PER_LOOP; i++) {
if (i == inconsistent)
ksft_print_msg("--------------------\n");
ksft_print_msg("%lu:%lu\n", list[i].tv_sec,
list[i].tv_nsec);
if (i == inconsistent + 1)
ksft_print_msg("--------------------\n");
}
delta = list[inconsistent].tv_sec * NSEC_PER_SEC;
delta += list[inconsistent].tv_nsec;
delta -= list[inconsistent+1].tv_sec * NSEC_PER_SEC;
delta -= list[inconsistent+1].tv_nsec;
ksft_print_msg("Delta: %llu ns\n", delta);
fflush(0);
/* timestamp inconsistency*/
t = time(0);
ksft_print_msg("%s\n", ctime(&t));
return -1;
}
now = list[0].tv_sec;
}
return 0;
}
int main(int argc, char *argv[])
{
int clockid, opt;
int userclock = CLOCK_REALTIME;
int maxclocks = CLOCK_TAI + 1;
int runtime = 10;
struct timespec ts;
/* Process arguments */
while ((opt = getopt(argc, argv, "t:c:")) != -1) {
switch (opt) {
case 't':
runtime = atoi(optarg);
break;
case 'c':
userclock = atoi(optarg);
maxclocks = userclock + 1;
break;
default:
printf("Usage: %s [-t <secs>] [-c <clockid>]\n", argv[0]);
printf(" -t: Number of seconds to run\n");
printf(" -c: clockid to use (default, all clockids)\n");
exit(-1);
}
}
setbuf(stdout, NULL);
ksft_print_header();
ksft_set_plan(maxclocks - userclock);
for (clockid = userclock; clockid < maxclocks; clockid++) {
if (clockid == CLOCK_HWSPECIFIC || clock_gettime(clockid, &ts)) {
ksft_test_result_skip("%-31s\n", clockstring(clockid));
continue;
}
if (consistency_test(clockid, runtime)) {
ksft_test_result_fail("%-31s\n", clockstring(clockid));
ksft_exit_fail();
} else {
ksft_test_result_pass("%-31s\n", clockstring(clockid));
}
}
ksft_exit_pass();
}
Annotation
- Immediate include surface: `stdio.h`, `unistd.h`, `stdlib.h`, `time.h`, `sys/time.h`, `sys/timex.h`, `string.h`, `signal.h`.
- Detected declarations: `function in_order`, `function consistency_test`, `function main`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.