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

  1 rizwank 1.1 /*
  2              * Unit test suite for cabinet.dll - FDI functions
  3              *
  4              * Copyright 2004 Rizwan Kassim, Dan Kegel
  5              *
  6              * This library is free software; you can redistribute it and/or
  7              * modify it under the terms of the GNU Lesser General Public
  8              * License as published by the Free Software Foundation; either
  9              * version 2.1 of the License, or (at your option) any later version.
 10              *
 11              * This library is distributed in the hope that it will be useful,
 12              * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13              * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14              * Lesser General Public License for more details.
 15              *
 16              * You should have received a copy of the GNU Lesser General Public
 17              * License along with this library; if not, write to the Free Software
 18              * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 19              */
 20             
 21             
 22 rizwank 1.1 #include <stdlib.h>
 23             
 24             #ifndef STANDALONE
 25             #include <wine/test.h>
 26             #define ok2 ok
 27             #else
 28             /* To build outside Wine tree, compile with cl -DSTANDALONE -D_X86_ cabinet_fdi.c FDI.lib 
 29               These are only called if standalone are used, defining ok and START_TEST, which would normally be declared in winetree */
 30             #include <assert.h> 
 31             #include <stdio.h>
 32             #define START_TEST(name) main(int argc, char **argv)
 33             #define ok(condition, msg)       \
 34             	do { if(!(condition)) {  \
 35             		fprintf(stderr,"failed at %d, msg:" msg "\n",__LINE__); \
 36             		exit(1);         \
 37             	} } while(0)
 38             #define ok2(condition, msg, arg) \
 39                     do { if(!(condition)) {  \
 40             		fprintf(stderr,"failed at %d, msg:" msg "\n",__LINE__, arg); \
 41             		exit(1);         \
 42             	} } while(0)
 43 rizwank 1.1 #define todo_wine
 44             #endif 
 45             
 46             
 47             #include <winerror.h>
 48             #include <fdi.h>
 49             
 50             /*	To do in FDI:				-from wine/include/fdi.h
 51             	FDICreate
 52             		Memory Allocation		-FNALLOC(cb)
 53             		Memory Free				-FNFREE(pv)
 54             		File Open				-FNOPEN(pszFile,oflag,pmode)
 55             		File Read				-FNREAD(hf, pv, cb)
 56             		File Write				-FNWRITE(hf, pv, cb)
 57             		File Close				-FNCLOSE(hf)
 58             		File Seek				-FNSEEK(hf,dist,seektype)
 59             		Error Structure
 60             	FDIlsCabinet
 61             		FDICabinetInfo Structure
 62             	FDICopy
 63             		Notification function
 64 rizwank 1.1 		Decryption function
 65             	FDIDestroy
 66             */
 67             
 68 rizwank 1.5 /* Currently mostly dummy function pointers */
 69 rizwank 1.1 
 70 rizwank 1.5 FNALLOC(debug_alloc) {
 71              	printf("   FNALLOC just called with %d\n",cb);
 72             	return malloc(cb);
 73 rizwank 1.3 }
 74             
 75 rizwank 1.5 FNFREE(debug_free) {
 76             	printf("   FNFREE just called with %d\n",pv);
 77             	free(pv);
 78 rizwank 1.3 	return;
 79             }
 80             
 81 rizwank 1.5 /*
 82             It is not necessary for these functions to actually call _open etc.; these functions could instead call fopen, fread, fwrite, fclose, and fseek, or CreateFile, ReadFile, WriteFile, CloseHandle, and SetFilePointer, etc.  However, the parameters and return codes will have to be translated appropriately (e.g. the file open mode passed in to pfnopen).
 83             */
 84             
 85 rizwank 1.3 FNOPEN(dummy_open) {
 86 rizwank 1.5 	 printf("  FNOPEN just called with %d, %d, %d\n",pszFile, oflag, pmode);
 87 rizwank 1.3 	return 0;
 88             }
 89             
 90             FNREAD(dummy_read) {
 91 rizwank 1.5 	 printf("   FNREAD just called with %d, %d, %d\n",hf, pv, cb);
 92             	return 0;
 93 rizwank 1.3 }
 94             	
 95             FNWRITE(dummy_write) {
 96 rizwank 1.5 	 printf("   FNWRITE just called with %d, %d, %d\n",hf, pv, cb);
 97             	return 0;
 98 rizwank 1.3 }
 99             
100             
101             FNCLOSE(dummy_close) {
102 rizwank 1.5 	 printf("   FNCLOSE just called with %d\n",hf);	
103             	return 0;
104 rizwank 1.3 }
105 rizwank 1.1 
106 rizwank 1.3 FNSEEK(dummy_seek) {
107 rizwank 1.5 	 printf("   FNSEEK just called with %d, %d, %d\n",hf, dist, seektype);	
108             	return 0;
109 rizwank 1.3 }
110             
111 rizwank 1.5 HFDI hfdi_386, hfdi_286, hfdi_unknown;
112 rizwank 1.4 /* yes its global and ugly */
113             
114 rizwank 1.3 static void TestDestroy(void) {
115 rizwank 1.4 	printf("Starting TestDestroy()\n");
116             		/* Only two things to check in FDIDestroy
117 rizwank 1.3 	   1=> Does it return T if its passed an hfdi
118             	   2=> Does it return F if its passed a non hfdi
119 rizwank 1.4 	   	EDIT : Causes GPL if FDIDestroy is called on an invalid pointer.
120             		ok( 0 == FDIDestroy(0), "Return true incorrectly in TestDestroy()!\n");
121 rizwank 1.3 		*/
122 rizwank 1.6 				
123             	ok(FDIDestroy(hfdi_unknown), "FDIDestroy (CPU = unknown) failed!\n");
124 rizwank 1.5 	printf("Ending TestDestroy()\n");
125 rizwank 1.4 		
126 rizwank 1.3 }
127 rizwank 1.1 
128 rizwank 1.4 static void TestCreate(void) {
129             			
130             	ERF error_structure;
131             	
132             	printf("Starting TestCreate()\n");
133             	
134 rizwank 1.5 	hfdi_unknown = FDICreate(
135             		debug_alloc,
136             		debug_free,
137             		dummy_open,
138             		dummy_read,
139             		dummy_write,
140             		dummy_close,
141             		dummy_seek,
142             		cpuUNKNOWN,
143             		&error_structure
144             	);
145             	ok(hfdi_unknown != NULL,"FDICreate (CPU = unknown) failed!\n");		
146             	
147             	
148             		
149 rizwank 1.4 	
150             	printf("Ending TestCreate()\n");		
151             }
152 rizwank 1.1 
153             START_TEST(paths)
154             {
155 rizwank 1.4 	
156             	TestCreate();
157 rizwank 1.2 	/*
158             	TestInfo();
159             	TestCopy();
160 rizwank 1.3 	*/
161 rizwank 1.2 	TestDestroy();
162 rizwank 1.3 	
163 rizwank 1.1 }

Rizwan Kassim
Powered by
ViewCVS 0.9.2