Skip to content

Commit

Permalink
test: zdtm: Enhance timers test with multiple timer configurations
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hckuo authored Jan 8, 2025
1 parent 1635543 commit d5ca42b
Showing 1 changed file with 21 additions and 11 deletions.
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;
}

0 comments on commit d5ca42b

Please sign in to comment.