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 2 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, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "torture/torture.h"
25 #include "librpc/gen_ndr/ndr_initshutdown_c.h"
26 #include "torture/rpc/rpc.h"
28 static void init_initshutdown_String(TALLOC_CTX *mem_ctx, struct initshutdown_String *name, const char *s)
30 name->name = talloc(mem_ctx, struct initshutdown_String_sub);
34 static BOOL test_Init(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
35 const char *msg, uint32_t timeout)
37 struct initshutdown_Init r;
39 uint16_t hostname = 0x0;
41 r.in.hostname = &hostname;
42 r.in.message = talloc(mem_ctx, struct initshutdown_String);
43 init_initshutdown_String(mem_ctx, r.in.message, msg);
45 r.in.timeout = timeout;
48 status = dcerpc_initshutdown_Init(p, mem_ctx, &r);
50 if (!NT_STATUS_IS_OK(status)) {
51 printf("initshutdown_Init failed - %s\n", nt_errstr(status));
55 if (!W_ERROR_IS_OK(r.out.result)) {
56 printf("initshutdown_Init failed - %s\n", win_errstr(r.out.result));
63 static BOOL test_InitEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
64 const char *msg, uint32_t timeout)
66 struct initshutdown_InitEx r;
68 uint16_t hostname = 0x0;
70 r.in.hostname = &hostname;
71 r.in.message = talloc(mem_ctx, struct initshutdown_String);
72 init_initshutdown_String(mem_ctx, r.in.message, msg);
74 r.in.timeout = timeout;
78 status = dcerpc_initshutdown_InitEx(p, mem_ctx, &r);
80 if (!NT_STATUS_IS_OK(status)) {
81 printf("initshutdown_InitEx failed - %s\n", nt_errstr(status));
85 if (!W_ERROR_IS_OK(r.out.result)) {
86 printf("initshutdown_InitEx failed - %s\n", win_errstr(r.out.result));
93 static BOOL test_Abort(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
95 struct initshutdown_Abort r;
97 uint16_t server = 0x0;
99 r.in.server = &server;
101 status = dcerpc_initshutdown_Abort(p, mem_ctx, &r);
103 if (!NT_STATUS_IS_OK(status)) {
104 printf("initshutdown_Abort failed - %s\n", nt_errstr(status));
108 if (!W_ERROR_IS_OK(r.out.result)) {
109 printf("initshutdown_Abort failed - %s\n", win_errstr(r.out.result));
116 BOOL torture_rpc_initshutdown(void)
119 struct dcerpc_pipe *p;
123 mem_ctx = talloc_init("torture_rpc_initshutdown");
125 status = torture_rpc_connection(mem_ctx, &p, &dcerpc_table_initshutdown);
127 if (!NT_STATUS_IS_OK(status)) {
128 talloc_free(mem_ctx);
132 if (!lp_parm_bool(-1, "torture", "dangerous", False)) {
133 printf("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);