s3/docs: Raise version number up to 3.5.
[Samba/gebeck_regimport.git] / source4 / torture / rpc / ntsvcs.c
blob5453102039fa208d3a91d84043ed163ffa4e9f18
1 /*
2 Unix SMB/CIFS implementation.
3 test suite for rpc ntsvcs operations
5 Copyright (C) Guenther Deschner 2008
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "includes.h"
23 #include "lib/torture/torture.h"
24 #include "torture/rpc/rpc.h"
25 #include "librpc/gen_ndr/ndr_ntsvcs_c.h"
26 #include "torture/util.h"
27 #include "param/param.h"
29 static bool test_PNP_GetVersion(struct torture_context *tctx,
30 struct dcerpc_pipe *p)
32 NTSTATUS status;
33 struct PNP_GetVersion r;
34 uint16_t version = 0;
36 r.out.version = &version;
38 status = dcerpc_PNP_GetVersion(p, tctx, &r);
40 torture_assert_ntstatus_ok(tctx, status, "PNP_GetVersion");
41 torture_assert_werr_ok(tctx, r.out.result, "PNP_GetVersion");
42 torture_assert_int_equal(tctx, version, 0x400, "invalid version");
44 return true;
47 static bool test_PNP_GetDeviceListSize(struct torture_context *tctx,
48 struct dcerpc_pipe *p)
50 NTSTATUS status;
51 struct PNP_GetDeviceListSize r;
52 uint32_t size = 0;
54 r.in.devicename = NULL;
55 r.in.flags = 0;
56 r.out.size = &size;
58 status = dcerpc_PNP_GetDeviceListSize(p, tctx, &r);
60 torture_assert_ntstatus_ok(tctx, status, "PNP_GetDeviceListSize");
61 torture_assert_werr_ok(tctx, r.out.result, "PNP_GetDeviceListSize");
63 return true;
66 static bool test_PNP_GetDeviceList(struct torture_context *tctx,
67 struct dcerpc_pipe *p)
69 NTSTATUS status;
70 struct PNP_GetDeviceList r;
71 uint16_t *buffer = NULL;
72 uint32_t length = 0;
74 buffer = talloc_array(tctx, uint16_t, 0);
76 r.in.filter = NULL;
77 r.in.flags = 0;
78 r.in.length = &length;
79 r.out.length = &length;
80 r.out.buffer = buffer;
82 status = dcerpc_PNP_GetDeviceList(p, tctx, &r);
83 torture_assert_ntstatus_ok(tctx, status, "PNP_GetDeviceList");
85 if (W_ERROR_EQUAL(r.out.result, WERR_CM_BUFFER_SMALL)) {
86 struct PNP_GetDeviceListSize s;
88 s.in.devicename = NULL;
89 s.in.flags = 0;
90 s.out.size = &length;
92 status = dcerpc_PNP_GetDeviceListSize(p, tctx, &s);
94 torture_assert_ntstatus_ok(tctx, status, "PNP_GetDeviceListSize");
95 torture_assert_werr_ok(tctx, s.out.result, "PNP_GetDeviceListSize");
98 buffer = talloc_array(tctx, uint16_t, length);
100 r.in.length = &length;
101 r.out.length = &length;
102 r.out.buffer = buffer;
104 status = dcerpc_PNP_GetDeviceList(p, tctx, &r);
105 torture_assert_ntstatus_ok(tctx, status, "PNP_GetDeviceList");
106 torture_assert_werr_ok(tctx, r.out.result, "PNP_GetDeviceList");
108 return true;
111 static bool test_PNP_GetDeviceRegProp(struct torture_context *tctx,
112 struct dcerpc_pipe *p)
114 NTSTATUS status;
115 struct PNP_GetDeviceRegProp r;
117 enum winreg_Type reg_data_type = REG_NONE;
118 uint32_t buffer_size = 0;
119 uint32_t needed = 0;
120 uint8_t *buffer;
122 buffer = talloc(tctx, uint8_t);
124 r.in.devicepath = "ACPI\\ACPI0003\\1";
125 r.in.property = DEV_REGPROP_DESC;
126 r.in.flags = 0;
127 r.in.reg_data_type = &reg_data_type;
128 r.in.buffer_size = &buffer_size;
129 r.in.needed = &needed;
130 r.out.buffer = buffer;
131 r.out.reg_data_type = &reg_data_type;
132 r.out.buffer_size = &buffer_size;
133 r.out.needed = &needed;
135 status = dcerpc_PNP_GetDeviceRegProp(p, tctx, &r);
136 torture_assert_ntstatus_ok(tctx, status, "PNP_GetDeviceRegProp");
138 if (W_ERROR_EQUAL(r.out.result, WERR_CM_BUFFER_SMALL)) {
140 buffer = talloc_array(tctx, uint8_t, needed);
141 r.in.buffer_size = &needed;
143 status = dcerpc_PNP_GetDeviceRegProp(p, tctx, &r);
144 torture_assert_ntstatus_ok(tctx, status, "PNP_GetDeviceRegProp");
147 return true;
150 struct torture_suite *torture_rpc_ntsvcs(TALLOC_CTX *mem_ctx)
152 struct torture_rpc_tcase *tcase;
153 struct torture_suite *suite = torture_suite_create(mem_ctx, "NTSVCS");
154 struct torture_test *test;
156 tcase = torture_suite_add_rpc_iface_tcase(suite, "ntsvcs",
157 &ndr_table_ntsvcs);
159 test = torture_rpc_tcase_add_test(tcase, "PNP_GetDeviceRegProp",
160 test_PNP_GetDeviceRegProp);
161 test = torture_rpc_tcase_add_test(tcase, "PNP_GetDeviceList",
162 test_PNP_GetDeviceList);
163 test = torture_rpc_tcase_add_test(tcase, "PNP_GetDeviceListSize",
164 test_PNP_GetDeviceListSize);
165 test = torture_rpc_tcase_add_test(tcase, "PNP_GetVersion",
166 test_PNP_GetVersion);
168 return suite;