[CRIU] [PATCH 12/12] posix-timer: Remove periodic test, test non consequent timer ids
Pavel Tikhomirov
snorcht at gmail.com
Wed May 29 19:36:21 EDT 2013
Explanation of remove periodic test is that we can't set overrun for
timer, so all checks will fail in case of big overrun before dump.
Add fake timers to inshure that then timer ids don't go one after
another c/r go well.
Signed-off-by: Pavel Tikhomirov <snorcht at gmail.com>
---
test/zdtm/live/static/posix_timers.c | 37 ++++++++++++++++------------------
1 file changed, 17 insertions(+), 20 deletions(-)
diff --git a/test/zdtm/live/static/posix_timers.c b/test/zdtm/live/static/posix_timers.c
index ae9a882..5ee9b87 100644
--- a/test/zdtm/live/static/posix_timers.c
+++ b/test/zdtm/live/static/posix_timers.c
@@ -19,14 +19,10 @@ sigset_t mask;
#define MAX_TIMER_DISPLACEMENT 10
-static void realtime_periodic_handler(int sig, siginfo_t *si, void *uc);
-static void monotonic_periodic_handler(int sig, siginfo_t *si, void *uc);
static void realtime_oneshot_handler(int sig, siginfo_t *si, void *uc);
static void monotonic_oneshot_handler(int sig, siginfo_t *si, void *uc);
enum {
- REALTIME_PERIODIC_INFO,
- MONOTONIC_PERIODIC_INFO,
REALTIME_ONESHOT_INFO,
MONOTONIC_ONESHOT_INFO,
};
@@ -45,10 +41,6 @@ static struct posix_timers_info {
int overrun;
struct timespec start, end;
} posix_timers[] = {
- [REALTIME_PERIODIC_INFO] = {CLOCK_REALTIME, "REALTIME (periodic)",
- realtime_periodic_handler, SIGALRM, 0, 1},
- [MONOTONIC_PERIODIC_INFO] = {CLOCK_MONOTONIC, "MONOTONIC (periodic)",
- monotonic_periodic_handler, SIGINT, 0, 3},
[REALTIME_ONESHOT_INFO] = {CLOCK_REALTIME, "REALTIME (oneshot)",
realtime_oneshot_handler, SIGUSR1, 1, INT_MAX},
[MONOTONIC_ONESHOT_INFO] = {CLOCK_MONOTONIC, "MONOTONIC (oneshot)",
@@ -179,24 +171,12 @@ static void generic_handler(struct posix_timers_info *info,
info->handler_cnt++;
}
-static void monotonic_periodic_handler(int sig, siginfo_t *si, void *uc)
-{
- generic_handler(si->si_value.sival_ptr,
- &posix_timers[MONOTONIC_PERIODIC_INFO], sig);
-}
-
static void monotonic_oneshot_handler(int sig, siginfo_t *si, void *uc)
{
generic_handler(si->si_value.sival_ptr,
&posix_timers[MONOTONIC_ONESHOT_INFO], sig);
}
-static void realtime_periodic_handler(int sig, siginfo_t *si, void *uc)
-{
- generic_handler(si->si_value.sival_ptr,
- &posix_timers[REALTIME_PERIODIC_INFO], sig);
-}
-
static void realtime_oneshot_handler(int sig, siginfo_t *si, void *uc)
{
generic_handler(si->si_value.sival_ptr,
@@ -205,6 +185,8 @@ static void realtime_oneshot_handler(int sig, siginfo_t *si, void *uc)
static int setup_timers(void)
{
+ int i;
+ int ret;
struct posix_timers_info *info = posix_timers;
struct sigevent sev;
struct itimerspec its;
@@ -222,6 +204,21 @@ static int setup_timers(void)
info = posix_timers;
while(info->handler) {
+ /* Add and delete fake timers to test restoring 'with holes' */
+ timer_t timeridt;
+ for (i = 0; i < 10; i++) {
+ ret = timer_create(CLOCK_REALTIME, NULL, &timeridt);
+ if (ret < 0) {
+ err("Can't create temporary posix timer %lx\n", (long) timeridt);
+ return -errno;
+ }
+ ret = timer_delete(timeridt);
+ if (ret < 0) {
+ err("Can't remove temporaty posix timer %lx\n", (long) timeridt);
+ return -errno;
+ }
+ }
+
info->sa.sa_flags = SA_SIGINFO;
info->sa.sa_sigaction = info->handler;
sigemptyset(&info->sa.sa_mask);
--
1.7.9.5
More information about the CRIU
mailing list