-- v7: 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 | 79 +++++++++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 2 deletions(-)
diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c index df56b0968ee..6f386574e4d 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); + 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 != %d\n", size, sizeof(test_data)); + for (int i = 0; i < sizeof(test_data); ++i) + todo_wine ok(test_data[i] == output[i], "output is not what expected i=%d %d != %d\n", i, test_data[i], output[i]); + + RegCloseKey(appkey); + + wait_file_available(hivefilepath); + DeleteFileA(hivefilepath); +} + +/* 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(); @@ -4502,6 +4578,5 @@ START_TEST(registry)
/* cleanup */ delete_key( hkey_main ); - test_regconnectregistry(); }
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=122847
Your paranoid android.
=== debian11 (32 bit report) ===
advapi32: registry.c:1670: Test succeeded inside todo block: output is not what expected i=11 0 != 0
Report validation errors: advapi32:registry has unaccounted for failure messages
=== debian11 (32 bit Arabic:Morocco report) ===
advapi32: registry.c:1670: Test succeeded inside todo block: output is not what expected i=11 0 != 0
Report validation errors: advapi32:registry has unaccounted for failure messages
=== debian11 (32 bit German report) ===
advapi32: registry.c:1670: Test succeeded inside todo block: output is not what expected i=11 0 != 0
Report validation errors: advapi32:registry has unaccounted for failure messages
=== debian11 (32 bit French report) ===
advapi32: registry.c:1670: Test succeeded inside todo block: output is not what expected i=11 0 != 0
Report validation errors: advapi32:registry has unaccounted for failure messages
=== debian11 (32 bit Hebrew:Israel report) ===
advapi32: registry.c:1670: Test succeeded inside todo block: output is not what expected i=11 0 != 0
Report validation errors: advapi32:registry has unaccounted for failure messages
=== debian11 (32 bit Hindi:India report) ===
advapi32: registry.c:1670: Test succeeded inside todo block: output is not what expected i=11 0 != 0
Report validation errors: advapi32:registry has unaccounted for failure messages
=== debian11 (32 bit Japanese:Japan report) ===
advapi32: registry.c:1670: Test succeeded inside todo block: output is not what expected i=11 0 != 0
Report validation errors: advapi32:registry has unaccounted for failure messages
=== debian11 (32 bit Chinese:China report) ===
advapi32: registry.c:1670: Test succeeded inside todo block: output is not what expected i=11 0 != 0
Report validation errors: advapi32:registry has unaccounted for failure messages
=== debian11 (32 bit WoW report) ===
advapi32: registry.c:1670: Test succeeded inside todo block: output is not what expected i=11 0 != 0
Report validation errors: advapi32:registry has unaccounted for failure messages
=== debian11 (64 bit WoW report) ===
advapi32: registry.c:1670: Test succeeded inside todo block: output is not what expected i=11 0 != 0
Report validation errors: advapi32:registry has unaccounted for failure messages