tools/testing/selftests/proc/proc-uptime-001.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/proc/proc-uptime-001.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/proc/proc-uptime-001.c- Extension
.c- Size
- 1638 bytes
- Lines
- 59
- 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.
Dependency Surface
assert.hstdint.hsys/types.hsys/stat.hfcntl.hproc-uptime.h
Detected Declarations
function main
Annotated Snippet
// Test that boottime value in /proc/uptime and CLOCK_BOOTTIME increment
// monotonically. We don't test idle time monotonicity due to broken iowait
// task counting, cf: comment above get_cpu_idle_time_us()
#undef NDEBUG
#include <assert.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "proc-uptime.h"
int main(void)
{
uint64_t start, u0, u1, c0, c1;
int fd;
fd = open("/proc/uptime", O_RDONLY);
assert(fd >= 0);
u0 = proc_uptime(fd);
start = u0;
c0 = clock_boottime();
do {
u1 = proc_uptime(fd);
c1 = clock_boottime();
/* Is /proc/uptime monotonic ? */
assert(u1 >= u0);
/* Is CLOCK_BOOTTIME monotonic ? */
assert(c1 >= c0);
/* Is CLOCK_BOOTTIME VS /proc/uptime monotonic ? */
assert(c0 >= u0);
u0 = u1;
c0 = c1;
} while (u1 - start < 100);
return 0;
}
Annotation
- Immediate include surface: `assert.h`, `stdint.h`, `sys/types.h`, `sys/stat.h`, `fcntl.h`, `proc-uptime.h`.
- Detected declarations: `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.