1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

s4: torture: libsmbclient: Add a torture test to ensure smbc_stat() returns ENOENT on a non-existent file.

Add knownfail.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15195

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
(cherry picked from commit 9eda432836)
This commit is contained in:
Jeremy Allison 2022-10-17 13:14:41 -07:00 committed by Jule Anger
parent f7a84cffe9
commit efa48817d3
2 changed files with 65 additions and 0 deletions

View File

@ -0,0 +1,2 @@
^samba4.libsmbclient.getatr.NT1.getatr\(nt4_dc_smb1_done\)
^samba4.libsmbclient.getatr.SMB3.getatr\(nt4_dc\)

View File

@ -1412,6 +1412,67 @@ static bool torture_libsmbclient_rename(struct torture_context *tctx)
return success;
}
static bool torture_libsmbclient_getatr(struct torture_context *tctx)
{
const char *smburl = torture_setting_string(tctx, "smburl", NULL);
SMBCCTX *ctx = NULL;
char *getatr_name = NULL;
struct stat st = {0};
bool ok;
int ret = 0;
int err = 0;
if (smburl == NULL) {
torture_fail(tctx,
"option --option=torture:smburl="
"smb://user:password@server missing\n");
}
ok = torture_libsmbclient_init_context(tctx, &ctx);
torture_assert(tctx, ok, "Failed to init context");
smbc_set_context(ctx);
getatr_name = talloc_asprintf(tctx,
"%s/noexist",
smburl);
if (getatr_name == NULL) {
torture_result(tctx,
TORTURE_FAIL,
__location__": %s",
"talloc fail\n");
return false;
}
/* Ensure the file doesn't exist. */
smbc_unlink(getatr_name);
/*
* smbc_stat() internally uses SMBC_getatr().
* Make sure doing getatr on a non-existent file gives
* an error of -1, errno = ENOENT.
*/
ret = smbc_stat(getatr_name, &st);
if (ret == -1) {
err = errno;
}
torture_assert_int_equal(tctx,
ret,
-1,
talloc_asprintf(tctx,
"smbc_stat on '%s' should "
"get -1, got %d\n",
getatr_name,
ret));
torture_assert_int_equal(tctx,
err,
ENOENT,
talloc_asprintf(tctx,
"smbc_stat on '%s' should "
"get errno = ENOENT, got %s\n",
getatr_name,
strerror(err)));
return true;
}
NTSTATUS torture_libsmbclient_init(TALLOC_CTX *ctx)
{
struct torture_suite *suite;
@ -1438,6 +1499,8 @@ NTSTATUS torture_libsmbclient_init(TALLOC_CTX *ctx)
torture_suite_add_simple_test(suite,
"rename",
torture_libsmbclient_rename);
torture_suite_add_simple_test(suite, "getatr",
torture_libsmbclient_getatr);
suite->description = talloc_strdup(suite, "libsmbclient interface tests");