Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced Timer Handling and Testing for One Shot Timer #2562

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: zdtm: Enhance timers test with multiple timer configurations
This commit improves the timers test in ZDTM (Zero Downtime Migration) by introducing multiple timer configurations. The changes include:

- Refactoring setup_timers() to accept a timer configuration parameter.
- Adding a one-shot timer configuration alongside the existing periodic timer.
- Running the test twice with different timer configurations.

Signed-off-by: Austin Kuo <hsuanchikuo@gmail.com>
  • Loading branch information
hckuo committed Jan 10, 2025
commit c20a4cfa3a403558dd702942cf02b51b36c01f30
32 changes: 21 additions & 11 deletions test/zdtm/static/timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,17 @@ static void timer_tick(int sig)
}
}

static void setup_timers(void)
static void setup_timers(const struct itimerval *tv)
{
int i;
struct itimerval tv = {
.it_interval = { .tv_sec = 0, .tv_usec = 100000 },
.it_value = { .tv_sec = 0, .tv_usec = 100 },
};

for (i = 0; i < NUM_TIMERS; i++) {
if (signal(timer_tests[i].signal, timer_tick) == SIG_ERR) {
pr_perror("can't set signal handler %d", i);
exit(1);
}

if (setitimer(timer_tests[i].timer_type, &tv, NULL) < 0) {
if (setitimer(timer_tests[i].timer_type, tv, NULL) < 0) {
pr_perror("can't set timer %d", i);
exit(1);
}
Expand Down Expand Up @@ -77,13 +73,27 @@ static void check_timers(void)

int main(int argc, char **argv)
{
test_init(argc, argv);
const struct itimerval tv = {
.it_interval = { .tv_sec = 0, .tv_usec = 100000 },
.it_value = { .tv_sec = 0, .tv_usec = 100 },
};
const struct itimerval oneshot_tv = {
.it_interval = { .tv_sec = 0, .tv_usec = 0 },
.it_value = { .tv_sec = 1, .tv_usec = 100 },
};
const struct itimerval tvs[2] = {
tv,
oneshot_tv,
};

setup_timers();
test_init(argc, argv);
for (int i = 0; i < 2; i++) {
setup_timers(&tvs[i]);

test_daemon();
test_waitsig();
test_daemon();
test_waitsig();

check_timers();
check_timers();
}
return 0;
}
Loading