ReactOS  0.4.15-dev-1152-g6c94e4f
TunnelCache.c File Reference
#include "precomp.h"
Include dependency graph for TunnelCache.c:

Go to the source code of this file.

Functions

static void Test_VeryLongTests (void)
 
static void Test_LongTests (void)
 
static void Test_ShortTests (void)
 
 START_TEST (TunnelCache)
 

Function Documentation

◆ START_TEST()

START_TEST ( TunnelCache  )

Definition at line 274 of file TunnelCache.c.

275 {
276  Test_ShortTests();
277  Test_LongTests();
279 }
static void Test_ShortTests(void)
Definition: TunnelCache.c:192
static void Test_LongTests(void)
Definition: TunnelCache.c:105
static void Test_VeryLongTests(void)
Definition: TunnelCache.c:12

◆ Test_LongTests()

static void Test_LongTests ( void  )
static

Definition at line 105 of file TunnelCache.c.

106 {
107  UCHAR i = 0;
108  HANDLE hFile;
109  CHAR TestDir[] = "XTestDirTunnelCache";
110  CHAR OldDir[MAX_PATH];
111  FILETIME FileTime, File1Time;
112 
113  /* Create a blank test directory */
114  if (GetCurrentDirectory(MAX_PATH, OldDir) == 0)
115  {
116  win_skip("No test directory available\n");
117  return;
118  }
119 
120  /* Create a blank test directory */
121  for (; i < 10; ++i)
122  {
123  TestDir[0] = '0' + i;
124  if (CreateDirectory(TestDir, NULL))
125  {
126  if (SetCurrentDirectory(TestDir) == 0)
127  {
128  RemoveDirectory(TestDir);
129  win_skip("No test directory available\n");
130  return;
131  }
132 
133  break;
134  }
135  }
136 
137  if (i == 10)
138  {
139  win_skip("No test directory available\n");
140  return;
141  }
142 
143  hFile = CreateFile("file1",
145  0, NULL,
146  CREATE_NEW,
148  NULL);
149  ok(hFile != INVALID_HANDLE_VALUE, "CreateFile() failed\n");
150  ok(GetFileTime(hFile, &FileTime, NULL, NULL) != FALSE, "GetFileTime() failed\n");
152 
153  /* Wait a least 10ms (resolution of FAT) */
154  /* XXX: Increased to 1s for ReactOS... */
155  Sleep(1000);
156 
157  hFile = CreateFile("file2",
159  0, NULL,
160  CREATE_NEW,
162  NULL);
163  ok(hFile != INVALID_HANDLE_VALUE, "CreateFile() failed\n");
165 
166  ok(MoveFile("file1", "file") != FALSE, "MoveFile() failed\n");
167  ok(MoveFile("file2", "file1") != FALSE, "MoveFile() failed\n");
168 
169  hFile = CreateFile("file1",
170  GENERIC_READ,
171  0, NULL,
174  NULL);
175  ok(hFile != INVALID_HANDLE_VALUE, "CreateFile() failed\n");
176  ok(GetFileTime(hFile, &File1Time, NULL, NULL) != FALSE, "GetFileTime() failed\n");
178 
180  ok(RtlCompareMemory(&FileTime, &File1Time, sizeof(FILETIME)) == sizeof(FILETIME), "Tunnel cache failed\n");
181 
182  DeleteFile("file2");
183  DeleteFile("file1");
184  DeleteFile("file");
185 
186  SetCurrentDirectory(OldDir);
187  RemoveDirectory(TestDir);
188 }
#define CloseHandle
Definition: compat.h:487
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
char CHAR
Definition: xmlstorage.h:175
#define RemoveDirectory
Definition: winbase.h:3735
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
#define DeleteFile
Definition: winbase.h:3604
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FALSE
Definition: types.h:117
#define GENERIC_WRITE
Definition: nt_native.h:90
#define GetCurrentDirectory
Definition: winbase.h:3645
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:523
#define MAX_PATH
Definition: compat.h:34
unsigned char UCHAR
Definition: xmlstorage.h:181
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define GENERIC_READ
Definition: compat.h:135
_In_ HANDLE hFile
Definition: mswsock.h:90
#define MoveFile
Definition: winbase.h:3717
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:913
#define ros_skip_flaky
Definition: test.h:166
#define ok(value,...)
Definition: atltest.h:57
#define CREATE_NEW
Definition: disk.h:69
#define win_skip
Definition: test.h:149
BOOL WINAPI GetFileTime(IN HANDLE hFile, OUT LPFILETIME lpCreationTime OPTIONAL, OUT LPFILETIME lpLastAccessTime OPTIONAL, OUT LPFILETIME lpLastWriteTime OPTIONAL)
Definition: fileinfo.c:896
#define SetCurrentDirectory
Definition: winbase.h:3743
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465

Referenced by START_TEST().

◆ Test_ShortTests()

static void Test_ShortTests ( void  )
static

Definition at line 192 of file TunnelCache.c.

193 {
194  UCHAR i = 0;
195  CHAR ShortName[14];
196  HANDLE hFile, hFind;
198  CHAR TestDir[] = "XTestDirTunnelCache";
199  CHAR OldDir[MAX_PATH];
200 
201  /* Create a blank test directory */
202  if (GetCurrentDirectory(MAX_PATH, OldDir) == 0)
203  {
204  win_skip("No test directory available\n");
205  return;
206  }
207 
208  /* Create a blank test directory */
209  for (; i < 10; ++i)
210  {
211  TestDir[0] = '0' + i;
212  if (CreateDirectory(TestDir, NULL))
213  {
214  if (SetCurrentDirectory(TestDir) == 0)
215  {
216  RemoveDirectory(TestDir);
217  win_skip("No test directory available\n");
218  return;
219  }
220 
221  break;
222  }
223  }
224 
225  if (i == 10)
226  {
227  win_skip("No test directory available\n");
228  return;
229  }
230 
231  hFile = CreateFile("verylongfilename",
233  0, NULL,
234  CREATE_NEW,
236  NULL);
237  ok(hFile != INVALID_HANDLE_VALUE, "CreateFile() failed\n");
239 
240  hFind = FindFirstFile("verylongfilename", &FileInfo);
241  ok(hFind != INVALID_HANDLE_VALUE, "FindFirstFile() failed\n");
242  FindClose(hFind);
243  RtlCopyMemory(ShortName, FileInfo.cAlternateFileName, sizeof(ShortName));
244 
245  ok(MoveFile("verylongfilename", "verylongfilename2") != FALSE, "MoveFile() failed\n");
246  hFind = FindFirstFile("verylongfilename2", &FileInfo);
247  ok(hFind != INVALID_HANDLE_VALUE, "FindFirstFile() failed\n");
248  FindClose(hFind);
249  ok(strcmp(FileInfo.cAlternateFileName, ShortName) == 0, "strcmp() failed\n");
250 
251  hFile = CreateFile("randomfilename",
253  0, NULL,
254  CREATE_NEW,
256  NULL);
257  ok(hFile != INVALID_HANDLE_VALUE, "CreateFile() failed\n");
259 
260  ok(MoveFileEx("randomfilename", "verylongfilename2", MOVEFILE_REPLACE_EXISTING) != FALSE, "MoveFile() failed\n");
261  hFind = FindFirstFile("verylongfilename2", &FileInfo);
262  ok(hFind != INVALID_HANDLE_VALUE, "FindFirstFile() failed\n");
263  FindClose(hFind);
264  ok(strcmp(FileInfo.cAlternateFileName, ShortName) == 0, "strcmp() failed\n");
265 
266  DeleteFile("randomfilename");
267  DeleteFile("verylongfilename");
268  DeleteFile("verylongfilename2");
269 
270  SetCurrentDirectory(OldDir);
271  RemoveDirectory(TestDir);
272 }
IN PDCB IN POEM_STRING IN PUNICODE_STRING IN OUT POEM_STRING ShortName
Definition: fatprocs.h:1303
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define CloseHandle
Definition: compat.h:487
#define MOVEFILE_REPLACE_EXISTING
Definition: filesup.h:28
char CHAR
Definition: xmlstorage.h:175
#define RemoveDirectory
Definition: winbase.h:3735
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
#define MoveFileEx
Definition: winbase.h:3718
#define DeleteFile
Definition: winbase.h:3604
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FALSE
Definition: types.h:117
#define GENERIC_WRITE
Definition: nt_native.h:90
#define GetCurrentDirectory
Definition: winbase.h:3645
smooth NULL
Definition: ftsmooth.c:416
#define FindFirstFile
Definition: winbase.h:3622
#define MAX_PATH
Definition: compat.h:34
unsigned char UCHAR
Definition: xmlstorage.h:181
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define GENERIC_READ
Definition: compat.h:135
_In_ HANDLE hFile
Definition: mswsock.h:90
#define MoveFile
Definition: winbase.h:3717
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:913
#define ok(value,...)
Definition: atltest.h:57
struct FileInfo FileInfo
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define CREATE_NEW
Definition: disk.h:69
#define win_skip
Definition: test.h:149
#define SetCurrentDirectory
Definition: winbase.h:3743
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by START_TEST().

◆ Test_VeryLongTests()

static void Test_VeryLongTests ( void  )
static

Definition at line 12 of file TunnelCache.c.

13 {
14  UCHAR i = 0;
15  HANDLE hFile;
16  CHAR TestDir[] = "XTestDirTunnelCache";
17  CHAR OldDir[MAX_PATH];
18  FILETIME FileTime, File1Time;
19 
20  win_skip("Too long, see: ROSTESTS-177\n");
21  return;
22 
23  /* Create a blank test directory */
24  if (GetCurrentDirectory(MAX_PATH, OldDir) == 0)
25  {
26  win_skip("No test directory available\n");
27  return;
28  }
29 
30  /* Create a blank test directory */
31  for (; i < 10; ++i)
32  {
33  TestDir[0] = '0' + i;
34  if (CreateDirectory(TestDir, NULL))
35  {
36  if (SetCurrentDirectory(TestDir) == 0)
37  {
38  RemoveDirectory(TestDir);
39  win_skip("No test directory available\n");
40  return;
41  }
42 
43  break;
44  }
45  }
46 
47  if (i == 10)
48  {
49  win_skip("No test directory available\n");
50  return;
51  }
52 
53  hFile = CreateFile("file1",
55  0, NULL,
56  CREATE_NEW,
58  NULL);
59  ok(hFile != INVALID_HANDLE_VALUE, "CreateFile() failed\n");
60  ok(GetFileTime(hFile, &FileTime, NULL, NULL) != FALSE, "GetFileTime() failed\n");
62 
63  /* Wait a least 10ms (resolution of FAT) */
64  /* XXX: Increased to 1s for ReactOS... */
65  Sleep(1000);
66 
67  hFile = CreateFile("file2",
69  0, NULL,
70  CREATE_NEW,
72  NULL);
73  ok(hFile != INVALID_HANDLE_VALUE, "CreateFile() failed\n");
75 
76  ok(MoveFile("file1", "file") != FALSE, "MoveFile() failed\n");
77  /* Sleep over cache expiry */
78  /* FIXME: Query correct value from registry if it exists:
79  * \HKLM\System\CurrentControlSet\Control\FileSystem\MaximumTunnelEntryAgeInSeconds */
80  Sleep(16000);
81  ok(MoveFile("file2", "file1") != FALSE, "MoveFile() failed\n");
82 
83  hFile = CreateFile("file1",
85  0, NULL,
88  NULL);
89  ok(hFile != INVALID_HANDLE_VALUE, "CreateFile() failed\n");
90  ok(GetFileTime(hFile, &File1Time, NULL, NULL) != FALSE, "GetFileTime() failed\n");
92 
93  ok(RtlCompareMemory(&FileTime, &File1Time, sizeof(FILETIME)) != sizeof(FILETIME), "Tunnel cache still in action?\n");
94 
95  DeleteFile("file2");
96  DeleteFile("file1");
97  DeleteFile("file");
98 
99  SetCurrentDirectory(OldDir);
100  RemoveDirectory(TestDir);
101 }
#define CloseHandle
Definition: compat.h:487
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
char CHAR
Definition: xmlstorage.h:175
#define RemoveDirectory
Definition: winbase.h:3735
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
#define DeleteFile
Definition: winbase.h:3604
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FALSE
Definition: types.h:117
#define GENERIC_WRITE
Definition: nt_native.h:90
#define GetCurrentDirectory
Definition: winbase.h:3645
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:523
#define MAX_PATH
Definition: compat.h:34
unsigned char UCHAR
Definition: xmlstorage.h:181
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define GENERIC_READ
Definition: compat.h:135
_In_ HANDLE hFile
Definition: mswsock.h:90
#define MoveFile
Definition: winbase.h:3717
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:913
#define ok(value,...)
Definition: atltest.h:57
#define CREATE_NEW
Definition: disk.h:69
#define win_skip
Definition: test.h:149
BOOL WINAPI GetFileTime(IN HANDLE hFile, OUT LPFILETIME lpCreationTime OPTIONAL, OUT LPFILETIME lpLastAccessTime OPTIONAL, OUT LPFILETIME lpLastWriteTime OPTIONAL)
Definition: fileinfo.c:896
#define SetCurrentDirectory
Definition: winbase.h:3743
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465

Referenced by START_TEST().