From 18302e7030e568d23f13717cb006193490e4213d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 28 Aug 2007 16:24:18 +0000 Subject: r24751: Run more tests, remove empty testsuites, more small improvements. (This used to be commit 2a5a0819eea86ba322434306e062d13893b5722e) --- source4/torture/rpc/atsvc.c | 2 +- source4/torture/rpc/dfs.c | 124 +++++++++++----------- source4/torture/rpc/echo.c | 2 +- source4/torture/rpc/epmapper.c | 109 +++++++------------- source4/torture/rpc/eventlog.c | 2 +- source4/torture/rpc/initshutdown.c | 132 ++++++++++-------------- source4/torture/rpc/oxidresolve.c | 203 +++++++++++++++---------------------- source4/torture/rpc/remact.c | 78 ++++---------- source4/torture/rpc/rot.c | 47 --------- source4/torture/rpc/rpc.c | 11 +- source4/torture/rpc/srvsvc.c | 2 +- source4/torture/rpc/svcctl.c | 2 +- source4/torture/rpc/unixinfo.c | 2 +- source4/torture/rpc/winreg.c | 2 +- source4/torture/rpc/wkssvc.c | 2 +- 15 files changed, 270 insertions(+), 450 deletions(-) delete mode 100644 source4/torture/rpc/rot.c (limited to 'source4/torture/rpc') diff --git a/source4/torture/rpc/atsvc.c b/source4/torture/rpc/atsvc.c index da541fa1d1..f5295cc6cc 100644 --- a/source4/torture/rpc/atsvc.c +++ b/source4/torture/rpc/atsvc.c @@ -123,7 +123,7 @@ struct torture_suite *torture_rpc_atsvc(void) struct torture_suite *suite = torture_suite_create( talloc_autofree_context(), "ATSVC"); - struct torture_tcase *tcase; + struct torture_rpc_tcase *tcase; tcase = torture_suite_add_rpc_iface_tcase(suite, "atsvc", &ndr_table_atsvc); diff --git a/source4/torture/rpc/dfs.c b/source4/torture/rpc/dfs.c index 249af3ebb1..7dc600ae93 100644 --- a/source4/torture/rpc/dfs.c +++ b/source4/torture/rpc/dfs.c @@ -6,7 +6,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or + the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -15,7 +15,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "includes.h" @@ -29,8 +30,6 @@ #include "libcli/libcli.h" #include "lib/cmdline/popt_common.h" -#if 0 - #define SMBTORTURE_DFS_SHARENAME "smbtorture_dfs_share" #define SMBTORTURE_DFS_DIRNAME "\\smbtorture_dfs_dir" #define SMBTORTURE_DFS_PATHNAME "C:"SMBTORTURE_DFS_DIRNAME @@ -140,20 +139,23 @@ static BOOL test_DeleteDir(struct smbcli_state *cli, const char *dir) return True; } -static BOOL test_GetManagerVersion(struct torture_context *tctx, struct dcerpc_pipe *p, enum dfs_ManagerVersion *version) +static BOOL test_GetManagerVersion(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, enum dfs_ManagerVersion *version) { NTSTATUS status; struct dfs_GetManagerVersion r; r.out.version = version; - status = dcerpc_dfs_GetManagerVersion(p, tctx, &r); - torture_assert_ntstatus_ok(tctx, status, "GetManagerVersion failed"); + status = dcerpc_dfs_GetManagerVersion(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + printf("GetManagerVersion failed - %s\n", nt_errstr(status)); + return False; + } - return true; + return True; } -static BOOL test_ManagerInitialize(struct torture_context *tctx, struct dcerpc_pipe *p, const char *host) +static BOOL test_ManagerInitialize(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host) { NTSTATUS status; enum dfs_ManagerVersion version; @@ -161,14 +163,14 @@ static BOOL test_ManagerInitialize(struct torture_context *tctx, struct dcerpc_p printf("Testing ManagerInitialize\n"); - if (!test_GetManagerVersion(tctx, p, &version)) { + if (!test_GetManagerVersion(p, mem_ctx, &version)) { return False; } r.in.servername = host; r.in.flags = 0; - status = dcerpc_dfs_ManagerInitialize(p, tctx, &r); + status = dcerpc_dfs_ManagerInitialize(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("ManagerInitialize failed - %s\n", nt_errstr(status)); return False; @@ -181,31 +183,33 @@ static BOOL test_ManagerInitialize(struct torture_context *tctx, struct dcerpc_p return True; } -static BOOL test_GetInfoLevel(struct torture_context *tctx, struct dcerpc_pipe *p, uint16_t level, const char *root) +static BOOL test_GetInfoLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t level, + const char *root) { NTSTATUS status; struct dfs_GetInfo r; - torture_comment(tctx, - talloc_asprintf(tctx, "Testing GetInfo level %u on '%s'\n", level, root)); + printf("Testing GetInfo level %u on '%s'\n", level, root); - r.in.dfs_entry_path = talloc_strdup(tctx, root); + r.in.dfs_entry_path = talloc_strdup(mem_ctx, root); r.in.servername = NULL; r.in.sharename = NULL; r.in.level = level; - status = dcerpc_dfs_GetInfo(p, tctx, &r); - torture_assert_ntstatus_ok(tctx, status, "Info failed"); - torture_assert(tctx, W_ERROR_IS_OK(r.out.result) || - W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, r.out.result), - talloc_asprintf(tctx, - "dfs_GetInfo failed - %s", win_errstr(r.out.result))); + status = dcerpc_dfs_GetInfo(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + printf("GetInfo failed - %s\n", nt_errstr(status)); + return False; + } else if (!W_ERROR_IS_OK(r.out.result) && + !W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, r.out.result)) { + printf("dfs_GetInfo failed - %s\n", win_errstr(r.out.result)); + return False; + } return True; } -static bool test_Info(struct torture_context *tctx, - struct dcerpc_pipe *p, const char *root) +static BOOL test_GetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *root) { BOOL ret = True; /* 103, 104, 105, 106 is only available on Set */ @@ -213,15 +217,14 @@ static bool test_Info(struct torture_context *tctx, int i; for (i=0;is = &s; s.path = NULL; - status = dcerpc_dfs_Enum(p, tctx, &r); - torture_assert_ntstatus_ok(tctx, status, "Enum failed - %s\n", - nt_errstr(status)); - torture_assert(tctx, W_ERROR_IS_OK(r.out.result) || - W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, r.out.result), - "dfs_Enum failed - %s", win_errstr(r.out.result)); + printf("Testing Enum level %u\n", level); + + status = dcerpc_dfs_Enum(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + printf("Enum failed - %s\n", nt_errstr(status)); + return False; + } else if (!W_ERROR_IS_OK(r.out.result) && + !W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, r.out.result)) { + printf("dfs_Enum failed - %s\n", win_errstr(r.out.result)); + return False; + } if (level == 1 && r.out.total) { int i; for (i=0;i<*r.out.total;i++) { const char *root = r.out.info->e.info1->s[i].path; - if (!test_GetInfo(tctx, p, root)) { + if (!test_GetInfo(p, mem_ctx, root)) { ret = False; } } @@ -324,16 +332,15 @@ static BOOL test_EnumLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t } -static bool test_Enum(struct torture_context *tctx, - struct dcerpc_pipe *p) +static BOOL test_Enum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) { BOOL ret = True; uint16_t levels[] = {1, 2, 3, 4, 200, 300}; int i; for (i=0;itower); + display_tower(tctx, &r.out.entries[i].tower->tower); if (r.out.entries[i].tower->tower.num_floors == 5) { - test_Map(p, mem_ctx, r.out.entries[i].tower); + test_Map(p, tctx, r.out.entries[i].tower); } } } while (NT_STATUS_IS_OK(status) && @@ -180,13 +181,9 @@ static BOOL test_Lookup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) *r.out.num_ents == r.in.max_ents && !policy_handle_empty(&handle)); - if (!NT_STATUS_IS_OK(status)) { - printf("Lookup failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "Lookup failed"); - - return True; + return true; } static BOOL test_Delete(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct epm_entry_t *entries) @@ -211,7 +208,8 @@ static BOOL test_Delete(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct epm_e return True; } -static BOOL test_Insert(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_Insert(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct epm_Insert r; @@ -219,89 +217,60 @@ static BOOL test_Insert(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) r.in.num_ents = 1; - r.in.entries = talloc_array(mem_ctx, struct epm_entry_t, 1); + r.in.entries = talloc_array(tctx, struct epm_entry_t, 1); ZERO_STRUCT(r.in.entries[0].object); r.in.entries[0].annotation = "smbtorture endpoint"; - status = dcerpc_parse_binding(mem_ctx, "ncalrpc:[SMBTORTURE]", &bd); - if (NT_STATUS_IS_ERR(status)) { - printf("Unable to generate dcerpc_binding struct\n"); - return False; - } + status = dcerpc_parse_binding(tctx, "ncalrpc:[SMBTORTURE]", &bd); + torture_assert_ntstatus_ok(tctx, status, + "Unable to generate dcerpc_binding struct"); - r.in.entries[0].tower = talloc(mem_ctx, struct epm_twr_t); + r.in.entries[0].tower = talloc(tctx, struct epm_twr_t); - status = dcerpc_binding_build_tower(mem_ctx, bd, &r.in.entries[0].tower->tower); - if (NT_STATUS_IS_ERR(status)) { - printf("Unable to build tower from binding struct\n"); - return False; - } + status = dcerpc_binding_build_tower(tctx, bd, &r.in.entries[0].tower->tower); + torture_assert_ntstatus_ok(tctx, status, + "Unable to build tower from binding struct"); r.in.replace = 0; - status = dcerpc_epm_Insert(p, mem_ctx, &r); - if (NT_STATUS_IS_ERR(status)) { - printf("Insert failed - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_epm_Insert(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "Insert failed"); - if (r.out.result != 0) { - printf("Insert failed - %d\n", r.out.result); - printf("NOT CONSIDERING AS A FAILURE\n"); - return True; - } + torture_assert(tctx, r.out.result == 0, "Insert failed"); - if (!test_Delete(p, mem_ctx, r.in.entries)) { - return False; + if (!test_Delete(p, tctx, r.in.entries)) { + return false; } - return True; + return true; } -static BOOL test_InqObject(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_InqObject(struct torture_context *tctx, struct dcerpc_pipe *p) { NTSTATUS status; struct epm_InqObject r; - r.in.epm_object = talloc(mem_ctx, struct GUID); + r.in.epm_object = talloc(tctx, struct GUID); *r.in.epm_object = ndr_table_epmapper.syntax_id.uuid; - status = dcerpc_epm_InqObject(p, mem_ctx, &r); - if (NT_STATUS_IS_ERR(status)) { - printf("InqObject failed - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_epm_InqObject(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "InqObject failed"); - return True; + return true; } -BOOL torture_rpc_epmapper(struct torture_context *torture) +struct torture_suite *torture_rpc_epmapper(TALLOC_CTX *mem_ctx) { - NTSTATUS status; - struct dcerpc_pipe *p; - TALLOC_CTX *mem_ctx; - BOOL ret = True; - - mem_ctx = talloc_init("torture_rpc_epmapper"); - - status = torture_rpc_connection(torture, &p, &ndr_table_epmapper); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(mem_ctx); - return False; - } - - if (!test_Lookup(p, mem_ctx)) { - ret = False; - } + struct torture_suite *suite = torture_suite_create(mem_ctx, "EPMAPPER"); + struct torture_rpc_tcase *tcase; + + tcase = torture_suite_add_rpc_iface_tcase(suite, "epmapper", + &ndr_table_epmapper); - if (!test_Insert(p, mem_ctx)) { - ret = False; - } + torture_rpc_tcase_add_test(tcase, "Lookup", test_Lookup); - if (!test_InqObject(p, mem_ctx)) { - ret = False; - } + torture_rpc_tcase_add_test(tcase, "Insert", test_Insert); - talloc_free(mem_ctx); + torture_rpc_tcase_add_test(tcase, "InqObject", test_InqObject); - return ret; + return suite; } diff --git a/source4/torture/rpc/eventlog.c b/source4/torture/rpc/eventlog.c index 0c4ee14f85..1c72625f73 100644 --- a/source4/torture/rpc/eventlog.c +++ b/source4/torture/rpc/eventlog.c @@ -236,7 +236,7 @@ static bool test_OpenEventLog(struct torture_context *tctx, struct torture_suite *torture_rpc_eventlog(void) { struct torture_suite *suite; - struct torture_tcase *tcase; + struct torture_rpc_tcase *tcase; suite = torture_suite_create(talloc_autofree_context(), "EVENTLOG"); tcase = torture_suite_add_rpc_iface_tcase(suite, "eventlog", diff --git a/source4/torture/rpc/initshutdown.c b/source4/torture/rpc/initshutdown.c index aa817928ab..77b86ea3a1 100644 --- a/source4/torture/rpc/initshutdown.c +++ b/source4/torture/rpc/initshutdown.c @@ -30,115 +30,91 @@ static void init_initshutdown_String(TALLOC_CTX *mem_ctx, struct initshutdown_St name->name->name = s; } -static BOOL test_Init(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - const char *msg, uint32_t timeout) + +static bool test_Abort(struct torture_context *tctx, + struct dcerpc_pipe *p) { - struct initshutdown_Init r; + struct initshutdown_Abort r; NTSTATUS status; - uint16_t hostname = 0x0; - - r.in.hostname = &hostname; - r.in.message = talloc(mem_ctx, struct initshutdown_String); - init_initshutdown_String(mem_ctx, r.in.message, msg); - r.in.force_apps = 1; - r.in.timeout = timeout; - r.in.reboot = 1; + uint16_t server = 0x0; - status = dcerpc_initshutdown_Init(p, mem_ctx, &r); + r.in.server = &server; + + status = dcerpc_initshutdown_Abort(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("initshutdown_Init failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, + "initshutdown_Abort failed"); - if (!W_ERROR_IS_OK(r.out.result)) { - printf("initshutdown_Init failed - %s\n", win_errstr(r.out.result)); - return False; - } + torture_assert_werr_ok(tctx, r.out.result, "initshutdown_Abort failed"); - return True; + return true; } -static BOOL test_InitEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - const char *msg, uint32_t timeout) +static bool test_Init(struct torture_context *tctx, + struct dcerpc_pipe *p) { - struct initshutdown_InitEx r; + struct initshutdown_Init r; NTSTATUS status; uint16_t hostname = 0x0; + + if (!torture_setting_bool(tctx, "dangerous", false)) + torture_skip(tctx, + "initshutdown tests disabled - enable dangerous tests to use"); r.in.hostname = &hostname; - r.in.message = talloc(mem_ctx, struct initshutdown_String); - init_initshutdown_String(mem_ctx, r.in.message, msg); + r.in.message = talloc(tctx, struct initshutdown_String); + init_initshutdown_String(tctx, r.in.message, "spottyfood"); r.in.force_apps = 1; - r.in.timeout = timeout; + r.in.timeout = 30; r.in.reboot = 1; - r.in.reason = 0; - status = dcerpc_initshutdown_InitEx(p, mem_ctx, &r); + status = dcerpc_initshutdown_Init(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("initshutdown_InitEx failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "initshutdown_Init failed"); + torture_assert_werr_ok(tctx, r.out.result, "initshutdown_Init failed"); - if (!W_ERROR_IS_OK(r.out.result)) { - printf("initshutdown_InitEx failed - %s\n", win_errstr(r.out.result)); - return False; - } - - return True; + return test_Abort(tctx, p); } -static BOOL test_Abort(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_InitEx(struct torture_context *tctx, + struct dcerpc_pipe *p) { - struct initshutdown_Abort r; + struct initshutdown_InitEx r; NTSTATUS status; - uint16_t server = 0x0; + uint16_t hostname = 0x0; - r.in.server = &server; + if (!torture_setting_bool(tctx, "dangerous", false)) + torture_skip(tctx, + "initshutdown tests disabled - enable dangerous tests to use"); - status = dcerpc_initshutdown_Abort(p, mem_ctx, &r); - - if (!NT_STATUS_IS_OK(status)) { - printf("initshutdown_Abort failed - %s\n", nt_errstr(status)); - return False; - } + r.in.hostname = &hostname; + r.in.message = talloc(tctx, struct initshutdown_String); + init_initshutdown_String(tctx, r.in.message, "spottyfood"); + r.in.force_apps = 1; + r.in.timeout = 30; + r.in.reboot = 1; + r.in.reason = 0; - if (!W_ERROR_IS_OK(r.out.result)) { - printf("initshutdown_Abort failed - %s\n", win_errstr(r.out.result)); - return False; - } + status = dcerpc_initshutdown_InitEx(p, tctx, &r); - return True; -} + torture_assert_ntstatus_ok(tctx, status, "initshutdown_InitEx failed"); -BOOL torture_rpc_initshutdown(struct torture_context *torture) -{ - NTSTATUS status; - struct dcerpc_pipe *p; - TALLOC_CTX *mem_ctx; - BOOL ret = True; + torture_assert_werr_ok(tctx, r.out.result, "initshutdown_InitEx failed"); - mem_ctx = talloc_init("torture_rpc_initshutdown"); + return test_Abort(tctx, p); +} - status = torture_rpc_connection(torture, &p, &ndr_table_initshutdown); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(mem_ctx); - return False; - } +struct torture_suite *torture_rpc_initshutdown(TALLOC_CTX *mem_ctx) +{ + struct torture_suite *suite = torture_suite_create(mem_ctx, "INITSHUTDOWN"); + struct torture_rpc_tcase *tcase; - if (!torture_setting_bool(torture, "dangerous", False)) { - torture_comment(torture, - "initshutdown tests disabled - enable dangerous tests to use\n"); - } else { - ret &= test_Init(p, mem_ctx, "spottyfood", 30); - ret &= test_Abort(p, mem_ctx); - ret &= test_InitEx(p, mem_ctx, "spottyfood", 30); - ret &= test_Abort(p, mem_ctx); - } + tcase = torture_suite_add_rpc_iface_tcase(suite, "initshutdown", + &ndr_table_initshutdown); - talloc_free(mem_ctx); + torture_rpc_tcase_add_test(tcase, "Init", test_Init); + torture_rpc_tcase_add_test(tcase, "InitEx", test_InitEx); - return ret; + return suite; } diff --git a/source4/torture/rpc/oxidresolve.c b/source4/torture/rpc/oxidresolve.c index 2809a2a3fb..02edb306b3 100644 --- a/source4/torture/rpc/oxidresolve.c +++ b/source4/torture/rpc/oxidresolve.c @@ -31,12 +31,21 @@ const struct GUID IUnknown_uuid = { 0x00000000,0x0000,0x0000,{0xc0,0x00},{0x00,0x00,0x00,0x00,0x00,0x46} }; -static int test_RemoteActivation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint64_t *oxid, struct GUID *oid) +static bool test_RemoteActivation(struct torture_context *tctx, + uint64_t *oxid, struct GUID *oid) { struct RemoteActivation r; NTSTATUS status; struct GUID iids[2]; uint16_t protseq[3] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_UUID }; + struct dcerpc_pipe *p; + + status = torture_rpc_connection(tctx, &p, + &ndr_table_IRemoteActivation); + + if (!NT_STATUS_IS_OK(status)) { + return false; + } ZERO_STRUCT(r.in); r.in.this.version.MajorVersion = 5; @@ -52,66 +61,67 @@ static int test_RemoteActivation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uin r.out.pOxid = oxid; r.out.ipidRemUnknown = oid; - status = dcerpc_RemoteActivation(p, mem_ctx, &r); + status = dcerpc_RemoteActivation(p, tctx, &r); if(NT_STATUS_IS_ERR(status)) { fprintf(stderr, "RemoteActivation: %s\n", nt_errstr(status)); - return 0; + return false; } if(!W_ERROR_IS_OK(r.out.result)) { fprintf(stderr, "RemoteActivation: %s\n", win_errstr(r.out.result)); - return 0; + return false; } if(!W_ERROR_IS_OK(*r.out.hr)) { fprintf(stderr, "RemoteActivation: %s\n", win_errstr(*r.out.hr)); - return 0; + return false; } if(!W_ERROR_IS_OK(r.out.results[0])) { fprintf(stderr, "RemoteActivation: %s\n", win_errstr(r.out.results[0])); - return 0; + return false; } - - return 1; + return true; } -static int test_SimplePing(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint64_t setid) +static bool test_SimplePing(struct torture_context *tctx, + struct dcerpc_pipe *p) { struct SimplePing r; NTSTATUS status; + uint64_t setid; r.in.SetId = &setid; - status = dcerpc_SimplePing(p, mem_ctx, &r); - if(NT_STATUS_IS_ERR(status)) { - fprintf(stderr, "SimplePing: %s\n", nt_errstr(status)); - return 0; - } - - if(!W_ERROR_IS_OK(r.out.result)) { - fprintf(stderr, "SimplePing: %s\n", win_errstr(r.out.result)); - return 0; - } + status = dcerpc_SimplePing(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "SimplePing"); + torture_assert_werr_ok(tctx, r.out.result, "SimplePing"); - return 1; + return true; } -static int test_ComplexPing(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint64_t *setid, struct GUID oid) +static bool test_ComplexPing(struct torture_context *tctx, + struct dcerpc_pipe *p) { struct ComplexPing r; NTSTATUS status; + uint64_t setid; + struct GUID oid; + uint64_t oxid; - *setid = 0; + if (!test_RemoteActivation(tctx, &oxid, &oid)) + return false; + + setid = 0; ZERO_STRUCT(r.in); r.in.SequenceNum = 0; - r.in.SetId = setid; + r.in.SetId = &setid; r.in.cAddToSet = 1; r.in.AddToSet = &oid; - status = dcerpc_ComplexPing(p, mem_ctx, &r); + status = dcerpc_ComplexPing(p, tctx, &r); if(NT_STATUS_IS_ERR(status)) { fprintf(stderr, "ComplexPing: %s\n", nt_errstr(status)); return 0; @@ -127,148 +137,101 @@ static int test_ComplexPing(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint64_t return 1; } -static int test_ServerAlive(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_ServerAlive(struct torture_context *tctx, + struct dcerpc_pipe *p) { struct ServerAlive r; NTSTATUS status; - status = dcerpc_ServerAlive(p, mem_ctx, &r); - if(NT_STATUS_IS_ERR(status)) { - fprintf(stderr, "ServerAlive: %s\n", nt_errstr(status)); - return 0; - } - - if(!W_ERROR_IS_OK(r.out.result)) { - fprintf(stderr, "ServerAlive: %s\n", win_errstr(r.out.result)); - return 0; - } + status = dcerpc_ServerAlive(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "ServerAlive"); + torture_assert_werr_ok(tctx, r.out.result, "ServerAlive"); - return 1; + return true; } -static int test_ResolveOxid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint64_t oxid) +static bool test_ResolveOxid(struct torture_context *tctx, + struct dcerpc_pipe *p) { struct ResolveOxid r; NTSTATUS status; uint16_t protseq[2] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_SMB }; + uint64_t oxid; + struct GUID oid; + + if (!test_RemoteActivation(tctx, &oxid, &oid)) + return false; r.in.pOxid = oxid; r.in.cRequestedProtseqs = 2; r.in.arRequestedProtseqs = protseq; - status = dcerpc_ResolveOxid(p, mem_ctx, &r); - if(NT_STATUS_IS_ERR(status)) { - fprintf(stderr, "ResolveOxid: %s\n", nt_errstr(status)); - return 0; - } - - if(!W_ERROR_IS_OK(r.out.result)) { - fprintf(stderr, "ResolveOxid: %s\n", win_errstr(r.out.result)); - return 0; - } + status = dcerpc_ResolveOxid(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "ResolveOxid"); + torture_assert_werr_ok(tctx, r.out.result, "ResolveOxid"); - return 1; + return true; } -static int test_ResolveOxid2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint64_t oxid) +static bool test_ResolveOxid2(struct torture_context *tctx, + struct dcerpc_pipe *p) { struct ResolveOxid2 r; NTSTATUS status; uint16_t protseq[2] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_SMB }; + uint64_t oxid; + struct GUID oid; + + if (!test_RemoteActivation(tctx, &oxid, &oid)) + return false; r.in.pOxid = oxid; r.in.cRequestedProtseqs = 2; r.in.arRequestedProtseqs = protseq; - status = dcerpc_ResolveOxid2(p, mem_ctx, &r); - if(NT_STATUS_IS_ERR(status)) { - fprintf(stderr, "ResolveOxid2: %s\n", nt_errstr(status)); - return 0; - } + status = dcerpc_ResolveOxid2(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "ResolveOxid2"); - if(!W_ERROR_IS_OK(r.out.result)) { - fprintf(stderr, "ResolveOxid2: %s\n", win_errstr(r.out.result)); - return 0; - } + torture_assert_werr_ok(tctx, r.out.result, "ResolveOxid2"); - printf("Remote server versions: %d, %d\n", r.out.ComVersion->MajorVersion, r.out.ComVersion->MinorVersion); + torture_comment(tctx, "Remote server versions: %d, %d\n", r.out.ComVersion->MajorVersion, r.out.ComVersion->MinorVersion); - return 1; + return true; } - - -static int test_ServerAlive2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_ServerAlive2(struct torture_context *tctx, + struct dcerpc_pipe *p) { struct ServerAlive2 r; NTSTATUS status; - status = dcerpc_ServerAlive2(p, mem_ctx, &r); - if(NT_STATUS_IS_ERR(status)) { - fprintf(stderr, "ServerAlive2: %s\n", nt_errstr(status)); - return 0; - } - - if(!W_ERROR_IS_OK(r.out.result)) { - fprintf(stderr, "ServerAlive2: %s\n", win_errstr(r.out.result)); - return 0; - } + status = dcerpc_ServerAlive2(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "ServerAlive2"); + torture_assert_werr_ok(tctx, r.out.result, "ServerAlive2"); - return 1; + return true; } -BOOL torture_rpc_oxidresolve(struct torture_context *torture) +struct torture_suite *torture_rpc_oxidresolve(TALLOC_CTX *mem_ctx) { - NTSTATUS status; - struct dcerpc_pipe *p, *premact; - TALLOC_CTX *mem_ctx; - BOOL ret = True; - uint64_t setid; - uint64_t oxid; - struct GUID oid; - - mem_ctx = talloc_init("torture_rpc_oxidresolve"); - - status = torture_rpc_connection(torture, - &premact, - &ndr_table_IRemoteActivation); - - if (!NT_STATUS_IS_OK(status)) { - talloc_free(mem_ctx); - return False; - } - - status = torture_rpc_connection(torture, - &p, - &ndr_table_IOXIDResolver); - - if (!NT_STATUS_IS_OK(status)) { - talloc_free(mem_ctx); - return False; - } - - if(!test_ServerAlive(p, mem_ctx)) - ret = False; + struct torture_suite *suite = torture_suite_create(mem_ctx, + "OXIDRESOLVE"); + struct torture_rpc_tcase *tcase; - if(!test_ServerAlive2(p, mem_ctx)) - ret = False; + tcase = torture_suite_add_rpc_iface_tcase(suite, "oxidresolver", + &ndr_table_IOXIDResolver); - if(!test_RemoteActivation(premact, mem_ctx, &oxid, &oid)) - return False; + torture_rpc_tcase_add_test(tcase, "ServerAlive", test_ServerAlive); - if(!test_ComplexPing(p, mem_ctx, &setid, oid)) - ret = False; + torture_rpc_tcase_add_test(tcase, "ServerAlive2", test_ServerAlive2); - if(!test_SimplePing(p, mem_ctx, setid)) - ret = False; + torture_rpc_tcase_add_test(tcase, "ComplexPing", test_ComplexPing); - if(!test_ResolveOxid(p, mem_ctx, oxid)) - ret = False; - - if(!test_ResolveOxid2(p, mem_ctx, oxid)) - ret = False; + torture_rpc_tcase_add_test(tcase, "SimplePing", test_SimplePing); + + torture_rpc_tcase_add_test(tcase, "ResolveOxid", test_ResolveOxid); - talloc_free(mem_ctx); + torture_rpc_tcase_add_test(tcase, "ResolveOxid2", test_ResolveOxid2); - return ret; + return suite; } diff --git a/source4/torture/rpc/remact.c b/source4/torture/rpc/remact.c index d1294f429d..1fc3c1376b 100644 --- a/source4/torture/rpc/remact.c +++ b/source4/torture/rpc/remact.c @@ -28,7 +28,8 @@ #define DCERPC_IUNKNOWN_UUID "00000000-0000-0000-c000-000000000046" #define DCERPC_ICLASSFACTORY_UUID "00000001-0000-0000-c000-000000000046" -static int test_RemoteActivation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_RemoteActivation(struct torture_context *tctx, + struct dcerpc_pipe *p) { struct RemoteActivation r; NTSTATUS status; @@ -47,77 +48,42 @@ static int test_RemoteActivation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) GUID_from_string(DCERPC_IUNKNOWN_UUID, &iids[0]); r.in.pIIDs = iids; - status = dcerpc_RemoteActivation(p, mem_ctx, &r); - if(NT_STATUS_IS_ERR(status)) { - printf("RemoteActivation: %s\n", nt_errstr(status)); - return 0; - } + status = dcerpc_RemoteActivation(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "RemoteActivation"); - if(!W_ERROR_IS_OK(r.out.result)) { - printf("RemoteActivation: %s\n", win_errstr(r.out.result)); - return 0; - } + torture_assert_werr_ok(tctx, r.out.result, "RemoteActivation"); - if(!W_ERROR_IS_OK(*r.out.hr)) { - printf("RemoteActivation: %s\n", win_errstr(*r.out.hr)); - return 0; - } + torture_assert_werr_ok(tctx, *r.out.hr, "RemoteActivation"); - if(!W_ERROR_IS_OK(r.out.results[0])) { - printf("RemoteActivation: %s\n", win_errstr(r.out.results[0])); - return 0; - } + torture_assert_werr_ok(tctx, r.out.results[0], "RemoteActivation"); GUID_from_string(DCERPC_ICLASSFACTORY_UUID, &iids[0]); r.in.Interfaces = 1; r.in.Mode = MODE_GET_CLASS_OBJECT; - status = dcerpc_RemoteActivation(p, mem_ctx, &r); - if(NT_STATUS_IS_ERR(status)) { - printf("RemoteActivation(GetClassObject): %s\n", nt_errstr(status)); - return 0; - } + status = dcerpc_RemoteActivation(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, + "RemoteActivation(GetClassObject)"); - if(!W_ERROR_IS_OK(r.out.result)) { - printf("RemoteActivation(GetClassObject): %s\n", win_errstr(r.out.result)); - return 0; - } + torture_assert_werr_ok(tctx, r.out.result, + "RemoteActivation(GetClassObject)"); - if(!W_ERROR_IS_OK(*r.out.hr)) { - printf("RemoteActivation(GetClassObject): %s\n", win_errstr(*r.out.hr)); - return 0; - } + torture_assert_werr_ok(tctx, *r.out.hr, "RemoteActivation(GetClassObject)"); - if(!W_ERROR_IS_OK(r.out.results[0])) { - printf("RemoteActivation(GetClassObject): %s\n", win_errstr(r.out.results[0])); - return 0; - } + torture_assert_werr_ok(tctx, r.out.results[0], + "RemoteActivation(GetClassObject)"); - return 1; + return true; } -BOOL torture_rpc_remact(struct torture_context *torture) +struct torture_suite *torture_rpc_remact(TALLOC_CTX *mem_ctx) { - NTSTATUS status; - struct dcerpc_pipe *p; - TALLOC_CTX *mem_ctx; - BOOL ret = True; - - mem_ctx = talloc_init("torture_rpc_remact"); - - status = torture_rpc_connection(torture, - &p, - &ndr_table_IRemoteActivation); - - if (!NT_STATUS_IS_OK(status)) { - talloc_free(mem_ctx); - return False; - } + struct torture_suite *suite = torture_suite_create(mem_ctx, "REMACT"); + struct torture_rpc_tcase *tcase; - if(!test_RemoteActivation(p, mem_ctx)) - ret = False; + tcase = torture_suite_add_rpc_iface_tcase(suite, "remact", &ndr_table_IRemoteActivation); - talloc_free(mem_ctx); + torture_rpc_tcase_add_test(tcase, "RemoteActivation", test_RemoteActivation); - return ret; + return suite; } diff --git a/source4/torture/rpc/rot.c b/source4/torture/rpc/rot.c deleted file mode 100644 index 32a18b1d32..0000000000 --- a/source4/torture/rpc/rot.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - Unix SMB/CIFS implementation. - test suite for the running object table - - Copyright (C) Jelmer Vernooij 2004 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "includes.h" -#include "torture/torture.h" -#include "librpc/gen_ndr/ndr_rot.h" -#include "torture/rpc/rpc.h" - -BOOL torture_rpc_rot(struct torture_context *torture) -{ - NTSTATUS status; - struct dcerpc_pipe *p; - TALLOC_CTX *mem_ctx; - BOOL ret = True; - - mem_ctx = talloc_init("torture_rpc_rot"); - - status = torture_rpc_connection(torture, - &p, - &ndr_table_rot); - - if (!NT_STATUS_IS_OK(status)) { - talloc_free(mem_ctx); - return False; - } - - talloc_free(mem_ctx); - - return ret; -} diff --git a/source4/torture/rpc/rpc.c b/source4/torture/rpc/rpc.c index 21a85fbf03..3d8a56ffba 100644 --- a/source4/torture/rpc/rpc.c +++ b/source4/torture/rpc/rpc.c @@ -250,7 +250,7 @@ NTSTATUS torture_rpc_init(void) torture_suite_add_simple_test(suite, "LSA-GETUSER", torture_rpc_lsa_get_user); torture_suite_add_simple_test(suite, "SECRETS", torture_rpc_lsa_secrets); torture_suite_add_suite(suite, torture_rpc_echo()); - torture_suite_add_suite(suite, torture_rpc_dfs()); + torture_suite_add_simple_test(suite, "DFS", torture_rpc_dfs); torture_suite_add_suite(suite, torture_rpc_unixinfo()); torture_suite_add_suite(suite, torture_rpc_eventlog()); torture_suite_add_suite(suite, torture_rpc_atsvc()); @@ -268,10 +268,10 @@ NTSTATUS torture_rpc_init(void) torture_suite_add_simple_test(suite, "SCHANNEL2", torture_rpc_schannel2); torture_suite_add_suite(suite, torture_rpc_srvsvc(suite)); torture_suite_add_suite(suite, torture_rpc_svcctl(suite)); - torture_suite_add_simple_test(suite, "EPMAPPER", torture_rpc_epmapper); - torture_suite_add_simple_test(suite, "INITSHUTDOWN", torture_rpc_initshutdown); - torture_suite_add_simple_test(suite, "OXIDRESOLVE", torture_rpc_oxidresolve); - torture_suite_add_simple_test(suite, "REMACT", torture_rpc_remact); + torture_suite_add_suite(suite, torture_rpc_epmapper(suite)); + torture_suite_add_suite(suite, torture_rpc_initshutdown(suite)); + torture_suite_add_suite(suite, torture_rpc_oxidresolve(suite)); + torture_suite_add_suite(suite, torture_rpc_remact(suite)); torture_suite_add_simple_test(suite, "MGMT", torture_rpc_mgmt); torture_suite_add_simple_test(suite, "SCANNER", torture_rpc_scanner); torture_suite_add_simple_test(suite, "AUTOIDL", torture_rpc_autoidl); @@ -292,7 +292,6 @@ NTSTATUS torture_rpc_init(void) torture_suite_add_simple_test(suite, "RPC-SAMBA3-WINREG", torture_samba3_rpc_winreg); torture_suite_add_simple_test(suite, "DRSUAPI", torture_rpc_drsuapi); torture_suite_add_simple_test(suite, "CRACKNAMES", torture_rpc_drsuapi_cracknames); - torture_suite_add_simple_test(suite, "ROT", torture_rpc_rot); torture_suite_add_simple_test(suite, "DSSETUP", torture_rpc_dssetup); torture_suite_add_simple_test(suite, "ALTERCONTEXT", torture_rpc_alter_context); torture_suite_add_simple_test(suite, "JOIN", torture_rpc_join); diff --git a/source4/torture/rpc/srvsvc.c b/source4/torture/rpc/srvsvc.c index 15d8502867..a51dc96876 100644 --- a/source4/torture/rpc/srvsvc.c +++ b/source4/torture/rpc/srvsvc.c @@ -1131,7 +1131,7 @@ again: struct torture_suite *torture_rpc_srvsvc(TALLOC_CTX *mem_ctx) { struct torture_suite *suite = torture_suite_create(mem_ctx, "SRVSVC"); - struct torture_tcase *tcase; + struct torture_rpc_tcase *tcase; tcase = torture_suite_add_rpc_iface_tcase(suite, "srvsvc (admin access)", &ndr_table_srvsvc); diff --git a/source4/torture/rpc/svcctl.c b/source4/torture/rpc/svcctl.c index 4390b8dd3e..2f2b4ec485 100644 --- a/source4/torture/rpc/svcctl.c +++ b/source4/torture/rpc/svcctl.c @@ -117,7 +117,7 @@ static bool test_SCManager(struct torture_context *tctx, struct torture_suite *torture_rpc_svcctl(TALLOC_CTX *mem_ctx) { struct torture_suite *suite = torture_suite_create(mem_ctx, "SVCCTL"); - struct torture_tcase *tcase; + struct torture_rpc_tcase *tcase; tcase = torture_suite_add_rpc_iface_tcase(suite, "svcctl", &ndr_table_svcctl); diff --git a/source4/torture/rpc/unixinfo.c b/source4/torture/rpc/unixinfo.c index 6a8a664020..80d7d96a9e 100644 --- a/source4/torture/rpc/unixinfo.c +++ b/source4/torture/rpc/unixinfo.c @@ -128,7 +128,7 @@ static bool test_gidtosid(struct torture_context *tctx, struct dcerpc_pipe *p) struct torture_suite *torture_rpc_unixinfo(void) { struct torture_suite *suite; - struct torture_tcase *tcase; + struct torture_rpc_tcase *tcase; suite = torture_suite_create(talloc_autofree_context(), "UNIXINFO"); tcase = torture_suite_add_rpc_iface_tcase(suite, "unixinfo", diff --git a/source4/torture/rpc/winreg.c b/source4/torture/rpc/winreg.c index 7559a4d8ac..a3d671c489 100644 --- a/source4/torture/rpc/winreg.c +++ b/source4/torture/rpc/winreg.c @@ -747,7 +747,7 @@ struct torture_suite *torture_rpc_winreg(TALLOC_CTX *mem_ctx) {"OpenHKCR", (winreg_open_fn)dcerpc_winreg_OpenHKCR }, {"OpenHKCU", (winreg_open_fn)dcerpc_winreg_OpenHKCU }}; int i; - struct torture_tcase *tcase; + struct torture_rpc_tcase *tcase; struct torture_suite *suite = torture_suite_create(mem_ctx, "WINREG"); tcase = torture_suite_add_rpc_iface_tcase(suite, "winreg", diff --git a/source4/torture/rpc/wkssvc.c b/source4/torture/rpc/wkssvc.c index 49adcb7c29..89be804b07 100644 --- a/source4/torture/rpc/wkssvc.c +++ b/source4/torture/rpc/wkssvc.c @@ -80,7 +80,7 @@ static bool test_NetWkstaTransportEnum(struct torture_context *tctx, struct torture_suite *torture_rpc_wkssvc(void) { struct torture_suite *suite; - struct torture_tcase *tcase; + struct torture_rpc_tcase *tcase; suite = torture_suite_create(talloc_autofree_context(), "WKSSVC"); tcase = torture_suite_add_rpc_iface_tcase(suite, "wkssvc", -- cgit