version 2.0, 2005/02/11 10:54:42
|
version 2.7, 2005/02/26 04:24:51
|
|
|
/* | /* |
* Unit test suite for cabinet.dll - FDI functions | * Unit test suite for cabinet.dll - FDI functions |
* | * |
* Copyright 2004 Rizwan Kassim, Dan Kegel |
* Copyright 2004 Rizwan Kassim, Dan Kegel, Alexander Liber |
* | * |
* This library is free software; you can redistribute it and/or | * This library is free software; you can redistribute it and/or |
* modify it under the terms of the GNU Lesser General Public | * modify it under the terms of the GNU Lesser General Public |
|
|
*/ | */ |
| |
#include <stdlib.h> | #include <stdlib.h> |
|
#include <string.h> |
|
#include <sys/stat.h> |
| |
#ifndef STANDALONE | #ifndef STANDALONE |
#include <wine/test.h> | #include <wine/test.h> |
#define ok2 ok | #define ok2 ok |
#else | #else |
/* To build outside Wine tree, compile with cl -DSTANDALONE -D_X86_ cabinet_fdi.c FDI.lib |
/* To build outside Wine tree, compile with cl -DSTANDALONE -D_X86_ tvfs.c cabinet_fdi.c FDI.lib |
These are only called if standalone are used, defining ok and START_TEST, which would normally be declared in winetree */ | These are only called if standalone are used, defining ok and START_TEST, which would normally be declared in winetree */ |
#include <assert.h> | #include <assert.h> |
#include <stdio.h> | #include <stdio.h> |
|
|
#define todo_wine | #define todo_wine |
#endif | #endif |
| |
|
#define TVFS |
|
|
#include <winerror.h> | #include <winerror.h> |
#include <fdi.h> | #include <fdi.h> |
#include <fcntl.h> | #include <fcntl.h> |
|
#include "tvfs.h" |
|
#include "data.h" |
| |
/* Do malloc and free output debug messages? | /* Do malloc and free output debug messages? |
#define DEBUG_ALLOC | #define DEBUG_ALLOC |
*/ | */ |
| |
/* What is our "Fake" Filedescriptor? */ |
|
static int fakeFD = 22881; |
|
|
|
/* |
|
This hex data is the output of makecab.exe (Windows Cabinet SDK/bin) |
|
****** IS USING THE OUTPUT OF A NON LGPL program okay ****** |
|
|
|
The cab file is mirrored in the file system as simple.cab |
|
|
|
The 'test.txt' in the cab file contains the string 'So long, and thanks for all the fish.' |
|
*/ |
|
static unsigned char compressed_file[] = |
|
{0x4D,0x53,0x43,0x46,0x00,0x00,0x00,0x00,0x75,0x00, |
|
0x00,0x00,0x00,0x00,0x00,0x00,0x2C,0x00,0x00,0x00, |
|
0x00,0x00,0x00,0x00,0x03,0x01,0x01,0x00,0x01,0x00, |
|
0x00,0x00,0x39,0x30,0x00,0x00,0x45,0x00,0x00,0x00, |
|
0x01,0x00,0x01,0x00,0x26,0x00,0x00,0x00,0x00,0x00, |
|
0x00,0x00,0x00,0x00,0x4A,0x32,0xB2,0xBE,0x20,0x00, |
|
0x74,0x65,0x73,0x74,0x2E,0x74,0x78,0x74,0x00,0x9C, |
|
0x74,0xD0,0x75,0x28,0x00,0x26,0x00,0x43,0x4B,0x0B, |
|
0xCE,0x57,0xC8,0xC9,0xCF,0x4B,0xD7,0x51,0x48,0xCC, |
|
0x4B,0x51,0x28,0xC9,0x48,0xCC,0xCB,0x2E,0x56,0x48, |
|
0xCB,0x2F,0x52,0x48,0xCC,0xC9,0x01,0x72,0x53,0x15, |
|
0xD2,0x32,0x8B,0x33,0xF4,0xB8,0x00}; |
|
static int szcompressed_file = sizeof(compressed_file); |
|
|
|
/* |
|
Multiple File Cabs are included, as cabinet.dll supports multiple file archive types. |
|
The compressed file size had to be greater than 50k, cabarc restricts 'diskette spanning' to |
|
archives above 50k. |
|
The peculiar options were selected specifically to test cabinet.dll more throughly. |
|
|
|
complex_lzw.cab cabarc -m LZX:16 -pr -i 32356 N complex_lzw.cab amontillado.txt lgpl.txt gpl.txt midsummer\* |
|
complex_lzw2.cab cabarc -m LZX:17 -d 50000 -pr -i 32356 N complex_lzw*.cab amontillado.txt + lgpl.txt gpl.txt midsummer\* |
|
|
|
complex_zip.cab cabarc -m MSZIP -pr -i 32356 N complex_lzw.cab amontillado.txt lgpl.txt gpl.txt midsummer\* |
|
complex_zip2.cab cabarc -m MSZIP -d 50000 -pr -i 32356 N complex_zip*.cab amontillado.txt + lgpl.txt gpl.txt midsummer\* |
|
|
|
complex_none.cab cabarc -m NONE -pr -i 32356 N complex_none.cab amontillado.txt midsummer\act1* |
|
|
|
/* |
|
To do in FDI: -from wine/include/fdi.h |
|
FDICreate |
|
File Write -FNWRITE(hf, pv, cb) |
|
File Seek -FNSEEK(hf,dist,seektype) |
|
Error Structure |
|
FDICopy |
|
Notification function |
|
Decryption function |
|
FDIDestroy |
|
*/ |
|
|
|
#ifndef DEBUG_ALLOC | #ifndef DEBUG_ALLOC |
FNALLOC(final_alloc) { | FNALLOC(final_alloc) { |
return malloc(cb); | return malloc(cb); |
|
|
#endif | #endif |
| |
| |
/* |
|
Match i/o specs of _open, _read, _write, _close, and _lseek. |
|
*/ |
|
|
|
/* |
|
http://msdn.microsoft.com/library/en-us/vclib/html/_crt__open.2c_._wopen.asp |
|
_open I: const char *filename, int oflag, int pmode O: int (handler), -1 for err. |
|
DUMMY : FUNCTIONAL FAKE : FUNCTIONAL REAL : FUNCTIONAL |
|
*/ |
|
|
|
FNOPEN(dummy_open) { | FNOPEN(dummy_open) { |
printf(" FNOPEN (dummy) just called with %d, %d, %d\n",pszFile, oflag, pmode); | printf(" FNOPEN (dummy) just called with %d, %d, %d\n",pszFile, oflag, pmode); |
return 0; | return 0; |
} | } |
| |
FNOPEN(fake_open) { |
FNREAD(dummy_read) { |
printf(" FNOPEN (fake) just called with %d, %d, %d\n",pszFile, oflag, pmode); |
printf(" FNREAD (dummy) just called with %d, %d, %d\n",hf, pv, cb); |
printf(" Returning %d as file descriptor\n",fakeFD); |
return 0; |
return 12; |
|
} | } |
| |
FNOPEN(real_open) { |
FNCLOSE(dummy_close) { |
int handler = _open(pszFile,oflag,pmode); |
printf(" FNCLOSE (dummy) just called with %d - returning %d\n",hf,0); |
printf(" FNOPEN (real) just called with %s, %d, %d\n",pszFile, oflag, pmode); |
return 0; |
printf(" FNOPEN (real) returning handler (%d)\n",handler); |
|
return handler; |
|
} | } |
| |
/* |
FNWRITE(dummy_write) { |
http://msdn.microsoft.com/library/en-us/vclib/html/_CRT__read.asp |
printf(" FNWRITE just called with %d, %d, %d\n",hf, pv, cb); |
_read I: int fd, void *buffer, unsigned int count O: int (szBuffer) |
return 0; |
DUMMY : FUNCTIONAL FAKE : FUNCTIONAL, INCOMPLETE REAL : FUNCTIONAL |
} |
*/ |
|
| |
FNREAD(dummy_read) { |
FNSEEK(dummy_seek) { |
printf(" FNREAD (dummy) just called with %d, %d, %d\n",hf, pv, cb); |
printf(" FNSEEK just called with %d, %d, %d\n",hf, dist, seektype); |
return 0; | return 0; |
} | } |
| |
/* Doesn't keep virtual file location pointer */ |
FNFDINOTIFY(dummy_notification){ |
FNREAD(fake_read) { |
printf(" FNFDINOTIFY just called with %d, %d \n",fdint,pfdin); |
printf(" FNREAD (fake) just called with %d, %d, %d\n",hf, pv, cb); |
return 0; |
if (hf == fakeFD) { |
|
printf (" Called with fake file descriptor, populating buffer and size (%d)\n",cb); |
|
memcpy (pv, compressed_file ,cb); |
|
} | } |
else { |
|
printf (" FNREAD (fake) was called with the unknown file handler. Failed!\n",hf); |
FNFDINOTIFY(notification_function) |
|
{ |
|
printf(" FNFDINOTIFY real just called with %d, %d \n",fdint,pfdin); |
|
switch (fdint) |
|
{ |
|
case fdintCABINET_INFO: |
|
{ |
|
printf("fdintCABINET_INFO\n"); |
|
return 0; |
} | } |
return cb; |
case fdintPARTIAL_FILE: |
|
{ |
|
printf("dintPARTIAL_FILE\n"); |
|
return 0; |
} | } |
|
case fdintCOPY_FILE: |
|
{ |
|
int fih = 0; |
|
char target[256]; |
| |
FNREAD(real_read) { |
printf("fdintCOPY_FILE\n"); |
int szBuffer = _read(hf,pv,cb); |
printf(" file name: %s\n", pfdin->psz1); |
printf(" FNREAD (read) just called with %d, %d, %d\n",hf, pv, cb); |
sprintf(target, "./%s",pfdin->psz1); |
printf(" FNREAD (read) returning size (%d)\n",szBuffer); |
printf("%s\n",target); |
return szBuffer; |
#ifdef TVFS |
|
fih = tvfs_open (target, |
|
_O_BINARY | _O_CREAT | _O_WRONLY | _O_SEQUENTIAL, |
|
_S_IREAD | _S_IWRITE |
|
); |
|
return fih; |
|
#else |
|
fih = real_open (target, |
|
_O_BINARY | _O_CREAT | _O_WRONLY | _O_SEQUENTIAL, |
|
_S_IREAD | _S_IWRITE |
|
); |
|
return fih; |
|
#endif |
} | } |
|
case fdintCLOSE_FILE_INFO: |
|
{ |
|
char filebuf[256]; |
|
int result; |
| |
/* |
|
http://msdn.microsoft.com/library/en-us/vclib/html/_CRT__close.asp |
|
_close I: int fd O: int (0=success 1=failure) |
|
DUMMY : FUNCTIONAL FAKE : FUNCTIONAL REAL : FUNCTIONAL |
|
*/ |
|
| |
FNCLOSE(dummy_close) { |
printf("Testing direct file compare and lseek of %s\n", name_simple_txt); |
printf(" FNCLOSE (dummy) just called with %d - returning %d\n",hf,0); |
printf("Reading and comparing file\n"); |
|
result = tvfs_read(7, filebuf, size_simple_txt); |
|
result = tvfs_compare( filebuf , file_simple_txt, size_simple_txt); |
|
if (result) |
|
printf ("File compare failed!\n"); |
|
|
return 0; | return 0; |
} | } |
|
case fdintNEXT_CABINET: |
|
{ |
| |
FNCLOSE(fake_close) { |
printf("fdintNEXT_CABINET\n"); |
printf(" FNCLOSE (fake) just called with %d - returning %d\n",hf,0); |
return 0; |
|
} |
|
case fdintENUMERATE: |
|
{ |
|
printf("fdintENUMERATE\n"); |
|
return 0; |
|
} |
|
} |
return 0; | return 0; |
} | } |
| |
|
static void printCabInfo(FDICABINETINFO cabinfo){ |
|
printf(" Cabinet Data : cbC %d cF %d cFi %d si %d iC %d fr %d hp %d hn %d\n", |
|
cabinfo.cbCabinet, |
|
cabinfo.cFolders , |
|
cabinfo.cFiles , |
|
cabinfo.setID, |
|
cabinfo.iCabinet, |
|
cabinfo.fReserve , |
|
cabinfo.hasprev , |
|
cabinfo.hasnext ); |
|
} |
|
#ifndef TVFS |
|
FNREAD(real_read) { |
|
int szBuffer = _read(hf,pv,cb); |
|
printf(" FNREAD (read) just called with %d, %d, %d\n",hf, pv, cb); |
|
printf(" FNREAD (read) returning size (%d)\n",szBuffer); |
|
return szBuffer; |
|
} |
FNCLOSE(real_close) { | FNCLOSE(real_close) { |
int closevalue = _close(hf); | int closevalue = _close(hf); |
printf(" FNCLOSE (real) just called with %d - returning %d\n",hf,closevalue); | printf(" FNCLOSE (real) just called with %d - returning %d\n",hf,closevalue); |
return closevalue; | return closevalue; |
} | } |
| |
|
FNWRITE(real_write) { |
|
int write_value = _write(hf, pv, cb); |
|
printf(" FNWRITE just called with %d, %d, %d - returning %d\n",hf, pv, cb, write_value); |
|
return write_value; |
FNWRITE(dummy_write) { |
|
printf(" FNWRITE just called with %d, %d, %d\n",hf, pv, cb); |
|
return 0; |
|
} | } |
| |
FNSEEK(dummy_seek) { |
FNSEEK(real_seek) { |
printf(" FNSEEK just called with %d, %d, %d\n",hf, dist, seektype); |
long lseek_value = _lseek(hf, dist, seektype); |
return 0; |
printf(" FNSEEK just called with %d, %d, %d - returning %d\n",hf, dist, seektype,lseek_value); |
|
return lseek_value; |
} | } |
| |
|
FNOPEN(real_open) { |
|
int handler = _open(pszFile,oflag,pmode); |
|
printf(" FNOPEN (real) just called with %s, %d, %d\n",pszFile, oflag, pmode); |
|
printf(" FNOPEN (real) returning handler (%d)\n",handler); |
|
return handler; |
|
} |
|
#endif |
| |
|
static void CheckCabInfo(char * cabname, |
HFDI hfdi_unknown_dummy, hfdi_unknown_fake,hfdi_unknown_real; |
FDICABINETINFO cabinfo, |
|
long TcbCabinet, |
|
USHORT TcFolders, |
|
USHORT TcFiles, |
|
USHORT TsetID, |
|
USHORT TiCabinet, |
|
BOOL TfReserve, |
|
BOOL Thasprev, |
|
BOOL Thasnext){ |
|
ok2 ( cabinfo.cbCabinet == TcbCabinet, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n", cabname); |
|
ok2 ( cabinfo.cFolders == TcFolders, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n", cabname); |
|
ok2 ( cabinfo.cFiles == TcFiles, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n", cabname); |
|
ok2 ( cabinfo.setID == TsetID, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n", cabname); |
|
ok2 ( cabinfo.iCabinet == TiCabinet, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n", cabname); |
|
ok2 ( cabinfo.fReserve == TfReserve, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n", cabname); |
|
ok2 ( cabinfo.hasprev == Thasprev, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n", cabname); |
|
ok2 ( cabinfo.hasnext == Thasnext, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n", cabname); |
|
} |
|
HFDI hfdi_unknown_dummy, hfdi_unknown_tvfs; |
/* yes its global and ugly */ | /* yes its global and ugly */ |
| |
/* Is CPU386 or Unknown more commonly used? */ | /* Is CPU386 or Unknown more commonly used? */ |
|
|
); | ); |
ok(hfdi_unknown_dummy != NULL,"FDICreate (CPU = unknown) (functions=dummy) failed!\n"); | ok(hfdi_unknown_dummy != NULL,"FDICreate (CPU = unknown) (functions=dummy) failed!\n"); |
| |
hfdi_unknown_fake = FDICreate( |
hfdi_unknown_tvfs = FDICreate( |
final_alloc, |
|
final_free, |
|
fake_open, |
|
fake_read, |
|
dummy_write, |
|
dummy_close, |
|
dummy_seek, |
|
cpuUNKNOWN, |
|
&error_structure |
|
); |
|
ok(hfdi_unknown_fake != NULL,"FDICreate (CPU = unknown) (functions=fake) failed!\n"); |
|
|
|
hfdi_unknown_real = FDICreate( |
|
final_alloc, | final_alloc, |
final_free, | final_free, |
real_open, |
#ifdef TVFS |
real_read, |
tvfs_open, tvfs_read, tvfs_write, tvfs_close, tvfs_lseek, |
dummy_write, |
#else |
real_close, |
real_open, real_read, real_write, real_close,real_seek, |
dummy_seek, |
#endif |
cpuUNKNOWN, | cpuUNKNOWN, |
&error_structure | &error_structure |
); | ); |
ok(hfdi_unknown_real != NULL,"FDICreate (CPU = unknown) (functions=real) failed!\n"); |
ok(hfdi_unknown_tvfs != NULL,"FDICreate (CPU = unknown) (functions=tvfs) failed!\n"); |
| |
printf("Ending TestCreate()\n"); | printf("Ending TestCreate()\n"); |
} | } |
| |
static void TestInfo(void) { | static void TestInfo(void) { |
/* Noticed Behavior : |
#ifdef TVFS |
FDIIsCabinet does not open the file on its own, it requires a file open/close to be done externally. |
int fd; |
WHY? |
|
The only functions in HFDI that FDIIsCabinet directly accesses is FNREAD |
|
Important cases to check : |
|
If the filedescriptor == ERR, does it FAIL? (dummy_read) |
|
If the filedescriptor == NOTCABINET, does it FAIL? (fake_read, real_read) |
|
If the filedescriptor == CABINET, does it SUCCEED? (fake_read, real_read) |
|
If the filedescriptor == CABINET, does it populate FDICABINETINFO? (fake_read, real_read) |
|
*/ |
|
| |
int realfd; |
|
int sizer; |
|
FDICABINETINFO fdi_cabinfo_dummy, fdi_cabinfo_simple, fdi_cabinfo_complex; | FDICABINETINFO fdi_cabinfo_dummy, fdi_cabinfo_simple, fdi_cabinfo_complex; |
| |
printf("Starting TestInfo()\n"); | printf("Starting TestInfo()\n"); |
|
|
ok ( FDIIsCabinet( hfdi_unknown_dummy, -1, &fdi_cabinfo_dummy) == FALSE, | ok ( FDIIsCabinet( hfdi_unknown_dummy, -1, &fdi_cabinfo_dummy) == FALSE, |
"FDIIsCabinet (File = Error) failed!\n"); | "FDIIsCabinet (File = Error) failed!\n"); |
| |
/* TEST : Fake filehandle associated, memory manually copied, should return TRUE */ |
|
ok ( FDIIsCabinet( hfdi_unknown_fake, fakeFD, &fdi_cabinfo_simple) == TRUE, |
|
"FDIIsCabinet (FakeFile = Cabinet) failed!\n"); |
|
|
|
ok ( fdi_cabinfo_simple.cbCabinet == 117, "FDIIsCabinet,cabinfo (FakeFile = Cabinet) data did not match! Failed!\n"); |
|
ok ( fdi_cabinfo_simple.cFolders == 1, "FDIIsCabinet,cabinfo (FakeFile = Cabinet) data did not match! Failed!\n"); |
|
ok ( fdi_cabinfo_simple.cFiles == 1, "FDIIsCabinet,cabinfo (FakeFile = Cabinet) data did not match! Failed!\n"); |
|
ok ( fdi_cabinfo_simple.setID == 12345, "FDIIsCabinet,cabinfo (FakeFile = Cabinet) data did not match! Failed!\n"); |
|
ok ( fdi_cabinfo_simple.iCabinet == 0, "FDIIsCabinet,cabinfo (FakeFile = Cabinet) data did not match! Failed!\n"); |
|
ok ( fdi_cabinfo_simple.fReserve == 0, "FDIIsCabinet,cabinfo (FakeFile = Cabinet) data did not match! Failed!\n"); |
|
ok ( fdi_cabinfo_simple.hasprev == 0, "FDIIsCabinet,cabinfo (FakeFile = Cabinet) data did not match! Failed!\n"); |
|
ok ( fdi_cabinfo_simple.hasnext == 0, "FDIIsCabinet,cabinfo (FakeFile = Cabinet) data did not match! Failed!\n"); |
|
|
|
|
|
/* simply this with macros? |
|
yes, make one macro with inputs (cabname, testname, [expected values] ) --- using lambda notation |
|
add checks for cabinfo data! |
|
Is it ok to reuse the same hfdi_unknown_real ? */ |
|
|
|
/* TEST : Opened filehandle associated, corrupted cab loaded, should return FALSE */ |
|
/* We can see that the Windows implementation only reads the first 36 bytes - what if we corrupted a CAB after 36 bytes?*/ |
|
|
|
realfd = real_open( "broken.cab" , _O_BINARY | _O_RDONLY | _O_SEQUENTIAL, 0); |
|
|
|
ok ( FDIIsCabinet( hfdi_unknown_real, realfd, &fdi_cabinfo_complex) == FALSE, |
|
"FDIIsCabinet (File = Bad-Cabinet) broken.cab failed!\n"); |
|
real_close(realfd); |
|
|
|
realfd = real_open( "cabinet_fdi.c" , _O_BINARY | _O_RDONLY | _O_SEQUENTIAL, 0); |
|
|
|
ok ( FDIIsCabinet( hfdi_unknown_real, realfd, &fdi_cabinfo_complex) == FALSE, |
|
"FDIIsCabinet (File = Non-Cabinet) cabinet_fdi.c failed!\n"); |
|
real_close(realfd); |
|
|
|
|
|
/* TEST : Opened filehandle associated, valid cab loaded, should return TRUE */ |
|
realfd = real_open( "complex_lzw.cab" , _O_BINARY | _O_RDONLY | _O_SEQUENTIAL, 0); |
|
|
|
ok ( FDIIsCabinet( hfdi_unknown_real, realfd, &fdi_cabinfo_complex) == TRUE, |
|
"FDIIsCabinet (File = Cabinet) complex_lzw.cab failed!\n"); |
|
real_close(realfd); |
|
|
|
printf("Cabinet Data : cbC %d cF %d cFi %d si %d iC %d fr %b hp %d hn %d\n", |
|
fdi_cabinfo_complex.cbCabinet, |
|
fdi_cabinfo_complex.cFolders , |
|
fdi_cabinfo_complex.cFiles , |
|
fdi_cabinfo_complex.setID, |
|
fdi_cabinfo_complex.iCabinet, |
|
fdi_cabinfo_complex.fReserve , |
|
fdi_cabinfo_complex.hasprev , |
|
fdi_cabinfo_complex.hasnext ); |
|
|
|
realfd = real_open( "complex_lzw2.cab" , _O_BINARY | _O_RDONLY | _O_SEQUENTIAL, 0); |
|
|
|
ok ( FDIIsCabinet( hfdi_unknown_real, realfd, &fdi_cabinfo_complex) == TRUE, |
|
"FDIIsCabinet (File = Cabinet) complex_lzw2.cab failed!\n"); |
|
real_close(realfd); |
|
|
|
printf("Cabinet Data : cbC %d cF %d cFi %d si %d iC %d fr %b hp %d hn %d\n", |
|
fdi_cabinfo_complex.cbCabinet, |
|
fdi_cabinfo_complex.cFolders , |
|
fdi_cabinfo_complex.cFiles , |
|
fdi_cabinfo_complex.setID, |
|
fdi_cabinfo_complex.iCabinet, |
|
fdi_cabinfo_complex.fReserve , |
|
fdi_cabinfo_complex.hasprev , |
|
fdi_cabinfo_complex.hasnext ); |
|
|
|
realfd = real_open( "complex_zip.cab" , _O_BINARY | _O_RDONLY | _O_SEQUENTIAL, 0); |
|
|
|
ok ( FDIIsCabinet( hfdi_unknown_real, realfd, &fdi_cabinfo_complex) == TRUE, |
|
"FDIIsCabinet (File = Cabinet) complex_zip.cab failed!\n"); |
|
real_close(realfd); |
|
|
|
printf("Cabinet Data : cbC %d cF %d cFi %d si %d iC %d fr %b hp %d hn %d\n", |
|
fdi_cabinfo_complex.cbCabinet, |
|
fdi_cabinfo_complex.cFolders , |
|
fdi_cabinfo_complex.cFiles , |
|
fdi_cabinfo_complex.setID, |
|
fdi_cabinfo_complex.iCabinet, |
|
fdi_cabinfo_complex.fReserve , |
|
fdi_cabinfo_complex.hasprev , |
|
fdi_cabinfo_complex.hasnext ); |
|
|
|
realfd = real_open( "complex_zip2.cab" , _O_BINARY | _O_RDONLY | _O_SEQUENTIAL, 0); |
|
|
|
ok ( FDIIsCabinet( hfdi_unknown_real, realfd, &fdi_cabinfo_complex) == TRUE, |
|
"FDIIsCabinet (File = Cabinet) complex_zip2.cab failed!\n"); |
|
real_close(realfd); |
|
|
|
printf("Cabinet Data : cbC %d cF %d cFi %d si %d iC %d fr %b hp %d hn %d\n", |
|
fdi_cabinfo_complex.cbCabinet, |
|
fdi_cabinfo_complex.cFolders , |
|
fdi_cabinfo_complex.cFiles , |
|
fdi_cabinfo_complex.setID, |
|
fdi_cabinfo_complex.iCabinet, |
|
fdi_cabinfo_complex.fReserve , |
|
fdi_cabinfo_complex.hasprev , |
|
fdi_cabinfo_complex.hasnext ); |
|
|
|
realfd = real_open( "complex_none.cab" , _O_BINARY | _O_RDONLY | _O_SEQUENTIAL, 0); |
|
|
|
ok ( FDIIsCabinet( hfdi_unknown_real, realfd, &fdi_cabinfo_complex) == TRUE, |
|
"FDIIsCabinet (File = Cabinet) complex_zip.cab failed!\n"); |
|
real_close(realfd); |
|
|
|
printf("Cabinet Data : cbC %d cF %d cFi %d si %d iC %d fr %b hp %d hn %d\n", |
|
fdi_cabinfo_complex.cbCabinet, |
|
fdi_cabinfo_complex.cFolders , |
|
fdi_cabinfo_complex.cFiles , |
|
fdi_cabinfo_complex.setID, |
|
fdi_cabinfo_complex.iCabinet, |
|
fdi_cabinfo_complex.fReserve , |
|
fdi_cabinfo_complex.hasprev , |
|
fdi_cabinfo_complex.hasnext ); |
|
| |
|
tvfs_create( name_simple_cab, file_simple_cab, size_simple_cab); |
|
fd = tvfs_open( name_simple_cab, _O_BINARY, 0 ); |
|
|
|
ok( FDIIsCabinet( hfdi_unknown_tvfs, fd, &fdi_cabinfo_simple) == TRUE, |
|
"FDIIsCabinet (Virtual File = Simple.cab) failed!\n"); |
|
|
|
printCabInfo(fdi_cabinfo_simple); |
|
CheckCabInfo("simple.cab",fdi_cabinfo_simple,121,1,1,0,0,0,0,0); |
|
|
|
tvfs_close(fd); |
|
|
|
|
|
tvfs_create( name_complex_cab, file_complex_cab, size_complex_cab); |
|
fd = tvfs_open( name_complex_cab, _O_BINARY, 0 ); |
|
|
|
ok( FDIIsCabinet( hfdi_unknown_tvfs, fd, &fdi_cabinfo_complex) == TRUE, |
|
"FDIIsCabinet (Virtual File = Complex.cab) failed!\n"); |
|
|
|
printCabInfo(fdi_cabinfo_complex); |
|
CheckCabInfo("complex.cab",fdi_cabinfo_complex,12918,1,2,0,0,0,0,0); |
| |
|
tvfs_close(fd); |
|
|
|
printf("Ending TestInfo()\n"); |
|
#endif |
|
} |
|
|
|
static void TestCopy(void){ |
|
printf("Starting TestCopy()\n"); |
|
printf("---simple.cab\n"); |
|
FDICopy(hfdi_unknown_tvfs, |
|
"complex.cab", |
|
"", |
|
0, |
|
notification_function, |
|
NULL, |
|
NULL); |
|
|
|
printf("Ending TestCopy()\n"); |
} | } |
| |
static void TestDestroy(void) { | static void TestDestroy(void) { |
printf("Starting TestDestroy()\n"); | printf("Starting TestDestroy()\n"); |
/* Should return TRUE if given a valid hfdi, else FALSE (only due to context errors?) */ |
|
| |
ok(FDIDestroy(hfdi_unknown_dummy), "FDIDestroy (CPU = unknown) (functions=fake) failed!\n"); | ok(FDIDestroy(hfdi_unknown_dummy), "FDIDestroy (CPU = unknown) (functions=fake) failed!\n"); |
ok(FDIDestroy(hfdi_unknown_fake), "FDIDestroy (CPU = unknown) (functions=fake) failed!\n"); |
ok(FDIDestroy(hfdi_unknown_tvfs), "FDIDestroy (CPU = unknown) (functions=tvfs) failed!\n"); |
ok(FDIDestroy(hfdi_unknown_real), "FDIDestroy (CPU = unknown) (functions=real) failed!\n"); |
|
printf("Ending TestDestroy()\n"); | printf("Ending TestDestroy()\n"); |
|
|
} | } |
| |
START_TEST(paths) | START_TEST(paths) |
{ | { |
TestCreate(); | TestCreate(); |
TestInfo(); | TestInfo(); |
/* |
|
TestCopy(); | TestCopy(); |
*/ |
|
TestDestroy(); | TestDestroy(); |
|
tvfs_free(); |
} | } |