Hans Leidekker : setupapi/tests: Skip SetupGetInfInformation tests if the user doesn't have admin rights.
Alexandre Julliard
julliard at winehq.org
Tue Dec 20 16:23:24 CST 2016
Module: wine
Branch: master
Commit: 0e3a0e13ef64f52e569e162ab8a76d488ed08707
URL: http://source.winehq.org/git/wine.git/?a=commit;h=0e3a0e13ef64f52e569e162ab8a76d488ed08707
Author: Hans Leidekker <hans at codeweavers.com>
Date: Tue Dec 20 12:08:34 2016 +0100
setupapi/tests: Skip SetupGetInfInformation tests if the user doesn't have admin rights.
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/setupapi/tests/query.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/dlls/setupapi/tests/query.c b/dlls/setupapi/tests/query.c
index 17c24bf..6b6d1bd 100644
--- a/dlls/setupapi/tests/query.c
+++ b/dlls/setupapi/tests/query.c
@@ -99,13 +99,16 @@ static const char inf_data6[] =
"[CopyAlways.Windir.Files]\n"
"WindowsCodecs.dll\n";
-static void create_inf_file(LPSTR filename, const char *data, DWORD size)
+static BOOL create_inf_file(LPSTR filename, const char *data, DWORD size)
{
+ BOOL ret;
DWORD dwNumberOfBytesWritten;
HANDLE hf = CreateFileA(filename, GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
- WriteFile(hf, data, size, &dwNumberOfBytesWritten, NULL);
+ if (hf == INVALID_HANDLE_VALUE) return FALSE;
+ ret = WriteFile(hf, data, size, &dwNumberOfBytesWritten, NULL);
CloseHandle(hf);
+ return ret;
}
static BOOL check_info_filename(PSP_INF_INFORMATION info, LPSTR test)
@@ -258,7 +261,13 @@ static void test_SetupGetInfInformation(void)
lstrcpyA(inf_two, WIN_DIR);
lstrcatA(inf_two, "\\system32\\");
lstrcatA(inf_two, "test.inf");
- create_inf_file(inf_two, inf_data1, sizeof(inf_data1) - 1);
+ ret = create_inf_file(inf_two, inf_data1, sizeof(inf_data1) - 1);
+ if (!ret && GetLastError() == ERROR_ACCESS_DENIED)
+ {
+ skip("need admin rights\n");
+ goto done;
+ }
+ ok(ret, "can't create inf file %u\n", GetLastError());
HeapFree(GetProcessHeap(), 0, info);
info = alloc_inf_info("test.inf", INFINFO_DEFAULT_SEARCH, &size);
@@ -291,8 +300,8 @@ static void test_SetupGetInfInformation(void)
ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
ok(check_info_filename(info, revfile), "Expected returned filename to be equal\n");
+done:
HeapFree(GetProcessHeap(), 0, info);
-
DeleteFileA(inf_filename);
DeleteFileA(inf_one);
DeleteFileA(inf_two);
More information about the wine-cvs
mailing list