2 Unix SMB/CIFS implementation.
3 test suite for initshutdown operations
5 Copyright (C) Tim Potter 2003
6 Copyright (C) Jelmer Vernooij 2004-2005
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "torture/torture.h"
24 #include "librpc/gen_ndr/ndr_initshutdown_c.h"
25 #include "torture/rpc/rpc.h"
27 static void init_initshutdown_String(TALLOC_CTX *mem_ctx, struct initshutdown_String *name, const char *s)
29 name->name = talloc(mem_ctx, struct initshutdown_String_sub);
33 static BOOL test_Init(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
34 const char *msg, uint32_t timeout)
36 struct initshutdown_Init r;
38 uint16_t hostname = 0x0;
40 r.in.hostname = &hostname;
41 r.in.message = talloc(mem_ctx, struct initshutdown_String);
42 init_initshutdown_String(mem_ctx, r.in.message, msg);
44 r.in.timeout = timeout;
47 status = dcerpc_initshutdown_Init(p, mem_ctx, &r);
49 if (!NT_STATUS_IS_OK(status)) {
50 printf("initshutdown_Init failed - %s\n", nt_errstr(status));
54 if (!W_ERROR_IS_OK(r.out.result)) {
55 printf("initshutdown_Init failed - %s\n", win_errstr(r.out.result));
62 static BOOL test_InitEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
63 const char *msg, uint32_t timeout)
65 struct initshutdown_InitEx r;
67 uint16_t hostname = 0x0;
69 r.in.hostname = &hostname;
70 r.in.message = talloc(mem_ctx, struct initshutdown_String);
71 init_initshutdown_String(mem_ctx, r.in.message, msg);
73 r.in.timeout = timeout;
77 status = dcerpc_initshutdown_InitEx(p, mem_ctx, &r);
79 if (!NT_STATUS_IS_OK(status)) {
80 printf("initshutdown_InitEx failed - %s\n", nt_errstr(status));
84 if (!W_ERROR_IS_OK(r.out.result)) {
85 printf("initshutdown_InitEx failed - %s\n", win_errstr(r.out.result));
92 static BOOL test_Abort(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
94 struct initshutdown_Abort r;
96 uint16_t server = 0x0;
98 r.in.server = &server;
100 status = dcerpc_initshutdown_Abort(p, mem_ctx, &r);
102 if (!NT_STATUS_IS_OK(status)) {
103 printf("initshutdown_Abort failed - %s\n", nt_errstr(status));
107 if (!W_ERROR_IS_OK(r.out.result)) {
108 printf("initshutdown_Abort failed - %s\n", win_errstr(r.out.result));
115 BOOL torture_rpc_initshutdown(struct torture_context *torture)
118 struct dcerpc_pipe *p;
122 mem_ctx = talloc_init("torture_rpc_initshutdown");
124 status = torture_rpc_connection(torture, &p, &ndr_table_initshutdown);
126 if (!NT_STATUS_IS_OK(status)) {
127 talloc_free(mem_ctx);
131 if (!torture_setting_bool(torture, "dangerous", False)) {
132 torture_comment(torture,
133 "initshutdown tests disabled - enable dangerous tests to use\n");
135 ret &= test_Init(p, mem_ctx, "spottyfood", 30);
136 ret &= test_Abort(p, mem_ctx);
137 ret &= test_InitEx(p, mem_ctx, "spottyfood", 30);
138 ret &= test_Abort(p, mem_ctx);
141 talloc_free(mem_ctx);