From 2c200dd00d8a3969e5dbbdb0598b5073fd3cf65e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 25 May 2017 10:48:15 +0200 Subject: [PATCH] torture3: Test heuristic cleanup Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- source3/selftest/tests.py | 1 + source3/torture/proto.h | 1 + source3/torture/test_g_lock.c | 142 ++++++++++++++++++++++++++++++++++++++++++ source3/torture/torture.c | 1 + 4 files changed, 145 insertions(+) diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index 8a8a62d1fb6..965ad7eee3e 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -152,6 +152,7 @@ local_tests = [ "LOCAL-G-LOCK2", "LOCAL-G-LOCK3", "LOCAL-G-LOCK4", + "LOCAL-G-LOCK5", "LOCAL-hex_encode_buf", "LOCAL-remove_duplicate_addrs2"] diff --git a/source3/torture/proto.h b/source3/torture/proto.h index c945d92038c..6d5ca7747e1 100644 --- a/source3/torture/proto.h +++ b/source3/torture/proto.h @@ -128,5 +128,6 @@ bool run_g_lock1(int dummy); bool run_g_lock2(int dummy); bool run_g_lock3(int dummy); bool run_g_lock4(int dummy); +bool run_g_lock5(int dummy); #endif /* __TORTURE_H__ */ diff --git a/source3/torture/test_g_lock.c b/source3/torture/test_g_lock.c index 98fd01312f8..ca373123e11 100644 --- a/source3/torture/test_g_lock.c +++ b/source3/torture/test_g_lock.c @@ -500,3 +500,145 @@ fail: TALLOC_FREE(ev); return ret; } + +struct lock5_parser_state { + size_t num_locks; +}; + +static void lock5_parser(const struct g_lock_rec *locks, + size_t num_locks, + const uint8_t *data, + size_t datalen, + void *private_data) +{ + struct lock5_parser_state *state = private_data; + state->num_locks = num_locks; +} + +/* + * Test heuristic cleanup + */ + +bool run_g_lock5(int dummy) +{ + struct tevent_context *ev = NULL; + struct messaging_context *msg = NULL; + struct g_lock_ctx *ctx = NULL; + const char *lockname = "lock5"; + 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; + + nprocs = 5; + + 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; + } + + for (i=0; i