Index: trunk/psLib/test/psTest.c
===================================================================
--- trunk/psLib/test/psTest.c	(revision 1034)
+++ trunk/psLib/test/psTest.c	(revision 1193)
@@ -15,4 +15,6 @@
 #include <unistd.h>
 #include <sys/wait.h>
+#include <stdbool.h>
+#include <string.h>
 
 #include "psTest.h"
@@ -25,11 +27,103 @@
 #define HEADER_BOTTOM "\\**********************************************************************************/\n\n"
 
-bool p_runTestSuite(FILE *fp, const char* testPointFile, const char* packageName, testDescription tests[])
+bool p_runTestSuite(FILE *fp, const char* testPointFile, const char* packageName,
+                    testDescription tests[], int argc, char * const argv[])
 {
     bool success = true;
-
-    for (int index=0; tests[index].fcn != NULL; index++) {
-        success = p_runTest(fp,testPointFile,packageName,tests[index].testPointName,
-                            tests[index].fcn,tests[index].expectedReturn) && success;
+    bool runAll = true;
+    bool useFork = true;
+    bool found;
+    int c;
+    int n;
+    extern char *optarg;
+
+    if (argc > 0) {
+        while ( (c=getopt(argc,argv,"lhn:dt:")) != -1) {
+            switch (c) {
+            case 'h':
+                printf("Usage: %s [-l] [-d] [-h] [-n=Testpoint#] [-t=TestpointName]\n"
+                       "    where:\n"
+                       "           -l  : lists the testpoints contained in this test driver executable\n"
+                       "           -d  : turns on debugger-friendly mode (no forking, aborts/signals are not handled)\n"
+                       "           -h  : prints this help\n"
+                       "           -n  : specifies a particular testpoint by number to run\n"
+                       "           -t  : specifies a particular testpoint by name to run\n"
+                       "    (if no -l, -n or -t options are given, all testpoints are run)\n",
+                       argv[0]);
+                runAll = false;
+                break;
+            case 'd':
+                useFork = false;
+                break;
+            case 'l':
+                printf("Test Driver:  %s\n",testPointFile);
+                printf("Package Name: %s\n",packageName);
+                printf("Testpoints:\n");
+                runAll = false;
+                for (int index=0; tests[index].fcn != NULL; index++) {
+                    printf("    %6d - %s \n",tests[index].testPointNumber,
+                           tests[index].testPointName);
+                }
+                printf("\n");
+                break;
+            case 't':
+                runAll = false;
+                for (int index=0; tests[index].fcn != NULL; index++) {
+                    if (strcmp(optarg,tests[index].testPointName) == 0) {
+                        success = p_runTest(fp,
+                                            testPointFile,
+                                            packageName,
+                                            tests[index].testPointName,
+                                            tests[index].fcn,
+                                            tests[index].expectedReturn,
+                                            useFork) && success;
+                    }
+                }
+                break;
+            case 'n':
+                runAll = false;
+                if (sscanf(optarg,"%i",&n) != 1) {
+                    psError(__func__,"Failed to parse the testpoint number (%s).",
+                            optarg);
+                    break;
+                }
+                found = false;
+                for (int index=0; tests[index].fcn != NULL; index++) {
+                    if (n==tests[index].testPointNumber) {
+                        found = true;
+                        success = p_runTest(fp,
+                                            testPointFile,
+                                            packageName,
+                                            tests[index].testPointName,
+                                            tests[index].fcn,
+                                            tests[index].expectedReturn,
+                                            useFork) && success;
+                    }
+                }
+                if (! found) {
+                    psError(__func__,"The specified testpoint number (%d) doesn't exist in this test driver.",
+                            n);
+                    break;
+                }
+                break;
+            case '?':
+                psError(__func__,"Option %s is not recognized and is ignored.",optarg);
+                break;
+            }
+        }
+    }
+
+    if (runAll) {
+        for (int index=0; tests[index].fcn != NULL; index++) {
+            if (! tests[index].isDuplicateEntry) {
+                success = p_runTest(fp,
+                                    testPointFile,
+                                    packageName,
+                                    tests[index].testPointName,
+                                    tests[index].fcn,
+                                    tests[index].expectedReturn,
+                                    useFork) && success;
+            }
+        }
     }
     return success;
@@ -37,5 +131,5 @@
 
 bool p_runTest(FILE *fp, const char* testPointFile, const char* packageName, const char* testPointName,
-               testFcn fcn, int expectedReturn)
+               testFcn fcn, int expectedReturn, bool useFork)
 {
     int childReturn = 0;
@@ -44,28 +138,41 @@
     p_printPositiveTestHeader(fp,testPointFile,packageName,testPointName);
 
-    child = fork();
-    if (child == 0) {                   // I am the child process, run the test
+    if (useFork) {
+        child = fork();
+        if (child == 0) {                   // I am the child process, run the test
+            int currentId = psMemGetId();
+            int retVal = fcn();
+            if (retVal == 0) { // only bother checking memory if test executed to end.
+                if (psMemCheckLeaks(currentId,NULL,stderr) != 0) {
+                    psError(__func__,"Memory Leaks Detected");
+                    retVal = 64;
+                }
+                psMemCheckCorruption(1);
+            }
+            exit(retVal);
+        } else if (child < 0) {
+            fprintf(fp,"Couldn't fork a process to run a negative test (%s|%s)",
+                    packageName, testPointName);
+            abort();
+        }
+
+        waitpid(child,&childReturn,0);
+        if (WIFSIGNALED(childReturn)) {
+            childReturn =  -WTERMSIG(childReturn);
+        } else {
+            childReturn = WEXITSTATUS(childReturn);
+        }
+    } else {
         int currentId = psMemGetId();
-        int retVal = fcn();
-        if (retVal == 0) { // only bother checking memory if test executed to end.
+        childReturn = fcn();
+        if (childReturn == 0) { // only bother checking memory if test executed to end.
             if (psMemCheckLeaks(currentId,NULL,stderr) != 0) {
                 psError(__func__,"Memory Leaks Detected");
-                retVal = 64;
+                childReturn = 64;
             }
             psMemCheckCorruption(1);
         }
-        exit(retVal);
-    } else if (child < 0) {
-        fprintf(fp,"Couldn't fork a process to run a negative test (%s|%s)",
-                packageName, testPointName);
-        abort();
-    }
-
-    waitpid(child,&childReturn,0);
-    if (WIFSIGNALED(childReturn)) {
-        childReturn =  -WTERMSIG(childReturn);
-    } else {
-        childReturn = WEXITSTATUS(childReturn);
-    }
+    }
+
 
     if (childReturn != expectedReturn) {
