mirror of https://github.com/xemu-project/xemu.git
tests: ptimer: Add tests for "continuous trigger" policy
PTIMER_POLICY_CONTINUOUS_TRIGGER makes periodic ptimer to re-trigger every period in case of load = delta = 0. Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Message-id: 7a908ab38b902d521eb959941f9efe2df8ce4297.1475421224.git.digetx@gmail.com Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
ef0a9984aa
commit
2e74583b29
|
@ -503,6 +503,7 @@ static void check_periodic_with_load_0(gconstpointer arg)
|
||||||
const uint8_t *policy = arg;
|
const uint8_t *policy = arg;
|
||||||
QEMUBH *bh = qemu_bh_new(ptimer_trigger, NULL);
|
QEMUBH *bh = qemu_bh_new(ptimer_trigger, NULL);
|
||||||
ptimer_state *ptimer = ptimer_init(bh, *policy);
|
ptimer_state *ptimer = ptimer_init(bh, *policy);
|
||||||
|
bool continuous_trigger = (*policy & PTIMER_POLICY_CONTINUOUS_TRIGGER);
|
||||||
|
|
||||||
triggered = false;
|
triggered = false;
|
||||||
|
|
||||||
|
@ -517,7 +518,12 @@ static void check_periodic_with_load_0(gconstpointer arg)
|
||||||
qemu_clock_step(2000000 + 100000);
|
qemu_clock_step(2000000 + 100000);
|
||||||
|
|
||||||
g_assert_cmpuint(ptimer_get_count(ptimer), ==, 0);
|
g_assert_cmpuint(ptimer_get_count(ptimer), ==, 0);
|
||||||
g_assert_false(triggered);
|
|
||||||
|
if (continuous_trigger) {
|
||||||
|
g_assert_true(triggered);
|
||||||
|
} else {
|
||||||
|
g_assert_false(triggered);
|
||||||
|
}
|
||||||
|
|
||||||
triggered = false;
|
triggered = false;
|
||||||
|
|
||||||
|
@ -534,7 +540,12 @@ static void check_periodic_with_load_0(gconstpointer arg)
|
||||||
qemu_clock_step(2000000 + 100000);
|
qemu_clock_step(2000000 + 100000);
|
||||||
|
|
||||||
g_assert_cmpuint(ptimer_get_count(ptimer), ==, 0);
|
g_assert_cmpuint(ptimer_get_count(ptimer), ==, 0);
|
||||||
g_assert_false(triggered);
|
|
||||||
|
if (continuous_trigger) {
|
||||||
|
g_assert_true(triggered);
|
||||||
|
} else {
|
||||||
|
g_assert_false(triggered);
|
||||||
|
}
|
||||||
|
|
||||||
ptimer_stop(ptimer);
|
ptimer_stop(ptimer);
|
||||||
}
|
}
|
||||||
|
@ -576,6 +587,10 @@ static void add_ptimer_tests(uint8_t policy)
|
||||||
g_strlcat(policy_name, "wrap_after_one_period,", 256);
|
g_strlcat(policy_name, "wrap_after_one_period,", 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (policy & PTIMER_POLICY_CONTINUOUS_TRIGGER) {
|
||||||
|
g_strlcat(policy_name, "continuous_trigger,", 256);
|
||||||
|
}
|
||||||
|
|
||||||
g_test_add_data_func(
|
g_test_add_data_func(
|
||||||
g_strdup_printf("/ptimer/set_count policy=%s", policy_name),
|
g_strdup_printf("/ptimer/set_count policy=%s", policy_name),
|
||||||
ppolicy, check_set_count);
|
ppolicy, check_set_count);
|
||||||
|
@ -623,7 +638,7 @@ static void add_ptimer_tests(uint8_t policy)
|
||||||
|
|
||||||
static void add_all_ptimer_policies_comb_tests(void)
|
static void add_all_ptimer_policies_comb_tests(void)
|
||||||
{
|
{
|
||||||
int last_policy = PTIMER_POLICY_WRAP_AFTER_ONE_PERIOD;
|
int last_policy = PTIMER_POLICY_CONTINUOUS_TRIGGER;
|
||||||
int policy = PTIMER_POLICY_DEFAULT;
|
int policy = PTIMER_POLICY_DEFAULT;
|
||||||
|
|
||||||
for (; policy < (last_policy << 1); policy++) {
|
for (; policy < (last_policy << 1); policy++) {
|
||||||
|
|
Loading…
Reference in New Issue