]> git.ozlabs.org Git - ccan/blobdiff - ccan/failtest/test/run-history.c
failtest: use a linked list for history, not an array.
[ccan] / ccan / failtest / test / run-history.c
index dc5a3f96a4732f16c6232595f2578ea922a6799d..24dc1169046945f0110be6c70710f518a83cd911 100644 (file)
@@ -45,8 +45,8 @@ int main(void)
        realloc_call.ret = realloc(malloc_call.ret, 3);
        realloc_call.ptr = malloc_call.ret;
        realloc_call.size = 3;
-       call = add_history(FAILTEST_REALLOC, "run-history.c",
-                          3, &realloc_call);
+       call = add_history(FAILTEST_REALLOC, "run-history.c", 3,
+                          &realloc_call);
        ok1(call->type == FAILTEST_REALLOC);
        ok1(strcmp(call->file, "run-history.c") == 0);
        ok1(call->line == 3);
@@ -102,20 +102,24 @@ int main(void)
        ok1(call->u.write.fd == write_call.fd);
        ok1(call->u.write.count == write_call.count);
 
-       ok1(history_num == 7);
+       i = 0;
+       tlist_for_each(&history, call, list)
+               i++;
 
-       for (i = 0; i < history_num; i++)
-               history[i].fail = false;
+       ok1(i == 7);
+
+       tlist_for_each(&history, call, list)
+               call->fail = false;
 
        path = failpath_string();
-       ok1(strcmp(path, "cmeoprw") == 0);
+       ok1(streq(path, "cmeoprw"));
        free(path);
 
-       for (i = 0; i < history_num; i++)
-               history[i].fail = true;
+       tlist_for_each(&history, call, list)
+               call->fail = true;
 
        path = failpath_string();
-       ok1(strcmp(path, "CMEOPRW") == 0);
+       ok1(streq(path, "CMEOPRW"));
        free(path);
 
        return exit_status();