]> git.ozlabs.org Git - ccan/commitdiff
coroutine: Remove on-stack buffers from testcases
authorDavid Gibson <david@gibson.dropbear.id.au>
Sat, 24 Dec 2016 10:40:00 +0000 (21:40 +1100)
committerDavid Gibson <david@gibson.dropbear.id.au>
Tue, 24 Jan 2017 10:22:27 +0000 (21:22 +1100)
In preparation for enabling valgrind tests, remove instances where we
allocate a coroutine's stack from a buffer itself on the stack.  Not all
that surprisingly, valgrind gets very, very confused by having one
"thread"'s stack embedded within another's.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
ccan/coroutine/test/api-1.c
ccan/coroutine/test/api-3.c

index fbf66df60b117b9ef140601231e96d4fbc16d38b..ea59dc02fb3f9ad7df753b5cc84a8f91972af0c5 100644 (file)
@@ -30,9 +30,10 @@ static void test_trivial(struct coroutine_stack *stack)
 }
 
 
+static char buf[COROUTINE_MIN_STKSZ + COROUTINE_STK_OVERHEAD];
+
 int main(void)
 {
-       char buf[COROUTINE_MIN_STKSZ + COROUTINE_STK_OVERHEAD];
        struct coroutine_stack *stack;
 
        /* This is how many tests you plan to run */
index 129126549e3edb6ceefd39bb8d2e281dad80587e..4b90b46310b2952ba2a780ac72089db842670496 100644 (file)
@@ -64,16 +64,19 @@ static void test_metadata(struct coroutine_stack *stack)
 
 int main(void)
 {
-       char buf[BUFSIZE];
+       char *buf;
        struct coroutine_stack *stack;
 
        /* This is how many tests you plan to run */
-       plan_tests(9);
+       plan_tests(10);
 
        /* Fix seed so we get consistent, though pseudo-random results */       
        srandom(0);
 
-       stack = coroutine_stack_init(buf, sizeof(buf), sizeof(struct metadata));
+       buf = malloc(BUFSIZE);
+       ok1(buf != NULL);
+
+       stack = coroutine_stack_init(buf, BUFSIZE, sizeof(struct metadata));
        ok1(stack != NULL);
        ok1(coroutine_stack_check(stack, NULL) == stack);
        ok1(coroutine_stack_size(stack)
@@ -83,6 +86,8 @@ int main(void)
 
        coroutine_stack_release(stack, sizeof(struct metadata));
 
+       free(buf);
+
        /* This exits depending on whether all tests passed */
        return exit_status();
 }