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.5 ok(FDIDestroy(hfdi_386), "Failed on destroying 386 hfdi!\n");
123 ok(FDIDestroy(hfdi_286), "Failed on destroying 286 hfdi!\n");
124 ok(FDIDestroy(hfdi_unknown), "Failed on destroying unknown hfdi!\n");
125 printf("Ending TestDestroy()\n");
|
126 rizwank 1.4
|
127 rizwank 1.3 }
|
128 rizwank 1.1
|
129 rizwank 1.4 static void TestCreate(void) {
130
131 ERF error_structure;
132
133 printf("Starting TestCreate()\n");
134
|
135 rizwank 1.5 hfdi_386 = FDICreate(
136 debug_alloc,
137 debug_free,
|
138 rizwank 1.4 dummy_open,
139 dummy_read,
140 dummy_write,
141 dummy_close,
142 dummy_seek,
143 cpu80386,
144 &error_structure
145 );
|
146 rizwank 1.5 ok(hfdi_386 != NULL,"FDICreate (CPU = cpu80386) failed!\n");
147
148 hfdi_286 = FDICreate(
149 debug_alloc,
150 debug_free,
151 dummy_open,
152 dummy_read,
153 dummy_write,
154 dummy_close,
155 dummy_seek,
156 cpu80286,
157 &error_structure
158 );
159 ok(hfdi_286 != NULL,"FDICreate (CPU = cpu80286) failed!\n");
160
161 hfdi_unknown = FDICreate(
162 debug_alloc,
163 debug_free,
164 dummy_open,
165 dummy_read,
166 dummy_write,
167 rizwank 1.5 dummy_close,
168 dummy_seek,
169 cpuUNKNOWN,
170 &error_structure
171 );
172 ok(hfdi_unknown != NULL,"FDICreate (CPU = unknown) failed!\n");
173
174
175
|
176 rizwank 1.4
177 printf("Ending TestCreate()\n");
178 }
|
179 rizwank 1.1
180 START_TEST(paths)
181 {
|
182 rizwank 1.4
183 TestCreate();
|
184 rizwank 1.2 /*
185 TestInfo();
186 TestCopy();
|
187 rizwank 1.3 */
|
188 rizwank 1.2 TestDestroy();
|
189 rizwank 1.3
|
190 rizwank 1.1 }
|