Commit bedd54c9 authored by Hugh McMaster's avatar Hugh McMaster Committed by Alexandre Julliard

regedit/tests: Comprehensively check for elevated privileges before starting tests.

Calls to regedit.exe on user accounts with standard privileges trigger a UAC prompt. Not responding to the prompt eventually causes a test timeout, so use registry API calls to determine if the tests are running with elevated privileges. Signed-off-by: 's avatarHugh McMaster <hugh.mcmaster@outlook.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent bfdb2e11
......@@ -3741,16 +3741,27 @@ static void test_export(void)
START_TEST(regedit)
{
if(!exec_import_str("REGEDIT4\r\n\r\n")){
win_skip("regedit not available, skipping regedit tests\n");
return;
}
HKEY hkey;
LONG err;
if (!run_regedit_exe("regedit.exe /s test.reg") && GetLastError() == ERROR_ELEVATION_REQUIRED)
/* Check if regedit.exe is running with elevated privileges */
err = RegDeleteKeyA(HKEY_CLASSES_ROOT, KEY_BASE);
if (err == ERROR_ACCESS_DENIED)
{
win_skip("User is a non-elevated admin; skipping regedit tests.\n");
return;
}
if (err == ERROR_FILE_NOT_FOUND)
{
if (RegCreateKeyExA(HKEY_CLASSES_ROOT, KEY_BASE, 0, NULL, REG_OPTION_NON_VOLATILE,
KEY_READ, NULL, &hkey, NULL))
{
win_skip("User is a non-elevated admin; skipping regedit tests.\n");
return;
}
RegCloseKey(hkey);
RegDeleteKeyA(HKEY_CLASSES_ROOT, KEY_BASE);
}
test_basic_import();
test_basic_import_unicode();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment