summaryrefslogtreecommitdiff
path: root/source4/torture/rpc/initshutdown.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/torture/rpc/initshutdown.c')
-rw-r--r--source4/torture/rpc/initshutdown.c132
1 files changed, 54 insertions, 78 deletions
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;
}