[PATCH 2/2] advpack/tests: Dynamic bind to cabinet.dll
Detlef Riekenberg
wine.dev at web.de
Sun Aug 5 08:55:21 CDT 2012
cabinet.dll is not present on NT4 (below sp4)
See the test machines from francois.
example:
http://test.winehq.org/data/9177c088306723d10475839c2fcf56fd30e1b611/nt4_fg-winnt4-2sp
--
By by ... Detlef
---
dlls/advpack/tests/Makefile.in | 2 +-
dlls/advpack/tests/files.c | 43 ++++++++++++++++++++++++++++++++-------
2 files changed, 36 insertions(+), 9 deletions(-)
diff --git a/dlls/advpack/tests/Makefile.in b/dlls/advpack/tests/Makefile.in
index af9d2ee..1274f33 100644
--- a/dlls/advpack/tests/Makefile.in
+++ b/dlls/advpack/tests/Makefile.in
@@ -1,5 +1,5 @@
TESTDLL = advpack.dll
-IMPORTS = cabinet advapi32 advpack
+IMPORTS = advapi32 advpack
C_SRCS = \
advpack.c \
diff --git a/dlls/advpack/tests/files.c b/dlls/advpack/tests/files.c
index b29168a..790341b 100644
--- a/dlls/advpack/tests/files.c
+++ b/dlls/advpack/tests/files.c
@@ -34,6 +34,16 @@ static HRESULT (WINAPI *pAddDelBackupEntry)(LPCSTR, LPCSTR, LPCSTR, DWORD);
static HRESULT (WINAPI *pExtractFiles)(LPCSTR, LPCSTR, DWORD, LPCSTR, LPVOID, DWORD);
static HRESULT (WINAPI *pAdvInstallFile)(HWND,LPCSTR,LPCSTR,LPCSTR,LPCSTR,DWORD,DWORD);
+static HMODULE hcabinet;
+static HFCI (__cdecl *pFCICreate)(PERF, PFNFCIFILEPLACED, PFNFCIALLOC, PFNFCIFREE,
+ PFNFCIOPEN, PFNFCIREAD, PFNFCIWRITE, PFNFCICLOSE,
+ PFNFCISEEK, PFNFCIDELETE, PFNFCIGETTEMPFILE, PCCAB, void *);
+static BOOL (__cdecl *pFCIAddFile)(HFCI, char *, char *, BOOL, PFNFCIGETNEXTCABINET,
+ PFNFCISTATUS, PFNFCIGETOPENINFO, TCOMP);
+static BOOL (__cdecl *pFCIFlushCabinet)(HFCI, BOOL, PFNFCIGETNEXTCABINET, PFNFCISTATUS);
+static BOOL (__cdecl *pFCIDestroy)(HFCI hfci);
+
+
static CHAR CURR_DIR[MAX_PATH];
static void init_function_pointers(void)
@@ -46,6 +56,13 @@ static void init_function_pointers(void)
pExtractFiles = (void *)GetProcAddress(hAdvPack, "ExtractFiles");
pAdvInstallFile = (void*)GetProcAddress(hAdvPack, "AdvInstallFile");
}
+
+ hcabinet = LoadLibrary("cabinet.dll");
+ pFCICreate = (void*)GetProcAddress(hcabinet, "FCICreate");
+ pFCIAddFile = (void*)GetProcAddress(hcabinet, "FCIAddFile");
+ pFCIFlushCabinet = (void*)GetProcAddress(hcabinet, "FCIFlushCabinet");
+ pFCIDestroy = (void*)GetProcAddress(hcabinet, "FCIDestroy");
+
}
/* creates a file with the specified name for tests */
@@ -79,8 +96,6 @@ static void delete_test_files(void)
DeleteFileA("testdir\\d.txt");
RemoveDirectoryA("testdir");
RemoveDirectoryA("dest");
-
- DeleteFileA("extract.cab");
}
static BOOL check_ini_file_attr(LPSTR filename)
@@ -334,7 +349,7 @@ static void add_file(HFCI hfci, char *file)
lstrcatA(path, "\\");
lstrcatA(path, file);
- res = FCIAddFile(hfci, path, file, FALSE, get_next_cabinet, progress,
+ res = pFCIAddFile(hfci, path, file, FALSE, get_next_cabinet, progress,
get_open_info, tcompTYPE_MSZIP);
ok(res, "Expected FCIAddFile to succeed\n");
}
@@ -351,7 +366,7 @@ static void set_cab_parameters(PCCAB pCabParams)
lstrcpyA(pCabParams->szCab, "extract.cab");
}
-static void create_cab_file(void)
+static BOOL create_cab_file(void)
{
CCAB cabParams;
HFCI hfci;
@@ -362,9 +377,15 @@ static void create_cab_file(void)
testdir_d_txt[] = "testdir\\d.txt";
BOOL res;
+ if (!pFCICreate || !pFCIAddFile || !pFCIFlushCabinet || !pFCIDestroy)
+ {
+ win_skip("FCI* functions from cabinet.dll not available\n");
+ return FALSE;
+ }
+
set_cab_parameters(&cabParams);
- hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
+ hfci = pFCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
fci_read, fci_write, fci_close, fci_seek, fci_delete,
get_temp_file, &cabParams, NULL);
@@ -375,11 +396,13 @@ static void create_cab_file(void)
add_file(hfci, testdir_c_txt);
add_file(hfci, testdir_d_txt);
- res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
+ res = pFCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
ok(res, "Failed to flush the cabinet\n");
- res = FCIDestroy(hfci);
+ res = pFCIDestroy(hfci);
ok(res, "Failed to destroy the cabinet\n");
+
+ return TRUE;
}
static void test_ExtractFiles(void)
@@ -387,6 +410,9 @@ static void test_ExtractFiles(void)
HRESULT hr;
char destFolder[MAX_PATH];
+ if (!create_cab_file())
+ return;
+
lstrcpyA(destFolder, CURR_DIR);
lstrcatA(destFolder, "\\");
lstrcatA(destFolder, "dest");
@@ -468,6 +494,8 @@ static void test_ExtractFiles(void)
ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
+
+ DeleteFileA("extract.cab");
}
static void test_AdvInstallFile(void)
@@ -545,7 +573,6 @@ START_TEST(files)
CURR_DIR[len - 1] = 0;
create_test_files();
- create_cab_file();
test_AddDelBackupEntry();
test_ExtractFiles();
--
1.7.5.4
More information about the wine-patches
mailing list