From dabd23ba77de41e58cb15cd70072e4a4763bae98 Mon Sep 17 00:00:00 2001 From: Rex Jolliff Date: Tue, 1 May 2001 04:35:08 +0000 Subject: [PATCH] added test set for fsd driver svn path=/trunk/; revision=1842 --- reactos/apps/tests/test_old/makefile | 6 +- reactos/apps/tests/test_old/testfsd.c | 179 ++++++++++++++++++++++++++ 2 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 reactos/apps/tests/test_old/testfsd.c diff --git a/reactos/apps/tests/test_old/makefile b/reactos/apps/tests/test_old/makefile index 25d7dda8dcb..f31eb8365e4 100644 --- a/reactos/apps/tests/test_old/makefile +++ b/reactos/apps/tests/test_old/makefile @@ -4,7 +4,7 @@ PATH_TO_TOP = ../.. PROGS= test-stdio tst-printf tstdiomisc bug2 bug3 \ - temptest test-fseek test_rdwr + temptest test-fseek test_rdwr testfsd all: $(PROGS:%=%.exe) @@ -65,4 +65,8 @@ tstdiomisc.exe: tstdiomisc.c $(CC) tstdiomisc.c -lkernel32 -o tstdiomisc.exe $(NM) --numeric-sort tstdiomisc.exe > tstdiomisc.sym +testfsd.exe: testfsd.c + $(CC) testfsd.c -lkernel32 -o testfsd.exe + $(NM) --numeric-sort testfsd.exe > testfsd.sym + include ../../rules.mak diff --git a/reactos/apps/tests/test_old/testfsd.c b/reactos/apps/tests/test_old/testfsd.c new file mode 100644 index 00000000000..018ef0aca7b --- /dev/null +++ b/reactos/apps/tests/test_old/testfsd.c @@ -0,0 +1,179 @@ +/* $Id: testfsd.c,v 1.1 2001/05/01 04:35:08 rex Exp $ + * + * FILE: testFSD.c + * PURPOSE: A test set for the File System Driver + * PROJECT: ReactOS kernel + * COPYRIGHT: See COPYING in the top level directory + * PROGRAMMER: Rex Jolliff (rex@lvcablemodem.com) + * + */ + +#include +#include + +#define ASSERT(x) doAssertion (x, #x, __FUNCTION__, __LINE__) + +const char *rootDir = "c:\\"; +const char *systemRootDir = "c:\\ReactOS"; +const char *systemDllDir = "c:\\ReactOS\\System32"; +const char *bogusRootFile = "c:\\bogus"; +const char *bogusDirAndFile = "c:\\bogus\\bogus"; +const char *bogusSystemRootFile = "c:\\ReactOS\\bogus"; +const char *bogusSystemDllFile = "c:\\ReactOS\\System32\\bogus"; + +int tests, assertions, failures, successes; + +void doAssertion (BOOL pTest, PCHAR pTestText, PCHAR pFunction, int pLine); + +void testOpenExistant (void); +void testOpenNonExistant (void); +void testCreateExistant (void); +void testCreateNonExistant (void); +void testOverwriteExistant (void); +void testOverwriteNonExistant (void); + +void testOpenWithBlankPathName (void); +void testOpenWithBlankDirElement (void); + +int main (void) +{ + tests = assertions = failures = successes = 0; + + testOpenExistant (); + testOpenNonExistant (); + testCreateExistant (); + testCreateNonExistant (); + testOpenWithBlankPathName (); + testOpenWithBlankDirElement (); +// testFullObjectPaths (); + + printf ("\nTotals: tests: %d assertions: %d successes: %d failures: %d\n", + tests, + assertions, + successes, + failures); + if (failures == 0) + { + printf ("\n*** OK ***\n"); + } + else + { + printf ("\n*** FAIL ***\n"); + } +} + +void testOpenExistant (void) +{ + HANDLE fileHandle; + + tests++; + + fileHandle = CreateFile (rootDir, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0); + ASSERT (fileHandle != INVALID_HANDLE_VALUE); + CloseHandle (fileHandle); + fileHandle = CreateFile (systemRootDir, GENERIC_READ, 0, 0, + OPEN_EXISTING, 0, 0); + ASSERT (fileHandle != INVALID_HANDLE_VALUE); + CloseHandle (fileHandle); + fileHandle = CreateFile (systemDllDir, GENERIC_READ, 0, 0, + OPEN_EXISTING, 0, 0); + ASSERT (fileHandle != INVALID_HANDLE_VALUE); + CloseHandle (fileHandle); +} + +void testOpenNonExistant (void) +{ + DWORD status; + HANDLE fileHandle; + + tests++; + + fileHandle = CreateFile (bogusRootFile, GENERIC_READ, 0, 0, + OPEN_EXISTING, 0, 0); + ASSERT (fileHandle == INVALID_HANDLE_VALUE); + status = GetLastError (); + ASSERT (status == ERROR_FILE_NOT_FOUND); + CloseHandle (fileHandle); + fileHandle = CreateFile (bogusDirAndFile, GENERIC_READ, 0, 0, + OPEN_EXISTING, 0, 0); + ASSERT (fileHandle == INVALID_HANDLE_VALUE); + status = GetLastError (); + ASSERT (status == ERROR_PATH_NOT_FOUND); + CloseHandle (fileHandle); + fileHandle = CreateFile (bogusSystemRootFile, GENERIC_READ, 0, 0, + OPEN_EXISTING, 0, 0); + ASSERT (fileHandle == INVALID_HANDLE_VALUE); + status = GetLastError (); + ASSERT (status == ERROR_FILE_NOT_FOUND); + CloseHandle (fileHandle); + fileHandle = CreateFile (bogusSystemDllFile, GENERIC_READ, 0, 0, + OPEN_EXISTING, 0, 0); + ASSERT (fileHandle == INVALID_HANDLE_VALUE); + status = GetLastError (); + ASSERT (status == ERROR_FILE_NOT_FOUND); + CloseHandle (fileHandle); +} + +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); +printf ("after CreateFile (%s)\n", rootDir); + ASSERT (fileHandle == INVALID_HANDLE_VALUE); + status = GetLastError (); + ASSERT (status == ERROR_ALREADY_EXISTS); +printf ("before CreateFile (%s)\n", systemRootDir); + fileHandle = CreateFile (systemRootDir, GENERIC_READ, 0, 0, + CREATE_NEW, 0, 0); +printf ("after CreateFile (%s)\n", rootDir); + ASSERT (fileHandle == INVALID_HANDLE_VALUE); + status = GetLastError (); + ASSERT (status == ERROR_ALREADY_EXISTS); +printf ("before CreateFile (%s)\n", systemDllDir); + fileHandle = CreateFile (systemDllDir, GENERIC_READ, 0, 0, + CREATE_NEW, 0, 0); +printf ("after CreateFile (%s)\n", rootDir); + ASSERT (fileHandle == INVALID_HANDLE_VALUE); + status = GetLastError (); + ASSERT (status == ERROR_ALREADY_EXISTS); +} + +void testCreateNonExistant (void) +{ + tests++; + +} + +void testOpenWithBlankPathName (void) +{ + tests++; + +} + +void testOpenWithBlankDirElement (void) +{ + tests++; + +} + +void doAssertion (BOOL pTest, PCHAR pTestText, PCHAR pFunction, int pLine) +{ + assertions++; + if (!pTest) + { + printf ("%s(%d): assertion \"%s\" failed", pFunction, pLine, pTestText); + failures++; + } + else + { + successes++; + } +} + +