setupapi: Enable reuse of create_inf_file in tests.

This commit is contained in:
Hans Leidekker 2009-01-12 22:07:41 +01:00 committed by Alexandre Julliard
parent 66a7da71ee
commit b0f2bebc4c
1 changed files with 34 additions and 45 deletions

View File

@ -43,48 +43,37 @@ static void get_directories(void)
WIN_DIR[len-1] = 0;
}
static void create_inf_file(LPSTR filename)
static const char inf_data1[] =
"[Version]\n"
"Signature=\"$Chicago$\"\n"
"AdvancedINF=2.5\n"
"[SourceDisksNames]\n"
"2 = %SrcDiskName%, LANCOM\\LANtools\\lanconf.cab\n"
"[SourceDisksFiles]\n"
"lanconf.exe = 2\n"
"[DestinationDirs]\n"
"DefaultDestDir = 24, %DefaultDest%\n"
"[Strings]\n"
"LangDir = english\n"
"DefaultDest = LANCOM\n"
"SrcDiskName = \"LANCOM Software CD\"\n";
static const char inf_data2[] =
"[SourceFileInfo]\n"
"sp1qfe\\bitsinst.exe=250B3702C7CCD7C2F9E4DAA1555C933E,000600060A28062C,27136,SP1QFE\n"
"sp1qfe\\bitsprx2.dll=4EBEA67F4BB4EB402E725CA7CA2857AE,000600060A280621,7680,SP1QFE\n"
"sp1qfe\\bitsprx3.dll=C788A1D9330DA011EF25E95D3BC7BDE5,000600060A280621,7168,SP1QFE\n"
"sp1qfe\\qmgr.dll=696AC82FB290A03F205901442E0E9589,000600060A280621,361984,SP1QFE\n"
"sp1qfe\\qmgrprxy.dll=8B5848144829E1BC985EA4C3D8CA7E3F,000600060A280621,17408,SP1QFE\n"
"sp1qfe\\winhttp.dll=3EC6F518114606CA59D4160322077437,000500010A280615,331776,SP1QFE\n"
"sp1qfe\\xpob2res.dll=DB83156B9F496F20D1EA70E4ABEC0166,000500010A280622,158720,SP1QFE\n";
static void create_inf_file(LPSTR filename, const char *data, DWORD size)
{
DWORD dwNumberOfBytesWritten;
HANDLE hf = CreateFile(filename, GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
static const char data[] =
"[Version]\n"
"Signature=\"$Chicago$\"\n"
"AdvancedINF=2.5\n"
"[SourceDisksNames]\n"
"2 = %SrcDiskName%, LANCOM\\LANtools\\lanconf.cab\n"
"[SourceDisksFiles]\n"
"lanconf.exe = 2\n"
"[DestinationDirs]\n"
"DefaultDestDir = 24, %DefaultDest%\n"
"[Strings]\n"
"LangDir = english\n"
"DefaultDest = LANCOM\n"
"SrcDiskName = \"LANCOM Software CD\"\n";
WriteFile(hf, data, sizeof(data) - 1, &dwNumberOfBytesWritten, NULL);
CloseHandle(hf);
}
static void create_inf_file2(LPSTR filename)
{
DWORD dwNumberOfBytesWritten;
HANDLE hf = CreateFile(filename, GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
static const char data[] =
"[SourceFileInfo]\n"
"sp1qfe\\bitsinst.exe=250B3702C7CCD7C2F9E4DAA1555C933E,000600060A28062C,27136,SP1QFE\n"
"sp1qfe\\bitsprx2.dll=4EBEA67F4BB4EB402E725CA7CA2857AE,000600060A280621,7680,SP1QFE\n"
"sp1qfe\\bitsprx3.dll=C788A1D9330DA011EF25E95D3BC7BDE5,000600060A280621,7168,SP1QFE\n"
"sp1qfe\\qmgr.dll=696AC82FB290A03F205901442E0E9589,000600060A280621,361984,SP1QFE\n"
"sp1qfe\\qmgrprxy.dll=8B5848144829E1BC985EA4C3D8CA7E3F,000600060A280621,17408,SP1QFE\n"
"sp1qfe\\winhttp.dll=3EC6F518114606CA59D4160322077437,000500010A280615,331776,SP1QFE\n"
"sp1qfe\\xpob2res.dll=DB83156B9F496F20D1EA70E4ABEC0166,000500010A280622,158720,SP1QFE\n";
WriteFile(hf, data, sizeof(data) - 1, &dwNumberOfBytesWritten, NULL);
WriteFile(hf, data, size, &dwNumberOfBytesWritten, NULL);
CloseHandle(hf);
}
@ -165,7 +154,7 @@ static void test_SetupGetInfInformation(void)
ok(size == 0xdeadbeef, "Expected size to remain unchanged\n");
}
create_inf_file(inf_filename);
create_inf_file(inf_filename, inf_data1, sizeof(inf_data1) - 1);
/* try an invalid search flag */
size = 0xdeadbeef;
@ -237,7 +226,7 @@ static void test_SetupGetInfInformation(void)
lstrcpyA(inf_two, WIN_DIR);
lstrcatA(inf_two, "\\system32\\");
lstrcatA(inf_two, "test.inf");
create_inf_file(inf_two);
create_inf_file(inf_two, inf_data1, sizeof(inf_data1) - 1);
HeapFree(GetProcessHeap(), 0, info);
info = alloc_inf_info("test.inf", INFINFO_DEFAULT_SEARCH, &size);
@ -252,7 +241,7 @@ static void test_SetupGetInfInformation(void)
lstrcpyA(inf_one, WIN_DIR);
lstrcatA(inf_one, "\\inf\\");
lstrcatA(inf_one, "test.inf");
create_inf_file(inf_one);
create_inf_file(inf_one, inf_data1, sizeof(inf_data1) - 1);
HeapFree(GetProcessHeap(), 0, info);
info = alloc_inf_info("test.inf", INFINFO_DEFAULT_SEARCH, &size);
@ -289,7 +278,7 @@ static void test_SetupGetSourceFileLocation(void)
lstrcatA(inf_filename, "\\");
lstrcatA(inf_filename, "test.inf");
create_inf_file(inf_filename);
create_inf_file(inf_filename, inf_data1, sizeof(inf_data1) - 1);
hinf = SetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
ok(hinf != INVALID_HANDLE_VALUE, "could not open inf file\n");
@ -307,7 +296,7 @@ static void test_SetupGetSourceFileLocation(void)
SetupCloseInfFile(hinf);
DeleteFileA(inf_filename);
create_inf_file2(inf_filename);
create_inf_file(inf_filename, inf_data2, sizeof(inf_data2) - 1);
SetLastError(0xdeadbeef);
hinf = SetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
@ -336,7 +325,7 @@ static void test_SetupGetSourceInfo(void)
lstrcatA(inf_filename, "\\");
lstrcatA(inf_filename, "test.inf");
create_inf_file(inf_filename);
create_inf_file(inf_filename, inf_data1, sizeof(inf_data1) - 1);
hinf = SetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
ok(hinf != INVALID_HANDLE_VALUE, "could not open inf file\n");
@ -384,7 +373,7 @@ static void test_SetupGetTargetPath(void)
lstrcatA(inf_filename, "\\");
lstrcatA(inf_filename, "test.inf");
create_inf_file(inf_filename);
create_inf_file(inf_filename, inf_data1, sizeof(inf_data1) - 1);
hinf = SetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
ok(hinf != INVALID_HANDLE_VALUE, "could not open inf file\n");