]> git.ozlabs.org Git - ccan/blobdiff - ccan/talloc/test/run.c
Simple locking for talloc.
[ccan] / ccan / talloc / test / run.c
index 7369186c08f5b5754c4988618b16a1561a63c3f9..32fe47b554cdc78ca75b11c5f8be8855c9d905eb 100644 (file)
@@ -861,11 +861,31 @@ static bool torture_local_talloc(struct torture_context *tctx)
        return ret;
 }
 
+static int lock_failed = 0, unlock_failed = 0;
+static void test_lock(int *locked)
+{
+       if (*locked)
+               lock_failed++;
+       *locked = 1;
+}
+
+static void test_unlock(int *locked)
+{
+       if (!*locked)
+               unlock_failed++;
+       *locked = 0;
+}
+
 int main(void)
 {
-       plan_tests(134);
+       int locked = 0;
+
+       plan_tests(136);
+       talloc_locksafe(test_lock, test_unlock, &locked);
 
        torture_local_talloc(NULL);
+       ok(!lock_failed, "lock_failed count %u should be zero", lock_failed);
+       ok(!unlock_failed, "unlock_failed count %u should be zero", unlock_failed);
        return exit_status();
 }