summaryrefslogtreecommitdiff
path: root/source4/torture/rpc
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2006-10-16 13:06:41 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:21:12 -0500
commit8773e743c518578584d07d35ffdafdd598af88b0 (patch)
tree89726232dd6ae9eca1c219e21729a9b2336ddaa9 /source4/torture/rpc
parent0f2347e417dec4a50f95d64353b260cd53a44a2b (diff)
downloadsamba-8773e743c518578584d07d35ffdafdd598af88b0.tar.gz
samba-8773e743c518578584d07d35ffdafdd598af88b0.tar.bz2
samba-8773e743c518578584d07d35ffdafdd598af88b0.zip
r19339: Merge my 4.0-unittest branch. This adds an API for more fine-grained
output in the testsuite rather than just True or False for a set of tests. The aim is to use this for: * known failure lists (run all tests and detect tests that started working or started failing). This would allow us to get rid of the RPC-SAMBA3-* tests * nicer torture output * simplification of the testsuite system * compatibility with other unit testing systems * easier usage of smbtorture (being able to run one test and automatically set up the environment for that) This is still a work-in-progress; expect more updates over the next couple of days. (This used to be commit 0eb6097305776325c75081356309115f445a7218)
Diffstat (limited to 'source4/torture/rpc')
-rw-r--r--source4/torture/rpc/atsvc.c102
-rw-r--r--source4/torture/rpc/dfs.c122
-rw-r--r--source4/torture/rpc/echo.c379
-rw-r--r--source4/torture/rpc/eventlog.c255
-rw-r--r--source4/torture/rpc/rpc.c173
-rw-r--r--source4/torture/rpc/rpc.h1
-rw-r--r--source4/torture/rpc/unixinfo.c65
-rw-r--r--source4/torture/rpc/wkssvc.c77
8 files changed, 545 insertions, 629 deletions
diff --git a/source4/torture/rpc/atsvc.c b/source4/torture/rpc/atsvc.c
index e586a1e98f..227e56a85b 100644
--- a/source4/torture/rpc/atsvc.c
+++ b/source4/torture/rpc/atsvc.c
@@ -24,7 +24,7 @@
#include "librpc/gen_ndr/ndr_atsvc_c.h"
#include "torture/rpc/rpc.h"
-static BOOL test_JobGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint32_t job_id)
+static bool test_JobGetInfo(struct dcerpc_pipe *p, struct torture_context *tctx, uint32_t job_id)
{
NTSTATUS status;
struct atsvc_JobGetInfo r;
@@ -32,17 +32,14 @@ static BOOL test_JobGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint32_t
r.in.servername = dcerpc_server_name(p);
r.in.job_id = job_id;
- status = dcerpc_atsvc_JobGetInfo(p, mem_ctx, &r);
+ status = dcerpc_atsvc_JobGetInfo(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("JobGetInfo failed - %s\n", nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "JobGetInfo failed");
- return True;
+ return true;
}
-static BOOL test_JobDel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint32_t min_job_id,
+static bool test_JobDel(struct dcerpc_pipe *p, struct torture_context *tctx, uint32_t min_job_id,
uint32_t max_job_id)
{
NTSTATUS status;
@@ -52,25 +49,20 @@ static BOOL test_JobDel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint32_t min
r.in.min_job_id = min_job_id;
r.in.max_job_id = max_job_id;
- status = dcerpc_atsvc_JobDel(p, mem_ctx, &r);
+ status = dcerpc_atsvc_JobDel(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("JobDel failed - %s\n", nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "JobDel failed");
- return True;
+ return true;
}
-static BOOL test_JobEnum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_JobEnum(struct torture_context *tctx, struct dcerpc_pipe *p)
{
NTSTATUS status;
struct atsvc_JobEnum r;
struct atsvc_enum_ctr ctr;
uint32_t resume_handle = 0, i;
- BOOL ret = True;
-
- printf("\ntesting JobEnum\n");
+ bool ret = true;
r.in.servername = dcerpc_server_name(p);
ctr.entries_read = 0;
@@ -79,15 +71,12 @@ static BOOL test_JobEnum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
r.in.preferred_max_len = 0xffffffff;
r.in.resume_handle = r.out.resume_handle = &resume_handle;
- status = dcerpc_atsvc_JobEnum(p, mem_ctx, &r);
+ status = dcerpc_atsvc_JobEnum(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("JobEnum failed - %s\n", nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "JobEnum failed");
for (i = 0; i < r.out.ctr->entries_read; i++) {
- if (!test_JobGetInfo(p, mem_ctx, r.out.ctr->first_entry[i].job_id)) {
+ if (!test_JobGetInfo(p, tctx, r.out.ctr->first_entry[i].job_id)) {
ret = False;
}
}
@@ -95,14 +84,12 @@ static BOOL test_JobEnum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
return ret;
}
-static BOOL test_JobAdd(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_JobAdd(struct torture_context *tctx, struct dcerpc_pipe *p)
{
NTSTATUS status;
struct atsvc_JobAdd r;
struct atsvc_JobInfo info;
- printf("\ntesting JobAdd\n");
-
r.in.servername = dcerpc_server_name(p);
info.job_time = 0x050ae4c0; /* 11:30pm */
info.days_of_month = 0; /* n/a */
@@ -111,56 +98,39 @@ static BOOL test_JobAdd(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
info.command = "foo.exe";
r.in.job_info = &info;
- status = dcerpc_atsvc_JobAdd(p, mem_ctx, &r);
+ status = dcerpc_atsvc_JobAdd(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("JobAdd failed - %s\n", nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "JobAdd failed");
/* Run EnumJobs again in case there were no jobs to begin with */
- if (!test_JobEnum(p, mem_ctx)) {
- return False;
+ if (!test_JobEnum(tctx, p)) {
+ return false;
}
- if (!test_JobGetInfo(p, mem_ctx, r.out.job_id)) {
- return False;
+ if (!test_JobGetInfo(p, tctx, r.out.job_id)) {
+ return false;
}
- if (!test_JobDel(p, mem_ctx, r.out.job_id, r.out.job_id)) {
- return False;
+ if (!test_JobDel(p, tctx, r.out.job_id, r.out.job_id)) {
+ return false;
}
- return True;
+ return true;
}
-BOOL torture_rpc_atsvc(struct torture_context *torture)
+struct torture_suite *torture_rpc_atsvc(void)
{
- NTSTATUS status;
- struct dcerpc_pipe *p;
- TALLOC_CTX *mem_ctx;
- BOOL ret = True;
-
- mem_ctx = talloc_init("torture_rpc_atsvc");
-
- status = torture_rpc_connection(mem_ctx, &p, &dcerpc_table_atsvc);
- if (!NT_STATUS_IS_OK(status)) {
- talloc_free(mem_ctx);
- return False;
- }
-
- if (!test_JobEnum(p, mem_ctx)) {
- talloc_free(mem_ctx);
- return False;
- }
-
- if (!test_JobAdd(p, mem_ctx)) {
- talloc_free(mem_ctx);
- return False;
- }
-
- talloc_free(mem_ctx);
-
- return ret;
+ struct torture_suite *suite = torture_suite_create(
+ talloc_autofree_context(),
+ "ATSVC");
+ struct torture_tcase *tcase;
+
+ tcase = torture_suite_add_rpc_iface_tcase(suite, "atsvc",
+ &dcerpc_table_atsvc);
+
+ torture_rpc_tcase_add_test(tcase, "JobEnum", test_JobEnum);
+ torture_rpc_tcase_add_test(tcase, "JobAdd", test_JobAdd);
+
+ return suite;
}
diff --git a/source4/torture/rpc/dfs.c b/source4/torture/rpc/dfs.c
index 3eebfc5e5d..6af65e4f44 100644
--- a/source4/torture/rpc/dfs.c
+++ b/source4/torture/rpc/dfs.c
@@ -30,6 +30,8 @@
#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
@@ -139,23 +141,20 @@ static BOOL test_DeleteDir(struct smbcli_state *cli, const char *dir)
return True;
}
-static BOOL test_GetManagerVersion(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, enum dfs_ManagerVersion *version)
+static BOOL test_GetManagerVersion(struct torture_context *tctx, struct dcerpc_pipe *p, enum dfs_ManagerVersion *version)
{
NTSTATUS status;
struct dfs_GetManagerVersion r;
r.out.version = version;
- status = dcerpc_dfs_GetManagerVersion(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("GetManagerVersion failed - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_dfs_GetManagerVersion(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "GetManagerVersion failed");
- return True;
+ return true;
}
-static BOOL test_ManagerInitialize(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host)
+static BOOL test_ManagerInitialize(struct torture_context *tctx, struct dcerpc_pipe *p, const char *host)
{
NTSTATUS status;
enum dfs_ManagerVersion version;
@@ -163,14 +162,14 @@ static BOOL test_ManagerInitialize(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, c
printf("Testing ManagerInitialize\n");
- if (!test_GetManagerVersion(p, mem_ctx, &version)) {
+ if (!test_GetManagerVersion(tctx, p, &version)) {
return False;
}
r.in.servername = host;
r.in.flags = 0;
- status = dcerpc_dfs_ManagerInitialize(p, mem_ctx, &r);
+ status = dcerpc_dfs_ManagerInitialize(p, tctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("ManagerInitialize failed - %s\n", nt_errstr(status));
return False;
@@ -183,33 +182,31 @@ static BOOL test_ManagerInitialize(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, c
return True;
}
-static BOOL test_GetInfoLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t level,
- const char *root)
+static BOOL test_GetInfoLevel(struct torture_context *tctx, struct dcerpc_pipe *p, uint16_t level, const char *root)
{
NTSTATUS status;
struct dfs_GetInfo r;
- printf("Testing GetInfo level %u on '%s'\n", level, root);
+ torture_comment(tctx,
+ talloc_asprintf(tctx, "Testing GetInfo level %u on '%s'\n", level, root));
- r.in.dfs_entry_path = talloc_strdup(mem_ctx, root);
+ r.in.dfs_entry_path = talloc_strdup(tctx, root);
r.in.servername = NULL;
r.in.sharename = NULL;
r.in.level = level;
- 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;
- }
+ 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)));
return True;
}
-static BOOL test_GetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *root)
+static bool test_Info(struct torture_context *tctx,
+ struct dcerpc_pipe *p, const char *root)
{
BOOL ret = True;
/* 103, 104, 105, 106 is only available on Set */
@@ -217,14 +214,15 @@ static BOOL test_GetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char
int i;
for (i=0;i<ARRAY_SIZE(levels);i++) {
- if (!test_GetInfoLevel(p, mem_ctx, levels[i], root)) {
- ret = False;
+ if (!test_GetInfoLevel(tctx, p, levels[i], root)) {
+ ret = false;
}
}
return ret;
}
-static BOOL test_EnumLevelEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t level, const char *dfs_name)
+static bool test_EnumLevel(struct torture_context *tctx,
+ struct dcerpc_pipe *p, uint16_t level)
{
NTSTATUS status;
struct dfs_EnumEx rex;
@@ -305,23 +303,18 @@ static BOOL test_EnumLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t
e.e.info1->s = &s;
s.path = NULL;
- 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;
- }
+ 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));
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(p, mem_ctx, root)) {
+ if (!test_GetInfo(tctx, p, root)) {
ret = False;
}
}
@@ -332,15 +325,16 @@ static BOOL test_EnumLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t
}
-static BOOL test_Enum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_Enum(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
BOOL ret = True;
uint16_t levels[] = {1, 2, 3, 4, 200, 300};
int i;
for (i=0;i<ARRAY_SIZE(levels);i++) {
- if (!test_EnumLevel(p, mem_ctx, levels[i])) {
- ret = False;
+ if (!test_EnumLevel(tctx, p, levels[i])) {
+ ret = false;
}
}
@@ -481,31 +475,35 @@ static BOOL test_StdRoot(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char
return ret;
}
-BOOL torture_rpc_dfs(struct torture_context *torture)
+#endif
+
+struct torture_suite *torture_rpc_dfs(void)
{
- NTSTATUS status;
- struct dcerpc_pipe *p;
- TALLOC_CTX *mem_ctx;
- BOOL ret = True;
- enum dfs_ManagerVersion version;
- const char *host = lp_parm_string(-1, "torture", "host");
+ struct torture_suite *suite = torture_suite_create(
+ talloc_autofree_context(), "RPC-DFS");
- mem_ctx = talloc_init("torture_rpc_dfs");
+#if 0
+ struct torture_tcase *tcase = torture_suite_add_rpc_iface_tcase(suite,
+ "dfs", &dcerpc_table_netdfs);
- status = torture_rpc_connection(mem_ctx,
- &p,
- &dcerpc_table_netdfs);
- if (!NT_STATUS_IS_OK(status)) {
- return False;
- }
+ torture_rpc_tcase_add_test(tcase, "GetManagerVersion",
+ test_GetManagerVersion);
- ret &= test_GetManagerVersion(p, mem_ctx, &version);
- ret &= test_ManagerInitialize(p, mem_ctx, host);
- ret &= test_Enum(p, mem_ctx);
- ret &= test_EnumEx(p, mem_ctx, host);
- ret &= test_StdRoot(p, mem_ctx, host);
+#if 0
+ torture_rpc_tcase_add_test(tcase, "Add",
+ test_Add);
+#endif
+
+ torture_rpc_tcase_add_test(tcase, "Enum", test_Enum);
+ torture_rpc_tcase_add_test(tcase, "EnumEx", test_EnumEx);
+ torture_rpc_tcase_add_test(tcase, "ManagerInitialize",
+ test_ManagerInitialize);
+ torture_rpc_tcase_add_test(tcase, "StdRoot",
+ test_StdRoot);
talloc_free(mem_ctx);
- return ret;
+#endif
+
+ return suite;
}
diff --git a/source4/torture/rpc/echo.c b/source4/torture/rpc/echo.c
index 02f255e5f8..fef9eb8c2b 100644
--- a/source4/torture/rpc/echo.c
+++ b/source4/torture/rpc/echo.c
@@ -31,49 +31,40 @@
/*
test the AddOne interface
*/
-#define TEST_ADDONE(value) do { \
+#define TEST_ADDONE(tctx, value) do { \
n = i = value; \
r.in.in_data = n; \
r.out.out_data = &n; \
- status = dcerpc_echo_AddOne(p, mem_ctx, &r); \
- if (!NT_STATUS_IS_OK(status)) { \
- printf("AddOne(%d) failed - %s\n", i, nt_errstr(status)); \
- return False; \
- } \
- if (n != i+1) { \
- printf("%d + 1 != %u (should be %u)\n", i, n, i+1); \
- ret = False; \
- } else { \
- printf("%d + 1 = %u\n", i, n); \
- } \
+ status = dcerpc_echo_AddOne(p, tctx, &r); \
+ torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, "AddOne(%d) failed", i)); \
+ torture_assert (tctx, n == i+1, talloc_asprintf(tctx, "%d + 1 != %u (should be %u)\n", i, n, i+1)); \
+ torture_comment (tctx, "%d + 1 = %u\n", i, n); \
} while(0)
-static BOOL test_addone(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_addone(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
- BOOL ret = True;
uint32_t i;
NTSTATUS status;
uint32_t n;
struct echo_AddOne r;
- printf("\nTesting AddOne\n");
-
for (i=0;i<10;i++) {
- TEST_ADDONE(i);
+ TEST_ADDONE(tctx, i);
}
- TEST_ADDONE(0x7FFFFFFE);
- TEST_ADDONE(0xFFFFFFFE);
- TEST_ADDONE(0xFFFFFFFF);
- TEST_ADDONE(random() & 0xFFFFFFFF);
-
- return ret;
+ TEST_ADDONE(tctx, 0x7FFFFFFE);
+ TEST_ADDONE(tctx, 0xFFFFFFFE);
+ TEST_ADDONE(tctx, 0xFFFFFFFF);
+ TEST_ADDONE(tctx, random() & 0xFFFFFFFF);
+ return true;
}
/*
test the EchoData interface
*/
-static BOOL test_echodata(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_echodata(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
int i;
NTSTATUS status;
@@ -81,17 +72,15 @@ static BOOL test_echodata(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
int len;
struct echo_EchoData r;
- if (lp_parm_bool(-1, "torture", "quick", False) &&
+ if (torture_setting_bool(tctx, "quick", false) &&
(p->conn->flags & DCERPC_DEBUG_VALIDATE_BOTH)) {
len = 1 + (random() % 500);
} else {
len = 1 + (random() % 5000);
}
- printf("\nTesting EchoData\n");
-
- data_in = talloc_size(mem_ctx, len);
- data_out = talloc_size(mem_ctx, len);
+ data_in = talloc_size(tctx, len);
+ data_out = talloc_size(tctx, len);
for (i=0;i<len;i++) {
data_in[i] = i;
}
@@ -99,73 +88,64 @@ static BOOL test_echodata(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
r.in.len = len;
r.in.in_data = data_in;
- status = dcerpc_echo_EchoData(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("EchoData(%d) failed - %s\n", len, nt_errstr(status));
- return False;
- }
+ status = dcerpc_echo_EchoData(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx,
+ "EchoData(%d) failed\n", len));
data_out = r.out.out_data;
for (i=0;i<len;i++) {
if (data_in[i] != data_out[i]) {
- printf("Bad data returned for len %d at offset %d\n",
+ torture_comment(tctx, "Bad data returned for len %d at offset %d\n",
len, i);
- printf("in:\n");
+ torture_comment(tctx, "in:\n");
dump_data(0, data_in+i, MIN(len-i, 16));
- printf("out:\n");
+ torture_comment(tctx, "out:\n");
dump_data(0, data_out+i, MIN(len-1, 16));
- return False;
+ return false;
}
}
-
-
- return True;
+ return true;
}
-
/*
test the SourceData interface
*/
-static BOOL test_sourcedata(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_sourcedata(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
int i;
NTSTATUS status;
int len;
struct echo_SourceData r;
- if (lp_parm_bool(-1, "torture", "quick", False) &&
+ if (torture_setting_bool(tctx, "quick", false) &&
(p->conn->flags & DCERPC_DEBUG_VALIDATE_BOTH)) {
len = 100 + (random() % 500);
} else {
len = 200000 + (random() % 5000);
}
- printf("\nTesting SourceData\n");
-
r.in.len = len;
- status = dcerpc_echo_SourceData(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("SourceData(%d) failed - %s\n", len, nt_errstr(status));
- return False;
- }
+ status = dcerpc_echo_SourceData(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx,
+ "SourceData(%d) failed", len));
for (i=0;i<len;i++) {
uint8_t *v = (uint8_t *)r.out.data;
- if (v[i] != (i & 0xFF)) {
- printf("bad data 0x%x at %d\n", (uint8_t)r.out.data[i], i);
- return False;
- }
+ torture_assert(tctx, v[i] == (i & 0xFF),
+ talloc_asprintf(tctx,
+ "bad data 0x%x at %d\n", (uint8_t)r.out.data[i], i));
}
-
- return True;
+ return true;
}
/*
test the SinkData interface
*/
-static BOOL test_sinkdata(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_sinkdata(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
int i;
NTSTATUS status;
@@ -173,16 +153,14 @@ static BOOL test_sinkdata(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
int len;
struct echo_SinkData r;
- if (lp_parm_bool(-1, "torture", "quick", False) &&
+ if (torture_setting_bool(tctx, "quick", false) &&
(p->conn->flags & DCERPC_DEBUG_VALIDATE_BOTH)) {
len = 100 + (random() % 5000);
} else {
len = 200000 + (random() % 5000);
}
- printf("\nTesting SinkData\n");
-
- data_in = talloc_size(mem_ctx, len);
+ data_in = talloc_size(tctx, len);
for (i=0;i<len;i++) {
data_in[i] = i+1;
}
@@ -190,74 +168,63 @@ static BOOL test_sinkdata(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
r.in.len = len;
r.in.data = data_in;
- status = dcerpc_echo_SinkData(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("SinkData(%d) failed - %s\n", len, nt_errstr(status));
- return False;
- }
-
- printf("sunk %d bytes\n", len);
+ status = dcerpc_echo_SinkData(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx,
+ "SinkData(%d) failed",
+ len));
- return True;
+ torture_comment(tctx, "sunk %d bytes\n", len);
+ return true;
}
/*
test the testcall interface
*/
-static BOOL test_testcall(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_testcall(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct echo_TestCall r;
- char *s = NULL;
+ const char *s = NULL;
r.in.s1 = "input string";
r.out.s2 = &s;
- printf("\nTesting TestCall\n");
- status = dcerpc_echo_TestCall(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("TestCall failed - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_echo_TestCall(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "TestCall failed");
- if (!strcmp(s, "input string")) {
- printf("Didn't receive back same string\n");
- return False;
- }
+ torture_assert_str_equal(tctx, s, "input string", "Didn't receive back same string");
- return True;
+ return true;
}
/*
test the testcall interface
*/
-static BOOL test_testcall2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_testcall2(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct echo_TestCall2 r;
int i;
- BOOL ret = True;
for (i=1;i<=7;i++) {
r.in.level = i;
- r.out.info = talloc(mem_ctx, union echo_Info);
+ r.out.info = talloc(tctx, union echo_Info);
- printf("\nTesting TestCall2 level %d\n", i);
- status = dcerpc_echo_TestCall2(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("TestCall2 failed - %s\n", nt_errstr(status));
- ret = False;
- }
+ torture_comment(tctx, "Testing TestCall2 level %d\n", i);
+ status = dcerpc_echo_TestCall2(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "TestCall2 failed");
}
-
- return ret;
+ return true;
}
/*
test the TestSleep interface
*/
-static BOOL test_sleep(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_sleep(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
int i;
NTSTATUS status;
@@ -270,31 +237,25 @@ static BOOL test_sleep(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
struct timeval diff[ASYNC_COUNT];
struct event_context *ctx;
int total_done = 0;
- BOOL ret = True;
- if (lp_parm_bool(-1, "torture", "quick", False)) {
- printf("TestSleep disabled - use \"torture:quick=no\" to enable\n");
- return True;
+ if (torture_setting_bool(tctx, "quick", false)) {
+ torture_skip(tctx, "TestSleep disabled - use \"torture:quick=no\" to enable\n");
}
- printf("Testing TestSleep - use \"torture:quick=no\" to disable\n");
+ torture_comment(tctx, "Testing TestSleep - use \"torture:quick=no\" to disable\n");
for (i=0;i<ASYNC_COUNT;i++) {
done[i] = False;
snd[i] = timeval_current();
rcv[i] = timeval_zero();
r[i].in.seconds = ASYNC_COUNT-i;
- req[i] = dcerpc_echo_TestSleep_send(p, mem_ctx, &r[i]);
- if (!req[i]) {
- printf("Failed to send async sleep request\n");
- return False;
- }
+ req[i] = dcerpc_echo_TestSleep_send(p, tctx, &r[i]);
+ torture_assert(tctx, req[i], "Failed to send async sleep request\n");
}
ctx = dcerpc_event_context(p);
while (total_done < ASYNC_COUNT) {
- if (event_loop_once(ctx) != 0) {
- return False;
- }
+ torture_assert(tctx, event_loop_once(ctx) == 0,
+ "Event context loop failed");
for (i=0;i<ASYNC_COUNT;i++) {
if (done[i] == False && req[i]->state == RPC_REQUEST_DONE) {
total_done++;
@@ -302,46 +263,39 @@ static BOOL test_sleep(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
rcv[i] = timeval_current();
diff[i] = timeval_until(&snd[i], &rcv[i]);
status = dcerpc_ndr_request_recv(req[i]);
- if (!NT_STATUS_IS_OK(status)) {
- printf("TestSleep(%d) failed - %s\n",
- i, nt_errstr(status));
- ret = False;
- } else if (r[i].out.result != r[i].in.seconds) {
- printf("Failed - Asked to sleep for %u seconds (server replied with %u seconds and the reply takes only %u seconds)\n",
- r[i].out.result, r[i].in.seconds, (uint_t)diff[i].tv_sec);
- ret = False;
+ torture_assert_ntstatus_ok(tctx, status,
+ talloc_asprintf(tctx, "TestSleep(%d) failed", i));
+ torture_assert(tctx, r[i].out.result == r[i].in.seconds,
+ talloc_asprintf(tctx, "Failed - Asked to sleep for %u seconds (server replied with %u seconds and the reply takes only %u seconds)",
+ r[i].out.result, r[i].in.seconds, (uint_t)diff[i].tv_sec));
+ torture_assert(tctx, r[i].out.result <= diff[i].tv_sec,
+ talloc_asprintf(tctx, "Failed - Slept for %u seconds (but reply takes only %u.%06u seconds)",
+ r[i].out.result, (uint_t)diff[i].tv_sec, (uint_t)diff[i].tv_usec));
+ if (r[i].out.result+1 == diff[i].tv_sec) {
+ torture_comment(tctx, "Slept for %u seconds (but reply takes %u.%06u seconds - busy server?)\n",
+ r[i].out.result, (uint_t)diff[i].tv_sec, (uint_t)diff[i].tv_usec);
+ } else if (r[i].out.result == diff[i].tv_sec) {
+ torture_comment(tctx, "Slept for %u seconds (reply takes %u.%06u seconds - ok)\n",
+ r[i].out.result, (uint_t)diff[i].tv_sec, (uint_t)diff[i].tv_usec);
} else {
- if (r[i].out.result > diff[i].tv_sec) {
- printf("Failed - Slept for %u seconds (but reply takes only %u.%06u seconds)\n",
- r[i].out.result, (uint_t)diff[i].tv_sec, (uint_t)diff[i].tv_usec);
- } else if (r[i].out.result+1 == diff[i].tv_sec) {
- printf("Slept for %u seconds (but reply takes %u.%06u seconds - busy server?)\n",
- r[i].out.result, (uint_t)diff[i].tv_sec, (uint_t)diff[i].tv_usec);
- } else if (r[i].out.result == diff[i].tv_sec) {
- printf("Slept for %u seconds (reply takes %u.%06u seconds - ok)\n",
- r[i].out.result, (uint_t)diff[i].tv_sec, (uint_t)diff[i].tv_usec);
- } else {
- printf("(Failed) - Not async - Slept for %u seconds (but reply takes %u.%06u seconds)\n",
- r[i].out.result, (uint_t)diff[i].tv_sec, (uint_t)diff[i].tv_usec);
- /* TODO: let the test fail here, when we support async rpc on ncacn_np
- ret = False;*/
- }
+ torture_comment(tctx, "(Failed) - Not async - Slept for %u seconds (but reply takes %u.%06u seconds)",
+ r[i].out.result, (uint_t)diff[i].tv_sec, (uint_t)diff[i].tv_usec);
+ /* TODO: let the test fail here, when we support async rpc on ncacn_np */
}
}
}
}
-
- return ret;
+ return true;
}
/*
test enum handling
*/
-static BOOL test_enum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_enum(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct echo_TestEnum r;
- BOOL ret = True;
enum echo_Enum1 v = ECHO_ENUM1;
struct echo_Enum2 e2;
union echo_Enum3 e3;
@@ -357,56 +311,45 @@ static BOOL test_enum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
e2.e2 = ECHO_ENUM1_32;
e3.e1 = ECHO_ENUM2;
- printf("\nTesting TestEnum\n");
- status = dcerpc_echo_TestEnum(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("TestEnum failed - %s\n", nt_errstr(status));
- ret = False;
- }
-
- return ret;
+ status = dcerpc_echo_TestEnum(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "TestEnum failed");
+ return true;
}
/*
test surrounding conformant array handling
*/
-static BOOL test_surrounding(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_surrounding(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct echo_TestSurrounding r;
- BOOL ret = True;
ZERO_STRUCT(r);
- r.in.data = talloc(mem_ctx, struct echo_Surrounding);
+ r.in.data = talloc(tctx, struct echo_Surrounding);
r.in.data->x = 20;
- r.in.data->surrounding = talloc_zero_array(mem_ctx, uint16_t, r.in.data->x);
+ r.in.data->surrounding = talloc_zero_array(tctx, uint16_t, r.in.data->x);
- r.out.data = talloc(mem_ctx, struct echo_Surrounding);
+ r.out.data = talloc(tctx, struct echo_Surrounding);
- printf("\nTesting TestSurrounding\n");
- status = dcerpc_echo_TestSurrounding(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("TestSurrounding failed - %s\n", nt_errstr(status));
- return False;
- }
+ status = dcerpc_echo_TestSurrounding(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "TestSurrounding failed");
- if (r.out.data->x != 2 * r.in.data->x) {
- printf("TestSurrounding did not make the array twice as large\n");
- ret = False;
- }
+ torture_assert(tctx, r.out.data->x == 2 * r.in.data->x,
+ "TestSurrounding did not make the array twice as large");
- return ret;
+ return true;
}
/*
test multiple levels of pointers
*/
-static BOOL test_doublepointer(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_doublepointer(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct echo_TestDoublePointer r;
- BOOL ret = True;
uint16_t value = 12;
uint16_t *pvalue = &value;
uint16_t **ppvalue = &pvalue;
@@ -414,112 +357,88 @@ static BOOL test_doublepointer(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
ZERO_STRUCT(r);
r.in.data = &ppvalue;
- printf("\nTesting TestDoublePointer\n");
- status = dcerpc_echo_TestDoublePointer(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("TestDoublePointer failed - %s\n", nt_errstr(status));
- ret = False;
- }
+ status = dcerpc_echo_TestDoublePointer(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "TestDoublePointer failed");
- if (value != r.out.result) {
- printf("TestDoublePointer did not return original value (%d != %d)\n", value, r.out.result);
- ret = False;
- }
-
- return ret;
+ torture_assert_int_equal(tctx, value, r.out.result,
+ "TestDoublePointer did not return original value");
+ return true;
}
/*
test request timeouts
*/
-static BOOL test_timeout(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_timeout(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct rpc_request *req;
struct echo_TestSleep r;
int timeout_saved = p->request_timeout;
- if (lp_parm_bool(-1, "torture", "quick", False)) {
- printf("timeout testing disabled - use \"torture:quick=no\" to enable\n");
- return True;
+ if (torture_setting_bool(tctx, "quick", false)) {
+ torture_skip(tctx, "timeout testing disabled - use \"torture:quick=no\" to enable\n");
}
- printf("testing request timeouts\n");
+ torture_comment(tctx, "testing request timeouts\n");
r.in.seconds = 2;
p->request_timeout = 1;
- req = dcerpc_echo_TestSleep_send(p, mem_ctx, &r);
- if (!req) {
- printf("Failed to send async sleep request\n");
- goto failed;
- }
+ torture_assert(tctx, req = dcerpc_echo_TestSleep_send(p, tctx, &r),
+ "Failed to send async sleep request");
status = dcerpc_ndr_request_recv(req);
- if (!NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
- printf("request should have timed out - %s\n", nt_errstr(status));
- goto failed;
- }
+ torture_assert_ntstatus_equal(tctx, status, NT_STATUS_IO_TIMEOUT,
+ "request should have timed out");
- printf("testing request destruction\n");
- req = dcerpc_echo_TestSleep_send(p, mem_ctx, &r);
+ torture_comment(tctx, "testing request destruction\n");
+ req = dcerpc_echo_TestSleep_send(p, tctx, &r);
if (!req) {
- printf("Failed to send async sleep request\n");
+ torture_comment(tctx, "Failed to send async sleep request\n");
goto failed;
}
talloc_free(req);
- req = dcerpc_echo_TestSleep_send(p, mem_ctx, &r);
+ req = dcerpc_echo_TestSleep_send(p, tctx, &r);
if (!req) {
- printf("Failed to send async sleep request\n");
+ torture_comment(tctx, "Failed to send async sleep request\n");
goto failed;
}
status = dcerpc_ndr_request_recv(req);
- if (!NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
- printf("request should have timed out - %s\n", nt_errstr(status));
- goto failed;
- }
+ torture_assert_ntstatus_equal(tctx, status, NT_STATUS_IO_TIMEOUT,
+ "request should have timed out");
p->request_timeout = timeout_saved;
- return test_addone(p, mem_ctx);
+
+ return test_addone(tctx, p);
failed:
p->request_timeout = timeout_saved;
- return False;
+ return false;
}
-BOOL torture_rpc_echo(struct torture_context *torture)
+struct torture_suite *torture_rpc_echo(void)
{
- NTSTATUS status;
- struct dcerpc_pipe *p;
- TALLOC_CTX *mem_ctx;
- BOOL ret = True;
-
- mem_ctx = talloc_init("torture_rpc_echo");
-
- status = torture_rpc_connection(mem_ctx,
- &p,
- &dcerpc_table_rpcecho);
- if (!NT_STATUS_IS_OK(status)) {
- return False;
- }
-
- ret &= test_addone(p, mem_ctx);
- ret &= test_sinkdata(p, mem_ctx);
- ret &= test_echodata(p, mem_ctx);
- ret &= test_sourcedata(p, mem_ctx);
- ret &= test_testcall(p, mem_ctx);
- ret &= test_testcall2(p, mem_ctx);
- ret &= test_enum(p, mem_ctx);
- ret &= test_surrounding(p, mem_ctx);
- ret &= test_doublepointer(p, mem_ctx);
- ret &= test_sleep(p, mem_ctx);
- ret &= test_timeout(p, mem_ctx);
-
- printf("\n");
-
- talloc_free(mem_ctx);
-
- return ret;
+ struct torture_suite *suite = torture_suite_create(
+ talloc_autofree_context(), "ECHO");
+ struct torture_tcase *tcase;
+
+ tcase = torture_suite_add_rpc_iface_tcase(suite, "echo",
+ &dcerpc_table_rpcecho);
+
+ torture_rpc_tcase_add_test(tcase, "addone", test_addone);
+ torture_rpc_tcase_add_test(tcase, "sinkdata", test_sinkdata);
+ torture_rpc_tcase_add_test(tcase, "echodata", test_echodata);
+ torture_rpc_tcase_add_test(tcase, "sourcedata", test_sourcedata);
+ torture_rpc_tcase_add_test(tcase, "testcall", test_testcall);
+ torture_rpc_tcase_add_test(tcase, "testcall2", test_testcall2);
+ torture_rpc_tcase_add_test(tcase, "enum", test_enum);
+ torture_rpc_tcase_add_test(tcase, "surrounding", test_surrounding);
+ torture_rpc_tcase_add_test(tcase, "doublepointer", test_doublepointer);
+ torture_rpc_tcase_add_test(tcase, "sleep", test_sleep);
+ torture_rpc_tcase_add_test(tcase, "timeout", test_timeout);
+
+ return suite;
}
diff --git a/source4/torture/rpc/eventlog.c b/source4/torture/rpc/eventlog.c
index 381b34a49c..3ecc1a422b 100644
--- a/source4/torture/rpc/eventlog.c
+++ b/source4/torture/rpc/eventlog.c
@@ -34,38 +34,72 @@ static void init_lsa_String(struct lsa_String *name, const char *s)
name->size = name->length;
}
-static BOOL test_GetNumRecords(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle)
+static bool get_policy_handle(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct policy_handle *handle)
+{
+ struct eventlog_OpenEventLogW r;
+ struct eventlog_OpenUnknown0 unknown0;
+
+ unknown0.unknown0 = 0x005c;
+ unknown0.unknown1 = 0x0001;
+
+ r.in.unknown0 = &unknown0;
+ init_lsa_String(&r.in.logname, "dns server");
+ init_lsa_String(&r.in.servername, NULL);
+ r.in.unknown2 = 0x00000001;
+ r.in.unknown3 = 0x00000001;
+ r.out.handle = handle;
+
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_eventlog_OpenEventLogW(p, tctx, &r),
+ "OpenEventLog failed");
+
+ torture_assert_ntstatus_ok(tctx, r.out.result, "OpenEventLog failed");
+
+ return true;
+}
+
+
+
+static bool test_GetNumRecords(struct torture_context *tctx, struct dcerpc_pipe *p)
{
- NTSTATUS status;
struct eventlog_GetNumRecords r;
+ struct eventlog_CloseEventLog cr;
+ struct policy_handle handle;
- printf("\ntesting GetNumRecords\n");
+ if (!get_policy_handle(tctx, p, &handle))
+ return false;
- r.in.handle = handle;
+ r.in.handle = &handle;
- status = dcerpc_eventlog_GetNumRecords(p, mem_ctx, &r);
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_eventlog_GetNumRecords(p, tctx, &r),
+ "GetNumRecords failed");
- if (!NT_STATUS_IS_OK(status)) {
- printf("GetNumRecords failed - %s\n", nt_errstr(status));
- return False;
- }
+ torture_comment(tctx, talloc_asprintf(tctx, "%d records\n", r.out.number));
- printf("%d records\n", r.out.number);
+ cr.in.handle = cr.out.handle = &handle;
- return True;
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_eventlog_CloseEventLog(p, tctx, &cr),
+ "CloseEventLog failed");
+ return true;
}
-static BOOL test_ReadEventLog(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle)
+static bool test_ReadEventLog(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct eventlog_ReadEventLogW r;
+ struct eventlog_CloseEventLog cr;
+ struct policy_handle handle;
- printf("\ntesting ReadEventLog\n");
+ if (!get_policy_handle(tctx, p, &handle))
+ return false;
r.in.offset = 0;
- r.in.handle = handle;
+ r.in.handle = &handle;
r.in.flags = EVENTLOG_BACKWARDS_READ|EVENTLOG_SEQUENTIAL_READ;
while (1) {
@@ -78,185 +112,142 @@ static BOOL test_ReadEventLog(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r.in.number_of_bytes = 0;
r.out.data = NULL;
- status = dcerpc_eventlog_ReadEventLogW(p, mem_ctx, &r);
+ status = dcerpc_eventlog_ReadEventLogW(p, tctx, &r);
if (NT_STATUS_EQUAL(r.out.result, NT_STATUS_END_OF_FILE)) {
break;
}
- if (!NT_STATUS_EQUAL(r.out.result, NT_STATUS_BUFFER_TOO_SMALL)) {
- printf("ReadEventLog failed - %s\n", nt_errstr(r.out.result));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "ReadEventLog failed");
+
+ torture_assert_ntstatus_equal(tctx, r.out.result, NT_STATUS_BUFFER_TOO_SMALL,
+ "ReadEventLog failed");
/* Now read the actual record */
r.in.number_of_bytes = r.out.real_size;
- r.out.data = talloc_size(mem_ctx, r.in.number_of_bytes);
+ r.out.data = talloc_size(tctx, r.in.number_of_bytes);
- status = dcerpc_eventlog_ReadEventLogW(p, mem_ctx, &r);
+ status = dcerpc_eventlog_ReadEventLogW(p, tctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("ReadEventLog failed - %s\n", nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status, "ReadEventLog failed");
/* Decode a user-marshalled record */
blob.length = r.out.sent_size;
- blob.data = talloc_steal(mem_ctx, r.out.data);
+ blob.data = talloc_steal(tctx, r.out.data);
- ndr = ndr_pull_init_blob(&blob, mem_ctx);
+ ndr = ndr_pull_init_blob(&blob, tctx);
status = ndr_pull_eventlog_Record(
ndr, NDR_SCALARS|NDR_BUFFERS, &rec);
NDR_PRINT_DEBUG(eventlog_Record, &rec);
- if (!NT_STATUS_IS_OK(status)) {
- printf("ReadEventLog failed parsing event log record "
- "- %s\n", nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, status,
+ "ReadEventLog failed parsing event log record");
r.in.offset++;
}
- return True;
-}
-
-static BOOL test_CloseEventLog(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle)
-{
- NTSTATUS status;
- struct eventlog_CloseEventLog r;
+ cr.in.handle = cr.out.handle = &handle;
- r.in.handle = r.out.handle = handle;
-
- printf("Testing CloseEventLog\n");
-
- status = dcerpc_eventlog_CloseEventLog(p, mem_ctx, &r);
-
- if (!NT_STATUS_IS_OK(status)) {
- printf("CloseEventLog failed - %s\n", nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_eventlog_CloseEventLog(p, tctx, &cr),
+ "CloseEventLog failed");
- return True;
+ return true;
}
-static BOOL test_FlushEventLog(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle)
+static bool test_FlushEventLog(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
- NTSTATUS status;
struct eventlog_FlushEventLog r;
+ struct eventlog_CloseEventLog cr;
+ struct policy_handle handle;
- r.in.handle = handle;
-
- printf("Testing FlushEventLog\n");
+ if (!get_policy_handle(tctx, p, &handle))
+ return false;
- status = dcerpc_eventlog_FlushEventLog(p, mem_ctx, &r);
+ r.in.handle = &handle;
/* Huh? Does this RPC always return access denied? */
+ torture_assert_ntstatus_equal(tctx,
+ dcerpc_eventlog_FlushEventLog(p, tctx, &r),
+ NT_STATUS_ACCESS_DENIED,
+ "FlushEventLog failed");
- if (!NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
- printf("FlushEventLog failed - %s\n", nt_errstr(status));
- return False;
- }
+ cr.in.handle = cr.out.handle = &handle;
+
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_eventlog_CloseEventLog(p, tctx, &cr),
+ "CloseEventLog failed");
- return True;
+ return true;
}
-static BOOL test_ClearEventLog(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle)
+static bool test_ClearEventLog(struct dcerpc_pipe *p, TALLOC_CTX *tctx)
{
- NTSTATUS status;
struct eventlog_ClearEventLogW r;
+ struct eventlog_CloseEventLog cr;
+ struct policy_handle handle;
- r.in.handle = handle;
+ if (!get_policy_handle(tctx, p, &handle))
+ return false;
+
+ r.in.handle = &handle;
r.in.unknown = NULL;
- printf("Testing ClearEventLog\n");
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_eventlog_ClearEventLogW(p, tctx, &r),
+ "ClearEventLog failed");
- status = dcerpc_eventlog_ClearEventLogW(p, mem_ctx, &r);
+ cr.in.handle = cr.out.handle = &handle;
- if (!NT_STATUS_IS_OK(status)) {
- printf("ClearEventLog failed - %s\n", nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_eventlog_CloseEventLog(p, tctx, &cr),
+ "CloseEventLog failed");
- return True;
+ return true;
}
-static BOOL test_OpenEventLog(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle)
+static bool test_OpenEventLog(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
- NTSTATUS status;
- struct eventlog_OpenEventLogW r;
- struct eventlog_OpenUnknown0 unknown0;
-
- printf("\ntesting OpenEventLog\n");
-
- unknown0.unknown0 = 0x005c;
- unknown0.unknown1 = 0x0001;
-
- r.in.unknown0 = &unknown0;
- init_lsa_String(&r.in.logname, "dns server");
- init_lsa_String(&r.in.servername, NULL);
- r.in.unknown2 = 0x00000001;
- r.in.unknown3 = 0x00000001;
- r.out.handle = handle;
+ struct policy_handle handle;
+ struct eventlog_CloseEventLog cr;
- status = dcerpc_eventlog_OpenEventLogW(p, mem_ctx, &r);
+ if (!get_policy_handle(tctx, p, &handle))
+ return false;
- if (!NT_STATUS_IS_OK(status)) {
- printf("OpenEventLog failed - %s\n", nt_errstr(status));
- return False;
- }
+ cr.in.handle = cr.out.handle = &handle;
- if (!NT_STATUS_IS_OK(r.out.result)) {
- printf("OpenEventLog failed - %s\n", nt_errstr(r.out.result));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_eventlog_CloseEventLog(p, tctx, &cr),
+ "CloseEventLog failed");
- return True;
+ return true;
}
-BOOL torture_rpc_eventlog(struct torture_context *torture)
+struct torture_suite *torture_rpc_eventlog(void)
{
- NTSTATUS status;
- struct dcerpc_pipe *p;
- struct policy_handle handle;
- TALLOC_CTX *mem_ctx;
- BOOL ret = True;
-
- mem_ctx = talloc_init("torture_rpc_atsvc");
+ struct torture_suite *suite;
+ struct torture_tcase *tcase;
- status = torture_rpc_connection(mem_ctx, &p, &dcerpc_table_eventlog);
+ suite = torture_suite_create(talloc_autofree_context(), "EVENTLOG");
+ tcase = torture_suite_add_rpc_iface_tcase(suite, "eventlog",
+ &dcerpc_table_eventlog);
- if (!NT_STATUS_IS_OK(status)) {
- talloc_free(mem_ctx);
- return False;
- }
-
- if (!test_OpenEventLog(p, mem_ctx, &handle)) {
- talloc_free(mem_ctx);
- return False;
- }
+ torture_rpc_tcase_add_test(tcase, "OpenEventLog", test_OpenEventLog);
#if 0
- ret &= test_ClearEventLog(p, mem_ctx, &handle); /* Destructive test */
+ /* Destructive test */
+ torture_rpc_tcase_add_test(tcase, "ClearEventLog", test_ClearEventLog);
#endif
- ret &= test_GetNumRecords(p, mem_ctx, &handle);
-
- ret &= test_ReadEventLog(p, mem_ctx, &handle);
-
- ret &= test_FlushEventLog(p, mem_ctx, &handle);
-
- ret &= test_CloseEventLog(p, mem_ctx, &handle);
-
- talloc_free(mem_ctx);
+ torture_rpc_tcase_add_test(tcase, "GetNumRecords", test_GetNumRecords);
+ torture_rpc_tcase_add_test(tcase, "ReadEventLog", test_ReadEventLog);
+ torture_rpc_tcase_add_test(tcase, "FlushEventLog", test_FlushEventLog);
- return ret;
+ return suite;
}
diff --git a/source4/torture/rpc/rpc.c b/source4/torture/rpc/rpc.c
index 754633e51b..6d3031ede9 100644
--- a/source4/torture/rpc/rpc.c
+++ b/source4/torture/rpc/rpc.c
@@ -26,6 +26,7 @@
#include "torture/rpc/rpc.h"
#include "torture/torture.h"
#include "librpc/rpc/dcerpc_table.h"
+#include "lib/util/dlinklist.h"
/* open a rpc connection to the chosen binding string */
_PUBLIC_ NTSTATUS torture_rpc_connection(TALLOC_CTX *parent_ctx,
@@ -89,64 +90,136 @@ NTSTATUS torture_rpc_connection_transport(TALLOC_CTX *parent_ctx,
return status;
}
+static bool torture_rpc_setup (struct torture_context *tctx, void **data)
+{
+ NTSTATUS status;
+
+ status = torture_rpc_connection(tctx,
+ (struct dcerpc_pipe **)data,
+ (const struct dcerpc_interface_table *)tctx->active_tcase->data);
+
+ torture_assert_ntstatus_ok(tctx, status, "Error connecting to server");
+
+ return true;
+}
+
+static bool torture_rpc_teardown (struct torture_context *tcase, void *data)
+{
+ talloc_free(data);
+ return true;
+}
+
+_PUBLIC_ struct torture_tcase *torture_suite_add_rpc_iface_tcase(struct torture_suite *suite,
+ const char *name,
+ const struct dcerpc_interface_table *table)
+{
+ struct torture_tcase *tcase = torture_suite_add_tcase(suite, name);
+
+ tcase->setup = torture_rpc_setup;
+ tcase->teardown = torture_rpc_teardown;
+ tcase->data = table;
+
+ return tcase;
+}
+
+static bool torture_rpc_wrap_test(struct torture_context *tctx,
+ struct torture_tcase *tcase,
+ struct torture_test *test)
+{
+ bool (*fn) (struct torture_context *, struct dcerpc_pipe *);
+
+ fn = test->fn;
+
+ return fn(tctx, (struct dcerpc_pipe *)tcase->data);
+}
+
+_PUBLIC_ struct torture_test *torture_rpc_tcase_add_test(
+ struct torture_tcase *tcase,
+ const char *name,
+ bool (*fn) (struct torture_context *, struct dcerpc_pipe *))
+{
+ struct torture_test *test;
+
+ test = talloc(tcase, struct torture_test);
+
+ test->name = talloc_strdup(test, name);
+ test->description = NULL;
+ test->run = torture_rpc_wrap_test;
+ test->dangerous = false;
+ test->data = NULL;
+ test->fn = fn;
+
+ DLIST_ADD(tcase->tests, test);
+
+ return test;
+}
+
NTSTATUS torture_rpc_init(void)
{
+ struct torture_suite *suite = torture_suite_create(
+ talloc_autofree_context(),
+ "RPC");
dcerpc_init();
dcerpc_table_init();
- register_torture_op("RPC-LSA", torture_rpc_lsa);
- register_torture_op("RPC-LSALOOKUP", torture_rpc_lsa_lookup);
- register_torture_op("RPC-LSA-GETUSER", torture_rpc_lsa_get_user);
- register_torture_op("RPC-SECRETS", torture_rpc_lsa_secrets);
- register_torture_op("RPC-ECHO", torture_rpc_echo);
- register_torture_op("RPC-DFS", torture_rpc_dfs);
- register_torture_op("RPC-SPOOLSS", torture_rpc_spoolss);
- register_torture_op("RPC-SAMR", torture_rpc_samr);
- register_torture_op("RPC-SAMR-USERS", torture_rpc_samr_users);
- register_torture_op("RPC-SAMR-PASSWORDS", torture_rpc_samr_passwords);
- register_torture_op("RPC-UNIXINFO", torture_rpc_unixinfo);
- register_torture_op("RPC-NETLOGON", torture_rpc_netlogon);
- register_torture_op("RPC-SAMLOGON", torture_rpc_samlogon);
- register_torture_op("RPC-SAMSYNC", torture_rpc_samsync);
- register_torture_op("RPC-SCHANNEL", torture_rpc_schannel);
- register_torture_op("RPC-WKSSVC", torture_rpc_wkssvc);
- register_torture_op("RPC-SRVSVC", torture_rpc_srvsvc);
- register_torture_op("RPC-SVCCTL", torture_rpc_svcctl);
- register_torture_op("RPC-ATSVC", torture_rpc_atsvc);
- register_torture_op("RPC-EVENTLOG", torture_rpc_eventlog);
- register_torture_op("RPC-EPMAPPER", torture_rpc_epmapper);
- register_torture_op("RPC-WINREG", torture_rpc_winreg);
- register_torture_op("RPC-INITSHUTDOWN", torture_rpc_initshutdown);
- register_torture_op("RPC-OXIDRESOLVE", torture_rpc_oxidresolve);
- register_torture_op("RPC-REMACT", torture_rpc_remact);
- register_torture_op("RPC-MGMT", torture_rpc_mgmt);
- register_torture_op("RPC-SCANNER", torture_rpc_scanner);
- register_torture_op("RPC-AUTOIDL", torture_rpc_autoidl);
- register_torture_op("RPC-COUNTCALLS", torture_rpc_countcalls);
- register_torture_op("RPC-MULTIBIND", torture_multi_bind);
- register_torture_op("RPC-AUTHCONTEXT", torture_bind_authcontext);
- register_torture_op("RPC-BINDSAMBA3", torture_bind_samba3);
- register_torture_op("RPC-NETLOGSAMBA3", torture_netlogon_samba3);
- register_torture_op("RPC-SAMBA3SESSIONKEY", torture_samba3_sessionkey);
- register_torture_op("RPC-SAMBA3-SRVSVC", torture_samba3_rpc_srvsvc);
- register_torture_op("RPC-SAMBA3-SHARESEC",
+ torture_suite_add_simple_test(suite, "LSA", torture_rpc_lsa);
+ torture_suite_add_simple_test(suite, "LSALOOKUP", torture_rpc_lsa_lookup);
+ 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_suite(suite, torture_rpc_unixinfo());
+ torture_suite_add_suite(suite, torture_rpc_eventlog());
+ torture_suite_add_suite(suite, torture_rpc_atsvc());
+ torture_suite_add_suite(suite, torture_rpc_wkssvc());
+ torture_suite_add_simple_test(suite, "SPOOLSS", torture_rpc_spoolss);
+ torture_suite_add_simple_test(suite, "SAMR", torture_rpc_samr);
+ torture_suite_add_simple_test(suite, "SAMR-USERS", torture_rpc_samr_users);
+ torture_suite_add_simple_test(suite, "SAMR-PASSWORDS", torture_rpc_samr_passwords);
+ torture_suite_add_simple_test(suite, "NETLOGON", torture_rpc_netlogon);
+ torture_suite_add_simple_test(suite, "SAMLOGON", torture_rpc_samlogon);
+ torture_suite_add_simple_test(suite, "SAMSYNC", torture_rpc_samsync);
+ torture_suite_add_simple_test(suite, "SCHANNEL", torture_rpc_schannel);
+ torture_suite_add_simple_test(suite, "SRVSVC", torture_rpc_srvsvc);
+ torture_suite_add_simple_test(suite, "SVCCTL", torture_rpc_svcctl);
+ torture_suite_add_simple_test(suite, "EPMAPPER", torture_rpc_epmapper);
+ torture_suite_add_simple_test(suite, "WINREG", torture_rpc_winreg);
+ 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_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);
+ torture_suite_add_simple_test(suite, "COUNTCALLS", torture_rpc_countcalls);
+ torture_suite_add_simple_test(suite, "MULTIBIND", torture_multi_bind);
+ torture_suite_add_simple_test(suite, "AUTHCONTEXT", torture_bind_authcontext);
+ torture_suite_add_simple_test(suite, "BINDSAMBA3", torture_bind_samba3);
+ torture_suite_add_simple_test(suite, "NETLOGSAMBA3", torture_netlogon_samba3);
+ torture_suite_add_simple_test(suite, "SAMBA3SESSIONKEY", torture_samba3_sessionkey);
+ torture_suite_add_simple_test(suite, "SAMBA3-SRVSVC", torture_samba3_rpc_srvsvc);
+ torture_suite_add_simple_test(suite, "SAMBA3-SHARESEC",
torture_samba3_rpc_sharesec);
- register_torture_op("RPC-SAMBA3-GETUSERNAME",
+ torture_suite_add_simple_test(suite, "SAMBA3-GETUSERNAME",
torture_samba3_rpc_getusername);
- register_torture_op("RPC-SAMBA3-LSA", torture_samba3_rpc_lsa);
- register_torture_op("RPC-SAMBA3-SPOOLSS", torture_samba3_rpc_spoolss);
- register_torture_op("RPC-SAMBA3-WKSSVC", torture_samba3_rpc_wkssvc);
- register_torture_op("RPC-SAMBA3-WINREG", torture_samba3_rpc_winreg);
- register_torture_op("RPC-DRSUAPI", torture_rpc_drsuapi);
- register_torture_op("RPC-CRACKNAMES", torture_rpc_drsuapi_cracknames);
- register_torture_op("RPC-ROT", torture_rpc_rot);
- register_torture_op("RPC-DSSETUP", torture_rpc_dssetup);
- register_torture_op("RPC-ALTERCONTEXT", torture_rpc_alter_context);
- register_torture_op("RPC-JOIN", torture_rpc_join);
- register_torture_op("RPC-DSSYNC", torture_rpc_dssync);
- register_torture_op("BENCH-RPC", torture_bench_rpc);
- register_torture_op("RPC-ASYNCBIND", torture_async_bind);
+ torture_suite_add_simple_test(suite, "SAMBA3-LSA", torture_samba3_rpc_lsa);
+ torture_suite_add_simple_test(suite, "SAMBA3-SPOOLSS", torture_samba3_rpc_spoolss);
+ torture_suite_add_simple_test(suite, "SAMBA3-WKSSVC", torture_samba3_rpc_wkssvc);
+ 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);
+ torture_suite_add_simple_test(suite, "DSSYNC", torture_rpc_dssync);
+ torture_suite_add_simple_test(suite, "BENCH-RPC", torture_bench_rpc);
+ torture_suite_add_simple_test(suite, "ASYNCBIND", torture_async_bind);
+
+ suite->description = talloc_strdup(suite,
+ "DCE/RPC protocol and interface tests");
+
+ torture_register_suite(suite);
return NT_STATUS_OK;
}
diff --git a/source4/torture/rpc/rpc.h b/source4/torture/rpc/rpc.h
index 6d020bde88..934e1a214d 100644
--- a/source4/torture/rpc/rpc.h
+++ b/source4/torture/rpc/rpc.h
@@ -29,5 +29,6 @@
#include "librpc/rpc/dcerpc.h"
#include "libcli/raw/libcliraw.h"
#include "torture/rpc/proto.h"
+#include "torture/ui.h"
#endif /* __TORTURE_RPC_H__ */
diff --git a/source4/torture/rpc/unixinfo.c b/source4/torture/rpc/unixinfo.c
index 4bf27b916b..567a85fd44 100644
--- a/source4/torture/rpc/unixinfo.c
+++ b/source4/torture/rpc/unixinfo.c
@@ -51,24 +51,21 @@ static BOOL test_sidtouid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
/*
test the UidToSid interface
*/
-static BOOL test_uidtosid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_uidtosid(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
- NTSTATUS status;
struct unixinfo_UidToSid r;
r.in.uid = 1000;
- status = dcerpc_unixinfo_UidToSid(p, mem_ctx, &r);
- if (NT_STATUS_EQUAL(NT_STATUS_NO_SUCH_USER, status)) {
- } else if (!NT_STATUS_IS_OK(status)) {
- printf("UidToSid failed == %s\n", nt_errstr(status));
- return False;
- }
+ torture_assert_ntstatus_ok(tctx, dcerpc_unixinfo_UidToSid(p, tctx, &r),
+ "UidToSid failed");
- return True;
+ return true;
}
-static BOOL test_getpwuid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static bool test_getpwuid(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
uint64_t uids[512];
uint32_t num_uids = ARRAY_SIZE(uids);
@@ -83,11 +80,13 @@ static BOOL test_getpwuid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
r.in.count = &num_uids;
r.in.uids = uids;
r.out.count = &num_uids;
- r.out.infos = talloc_array(mem_ctx, struct unixinfo_GetPWUidInfo, num_uids);
+ r.out.infos = talloc_array(tctx, struct unixinfo_GetPWUidInfo, num_uids);
- result = dcerpc_unixinfo_GetPWUid(p, mem_ctx, &r);
+ result = dcerpc_unixinfo_GetPWUid(p, tctx, &r);
- return NT_STATUS_IS_OK(result);
+ torture_assert_ntstatus_ok(tctx, result, "GetPWUid failed");
+
+ return true;
}
/*
@@ -115,44 +114,32 @@ static BOOL test_sidtogid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
/*
test the GidToSid interface
*/
-static BOOL test_gidtosid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static BOOL test_gidtosid(struct torture_context *tctx, struct dcerpc_pipe *p)
{
NTSTATUS status;
struct unixinfo_GidToSid r;
r.in.gid = 1000;
- status = dcerpc_unixinfo_GidToSid(p, mem_ctx, &r);
+ status = dcerpc_unixinfo_GidToSid(p, tctx, &r);
if (NT_STATUS_EQUAL(NT_STATUS_NO_SUCH_GROUP, status)) {
- } else if (!NT_STATUS_IS_OK(status)) {
- printf("GidToSid failed == %s\n", nt_errstr(status));
- return False;
- }
+ } else torture_assert_ntstatus_ok(tctx, status, "GidToSid failed");
- return True;
+ return true;
}
-BOOL torture_rpc_unixinfo(struct torture_context *torture)
+struct torture_suite *torture_rpc_unixinfo(void)
{
- NTSTATUS status;
- struct dcerpc_pipe *p;
- TALLOC_CTX *mem_ctx;
- BOOL ret = True;
-
- mem_ctx = talloc_init("torture_rpc_unixinfo");
+ struct torture_suite *suite;
+ struct torture_tcase *tcase;
- status = torture_rpc_connection(mem_ctx, &p, &dcerpc_table_unixinfo);
- if (!NT_STATUS_IS_OK(status)) {
- return False;
- }
+ suite = torture_suite_create(talloc_autofree_context(), "UNIXINFO");
+ tcase = torture_suite_add_rpc_iface_tcase(suite, "unixinfo",
+ &dcerpc_table_unixinfo);
- ret &= test_uidtosid(p, mem_ctx);
- ret &= test_getpwuid(p, mem_ctx);
- ret &= test_gidtosid(p, mem_ctx);
-
- printf("\n");
-
- talloc_free(mem_ctx);
+ torture_rpc_tcase_add_test(tcase, "uidtosid", test_uidtosid);
+ torture_rpc_tcase_add_test(tcase, "getpwuid", test_getpwuid);
+ torture_rpc_tcase_add_test(tcase, "gidtosid", test_gidtosid);
- return ret;
+ return suite;
}
diff --git a/source4/torture/rpc/wkssvc.c b/source4/torture/rpc/wkssvc.c
index 4526b3f91b..e99cdada28 100644
--- a/source4/torture/rpc/wkssvc.c
+++ b/source4/torture/rpc/wkssvc.c
@@ -24,43 +24,37 @@
#include "librpc/gen_ndr/ndr_wkssvc_c.h"
#include "torture/rpc/rpc.h"
-
-static BOOL test_NetWkstaGetInfo(struct dcerpc_pipe *p,
- TALLOC_CTX *mem_ctx)
+static bool test_NetWkstaGetInfo(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct wkssvc_NetWkstaGetInfo r;
union wkssvc_NetWkstaInfo info;
uint16_t levels[] = {100, 101, 102, 502};
int i;
- BOOL ret = True;
r.in.server_name = dcerpc_server_name(p);
r.out.info = &info;
for (i=0;i<ARRAY_SIZE(levels);i++) {
r.in.level = levels[i];
- printf("testing NetWkstaGetInfo level %u\n", r.in.level);
- status = dcerpc_wkssvc_NetWkstaGetInfo(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("NetWkstaGetInfo level %u failed - %s\n", r.in.level, nt_errstr(status));
- ret = False;
- }
- if (!W_ERROR_IS_OK(r.out.result)) {
- printf("NetWkstaGetInfo level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
- }
+ torture_comment(tctx, talloc_asprintf(tctx, "testing NetWkstaGetInfo level %u\n", r.in.level));
+ status = dcerpc_wkssvc_NetWkstaGetInfo(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status,
+ talloc_asprintf(tctx, "NetWkstaGetInfo level %u failed", r.in.level));
+ torture_assert_werr_ok(tctx, r.out.result,
+ talloc_asprintf(tctx, "NetWkstaGetInfo level %u failed", r.in.level));
}
- return ret;
+ return true;
}
-static BOOL test_NetWkstaTransportEnum(struct dcerpc_pipe *p,
- TALLOC_CTX *mem_ctx)
+static bool test_NetWkstaTransportEnum(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
{
NTSTATUS status;
struct wkssvc_NetWkstaTransportEnum r;
- BOOL ret = True;
uint32_t resume_handle = 0;
union wkssvc_NetWkstaTransportCtr ctr;
struct wkssvc_NetWkstaTransportCtr0 ctr0;
@@ -76,45 +70,28 @@ static BOOL test_NetWkstaTransportEnum(struct dcerpc_pipe *p,
r.out.ctr = &ctr;
r.out.resume_handle = &resume_handle;
- printf("testing NetWkstaTransportEnum\n");
- status = dcerpc_wkssvc_NetWkstaTransportEnum(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("NetWkstaTransportEnum failed - %s\n", nt_errstr(status));
- ret = False;
- }
- if (!W_ERROR_IS_OK(r.out.result)) {
- printf("NetWkstaTransportEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result));
- }
+ status = dcerpc_wkssvc_NetWkstaTransportEnum(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "NetWkstaTransportEnum failed");
+ torture_assert_werr_ok(tctx, r.out.result,
+ talloc_asprintf(tctx,
+ "NetWkstaTransportEnum level %u failed", r.in.level));
- return ret;
+ return true;
}
-BOOL torture_rpc_wkssvc(struct torture_context *torture)
+struct torture_suite *torture_rpc_wkssvc(void)
{
- NTSTATUS status;
- struct dcerpc_pipe *p;
- TALLOC_CTX *mem_ctx;
- BOOL ret = True;
-
- mem_ctx = talloc_init("torture_rpc_wkssvc");
-
- status = torture_rpc_connection(mem_ctx, &p, &dcerpc_table_wkssvc);
- if (!NT_STATUS_IS_OK(status)) {
- talloc_free(mem_ctx);
- return False;
- }
-
- if (!test_NetWkstaGetInfo(p, mem_ctx)) {
- ret = False;
- }
-
- if (!test_NetWkstaTransportEnum(p, mem_ctx)) {
- ret = False;
- }
+ struct torture_suite *suite;
+ struct torture_tcase *tcase;
- talloc_free(mem_ctx);
+ suite = torture_suite_create(talloc_autofree_context(), "WKSSVC");
+ tcase = torture_suite_add_rpc_iface_tcase(suite, "wkssvc",
+ &dcerpc_table_wkssvc);
- return ret;
+ torture_rpc_tcase_add_test(tcase, "NetWkstaGetInfo", test_NetWkstaGetInfo);
+ torture_rpc_tcase_add_test(tcase, "NetWkstaTransportEnum",
+ test_NetWkstaTransportEnum);
+ return suite;
}