ReactOS 0.4.16-dev-250-g3ecd236
TunnelCache.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Tests for Tunnel Cache
5 * PROGRAMMER: Pierre Schweitzer <pierre.schweitzer@reactos.org>
6 */
7
8#include "precomp.h"
9
10static
11void
13{
14 UCHAR i = 0;
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,
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,
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}
102
103static
104void
106{
107 UCHAR i = 0;
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,
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,
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",
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}
189
190static
191void
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,
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,
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}
273
274START_TEST(TunnelCache)
275{
279}
static void Test_VeryLongTests(void)
Definition: TunnelCache.c:12
static void Test_LongTests(void)
Definition: TunnelCache.c:105
static void Test_ShortTests(void)
Definition: TunnelCache.c:192
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
BOOL WINAPI GetFileTime(IN HANDLE hFile, OUT LPFILETIME lpCreationTime OPTIONAL, OUT LPFILETIME lpLastAccessTime OPTIONAL, OUT LPFILETIME lpLastWriteTime OPTIONAL)
Definition: fileinfo.c:896
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
IN PDCB IN POEM_STRING IN PUNICODE_STRING IN OUT POEM_STRING ShortName
Definition: fatprocs.h:1307
#define MOVEFILE_REPLACE_EXISTING
Definition: filesup.h:28
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 CREATE_NEW
Definition: disk.h:69
_In_ HANDLE hFile
Definition: mswsock.h:90
#define GENERIC_WRITE
Definition: nt_native.h:90
#define ros_skip_flaky
Definition: test.h:180
#define win_skip
Definition: test.h:163
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RemoveDirectory
Definition: winbase.h:3920
#define SetCurrentDirectory
Definition: winbase.h:3928
#define CreateDirectory
Definition: winbase.h:3771
#define MoveFile
Definition: winbase.h:3902
#define DeleteFile
Definition: winbase.h:3789
#define MoveFileEx
Definition: winbase.h:3903
#define FindFirstFile
Definition: winbase.h:3807
#define CreateFile
Definition: winbase.h:3774
#define GetCurrentDirectory
Definition: winbase.h:3830
unsigned char UCHAR
Definition: xmlstorage.h:181
char CHAR
Definition: xmlstorage.h:175