Module: wine Branch: master Commit: cc62cdc1fd025c0c6f728ee82502315f9e8a05e8 URL: https://gitlab.winehq.org/wine/wine/-/commit/cc62cdc1fd025c0c6f728ee82502315...
Author: Piotr Caban piotr@codeweavers.com Date: Thu Mar 21 14:54:13 2024 +0100
advapi32/tests: Test if modifications are saved in RegUnLoadKey.
---
dlls/advapi32/tests/registry.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c index f85c73ed4f2..2407eddd813 100644 --- a/dlls/advapi32/tests/registry.c +++ b/dlls/advapi32/tests/registry.c @@ -1575,11 +1575,11 @@ static void delete_dir(const char *path)
static void test_reg_load_key(void) { - char saved_key[2 * MAX_PATH], *p; + char saved_key[2 * MAX_PATH], buf[16], *p; UNICODE_STRING key_name; OBJECT_ATTRIBUTES attr; NTSTATUS status; - DWORD ret; + DWORD ret, size; HKEY key;
if (!set_privileges(SE_RESTORE_NAME, TRUE) || @@ -1603,6 +1603,9 @@ static void test_reg_load_key(void) ret = RegOpenKeyA(HKEY_LOCAL_MACHINE, "Test", &key); ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", ret);
+ ret = RegSetValueExA(key, "test", 0, REG_SZ, (BYTE *)"value", 6); + ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", ret); + /* try to unload though the key handle is live */ pRtlInitUnicodeString(&key_name, L"\REGISTRY\Machine\Test"); InitializeObjectAttributes(&attr, &key_name, OBJ_CASE_INSENSITIVE, NULL, NULL); @@ -1614,6 +1617,27 @@ static void test_reg_load_key(void) ret = RegUnLoadKeyA(HKEY_LOCAL_MACHINE, "Test"); ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", ret);
+ /* check if modifications are saved */ + ret = RegLoadKeyA(HKEY_LOCAL_MACHINE, "Test", saved_key); + ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", ret); + + ret = RegOpenKeyA(HKEY_LOCAL_MACHINE, "Test", &key); + ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", ret); + + size = sizeof(buf); + ret = RegGetValueA(key, NULL, "test", RRF_RT_REG_SZ, NULL, buf, &size); + todo_wine ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", ret); + if (ret == ERROR_SUCCESS) + { + ok(size == 6, "size = %ld\n", size); + ok(!strcmp(buf, "value"), "buf = %s\n", buf); + } + + RegCloseKey(key); + + ret = RegUnLoadKeyA(HKEY_LOCAL_MACHINE, "Test"); + ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", ret); + pRtlInitUnicodeString(&key_name, L"\REGISTRY\User\.Default"); InitializeObjectAttributes(&attr, &key_name, OBJ_CASE_INSENSITIVE, NULL, NULL); status = pNtUnloadKey(&attr);