X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=tests%2Fwin32-tree-cmp.c;h=928722554ab190395ff26945d286e485a301ffea;hb=269f10a27c62027d48c0ba58f164d20e3bf3cf85;hp=3de18a0daae6930802a10b088030f34f3c9183b6;hpb=f3bfbdd5c07b4b096a2e8a35a03e9dfc6269e41f;p=wimlib diff --git a/tests/win32-tree-cmp.c b/tests/win32-tree-cmp.c index 3de18a0d..92872255 100644 --- a/tests/win32-tree-cmp.c +++ b/tests/win32-tree-cmp.c @@ -3,6 +3,7 @@ */ #include +#include #include #include #include @@ -476,18 +477,39 @@ err: win32_error(L"Can't read security descriptor of %ls", path); } +static wchar_t * +get_security_descriptor_string(PSECURITY_DESCRIPTOR desc) +{ + wchar_t *str; + ULONG len; + ConvertSecurityDescriptorToStringSecurityDescriptor(desc, + SDDL_REVISION_1, + OWNER_SECURITY_INFORMATION | + GROUP_SECURITY_INFORMATION | + DACL_SECURITY_INFORMATION | + SACL_SECURITY_INFORMATION, + &str, + NULL); + return str; +} + static void cmp_security(const wchar_t *path_1, const wchar_t *path_2) { void *descr_1, *descr_2; size_t len_1, len_2; + const wchar_t *str_1, *str_2; descr_1 = get_security(path_1, &len_1); descr_2 = get_security(path_2, &len_2); - if (len_1 != len_2 || memcmp(descr_1, descr_2, len_1)) - error(L"%ls and %ls do not have the same security descriptor", - path_1, path_2); + if (len_1 != len_2 || memcmp(descr_1, descr_2, len_1)) { + str_1 = get_security_descriptor_string(descr_1); + str_2 = get_security_descriptor_string(descr_2); + error(L"%ls and %ls do not have the same security " + "descriptor:\n\t%ls\nvs.\n\t%ls", + path_1, path_2, str_1, str_2); + } free(descr_1); free(descr_2); } @@ -515,13 +537,17 @@ tree_cmp(wchar_t *path_1, size_t path_1_len, wchar_t *path_2, size_t path_2_len) path_2, (unsigned)file_info_2.dwFileAttributes); } - size_1 = ((u64)file_info_1.nFileSizeHigh << 32) | - file_info_1.nFileSizeLow; - size_2 = ((u64)file_info_2.nFileSizeHigh << 32) | - file_info_2.nFileSizeLow; - if (size_1 != size_2) { - error(L"Size for %ls (%"PRIu64") differs from size for %ls (%"PRIu64")", - path_1, size_1, path_2, size_2); + attribs = file_info_1.dwFileAttributes; + + if (!(attribs & FILE_ATTRIBUTE_DIRECTORY)) { + size_1 = ((u64)file_info_1.nFileSizeHigh << 32) | + file_info_1.nFileSizeLow; + size_2 = ((u64)file_info_2.nFileSizeHigh << 32) | + file_info_2.nFileSizeLow; + if (size_1 != size_2) { + error(L"Size for %ls (%"PRIu64") differs from size for %ls (%"PRIu64")", + path_1, size_1, path_2, size_2); + } } if (file_info_1.nNumberOfLinks != file_info_2.nNumberOfLinks) { error(L"Number of links for %ls (%u) differs from number " @@ -547,8 +573,6 @@ tree_cmp(wchar_t *path_1, size_t path_1_len, wchar_t *path_2, size_t path_2_len) error(L"Last write times on %ls and %ls differ", path_1, path_2); - attribs = file_info_1.dwFileAttributes; - cmp_security(path_1, path_2); cmp_streams(path_1, path_1_len, path_2, path_2_len); if (attribs & FILE_ATTRIBUTE_REPARSE_POINT)