summaryrefslogtreecommitdiff
path: root/source4/torture/basic/aliases.c
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/basic/aliases.c
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/basic/aliases.c')
-rw-r--r--source4/torture/basic/aliases.c197
1 files changed, 95 insertions, 102 deletions
diff --git a/source4/torture/basic/aliases.c b/source4/torture/basic/aliases.c
index 3643d098ba..01ca33359d 100644
--- a/source4/torture/basic/aliases.c
+++ b/source4/torture/basic/aliases.c
@@ -34,62 +34,62 @@ struct trans2_blobs {
};
/* look for aliases for a query */
-static void gen_aliases(struct smbcli_state *cli, struct smb_trans2 *t2, int level_offset)
+static bool gen_aliases(struct torture_context *tctx,
+ struct smbcli_state *cli, struct smb_trans2 *t2,
+ int level_offset)
{
- TALLOC_CTX *mem_ctx;
uint16_t level;
struct trans2_blobs *alias_blobs = NULL;
struct trans2_blobs *t2b, *t2b2;
int count=0, alias_count=0;
- mem_ctx = talloc_init("aliases");
-
for (level=0;level<2000;level++) {
NTSTATUS status;
SSVAL(t2->in.params.data, level_offset, level);
- status = smb_raw_trans2(cli->tree, mem_ctx, t2);
+ status = smb_raw_trans2(cli->tree, tctx, t2);
if (!NT_STATUS_IS_OK(status)) continue;
- t2b = talloc(mem_ctx, struct trans2_blobs);
+ t2b = talloc(tctx, struct trans2_blobs);
t2b->level = level;
t2b->params = t2->out.params;
t2b->data = t2->out.data;
DLIST_ADD(alias_blobs, t2b);
- d_printf("\tFound level %4u (0x%03x) of size %3d (0x%02x)\n",
+ torture_comment(tctx,
+ "\tFound level %4u (0x%03x) of size %3d (0x%02x)\n",
level, level,
(int)t2b->data.length, (int)t2b->data.length);
count++;
}
- d_printf("Found %d levels with success status\n", count);
+ torture_comment(tctx, "Found %d levels with success status\n", count);
for (t2b=alias_blobs; t2b; t2b=t2b->next) {
for (t2b2=alias_blobs; t2b2; t2b2=t2b2->next) {
if (t2b->level >= t2b2->level) continue;
if (data_blob_equal(&t2b->params, &t2b2->params) &&
data_blob_equal(&t2b->data, &t2b2->data)) {
- printf("\tLevel %u (0x%x) and level %u (0x%x) are possible aliases\n",
+ torture_comment(tctx,
+ "\tLevel %u (0x%x) and level %u (0x%x) are possible aliases\n",
t2b->level, t2b->level, t2b2->level, t2b2->level);
alias_count++;
}
}
}
- d_printf("Found %d aliased levels\n", alias_count);
-
- talloc_free(mem_ctx);
+ torture_comment(tctx, "Found %d aliased levels\n", alias_count);
+
+ return true;
}
/* look for qfsinfo aliases */
-static void qfsinfo_aliases(struct smbcli_state *cli)
+static bool qfsinfo_aliases(struct torture_context *tctx,
+ struct smbcli_state *cli)
{
struct smb_trans2 t2;
uint16_t setup = TRANSACT2_QFSINFO;
- d_printf("\nChecking for QFSINFO aliases\n");
-
t2.in.max_param = 0;
t2.in.max_data = smb_raw_max_trans_data(cli->tree, 0);
t2.in.max_setup = 0;
@@ -100,19 +100,18 @@ static void qfsinfo_aliases(struct smbcli_state *cli)
t2.in.params = data_blob(NULL, 2);
t2.in.data = data_blob(NULL, 0);
- gen_aliases(cli, &t2, 0);
+ return gen_aliases(tctx, cli, &t2, 0);
}
/* look for qfileinfo aliases */
-static void qfileinfo_aliases(struct smbcli_state *cli)
+static bool qfileinfo_aliases(struct torture_context *tctx,
+ struct smbcli_state *cli)
{
struct smb_trans2 t2;
uint16_t setup = TRANSACT2_QFILEINFO;
const char *fname = "\\qfileinfo_aliases.txt";
int fnum;
- d_printf("\nChecking for QFILEINFO aliases\n");
-
t2.in.max_param = 2;
t2.in.max_data = smb_raw_max_trans_data(cli->tree, 2);
t2.in.max_setup = 0;
@@ -125,33 +124,32 @@ static void qfileinfo_aliases(struct smbcli_state *cli)
smbcli_unlink(cli->tree, fname);
fnum = create_complex_file(cli, cli, fname);
- if (fnum == -1) {
- printf("ERROR: open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
- }
+ torture_assert(tctx, fnum != -1, talloc_asprintf(tctx,
+ "open of %s failed (%s)", fname,
+ smbcli_errstr(cli->tree)));
smbcli_write(cli->tree, fnum, 0, &t2, 0, sizeof(t2));
SSVAL(t2.in.params.data, 0, fnum);
- gen_aliases(cli, &t2, 2);
+ if (!gen_aliases(tctx, cli, &t2, 2))
+ return false;
smbcli_close(cli->tree, fnum);
smbcli_unlink(cli->tree, fname);
+
+ return true;
}
/* look for qpathinfo aliases */
-static void qpathinfo_aliases(struct smbcli_state *cli)
+static bool qpathinfo_aliases(struct torture_context *tctx,
+ struct smbcli_state *cli)
{
struct smb_trans2 t2;
uint16_t setup = TRANSACT2_QPATHINFO;
const char *fname = "\\qpathinfo_aliases.txt";
int fnum;
- TALLOC_CTX *mem_ctx;
-
- mem_ctx = talloc_init("qpathinfo");
-
- d_printf("\nChecking for QPATHINFO aliases\n");
t2.in.max_param = 2;
t2.in.max_data = smb_raw_max_trans_data(cli->tree, 2);
@@ -160,42 +158,40 @@ static void qpathinfo_aliases(struct smbcli_state *cli)
t2.in.timeout = 0;
t2.in.setup_count = 1;
t2.in.setup = &setup;
- t2.in.params = data_blob_talloc(mem_ctx, NULL, 6);
+ t2.in.params = data_blob_talloc(tctx, NULL, 6);
t2.in.data = data_blob(NULL, 0);
smbcli_unlink(cli->tree, fname);
fnum = create_complex_file(cli, cli, fname);
- if (fnum == -1) {
- printf("ERROR: open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
- }
+ torture_assert(tctx, fnum != -1, talloc_asprintf(tctx,
+ "open of %s failed (%s)", fname,
+ smbcli_errstr(cli->tree)));
smbcli_write(cli->tree, fnum, 0, &t2, 0, sizeof(t2));
smbcli_close(cli->tree, fnum);
SIVAL(t2.in.params.data, 2, 0);
- smbcli_blob_append_string(cli->session, mem_ctx, &t2.in.params,
+ smbcli_blob_append_string(cli->session, tctx, &t2.in.params,
fname, STR_TERMINATE);
- gen_aliases(cli, &t2, 0);
+ if (!gen_aliases(tctx, cli, &t2, 0))
+ return false;
smbcli_unlink(cli->tree, fname);
- talloc_free(mem_ctx);
+
+ return true;
}
/* look for trans2 findfirst aliases */
-static void findfirst_aliases(struct smbcli_state *cli)
+static bool findfirst_aliases(struct torture_context *tctx,
+ struct smbcli_state *cli)
{
struct smb_trans2 t2;
uint16_t setup = TRANSACT2_FINDFIRST;
const char *fname = "\\findfirst_aliases.txt";
int fnum;
- TALLOC_CTX *mem_ctx;
-
- mem_ctx = talloc_init("findfirst");
-
- d_printf("\nChecking for FINDFIRST aliases\n");
t2.in.max_param = 16;
t2.in.max_data = smb_raw_max_trans_data(cli->tree, 16);
@@ -204,14 +200,14 @@ static void findfirst_aliases(struct smbcli_state *cli)
t2.in.timeout = 0;
t2.in.setup_count = 1;
t2.in.setup = &setup;
- t2.in.params = data_blob_talloc(mem_ctx, NULL, 12);
+ t2.in.params = data_blob_talloc(tctx, NULL, 12);
t2.in.data = data_blob(NULL, 0);
smbcli_unlink(cli->tree, fname);
fnum = create_complex_file(cli, cli, fname);
- if (fnum == -1) {
- printf("ERROR: open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
- }
+ torture_assert(tctx, fnum != -1, talloc_asprintf(tctx,
+ "open of %s failed (%s)", fname,
+ smbcli_errstr(cli->tree)));
smbcli_write(cli->tree, fnum, 0, &t2, 0, sizeof(t2));
smbcli_close(cli->tree, fnum);
@@ -222,28 +218,29 @@ static void findfirst_aliases(struct smbcli_state *cli)
SSVAL(t2.in.params.data, 6, 0);
SIVAL(t2.in.params.data, 8, 0);
- smbcli_blob_append_string(cli->session, mem_ctx, &t2.in.params,
+ smbcli_blob_append_string(cli->session, tctx, &t2.in.params,
fname, STR_TERMINATE);
- gen_aliases(cli, &t2, 6);
+ if (!gen_aliases(tctx, cli, &t2, 6))
+ return false;
smbcli_unlink(cli->tree, fname);
- talloc_free(mem_ctx);
+
+ return true;
}
/* look for aliases for a set function */
-static void gen_set_aliases(struct smbcli_state *cli, struct smb_trans2 *t2, int level_offset)
+static bool gen_set_aliases(struct torture_context *tctx,
+ struct smbcli_state *cli,
+ struct smb_trans2 *t2, int level_offset)
{
- TALLOC_CTX *mem_ctx;
uint16_t level;
struct trans2_blobs *alias_blobs = NULL;
struct trans2_blobs *t2b;
int count=0, dsize;
- mem_ctx = talloc_init("aliases");
-
for (level=1;level<1100;level++) {
NTSTATUS status, status1;
SSVAL(t2->in.params.data, level_offset, level);
@@ -254,7 +251,7 @@ static void gen_set_aliases(struct smbcli_state *cli, struct smb_trans2 *t2, int
data_blob_free(&t2->in.data);
t2->in.data = data_blob(NULL, dsize);
data_blob_clear(&t2->in.data);
- status = smb_raw_trans2(cli->tree, mem_ctx, t2);
+ status = smb_raw_trans2(cli->tree, tctx, t2);
/* some error codes mean that this whole level doesn't exist */
if (NT_STATUS_EQUAL(NT_STATUS_INVALID_LEVEL, status) ||
NT_STATUS_EQUAL(NT_STATUS_INVALID_INFO_CLASS, status) ||
@@ -274,7 +271,7 @@ static void gen_set_aliases(struct smbcli_state *cli, struct smb_trans2 *t2, int
}
if (!NT_STATUS_EQUAL(status, status1)) {
- printf("level=%d size=%d %s\n", level, dsize, nt_errstr(status));
+ torture_comment(tctx, "level=%d size=%d %s\n", level, dsize, nt_errstr(status));
}
status1 = status;
}
@@ -282,33 +279,34 @@ static void gen_set_aliases(struct smbcli_state *cli, struct smb_trans2 *t2, int
if (!NT_STATUS_IS_OK(status) &&
!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) continue;
- t2b = talloc(mem_ctx, struct trans2_blobs);
+ t2b = talloc(tctx, struct trans2_blobs);
t2b->level = level;
t2b->params = t2->out.params;
t2b->data = t2->out.data;
DLIST_ADD(alias_blobs, t2b);
- d_printf("\tFound level %4u (0x%03x) of size %3d (0x%02x)\n",
+ torture_comment(tctx,
+ "\tFound level %4u (0x%03x) of size %3d (0x%02x)\n",
level, level,
(int)t2->in.data.length, (int)t2->in.data.length);
count++;
}
- d_printf("Found %d valid levels\n", count);
- talloc_free(mem_ctx);
+ torture_comment(tctx, "Found %d valid levels\n", count);
+
+ return true;
}
/* look for setfileinfo aliases */
-static void setfileinfo_aliases(struct smbcli_state *cli)
+static bool setfileinfo_aliases(struct torture_context *tctx,
+ struct smbcli_state *cli)
{
struct smb_trans2 t2;
uint16_t setup = TRANSACT2_SETFILEINFO;
const char *fname = "\\setfileinfo_aliases.txt";
int fnum;
- d_printf("\nChecking for SETFILEINFO aliases\n");
-
t2.in.max_param = 2;
t2.in.max_data = 0;
t2.in.max_setup = 0;
@@ -321,33 +319,31 @@ static void setfileinfo_aliases(struct smbcli_state *cli)
smbcli_unlink(cli->tree, fname);
fnum = create_complex_file(cli, cli, fname);
- if (fnum == -1) {
- printf("ERROR: open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
- }
+ torture_assert(tctx, fnum != -1, talloc_asprintf(tctx,
+ "open of %s failed (%s)", fname,
+ smbcli_errstr(cli->tree)));
smbcli_write(cli->tree, fnum, 0, &t2, 0, sizeof(t2));
SSVAL(t2.in.params.data, 0, fnum);
SSVAL(t2.in.params.data, 4, 0);
- gen_set_aliases(cli, &t2, 2);
+ gen_set_aliases(tctx, cli, &t2, 2);
smbcli_close(cli->tree, fnum);
smbcli_unlink(cli->tree, fname);
+
+ return true;
}
/* look for setpathinfo aliases */
-static void setpathinfo_aliases(struct smbcli_state *cli)
+static bool setpathinfo_aliases(struct torture_context *tctx,
+ struct smbcli_state *cli)
{
struct smb_trans2 t2;
uint16_t setup = TRANSACT2_SETPATHINFO;
const char *fname = "\\setpathinfo_aliases.txt";
int fnum;
- TALLOC_CTX *mem_ctx;
-
- mem_ctx = talloc_init("findfirst");
-
- d_printf("\nChecking for SETPATHINFO aliases\n");
t2.in.max_param = 32;
t2.in.max_data = smb_raw_max_trans_data(cli->tree, 32);
@@ -356,53 +352,50 @@ static void setpathinfo_aliases(struct smbcli_state *cli)
t2.in.timeout = 0;
t2.in.setup_count = 1;
t2.in.setup = &setup;
- t2.in.params = data_blob_talloc(mem_ctx, NULL, 4);
+ t2.in.params = data_blob_talloc(tctx, NULL, 4);
t2.in.data = data_blob(NULL, 0);
smbcli_unlink(cli->tree, fname);
fnum = create_complex_file(cli, cli, fname);
- if (fnum == -1) {
- printf("ERROR: open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
- }
+ torture_assert(tctx, fnum != -1, talloc_asprintf(tctx,
+ "open of %s failed (%s)", fname,
+ smbcli_errstr(cli->tree)));
smbcli_write(cli->tree, fnum, 0, &t2, 0, sizeof(t2));
smbcli_close(cli->tree, fnum);
SSVAL(t2.in.params.data, 2, 0);
- smbcli_blob_append_string(cli->session, mem_ctx, &t2.in.params,
+ smbcli_blob_append_string(cli->session, tctx, &t2.in.params,
fname, STR_TERMINATE);
- gen_set_aliases(cli, &t2, 0);
+ if (!gen_set_aliases(tctx, cli, &t2, 0))
+ return false;
- if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fname))) {
- printf("unlink: %s\n", smbcli_errstr(cli->tree));
- }
- talloc_free(mem_ctx);
+ torture_assert_ntstatus_ok(tctx, smbcli_unlink(cli->tree, fname),
+ talloc_asprintf(tctx, "unlink: %s", smbcli_errstr(cli->tree)));
+
+ return true;
}
/* look for aliased info levels in trans2 calls */
-BOOL torture_trans2_aliases(struct torture_context *torture)
+struct torture_suite *torture_trans2_aliases(void)
{
- struct smbcli_state *cli;
-
- if (!torture_open_connection(&cli, 0)) {
- return False;
- }
-
-
- qfsinfo_aliases(cli);
- qfileinfo_aliases(cli);
- qpathinfo_aliases(cli);
- findfirst_aliases(cli);
- setfileinfo_aliases(cli);
- setpathinfo_aliases(cli);
-
- if (!torture_close_connection(cli)) {
- return False;
- }
-
- return True;
+ struct torture_suite *suite = torture_suite_create(
+ talloc_autofree_context(),
+ "ALIASES");
+
+ torture_suite_add_1smb_test(suite, "QFILEINFO aliases",
+ qfsinfo_aliases);
+ torture_suite_add_1smb_test(suite, "QFSINFO aliases", qfileinfo_aliases);
+ torture_suite_add_1smb_test(suite, "QPATHINFO aliases", qpathinfo_aliases);
+ torture_suite_add_1smb_test(suite, "FINDFIRST aliases", findfirst_aliases);
+ torture_suite_add_1smb_test(suite, "setfileinfo_aliases",
+ setfileinfo_aliases);
+ torture_suite_add_1smb_test(suite, "setpathinfo_aliases",
+ setpathinfo_aliases);
+
+ return suite;
}