quartz: Use proper alloc/free functions for COM objects.
[wine] / dlls / wininet / tests / ftp.c
1 /*
2  * Wininet - ftp tests
3  *
4  * Copyright 2007 Paul Vriens
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 /*
22  * FIXME:
23  *     Use InternetGetLastResponseInfo when the last error is set to ERROR_INTERNET_EXTENDED_ERROR.
24  * TODO:
25  *     Add W-function tests.
26  *     Add missing function tests:
27  *         FtpCommand
28  *         FtpFindFirstFile
29  *         FtpGetCurrentDirectory
30  *         FtpGetFileSize
31  *         FtpSetCurrentDirectory
32  */
33
34 #include <stdarg.h>
35 #include <stdio.h>
36 #include <stdlib.h>
37
38 #include "windef.h"
39 #include "winbase.h"
40 #include "wininet.h"
41 #include "winsock.h"
42
43 #include "wine/test.h"
44
45 static void test_getfile_no_open(void)
46 {
47     BOOL      bRet;
48
49     /* Invalid internet handle, the others are valid parameters */
50     SetLastError(0xdeadbeef);
51     bRet = FtpGetFileA(NULL, "welcome.msg", "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
52     ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
53     ok ( GetLastError() == ERROR_INTERNET_NOT_INITIALIZED ||
54          GetLastError() == ERROR_INVALID_HANDLE,
55         "Expected ERROR_INTERNET_NOT_INITIALIZED or ERROR_INVALID_HANDLE (win98), got %d\n", GetLastError());
56 }
57
58 static void test_connect(void)
59 {
60     HINTERNET hInternet, hFtp;
61
62     SetLastError(0xdeadbeef);
63     hInternet = InternetOpen(NULL, 0, NULL, NULL, 0);
64     ok(hInternet != NULL, "InternetOpen failed : %d\n", GetLastError());
65
66     if(!hInternet)
67     {
68         skip("No internet connection could be made\n");
69         return;
70     }
71
72     /* Try a few username/password combinations:
73      * anonymous : NULL
74      * NULL      : IEUser@
75      * NULL      : NULL
76      */
77
78     SetLastError(0xdeadbeef);
79     hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "anonymous", NULL, INTERNET_SERVICE_FTP, 0, 0);
80     ok ( hFtp == NULL, "Expected InternetConnect to fail\n");
81     ok ( GetLastError() == ERROR_INTERNET_LOGIN_FAILURE,
82         "Expected ERROR_INTERNET_LOGIN_FAILURE, got %d\n", GetLastError());
83
84     SetLastError(0xdeadbeef);
85     hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, NULL, "IEUser@", INTERNET_SERVICE_FTP, 0, 0);
86     ok ( hFtp == NULL, "Expected InternetConnect to fail\n");
87     ok ( GetLastError() == ERROR_INVALID_PARAMETER,
88         "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
89
90     /* Using a NULL username and password will be interpreted as anonymous ftp. The username will be 'anonymous' the password
91      * is created via some simple heuristics (see dlls/wininet/ftp.c).
92      * On Wine this registry key is not set by default so (NULL, NULL) will result in anonymous ftp with an (most likely) not
93      * accepted password (the username).
94      * If the first call fails because we get an ERROR_INTERNET_LOGIN_FAILURE, we try again with a (more) correct password.
95      */
96
97     SetLastError(0xdeadbeef);
98     hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, NULL, NULL, INTERNET_SERVICE_FTP, 0, 0);
99     if (!hFtp && (GetLastError() == ERROR_INTERNET_LOGIN_FAILURE))
100     {
101         /* We are most likely running on a clean Wine install or a Windows install where the registry key is removed */
102         SetLastError(0xdeadbeef);
103         hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "anonymous", "IEUser@", INTERNET_SERVICE_FTP, 0, 0);
104     }
105     ok ( hFtp != NULL, "InternetConnect failed : %d\n", GetLastError());
106     ok ( GetLastError() == ERROR_SUCCESS,
107         "ERROR_SUCCESS, got %d\n", GetLastError());
108
109     InternetCloseHandle(hFtp);
110     InternetCloseHandle(hInternet);
111 }
112
113 static void test_createdir(void)
114 {
115     BOOL      bRet;
116     HINTERNET hInternet, hFtp, hConnect;
117
118     /* Invalid internet handle, the other is a valid parameter */
119     SetLastError(0xdeadbeef);
120     bRet = FtpCreateDirectoryA(NULL, "new_directory_deadbeef");
121     ok ( bRet == FALSE, "Expected FtpCreateDirectoryA to fail\n");
122     ok ( GetLastError() == ERROR_INVALID_HANDLE,
123         "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
124
125     hInternet = InternetOpen(NULL, 0, NULL, NULL, 0);
126     hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "anonymous", "IEUser@", INTERNET_SERVICE_FTP, 0, 0);
127     if(!hFtp)
128     {
129         skip("No ftp connection could be made to ftp.winehq.org\n");
130         InternetCloseHandle(hInternet);
131         return;
132     }
133
134     /* We should have a ftp-connection (valid ftp session handle), try some creating */
135
136     /* No directory-name */
137     SetLastError(0xdeadbeef);
138     bRet = FtpCreateDirectoryA(hFtp, NULL);
139     ok ( bRet == FALSE, "Expected FtpCreateDirectoryA to fail\n");
140     ok ( GetLastError() == ERROR_INVALID_PARAMETER,
141         "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
142
143     /* Parameters are OK, but we shouldn't be allowed to create the directory */
144     SetLastError(0xdeadbeef);
145     bRet = FtpCreateDirectoryA(hFtp, "new_directory_deadbeef");
146     ok ( bRet == FALSE, "Expected FtpCreateDirectoryA to fail\n");
147     todo_wine
148     ok ( GetLastError() == ERROR_INTERNET_EXTENDED_ERROR,
149         "Expected ERROR_INTERNET_EXTENDED_ERROR, got %d\n", GetLastError());
150
151     InternetCloseHandle(hFtp);
152
153     /* Http handle-type for ftp connection */
154
155     hConnect = InternetConnect(hInternet, "www.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
156
157     /* One small test to show that handle type is checked before parameters */
158     SetLastError(0xdeadbeef);
159     bRet = FtpCreateDirectoryA(hConnect, NULL);
160     ok ( bRet == FALSE, "Expected FtpCreateDirectoryA to fail\n");
161     ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
162         "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
163
164     SetLastError(0xdeadbeef);
165     bRet = FtpCreateDirectoryA(hConnect, "new_directory_deadbeef");
166     ok ( bRet == FALSE, "Expected FtpCreateDirectoryA to fail\n");
167     ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
168         "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
169
170     InternetCloseHandle(hConnect);
171     InternetCloseHandle(hInternet);
172 }
173
174 static void test_deletefile(void)
175 {
176     BOOL      bRet;
177     HINTERNET hInternet, hFtp, hConnect;
178
179     /* Invalid internet handle, the other is a valid parameter */
180     SetLastError(0xdeadbeef);
181     bRet = FtpDeleteFileA(NULL, "non_existent_file_deadbeef");
182     ok ( bRet == FALSE, "Expected FtpDeleteFileA to fail\n");
183     ok ( GetLastError() == ERROR_INVALID_HANDLE,
184         "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
185
186     hInternet = InternetOpen(NULL, 0, NULL, NULL, 0);
187     hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "anonymous", "IEUser@", INTERNET_SERVICE_FTP, 0, 0);
188     if(!hFtp)
189     {
190         skip("No ftp connection could be made to ftp.winehq.org\n");
191         InternetCloseHandle(hInternet);
192         return;
193     }
194
195     /* We should have a ftp-connection, try some deleting */
196
197     /* No filename */
198     SetLastError(0xdeadbeef);
199     bRet = FtpDeleteFileA(hFtp, NULL);
200     ok ( bRet == FALSE, "Expected FtpDeleteFileA to fail\n");
201     ok ( GetLastError() == ERROR_INVALID_PARAMETER,
202         "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
203
204     /* Parameters are OK but remote file should not be there */
205     SetLastError(0xdeadbeef);
206     bRet = FtpDeleteFileA(hFtp, "non_existent_file_deadbeef");
207     ok ( bRet == FALSE, "Expected FtpDeleteFileA to fail\n");
208     todo_wine
209     ok ( GetLastError() == ERROR_INTERNET_EXTENDED_ERROR,
210         "Expected ERROR_INTERNET_EXTENDED_ERROR, got %d\n", GetLastError());
211
212     InternetCloseHandle(hFtp);
213
214     /* Http handle-type for ftp connection */
215
216     hConnect = InternetConnect(hInternet, "www.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
217
218     /* One small test to show that handle type is checked before parameters */
219     SetLastError(0xdeadbeef);
220     bRet = FtpDeleteFileA(hConnect, NULL);
221     ok ( bRet == FALSE, "Expected FtpDeleteFileA to fail\n");
222     ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
223         "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
224
225     SetLastError(0xdeadbeef);
226     bRet = FtpDeleteFileA(hConnect, "non_existent_file_deadbeef");
227     ok ( bRet == FALSE, "Expected FtpCreateDirectoryA to fail\n");
228     ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
229         "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
230
231     InternetCloseHandle(hConnect);
232     InternetCloseHandle(hInternet);
233 }
234
235 static void test_getfile(void)
236 {
237     BOOL      bRet;
238     HINTERNET hInternet, hFtp, hConnect;
239     HANDLE    hFile;
240
241     /* The order of checking is:
242      *
243      *   All parameters except 'session handle' and 'condition flags'
244      *   Session handle
245      *   Session handle type
246      *   Condition flags
247      */
248
249     /* Test to show the parameter checking order depends on the Windows version */
250     SetLastError(0xdeadbeef);
251     bRet = FtpGetFileA(NULL, NULL, "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
252     ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
253     ok ( GetLastError() == ERROR_INVALID_HANDLE ||
254          GetLastError() == ERROR_INVALID_PARAMETER,
255         "Expected ERROR_INVALID_HANDLE (win98) or ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
256
257     /* Test to show session handle is checked before 'condition flags' */
258     SetLastError(0xdeadbeef);
259     bRet = FtpGetFileA(NULL, "welcome.msg", "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, 5, 0);
260     ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
261     ok ( GetLastError() == ERROR_INVALID_HANDLE,
262         "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
263
264     hInternet = InternetOpen(NULL, 0, NULL, NULL, 0);
265     hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "anonymous", "IEUser@", INTERNET_SERVICE_FTP, 0, 0);
266     if(!hFtp)
267     {
268         skip("No ftp connection could be made to ftp.winehq.org\n");
269         InternetCloseHandle(hInternet);
270         return;
271     }
272
273     /* Make sure we start clean */
274
275     DeleteFileA("should_be_non_existing_deadbeef");
276     DeleteFileA("should_also_be_non_existing_deadbeef");
277
278     /* We should have a ftp-connection, try some getting */
279
280     /* No remote file */
281     SetLastError(0xdeadbeef);
282     bRet = FtpGetFileA(hFtp, NULL, "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
283     ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
284     ok ( GetLastError() == ERROR_INVALID_PARAMETER,
285         "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
286     ok (GetFileAttributesA("should_be_non_existing_deadbeef") == INVALID_FILE_ATTRIBUTES,
287         "Local file should not have been created\n");
288     DeleteFileA("should_be_non_existing_deadbeef");
289
290     /* No local file */
291     SetLastError(0xdeadbeef);
292     bRet = FtpGetFileA(hFtp, "welcome.msg", NULL, FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
293     ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
294     ok ( GetLastError() == ERROR_INVALID_PARAMETER,
295         "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
296
297     /* Zero attributes, but call succeeds (as would CreateFile with zero attributes) */
298     SetLastError(0xdeadbeef);
299     bRet = FtpGetFileA(hFtp, "welcome.msg", "should_be_non_existing_deadbeef", FALSE, 0, FTP_TRANSFER_TYPE_UNKNOWN, 0);
300     todo_wine
301     {
302     ok ( bRet == TRUE, "Expected FtpGetFileA to succeed\n");
303     ok ( GetLastError() == ERROR_SUCCESS,
304         "Expected ERROR_SUCCESS, got %d\n", GetLastError());
305     }
306     /* Wine passes this test but for the wrong reason */
307     ok (GetFileAttributesA("should_be_non_existing_deadbeef") != INVALID_FILE_ATTRIBUTES,
308         "Local file should have been created\n");
309     DeleteFileA("should_be_non_existing_deadbeef");
310
311     /* Illegal condition flags */
312     SetLastError(0xdeadbeef);
313     bRet = FtpGetFileA(hFtp, "welcome.msg", "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, 5, 0);
314     ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
315     ok ( GetLastError() == ERROR_INVALID_PARAMETER,
316         "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
317     ok (GetFileAttributesA("should_be_non_existing_deadbeef") == INVALID_FILE_ATTRIBUTES,
318         "Local file should not have been created\n");
319     DeleteFileA("should_be_non_existing_deadbeef");
320
321     /* Remote file doesn't exist (and local doesn't exist as well) */
322     SetLastError(0xdeadbeef);
323     bRet = FtpGetFileA(hFtp, "should_be_non_existing_deadbeef", "should_also_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
324     ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
325     todo_wine
326     {
327     ok ( GetLastError() == ERROR_INTERNET_EXTENDED_ERROR,
328         "Expected ERROR_INTERNET_EXTENDED_ERROR, got %d\n", GetLastError());
329     /* Currently Wine always creates the local file (even on failure) which is not correct, hence the test */
330     ok (GetFileAttributesA("should_also_be_non_existing_deadbeef") == INVALID_FILE_ATTRIBUTES,
331         "Local file should not have been created\n");
332     }
333     DeleteFileA("should_also_be_non_existing_deadbeef");
334
335     /* Same call as the previous but now the local file does exists. Windows just removes the file if the call fails
336      * even if the local existed before!
337      */
338
339     /* Create a temporary local file */
340     SetLastError(0xdeadbeef);
341     hFile = CreateFileA("should_also_be_non_existing_deadbeef", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
342     ok ( hFile != NULL, "Error creating a local file : %d\n", GetLastError());
343     CloseHandle(hFile);
344     SetLastError(0xdeadbeef);
345     bRet = FtpGetFileA(hFtp, "should_be_non_existing_deadbeef", "should_also_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
346     ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
347     todo_wine
348     {
349     ok ( GetLastError() == ERROR_INTERNET_EXTENDED_ERROR,
350         "Expected ERROR_INTERNET_EXTENDED_ERROR, got %d\n", GetLastError());
351     /* Currently Wine always creates the local file (even on failure) which is not correct, hence the test */
352     ok (GetFileAttributesA("should_also_be_non_existing_deadbeef") == INVALID_FILE_ATTRIBUTES,
353         "Local file should not have been created\n");
354     }
355     DeleteFileA("should_also_be_non_existing_deadbeef");
356
357     /* This one should succeed and give us a copy of the 'welcome.msg' file */
358     SetLastError(0xdeadbeef);
359     bRet = FtpGetFileA(hFtp, "welcome.msg", "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
360     todo_wine
361     {
362     ok ( bRet == TRUE, "Expected FtpGetFileA to succeed\n");
363     ok ( GetLastError() == ERROR_SUCCESS,
364         "Expected ERROR_SUCCESS, got %d\n", GetLastError());
365     }
366
367     if (GetFileAttributesA("should_be_non_existing_deadbeef") != INVALID_FILE_ATTRIBUTES)
368     {
369         /* Should succeed as fFailIfExists is set to FALSE (meaning don't fail if local file exists) */
370         SetLastError(0xdeadbeef);
371         bRet = FtpGetFileA(hFtp, "welcome.msg", "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
372         todo_wine
373         {
374         ok ( bRet == TRUE, "Expected FtpGetFileA to succeed\n");
375         ok ( GetLastError() == ERROR_SUCCESS,
376             "Expected ERROR_SUCCESS, got %d\n", GetLastError());
377         }
378
379         /* Should fail as fFailIfExists is set to TRUE */
380         SetLastError(0xdeadbeef);
381         bRet = FtpGetFileA(hFtp, "welcome.msg", "should_be_non_existing_deadbeef", TRUE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
382         ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
383         todo_wine
384         ok ( GetLastError() == ERROR_FILE_EXISTS,
385             "Expected ERROR_FILE_EXISTS, got %d\n", GetLastError());
386
387         /* Prove that the existence of the local file is checked first (or at least reported last) */
388         SetLastError(0xdeadbeef);
389         bRet = FtpGetFileA(hFtp, "should_be_non_existing_deadbeef", "should_be_non_existing_deadbeef", TRUE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
390         ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
391         todo_wine
392         ok ( GetLastError() == ERROR_FILE_EXISTS,
393             "Expected ERROR_FILE_EXISTS, got %d\n", GetLastError());
394
395         DeleteFileA("should_be_non_existing_deadbeef");
396     }
397
398     InternetCloseHandle(hFtp);
399
400     /* Http handle-type for ftp connection */
401
402     hConnect = InternetConnect(hInternet, "www.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
403
404     /* Test to show the parameter checking order depends on the Windows version */
405     SetLastError(0xdeadbeef);
406     bRet = FtpGetFileA(hConnect, NULL, "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
407     ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
408     ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE ||
409          GetLastError() == ERROR_INVALID_PARAMETER,
410         "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE (win98) or ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
411
412     /* Test to show that 'session handle type' is checked before 'condition flags' */
413     SetLastError(0xdeadbeef);
414     bRet = FtpGetFileA(hConnect, "welcome.msg", "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, 5, 0);
415     ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
416     ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
417         "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
418
419     SetLastError(0xdeadbeef);
420     bRet = FtpGetFileA(hConnect, "should_be_non_existing_deadbeef", "should_be_non_existing_deadbeef", TRUE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
421     ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
422     ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
423         "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
424
425     InternetCloseHandle(hConnect);
426     InternetCloseHandle(hInternet);
427 }
428
429 static void test_openfile(void)
430 {
431     HINTERNET hOpenFile, hInternet, hFtp, hConnect;
432
433     /* Invalid internet handle, the rest are valid parameters */
434     SetLastError(0xdeadbeef);
435     hOpenFile = FtpOpenFileA(NULL, "welcome.msg", GENERIC_READ, FTP_TRANSFER_TYPE_ASCII, 0);
436     ok ( !hOpenFile, "Expected FtpOpenFileA to fail\n");
437     ok ( GetLastError() == ERROR_INVALID_HANDLE,
438         "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
439     InternetCloseHandle(hOpenFile); /* Just in case */
440
441     hInternet = InternetOpen(NULL, 0, NULL, NULL, 0);
442     hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "anonymous", "IEUser@", INTERNET_SERVICE_FTP, 0, 0);
443     if(!hFtp)
444     {
445         skip("No ftp connection could be made to ftp.winehq.org\n");
446         InternetCloseHandle(hInternet);
447         return;
448     }
449
450     /* We should have a ftp-connection (valid ftp session handle), try some opening */
451
452     /* No filename */
453     SetLastError(0xdeadbeef);
454     hOpenFile = FtpOpenFileA(hFtp, NULL, GENERIC_READ, FTP_TRANSFER_TYPE_ASCII, 0);
455     ok ( !hOpenFile, "Expected FtpOpenFileA to fail\n");
456     ok ( GetLastError() == ERROR_INVALID_PARAMETER,
457         "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
458     InternetCloseHandle(hOpenFile); /* Just in case */
459
460     /* Illegal access flags */
461     SetLastError(0xdeadbeef);
462     hOpenFile = FtpOpenFileA(hFtp, "welcome.msg", 0, FTP_TRANSFER_TYPE_ASCII, 0);
463     ok ( !hOpenFile, "Expected FtpOpenFileA to fail\n");
464     ok ( GetLastError() == ERROR_INVALID_PARAMETER,
465         "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
466     InternetCloseHandle(hOpenFile); /* Just in case */
467
468     /* Illegal combination of access flags */
469     SetLastError(0xdeadbeef);
470     hOpenFile = FtpOpenFileA(hFtp, "welcome.msg", GENERIC_READ|GENERIC_WRITE, FTP_TRANSFER_TYPE_ASCII, 0);
471     ok ( !hOpenFile, "Expected FtpOpenFileA to fail\n");
472     ok ( GetLastError() == ERROR_INVALID_PARAMETER,
473         "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
474     InternetCloseHandle(hOpenFile); /* Just in case */
475
476     /* Illegal condition flags */
477     SetLastError(0xdeadbeef);
478     hOpenFile = FtpOpenFileA(hFtp, "welcome.msg", GENERIC_READ, 5, 0);
479     ok ( !hOpenFile, "Expected FtpOpenFileA to fail\n");
480     ok ( GetLastError() == ERROR_INVALID_PARAMETER,
481         "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
482     InternetCloseHandle(hOpenFile); /* Just in case */
483
484     /* All OK */
485     SetLastError(0xdeadbeef);
486     hOpenFile = FtpOpenFileA(hFtp, "welcome.msg", GENERIC_READ, FTP_TRANSFER_TYPE_ASCII, 0);
487     ok ( hOpenFile != NULL, "Expected FtpOpenFileA to succeed\n");
488     /* For some strange/unknown reason, win98 returns ERROR_FILE_NOT_FOUND */
489     ok ( GetLastError() == ERROR_SUCCESS || GetLastError() == ERROR_FILE_NOT_FOUND,
490         "Expected ERROR_SUCCESS or ERROR_FILE_NOT_FOUND (win98), got %d\n", GetLastError());
491
492     if (hOpenFile)
493     {
494         BOOL bRet;
495         HINTERNET hOpenFile2;
496         HANDLE    hFile;
497
498         /* We have a handle so all ftp calls should fail (TODO: Put all ftp-calls in here) */
499         SetLastError(0xdeadbeef);
500         bRet = FtpCreateDirectoryA(hFtp, "new_directory_deadbeef");
501         ok ( bRet == FALSE, "Expected FtpCreateDirectoryA to fail\n");
502         todo_wine
503         ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
504             "Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
505
506         SetLastError(0xdeadbeef);
507         bRet = FtpDeleteFileA(hFtp, "non_existent_file_deadbeef");
508         ok ( bRet == FALSE, "Expected FtpDeleteFileA to fail\n");
509         todo_wine
510         ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
511             "Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
512
513         SetLastError(0xdeadbeef);
514         bRet = FtpGetFileA(hFtp, "welcome.msg", "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
515         ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
516         ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
517             "Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
518         DeleteFileA("should_be_non_existing_deadbeef"); /* Just in case */
519
520         SetLastError(0xdeadbeef);
521         hOpenFile2 = FtpOpenFileA(hFtp, "welcome.msg", GENERIC_READ, FTP_TRANSFER_TYPE_ASCII, 0);
522         ok ( bRet == FALSE, "Expected FtpOpenFileA to fail\n");
523         ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
524             "Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
525         InternetCloseHandle(hOpenFile2); /* Just in case */
526
527         /* Create a temporary local file */
528         SetLastError(0xdeadbeef);
529         hFile = CreateFileA("now_existing_local", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
530         ok ( hFile != NULL, "Error creating a local file : %d\n", GetLastError());
531         CloseHandle(hFile);
532         SetLastError(0xdeadbeef);
533         bRet = FtpPutFileA(hFtp, "now_existing_local", "non_existing_remote", FTP_TRANSFER_TYPE_UNKNOWN, 0);
534         ok ( bRet == FALSE, "Expected FtpPutFileA to fail\n");
535         todo_wine
536         ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
537             "Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
538         DeleteFileA("now_existing_local");
539
540         SetLastError(0xdeadbeef);
541         bRet = FtpRemoveDirectoryA(hFtp, "should_be_non_existing_deadbeef_dir");
542         ok ( bRet == FALSE, "Expected FtpRemoveDirectoryA to fail\n");
543         todo_wine
544         ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
545             "Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
546
547         SetLastError(0xdeadbeef);
548         bRet = FtpRenameFileA(hFtp , "should_be_non_existing_deadbeef", "new");
549         ok ( bRet == FALSE, "Expected FtpRenameFileA to fail\n");
550         todo_wine
551         ok ( GetLastError() == ERROR_FTP_TRANSFER_IN_PROGRESS,
552             "Expected ERROR_FTP_TRANSFER_IN_PROGRESS, got %d\n", GetLastError());
553     }
554
555     InternetCloseHandle(hOpenFile);
556     InternetCloseHandle(hFtp);
557
558     /* Http handle-type for ftp connection */
559
560     hConnect = InternetConnect(hInternet, "www.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
561
562     /* One small test to show that handle type is checked before parameters */
563     SetLastError(0xdeadbeef);
564     hOpenFile = FtpOpenFileA(hConnect, "welcome.msg", GENERIC_READ, 5, 0);
565     ok ( !hOpenFile, "Expected FtpOpenFileA to fail\n");
566     ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
567         "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
568     InternetCloseHandle(hOpenFile); /* Just in case */
569
570     SetLastError(0xdeadbeef);
571     hOpenFile = FtpOpenFileA(hConnect, "welcome.msg", GENERIC_READ, FTP_TRANSFER_TYPE_ASCII, 0);
572     ok ( hOpenFile == NULL, "Expected FtpOpenFileA to fail\n");
573     ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
574         "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
575
576     InternetCloseHandle(hOpenFile); /* Just in case */
577     InternetCloseHandle(hConnect);
578     InternetCloseHandle(hInternet);
579 }
580
581 static void test_putfile(void)
582 {
583     BOOL      bRet;
584     HINTERNET hInternet, hFtp, hConnect;
585     HANDLE    hFile;
586
587     /* The order of checking is:
588      *
589      *   All parameters except 'session handle' and 'condition flags'
590      *   Session handle
591      *   Session handle type
592      *   Condition flags
593      */
594
595     /* Test to show the parameter checking order depends on the Windows version */
596     SetLastError(0xdeadbeef);
597     bRet = FtpPutFileA(NULL, NULL, "non_existing_remote", FTP_TRANSFER_TYPE_UNKNOWN, 0);
598     ok ( bRet == FALSE, "Expected FtpPutFileA to fail\n");
599     ok ( GetLastError() == ERROR_INVALID_HANDLE ||
600          GetLastError() == ERROR_INVALID_PARAMETER,
601         "Expected ERROR_INVALID_HANDLE (win98) or ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
602
603     /* Test to show session handle is checked before 'condition flags' */
604     SetLastError(0xdeadbeef);
605     bRet = FtpPutFileA(NULL, "non_existing_local", "non_existing_remote", 5, 0);
606     ok ( bRet == FALSE, "Expected FtpPutFileA to fail\n");
607     ok ( GetLastError() == ERROR_INVALID_HANDLE,
608         "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
609
610     hInternet = InternetOpen(NULL, 0, NULL, NULL, 0);
611     hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "anonymous", "IEUser@", INTERNET_SERVICE_FTP, 0, 0);
612     if(!hFtp)
613     {
614         skip("No ftp connection could be made to ftp.winehq.org\n");
615         InternetCloseHandle(hInternet);
616         return;
617     }
618
619     /* Start clean */
620     DeleteFileA("non_existing_local");
621
622     /* We should have a ftp-connection, try some puts */
623
624     /* No local file given */
625     SetLastError(0xdeadbeef);
626     bRet = FtpPutFileA(hFtp, NULL, "non_existing_remote", FTP_TRANSFER_TYPE_UNKNOWN, 0);
627     ok ( bRet == FALSE, "Expected FtpPutFileA to fail\n");
628     ok ( GetLastError() == ERROR_INVALID_PARAMETER,
629         "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
630
631     /* No remote file given */
632     SetLastError(0xdeadbeef);
633     bRet = FtpPutFileA(hFtp, "non_existing_local", NULL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
634     ok ( bRet == FALSE, "Expected FtpPutFileA to fail\n");
635     ok ( GetLastError() == ERROR_INVALID_PARAMETER,
636         "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
637
638     /* Illegal condition flags */
639     SetLastError(0xdeadbeef);
640     bRet = FtpPutFileA(hFtp, "non_existing_local", "non_existing_remote", 5, 0);
641     ok ( bRet == FALSE, "Expected FtpPutFileA to fail\n");
642     ok ( GetLastError() == ERROR_INVALID_PARAMETER,
643         "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
644
645     /* Parameters are OK but local file doesn't exist */
646     SetLastError(0xdeadbeef);
647     bRet = FtpPutFileA(hFtp, "non_existing_local", "non_existing_remote", FTP_TRANSFER_TYPE_UNKNOWN, 0);
648     ok ( bRet == FALSE, "Expected FtpPutFileA to fail\n");
649     ok ( GetLastError() == ERROR_FILE_NOT_FOUND,
650         "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
651
652     /* Create a temporary local file */
653     SetLastError(0xdeadbeef);
654     hFile = CreateFileA("now_existing_local", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
655     ok ( hFile != NULL, "Error creating a local file : %d\n", GetLastError());
656     CloseHandle(hFile);
657
658     /* Local file exists but we shouldn't be allowed to 'put' the file */
659     SetLastError(0xdeadbeef);
660     bRet = FtpPutFileA(hFtp, "now_existing_local", "non_existing_remote", FTP_TRANSFER_TYPE_UNKNOWN, 0);
661     ok ( bRet == FALSE, "Expected FtpPutFileA to fail\n");
662     todo_wine
663     ok ( GetLastError() == ERROR_INTERNET_EXTENDED_ERROR,
664         "Expected ERROR_INTERNET_EXTENDED_ERROR, got %d\n", GetLastError());
665
666     DeleteFileA("now_existing_local");
667
668     InternetCloseHandle(hFtp);
669
670     /* Http handle-type for ftp connection */
671
672     hConnect = InternetConnect(hInternet, "www.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
673
674     /* Test to show the parameter checking order depends on the Windows version */
675     SetLastError(0xdeadbeef);
676     bRet = FtpPutFileA(hConnect, NULL, "non_existing_remote", FTP_TRANSFER_TYPE_UNKNOWN, 0);
677     ok ( bRet == FALSE, "Expected FtpPutFileA to fail\n");
678     ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE ||
679          GetLastError() == ERROR_INVALID_PARAMETER,
680         "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE (win98) or ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
681
682     /* Test to show that 'session handle type' is checked before 'condition flags' */
683     SetLastError(0xdeadbeef);
684     bRet = FtpPutFileA(hConnect, "non_existing_local", "non_existing_remote", 5, 0);
685     ok ( bRet == FALSE, "Expected FtpPutFileA to fail\n");
686     ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
687         "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
688
689     SetLastError(0xdeadbeef);
690     bRet = FtpPutFileA(hConnect, "non_existing_local", "non_existing_remote", FTP_TRANSFER_TYPE_UNKNOWN, 0);
691     ok ( bRet == FALSE, "Expected FtpPutFileA to fail\n");
692     ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
693         "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
694
695     InternetCloseHandle(hConnect);
696     InternetCloseHandle(hInternet);
697 }
698
699 static void test_removedir(void)
700 {
701     BOOL      bRet;
702     HINTERNET hInternet, hFtp, hConnect;
703
704     /* Invalid internet handle, the other is a valid parameter */
705     SetLastError(0xdeadbeef);
706     bRet = FtpRemoveDirectoryA(NULL, "should_be_non_existing_deadbeef_dir");
707     ok ( bRet == FALSE, "Expected FtpRemoveDirectoryA to fail\n");
708     ok ( GetLastError() == ERROR_INVALID_HANDLE,
709         "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
710
711     hInternet = InternetOpen(NULL, 0, NULL, NULL, 0);
712     hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "anonymous", "IEUser@", INTERNET_SERVICE_FTP, 0, 0);
713     if(!hFtp)
714     {
715         skip("No ftp connection could be made to ftp.winehq.org\n");
716         InternetCloseHandle(hInternet);
717         return;
718     }
719
720     /* We should have a ftp-connection, try some removing */
721
722     /* No remote directory given */
723     SetLastError(0xdeadbeef);
724     bRet = FtpRemoveDirectoryA(hFtp, NULL);
725     ok ( bRet == FALSE, "Expected FtpRemoveDirectoryA to fail\n");
726     ok ( GetLastError() == ERROR_INVALID_PARAMETER,
727         "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
728
729     /* Remote directory doesn't exist */
730     SetLastError(0xdeadbeef);
731     bRet = FtpRemoveDirectoryA(hFtp, "should_be_non_existing_deadbeef_dir");
732     ok ( bRet == FALSE, "Expected FtpRemoveDirectoryA to fail\n");
733     todo_wine
734     ok ( GetLastError() == ERROR_INTERNET_EXTENDED_ERROR,
735         "Expected ERROR_INTERNET_EXTENDED_ERROR, got %d\n", GetLastError());
736
737     /* We shouldn't be allowed to remove that directory */
738     SetLastError(0xdeadbeef);
739     bRet = FtpRemoveDirectoryA(hFtp, "pub");
740     ok ( bRet == FALSE, "Expected FtpRemoveDirectoryA to fail\n");
741     todo_wine
742     ok ( GetLastError() == ERROR_INTERNET_EXTENDED_ERROR,
743         "Expected ERROR_INTERNET_EXTENDED_ERROR, got %d\n", GetLastError());
744
745     InternetCloseHandle(hFtp);
746
747     /* Http handle-type for ftp connection */
748
749     hConnect = InternetConnect(hInternet, "www.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
750
751     /* One small test to show that handle type is checked before parameters */
752     SetLastError(0xdeadbeef);
753     bRet = FtpRemoveDirectoryA(hConnect, NULL);
754     ok ( bRet == FALSE, "Expected FtpRemoveDirectoryA to fail\n");
755     ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
756         "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
757
758     SetLastError(0xdeadbeef);
759     bRet = FtpRemoveDirectoryA(hConnect, "should_be_non_existing_deadbeef_dir");
760     ok ( bRet == FALSE, "Expected FtpRemoveDirectoryA to fail\n");
761     ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
762         "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
763
764     InternetCloseHandle(hConnect);
765     InternetCloseHandle(hInternet);
766 }
767
768 static void test_renamefile(void)
769 {
770     BOOL      bRet;
771     HINTERNET hInternet, hFtp, hConnect;
772
773     /* Invalid internet handle, the rest are valid parameters */
774     SetLastError(0xdeadbeef);
775     bRet = FtpRenameFileA(NULL , "should_be_non_existing_deadbeef", "new");
776     ok ( bRet == FALSE, "Expected FtpRenameFileA to fail\n");
777     ok ( GetLastError() == ERROR_INVALID_HANDLE,
778         "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
779
780     hInternet = InternetOpen(NULL, 0, NULL, NULL, 0);
781     hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "anonymous", "IEUser@", INTERNET_SERVICE_FTP, 0, 0);
782     if(!hFtp)
783     {
784         skip("No ftp connection could be made to ftp.winehq.org\n");
785         InternetCloseHandle(hInternet);
786         return;
787     }
788
789     /* We should have a ftp-connection, try some renaming */
790
791     /* No 'existing' file */
792     SetLastError(0xdeadbeef);
793     bRet = FtpRenameFileA(hFtp , NULL, "new");
794     ok ( bRet == FALSE, "Expected FtpRenameFileA to fail\n");
795     ok ( GetLastError() == ERROR_INVALID_PARAMETER,
796         "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
797
798     /* No new file */
799     SetLastError(0xdeadbeef);
800     bRet = FtpRenameFileA(hFtp , "should_be_non_existing_deadbeef", NULL);
801     ok ( bRet == FALSE, "Expected FtpRenameFileA to fail\n");
802     ok ( GetLastError() == ERROR_INVALID_PARAMETER,
803         "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
804
805     /* Existing file shouldn't be there */
806     SetLastError(0xdeadbeef);
807     bRet = FtpRenameFileA(hFtp , "should_be_non_existing_deadbeef", "new");
808     ok ( bRet == FALSE, "Expected FtpRenameFileA to fail\n");
809     todo_wine
810     ok ( GetLastError() == ERROR_INTERNET_EXTENDED_ERROR,
811         "Expected ERROR_INTERNET_EXTENDED_ERROR, got %d\n", GetLastError());
812
813     InternetCloseHandle(hFtp);
814
815     /* Http handle-type for ftp connection */
816
817     hConnect = InternetConnect(hInternet, "www.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
818
819     /* One small test to show that handle type is checked before parameters */
820     SetLastError(0xdeadbeef);
821     bRet = FtpRenameFileA(hConnect , "should_be_non_existing_deadbeef", NULL);
822     ok ( bRet == FALSE, "Expected FtpRenameFileA to fail\n");
823     ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
824         "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
825
826     SetLastError(0xdeadbeef);
827     bRet = FtpRenameFileA(hConnect , "should_be_non_existing_deadbeef", "new");
828     ok ( bRet == FALSE, "Expected FtpRenameFileA to fail\n");
829     ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
830         "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got %d\n", GetLastError());
831
832     InternetCloseHandle(hConnect);
833     InternetCloseHandle(hInternet);
834 }
835
836 START_TEST(ftp)
837 {
838     /* The first call should always be a proper InternetOpen, if not
839      * several calls will return ERROR_INTERNET_NOT_INITIALIZED when
840      * all parameters are correct but no session handle is given. Whereas
841      * the same call will return ERROR_INVALID_HANDLE if an InternetOpen
842      * is done before.
843      * The following test will show that behaviour, where the tests inside
844      * the other sub-tests will show the other situation.
845      */
846     test_getfile_no_open();
847     test_connect();
848     test_createdir();
849     test_deletefile();
850     test_getfile();
851     test_openfile();
852     test_putfile();
853     test_removedir();
854     test_renamefile();
855 }