(file) Return to cabinet_fdi.c CVS log (file) (dir) Up to [RizwankCVS] / group3 / wine / dlls / cabinet / tests

Diff for /group3/wine/dlls/cabinet/tests/cabinet_fdi.c between version 2.5 and 2.15

version 2.5, 2005/02/25 10:35:55 version 2.15, 2005/03/18 00:28:59
Line 18 
Line 18 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */  */
  
   #include <stdio.h>
 #include <stdlib.h> #include <stdlib.h>
 #include <string.h> #include <string.h>
   #include <stdarg.h>
   #include <malloc.h>
   
   #include <stdarg.h>
   #include <stdio.h>
   
   #include "windef.h"
   #include "winbase.h"
   #include "winerror.h"
   #include "fdi.h"
   
   #ifndef WIN_ENV
   #include <msvcrt/fcntl.h>
   #include <msvcrt/sys/stat.h>
   #else
 #include <sys/stat.h> #include <sys/stat.h>
   #include <fcntl.h>
   #endif
   
   #define VERBOSE
   
   #include "tvfs.h"
   #include "simplecab.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_ tvfs.c cabinet_fdi.c FDI.lib  #include "standalone.h"
   These are only called if standalone are used, defining ok and START_TEST, which would normally be declared in winetree */  /* To build outside Wine tree, compile with cl -DSTANDALONE -D_X86_ -DWIN_ENV tvfs.c cabinet_fdi.c FDI.lib
 #include <assert.h>    standalone.h is used if standalone are used, defining ok and START_TEST, which would normally be declared in winetree */
 #include <stdio.h>  
 #define START_TEST(name) main(int argc, char **argv)  
 #define ok(condition, msg)       \  
         do { if(!(condition)) {  \  
                 fprintf(stderr,"failed at %d, msg:" msg "\n",__LINE__); \  
                 exit(1);         \  
         } } while(0)  
 #define ok2(condition, msg, arg) \  
         do { if(!(condition)) {  \  
                 fprintf(stderr,"failed at %d, msg:" msg "\n",__LINE__, arg); \  
                 exit(1);         \  
         } } while(0)  
 #define todo_wine  
 #endif #endif
  
 #include <winerror.h>  
 #include <fdi.h>  
 #include <fcntl.h>  
 #include "tvfs.h"  
 #include "data.h"  
   
 /* Do malloc and free output debug messages?  
 #define DEBUG_ALLOC  
 */  
   
 #ifndef DEBUG_ALLOC  
 FNALLOC(final_alloc) { FNALLOC(final_alloc) {
       trace("   FNALLOC just called with %d\n",cb);
         return malloc(cb);         return malloc(cb);
 } }
 FNFREE(final_free) { FNFREE(final_free) {
       trace("   FNFREE just called with %d\n",pv);
         free(pv);         free(pv);
         return;         return;
 } }
 #else  
 FNALLOC(final_alloc) {  
         printf("   FNALLOC just called with %d\n",cb);  
         return malloc(cb);  
 }  
 FNFREE(final_free) {  
         printf("   FNFREE just called with %d\n",pv);  
         free(pv);  
         return;  
 }  
 #endif  
   
   
 FNOPEN(dummy_open) {  
         printf("  FNOPEN (dummy) just called with %d, %d, %d\n",pszFile, oflag, pmode);  
         return 0;  
 }  
   
 FNREAD(dummy_read) {  
         printf("   FNREAD (dummy) just called with %d, %d, %d\n",hf, pv, cb);  
         return 0;  
 }  
   
 FNCLOSE(dummy_close) {  
         printf("   FNCLOSE (dummy) just called with %d - returning %d\n",hf,0);  
         return 0;  
 }  
   
 FNWRITE(dummy_write) {  
         printf("   FNWRITE just called with %d, %d, %d\n",hf, pv, cb);  
         return 0;  
 }  
   
 FNSEEK(dummy_seek) {  
         printf("   FNSEEK just called with %d, %d, %d\n",hf, dist, seektype);  
         return 0;  
 }  
   
 FNFDINOTIFY(dummy_notification){  
         printf("   FNFDINOTIFY just called with %d, %d \n",fdint,pfdin);  
         return 0;  
 }  
  
   /*Possible non trivial addition:
   Notify receives some information about the cab file(see FDI documentation).
   Since this info is different depending on the value of fdint, and Notify should
   be generic, it is not simple or nice to check this information.
   */
 FNFDINOTIFY(notification_function) FNFDINOTIFY(notification_function)
 { {
         printf("   FNFDINOTIFY real just called with %d, %d \n",fdint,pfdin);      trace("   FNFDINOTIFY real just called with %d, %d \n",fdint,pfdin);
         switch (fdint)         switch (fdint)
         {         {
                 case fdintCABINET_INFO:                 case fdintCABINET_INFO:
                 {                 {
                         printf("fdintCABINET_INFO\n");              trace(
                   "fdintCABINET_INFO:\n"
                   "-next cab name: %s\n"
                   "-next disk: %s\n"
                   "-path name: %s\n"
                   "-set ID: %d\n"
                   "-number in set: %d\n",
                   pfdin->psz1, pfdin->psz2, pfdin->psz3, pfdin->setID, pfdin->iCabinet
               );
                         return 0;                         return 0;
                 }                 }
                 case fdintPARTIAL_FILE:                 case fdintPARTIAL_FILE:
                 {                 {
                         printf("dintPARTIAL_FILE\n");              trace("dintPARTIAL_FILE\n");
   
                         return 0;                         return 0;
                 }                 }
                 case fdintCOPY_FILE:                 case fdintCOPY_FILE:
                 {                 {
                         int fih = 0;                         int fih = 0;
                         char target[256];                         char target[256];
               trace(
                         printf("fdintCOPY_FILE\n");                  "fdintCOPY_FILE:\n"
                         printf("  file name: %s\n",     pfdin->psz1);                  "-name: %s\n"
                   "-uncompressed size: %d\n"
                   "-date: %d\n"
                   "-time: %d\n"
                   "-attributes: %d\n"
                   "-file's folder index: %d\n",
                   pfdin->psz1, pfdin->cb, pfdin->date, pfdin->time, pfdin->attribs, pfdin->iFolder
               );
                         sprintf(target, "./%s",pfdin->psz1);                         sprintf(target, "./%s",pfdin->psz1);
                         printf("%s\n",target);              fih = tvfs_open (target,
   
                                 fih = 0;  
                                 /*real_open(  
                                         target,  
                                         _O_BINARY | _O_CREAT | _O_WRONLY | _O_SEQUENTIAL,                                         _O_BINARY | _O_CREAT | _O_WRONLY | _O_SEQUENTIAL,
                                         _S_IREAD | _S_IWRITE                                         _S_IREAD | _S_IWRITE
                                         );                                         );
 */  
                         return fih;                         return fih;
                 }                 }
                 case fdintCLOSE_FILE_INFO:                 case fdintCLOSE_FILE_INFO:
                 {                 {
   #ifdef VERBOSE
               trace(
                   "fdintCLOSE_FILE:\n"
                   "-name: %s\n"
                   "-handle: %d\n"
                   "-date: %d\n"
                   "-time: %d\n"
                   "-attributes: %d\n"
                   "-file's folder index: %d\n"
                   "-run: %d\n",
                   pfdin->psz1, pfdin->hf, pfdin->date, pfdin->time, pfdin->attribs, pfdin->iFolder, pfdin->cb
               );
   #endif
  
                         printf("fdintCLOSE_FILE_INFO\n");              tvfs_close(pfdin->hf);
                         return 0;              return TRUE;
                 }                 }
                 case fdintNEXT_CABINET:                 case fdintNEXT_CABINET:
                 {                 {
               trace("fdintNEXT_CABINET\n");
                         printf("fdintNEXT_CABINET\n");  
                         return 0;                         return 0;
                 }                 }
                 case fdintENUMERATE:                 case fdintENUMERATE:
                 {                 {
                                 printf("fdintENUMERATE\n");              trace("fdintENUMERATE\n");
                                 return 0;                                 return 0;
                 }                 }
         }         }
Line 161 
Line 148 
 } }
  
 static void printCabInfo(FDICABINETINFO  cabinfo){ 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",      trace("   Cabinet Data : cbC %d cF %d cFi %d si %d iC %d fr %d hp %d hn %d\n",
                 cabinfo.cbCabinet,                 cabinfo.cbCabinet,
                 cabinfo.cFolders ,                 cabinfo.cFolders ,
                 cabinfo.cFiles ,                 cabinfo.cFiles ,
Line 191 
Line 178 
         ok2 ( cabinfo.hasprev == Thasprev, "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);         ok2 ( cabinfo.hasnext == Thasnext, "FDIIsCabinet,cabinfo %s data did not match! Failed!\n", cabname);
                                                 }                                                 }
 HFDI hfdi_unknown_dummy, hfdi_unknown_tvfs;     /* TODO :  Message should contain variable values */
   
   static HFDI hfdi_simple;
 /* yes its global and ugly */ /* yes its global and ugly */
  
 /* Is CPU386 or Unknown more commonly used? */  
  
 static void TestCreate(void) { static void TestCreate(void) {
  
         ERF error_structure;         ERF error_structure;
  
         printf("Starting TestCreate()\n");      trace("Starting TestCreate()\n");
       /* Is CPU386 or Unknown more commonly used? */
         hfdi_unknown_dummy = FDICreate(      hfdi_simple = FDICreate(
                 final_alloc,                 final_alloc,
                 final_free,                 final_free,
                 dummy_open,          tvfs_open, tvfs_read, tvfs_write, tvfs_close, tvfs_lseek,
                 dummy_read,  
                 dummy_write,  
                 dummy_close,  
                 dummy_seek,  
                 cpuUNKNOWN,                 cpuUNKNOWN,
                 &error_structure                 &error_structure
         );         );
         ok(hfdi_unknown_dummy != NULL,"FDICreate (CPU = unknown) (functions=dummy) failed!\n");  
  
         hfdi_unknown_tvfs = FDICreate(      ok(hfdi_simple != NULL,"FDICreate (CPU = unknown) (functions=tvfs) failed!\n");
                 final_alloc,  
                 final_free,  
                 tvfs_open,  
                 tvfs_read,  
                 tvfs_write,  
                 tvfs_close,  
                 tvfs_lseek,  
                 cpuUNKNOWN,  
                 &error_structure  
         );  
         ok(hfdi_unknown_tvfs != NULL,"FDICreate (CPU = unknown) (functions=tvfs) failed!\n");  
  
         printf("Ending TestCreate()\n");      trace("Ending TestCreate()\n");
 } }
  
 static void TestInfo(void) { static void TestInfo(void) {
  
         int fd;         int fd;
  
         FDICABINETINFO  fdi_cabinfo_dummy, fdi_cabinfo_simple, fdi_cabinfo_complex;      FDICABINETINFO  fdi_cabinfo_simple;
   
         printf("Starting TestInfo()\n");  
   
         /* TEST : ERR filehandle associated, dummy functions should return FALSE */  
         ok ( FDIIsCabinet( hfdi_unknown_dummy, -1, &fdi_cabinfo_dummy) == FALSE,  
                         "FDIIsCabinet (File = Error) failed!\n");  
  
       trace("Starting TestInfo()\n");
  
         tvfs_create( name_simple_cab, file_simple_cab, size_simple_cab);         tvfs_create( name_simple_cab, file_simple_cab, size_simple_cab);
         fd = tvfs_open( name_simple_cab, _O_BINARY, 0 );         fd = tvfs_open( name_simple_cab, _O_BINARY, 0 );
  
         ok( FDIIsCabinet( hfdi_unknown_tvfs, fd, &fdi_cabinfo_simple) == TRUE,      ok( FDIIsCabinet( hfdi_simple, fd, &fdi_cabinfo_simple) == TRUE,
                         "FDIIsCabinet (Virtual File = Simple.cab) failed!\n");                         "FDIIsCabinet (Virtual File = Simple.cab) failed!\n");
  
         printCabInfo(fdi_cabinfo_simple);         printCabInfo(fdi_cabinfo_simple);
                 CheckCabInfo("simple.cab",fdi_cabinfo_simple,121,1,1,0,0,0,0,0);                 CheckCabInfo("simple.cab",fdi_cabinfo_simple,121,1,1,0,0,0,0,0);
  
         tvfs_close(fd);         tvfs_close(fd);
       tvfs_free();
  
       trace("Ending TestInfo()\n");
   }
  
         tvfs_create( name_complex_cab, file_complex_cab, size_complex_cab);  static void TestCopy(void){
         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);      char name_file_path[256];
       int result;
  
         printf("Ending TestInfo()\n");      trace("Starting TestCopy()\n");
         printf(" SEEK_CUR %d \n",SEEK_CUR);      trace("---simple.cab\n");
 }  
  
 static void TestCopy(void){      tvfs_create( name_simple_cab, file_simple_cab, size_simple_cab);
         printf("Starting TestCopy()\n");      FDICopy(hfdi_simple,
         printf("---simple.cab\n");  
         FDICopy(hfdi_unknown_tvfs,  
                         "simple.cab",                         "simple.cab",
                         "",                         "",
                         0,                         0,
Line 282 
Line 243 
                         NULL,                         NULL,
                         NULL);                         NULL);
  
         printf("Ending TestCopy()\n");      /* Filename when extracted is ./<filename> */
       sprintf(name_file_path, "./%s", name_simple_txt);
       result = tvfs_compare(name_file_path, file_simple_txt, size_simple_txt);
       if (result)
           trace ("File %s compare failed!\n",name_file_path);
       tvfs_free();
   
       trace("Ending TestCopy()\n");
 } }
  
 static void TestDestroy(void) { static void TestDestroy(void) {
         printf("Starting TestDestroy()\n");      trace("Starting TestDestroy()\n");
       ok(FDIDestroy(hfdi_simple), "FDIDestroy (CPU = unknown) (functions=tvfs) failed!\n");
         ok(FDIDestroy(hfdi_unknown_dummy), "FDIDestroy (CPU = unknown) (functions=fake) failed!\n");      trace("Ending TestDestroy()\n");
         ok(FDIDestroy(hfdi_unknown_tvfs), "FDIDestroy (CPU = unknown) (functions=tvfs) failed!\n");  
         printf("Ending TestDestroy()\n");  
 } }
  
 START_TEST(paths)  START_TEST(cabinet_fdi)
 { {
         TestCreate();         TestCreate();
         TestInfo();         TestInfo();


Legend:
Removed from v.2.5  
changed lines
  Added in v.2.15

Rizwan Kassim
Powered by
ViewCVS 0.9.2