2 * QTest testcase for the ptimer
4 * Copyright (c) 2016 Dmitry Osipenko <digetx@gmail.com>
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
11 #include "qemu/osdep.h"
12 #include <glib/gprintf.h>
14 #include "qemu/main-loop.h"
15 #include "hw/ptimer.h"
18 #include "ptimer-test.h"
20 static bool triggered
;
22 static void ptimer_trigger(void *opaque
)
27 static void ptimer_test_expire_qemu_timers(int64_t expire_time
,
30 QEMUTimerList
*timer_list
= main_loop_tlg
.tl
[type
];
31 QEMUTimer
*t
= timer_list
->active_timers
.next
;
34 if (t
->expire_time
== expire_time
) {
46 static void ptimer_test_set_qemu_time_ns(int64_t ns
)
48 ptimer_test_time_ns
= ns
;
51 static void qemu_clock_step(uint64_t ns
)
53 int64_t deadline
= qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL
);
54 int64_t advanced_time
= qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL
) + ns
;
56 while (deadline
!= -1 && deadline
<= advanced_time
) {
57 ptimer_test_set_qemu_time_ns(deadline
);
58 ptimer_test_expire_qemu_timers(deadline
, QEMU_CLOCK_VIRTUAL
);
59 deadline
= qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL
);
62 ptimer_test_set_qemu_time_ns(advanced_time
);
65 static void check_set_count(gconstpointer arg
)
67 const uint8_t *policy
= arg
;
68 QEMUBH
*bh
= qemu_bh_new(ptimer_trigger
, NULL
);
69 ptimer_state
*ptimer
= ptimer_init(bh
, *policy
);
73 ptimer_set_count(ptimer
, 1000);
74 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, 1000);
75 g_assert_false(triggered
);
79 static void check_set_limit(gconstpointer arg
)
81 const uint8_t *policy
= arg
;
82 QEMUBH
*bh
= qemu_bh_new(ptimer_trigger
, NULL
);
83 ptimer_state
*ptimer
= ptimer_init(bh
, *policy
);
87 ptimer_set_limit(ptimer
, 1000, 0);
88 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, 0);
89 g_assert_cmpuint(ptimer_get_limit(ptimer
), ==, 1000);
90 g_assert_false(triggered
);
92 ptimer_set_limit(ptimer
, 2000, 1);
93 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, 2000);
94 g_assert_cmpuint(ptimer_get_limit(ptimer
), ==, 2000);
95 g_assert_false(triggered
);
99 static void check_oneshot(gconstpointer arg
)
101 const uint8_t *policy
= arg
;
102 QEMUBH
*bh
= qemu_bh_new(ptimer_trigger
, NULL
);
103 ptimer_state
*ptimer
= ptimer_init(bh
, *policy
);
104 bool no_round_down
= (*policy
& PTIMER_POLICY_NO_COUNTER_ROUND_DOWN
);
108 ptimer_set_period(ptimer
, 2000000);
109 ptimer_set_count(ptimer
, 10);
110 ptimer_run(ptimer
, 1);
112 qemu_clock_step(2000000 * 2 + 1);
114 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, no_round_down
? 8 : 7);
115 g_assert_false(triggered
);
119 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, no_round_down
? 8 : 7);
120 g_assert_false(triggered
);
122 qemu_clock_step(2000000 * 11);
124 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, no_round_down
? 8 : 7);
125 g_assert_false(triggered
);
127 ptimer_run(ptimer
, 1);
129 qemu_clock_step(2000000 * 7 + 1);
131 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, no_round_down
? 1 : 0);
134 g_assert_false(triggered
);
136 g_assert_true(triggered
);
141 qemu_clock_step(2000000);
143 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, 0);
146 g_assert_true(triggered
);
150 g_assert_false(triggered
);
153 qemu_clock_step(4000000);
155 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, 0);
156 g_assert_false(triggered
);
158 ptimer_set_count(ptimer
, 10);
160 qemu_clock_step(20000000 + 1);
162 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, 10);
163 g_assert_false(triggered
);
165 ptimer_set_limit(ptimer
, 9, 1);
167 qemu_clock_step(20000000 + 1);
169 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, 9);
170 g_assert_false(triggered
);
172 ptimer_run(ptimer
, 1);
174 qemu_clock_step(2000000 + 1);
176 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, no_round_down
? 8 : 7);
177 g_assert_false(triggered
);
179 ptimer_set_count(ptimer
, 20);
181 qemu_clock_step(2000000 * 19 + 1);
183 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, no_round_down
? 1 : 0);
184 g_assert_false(triggered
);
186 qemu_clock_step(2000000);
188 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, 0);
189 g_assert_true(triggered
);
195 qemu_clock_step(2000000 * 12 + 1);
197 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, 0);
198 g_assert_false(triggered
);
202 static void check_periodic(gconstpointer arg
)
204 const uint8_t *policy
= arg
;
205 QEMUBH
*bh
= qemu_bh_new(ptimer_trigger
, NULL
);
206 ptimer_state
*ptimer
= ptimer_init(bh
, *policy
);
207 bool wrap_policy
= (*policy
& PTIMER_POLICY_WRAP_AFTER_ONE_PERIOD
);
208 bool no_immediate_trigger
= (*policy
& PTIMER_POLICY_NO_IMMEDIATE_TRIGGER
);
209 bool no_immediate_reload
= (*policy
& PTIMER_POLICY_NO_IMMEDIATE_RELOAD
);
210 bool no_round_down
= (*policy
& PTIMER_POLICY_NO_COUNTER_ROUND_DOWN
);
214 ptimer_set_period(ptimer
, 2000000);
215 ptimer_set_limit(ptimer
, 10, 1);
216 ptimer_run(ptimer
, 0);
218 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, 10);
219 g_assert_false(triggered
);
223 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, no_round_down
? 10 : 9);
224 g_assert_false(triggered
);
226 qemu_clock_step(2000000 * 10 - 1);
228 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, wrap_policy
? 0 : 10);
229 g_assert_true(triggered
);
233 g_assert_cmpuint(ptimer_get_count(ptimer
), ==,
234 wrap_policy
? 0 : (no_round_down
? 10 : 9));
235 g_assert_true(triggered
);
239 qemu_clock_step(2000000);
241 g_assert_cmpuint(ptimer_get_count(ptimer
), ==,
242 (no_round_down
? 9 : 8) + (wrap_policy
? 1 : 0));
243 g_assert_false(triggered
);
245 ptimer_set_count(ptimer
, 20);
247 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, 20);
248 g_assert_false(triggered
);
252 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, no_round_down
? 20 : 19);
253 g_assert_false(triggered
);
255 qemu_clock_step(2000000 * 11 + 1);
257 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, no_round_down
? 9 : 8);
258 g_assert_false(triggered
);
260 qemu_clock_step(2000000 * 10);
262 g_assert_cmpuint(ptimer_get_count(ptimer
), ==,
263 (no_round_down
? 9 : 8) + (wrap_policy
? 1 : 0));
264 g_assert_true(triggered
);
268 ptimer_set_count(ptimer
, 3);
270 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, 3);
271 g_assert_false(triggered
);
275 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, no_round_down
? 3 : 2);
276 g_assert_false(triggered
);
278 qemu_clock_step(2000000 * 4);
280 g_assert_cmpuint(ptimer_get_count(ptimer
), ==,
281 (no_round_down
? 9 : 8) + (wrap_policy
? 1 : 0));
282 g_assert_true(triggered
);
287 qemu_clock_step(2000000);
289 g_assert_cmpuint(ptimer_get_count(ptimer
), ==,
290 (no_round_down
? 9 : 8) + (wrap_policy
? 1 : 0));
291 g_assert_false(triggered
);
293 ptimer_set_count(ptimer
, 3);
294 ptimer_run(ptimer
, 0);
296 qemu_clock_step(2000000 * 3 + 1);
298 g_assert_cmpuint(ptimer_get_count(ptimer
), ==,
299 wrap_policy
? 0 : (no_round_down
? 10 : 9));
300 g_assert_true(triggered
);
304 qemu_clock_step(2000000);
306 g_assert_cmpuint(ptimer_get_count(ptimer
), ==,
307 (no_round_down
? 9 : 8) + (wrap_policy
? 1 : 0));
308 g_assert_false(triggered
);
310 ptimer_set_count(ptimer
, 0);
311 g_assert_cmpuint(ptimer_get_count(ptimer
), ==,
312 no_immediate_reload
? 0 : 10);
314 if (no_immediate_trigger
) {
315 g_assert_false(triggered
);
317 g_assert_true(triggered
);
324 if (no_immediate_reload
) {
325 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, 0);
326 g_assert_false(triggered
);
328 qemu_clock_step(2000000);
330 if (no_immediate_trigger
) {
331 g_assert_true(triggered
);
333 g_assert_false(triggered
);
339 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, no_round_down
? 10 : 9);
340 g_assert_false(triggered
);
342 qemu_clock_step(2000000 * 12);
344 g_assert_cmpuint(ptimer_get_count(ptimer
), ==,
345 (no_round_down
? 8 : 7) + (wrap_policy
? 1 : 0));
346 g_assert_true(triggered
);
352 qemu_clock_step(2000000 * 10);
354 g_assert_cmpuint(ptimer_get_count(ptimer
), ==,
355 (no_round_down
? 8 : 7) + (wrap_policy
? 1 : 0));
356 g_assert_false(triggered
);
358 ptimer_run(ptimer
, 0);
359 ptimer_set_period(ptimer
, 0);
361 qemu_clock_step(2000000 + 1);
363 g_assert_cmpuint(ptimer_get_count(ptimer
), ==,
364 (no_round_down
? 8 : 7) + (wrap_policy
? 1 : 0));
365 g_assert_false(triggered
);
369 static void check_on_the_fly_mode_change(gconstpointer arg
)
371 const uint8_t *policy
= arg
;
372 QEMUBH
*bh
= qemu_bh_new(ptimer_trigger
, NULL
);
373 ptimer_state
*ptimer
= ptimer_init(bh
, *policy
);
374 bool wrap_policy
= (*policy
& PTIMER_POLICY_WRAP_AFTER_ONE_PERIOD
);
375 bool no_round_down
= (*policy
& PTIMER_POLICY_NO_COUNTER_ROUND_DOWN
);
379 ptimer_set_period(ptimer
, 2000000);
380 ptimer_set_limit(ptimer
, 10, 1);
381 ptimer_run(ptimer
, 1);
383 qemu_clock_step(2000000 * 9 + 1);
385 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, no_round_down
? 1 : 0);
386 g_assert_false(triggered
);
388 ptimer_run(ptimer
, 0);
390 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, no_round_down
? 1 : 0);
391 g_assert_false(triggered
);
393 qemu_clock_step(2000000);
395 g_assert_cmpuint(ptimer_get_count(ptimer
), ==,
396 wrap_policy
? 0 : (no_round_down
? 10 : 9));
397 g_assert_true(triggered
);
401 qemu_clock_step(2000000 * 9);
403 ptimer_run(ptimer
, 1);
405 g_assert_cmpuint(ptimer_get_count(ptimer
), ==,
406 (no_round_down
? 1 : 0) + (wrap_policy
? 1 : 0));
407 g_assert_false(triggered
);
409 qemu_clock_step(2000000 * 3);
411 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, 0);
412 g_assert_true(triggered
);
416 static void check_on_the_fly_period_change(gconstpointer arg
)
418 const uint8_t *policy
= arg
;
419 QEMUBH
*bh
= qemu_bh_new(ptimer_trigger
, NULL
);
420 ptimer_state
*ptimer
= ptimer_init(bh
, *policy
);
421 bool no_round_down
= (*policy
& PTIMER_POLICY_NO_COUNTER_ROUND_DOWN
);
425 ptimer_set_period(ptimer
, 2000000);
426 ptimer_set_limit(ptimer
, 8, 1);
427 ptimer_run(ptimer
, 1);
429 qemu_clock_step(2000000 * 4 + 1);
431 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, no_round_down
? 4 : 3);
432 g_assert_false(triggered
);
434 ptimer_set_period(ptimer
, 4000000);
435 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, no_round_down
? 4 : 3);
437 qemu_clock_step(4000000 * 2 + 1);
439 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, no_round_down
? 2 : 0);
440 g_assert_false(triggered
);
442 qemu_clock_step(4000000 * 2);
444 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, 0);
445 g_assert_true(triggered
);
449 static void check_on_the_fly_freq_change(gconstpointer arg
)
451 const uint8_t *policy
= arg
;
452 QEMUBH
*bh
= qemu_bh_new(ptimer_trigger
, NULL
);
453 ptimer_state
*ptimer
= ptimer_init(bh
, *policy
);
454 bool no_round_down
= (*policy
& PTIMER_POLICY_NO_COUNTER_ROUND_DOWN
);
458 ptimer_set_freq(ptimer
, 500);
459 ptimer_set_limit(ptimer
, 8, 1);
460 ptimer_run(ptimer
, 1);
462 qemu_clock_step(2000000 * 4 + 1);
464 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, no_round_down
? 4 : 3);
465 g_assert_false(triggered
);
467 ptimer_set_freq(ptimer
, 250);
468 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, no_round_down
? 4 : 3);
470 qemu_clock_step(2000000 * 4 + 1);
472 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, no_round_down
? 2 : 0);
473 g_assert_false(triggered
);
475 qemu_clock_step(2000000 * 4);
477 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, 0);
478 g_assert_true(triggered
);
482 static void check_run_with_period_0(gconstpointer arg
)
484 const uint8_t *policy
= arg
;
485 QEMUBH
*bh
= qemu_bh_new(ptimer_trigger
, NULL
);
486 ptimer_state
*ptimer
= ptimer_init(bh
, *policy
);
490 ptimer_set_count(ptimer
, 99);
491 ptimer_run(ptimer
, 1);
493 qemu_clock_step(10 * NANOSECONDS_PER_SECOND
);
495 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, 99);
496 g_assert_false(triggered
);
500 static void check_run_with_delta_0(gconstpointer arg
)
502 const uint8_t *policy
= arg
;
503 QEMUBH
*bh
= qemu_bh_new(ptimer_trigger
, NULL
);
504 ptimer_state
*ptimer
= ptimer_init(bh
, *policy
);
505 bool wrap_policy
= (*policy
& PTIMER_POLICY_WRAP_AFTER_ONE_PERIOD
);
506 bool no_immediate_trigger
= (*policy
& PTIMER_POLICY_NO_IMMEDIATE_TRIGGER
);
507 bool no_immediate_reload
= (*policy
& PTIMER_POLICY_NO_IMMEDIATE_RELOAD
);
508 bool no_round_down
= (*policy
& PTIMER_POLICY_NO_COUNTER_ROUND_DOWN
);
512 ptimer_set_period(ptimer
, 2000000);
513 ptimer_set_limit(ptimer
, 99, 0);
514 ptimer_run(ptimer
, 1);
515 g_assert_cmpuint(ptimer_get_count(ptimer
), ==,
516 no_immediate_reload
? 0 : 99);
518 if (no_immediate_trigger
) {
519 g_assert_false(triggered
);
521 g_assert_true(triggered
);
526 if (no_immediate_trigger
|| no_immediate_reload
) {
527 qemu_clock_step(2000000 + 1);
529 g_assert_cmpuint(ptimer_get_count(ptimer
), ==,
530 no_immediate_reload
? 0 : (no_round_down
? 98 : 97));
532 if (no_immediate_trigger
&& no_immediate_reload
) {
533 g_assert_true(triggered
);
537 g_assert_false(triggered
);
540 ptimer_set_count(ptimer
, 99);
541 ptimer_run(ptimer
, 1);
544 qemu_clock_step(2000000 + 1);
546 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, no_round_down
? 98 : 97);
547 g_assert_false(triggered
);
549 qemu_clock_step(2000000 * 97);
551 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, no_round_down
? 1 : 0);
552 g_assert_false(triggered
);
554 qemu_clock_step(2000000 * 2);
556 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, 0);
557 g_assert_true(triggered
);
561 ptimer_set_count(ptimer
, 0);
562 ptimer_run(ptimer
, 0);
563 g_assert_cmpuint(ptimer_get_count(ptimer
), ==,
564 no_immediate_reload
? 0 : 99);
566 if (no_immediate_trigger
) {
567 g_assert_false(triggered
);
569 g_assert_true(triggered
);
576 if (no_immediate_reload
) {
577 qemu_clock_step(2000000);
580 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, no_round_down
? 99 : 98);
582 if (no_immediate_reload
&& no_immediate_trigger
) {
583 g_assert_true(triggered
);
585 g_assert_false(triggered
);
590 qemu_clock_step(2000000);
592 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, no_round_down
? 98 : 97);
593 g_assert_false(triggered
);
595 qemu_clock_step(2000000 * 98);
597 g_assert_cmpuint(ptimer_get_count(ptimer
), ==,
598 wrap_policy
? 0 : (no_round_down
? 99 : 98));
599 g_assert_true(triggered
);
605 static void check_periodic_with_load_0(gconstpointer arg
)
607 const uint8_t *policy
= arg
;
608 QEMUBH
*bh
= qemu_bh_new(ptimer_trigger
, NULL
);
609 ptimer_state
*ptimer
= ptimer_init(bh
, *policy
);
610 bool continuous_trigger
= (*policy
& PTIMER_POLICY_CONTINUOUS_TRIGGER
);
611 bool no_immediate_trigger
= (*policy
& PTIMER_POLICY_NO_IMMEDIATE_TRIGGER
);
615 ptimer_set_period(ptimer
, 2000000);
616 ptimer_run(ptimer
, 0);
618 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, 0);
620 if (no_immediate_trigger
) {
621 g_assert_false(triggered
);
623 g_assert_true(triggered
);
628 qemu_clock_step(2000000 + 1);
630 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, 0);
632 if (continuous_trigger
|| no_immediate_trigger
) {
633 g_assert_true(triggered
);
635 g_assert_false(triggered
);
640 ptimer_set_count(ptimer
, 10);
641 ptimer_run(ptimer
, 0);
643 qemu_clock_step(2000000 * 10 + 1);
645 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, 0);
646 g_assert_true(triggered
);
650 qemu_clock_step(2000000 + 1);
652 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, 0);
654 if (continuous_trigger
) {
655 g_assert_true(triggered
);
657 g_assert_false(triggered
);
664 static void check_oneshot_with_load_0(gconstpointer arg
)
666 const uint8_t *policy
= arg
;
667 QEMUBH
*bh
= qemu_bh_new(ptimer_trigger
, NULL
);
668 ptimer_state
*ptimer
= ptimer_init(bh
, *policy
);
669 bool no_immediate_trigger
= (*policy
& PTIMER_POLICY_NO_IMMEDIATE_TRIGGER
);
673 ptimer_set_period(ptimer
, 2000000);
674 ptimer_run(ptimer
, 1);
676 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, 0);
678 if (no_immediate_trigger
) {
679 g_assert_false(triggered
);
681 g_assert_true(triggered
);
686 qemu_clock_step(2000000 + 1);
688 g_assert_cmpuint(ptimer_get_count(ptimer
), ==, 0);
690 if (no_immediate_trigger
) {
691 g_assert_true(triggered
);
693 g_assert_false(triggered
);
699 static void add_ptimer_tests(uint8_t policy
)
701 char policy_name
[256] = "";
704 if (policy
== PTIMER_POLICY_DEFAULT
) {
705 g_sprintf(policy_name
, "default");
708 if (policy
& PTIMER_POLICY_WRAP_AFTER_ONE_PERIOD
) {
709 g_strlcat(policy_name
, "wrap_after_one_period,", 256);
712 if (policy
& PTIMER_POLICY_CONTINUOUS_TRIGGER
) {
713 g_strlcat(policy_name
, "continuous_trigger,", 256);
716 if (policy
& PTIMER_POLICY_NO_IMMEDIATE_TRIGGER
) {
717 g_strlcat(policy_name
, "no_immediate_trigger,", 256);
720 if (policy
& PTIMER_POLICY_NO_IMMEDIATE_RELOAD
) {
721 g_strlcat(policy_name
, "no_immediate_reload,", 256);
724 if (policy
& PTIMER_POLICY_NO_COUNTER_ROUND_DOWN
) {
725 g_strlcat(policy_name
, "no_counter_rounddown,", 256);
728 g_test_add_data_func_full(
729 tmp
= g_strdup_printf("/ptimer/set_count policy=%s", policy_name
),
730 g_memdup(&policy
, 1), check_set_count
, g_free
);
733 g_test_add_data_func_full(
734 tmp
= g_strdup_printf("/ptimer/set_limit policy=%s", policy_name
),
735 g_memdup(&policy
, 1), check_set_limit
, g_free
);
738 g_test_add_data_func_full(
739 tmp
= g_strdup_printf("/ptimer/oneshot policy=%s", policy_name
),
740 g_memdup(&policy
, 1), check_oneshot
, g_free
);
743 g_test_add_data_func_full(
744 tmp
= g_strdup_printf("/ptimer/periodic policy=%s", policy_name
),
745 g_memdup(&policy
, 1), check_periodic
, g_free
);
748 g_test_add_data_func_full(
749 tmp
= g_strdup_printf("/ptimer/on_the_fly_mode_change policy=%s",
751 g_memdup(&policy
, 1), check_on_the_fly_mode_change
, g_free
);
754 g_test_add_data_func_full(
755 tmp
= g_strdup_printf("/ptimer/on_the_fly_period_change policy=%s",
757 g_memdup(&policy
, 1), check_on_the_fly_period_change
, g_free
);
760 g_test_add_data_func_full(
761 tmp
= g_strdup_printf("/ptimer/on_the_fly_freq_change policy=%s",
763 g_memdup(&policy
, 1), check_on_the_fly_freq_change
, g_free
);
766 g_test_add_data_func_full(
767 tmp
= g_strdup_printf("/ptimer/run_with_period_0 policy=%s",
769 g_memdup(&policy
, 1), check_run_with_period_0
, g_free
);
772 g_test_add_data_func_full(
773 tmp
= g_strdup_printf("/ptimer/run_with_delta_0 policy=%s",
775 g_memdup(&policy
, 1), check_run_with_delta_0
, g_free
);
778 g_test_add_data_func_full(
779 tmp
= g_strdup_printf("/ptimer/periodic_with_load_0 policy=%s",
781 g_memdup(&policy
, 1), check_periodic_with_load_0
, g_free
);
784 g_test_add_data_func_full(
785 tmp
= g_strdup_printf("/ptimer/oneshot_with_load_0 policy=%s",
787 g_memdup(&policy
, 1), check_oneshot_with_load_0
, g_free
);
791 static void add_all_ptimer_policies_comb_tests(void)
793 int last_policy
= PTIMER_POLICY_NO_COUNTER_ROUND_DOWN
;
794 int policy
= PTIMER_POLICY_DEFAULT
;
796 for (; policy
< (last_policy
<< 1); policy
++) {
797 add_ptimer_tests(policy
);
801 int main(int argc
, char **argv
)
805 g_test_init(&argc
, &argv
, NULL
);
807 for (i
= 0; i
< QEMU_CLOCK_MAX
; i
++) {
808 main_loop_tlg
.tl
[i
] = g_new0(QEMUTimerList
, 1);
811 add_all_ptimer_policies_comb_tests();
813 qtest_allowed
= true;