tools/testing/selftests/alsa/utimer-test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/alsa/utimer-test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/alsa/utimer-test.c- Extension
.c- Size
- 4197 bytes
- Lines
- 173
- 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
kselftest_harness.hsound/asound.hunistd.hfcntl.hlimits.hsys/ioctl.hstdlib.hpthread.hstring.herrno.h
Detected Declarations
enum timer_app_eventfunction parse_timer_outputfunction parse_timer_result
Annotated Snippet
switch (parse_timer_output(buf)) {
case TIMER_APP_STARTED:
/* global-timer waits for timer to trigger, so start the ticking thread */
pthread_create(&ticking_thread, NULL, ticking_func,
&self->utimer_info->fd);
break;
case TIMER_APP_RESULT:
total_ticks = parse_timer_result(buf);
break;
case TIMER_NO_EVENT:
break;
}
}
pthread_join(ticking_thread, NULL);
ASSERT_EQ(total_ticks, TICKS_COUNT);
pclose(rfp);
free(buf);
}
TEST(wrong_timers_test) {
int timer_dev_fd;
int utimer_fd;
struct snd_timer_uinfo wrong_timer = {
.resolution = 0,
.id = UTIMER_DEFAULT_ID,
.fd = UTIMER_DEFAULT_FD,
};
timer_dev_fd = open("/dev/snd/timer", O_RDONLY);
ASSERT_GE(timer_dev_fd, 0);
utimer_fd = ioctl(timer_dev_fd, SNDRV_TIMER_IOCTL_CREATE, &wrong_timer);
ASSERT_LT(utimer_fd, 0);
/* Check that id was not updated */
ASSERT_EQ(wrong_timer.id, UTIMER_DEFAULT_ID);
/* Test the NULL as an argument is processed correctly */
ASSERT_LT(ioctl(timer_dev_fd, SNDRV_TIMER_IOCTL_CREATE, NULL), 0);
close(timer_dev_fd);
}
TEST_HARNESS_MAIN
Annotation
- Immediate include surface: `kselftest_harness.h`, `sound/asound.h`, `unistd.h`, `fcntl.h`, `limits.h`, `sys/ioctl.h`, `stdlib.h`, `pthread.h`.
- Detected declarations: `enum timer_app_event`, `function parse_timer_output`, `function parse_timer_result`.
- 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.