diff options
author | Aravind Srinivasan <aravind.srinivasan@isilon.com> | 2009-12-15 09:49:08 -0800 |
---|---|---|
committer | Tim Prouty <tprouty@samba.org> | 2009-12-15 09:51:36 -0800 |
commit | b85f6f63e6e957970f09acb2aab14e63d2661a22 (patch) | |
tree | 87c7b21a13a67869ca3a987b2347bd24c27a14f3 | |
parent | 8ba02d9ed9d1f6f330ed1f72d919bfa3869e37f5 (diff) | |
download | samba-b85f6f63e6e957970f09acb2aab14e63d2661a22.tar.gz samba-b85f6f63e6e957970f09acb2aab14e63d2661a22.tar.bz2 samba-b85f6f63e6e957970f09acb2aab14e63d2661a22.zip |
s4 torture: Add new RAW-SEARCH test to explore strange max count behavior
Signed-off-by: Tim Prouty <tprouty@samba.org>
-rw-r--r-- | source4/torture/raw/search.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/source4/torture/raw/search.c b/source4/torture/raw/search.c index 74186e3a5d..dec7da0751 100644 --- a/source4/torture/raw/search.c +++ b/source4/torture/raw/search.c @@ -1376,7 +1376,81 @@ static bool test_ea_list(struct torture_context *tctx, return ret; } +/* + Test the behavior of max count parameter in TRANS2_FIND_FIRST2 and + TRANS2_FIND_NEXT2 queries +*/ +static bool test_max_count(struct torture_context *tctx, + struct smbcli_state *cli) +{ + const int num_files = 2; + int i, fnum; + char *fname; + bool ret = true; + NTSTATUS status; + struct multiple_result result; + union smb_search_first io; + union smb_search_next io2; + + if (!torture_setup_dir(cli, BASEDIR)) { + return false; + } + + torture_comment(tctx, "Creating %d files\n", num_files); + + for (i=num_files-1;i>=0;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) { + torture_comment(tctx, + "Failed to create %s - %s\n", + fname, smbcli_errstr(cli->tree)); + ret = false; + goto done; + } + talloc_free(fname); + smbcli_close(cli->tree, fnum); + } + + torture_comment(tctx, "Set max_count parameter to 0. " + "This should return 1 entry\n"); + ZERO_STRUCT(result); + result.tctx = talloc_new(tctx); + io.t2ffirst.level = RAW_SEARCH_TRANS2; + io.t2ffirst.data_level = RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO; + io.t2ffirst.in.search_attrib = 0; + io.t2ffirst.in.max_count = 0; + io.t2ffirst.in.flags = 0; + io.t2ffirst.in.storage_type = 0; + io.t2ffirst.in.pattern = BASEDIR "\\*.*"; + + status = smb_raw_search_first(cli->tree, tctx, + &io, &result, multiple_search_callback); + CHECK_STATUS(status, NT_STATUS_OK); + CHECK_VALUE(result.count, 1); + + torture_comment(tctx, "Set max_count to 1. This should also " + "return 1 entry\n"); + io2.t2fnext.level = RAW_SEARCH_TRANS2; + io2.t2fnext.data_level = RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO; + io2.t2fnext.in.handle = io.t2ffirst.out.handle; + io2.t2fnext.in.max_count = 1; + io2.t2fnext.in.resume_key = 0; + io2.t2fnext.in.flags = 0; + io2.t2fnext.in.last_name = + result.list[result.count-1].both_directory_info.name.s; + + status = smb_raw_search_next(cli->tree, tctx, + &io2, &result, multiple_search_callback); + CHECK_STATUS(status, NT_STATUS_OK); + CHECK_VALUE(result.count, 2); +done: + smb_raw_exit(cli->session); + smbcli_deltree(cli->tree, BASEDIR); + + return ret; +} /* basic testing of all RAW_SEARCH_* calls using a single file @@ -1392,6 +1466,7 @@ struct torture_suite *torture_raw_search(TALLOC_CTX *mem_ctx) torture_suite_add_1smb_test(suite, "many dirs", test_many_dirs); torture_suite_add_1smb_test(suite, "os2 delete", test_os2_delete); torture_suite_add_1smb_test(suite, "ea list", test_ea_list); + torture_suite_add_1smb_test(suite, "max count", test_max_count); return suite; } |