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.
23 #include "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)
33 struct PNP_GetVersion r;
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");
47 static bool test_PNP_GetDeviceListSize(struct torture_context *tctx,
48 struct dcerpc_pipe *p)
51 struct PNP_GetDeviceListSize r;
54 r.in.devicename = NULL;
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");
66 static bool test_PNP_GetDeviceList(struct torture_context *tctx,
67 struct dcerpc_pipe *p)
70 struct PNP_GetDeviceList r;
71 uint16_t *buffer = NULL;
74 buffer = talloc_array(tctx, uint16_t, 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;
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");
112 struct torture_suite *torture_rpc_ntsvcs(TALLOC_CTX *mem_ctx)
114 struct torture_rpc_tcase *tcase;
115 struct torture_suite *suite = torture_suite_create(mem_ctx, "NTSVCS");
116 struct torture_test *test;
118 tcase = torture_suite_add_rpc_iface_tcase(suite, "ntsvcs",
121 test = torture_rpc_tcase_add_test(tcase, "PNP_GetDeviceList",
122 test_PNP_GetDeviceList);
123 test = torture_rpc_tcase_add_test(tcase, "PNP_GetDeviceListSize",
124 test_PNP_GetDeviceListSize);
125 test = torture_rpc_tcase_add_test(tcase, "PNP_GetVersion",
126 test_PNP_GetVersion);