summaryrefslogtreecommitdiff
path: root/source4/torture/rpc/dfs.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-08-28 16:24:18 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:03:02 -0500
commit18302e7030e568d23f13717cb006193490e4213d (patch)
treec1c5985f584a25e7e2798f8a5d179847c4bd5d09 /source4/torture/rpc/dfs.c
parent0e6773525fa9d3fe9b7559ab4067e088f8a934d8 (diff)
downloadsamba-18302e7030e568d23f13717cb006193490e4213d.tar.gz
samba-18302e7030e568d23f13717cb006193490e4213d.tar.bz2
samba-18302e7030e568d23f13717cb006193490e4213d.zip
r24751: Run more tests, remove empty testsuites, more small improvements.
(This used to be commit 2a5a0819eea86ba322434306e062d13893b5722e)
Diffstat (limited to 'source4/torture/rpc/dfs.c')
-rw-r--r--source4/torture/rpc/dfs.c124
1 files changed, 59 insertions, 65 deletions
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 <http://www.gnu.org/licenses/>.
+ 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;i<ARRAY_SIZE(levels);i++) {
- if (!test_GetInfoLevel(tctx, p, levels[i], root)) {
- ret = false;
+ if (!test_GetInfoLevel(p, mem_ctx, levels[i], root)) {
+ ret = False;
}
}
return ret;
}
-static bool test_EnumLevel(struct torture_context *tctx,
- struct dcerpc_pipe *p, uint16_t level)
+static BOOL test_EnumLevelEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t level, const char *dfs_name)
{
NTSTATUS status;
struct dfs_EnumEx rex;
@@ -302,18 +305,23 @@ static BOOL test_EnumLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t
e.e.info1->s = &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;i<ARRAY_SIZE(levels);i++) {
- if (!test_EnumLevel(tctx, p, levels[i])) {
- ret = false;
+ if (!test_EnumLevel(p, mem_ctx, levels[i])) {
+ ret = False;
}
}
@@ -474,35 +481,22 @@ static BOOL test_StdRoot(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char
return ret;
}
-#endif
-
-struct torture_suite *torture_rpc_dfs(void)
+bool torture_rpc_dfs(struct torture_context *torture)
{
- struct torture_suite *suite = torture_suite_create(
- talloc_autofree_context(), "RPC-DFS");
-
-#if 0
- struct torture_tcase *tcase = torture_suite_add_rpc_iface_tcase(suite,
- "dfs", &ndr_table_netdfs);
-
- torture_rpc_tcase_add_test(tcase, "GetManagerVersion",
- test_GetManagerVersion);
-
-#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);
+ NTSTATUS status;
+ struct dcerpc_pipe *p;
+ BOOL ret = True;
+ enum dfs_ManagerVersion version;
+ const char *host = lp_parm_string(-1, "torture", "host");
- talloc_free(mem_ctx);
+ status = torture_rpc_connection(torture, &p, &ndr_table_netdfs);
+ torture_assert_ntstatus_ok(torture, status, "Unable to connect");
-#endif
+ ret &= test_GetManagerVersion(p, torture, &version);
+ ret &= test_ManagerInitialize(p, torture, host);
+ ret &= test_Enum(p, torture);
+ ret &= test_EnumEx(p, torture, host);
+ ret &= test_StdRoot(p, torture, host);
- return suite;
+ return ret;
}