diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2015-02-10 11:15:59 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2015-03-09 11:11:59 +0100 |
commit | 7c2eed3efa86c19436bc33372bfa9d7fbb6fda2c (patch) | |
tree | 8ed99b28f1405b85d3ff652d7913702f5555f264 /tests/test-coroutine.c | |
parent | cd12bb567cdcd9665a5acdecd6ac8afd9a977003 (diff) |
test-coroutine: Regression test for yield bug
This adds a test for reentering a coroutine that previously yielded to a
coroutine that has meanwhile terminated.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'tests/test-coroutine.c')
-rw-r--r-- | tests/test-coroutine.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/test-coroutine.c b/tests/test-coroutine.c index 27d1b6f8e8..b552d9f5e9 100644 --- a/tests/test-coroutine.c +++ b/tests/test-coroutine.c @@ -13,6 +13,7 @@ #include <glib.h> #include "block/coroutine.h" +#include "block/coroutine_int.h" /* * Check that qemu_in_coroutine() works @@ -122,6 +123,30 @@ static void test_yield(void) g_assert_cmpint(i, ==, 5); /* coroutine must yield 5 times */ } +static void coroutine_fn c2_fn(void *opaque) +{ + qemu_coroutine_yield(); +} + +static void coroutine_fn c1_fn(void *opaque) +{ + Coroutine *c2 = opaque; + qemu_coroutine_enter(c2, NULL); +} + +static void test_co_queue(void) +{ + Coroutine *c1; + Coroutine *c2; + + c1 = qemu_coroutine_create(c1_fn); + c2 = qemu_coroutine_create(c2_fn); + + qemu_coroutine_enter(c1, c2); + memset(c1, 0xff, sizeof(Coroutine)); + qemu_coroutine_enter(c2, NULL); +} + /* * Check that creation, enter, and return work */ @@ -343,6 +368,7 @@ static void perf_cost(void) int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); + g_test_add_func("/basic/co_queue", test_co_queue); g_test_add_func("/basic/lifecycle", test_lifecycle); g_test_add_func("/basic/yield", test_yield); g_test_add_func("/basic/nesting", test_nesting); |