From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, pbonzini@redhat.com, famz@redhat.com,
wu.wubin@huawei.com, stefanha@redhat.com
Subject: [Qemu-devel] [PATCH 3/3] test-coroutine: Regression test for yield bug
Date: Tue, 10 Feb 2015 11:41:28 +0100 [thread overview]
Message-ID: <1423564888-14933-4-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1423564888-14933-1-git-send-email-kwolf@redhat.com>
From: Stefan Hajnoczi <stefanha@redhat.com>
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>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
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 <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);
--
1.8.3.1
next prev parent reply other threads:[~2015-02-10 10:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-10 10:41 [Qemu-devel] [PATCH 0/3] coroutine: Fix qemu_coroutine_yield() Kevin Wolf
2015-02-10 10:41 ` [Qemu-devel] [PATCH 1/3] coroutine: Fix use after free with qemu_coroutine_yield() Kevin Wolf
2015-02-20 15:05 ` Kevin Wolf
2015-02-10 10:41 ` [Qemu-devel] [PATCH 2/3] coroutine: Clean up qemu_coroutine_enter() Kevin Wolf
2015-02-10 10:55 ` Paolo Bonzini
2015-02-10 11:09 ` Kevin Wolf
2015-02-10 11:15 ` Paolo Bonzini
2015-02-18 13:50 ` Stefan Hajnoczi
2015-02-18 14:20 ` Kevin Wolf
2015-02-19 14:33 ` Stefan Hajnoczi
2015-02-10 10:41 ` Kevin Wolf [this message]
2015-02-16 10:19 ` [Qemu-devel] [PATCH 0/3] coroutine: Fix qemu_coroutine_yield() Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1423564888-14933-4-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=famz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=wu.wubin@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).