added a few more fsd tests
authorRex Jolliff <rex@lvcablemodem.com>
Tue, 1 May 2001 17:36:04 +0000 (17:36 +0000)
committerRex Jolliff <rex@lvcablemodem.com>
Tue, 1 May 2001 17:36:04 +0000 (17:36 +0000)
svn path=/trunk/; revision=1844

reactos/apps/tests/test_old/testfsd.c

index 018ef0a..e36d6d5 100644 (file)
@@ -1,4 +1,4 @@
-/* $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";
@@ -31,21 +40,28 @@ void  testCreateExistant (void);
 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,
@@ -66,8 +82,6 @@ void  testOpenExistant (void)
 {
   HANDLE  fileHandle;
 
-  tests++;
-
   fileHandle  = CreateFile (rootDir, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
   ASSERT (fileHandle != INVALID_HANDLE_VALUE);
   CloseHandle (fileHandle);
@@ -86,8 +100,6 @@ void  testOpenNonExistant (void)
   DWORD  status;
   HANDLE  fileHandle;
 
-  tests++;
-
   fileHandle  = CreateFile (bogusRootFile, GENERIC_READ, 0, 0, 
                             OPEN_EXISTING, 0, 0);
   ASSERT (fileHandle == INVALID_HANDLE_VALUE);
@@ -119,8 +131,6 @@ void  testCreateExistant (void)
   DWORD  status;
   HANDLE  fileHandle;
 
-  tests++;
-
 printf ("before CreateFile (%s)\n", rootDir);
   fileHandle  = CreateFile (rootDir, GENERIC_READ, 0, 0, 
                             CREATE_NEW, 0, 0);
@@ -146,20 +156,58 @@ printf ("after CreateFile (%s)\n", rootDir);
 
 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)