X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftalloc%2Ftest%2Frun.c;h=32fe47b554cdc78ca75b11c5f8be8855c9d905eb;hp=7369186c08f5b5754c4988618b16a1561a63c3f9;hb=fe35ee039b64d8a585a9766b293b1393b4f8c787;hpb=650c775ff00cccd03fc84e7789a03c51d9839004 diff --git a/ccan/talloc/test/run.c b/ccan/talloc/test/run.c index 7369186c..32fe47b5 100644 --- a/ccan/talloc/test/run.c +++ b/ccan/talloc/test/run.c @@ -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(); }