1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

test_vfs_gpfs: Add test for file id generation

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Christof Schmitt <cs@samba.org>
Autobuild-Date(master): Tue Sep  8 22:57:03 UTC 2020 on sn-devel-184
This commit is contained in:
Christof Schmitt 2020-08-18 14:54:09 -07:00
parent c94ea50b24
commit b65fbade02

View File

@ -82,6 +82,59 @@ static void test_dosmode_to_gpfs_winattrs(void **state)
GPFS_WINATTR_SYSTEM);
}
static void test_gpfs_get_file_id(void **state)
{
struct gpfs_iattr64 iattr;
uint64_t fileid1, fileid2;
NTSTATUS status;
/*
* Ensure that the generated fileid only depends on the
* ia_inode, ia_gen and ia_modsnapid fields in struct
* gpfs_iattr64 and any changes to these fields result in a
* different file id.
*/
memset(&iattr, 1, sizeof(iattr));
iattr.ia_inode = 0x11;
iattr.ia_gen = 0x22;
iattr.ia_modsnapid = 0x33;
status = vfs_gpfs_get_file_id(&iattr, &fileid1);
assert_true(NT_STATUS_IS_OK(status));
memset(&iattr, 2, sizeof(iattr));
iattr.ia_inode = 0x11;
iattr.ia_gen = 0x22;
iattr.ia_modsnapid = 0x33;
status = vfs_gpfs_get_file_id(&iattr, &fileid2);
assert_true(NT_STATUS_IS_OK(status));
assert_int_equal(fileid1, fileid2);
iattr.ia_inode = 0x44;
iattr.ia_gen = 0x22;
iattr.ia_modsnapid = 0x33;
status = vfs_gpfs_get_file_id(&iattr, &fileid2);
assert_true(NT_STATUS_IS_OK(status));
assert_true(NT_STATUS_IS_OK(status));
assert_int_not_equal(fileid1, fileid2);
iattr.ia_inode = 0x11;
iattr.ia_gen = 0x44;
iattr.ia_modsnapid = 0x33;
status = vfs_gpfs_get_file_id(&iattr, &fileid2);
assert_true(NT_STATUS_IS_OK(status));
assert_true(NT_STATUS_IS_OK(status));
assert_int_not_equal(fileid1, fileid2);
iattr.ia_inode = 0x11;
iattr.ia_gen = 0x22;
iattr.ia_modsnapid = 0x44;
status = vfs_gpfs_get_file_id(&iattr, &fileid2);
assert_true(NT_STATUS_IS_OK(status));
assert_true(NT_STATUS_IS_OK(status));
assert_int_not_equal(fileid1, fileid2);
}
int main(int argc, char **argv)
{
const struct CMUnitTest tests[] = {
@ -89,6 +142,7 @@ int main(int argc, char **argv)
cmocka_unit_test(test_gpfs_lease_mapping),
cmocka_unit_test(test_gpfs_winattrs_to_dosmode),
cmocka_unit_test(test_dosmode_to_gpfs_winattrs),
cmocka_unit_test(test_gpfs_get_file_id),
};
cmocka_set_message_output(CM_OUTPUT_SUBUNIT);