mirror of
https://github.com/samba-team/samba.git
synced 2025-02-22 05:57:43 +03:00
torture: Test g_lock_watch_data_send()/recv()
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
46e8e0cd7e
commit
90dcfa4e59
@ -233,6 +233,7 @@ local_tests = [
|
||||
"LOCAL-G-LOCK5",
|
||||
"LOCAL-G-LOCK6",
|
||||
"LOCAL-G-LOCK7",
|
||||
"LOCAL-G-LOCK8",
|
||||
"LOCAL-NAMEMAP-CACHE1",
|
||||
"LOCAL-IDMAP-CACHE1",
|
||||
"LOCAL-hex_encode_buf",
|
||||
|
@ -140,6 +140,7 @@ bool run_g_lock4a(int dummy);
|
||||
bool run_g_lock5(int dummy);
|
||||
bool run_g_lock6(int dummy);
|
||||
bool run_g_lock7(int dummy);
|
||||
bool run_g_lock8(int dummy);
|
||||
bool run_g_lock_ping_pong(int dummy);
|
||||
bool run_local_namemap_cache1(int dummy);
|
||||
bool run_local_idmap_cache1(int dummy);
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "lib/util/server_id.h"
|
||||
#include "lib/util/sys_rw.h"
|
||||
#include "lib/util/util_tdb.h"
|
||||
#include "lib/util/tevent_ntstatus.h"
|
||||
|
||||
static bool get_g_lock_ctx(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_context **ev,
|
||||
@ -1207,6 +1208,81 @@ fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool run_g_lock8(int dummy)
|
||||
{
|
||||
struct tevent_context *ev = NULL;
|
||||
struct messaging_context *msg = NULL;
|
||||
struct g_lock_ctx *ctx = NULL;
|
||||
struct tevent_req *req = NULL;
|
||||
TDB_DATA lockname = string_term_tdb_data("lock8");
|
||||
NTSTATUS status;
|
||||
bool ok;
|
||||
|
||||
ok = get_g_lock_ctx(talloc_tos(), &ev, &msg, &ctx);
|
||||
if (!ok) {
|
||||
fprintf(stderr, "get_g_lock_ctx failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
req = g_lock_watch_data_send(
|
||||
ev, ev, ctx, lockname, (struct server_id) { .pid = 0 });
|
||||
if (req == NULL) {
|
||||
fprintf(stderr, "get_g_lock_ctx failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
status = g_lock_lock(
|
||||
ctx,
|
||||
lockname,
|
||||
G_LOCK_WRITE,
|
||||
(struct timeval) { .tv_sec = 999 });
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
fprintf(stderr,
|
||||
"g_lock_lock failed: %s\n",
|
||||
nt_errstr(status));
|
||||
return false;
|
||||
}
|
||||
|
||||
status = g_lock_write_data(
|
||||
ctx, lockname, lockname.dptr, lockname.dsize);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
fprintf(stderr,
|
||||
"g_lock_write_data failed: %s\n",
|
||||
nt_errstr(status));
|
||||
return false;
|
||||
}
|
||||
|
||||
status = g_lock_write_data(ctx, lockname, NULL, 0);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
fprintf(stderr,
|
||||
"g_lock_write_data failed: %s\n",
|
||||
nt_errstr(status));
|
||||
return false;
|
||||
}
|
||||
|
||||
status = g_lock_unlock(ctx, lockname);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
fprintf(stderr,
|
||||
"g_lock_unlock failed: %s\n",
|
||||
nt_errstr(status));
|
||||
return false;
|
||||
}
|
||||
|
||||
ok = tevent_req_poll_ntstatus(req, ev, &status);
|
||||
if (!ok) {
|
||||
fprintf(stderr, "tevent_req_poll_ntstatus failed\n");
|
||||
return false;
|
||||
}
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
fprintf(stderr,
|
||||
"tevent_req_poll_ntstatus failed: %s\n",
|
||||
nt_errstr(status));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
extern int torture_numops;
|
||||
extern int torture_nprocs;
|
||||
|
||||
|
@ -14971,6 +14971,10 @@ static struct {
|
||||
.name = "LOCAL-G-LOCK7",
|
||||
.fn = run_g_lock7,
|
||||
},
|
||||
{
|
||||
.name = "LOCAL-G-LOCK8",
|
||||
.fn = run_g_lock8,
|
||||
},
|
||||
{
|
||||
.name = "LOCAL-G-LOCK-PING-PONG",
|
||||
.fn = run_g_lock_ping_pong,
|
||||
|
Loading…
x
Reference in New Issue
Block a user