From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YL8GF-0003N9-N1 for qemu-devel@nongnu.org; Tue, 10 Feb 2015 05:41:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YL8GE-0001UF-Rn for qemu-devel@nongnu.org; Tue, 10 Feb 2015 05:41:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58792) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YL8GE-0001Tw-E1 for qemu-devel@nongnu.org; Tue, 10 Feb 2015 05:41:42 -0500 From: Kevin Wolf Date: Tue, 10 Feb 2015 11:41:28 +0100 Message-Id: <1423564888-14933-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1423564888-14933-1-git-send-email-kwolf@redhat.com> References: <1423564888-14933-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 3/3] test-coroutine: Regression test for yield bug List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, famz@redhat.com, wu.wubin@huawei.com, stefanha@redhat.com From: Stefan Hajnoczi This adds a test for reentering a coroutine that previously yielded to a coroutine that has meanwhile terminated. Signed-off-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- tests/test-coroutine.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/test-coroutine.c b/tests/test-coroutine.c index 27d1b6f..b552d9f 100644 --- a/tests/test-coroutine.c +++ b/tests/test-coroutine.c @@ -13,6 +13,7 @@ #include #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); -- 1.8.3.1