summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-09-02 02:35:11 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:03:27 -0500
commite5470270ba08f71764220372155c05dadd692170 (patch)
tree738a94988312da8e60821d82276cdc204dad0f0f
parentac2a7014837b1ce135e732fd7a9b950d9fbc1401 (diff)
downloadsamba-e5470270ba08f71764220372155c05dadd692170.tar.gz
samba-e5470270ba08f71764220372155c05dadd692170.tar.bz2
samba-e5470270ba08f71764220372155c05dadd692170.zip
r24883: Use torture API.
(This used to be commit 9935aac0f3acd50ca775b8ccd74535c56a47ee33)
-rw-r--r--source4/torture/raw/qfileinfo.c47
-rw-r--r--source4/torture/raw/search.c98
2 files changed, 42 insertions, 103 deletions
diff --git a/source4/torture/raw/qfileinfo.c b/source4/torture/raw/qfileinfo.c
index 8cb80cecc1..95680392b4 100644
--- a/source4/torture/raw/qfileinfo.c
+++ b/source4/torture/raw/qfileinfo.c
@@ -222,7 +222,7 @@ static union smb_fileinfo *fname_find(bool is_ipc, const char *name)
for each call we test that it succeeds, and where possible test
for consistency between the calls.
*/
-static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
+static bool torture_raw_qfileinfo_internals(struct torture_context *torture,
TALLOC_CTX *mem_ctx,
struct smbcli_tree *tree,
int fnum, const char *fname,
@@ -295,8 +295,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
ret = False;
printf("%d levels failed\n", count);
if (count > 35) {
- printf("too many level failures - giving up\n");
- goto done;
+ torture_fail(torture, "too many level failures - giving up");
}
}
@@ -448,7 +447,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
/* now check that all the times that are supposed to be equal are correct */
s1 = fnum_find("BASIC_INFO");
correct_time = s1->basic_info.out.create_time;
- printf("create_time: %s\n", nt_time_string(mem_ctx, correct_time));
+ torture_comment(torture, "create_time: %s\n", nt_time_string(mem_ctx, correct_time));
TIME_CHECK_NT ("BASIC_INFO", basic_info, create_time);
TIME_CHECK_NT ("BASIC_INFORMATION", basic_info, create_time);
@@ -460,7 +459,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
s1 = fnum_find("BASIC_INFO");
correct_time = s1->basic_info.out.access_time;
- printf("access_time: %s\n", nt_time_string(mem_ctx, correct_time));
+ torture_comment(torture, "access_time: %s\n", nt_time_string(mem_ctx, correct_time));
TIME_CHECK_NT ("BASIC_INFO", basic_info, access_time);
TIME_CHECK_NT ("BASIC_INFORMATION", basic_info, access_time);
@@ -472,7 +471,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
s1 = fnum_find("BASIC_INFO");
correct_time = s1->basic_info.out.write_time;
- printf("write_time : %s\n", nt_time_string(mem_ctx, correct_time));
+ torture_comment(torture, "write_time : %s\n", nt_time_string(mem_ctx, correct_time));
TIME_CHECK_NT ("BASIC_INFO", basic_info, write_time);
TIME_CHECK_NT ("BASIC_INFORMATION", basic_info, write_time);
@@ -485,7 +484,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
s1 = fnum_find("BASIC_INFO");
correct_time = s1->basic_info.out.change_time;
- printf("change_time: %s\n", nt_time_string(mem_ctx, correct_time));
+ torture_comment(torture, "change_time: %s\n", nt_time_string(mem_ctx, correct_time));
TIME_CHECK_NT ("BASIC_INFO", basic_info, change_time);
TIME_CHECK_NT ("BASIC_INFORMATION", basic_info, change_time);
@@ -511,7 +510,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
s1 = fnum_find("STANDARD_INFO");
correct_size = s1->standard_info.out.size;
- printf("size: %u\n", (uint_t)correct_size);
+ torture_comment(torture, "size: %u\n", (uint_t)correct_size);
SIZE_CHECK("GETATTR", getattr, size);
SIZE_CHECK("GETATTRE", getattre, size);
@@ -532,7 +531,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
s1 = fnum_find("STANDARD_INFO");
correct_size = s1->standard_info.out.alloc_size;
- printf("alloc_size: %u\n", (uint_t)correct_size);
+ torture_comment(torture, "alloc_size: %u\n", (uint_t)correct_size);
SIZE_CHECK("GETATTRE", getattre, alloc_size);
SIZE_CHECK("STANDARD", standard, alloc_size);
@@ -565,7 +564,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
s1 = fnum_find("BASIC_INFO");
correct_attrib = s1->basic_info.out.attrib;
- printf("attrib: 0x%x\n", (uint_t)correct_attrib);
+ torture_comment(torture, "attrib: 0x%x\n", (uint_t)correct_attrib);
ATTRIB_CHECK("GETATTR", getattr, attrib);
if (!is_ipc) {
@@ -581,7 +580,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
ATTRIB_CHECK("ATTRIBUTE_TAG_INFORMATION", attribute_tag_information, attrib);
correct_name = fname;
- printf("name: %s\n", correct_name);
+ torture_comment(torture, "name: %s\n", correct_name);
#define NAME_CHECK(sname, stype, tfield, flags) do { \
s1 = fnum_find(sname); \
@@ -605,8 +604,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
/* the ALL_INFO file name is the full path on the filesystem */
s1 = fnum_find("ALL_INFO");
if (s1 && !s1->all_info.out.fname.s) {
- printf("ALL_INFO didn't give a filename\n");
- ret = False;
+ torture_fail(torture, "ALL_INFO didn't give a filename");
}
if (s1 && s1->all_info.out.fname.s) {
char *p = strrchr(s1->all_info.out.fname.s, '\\');
@@ -630,7 +628,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
s1 = fnum_find("ALT_NAME_INFO");
if (s1) {
correct_name = s1->alt_name_info.out.fname.s;
- printf("alt_name: %s\n", correct_name);
+ torture_comment(torture, "alt_name: %s\n", correct_name);
NAME_CHECK("ALT_NAME_INFO", alt_name_info, fname, STR_UNICODE);
NAME_CHECK("ALT_NAME_INFORMATION", alt_name_info, fname, STR_UNICODE);
@@ -652,7 +650,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
if (!skip_streams) {
correct_name = "::$DATA";
- printf("stream_name: %s\n", correct_name);
+ torture_comment(torture, "stream_name: %s\n", correct_name);
NAME_CHECK("STREAM_INFO", stream_info, streams[0].stream_name, STR_UNICODE);
NAME_CHECK("STREAM_INFORMATION", stream_info, streams[0].stream_name, STR_UNICODE);
@@ -768,7 +766,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
s1 = fnum_find("INTERNAL_INFORMATION");
if (s1) {
- printf("file_id=%.0f\n", (double)s1->internal_information.out.file_id);
+ torture_comment(torture, "file_id=%.0f\n", (double)s1->internal_information.out.file_id);
}
NAME_PATH_CHECK("INTERNAL_INFORMATION", internal_information, file_id);
@@ -808,9 +806,6 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture,
/* when we set the delete disposition then the link count should drop
to 0 and delete_pending should be 1 */
-
-done:
-
return ret;
}
@@ -840,7 +835,7 @@ bool torture_raw_qfileinfo(struct torture_context *torture,
}
bool torture_raw_qfileinfo_pipe(struct torture_context *torture,
- struct smbcli_state *cli)
+ struct smbcli_state *cli)
{
bool ret = true;
int fnum;
@@ -849,23 +844,17 @@ bool torture_raw_qfileinfo_pipe(struct torture_context *torture,
struct smbcli_tree *ipc_tree;
NTSTATUS status;
- if (!(p = dcerpc_pipe_init(torture,
- cli->tree->session->transport->socket->event.ctx))) {
+ if (!(p = dcerpc_pipe_init(torture, cli->tree->session->transport->socket->event.ctx))) {
return False;
}
status = dcerpc_pipe_open_smb(p, cli->tree, fname);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("dcerpc_pipe_open_smb failed: %s\n",
- nt_errstr(status));
- talloc_free(p);
- return False;
- }
+ torture_assert_ntstatus_ok(torture, status, "dcerpc_pipe_open_smb failed");
ipc_tree = dcerpc_smb_tree(p->conn);
fnum = dcerpc_smb_fnum(p->conn);
- ret = torture_raw_qfileinfo_internals(torture, torture, ipc_tree, fnum, fname, True /* is_ipc */);
+ ret = torture_raw_qfileinfo_internals(torture, torture, ipc_tree, fnum, fname, true /* is_ipc */);
talloc_free(p);
return ret;
diff --git a/source4/torture/raw/search.c b/source4/torture/raw/search.c
index 986da474d0..b1931d9359 100644
--- a/source4/torture/raw/search.c
+++ b/source4/torture/raw/search.c
@@ -36,7 +36,7 @@ static BOOL single_search_callback(void *private, const union smb_search_data *f
*data = *file;
- return True;
+ return true;
}
/*
@@ -231,8 +231,8 @@ static union smb_search_data *find(const char *name)
/*
basic testing of all RAW_SEARCH_* calls using a single file
*/
-static BOOL test_one_file(struct torture_context *tctx,
- struct smbcli_state *cli)
+static bool test_one_file(struct torture_context *tctx,
+ struct smbcli_state *cli)
{
BOOL ret = True;
int fnum;
@@ -243,8 +243,6 @@ static BOOL test_one_file(struct torture_context *tctx,
union smb_fileinfo all_info, alt_info, name_info, internal_info;
union smb_search_data *s;
- printf("Testing one file searches\n");
-
fnum = create_complex_file(cli, tctx, fname);
if (fnum == -1) {
printf("ERROR: open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
@@ -257,7 +255,7 @@ static BOOL test_one_file(struct torture_context *tctx,
NTSTATUS expected_status;
uint32_t cap = cli->transport->negotiate.capabilities;
- printf("testing %s\n", levels[i].name);
+ torture_comment(tctx, "testing %s\n", levels[i].name);
levels[i].status = torture_single_search(cli, tctx, fname,
levels[i].level,
@@ -305,38 +303,22 @@ static BOOL test_one_file(struct torture_context *tctx,
all_info.generic.level = RAW_FILEINFO_ALL_INFO;
all_info.generic.in.file.path = fname;
status = smb_raw_pathinfo(cli->tree, tctx, &all_info);
- if (!NT_STATUS_IS_OK(status)) {
- printf("RAW_FILEINFO_ALL_INFO failed - %s\n", nt_errstr(status));
- ret = False;
- goto done;
- }
+ torture_assert_ntstatus_ok(tctx, status, "RAW_FILEINFO_ALL_INFO failed");
alt_info.generic.level = RAW_FILEINFO_ALT_NAME_INFO;
alt_info.generic.in.file.path = fname;
status = smb_raw_pathinfo(cli->tree, tctx, &alt_info);
- if (!NT_STATUS_IS_OK(status)) {
- printf("RAW_FILEINFO_ALT_NAME_INFO failed - %s\n", nt_errstr(status));
- ret = False;
- goto done;
- }
+ torture_assert_ntstatus_ok(tctx, status, "RAW_FILEINFO_ALT_NAME_INFO failed");
internal_info.generic.level = RAW_FILEINFO_INTERNAL_INFORMATION;
internal_info.generic.in.file.path = fname;
status = smb_raw_pathinfo(cli->tree, tctx, &internal_info);
- if (!NT_STATUS_IS_OK(status)) {
- printf("RAW_FILEINFO_INTERNAL_INFORMATION failed - %s\n", nt_errstr(status));
- ret = False;
- goto done;
- }
+ torture_assert_ntstatus_ok(tctx, status, "RAW_FILEINFO_INTERNAL_INFORMATION failed");
name_info.generic.level = RAW_FILEINFO_NAME_INFO;
name_info.generic.in.file.path = fname;
status = smb_raw_pathinfo(cli->tree, tctx, &name_info);
- if (!NT_STATUS_IS_OK(status)) {
- printf("RAW_FILEINFO_NAME_INFO failed - %s\n", nt_errstr(status));
- ret = False;
- goto done;
- }
+ torture_assert_ntstatus_ok(tctx, status, "RAW_FILEINFO_NAME_INFO failed");
#define CHECK_VAL(name, sname1, field1, v, sname2, field2) do { \
s = find(name); \
@@ -540,7 +522,7 @@ static BOOL multiple_search_callback(void *private, const union smb_search_data
data->list[data->count-1] = *file;
- return True;
+ return true;
}
enum continue_type {CONT_FLAGS, CONT_NAME, CONT_RESUME_KEY};
@@ -640,28 +622,11 @@ static NTSTATUS multiple_search(struct smbcli_state *cli,
return status;
}
-#define CHECK_STATUS(status, correct) do { \
- if (!NT_STATUS_EQUAL(status, correct)) { \
- printf("(%s) Incorrect status %s - should be %s\n", \
- __location__, nt_errstr(status), nt_errstr(correct)); \
- ret = False; \
- goto done; \
- }} while (0)
+#define CHECK_STATUS(status, correct) torture_assert_ntstatus_equal(tctx, status, correct, "incorrect status")
-#define CHECK_VALUE(v, correct) do { \
- if ((v) != (correct)) { \
- printf("(%s) Incorrect value %s=%ld - should be %ld\n", \
- __location__, #v, (long)v, (long)correct); \
- ret = False; \
- goto done; \
- }} while (0)
+#define CHECK_VALUE(v, correct) torture_assert_int_equal(tctx, (v), (correct), "incorrect value");
-#define CHECK_STRING(v, correct) do { \
- if (strcasecmp_m(v, correct) != 0) { \
- printf("(%s) Incorrect value %s='%s' - should be '%s'\n", \
- __location__, #v, v, correct); \
- ret = False; \
- }} while (0)
+#define CHECK_STRING(v, correct) torture_assert_casestr_equal(tctx, v, correct, "incorrect value");
static enum smb_search_data_level compare_data_level;
@@ -688,7 +653,7 @@ static int search_compare(union smb_search_data *d1, union smb_search_data *d2)
basic testing of search calls using many files
*/
static bool test_many_files(struct torture_context *tctx,
- struct smbcli_state *cli)
+ struct smbcli_state *cli)
{
const int num_files = 700;
int i, fnum, t;
@@ -727,19 +692,15 @@ static bool test_many_files(struct torture_context *tctx,
};
if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
+ return false;
}
- printf("Testing with %d files\n", num_files);
+ torture_comment(tctx, "Testing with %d files\n", num_files);
for (i=0;i<num_files;i++) {
fname = talloc_asprintf(cli, BASEDIR "\\t%03d-%d.txt", i, i);
fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
- if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
- ret = False;
- goto done;
- }
+ torture_assert(tctx, fnum != -1, "Failed to create");
talloc_free(fname);
smbcli_close(cli->tree, fnum);
}
@@ -749,20 +710,15 @@ static bool test_many_files(struct torture_context *tctx,
ZERO_STRUCT(result);
result.tctx = talloc_new(tctx);
- printf("Continue %s via %s\n", search_types[t].name, search_types[t].cont_name);
+ torture_comment(tctx,
+ "Continue %s via %s\n", search_types[t].name, search_types[t].cont_name);
status = multiple_search(cli, tctx, BASEDIR "\\*.*",
search_types[t].data_level,
search_types[t].cont_type,
&result);
- if (!NT_STATUS_IS_OK(status)) {
- printf("search type %s failed - %s\n",
- search_types[t].name,
- nt_errstr(status));
- ret = False;
- continue;
- }
+ torture_assert_ntstatus_ok(tctx, status, "search failed");
CHECK_VALUE(result.count, num_files);
compare_data_level = search_types[t].data_level;
@@ -780,17 +736,12 @@ static bool test_many_files(struct torture_context *tctx,
}
s = extract_name(&result.list[i], level, compare_data_level);
fname = talloc_asprintf(cli, "t%03d-%d.txt", i, i);
- if (strcmp(fname, s)) {
- printf("Incorrect name %s at entry %d\n", s, i);
- ret = False;
- break;
- }
+ torture_assert_str_equal(tctx, fname, s, "Incorrect name");
talloc_free(fname);
}
talloc_free(result.tctx);
}
-done:
smb_raw_exit(cli->session);
smbcli_deltree(cli->tree, BASEDIR);
@@ -800,7 +751,7 @@ done:
/*
check a individual file result
*/
-static BOOL check_result(struct multiple_result *result, const char *name, BOOL exist, uint32_t attrib)
+static bool check_result(struct multiple_result *result, const char *name, BOOL exist, uint32_t attrib)
{
int i;
for (i=0;i<result->count;i++) {
@@ -812,7 +763,7 @@ static BOOL check_result(struct multiple_result *result, const char *name, BOOL
name, attrib_string(result->list, attrib));
return False;
}
- return True;
+ return true;
}
if (!exist) {
@@ -827,7 +778,7 @@ static BOOL check_result(struct multiple_result *result, const char *name, BOOL
attrib, result->list[i].both_directory_info.attrib);
return False;
}
- return True;
+ return true;
}
/*
@@ -1402,7 +1353,6 @@ static bool test_ea_list(struct torture_context *tctx,
CHECK_STRING(result.list[2].ea_list.eas.eas[1].name.s, "THIRD EA");
CHECK_VALUE(result.list[2].ea_list.eas.eas[1].value.length, 0);
-done:
smb_raw_exit(cli->session);
smbcli_deltree(cli->tree, BASEDIR);
@@ -1418,7 +1368,7 @@ struct torture_suite *torture_raw_search(TALLOC_CTX *mem_ctx)
{
struct torture_suite *suite = torture_suite_create(mem_ctx, "SEARCH");
- torture_suite_add_1smb_test(suite, "one file", test_one_file);
+ torture_suite_add_1smb_test(suite, "one file search", test_one_file);
torture_suite_add_1smb_test(suite, "many files", test_many_files);
torture_suite_add_1smb_test(suite, "sorted", test_sorted);
torture_suite_add_1smb_test(suite, "modify search", test_modify_search);