-- v10: advapi32/tests: Add tests for RegLoadAppKey.
From: Santino Mazza smazza@codeweavers.com
Signed-off-by: Santino Mazza smazza@codeweavers.com --- dlls/advapi32/tests/registry.c | 78 +++++++++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-)
diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c index df56b0968ee..b31f20fb5d7 100644 --- a/dlls/advapi32/tests/registry.c +++ b/dlls/advapi32/tests/registry.c @@ -1600,7 +1600,82 @@ static void test_reg_unload_key(void) DeleteFileA("saved_key.LOG"); }
-/* tests that show that RegConnectRegistry and +/* Helper function to wait for a file blocked by the registry to be available */ +static void wait_file_available(char *path) +{ + int attempts = 0; + HANDLE file = NULL; + + while (((file = CreateFileA(path, GENERIC_READ, 0, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) + && attempts++ <= 10) + { + Sleep(200); + } + ok(attempts <= 10, "couldn't open file %s after 10 attempts error %ld.\n", path, GetLastError()); + CloseHandle(file); +} + +static void test_reg_load_app_key(void) +{ + DWORD ret, size; + char temppath[MAX_PATH], hivefilepath[MAX_PATH]; + const BYTE test_data[] = "Hello World"; + BYTE output[sizeof(test_data)]; + HKEY appkey = NULL; + + GetTempPathA(sizeof(temppath), temppath); + GetTempFileNameA(temppath, "key", 0, hivefilepath); + DeleteFileA(hivefilepath); + + if (!set_privileges(SE_BACKUP_NAME, TRUE) || + !set_privileges(SE_RESTORE_NAME, FALSE)) + { + win_skip("Failed to set SE_BACKUP_NAME privileges, skipping tests\n"); + return; + } + + ret = RegSaveKeyA(hkey_main, hivefilepath, NULL); + if (ret != ERROR_SUCCESS) + { + win_skip("Failed to save test key 0x%lx\n", ret); + return; + } + + set_privileges(SE_BACKUP_NAME, FALSE); + set_privileges(SE_RESTORE_NAME, FALSE); + + /* Test simple key load */ + /* Check if the changes are saved */ + ret = RegLoadAppKeyA(hivefilepath, &appkey, KEY_READ | KEY_WRITE, 0, 0); + ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", ret); + ok(appkey != NULL, "got a null key\n"); + + ret = RegSetValueExA(appkey, "testkey", 0, REG_BINARY, test_data, sizeof(test_data)); + todo_wine ok(ret == ERROR_SUCCESS, "couldn't set key value %lx\n", ret); + RegCloseKey(appkey); + + wait_file_available(hivefilepath); + + appkey = NULL; + ret = RegLoadAppKeyA(hivefilepath, &appkey, KEY_READ, 0, 0); + ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", ret); + ok(appkey != NULL, "got a null key\n"); + + size = sizeof(test_data); + memset(output, 0xff, sizeof(output)); + ret = RegGetValueA(appkey, NULL, "testkey", RRF_RT_REG_BINARY, NULL, output, &size); + todo_wine ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", ret); + ok(size == sizeof(test_data), "size doesn't match %ld != %ld\n", size, (DWORD)sizeof(test_data)); + todo_wine ok(memcmp(test_data, output, sizeof(test_data)), "output is not what expected\n"); + + RegCloseKey(appkey); + + wait_file_available(hivefilepath); + ok(DeleteFileA(hivefilepath), "couldn't delete hive file %ld\n", GetLastError()); +} + +/* tests that show that RegConnectRegistry and OpenSCManager accept computer names without the \ prefix (what MSDN says). */ static void test_regconnectregistry( void) @@ -4486,6 +4561,7 @@ START_TEST(registry) test_reg_save_key(); test_reg_load_key(); test_reg_unload_key(); + test_reg_load_app_key(); test_reg_copy_tree(); test_reg_delete_tree(); test_rw_order();
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=122895
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
advapi32: registry.c:1670: Test failed: output is not what expected
=== w7u_el (32 bit report) ===
advapi32: registry.c:1670: Test failed: output is not what expected
=== w8 (32 bit report) ===
advapi32: registry.c:1670: Test failed: output is not what expected
=== w864 (32 bit report) ===
advapi32: registry.c:1670: Test failed: output is not what expected
=== w1064v1507 (32 bit report) ===
advapi32: registry.c:1670: Test failed: output is not what expected
=== w1064v1809 (32 bit report) ===
advapi32: registry.c:1670: Test failed: output is not what expected
=== w1064 (32 bit report) ===
advapi32: registry.c:1670: Test failed: output is not what expected
=== w1064_tsign (32 bit report) ===
advapi32: registry.c:1670: Test failed: output is not what expected
=== w10pro64 (32 bit report) ===
advapi32: registry.c:1670: Test failed: output is not what expected
=== w864 (64 bit report) ===
advapi32: registry.c:1670: Test failed: output is not what expected
=== w1064v1507 (64 bit report) ===
advapi32: registry.c:1670: Test failed: output is not what expected
=== w1064v1809 (64 bit report) ===
advapi32: registry.c:1670: Test failed: output is not what expected
=== w1064 (64 bit report) ===
advapi32: registry.c:1670: Test failed: output is not what expected
=== w1064_2qxl (64 bit report) ===
advapi32: registry.c:1670: Test failed: output is not what expected
=== w1064_tsign (64 bit report) ===
advapi32: registry.c:1670: Test failed: output is not what expected
=== w10pro64 (64 bit report) ===
advapi32: registry.c:1670: Test failed: output is not what expected
=== w10pro64_en_AE_u8 (64 bit report) ===
advapi32: registry.c:1670: Test failed: output is not what expected
=== w10pro64_ar (64 bit report) ===
advapi32: registry.c:1670: Test failed: output is not what expected
=== w10pro64_ja (64 bit report) ===
advapi32: registry.c:1670: Test failed: output is not what expected
=== w10pro64_zh_CN (64 bit report) ===
advapi32: registry.c:1670: Test failed: output is not what expected
=== debian11 (32 bit report) ===
advapi32: registry.c:1670: Test succeeded inside todo block: output is not what expected
=== debian11 (32 bit Arabic:Morocco report) ===
advapi32: registry.c:1670: Test succeeded inside todo block: output is not what expected
=== debian11 (32 bit German report) ===
advapi32: registry.c:1670: Test succeeded inside todo block: output is not what expected
=== debian11 (32 bit French report) ===
advapi32: registry.c:1670: Test succeeded inside todo block: output is not what expected
=== debian11 (32 bit Hebrew:Israel report) ===
advapi32: registry.c:1670: Test succeeded inside todo block: output is not what expected
=== debian11 (32 bit Hindi:India report) ===
advapi32: registry.c:1670: Test succeeded inside todo block: output is not what expected
=== debian11 (32 bit Japanese:Japan report) ===
advapi32: registry.c:1670: Test succeeded inside todo block: output is not what expected
=== debian11 (32 bit Chinese:China report) ===
advapi32: registry.c:1670: Test succeeded inside todo block: output is not what expected
=== debian11 (32 bit WoW report) ===
advapi32: registry.c:1670: Test succeeded inside todo block: output is not what expected
=== debian11 (64 bit WoW report) ===
advapi32: registry.c:1670: Test succeeded inside todo block: output is not what expected