diff options
-rw-r--r-- | source3/torture/proto.h | 1 | ||||
-rw-r--r-- | source3/torture/test_messaging_fd_passing.c | 77 | ||||
-rw-r--r-- | source3/torture/torture.c | 1 | ||||
-rwxr-xr-x | source3/wscript_build | 1 |
4 files changed, 80 insertions, 0 deletions
diff --git a/source3/torture/proto.h b/source3/torture/proto.h index 08790c758e9..0402f1a7c9f 100644 --- a/source3/torture/proto.h +++ b/source3/torture/proto.h @@ -116,6 +116,7 @@ bool run_bench_pthreadpool(int dummy); bool run_messaging_read1(int dummy); bool run_messaging_read2(int dummy); bool run_messaging_read3(int dummy); +bool run_messaging_fdpass1(int dummy); bool run_oplock_cancel(int dummy); #endif /* __TORTURE_H__ */ diff --git a/source3/torture/test_messaging_fd_passing.c b/source3/torture/test_messaging_fd_passing.c new file mode 100644 index 00000000000..b860939d46e --- /dev/null +++ b/source3/torture/test_messaging_fd_passing.c @@ -0,0 +1,77 @@ +/* + Unix SMB/CIFS implementation. + Test for fd passing with messaging + + Copyright (C) Michael Adam 2014 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "includes.h" +#include "torture/proto.h" +#include "lib/util/tevent_unix.h" +#include "messages.h" + +/** + * test fdpass1: + * + * Try to pass an fd to the sending process - fails. + */ +bool run_messaging_fdpass1(int dummy) +{ + struct tevent_context *ev = NULL; + struct messaging_context *msg_ctx = NULL; + bool retval = false; + int pipe_fds[2]; + int pass_fds[1] = { 0 }; + int ret; + NTSTATUS status; + struct server_id dst; + TALLOC_CTX *frame = talloc_stackframe(); + + ev = samba_tevent_context_init(frame); + if (ev == NULL) { + fprintf(stderr, "tevent_context_init failed\n"); + goto fail; + } + msg_ctx = messaging_init(ev, ev); + if (msg_ctx == NULL) { + fprintf(stderr, "messaging_init failed\n"); + goto fail; + } + + dst = messaging_server_id(msg_ctx); + + ret = pipe(pipe_fds); + if (ret != 0) { + perror("pipe failed"); + goto fail; + } + + pass_fds[0] = pipe_fds[0]; + + status = messaging_send_iov(msg_ctx, dst, MSG_PING, NULL, 0, + pass_fds, 1); + if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) { + fprintf(stderr, + "messaging_send_iov gave: %s\n", nt_errstr(status)); + goto fail; + } + + retval = true; + +fail: + TALLOC_FREE(frame); + return retval; +} diff --git a/source3/torture/torture.c b/source3/torture/torture.c index 799afc71dff..b3d9237ba3a 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -9606,6 +9606,7 @@ static struct { { "LOCAL-MESSAGING-READ1", run_messaging_read1, 0 }, { "LOCAL-MESSAGING-READ2", run_messaging_read2, 0 }, { "LOCAL-MESSAGING-READ3", run_messaging_read3, 0 }, + { "LOCAL-MESSAGING-FDPASS1", run_messaging_fdpass1, 0 }, { "LOCAL-BASE64", run_local_base64, 0}, { "LOCAL-RBTREE", run_local_rbtree, 0}, { "LOCAL-MEMCACHE", run_local_memcache, 0}, diff --git a/source3/wscript_build b/source3/wscript_build index 740ab765148..ca46dad68bf 100755 --- a/source3/wscript_build +++ b/source3/wscript_build @@ -1252,6 +1252,7 @@ bld.SAMBA3_BINARY('smbtorture' + bld.env.suffix3, torture/test_dbwrap_ctdb.c torture/test_buffersize.c torture/test_messaging_read.c + torture/test_messaging_fd_passing.c torture/test_oplock_cancel.c torture/t_strappend.c torture/bench_pthreadpool.c |