2 Unix SMB/CIFS implementation.
6 Copyright (C) Andrew Tridgell 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_srvsvc_c.h"
25 #include "torture/rpc/rpc.h"
27 /**************************/
29 /**************************/
30 static BOOL test_NetShareEnumAll(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
33 struct srvsvc_NetShareEnumAll r;
34 struct srvsvc_NetShareCtr0 c0;
35 uint32_t levels[] = {0, 1, 2, 501, 502};
38 uint32_t resume_handle;
42 r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p));
44 r.in.max_buffer = (uint32_t)-1;
45 r.in.resume_handle = &resume_handle;
46 r.out.resume_handle = &resume_handle;
48 for (i=0;i<ARRAY_SIZE(levels);i++) {
51 r.in.level = levels[i];
52 status = dcerpc_srvsvc_NetShareEnumAll(p, mem_ctx, &r);
53 if (!NT_STATUS_IS_OK(status)) {
54 printf("NetShareEnumAll level %u failed - %s\n", r.in.level, nt_errstr(status));
58 if (!W_ERROR_IS_OK(r.out.result)) {
59 printf("NetShareEnumAll level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
68 benchmark srvsvc netshareenumall queries
70 static BOOL bench_NetShareEnumAll(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
72 struct timeval tv = timeval_current();
74 int timelimit = lp_parm_int(-1, "torture", "timelimit", 10);
77 printf("Running for %d seconds\n", timelimit);
78 while (timeval_elapsed(&tv) < timelimit) {
79 TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
80 if (!test_NetShareEnumAll(p, tmp_ctx)) break;
83 if (count % 50 == 0) {
84 if (lp_parm_bool(-1, "torture", "progress", true)) {
85 printf("%.1f queries per second \r",
86 count / timeval_elapsed(&tv));
91 printf("%.1f queries per second \n", count / timeval_elapsed(&tv));
97 BOOL torture_bench_rpc(struct torture_context *torture)
100 struct dcerpc_pipe *p;
104 mem_ctx = talloc_init("torture_rpc_srvsvc");
106 status = torture_rpc_connection(mem_ctx,
108 &dcerpc_table_srvsvc);
109 if (!NT_STATUS_IS_OK(status)) {
110 talloc_free(mem_ctx);
114 if (!bench_NetShareEnumAll(p, mem_ctx)) {
118 talloc_free(mem_ctx);