mirror of
https://github.com/samba-team/samba.git
synced 2025-01-13 13:18:06 +03:00
r24569: Add two tests
A subtest for rename to check if case-changing renames work
A test that exposes the case insensitivity unix_convert bug
(This used to be commit 786706322a
)
This commit is contained in:
parent
7c9312a885
commit
7e43f973c4
@ -62,6 +62,8 @@ NTSTATUS torture_raw_init(void)
|
||||
torture_suite_add_simple_test(suite, "SAMBA3CLOSEERR", torture_samba3_closeerr);
|
||||
torture_suite_add_simple_test(suite, "SAMBA3CHECKFSP", torture_samba3_checkfsp);
|
||||
torture_suite_add_simple_test(suite, "SAMBA3BADPATH", torture_samba3_badpath);
|
||||
torture_suite_add_simple_test(suite, "SAMBA3CASEINSENSITIVE",
|
||||
torture_samba3_caseinsensitive);
|
||||
torture_suite_add_simple_test(suite, "SCAN-EAMAX", torture_max_eas);
|
||||
|
||||
suite->description = talloc_strdup(suite,
|
||||
|
@ -51,6 +51,8 @@ static BOOL test_mv(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
|
||||
int fnum = -1;
|
||||
const char *fname1 = BASEDIR "\\test1.txt";
|
||||
const char *fname2 = BASEDIR "\\test2.txt";
|
||||
const char *Fname1 = BASEDIR "\\Test1.txt";
|
||||
union smb_fileinfo finfo;
|
||||
union smb_open op;
|
||||
|
||||
printf("Testing SMBmv\n");
|
||||
@ -109,6 +111,24 @@ static BOOL test_mv(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
|
||||
status = smb_raw_rename(cli->tree, &io);
|
||||
CHECK_STATUS(status, NT_STATUS_OK);
|
||||
|
||||
printf("Trying case-changing rename\n");
|
||||
io.rename.in.pattern1 = fname1;
|
||||
io.rename.in.pattern2 = Fname1;
|
||||
status = smb_raw_rename(cli->tree, &io);
|
||||
CHECK_STATUS(status, NT_STATUS_OK);
|
||||
|
||||
finfo.generic.level = RAW_FILEINFO_ALL_INFO;
|
||||
finfo.all_info.in.file.path = fname1;
|
||||
status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo);
|
||||
CHECK_STATUS(status, NT_STATUS_OK);
|
||||
if (strcmp(finfo.all_info.out.fname.s, Fname1) != 0) {
|
||||
printf("(%s) Incorrect filename [%s] after case-changing "
|
||||
"rename, should be [%s]\n", __location__,
|
||||
finfo.all_info.out.fname.s, Fname1);
|
||||
ret = False;
|
||||
goto done;
|
||||
}
|
||||
|
||||
io.rename.in.pattern1 = fname1;
|
||||
io.rename.in.pattern2 = fname2;
|
||||
|
||||
|
@ -598,3 +598,70 @@ BOOL torture_samba3_badpath(struct torture_context *torture)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void count_fn(struct clilist_file_info *info, const char *name,
|
||||
void *private_data)
|
||||
{
|
||||
int *counter = (int *)private_data;
|
||||
*counter += 1;
|
||||
}
|
||||
|
||||
BOOL torture_samba3_caseinsensitive(struct torture_context *torture)
|
||||
{
|
||||
struct smbcli_state *cli;
|
||||
TALLOC_CTX *mem_ctx;
|
||||
NTSTATUS status;
|
||||
const char *dirname = "insensitive";
|
||||
const char *ucase_dirname = "InSeNsItIvE";
|
||||
const char *fname = "foo";
|
||||
char *fpath;
|
||||
int fnum;
|
||||
int counter = 0;
|
||||
BOOL ret = True;
|
||||
|
||||
if (!(mem_ctx = talloc_init("torture_samba3_caseinsensitive"))) {
|
||||
d_printf("talloc_init failed\n");
|
||||
return False;
|
||||
}
|
||||
|
||||
if (!torture_open_connection(&cli, 0)) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
smbcli_deltree(cli->tree, dirname);
|
||||
|
||||
status = smbcli_mkdir(cli->tree, dirname);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
d_printf("smbcli_mkdir failed: %s\n", nt_errstr(status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!(fpath = talloc_asprintf(mem_ctx, "%s\\%s", dirname, fname))) {
|
||||
goto done;
|
||||
}
|
||||
fnum = smbcli_open(cli->tree, fpath, O_RDWR | O_CREAT, DENY_NONE);
|
||||
if (fnum == -1) {
|
||||
d_printf("Could not create file %s: %s\n", fpath,
|
||||
smbcli_errstr(cli->tree));
|
||||
goto done;
|
||||
}
|
||||
smbcli_close(cli->tree, fnum);
|
||||
|
||||
smbcli_list(cli->tree, talloc_asprintf(
|
||||
mem_ctx, "%s\\*", ucase_dirname),
|
||||
FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_HIDDEN
|
||||
|FILE_ATTRIBUTE_SYSTEM,
|
||||
count_fn, (void *)&counter);
|
||||
|
||||
if (counter == 3) {
|
||||
ret = True;
|
||||
}
|
||||
else {
|
||||
d_fprintf(stderr, "expected 3 entries, got %d\n", counter);
|
||||
ret = False;
|
||||
}
|
||||
|
||||
done:
|
||||
talloc_free(mem_ctx);
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user