VirtualBox

Ticket #9753: TestVBoxFS.cpp

File TestVBoxFS.cpp, 2.6 KB (added by Kevin Hoffman, 13 years ago)

Source code of test program

Line 
1// TestVBoxFS.cpp : Defines the entry point for the console application.
2//
3
4#include "stdafx.h"
5#include <windows.h>
6#include <string>
7#include <stdio.h>
8
9int _tmain(int argc, _TCHAR* argv[])
10{
11 while(true){
12 for (int i=0; i<1000; i++){
13 fprintf(stderr, "."); fflush(stderr);
14 printf("Testing CreateFile( %s, FILE_FLAG_DELETE_ON_CLOSE)\n", argv[1]);
15 ::SetLastError(0);
16 HANDLE hTest = CreateFile( argv[1], GENERIC_WRITE, FILE_SHARE_DELETE|FILE_SHARE_READ|FILE_SHARE_WRITE, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_DELETE_ON_CLOSE, NULL);
17 if (hTest == INVALID_HANDLE_VALUE){
18 printf("FAILED to open file %s: %08X\n", argv[1], ::GetLastError());
19 printf("===================================================================================================================================================\n");
20 fprintf(stderr, "\n==== E ====\n"); fflush(stderr);
21 } else {
22 printf("Success %08X\n", ::GetLastError());
23 ::CloseHandle(hTest);
24 }
25
26 hTest = INVALID_HANDLE_VALUE;
27 printf("Testing CreateFile( %s, FILE_ATTRIBUTE_NORMAL)\n", argv[1]);
28 hTest = CreateFile( argv[1], GENERIC_WRITE, FILE_SHARE_DELETE|FILE_SHARE_READ|FILE_SHARE_WRITE, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
29 if (hTest == INVALID_HANDLE_VALUE){
30 printf("FAILED to open file %s: %08X\n", argv[1], ::GetLastError());
31 printf("===================================================================================================================================================\n");
32 fprintf(stderr, "\n==== E ====\n"); fflush(stderr);
33 } else {
34 printf("Success %08X\n", ::GetLastError());
35 ::CloseHandle(hTest);
36 }
37
38 BOOL ret = ::DeleteFile( argv[1] );
39 printf("DeleteFile(%s) = %d\n", argv[1], (int)ret);
40 printf("\n");
41 }
42 fprintf(stderr, "\n");
43
44 printf("------------------------------------------------------------------------------------------------\n");
45 printf("------------------------------------------------------------------------------------------------\n");
46 printf("------------------------------------------------------------------------------------------------\n");
47 printf("==== SLEEPING for 5000ms ====\n");
48 fprintf(stderr, "\nSLEEPING for 5000ms\n");
49 Sleep(5000);
50 printf("------------------------------------------------------------------------------------------------\n");
51 printf("------------------------------------------------------------------------------------------------\n");
52 printf("------------------------------------------------------------------------------------------------\n");
53
54 }
55
56 return 0;
57}
58

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy