From: Stefan Metzmacher Date: Wed, 20 Dec 2017 08:44:40 +0000 (+0100) Subject: torture3: add LOCAL-G-LOCK6 test X-Git-Tag: samba-4.7.10~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=72a417741bf90b1a20e4d28cf720d43a3a358d03;p=thirdparty%2Fsamba.git torture3: add LOCAL-G-LOCK6 test This is a regression test for bug #13195. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13195 Signed-off-by: Stefan Metzmacher Reviewed-by: Volker Lendecke --- diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index 696c44b8ba4..9362627f47d 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -161,6 +161,7 @@ local_tests = [ "LOCAL-G-LOCK3", "LOCAL-G-LOCK4", "LOCAL-G-LOCK5", + "LOCAL-G-LOCK6", "LOCAL-hex_encode_buf", "LOCAL-remove_duplicate_addrs2"] diff --git a/source3/torture/proto.h b/source3/torture/proto.h index a8400382e10..327fa3d6984 100644 --- a/source3/torture/proto.h +++ b/source3/torture/proto.h @@ -132,5 +132,6 @@ bool run_g_lock2(int dummy); bool run_g_lock3(int dummy); bool run_g_lock4(int dummy); bool run_g_lock5(int dummy); +bool run_g_lock6(int dummy); #endif /* __TORTURE_H__ */ diff --git a/source3/torture/test_g_lock.c b/source3/torture/test_g_lock.c index ca373123e11..1134e0d0716 100644 --- a/source3/torture/test_g_lock.c +++ b/source3/torture/test_g_lock.c @@ -640,5 +640,157 @@ bool run_g_lock5(int dummy) } + return true; +} + +struct lock6_parser_state { + size_t num_locks; +}; + +static void lock6_parser(const struct g_lock_rec *locks, + size_t num_locks, + const uint8_t *data, + size_t datalen, + void *private_data) +{ + struct lock6_parser_state *state = private_data; + state->num_locks = num_locks; +} + +/* + * Test cleanup with contention and stale locks + */ + +bool run_g_lock6(int dummy) +{ + struct tevent_context *ev = NULL; + struct messaging_context *msg = NULL; + struct g_lock_ctx *ctx = NULL; + const char *lockname = "lock6"; + pid_t child; + int exit_pipe[2], ready_pipe[2]; + NTSTATUS status; + size_t i, nprocs; + int ret; + bool ok; + ssize_t nread; + char c; + + if ((pipe(exit_pipe) != 0) || (pipe(ready_pipe) != 0)) { + perror("pipe failed"); + return false; + } + + ok = get_g_lock_ctx(talloc_tos(), &ev, &msg, &ctx); + if (!ok) { + fprintf(stderr, "get_g_lock_ctx failed"); + return false; + } + + nprocs = 2; + for (i=0; i