-/* $Id: testfsd.c,v 1.1 2001/05/01 04:35:08 rex Exp $
+/* $Id: testfsd.c,v 1.2 2001/05/01 17:36:04 rex Exp $
*
* FILE: testFSD.c
* PURPOSE: A test set for the File System Driver
#define ASSERT(x) doAssertion (x, #x, __FUNCTION__, __LINE__)
+struct TestSuite
+{
+ char *name;
+ (void)(*testFunc)(void);
+};
+
+#define ADD_TEST(x) {#x, x}
+#define COUNT_TESTS(x) (sizeof x/sizeof (struct TestSuite))
+
const char *rootDir = "c:\\";
const char *systemRootDir = "c:\\ReactOS";
const char *systemDllDir = "c:\\ReactOS\\System32";
void testCreateNonExistant (void);
void testOverwriteExistant (void);
void testOverwriteNonExistant (void);
+void testOpenWithBlankPathElements (void);
-void testOpenWithBlankPathName (void);
-void testOpenWithBlankDirElement (void);
+struct TestSuite gTests [] =
+{
+ ADD_TEST (testOpenExistant),
+ ADD_TEST (testOpenNonExistant),
+ ADD_TEST (testCreateExistant),
+ ADD_TEST (testCreateNonExistant),
+ ADD_TEST (testOverwriteExistant),
+ ADD_TEST (testOverwriteNonExistant),
+ ADD_TEST (testOpenWithBlankPathElements)
+};
int main (void)
{
tests = assertions = failures = successes = 0;
- testOpenExistant ();
- testOpenNonExistant ();
- testCreateExistant ();
- testCreateNonExistant ();
- testOpenWithBlankPathName ();
- testOpenWithBlankDirElement ();
-// testFullObjectPaths ();
+ for (testIndex = 0; testIndex < COUNT_TESTS(gTests); testIndex++)
+ {
+ gTests [testIndex].testFunc ();
+ tests++;
+ }
printf ("\nTotals: tests: %d assertions: %d successes: %d failures: %d\n",
tests,
{
HANDLE fileHandle;
- tests++;
-
fileHandle = CreateFile (rootDir, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
CloseHandle (fileHandle);
DWORD status;
HANDLE fileHandle;
- tests++;
-
fileHandle = CreateFile (bogusRootFile, GENERIC_READ, 0, 0,
OPEN_EXISTING, 0, 0);
ASSERT (fileHandle == INVALID_HANDLE_VALUE);
DWORD status;
HANDLE fileHandle;
- tests++;
-
printf ("before CreateFile (%s)\n", rootDir);
fileHandle = CreateFile (rootDir, GENERIC_READ, 0, 0,
CREATE_NEW, 0, 0);
void testCreateNonExistant (void)
{
- tests++;
-
-}
+ DWORD status;
+ HANDLE fileHandle;
-void testOpenWithBlankPathName (void)
-{
- tests++;
+ fileHandle = CreateFile (bogusRootFile, GENERIC_READ, 0, 0,
+ CREATE_NEW, 0, 0);
+ ASSERT (fileHandle != INVALID_HANDLE_VALUE);
+ CloseHandle (fileHandle);
+ fileHandle = CreateFile (bogusSystemRootFile, GENERIC_READ, 0, 0,
+ CREATE_NEW, 0, 0);
+ ASSERT (fileHandle != INVALID_HANDLE_VALUE);
+ CloseHandle (fileHandle);
+ fileHandle = CreateFile (bogusSystemDllFile, GENERIC_READ, 0, 0,
+ CREATE_NEW, 0, 0);
+ ASSERT (fileHandle != INVALID_HANDLE_VALUE);
+ CloseHandle (fileHandle);
+#if 0
+ fileHandle = CreateFile (bogusDirAndFile, GENERIC_READ, 0, 0,
+ CREATE_NEW, 0, 0);
+ ASSERT (fileHandle == INVALID_HANDLE_VALUE);
+ status = GetLastError ();
+ ASSERT (status == ERROR_PATH_NOT_FOUND);
+ CloseHandle (fileHandle);
+#endif
}
-void testOpenWithBlankDirElement (void)
+void testOpenWithBlankPathElements (void)
{
- tests++;
+ HANDLE fileHandle;
+ fileHandle = CreateFile ("c:", GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
+ ASSERT (fileHandle != INVALID_HANDLE_VALUE);
+ CloseHandle (fileHandle);
+ fileHandle = CreateFile ("c:\\\\", GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
+ ASSERT (fileHandle != INVALID_HANDLE_VALUE);
+ CloseHandle (fileHandle);
+ fileHandle = CreateFile ("c:\\\\reactos\\", GENERIC_READ, 0, 0,
+ OPEN_EXISTING, 0, 0);
+ ASSERT (fileHandle != INVALID_HANDLE_VALUE);
+ CloseHandle (fileHandle);
+ fileHandle = CreateFile ("c:\\reactos\\\\", GENERIC_READ, 0, 0,
+ OPEN_EXISTING, 0, 0);
+ ASSERT (fileHandle != INVALID_HANDLE_VALUE);
+ CloseHandle (fileHandle);
+ fileHandle = CreateFile ("c:\\reactos\\\\system32\\", GENERIC_READ, 0, 0,
+ OPEN_EXISTING, 0, 0);
+ ASSERT (fileHandle != INVALID_HANDLE_VALUE);
+ CloseHandle (fileHandle);
+ fileHandle = CreateFile ("c:\\reactos\\system32\\\\", GENERIC_READ, 0, 0,
+ OPEN_EXISTING, 0, 0);
+ ASSERT (fileHandle != INVALID_HANDLE_VALUE);
+ CloseHandle (fileHandle);
}
void doAssertion (BOOL pTest, PCHAR pTestText, PCHAR pFunction, int pLine)