samba-3.5.8 for ARM
[tomato.git] / release / src-rt-6.x.4708 / router / samba-3.5.8 / source4 / torture / rpc / atsvc.c
blob23d76ae502eb2a479e32e46cb6a9ef3dc534dcf7
1 /*
2 Unix SMB/CIFS implementation.
3 test suite for atsvc rpc operations
5 Copyright (C) Tim Potter 2003
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, see <http://www.gnu.org/licenses/>.
21 #include "includes.h"
22 #include "torture/torture.h"
23 #include "librpc/gen_ndr/ndr_atsvc_c.h"
24 #include "torture/rpc/rpc.h"
26 static bool test_JobGetInfo(struct dcerpc_pipe *p, struct torture_context *tctx, uint32_t job_id)
28 NTSTATUS status;
29 struct atsvc_JobGetInfo r;
30 struct atsvc_JobInfo *info = talloc(tctx, struct atsvc_JobInfo);
31 if (!info) {
32 return false;
35 r.in.servername = dcerpc_server_name(p);
36 r.in.job_id = job_id;
37 r.out.job_info = &info;
39 status = dcerpc_atsvc_JobGetInfo(p, tctx, &r);
41 torture_assert_ntstatus_ok(tctx, status, "JobGetInfo failed");
43 return true;
46 static bool test_JobDel(struct dcerpc_pipe *p, struct torture_context *tctx, uint32_t min_job_id,
47 uint32_t max_job_id)
49 NTSTATUS status;
50 struct atsvc_JobDel r;
52 r.in.servername = dcerpc_server_name(p);
53 r.in.min_job_id = min_job_id;
54 r.in.max_job_id = max_job_id;
56 status = dcerpc_atsvc_JobDel(p, tctx, &r);
58 torture_assert_ntstatus_ok(tctx, status, "JobDel failed");
60 return true;
63 static bool test_JobEnum(struct torture_context *tctx, struct dcerpc_pipe *p)
65 NTSTATUS status;
66 struct atsvc_JobEnum r;
67 struct atsvc_enum_ctr ctr;
68 uint32_t resume_handle = 0, i, total_entries = 0;
70 bool ret = true;
72 r.in.servername = dcerpc_server_name(p);
73 ctr.entries_read = 0;
74 ctr.first_entry = NULL;
75 r.in.ctr = r.out.ctr = &ctr;
76 r.in.preferred_max_len = 0xffffffff;
77 r.in.resume_handle = r.out.resume_handle = &resume_handle;
78 r.out.total_entries = &total_entries;
80 status = dcerpc_atsvc_JobEnum(p, tctx, &r);
82 torture_assert_ntstatus_ok(tctx, status, "JobEnum failed");
84 for (i = 0; i < r.out.ctr->entries_read; i++) {
85 if (!test_JobGetInfo(p, tctx, r.out.ctr->first_entry[i].job_id)) {
86 ret = false;
90 return ret;
93 static bool test_JobAdd(struct torture_context *tctx, struct dcerpc_pipe *p)
95 NTSTATUS status;
96 struct atsvc_JobAdd r;
97 struct atsvc_JobInfo info;
99 r.in.servername = dcerpc_server_name(p);
100 info.job_time = 0x050ae4c0; /* 11:30pm */
101 info.days_of_month = 0; /* n/a */
102 info.days_of_week = 0x02; /* Tuesday */
103 info.flags = 0x11; /* periodic, non-interactive */
104 info.command = "foo.exe";
105 r.in.job_info = &info;
107 status = dcerpc_atsvc_JobAdd(p, tctx, &r);
109 torture_assert_ntstatus_ok(tctx, status, "JobAdd failed");
111 /* Run EnumJobs again in case there were no jobs to begin with */
113 if (!test_JobEnum(tctx, p)) {
114 return false;
117 if (!test_JobGetInfo(p, tctx, *r.out.job_id)) {
118 return false;
121 if (!test_JobDel(p, tctx, *r.out.job_id, *r.out.job_id)) {
122 return false;
125 return true;
128 struct torture_suite *torture_rpc_atsvc(TALLOC_CTX *mem_ctx)
130 struct torture_suite *suite = torture_suite_create(mem_ctx, "ATSVC");
131 struct torture_rpc_tcase *tcase;
133 tcase = torture_suite_add_rpc_iface_tcase(suite, "atsvc", &ndr_table_atsvc);
135 torture_rpc_tcase_add_test(tcase, "JobEnum", test_JobEnum);
136 torture_rpc_tcase_add_test(tcase, "JobAdd", test_JobAdd);
138 return suite;