summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/libqos/virtio.c2
-rw-r--r--tests/test-coroutine.c42
2 files changed, 43 insertions, 1 deletions
diff --git a/tests/libqos/virtio.c b/tests/libqos/virtio.c
index 37ff860c16..105bccecaa 100644
--- a/tests/libqos/virtio.c
+++ b/tests/libqos/virtio.c
@@ -147,7 +147,7 @@ void qvring_init(const QGuestAllocator *alloc, QVirtQueue *vq, uint64_t addr)
for (i = 0; i < vq->size - 1; i++) {
/* vq->desc[i].addr */
- writew(vq->desc + (16 * i), 0);
+ writeq(vq->desc + (16 * i), 0);
/* vq->desc[i].next */
writew(vq->desc + (16 * i) + 14, i + 1);
}
diff --git a/tests/test-coroutine.c b/tests/test-coroutine.c
index 6431dd6d7c..abd97c23c1 100644
--- a/tests/test-coroutine.c
+++ b/tests/test-coroutine.c
@@ -53,6 +53,47 @@ static void test_self(void)
}
/*
+ * Check that qemu_coroutine_entered() works
+ */
+
+static void coroutine_fn verify_entered_step_2(void *opaque)
+{
+ Coroutine *caller = (Coroutine *)opaque;
+
+ g_assert(qemu_coroutine_entered(caller));
+ g_assert(qemu_coroutine_entered(qemu_coroutine_self()));
+ qemu_coroutine_yield();
+
+ /* Once more to check it still works after yielding */
+ g_assert(qemu_coroutine_entered(caller));
+ g_assert(qemu_coroutine_entered(qemu_coroutine_self()));
+ qemu_coroutine_yield();
+}
+
+static void coroutine_fn verify_entered_step_1(void *opaque)
+{
+ Coroutine *self = qemu_coroutine_self();
+ Coroutine *coroutine;
+
+ g_assert(qemu_coroutine_entered(self));
+
+ coroutine = qemu_coroutine_create(verify_entered_step_2, self);
+ g_assert(!qemu_coroutine_entered(coroutine));
+ qemu_coroutine_enter(coroutine);
+ g_assert(!qemu_coroutine_entered(coroutine));
+ qemu_coroutine_enter(coroutine);
+}
+
+static void test_entered(void)
+{
+ Coroutine *coroutine;
+
+ coroutine = qemu_coroutine_create(verify_entered_step_1, NULL);
+ g_assert(!qemu_coroutine_entered(coroutine));
+ qemu_coroutine_enter(coroutine);
+}
+
+/*
* Check that coroutines may nest multiple levels
*/
@@ -389,6 +430,7 @@ int main(int argc, char **argv)
g_test_add_func("/basic/yield", test_yield);
g_test_add_func("/basic/nesting", test_nesting);
g_test_add_func("/basic/self", test_self);
+ g_test_add_func("/basic/entered", test_entered);
g_test_add_func("/basic/in_coroutine", test_in_coroutine);
g_test_add_func("/basic/order", test_order);
if (g_test_perf()) {