395265 - eliminate libPKIX initialization from all the individual PKIX unit test source files. r=nelson
authoralexei.volkov.bugs%sun.com
Thu, 20 Sep 2007 19:04:01 +0000
changeset 8068 798ee6f3187d9c0c597b502842e7d22b65c95bbe
parent 8067 a9151c8538cfc3cae41be74bb8f97c64fcbc5b48
child 8069 3188546b8941abe45e6bb93eb0899a2f505f3e51
push idunknown
push userunknown
push dateunknown
reviewersnelson
bugs395265
395265 - eliminate libPKIX initialization from all the individual PKIX unit test source files. r=nelson
security/nss/cmd/libpkix/perf/libpkix_buildthreads.c
security/nss/cmd/libpkix/perf/nss_threads.c
security/nss/cmd/libpkix/pkix/certsel/test_certselector.c
security/nss/cmd/libpkix/pkix/certsel/test_comcertselparams.c
security/nss/cmd/libpkix/pkix/checker/test_certchainchecker.c
security/nss/cmd/libpkix/pkix/crlsel/test_comcrlselparams.c
security/nss/cmd/libpkix/pkix/crlsel/test_crlselector.c
security/nss/cmd/libpkix/pkix/params/test_buildparams.c
security/nss/cmd/libpkix/pkix/params/test_procparams.c
security/nss/cmd/libpkix/pkix/params/test_resourcelimits.c
security/nss/cmd/libpkix/pkix/params/test_trustanchor.c
security/nss/cmd/libpkix/pkix/params/test_valparams.c
security/nss/cmd/libpkix/pkix/results/test_buildresult.c
security/nss/cmd/libpkix/pkix/results/test_policynode.c
security/nss/cmd/libpkix/pkix/results/test_valresult.c
security/nss/cmd/libpkix/pkix/results/test_verifynode.c
security/nss/cmd/libpkix/pkix/store/test_store.c
security/nss/cmd/libpkix/pkix/top/test_basicchecker.c
security/nss/cmd/libpkix/pkix/top/test_basicconstraintschecker.c
security/nss/cmd/libpkix/pkix/top/test_buildchain.c
security/nss/cmd/libpkix/pkix/top/test_buildchain_partialchain.c
security/nss/cmd/libpkix/pkix/top/test_buildchain_resourcelimits.c
security/nss/cmd/libpkix/pkix/top/test_buildchain_uchecker.c
security/nss/cmd/libpkix/pkix/top/test_customcrlchecker.c
security/nss/cmd/libpkix/pkix/top/test_defaultcrlchecker2stores.c
security/nss/cmd/libpkix/pkix/top/test_ocsp.c
security/nss/cmd/libpkix/pkix/top/test_policychecker.c
security/nss/cmd/libpkix/pkix/top/test_subjaltnamechecker.c
security/nss/cmd/libpkix/pkix/top/test_validatechain.c
security/nss/cmd/libpkix/pkix/top/test_validatechain_NB.c
security/nss/cmd/libpkix/pkix/top/test_validatechain_bc.c
security/nss/cmd/libpkix/pkix/util/test_error.c
security/nss/cmd/libpkix/pkix/util/test_list.c
security/nss/cmd/libpkix/pkix/util/test_list2.c
security/nss/cmd/libpkix/pkix/util/test_logger.c
security/nss/cmd/libpkix/pkix_pl/module/test_colcertstore.c
security/nss/cmd/libpkix/pkix_pl/module/test_ekuchecker.c
security/nss/cmd/libpkix/pkix_pl/module/test_httpcertstore.c
security/nss/cmd/libpkix/pkix_pl/module/test_pk11certstore.c
security/nss/cmd/libpkix/pkix_pl/module/test_socket.c
security/nss/cmd/libpkix/pkix_pl/pki/test_authorityinfoaccess.c
security/nss/cmd/libpkix/pkix_pl/pki/test_cert.c
security/nss/cmd/libpkix/pkix_pl/pki/test_crl.c
security/nss/cmd/libpkix/pkix_pl/pki/test_crlentry.c
security/nss/cmd/libpkix/pkix_pl/pki/test_date.c
security/nss/cmd/libpkix/pkix_pl/pki/test_generalname.c
security/nss/cmd/libpkix/pkix_pl/pki/test_nameconstraints.c
security/nss/cmd/libpkix/pkix_pl/pki/test_subjectinfoaccess.c
security/nss/cmd/libpkix/pkix_pl/pki/test_x500name.c
security/nss/cmd/libpkix/pkix_pl/system/stress_test.c
security/nss/cmd/libpkix/pkix_pl/system/test_bigint.c
security/nss/cmd/libpkix/pkix_pl/system/test_bytearray.c
security/nss/cmd/libpkix/pkix_pl/system/test_hashtable.c
security/nss/cmd/libpkix/pkix_pl/system/test_mem.c
security/nss/cmd/libpkix/pkix_pl/system/test_monitorlock.c
security/nss/cmd/libpkix/pkix_pl/system/test_mutex.c
security/nss/cmd/libpkix/pkix_pl/system/test_mutex2.c
security/nss/cmd/libpkix/pkix_pl/system/test_mutex3.c
security/nss/cmd/libpkix/pkix_pl/system/test_object.c
security/nss/cmd/libpkix/pkix_pl/system/test_oid.c
security/nss/cmd/libpkix/pkix_pl/system/test_rwlock.c
security/nss/cmd/libpkix/pkix_pl/system/test_string.c
security/nss/cmd/libpkix/pkix_pl/system/test_string2.c
security/nss/cmd/libpkix/pkixutil/pkixutil.c
security/nss/cmd/libpkix/sample_apps/validate_chain.c
security/nss/cmd/libpkix/testutil/testutil.h
security/nss/tests/libpkix/pkix_pl_tests/module/runPLTests.sh
security/nss/tests/libpkix/pkix_tests/top/runTests.sh
security/nss/tests/libpkix/sample_apps/runPerf.sh
--- a/security/nss/cmd/libpkix/perf/libpkix_buildthreads.c
+++ b/security/nss/cmd/libpkix/perf/libpkix_buildthreads.c
@@ -307,18 +307,18 @@ Test(
 static void finish(char* message, int code)
 {
         (void) printf(message);
         exit(code);
 }
 
 static void usage(char* progname)
 {
-        (void) printf("Usage : %s <duration> <threads> <anchorNickname> "
-                "<eecertNickname>\n\n", progname);
+        (void) printf("Usage : %s <-d certStoreDirectory> <duration> <threads> "
+                      "<anchorNickname> <eecertNickname>\n\n", progname);
         finish("", 0);
 }
 
 int
 libpkix_buildthreads(int argc, char** argv)
 {
         CERTCertDBHandle *handle = NULL;
         CERTCertificate* eecert = NULL;
@@ -338,25 +338,18 @@ libpkix_buildthreads(int argc, char** ar
                 {
                         duration = PR_SecondsToInterval(atoi(argv[1]));
                 }
         if (atoi(argv[2]) > 0)
                 {
                         threads = atoi(argv[2]);
                 }
 
-        PKIX_Initialize_SetConfigDir(PKIX_STORE_TYPE_PK11, ".", plContext);
-
-        PKIX_Initialize(PKIX_TRUE, /* nssInitNeeded */
-                        PKIX_FALSE, /* useArenas */
-                        PKIX_MAJOR_VERSION,
-                        PKIX_MINOR_VERSION,
-                        PKIX_MINOR_VERSION,
-                        &actualMinorVersion,
-                        &plContext);
+        PKIX_PL_NssContext_Create(certificateUsageEmailSigner, PKIX_FALSE,
+                                  NULL, &plContext);
 
         handle = CERT_GetDefaultCertDB();
         PR_ASSERT(handle);
 
 #ifdef PKIX_LOGGER_ON
 
         /* set logger to log trace and up */
         PKIX_SetLoggers(NULL, plContext);
--- a/security/nss/cmd/libpkix/perf/nss_threads.c
+++ b/security/nss/cmd/libpkix/perf/nss_threads.c
@@ -177,22 +177,17 @@ int nss_threads(int argc, char** argv)
         if (atoi(argv[1]) > 0)
                 {
                         duration = PR_SecondsToInterval(atoi(argv[1]));
                 }
         if (atoi(argv[2]) > 0)
                 {
                         threads = atoi(argv[2]);
                 }
-        rv = NSS_Initialize(".", "", "",
-                            "secmod.db", NSS_INIT_READONLY);
-        if (SECSuccess != rv)
-                {
-                        finish("Unable to initialize NSS.\n", 1);
-                }
+
         handle = CERT_GetDefaultCertDB();
         PR_ASSERT(handle);
         cert = CERT_FindCertByNicknameOrEmailAddr(handle, argv[3]);
         if (!cert)
                 {
                         finish("Unable to find certificate.\n", 1);
                 }
         Test(cert, duration, threads);
--- a/security/nss/cmd/libpkix/pkix/certsel/test_certselector.c
+++ b/security/nss/cmd/libpkix/pkix/certsel/test_certselector.c
@@ -1822,32 +1822,23 @@ int test_certselector(int argc, char *ar
         PKIX_PL_Cert *cert = NULL;
         PKIX_PL_Cert *policy1Cert = NULL;
         PKIX_PL_Cert *policy2Cert = NULL;
         PKIX_PL_Cert *anyPolicyCert = NULL;
         PKIX_PL_Cert *subjectCert = NULL;
         PKIX_ComCertSelParams *selParams = NULL;
         char *certDir = NULL;
         char *dirName = NULL;
-        PKIX_Boolean useArenas = PKIX_FALSE;
 
         PKIX_TEST_STD_VARS();
 
         startTests("CertSelector");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         if (argc < 3) {
                 printUsage();
                 return (0);
         }
 
         dirName = argv[j+1];
         certDir = argv[j+3];
--- a/security/nss/cmd/libpkix/pkix/certsel/test_comcertselparams.c
+++ b/security/nss/cmd/libpkix/pkix/certsel/test_comcertselparams.c
@@ -745,37 +745,28 @@ int test_comcertselparams(int argc, char
         PKIX_List *cert2Policies = NULL; /* OIDs */
 
         PKIX_PL_Date *testDate = NULL;
         PKIX_PL_Date *goodDate = NULL;
         PKIX_PL_Date *equalDate = NULL;
         PKIX_PL_String *stringRep = NULL;
         char *asciiRep = NULL;
         char *dirName = NULL;
-        PKIX_Boolean useArenas = PKIX_FALSE;
 
         PKIX_TEST_STD_VARS();
 
         if (argc < 2) {
                 printUsage();
                 return (0);
         }
 
         startTests("ComCertSelParams");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                (PKIX_TRUE, /* nssInitNeeded */
-                useArenas,
-                PKIX_MAJOR_VERSION,
-                PKIX_MINOR_VERSION,
-                PKIX_MINOR_VERSION,
-                &actualMinorVersion,
-                &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         dirName = argv[j+1];
 
         asciiRep = "050501000000Z";
 
         PKIX_TEST_EXPECT_NO_ERROR
                 (PKIX_PL_String_Create
                 (PKIX_ESCASCII, asciiRep, 0, &stringRep, plContext));
--- a/security/nss/cmd/libpkix/pkix/checker/test_certchainchecker.c
+++ b/security/nss/cmd/libpkix/pkix/checker/test_certchainchecker.c
@@ -162,32 +162,23 @@ int test_certchainchecker(int argc, char
         PKIX_PL_OID *cpOID = NULL;
         PKIX_PL_OID *pmOID = NULL;
         PKIX_PL_OID *pcOID = NULL;
         PKIX_PL_OID *iaOID = NULL;
         PKIX_CertChainChecker *dummyChecker = NULL;
         PKIX_List *supportedExtensions = NULL;
         PKIX_PL_Object *initialState = NULL;
         PKIX_UInt32 j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
 
         PKIX_TEST_STD_VARS();
 
         startTests("CertChainChecker");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_Create
                 (&supportedExtensions, plContext));
 
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_OID_Create
                 (PKIX_BASICCONSTRAINTS_OID, &bcOID, plContext));
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_AppendItem
                 (supportedExtensions, (PKIX_PL_Object *)bcOID, plContext));
--- a/security/nss/cmd/libpkix/pkix/crlsel/test_comcrlselparams.c
+++ b/security/nss/cmd/libpkix/pkix/crlsel/test_comcrlselparams.c
@@ -411,32 +411,23 @@ void printUsage(char *pName){
 int test_comcrlselparams(int argc, char *argv[]){
 
         char *dataCentralDir = NULL;
         char *goodInput = "yassir2yassir";
         PKIX_ComCRLSelParams *goodObject = NULL;
         PKIX_ComCRLSelParams *diffObject = NULL;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
 
         PKIX_TEST_STD_VARS();
 
         startTests("ComCRLSelParams");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         if (argc < 2){
                 printUsage(argv[0]);
                 return (0);
         }
 
         dataCentralDir = argv[j+1];
 
--- a/security/nss/cmd/libpkix/pkix/crlsel/test_crlselector.c
+++ b/security/nss/cmd/libpkix/pkix/crlsel/test_crlselector.c
@@ -146,33 +146,24 @@ cleanup:
 
 int test_crlselector(int argc, char *argv[]){
 
         PKIX_PL_Date *context = NULL;
         PKIX_CRLSelector *goodObject = NULL;
         PKIX_CRLSelector *diffObject = NULL;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         char *asciiDate = "040329134847Z";
 
         PKIX_TEST_STD_VARS();
 
         startTests("CRLSelector");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         context = createDate(asciiDate, plContext);
 
         subTest("PKIX_CRLSelector_Create");
 
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_CRLSelector_Create
                                     (NULL,
                                     (PKIX_PL_Object *)context,
--- a/security/nss/cmd/libpkix/pkix/params/test_buildparams.c
+++ b/security/nss/cmd/libpkix/pkix/params/test_buildparams.c
@@ -101,17 +101,16 @@ void printUsage(char *pName){
 
 int test_buildparams(int argc, char *argv[]) {
 
         PKIX_BuildParams *goodObject = NULL;
         PKIX_BuildParams *equalObject = NULL;
         PKIX_BuildParams *diffObject = NULL;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
-	PKIX_Boolean useArenas = PKIX_FALSE;
 
         char *dataCentralDir = NULL;
         char *goodInput = "yassir2yassir";
         char *diffInput = "yassir2bcn";
 
         char *expectedAscii =
                 "[\n"
                 "\tProcessing Params: \n"
@@ -145,26 +144,18 @@ int test_buildparams(int argc, char *arg
                 "\n"
                 "\t********END PROCESSING PARAMS********\n"
                 "]\n";
 
         PKIX_TEST_STD_VARS();
 
         startTests("BuildParams");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         if (argc < 2){
                 printUsage(argv[0]);
                 return (0);
         }
 
         dataCentralDir = argv[j+1];
 
--- a/security/nss/cmd/libpkix/pkix/params/test_procparams.c
+++ b/security/nss/cmd/libpkix/pkix/params/test_procparams.c
@@ -428,17 +428,16 @@ void printUsage(char *pName){
 int test_procparams(int argc, char *argv[]) {
 
         PKIX_ProcessingParams *goodObject = NULL;
         PKIX_ProcessingParams *equalObject = NULL;
         PKIX_ProcessingParams *diffObject = NULL;
         PKIX_UInt32 actualMinorVersion;
         char *dataCentralDir = NULL;
         PKIX_UInt32 j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
 
         char *oidAnyPolicy = PKIX_CERTIFICATEPOLICIES_ANYPOLICY_OID;
         char *oidNist1Policy = "2.16.840.1.101.3.2.1.48.2";
 
         char *goodInput = "yassir2yassir";
         char *diffInput = "yassir2bcn";
 
         char *expectedAscii =
@@ -471,26 +470,18 @@ int test_procparams(int argc, char *argv
                 "]\n\n"
                 "\tCRL Checking Enabled:  0\n"
                 "]\n";
 
         PKIX_TEST_STD_VARS();
 
         startTests("ProcessingParams");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         if (argc < 2){
                 printUsage(argv[0]);
                 return (0);
         }
 
         dataCentralDir = argv[j+1];
 
--- a/security/nss/cmd/libpkix/pkix/params/test_resourcelimits.c
+++ b/security/nss/cmd/libpkix/pkix/params/test_resourcelimits.c
@@ -68,38 +68,29 @@ int test_resourcelimits(int argc, char *
         PKIX_ResourceLimits *goodObject = NULL;
         PKIX_ResourceLimits *equalObject = NULL;
         PKIX_ResourceLimits *diffObject = NULL;
         PKIX_UInt32 maxTime = 0;
         PKIX_UInt32 maxFanout = 0;
         PKIX_UInt32 maxDepth = 0;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         char *expectedAscii =
                 "[\n"
                 "\tMaxTime:           		10\n"
                 "\tMaxFanout:         		5\n"
                 "\tMaxDepth:         		5\n"
                 "]\n";
 
         PKIX_TEST_STD_VARS();
 
         startTests("ResourceLimits");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         subTest("PKIX_ResourceLimits_Create");
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_ResourceLimits_Create
                                   (&goodObject, plContext));
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_ResourceLimits_Create
                                   (&diffObject, plContext));
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_ResourceLimits_Create
                                   (&equalObject, plContext));
--- a/security/nss/cmd/libpkix/pkix/params/test_trustanchor.c
+++ b/security/nss/cmd/libpkix/pkix/params/test_trustanchor.c
@@ -222,17 +222,16 @@ void printUsage(void) {
 
 int test_trustanchor(int argc, char *argv[]) {
 
         PKIX_TrustAnchor *goodObject = NULL;
         PKIX_TrustAnchor *equalObject = NULL;
         PKIX_TrustAnchor *diffObject = NULL;
         PKIX_PL_Cert *diffCert = NULL;
         PKIX_UInt32 actualMinorVersion;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_UInt32 j = 0;
 
         char *goodInput = "yassir2yassir";
         char *expectedAscii =
                 "[\n"
                 "\tTrusted CA Name:         "
                 "CN=yassir,OU=bcn,OU=east,O=sun,C=us\n"
                 "\tTrusted CA PublicKey:    ANSI X9.57 DSA Signature\n"
@@ -240,26 +239,18 @@ int test_trustanchor(int argc, char *arg
                 "]\n";
         char *dirName = NULL;
         char *dataCentralDir = NULL;
 
         PKIX_TEST_STD_VARS();
 
         startTests("TrustAnchor");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         if (argc < 3) {
                 printUsage();
                 return (0);
         }
 
         dirName = argv[j+1];
         dataCentralDir = argv[j+2];
--- a/security/nss/cmd/libpkix/pkix/params/test_valparams.c
+++ b/security/nss/cmd/libpkix/pkix/params/test_valparams.c
@@ -135,17 +135,16 @@ int test_valparams(int argc, char *argv[
 
         PKIX_ValidateParams *goodObject = NULL;
         PKIX_ValidateParams *equalObject = NULL;
         PKIX_ValidateParams *diffObject = NULL;
         PKIX_List *chain = NULL;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
         char *dirName = NULL;
-        PKIX_Boolean useArenas = PKIX_FALSE;
 
         char *goodInput = "yassir2yassir";
         char *diffInput = "yassir2bcn";
 
         char *expectedAscii =
                 "[\n"
                 "\tProcessing Params: \n"
                 "\t********BEGIN PROCESSING PARAMS********\n"
@@ -221,26 +220,18 @@ int test_valparams(int argc, char *argv[
                 "]\n"
                 ")\n"
                 "]\n";
 
         PKIX_TEST_STD_VARS();
 
         startTests("ValidateParams");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         if (argc < 2){
                 printUsage(argv[0]);
                 return (0);
         }
 
         dirName = argv[j+1];
 
--- a/security/nss/cmd/libpkix/pkix/results/test_buildresult.c
+++ b/security/nss/cmd/libpkix/pkix/results/test_buildresult.c
@@ -133,17 +133,16 @@ void printUsage(char *pName){
 int test_buildresult(int argc, char *argv[]) {
 
         PKIX_BuildResult *goodObject = NULL;
         PKIX_BuildResult *equalObject = NULL;
         PKIX_BuildResult *diffObject = NULL;
         PKIX_UInt32 actualMinorVersion;
         char *dirName = NULL;
 	PKIX_UInt32 j = 0;
-	PKIX_Boolean useArenas = PKIX_FALSE;
 
         char *goodInput = "yassir2yassir";
         char *diffInput = "yassir2bcn";
 
         char *expectedAscii =
                 "[\n"
                 "\tValidateResult: \t\t"
                 "[\n"
@@ -203,26 +202,18 @@ int test_buildresult(int argc, char *arg
                 "]\n"
                 ")\n"
                 "]\n";
 
         PKIX_TEST_STD_VARS();
 
         startTests("BuildResult");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         if (argc < 2){
                 printUsage(argv[0]);
                 return (0);
         }
 
         dirName = argv[j+1];
 
--- a/security/nss/cmd/libpkix/pkix/results/test_policynode.c
+++ b/security/nss/cmd/libpkix/pkix/results/test_policynode.c
@@ -495,38 +495,29 @@ int test_policynode(int argc, char *argv
                 " 6F 6E 6C 79]),Critical,(2.16.840.1.101.3.2.1.48.1),1}\n"
                 ". . {2.16.840.1.101.3.2.1.48.1,(EMPTY),Not Critical,"
                 "(2.16.840.1.101.3.2.1.48.1),2}\n"
                 ". . . {2.16.840.1.101.3.2.1.48.1,{},Critical,(2.16.84"
                 "0.1.101.3.2.1.48.1),3}";
 
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         char *dirName = NULL;
 
         PKIX_TEST_STD_VARS();
 
         if (argc < 2) {
                 printUsage();
                 return (0);
         }
 
         startTests("PolicyNode");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                (PKIX_TRUE, /* nssInitNeeded */
-                useArenas,
-                PKIX_MAJOR_VERSION,
-                PKIX_MINOR_VERSION,
-                PKIX_MINOR_VERSION,
-                &actualMinorVersion,
-                &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         dirName = argv[j+1];
 
         subTest("Creating OID objects");
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_OID_Create
                 (asciiAnyPolicy, &oidAnyPolicy, plContext));
 
         /* Read certificates to get real policies, qualifiers */
--- a/security/nss/cmd/libpkix/pkix/results/test_valresult.c
+++ b/security/nss/cmd/libpkix/pkix/results/test_valresult.c
@@ -167,17 +167,16 @@ void printUsage(char *pName){
 
 int test_valresult(int argc, char *argv[]) {
 
         PKIX_ValidateResult *goodObject = NULL;
         PKIX_ValidateResult *equalObject = NULL;
         PKIX_ValidateResult *diffObject = NULL;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
 
         char *goodInput = "yassir2yassir";
         char *diffInput = "yassir2bcn";
         char *dirName = NULL;
 
         char *expectedAscii =
                 "[\n"
                 "\tTrustAnchor: \t\t"
@@ -191,26 +190,18 @@ int test_valresult(int argc, char *argv[
                 "ANSI X9.57 DSA Signature\n"
                 "\tPolicyTree:  \t\t(null)\n"
                 "]\n";
 
         PKIX_TEST_STD_VARS();
 
         startTests("ValidateResult");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         if (argc < 2){
                 printUsage(argv[0]);
                 return (0);
         }
 
         dirName = argv[j+1];
 
--- a/security/nss/cmd/libpkix/pkix/results/test_verifynode.c
+++ b/security/nss/cmd/libpkix/pkix/results/test_verifynode.c
@@ -61,17 +61,16 @@ int test_verifynode(int argc, char *argv
 	PKIX_PL_Cert *cert3 = NULL;
         PKIX_VerifyNode *parentNode = NULL;
         PKIX_VerifyNode *childNode = NULL;
         PKIX_VerifyNode *grandChildNode = NULL;
         PKIX_PL_String *parentString = NULL;
 
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         char *dirName = NULL;
 	char *twoNodeAscii = "CERT[Issuer:CN=Trust Anchor,O=Test Cert"
 		"ificates,C=US, Subject:CN=Trust Anchor,O=Test Certif"
 		"icates,C=US], depth=0, error=(null)\n. CERT[Issuer:C"
 		"N=Trust Anchor,O=Test Certificates,C=US, Subject:CN="
 		"Good CA,O=Test Certificates,C=US], depth=1, error=(null)";
 	char *threeNodeAscii = "CERT[Issuer:CN=Trust Anchor,O=Test Ce"
 		"rtificates,C=US, Subject:CN=Trust Anchor,O=Test Cert"
@@ -86,26 +85,18 @@ int test_verifynode(int argc, char *argv
 
         if (argc < 3) {
                 printUsage();
                 return (0);
         }
 
         startTests("VerifyNode");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                (PKIX_TRUE, /* nssInitNeeded */
-                useArenas,
-                PKIX_MAJOR_VERSION,
-                PKIX_MINOR_VERSION,
-                PKIX_MINOR_VERSION,
-                &actualMinorVersion,
-                &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         dirName = argv[++j];
 
         subTest("Creating Certs");
 
         cert1 = createCert
                 (dirName, argv[++j], plContext);
 
--- a/security/nss/cmd/libpkix/pkix/store/test_store.c
+++ b/security/nss/cmd/libpkix/pkix/store/test_store.c
@@ -189,31 +189,22 @@ void printUsage(char *pName){
 /* Functional tests for CertStore public functions */
 
 int test_store(int argc, char *argv[]) {
 
         char *platformDir = NULL;
         char *dataDir = NULL;
         char *combinedDir = NULL;
         PKIX_UInt32 actualMinorVersion;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_UInt32 j = 0;
 
         PKIX_TEST_STD_VARS();
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         if (argc < (3 + j)) {
                 printUsage(argv[0]);
                 return (0);
         }
 
         startTests(argv[1 + j]);
 
--- a/security/nss/cmd/libpkix/pkix/top/test_basicchecker.c
+++ b/security/nss/cmd/libpkix/pkix/top/test_basicchecker.c
@@ -227,33 +227,24 @@ void printUsage(char *pName){
 
 int test_basicchecker(int argc, char *argv[]) {
 
         char *goodInput = "yassir2yassir";
         char *diffInput = "yassir2bcn";
         char *dateAscii = "991201000000Z";
         char *dirName = NULL;
         PKIX_UInt32 j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_UInt32 actualMinorVersion;
 
         PKIX_TEST_STD_VARS();
 
         startTests("SignatureChecker");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         if (argc < 2){
                 printUsage(argv[0]);
                 return (0);
         }
 
         dirName = argv[j+1];
 
--- a/security/nss/cmd/libpkix/pkix/top/test_basicconstraintschecker.c
+++ b/security/nss/cmd/libpkix/pkix/top/test_basicconstraintschecker.c
@@ -68,39 +68,30 @@ int test_basicconstraintschecker(int arg
         PKIX_UInt32 actualMinorVersion;
         char *certNames[PKIX_TEST_MAX_CERTS];
         PKIX_PL_Cert *certs[PKIX_TEST_MAX_CERTS];
 	PKIX_VerifyNode *verifyTree = NULL;
 	PKIX_PL_String *verifyString = NULL;
         PKIX_UInt32 chainLength = 0;
         PKIX_UInt32 i = 0;
         PKIX_UInt32 j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_Boolean testValid = PKIX_FALSE;
         char *dirName = NULL;
 
         PKIX_TEST_STD_VARS();
 
         if (argc < 4){
                 printUsage1(argv[0]);
                 return (0);
         }
 
         startTests("BasicConstraintsChecker");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         /* ENE = expect no error; EE = expect error */
         if (PORT_Strcmp(argv[2+j], "ENE") == 0) {
                 testValid = PKIX_TRUE;
         } else if (PORT_Strcmp(argv[2+j], "EE") == 0) {
                 testValid = PKIX_FALSE;
         } else {
                 printUsage1(argv[0]);
--- a/security/nss/cmd/libpkix/pkix/top/test_buildchain.c
+++ b/security/nss/cmd/libpkix/pkix/top/test_buildchain.c
@@ -146,17 +146,16 @@ int test_buildchain(int argc, char *argv
         PKIX_CertStore *ldapCertStore = NULL;
         PRIntervalTime timeout = PR_INTERVAL_NO_TIMEOUT; /* blocking */
         /* PRIntervalTime timeout = PR_INTERVAL_NO_WAIT; =0 for non-blocking */
         PKIX_CertStore *certStore = NULL;
         PKIX_List *certStores = NULL;
         PKIX_List *revCheckers = NULL;
         char * asciiResult = NULL;
         PKIX_Boolean result = PKIX_FALSE;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_Boolean testValid = PKIX_TRUE;
         PKIX_List *expectedCerts = NULL;
         PKIX_PL_Cert *dirCert = NULL;
 	PKIX_VerifyNode *verifyTree = NULL;
 	PKIX_PL_String *verifyString = NULL;
         PKIX_PL_String *actualCertsString = NULL;
         PKIX_PL_String *expectedCertsString = NULL;
         void *state = NULL;
@@ -168,26 +167,18 @@ int test_buildchain(int argc, char *argv
 
         if (argc < 5) {
                 printUsage();
                 return (0);
         }
 
         startTests("BuildChain");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         /*
          * arguments:
          * [optional] -arenas
          * [optional] usebind
          *            servername or servername:port ( - for no server)
          *            testname
          *            EE or ENE
--- a/security/nss/cmd/libpkix/pkix/top/test_buildchain_partialchain.c
+++ b/security/nss/cmd/libpkix/pkix/top/test_buildchain_partialchain.c
@@ -695,17 +695,16 @@ cleanup:
 
 }
 
 int test_buildchain_partialchain(int argc, char *argv[])
 {
         PKIX_UInt32 actualMinorVersion = 0;
         PKIX_UInt32 j = 0;
         PKIX_UInt32 k = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_Boolean ene = PKIX_TRUE; /* expect no error */
         PKIX_List *listOfCerts = NULL;
         PKIX_List *certStores = NULL;
         PKIX_PL_Cert *dirCert = NULL;
         PKIX_PL_Cert *trusted = NULL;
         PKIX_PL_Cert *target = NULL;
         PKIX_CertStore *ldapCertStore = NULL;
         PKIX_CertStore *certStore = NULL;
@@ -719,26 +718,18 @@ int test_buildchain_partialchain(int arg
 
         if (argc < 5) {
                 printUsage();
                 return (0);
         }
 
         startTests("BuildChain");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         /*
          * arguments:
          * [optional] -arenas
          * [optional] usebind
          *            servername or servername:port ( - for no server)
          *            testname
          *            EE or ENE
--- a/security/nss/cmd/libpkix/pkix/top/test_buildchain_resourcelimits.c
+++ b/security/nss/cmd/libpkix/pkix/top/test_buildchain_resourcelimits.c
@@ -279,40 +279,31 @@ int test_buildchain_resourcelimits(int a
         PKIX_UInt32 actualMinorVersion = 0;
         PKIX_UInt32 j = 0;
         PKIX_UInt32 k = 0;
         PKIX_CertStore *ldapCertStore = NULL;
         PRIntervalTime timeout = 0; /* 0 for non-blocking */
         PKIX_CertStore *certStore = NULL;
         PKIX_List *certStores = NULL;
         PKIX_List *expectedCerts = NULL;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_Boolean testValid = PKIX_FALSE;
         PKIX_Boolean usebind = PKIX_FALSE;
         PKIX_Boolean useLDAP = PKIX_FALSE;
 
         PKIX_TEST_STD_VARS();
 
         if (argc < 5){
                 printUsage();
                 return (0);
         }
 
         startTests("BuildChain_ResourceLimits");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         /*
          * arguments:
          * [optional] -arenas
          * [optional] usebind
          *            servername or servername:port ( - for no server)
          *            testname
          *            EE or ENE
--- a/security/nss/cmd/libpkix/pkix/top/test_buildchain_uchecker.c
+++ b/security/nss/cmd/libpkix/pkix/top/test_buildchain_uchecker.c
@@ -110,37 +110,28 @@ int test_buildchain_uchecker(int argc, c
         PKIX_PL_Cert *dirCert = NULL;
         PKIX_PL_String *actualCertsString = NULL;
         PKIX_PL_String *expectedCertsString = NULL;
         char *actualCertsAscii = NULL;
         char *expectedCertsAscii = NULL;
         char *oidString = NULL;
         void *buildState = NULL; /* needed by pkix_build for non-blocking I/O */
         void *nbioContext = NULL; /* needed by pkix_build for non-blocking I/O */
-        PKIX_Boolean useArenas = PKIX_FALSE;
 
         PKIX_TEST_STD_VARS();
 
         if (argc < 5){
                 printUsage();
                 return (0);
         }
 
         startTests("BuildChain_UserChecker");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         /* ENE = expect no error; EE = expect error */
         if (PORT_Strcmp(argv[2+j], "ENE") == 0) {
                 testValid = PKIX_TRUE;
         } else if (PORT_Strcmp(argv[2+j], "EE") == 0) {
                 testValid = PKIX_FALSE;
         } else {
                 printUsage();
--- a/security/nss/cmd/libpkix/pkix/top/test_customcrlchecker.c
+++ b/security/nss/cmd/libpkix/pkix/top/test_customcrlchecker.c
@@ -399,38 +399,29 @@ int test_customcrlchecker(int argc, char
         char *certNames[PKIX_TEST_MAX_CERTS];
         PKIX_PL_Cert *certs[PKIX_TEST_MAX_CERTS];
 	PKIX_VerifyNode *verifyTree = NULL;
 	PKIX_PL_String *verifyString = NULL;
         PKIX_UInt32 chainLength = 0;
         PKIX_UInt32 i = 0;
         PKIX_UInt32 j = 0;
         PKIX_Boolean testValid = PKIX_TRUE;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         char *anchorName = NULL;
 
         PKIX_TEST_STD_VARS();
 
         if (argc < 5) {
                 printUsage1(argv[0]);
                 return (0);
         }
 
         startTests("CRL Checker");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         /* ENE = expect no error; EE = expect error */
         if (PORT_Strcmp(argv[2+j], "ENE") == 0) {
                 testValid = PKIX_TRUE;
         } else if (PORT_Strcmp(argv[2+j], "EE") == 0) {
                 testValid = PKIX_FALSE;
         } else {
                 printUsage1(argv[0]);
--- a/security/nss/cmd/libpkix/pkix/top/test_defaultcrlchecker2stores.c
+++ b/security/nss/cmd/libpkix/pkix/top/test_defaultcrlchecker2stores.c
@@ -167,39 +167,30 @@ int test_defaultcrlchecker2stores(int ar
         char *certNames[PKIX_TEST_MAX_CERTS];
         PKIX_PL_Cert *certs[PKIX_TEST_MAX_CERTS];
 	PKIX_VerifyNode *verifyTree = NULL;
 	PKIX_PL_String *verifyString = NULL;
         PKIX_UInt32 chainLength = 0;
         PKIX_UInt32 i = 0;
         PKIX_UInt32 j = 0;
         PKIX_Boolean testValid = PKIX_TRUE;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         char *dirName = NULL;
         char *anchorName = NULL;
 
         PKIX_TEST_STD_VARS();
 
         if (argc < 6) {
                 printUsage1(argv[0]);
                 return (0);
         }
 
         startTests("CRL Checker");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         /* ENE = expect no error; EE = expect error */
         if (PORT_Strcmp(argv[2+j], "ENE") == 0) {
                 testValid = PKIX_TRUE;
         } else if (PORT_Strcmp(argv[2+j], "EE") == 0) {
                 testValid = PKIX_FALSE;
         } else {
                 printUsage1(argv[0]);
--- a/security/nss/cmd/libpkix/pkix/top/test_ocsp.c
+++ b/security/nss/cmd/libpkix/pkix/top/test_ocsp.c
@@ -43,22 +43,24 @@
 
 #include "testutil.h"
 #include "testutil_nss.h"
 
 static void *plContext = NULL;
 
 static
 void printUsage(void){
-        (void) printf("\nUSAGE:\nOcspChecker TestName [ENE|EE] "
-                    "<certStoreDirectory> <trustedCert> <targetCert>\n\n");
+        (void) printf("\nUSAGE:\nOcspChecker -d <certStoreDirectory> TestName "
+                      "[ENE|EE] <certLocationDirectory> <trustedCert> "
+                      "<targetCert>\n\n");
         (void) printf
                 ("Validates a chain of certificates between "
                 "<trustedCert> and <targetCert>\n"
-                "using the certs and CRLs in <certStoreDirectory>. "
+                "using the certs and CRLs in <certLocationDirectory> and "
+                "pkcs11 db from <certStoreDirectory>. "
                 "If ENE is specified,\n"
                 "then an Error is Not Expected. "
                 "If EE is specified, an Error is Expected.\n");
 }
 
 static
 char *createFullPathName(
         char *dirName,
@@ -185,17 +187,16 @@ int test_ocsp(int argc, char *argv[]){
         PKIX_ComCertSelParams *certSelParams = NULL;
         PKIX_CertSelector *certSelector = NULL;
         PKIX_ValidateResult *valResult = NULL;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
         PKIX_UInt32 k = 0;
         PKIX_UInt32 chainLength = 0;
         PKIX_Boolean testValid = PKIX_TRUE;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_List *chainCerts = NULL;
 	PKIX_VerifyNode *verifyTree = NULL;
 	PKIX_PL_String *verifyString = NULL;
         PKIX_PL_Cert *dirCert = NULL;
         PKIX_PL_Cert *trustedCert = NULL;
         PKIX_PL_Cert *targetCert = NULL;
         PKIX_TrustAnchor *anchor = NULL;
         PKIX_List *anchors = NULL;
@@ -208,46 +209,32 @@ int test_ocsp(int argc, char *argv[]){
 
         if (argc < 5) {
                 printUsage();
                 return (0);
         }
 
         startTests("OcspChecker");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        databaseDir = argv[3+j];
-
-        /* This must precede the call to PKIX_Initialize! */
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize_SetConfigDir
-            (PKIX_STORE_TYPE_PK11, databaseDir, plContext));
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                (PKIX_TRUE, /* nssInitNeeded */
-                useArenas,
-                PKIX_MAJOR_VERSION,
-                PKIX_MINOR_VERSION,
-                PKIX_MINOR_VERSION,
-                &actualMinorVersion,
-                &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         /* ENE = expect no error; EE = expect error */
         if (PORT_Strcmp(argv[2+j], "ENE") == 0) {
                 testValid = PKIX_TRUE;
         } else if (PORT_Strcmp(argv[2+j], "EE") == 0) {
                 testValid = PKIX_FALSE;
         } else {
                 printUsage();
                 return (0);
         }
 
         subTest(argv[1+j]);
 
-        dirName = databaseDir;
+        dirName = argv[3+j];
 
         chainLength = argc - j - 5;
 
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_Create(&chainCerts, plContext));
 
         for (k = 0; k < chainLength; k++) {
 
                 dirCert = createCert(dirName, argv[5+k+j], plContext);
--- a/security/nss/cmd/libpkix/pkix/top/test_policychecker.c
+++ b/security/nss/cmd/libpkix/pkix/top/test_policychecker.c
@@ -411,17 +411,16 @@ cleanup:
 
 int test_policychecker(int argc, char *argv[])
 {
 
         PKIX_Boolean initialPolicyMappingInhibit = PKIX_FALSE;
         PKIX_Boolean initialAnyPolicyInhibit = PKIX_FALSE;
         PKIX_Boolean initialExplicitPolicy = PKIX_FALSE;
         PKIX_Boolean expectedResult = PKIX_FALSE;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_UInt32 chainLength = 0;
         PKIX_UInt32 initArgs = 0;
         PKIX_UInt32 firstCert = 0;
         PKIX_UInt32 i = 0;
         PKIX_Int32  j = 0;
         PKIX_UInt32 actualMinorVersion;
         PKIX_ProcessingParams *procParams = NULL;
         char *firstTrustAnchor = "yassir2yassir";
@@ -437,26 +436,18 @@ int test_policychecker(int argc, char *a
 	PKIX_VerifyNode *verifyTree = NULL;
 	PKIX_PL_String *verifyString = NULL;
         char *dirName = NULL;
         char *dataCentralDir = NULL;
         char *anchorName = NULL;
 
         PKIX_TEST_STD_VARS();
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         /*
          * Perform hard-coded tests if no command line args.
          * If command line args are provided, they must be:
          * arg[1]: test name
          * arg[2]: "ENE" or "EE", for "expect no error" or "expect error"
          * arg[3]: directory for certificates
          * arg[4]: user-initial-policy-set, consisting of braces
--- a/security/nss/cmd/libpkix/pkix/top/test_subjaltnamechecker.c
+++ b/security/nss/cmd/libpkix/pkix/top/test_subjaltnamechecker.c
@@ -132,41 +132,32 @@ int test_subjaltnamechecker(int argc, ch
         PKIX_UInt32 j = 0;
         char *nameStr;
         char *nameEnd;
         char *names[PKIX_TEST_MAX_CERTS];
         PKIX_UInt32 numNames = 0;
         PKIX_UInt32 nameType;
         PKIX_Boolean matchAll = PKIX_TRUE;
         PKIX_Boolean testValid = PKIX_TRUE;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         char *dirName = NULL;
         char *anchorName = NULL;
 	PKIX_VerifyNode *verifyTree = NULL;
 	PKIX_PL_String *verifyString = NULL;
 
         PKIX_TEST_STD_VARS();
 
         if (argc < 5) {
                 printUsage1(argv[0]);
                 return (0);
         }
 
         startTests("SubjAltNameConstraintChecker");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
 	j++; /* skip test-purpose string */
 
         /* ENE = expect no error; EE = expect error */
         if (PORT_Strcmp(argv[2+j], "ENE") == 0) {
                 testValid = PKIX_TRUE;
         } else if (PORT_Strcmp(argv[2+j], "EE") == 0) {
                 testValid = PKIX_FALSE;
--- a/security/nss/cmd/libpkix/pkix/top/test_validatechain.c
+++ b/security/nss/cmd/libpkix/pkix/top/test_validatechain.c
@@ -164,17 +164,16 @@ int test_validatechain(int argc, char *a
 
         PKIX_ValidateParams *valParams = NULL;
         PKIX_ValidateResult *valResult = NULL;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
         PKIX_UInt32 k = 0;
         PKIX_UInt32 chainLength = 0;
         PKIX_Boolean testValid = PKIX_TRUE;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_List *chainCerts = NULL;
         PKIX_PL_Cert *dirCert = NULL;
 	PKIX_VerifyNode *verifyTree = NULL;
 	PKIX_PL_String *verifyString = NULL;
         char *dirCertName = NULL;
         char *anchorCertName = NULL;
         char *dirName = NULL;
 
@@ -182,26 +181,18 @@ int test_validatechain(int argc, char *a
 
         if (argc < 5) {
                 printUsage();
                 return (0);
         }
 
         startTests("ValidateChain");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                (PKIX_TRUE, /* nssInitNeeded */
-                useArenas,
-                PKIX_MAJOR_VERSION,
-                PKIX_MINOR_VERSION,
-                PKIX_MINOR_VERSION,
-                &actualMinorVersion,
-                &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         /* ENE = expect no error; EE = expect error */
         if (PORT_Strcmp(argv[2+j], "ENE") == 0) {
                 testValid = PKIX_TRUE;
         } else if (PORT_Strcmp(argv[2+j], "EE") == 0) {
                 testValid = PKIX_FALSE;
         } else {
                 printUsage();
--- a/security/nss/cmd/libpkix/pkix/top/test_validatechain_NB.c
+++ b/security/nss/cmd/libpkix/pkix/top/test_validatechain_NB.c
@@ -201,17 +201,16 @@ int test_validatechain_NB(int argc, char
 
         PKIX_ValidateParams *valParams = NULL;
         PKIX_ValidateResult *valResult = NULL;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
         PKIX_UInt32 k = 0;
         PKIX_UInt32 chainLength = 0;
         PKIX_Boolean testValid = PKIX_TRUE;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_List *chainCerts = NULL;
         PKIX_PL_Cert *dirCert = NULL;
         char *dirCertName = NULL;
         char *anchorCertName = NULL;
         char *dirName = NULL;
         PKIX_UInt32 certIndex = 0;
         PKIX_UInt32 anchorIndex = 0;
         PKIX_UInt32 checkerIndex = 0;
@@ -233,26 +232,18 @@ int test_validatechain_NB(int argc, char
 
         if (argc < 5) {
                 printUsage();
                 return (0);
         }
 
         startTests("ValidateChain_NB");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                (PKIX_TRUE, /* nssInitNeeded */
-                useArenas,
-                PKIX_MAJOR_VERSION,
-                PKIX_MINOR_VERSION,
-                PKIX_MINOR_VERSION,
-                &actualMinorVersion,
-                &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         /* ENE = expect no error; EE = expect error */
         if (PORT_Strcmp(argv[2+j], "ENE") == 0) {
                 testValid = PKIX_TRUE;
         } else if (PORT_Strcmp(argv[2+j], "EE") == 0) {
                 testValid = PKIX_FALSE;
         } else {
                 printUsage();
--- a/security/nss/cmd/libpkix/pkix/top/test_validatechain_bc.c
+++ b/security/nss/cmd/libpkix/pkix/top/test_validatechain_bc.c
@@ -146,39 +146,30 @@ int test_validatechain_bc(int argc, char
         char *trustedCertFile = NULL;
         char *chainCertFile = NULL;
         PKIX_PL_Cert *trustedCert = NULL;
         PKIX_PL_Cert *chainCert = NULL;
         PKIX_UInt32 chainLength = 0;
         PKIX_UInt32 i = 0;
         PKIX_UInt32 j = 0;
         PKIX_UInt32 actualMinorVersion;
-        PKIX_Boolean useArenas = PKIX_FALSE;
 	PKIX_VerifyNode *verifyTree = NULL;
 	PKIX_PL_String *verifyString = NULL;
 
         PKIX_TEST_STD_VARS();
 
         if (argc < 3){
                 printUsage();
                 return (0);
         }
 
         startTests("ValidateChainBasicConstraints");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         chainLength = (argc - j) - 2;
 
         /* create processing params with list of trust anchors */
         trustedCertFile = argv[1+j];
         trustedCert = createCert(trustedCertFile);
 
         PKIX_TEST_EXPECT_NO_ERROR
--- a/security/nss/cmd/libpkix/pkix/util/test_error.c
+++ b/security/nss/cmd/libpkix/pkix/util/test_error.c
@@ -378,33 +378,24 @@ cleanup:
 
 int test_error(int argc, char *argv[]) {
 
         PKIX_Error *error, *error2, *error3, *error5, *error6, *error7;
         char *descChar = "Error Message";
         char *descChar2 = "Another Error Message";
         char *infoChar = "Auxiliary Info";
         PKIX_UInt32 actualMinorVersion;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_UInt32 j = 0;
 
         PKIX_TEST_STD_VARS();
 
         startTests("Errors");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         subTest("PKIX_Error_Create");
         createErrors
                 (&error,
                 &error2,
                 &error3,
                 &error5,
                 &error6,
--- a/security/nss/cmd/libpkix/pkix/util/test_list.c
+++ b/security/nss/cmd/libpkix/pkix/util/test_list.c
@@ -794,33 +794,24 @@ cleanup:
 int test_list(int argc, char *argv[]) {
 
         PKIX_List *list, *list2;
         PKIX_PL_String *testItem, *testItem2, *testItem3;
         char *testItemString = "a";
         char *testItemString2 = "b";
         char *testItemString3 = "c";
         PKIX_UInt32 actualMinorVersion;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_UInt32 j = 0;
 
         PKIX_TEST_STD_VARS();
 
         startTests("Lists");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         subTest("PKIX_List_Create");
         createLists(&list, &list2);
 
         subTest("pkix_List_ReverseList");
         testReverseList();
 
         subTest("Zero-length List");
--- a/security/nss/cmd/libpkix/pkix/util/test_list2.c
+++ b/security/nss/cmd/libpkix/pkix/util/test_list2.c
@@ -64,33 +64,24 @@ int test_list2(int argc, char *argv[]) {
                 "1.2.3.5",
                 "0.39",
                 "1.2.3.4.7",
                 "1.2.3.4.6",
                 "0.39.1",
                 "1.2.3.4.5",
                 "0.39.1.300"
         };
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_UInt32 actualMinorVersion;
 
         PKIX_TEST_STD_VARS();
 
         startTests("List Sorting");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         subTest("Creating Unsorted Lists");
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_Create(&list, plContext));
         for (i = 0; i < size; i++) {
                 /* Create a new OID object */
                 PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_OID_Create(
                                                 testOIDString[i],
                                                 &testOID,
--- a/security/nss/cmd/libpkix/pkix/util/test_logger.c
+++ b/security/nss/cmd/libpkix/pkix/util/test_logger.c
@@ -319,33 +319,24 @@ cleanup:
 
         PKIX_TEST_RETURN();
 }
 
 int test_logger(int argc, char *argv[]) {
 
         PKIX_Logger *logger, *logger2;
         PKIX_UInt32 actualMinorVersion;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_UInt32 j = 0;
 
         PKIX_TEST_STD_VARS();
 
         startTests("Loggers");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         subTest("PKIX_Logger_Create");
         createLogger(&logger, NULL, testLoggerCallback);
         createLogger(&logger2, (PKIX_PL_Object *)logger, testLoggerCallback2);
 
         subTest("Logger Context and Callback");
         testContextCallback(logger, logger2);
 
--- a/security/nss/cmd/libpkix/pkix_pl/module/test_colcertstore.c
+++ b/security/nss/cmd/libpkix/pkix_pl/module/test_colcertstore.c
@@ -242,36 +242,27 @@ static void printUsage(char *pName){
         printf("\nUSAGE: %s test-purpose <data-dir> <platform-dir>\n\n", pName);
 }
 
 /* Functional tests for CollectionCertStore public functions */
 
 int test_colcertstore(int argc, char *argv[]) {
 
         PKIX_UInt32 actualMinorVersion;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_UInt32 j = 0;
         char *platformDir = NULL;
         char *dataDir = NULL;
         char *combinedDir = NULL;
 
         PKIX_TEST_STD_VARS();
 
         startTests("CollectionCertStore");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-               (PKIX_TRUE, /* nssInitNeeded */
-               useArenas,
-               PKIX_MAJOR_VERSION,
-               PKIX_MINOR_VERSION,
-               PKIX_MINOR_VERSION,
-               &actualMinorVersion,
-               &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         if (argc < (3 + j)) {
                 printUsage(argv[0]);
                 return (0);
         }
 
         dataDir = argv[2 + j];
         platformDir = argv[3 + j];
--- a/security/nss/cmd/libpkix/pkix_pl/module/test_ekuchecker.c
+++ b/security/nss/cmd/libpkix/pkix_pl/module/test_ekuchecker.c
@@ -223,37 +223,28 @@ int test_ekuchecker(int argc, char *argv
         char *certNames[PKIX_TEST_MAX_CERTS];
         char *dirName = NULL;
         PKIX_PL_Cert *certs[PKIX_TEST_MAX_CERTS];
         PKIX_UInt32 chainLength = 0;
         PKIX_UInt32 i = 0;
         PKIX_UInt32 j = 0;
         PKIX_Boolean testValid = PKIX_FALSE;
         PKIX_Boolean only4EE = PKIX_FALSE;
-        PKIX_Boolean useArenas = PKIX_FALSE;
 
         PKIX_TEST_STD_VARS();
 
         if (argc < 5) {
                 printUsage1(argv[0]);
                 return (0);
         }
 
         startTests("EKU Checker");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         /* ENE = expect no error; EE = expect error */
         if (PORT_Strcmp(argv[2+j], "ENE") == 0) {
                 testValid = PKIX_TRUE;
         } else if (PORT_Strcmp(argv[2+j], "EE") == 0) {
                 testValid = PKIX_FALSE;
         } else {
                 printUsage1(argv[0]);
--- a/security/nss/cmd/libpkix/pkix_pl/module/test_httpcertstore.c
+++ b/security/nss/cmd/libpkix/pkix_pl/module/test_httpcertstore.c
@@ -122,17 +122,16 @@ cleanup:
 }
 
 int test_httpcertstore(int argc, char *argv[]) {
 
         PKIX_UInt32 i = 0;
         PKIX_UInt32 numCerts = 0;
         PKIX_UInt32 numCrls = 0;
         int j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 length = 0;
 
         char *certName = NULL;
         char *certDir = NULL;
 	PKIX_PL_Cert *cmdLineCert = NULL;
         PKIX_PL_Cert *cert = NULL;
         PKIX_CertSelector *certSelector = NULL;
@@ -151,26 +150,18 @@ int test_httpcertstore(int argc, char *a
 	PKIX_CertStore_CRLCallback getCrls = NULL;
 	PKIX_List *crls = NULL;
 	PKIX_PL_String *crlString = NULL;
 
         PKIX_TEST_STD_VARS();
 
         startTests("HttpCertStore");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                (PKIX_TRUE, /* nssInitNeeded */
-                useArenas,
-                PKIX_MAJOR_VERSION,
-                PKIX_MINOR_VERSION,
-                PKIX_MINOR_VERSION,
-                &actualMinorVersion,
-                &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         if (argc != (j + 3)) {
                 printUsage(argv[0]);
                 pkixTestErrorMsg = "Missing command line argument.";
                 goto cleanup;
         }
 
 	certDir = argv[++j];
--- a/security/nss/cmd/libpkix/pkix_pl/module/test_pk11certstore.c
+++ b/security/nss/cmd/libpkix/pkix_pl/module/test_pk11certstore.c
@@ -432,30 +432,28 @@ cleanup:
         PKIX_TEST_DECREF_AC(crlSelector);
         PKIX_TEST_DECREF_AC(crlList);
 
         PKIX_TEST_RETURN();
 }
 
 static 
 void printUsage(char *pName){
-        printf("\nUSAGE: %s <data-dir> <database-dir>\n\n", pName);
+        printf("\nUSAGE: %s <-d data-dir> <database-dir>\n\n", pName);
 }
 
 /* Functional tests for Pk11CertStore public functions */
 
 int test_pk11certstore(int argc, char *argv[]) {
 
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_UInt32 j = 0;
         PKIX_UInt32 actualMinorVersion;
         PKIX_PL_Date *validityDate = NULL;
         PKIX_PL_Date *betweenDate = NULL;
         char *crlDir = NULL;
-        char *databaseDir = NULL;
         char *expectedProfAscii = "([\n"
                 "\tVersion:         v3\n"
                 "\tSerialNumber:    00ca\n"
                 "\tIssuer:          CN=chemistry,O=mit,C=us\n"
                 "\tSubject:         CN=prof noall,O=mit,C=us\n"
                 "\tValidity: [From: Fri Feb 11 14:14:06 2005\n"
                 "\t           To:   Mon Jan 18, 2105]\n"
                 "\tSubjectAltNames: (null)\n"
@@ -602,37 +600,18 @@ int test_pk11certstore(int argc, char *a
 
         startTests("Pk11CertStore");
 
         if (argc < 3) {
                 printUsage(argv[0]);
                 return (0);
         }
 
-        /* too bad we cannot do this after the macro NSSCONTEXT_SETUP */
-        databaseDir = argv[1];
-        if (databaseDir[0] == '-') {
-                /* with -arenas at front */
-                databaseDir = argv[2];
-        }
-
-        /* This must precede the call to PKIX_Initialize! */
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize_SetConfigDir
-            (PKIX_STORE_TYPE_PK11, databaseDir, plContext));
-
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                (PKIX_TRUE, /* nssInitNeeded */
-                useArenas,
-                PKIX_MAJOR_VERSION,
-                PKIX_MINOR_VERSION,
-                PKIX_MINOR_VERSION,
-                &actualMinorVersion,
-                &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         crlDir = argv[j+2];
 
         /* Two certs for prof should be valid now */
         PKIX_TEST_EXPECT_NO_ERROR(pkix_pl_Date_CreateFromPRTime
                 (PR_Now(), &validityDate, plContext));
 
         subTest("Searching Certs for Subject");
--- a/security/nss/cmd/libpkix/pkix_pl/module/test_socket.c
+++ b/security/nss/cmd/libpkix/pkix_pl/module/test_socket.c
@@ -439,17 +439,16 @@ void dispatcher()
         
         } while ((serverState < SERVER_DONE) || (clientState < CLIENT_DONE));
 
         PKIX_TEST_RETURN();
 }
 
 int test_socket(int argc, char *argv[]) {
 
-        PKIX_Boolean useArenas = PKIX_FALSE;
         int j = 0;
         PKIX_UInt32 actualMinorVersion;
         char buf[PR_NETDB_BUF_SIZE];
         char *serverName = NULL;
         char *sepPtr = NULL;
         PRHostEnt hostent;
         PRUint16 portNum = 0;
         PRStatus prstatus = PR_FAILURE;
@@ -457,26 +456,18 @@ int test_socket(int argc, char *argv[]) 
         void *ipaddr = NULL;
         PKIX_Error *bindError = NULL;
         PRIntn hostenum;
 
         PKIX_TEST_STD_VARS();
 
         startTests("Socket");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                (PKIX_TRUE, /* nssInitNeeded */
-                useArenas,
-                PKIX_MAJOR_VERSION,
-                PKIX_MINOR_VERSION,
-                PKIX_MINOR_VERSION,
-                &actualMinorVersion,
-                &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         if (argc != (j + 2)) {
                 printUsage(argv[0]);
                 pkixTestErrorMsg = "Missing command line argument.";
                 goto cleanup;
         }
 
         serverName = argv[j + 1];
--- a/security/nss/cmd/libpkix/pkix_pl/pki/test_authorityinfoaccess.c
+++ b/security/nss/cmd/libpkix/pkix_pl/pki/test_authorityinfoaccess.c
@@ -57,36 +57,27 @@ int test_authorityinfoaccess(int argc, c
         PKIX_PL_InfoAccess *aia = NULL;
         PKIX_PL_InfoAccess *aiaDup = NULL;
         PKIX_PL_InfoAccess *aiaDiff = NULL;
         char *certPathName = NULL;
         char *dirName = NULL;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 size, i;
         PKIX_UInt32 j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         char *expectedAscii = "[method:caIssuers, location:ldap:"
                 "//betty.nist.gov/cn=CA,ou=Basic%20LDAP%20URI%20OU1,"
                 "o=Test%20Certificates,c=US?cACertificate;binary,"
                 "crossCertificatePair;binary]";
 
         PKIX_TEST_STD_VARS();
 
         startTests("AuthorityInfoAccess");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         if (argc < 5+j) {
                 printf("Usage: %s <test-purpose> <cert> <diff-cert>\n", argv[0]);
         }
 
         dirName = argv[2+j];
         certPathName = argv[3+j];
 
--- a/security/nss/cmd/libpkix/pkix_pl/pki/test_cert.c
+++ b/security/nss/cmd/libpkix/pkix_pl/pki/test_cert.c
@@ -2231,17 +2231,16 @@ void printUsage(void) {
 }
 
 int test_cert(int argc, char *argv[]) {
 
         PKIX_PL_Cert *goodObject = NULL;
         PKIX_PL_Cert *equalObject = NULL;
         PKIX_PL_Cert *diffObject = NULL;
         PKIX_UInt32 actualMinorVersion;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_UInt32 j = 0;
 
         char *dataCentralDir = NULL;
         char *dataDir = NULL;
         char *goodInput = "yassir2bcn";
         char *diffInput = "nss2alice";
 
         char *expectedAscii =
@@ -2271,26 +2270,18 @@ int test_cert(int argc, char *argv[]) {
                 "\tSubjectInfoAccess: (null)\n"
                 "\tCacheFlag:       0\n"
                 "]\n";
 
         PKIX_TEST_STD_VARS();
 
         startTests("Cert");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         if (argc < 3+j) {
                 printUsage();
                 return (0);
         }
 
         dataCentralDir = argv[2+j];
         dataDir = argv[3+j];
--- a/security/nss/cmd/libpkix/pkix_pl/pki/test_crl.c
+++ b/security/nss/cmd/libpkix/pkix_pl/pki/test_crl.c
@@ -244,17 +244,16 @@ void printUsage(void) {
 }
 
 /* Functional tests for CRL public functions */
 
 int test_crl(int argc, char *argv[]) {
         PKIX_PL_CRL *goodObject = NULL;
         PKIX_PL_CRL *equalObject = NULL;
         PKIX_PL_CRL *diffObject = NULL;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
 
         char *dataCentralDir = NULL;
         char *goodInput = "crlgood.crl";
         char *diffInput = "crldiff.crl";
         char *expectedAscii =
                 "[\n"
@@ -287,26 +286,18 @@ int test_crl(int argc, char *argv[]) {
                 "\tCritExtOIDs:     (EMPTY)\n"
                 "]\n";
         /* Note XXX serialnumber and reasoncode need debug */
 
         PKIX_TEST_STD_VARS();
 
         startTests("CRL");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         if (argc < 3+j) {
                 printUsage();
                 return (0);
         }
 
         dataCentralDir = argv[2+j];
 
--- a/security/nss/cmd/libpkix/pkix_pl/pki/test_crlentry.c
+++ b/security/nss/cmd/libpkix/pkix_pl/pki/test_crlentry.c
@@ -180,17 +180,16 @@ void printUsage(void) {
 
 int test_crlentry(int argc, char *argv[]) {
         PKIX_PL_CRL *crl = NULL;
         PKIX_PL_CRLEntry *goodObject = NULL;
         PKIX_PL_CRLEntry *equalObject = NULL;
         PKIX_PL_CRLEntry *diffObject = NULL;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
 
         char *dataDir = NULL;
         char *goodInput = "crlgood.crl";
         char *expectedAscii =
                 "\n\t[\n"
                 "\tSerialNumber:    010932\n"
                 "\tReasonCode:      260\n"
                 "\tRevocationDate:  Fri Jan 07 15:09:10 2005\n"
@@ -198,26 +197,18 @@ int test_crlentry(int argc, char *argv[]
                 "\t]\n\t";
 
         /* Note XXX serialnumber and reasoncode need debug */
 
         PKIX_TEST_STD_VARS();
 
         startTests("CRLEntry");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         if (argc < 1+j) {
                 printUsage();
                 return (0);
         }
 
         dataDir = argv[1+j];
 
--- a/security/nss/cmd/libpkix/pkix_pl/pki/test_date.c
+++ b/security/nss/cmd/libpkix/pkix_pl/pki/test_date.c
@@ -110,34 +110,25 @@ void testDate(char *goodInput, char *dif
         PKIX_TEST_RETURN();
 
 }
 
 int test_date(int argc, char *argv[]) {
 
         char *goodInput = NULL;
         char *diffInput = NULL;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
 
         PKIX_TEST_STD_VARS();
 
         startTests("Date");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         goodInput = "040329134847Z";
         diffInput = "050329135847Z";
         testDate(goodInput, diffInput);
 
 cleanup:
 
         PKIX_Shutdown(plContext);
--- a/security/nss/cmd/libpkix/pkix_pl/pki/test_generalname.c
+++ b/security/nss/cmd/libpkix/pkix_pl/pki/test_generalname.c
@@ -100,34 +100,25 @@ static void testNameType
 
         testDestroy(goodName, equalName, diffName);
 }
 
 int test_generalname(int argc, char *argv[]) {
 
         char *goodInput = NULL;
         char *diffInput = NULL;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
 
         PKIX_TEST_STD_VARS();
 
         startTests("GeneralName");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         goodInput = "john@sun.com";
         diffInput = "john@labs.com";
         testNameType(PKIX_RFC822_NAME, goodInput, diffInput, goodInput);
 
         goodInput = "example1.com";
         diffInput = "ex2.net";
         testNameType(PKIX_DNS_NAME, goodInput, diffInput, goodInput);
--- a/security/nss/cmd/libpkix/pkix_pl/pki/test_nameconstraints.c
+++ b/security/nss/cmd/libpkix/pkix_pl/pki/test_nameconstraints.c
@@ -117,34 +117,25 @@ void printUsage(void) {
 /* Functional tests for CRL public functions */
 
 int test_nameconstraints(int argc, char *argv[]) {
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
         char *platformDir = NULL;
         char *dataDir = NULL;
         char *combinedDir = NULL;
-        PKIX_Boolean useArenas = PKIX_FALSE;
 
         /* Note XXX serialnumber and reasoncode need debug */
 
         PKIX_TEST_STD_VARS();
 
         startTests("NameConstraints");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                (PKIX_TRUE, /* nssInitNeeded */
-                useArenas,
-                PKIX_MAJOR_VERSION,
-                PKIX_MINOR_VERSION,
-                PKIX_MINOR_VERSION,
-                &actualMinorVersion,
-                &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         if (argc < 3 + j) {
                 printUsage();
                 return (0);
         }
 
         dataDir = argv[2 + j];
         platformDir = argv[3 + j];
--- a/security/nss/cmd/libpkix/pkix_pl/pki/test_subjectinfoaccess.c
+++ b/security/nss/cmd/libpkix/pkix_pl/pki/test_subjectinfoaccess.c
@@ -59,35 +59,26 @@ int test_subjectinfoaccess(int argc, cha
         PKIX_PL_InfoAccess *siaDiff = NULL;
         PKIX_PL_GeneralName *location = NULL;
         char *certPathName = NULL;
         char *dirName = NULL;
         PKIX_UInt32 method = 0;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 size, i;
         PKIX_UInt32 j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         char *expectedAscii = "[method:caRepository, "
                 "location:http://betty.nist.gov/pathdiscoverytestsuite/"
                 "p7cfiles/IssuedByTrustAnchor1.p7c]";
 
         PKIX_TEST_STD_VARS();
 
         startTests("SubjectInfoAccess");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         if (argc < 5+j) {
                 printf("Usage: %s <test-purpose> <cert> <diff-cert>\n", argv[0]);
         }
 
         dirName = argv[2+j];
         certPathName = argv[3+j];
 
--- a/security/nss/cmd/libpkix/pkix_pl/pki/test_x500name.c
+++ b/security/nss/cmd/libpkix/pkix_pl/pki/test_x500name.c
@@ -161,40 +161,31 @@ cleanup:
 }
 
 int test_x500name(int argc, char *argv[]) {
 
         PKIX_PL_X500Name *goodObject = NULL;
         PKIX_PL_X500Name *equalObject = NULL;
         PKIX_PL_X500Name *diffObject = NULL;
         PKIX_PL_X500Name *diffObjectMatch = NULL;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
 
         /* goodInput is encoded in PKIX_ESCASCII */
         char *goodInput = "cn=Strau&#x00Df;,ou=labs,o=sun,c=us";
         char *diffInput = "cn=steve,ou=labs,o=sun,c=us";
         char *diffInputMatch = "Cn=SteVe,Ou=lABs,o=SUn,c=uS";
         char *expectedAscii = "CN=Strau&#x00DF;,OU=labs,O=sun,C=us";
 
         PKIX_TEST_STD_VARS();
 
         startTests("X500Name");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         createX500Names
                 (goodInput, diffInput, diffInputMatch,
                 &goodObject, &equalObject, &diffObject, &diffObjectMatch);
 
         PKIX_TEST_EQ_HASH_TOSTR_DUP
             (goodObject,
             equalObject,
--- a/security/nss/cmd/libpkix/pkix_pl/system/stress_test.c
+++ b/security/nss/cmd/libpkix/pkix_pl/system/stress_test.c
@@ -53,33 +53,24 @@ int stress_test(int argc, char *argv[]) 
         char temp[4];
         PKIX_Boolean result;
         PKIX_PL_String *strings[17576], *tempString;
         PKIX_PL_String *utf16strings[17576];
         PKIX_PL_ByteArray *byteArrays[17576];
         void *dest;
         PKIX_PL_HashTable *ht = NULL;
         PKIX_UInt32 actualMinorVersion;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_UInt32 j = 0;
 
         PKIX_TEST_STD_VARS();
 
         startTests("Stress Test");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         /* ---------------------------- */
         subTest("Create every three letter String");
 
         for (i = 0; i < 26; i++)
                 for (j = 0; j < 26; j++)
                         for (k = 0; k < 26; k++) {
                                 temp[0] = (char)('a'+i);
--- a/security/nss/cmd/libpkix/pkix_pl/system/test_bigint.c
+++ b/security/nss/cmd/libpkix/pkix_pl/system/test_bigint.c
@@ -148,42 +148,33 @@ cleanup:
 
 int test_bigint(int argc, char *argv[]) {
 
         PKIX_UInt32 size = 4, badSize = 3, i = 0;
         PKIX_PL_BigInt *testBigInt[4] = {NULL};
         PKIX_Int32 cmpResult;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
 
         char *bigIntValue[4] =
         {
                 "03",
                 "ff",
                 "1010101010101010101010101010101010101010",
                 "1010101010101010101010101010101010101010",
         };
 
         char *badValue[3] = {"00ff", "fff", "-ff"};
 
         PKIX_TEST_STD_VARS();
 
         startTests("BigInts");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         for (i = 0; i < badSize; i++) {
                 subTest("PKIX_PL_BigInt_Create <error_handling>");
                 createBigInt(&testBigInt[i], badValue[i], PKIX_TRUE);
         }
 
         for (i = 0; i < size; i++) {
                 subTest("PKIX_PL_BigInt_Create");
--- a/security/nss/cmd/libpkix/pkix_pl/system/test_bytearray.c
+++ b/security/nss/cmd/libpkix/pkix_pl/system/test_bytearray.c
@@ -208,37 +208,28 @@ int test_bytearray(int argc, char *argv[
                 "[127, 128, 129, 254, 255, 000]",
                 "[100]",
                 "[001, 002, 003, 004, 005]"
         };
 
         char *dummyArray[4];
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
 
         PKIX_TEST_STD_VARS();
 
         dummyArray[0] = dArray0;
         dummyArray[1] = (char*)dArray1;
         dummyArray[2] = dArray2;
         dummyArray[3] = dArray3;
 
         startTests("ByteArrays");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         subTest ("PKIX_PL_ByteArray_Create <zero length>");
         testZeroLength();
 
         for (i = 0; i < size; i++) {
                 subTest("PKIX_PL_ByteArray_Create");
                 createByteArray(&testByteArray[i], dummyArray[i], lengths[i]);
         }
--- a/security/nss/cmd/libpkix/pkix_pl/system/test_hashtable.c
+++ b/security/nss/cmd/libpkix/pkix_pl/system/test_hashtable.c
@@ -402,33 +402,24 @@ cleanup:
 
 
 int test_hashtable(int argc, char *argv[]) {
 
         PKIX_PL_HashTable *ht, *ht2, *ht3, *ht4;
         PKIX_PL_String *testString, *testString2, *testString3;
         PKIX_PL_OID *testOID;
         PKIX_UInt32 actualMinorVersion;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_UInt32 j = 0;
 
         PKIX_TEST_STD_VARS();
 
         startTests("HashTables");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         subTest("PKIX_PL_HashTable_Create");
         createHashTables(&ht, &ht2, &ht3, &ht4);
 
         PKIX_TEST_EQ_HASH_TOSTR_DUP
                 (ht,
                 ht3,
                 ht2,
--- a/security/nss/cmd/libpkix/pkix_pl/system/test_mem.c
+++ b/security/nss/cmd/libpkix/pkix_pl/system/test_mem.c
@@ -111,32 +111,23 @@ cleanup:
 }
 
 int test_mem(int argc, char *argv[]) {
 
         unsigned int *array = NULL;
         int arraySize = 10;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
 
         PKIX_TEST_STD_VARS();
 
         startTests("Memory Allocation");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         subTest("PKIX_PL_Malloc");
         testMalloc(&array);
 
         subTest("PKIX_PL_Realloc");
         testRealloc(&array);
 
         subTest("PKIX_PL_Free");
--- a/security/nss/cmd/libpkix/pkix_pl/system/test_monitorlock.c
+++ b/security/nss/cmd/libpkix/pkix_pl/system/test_monitorlock.c
@@ -101,32 +101,23 @@ cleanup:
         PKIX_TEST_RETURN();
 }
 
 int test_monitorlock(int argc, char *argv[]) {
 
         PKIX_PL_MonitorLock *monitorLock, *monitorLock2, *monitorLock3;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
 
         PKIX_TEST_STD_VARS();
 
         startTests("MonitorLocks");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         subTest("PKIX_PL_MonitorLock_Create");
         createMonitorLockes(&monitorLock, &monitorLock2, &monitorLock3);
 
         PKIX_TEST_EQ_HASH_TOSTR_DUP
                 (monitorLock,
                 monitorLock3,
                 monitorLock2,
--- a/security/nss/cmd/libpkix/pkix_pl/system/test_mutex.c
+++ b/security/nss/cmd/libpkix/pkix_pl/system/test_mutex.c
@@ -93,32 +93,23 @@ cleanup:
         PKIX_TEST_RETURN();
 }
 
 int test_mutex(int argc, char *argv[]) {
 
         PKIX_PL_Mutex *mutex, *mutex2, *mutex3;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
 
         PKIX_TEST_STD_VARS();
 
         startTests("Mutexes");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         subTest("PKIX_PL_Mutex_Create");
         createMutexes(&mutex, &mutex2, &mutex3);
 
         PKIX_TEST_EQ_HASH_TOSTR_DUP
                 (mutex,
                 mutex3,
                 mutex2,
--- a/security/nss/cmd/libpkix/pkix_pl/system/test_mutex2.c
+++ b/security/nss/cmd/libpkix/pkix_pl/system/test_mutex2.c
@@ -109,32 +109,23 @@ static void producer(void* arg) {
 }
 
 int test_mutex2(int argc, char *argv[]) {
 
         PRThread *consThread, *prodThread, *prodThread2, *prodThread3;
         int x = 10, y = 20, z = 30;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
 
         PKIX_TEST_STD_VARS();
 
         startTests("Mutex and Threads");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         (void) printf("Attempting to create new mutex...\n");
         subTest("Mutex Creation");
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Mutex_Create(&mutex, plContext));
 
         cv = PR_NewCondVar(*(PRLock **) mutex);
 
         subTest("Starting consumer thread");
--- a/security/nss/cmd/libpkix/pkix_pl/system/test_mutex3.c
+++ b/security/nss/cmd/libpkix/pkix_pl/system/test_mutex3.c
@@ -77,32 +77,23 @@ static void t2(/* ARGSUSED */ void* arg)
 
         (void) printf("t2 exiting...\n");
 }
 
 int test_mutex3(int argc, char *argv[]) {
         PRThread *thread, *thread2;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
 
         PKIX_TEST_STD_VARS();
 
         startTests("Mutex and Threads");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         subTest("Mutex Creation");
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Mutex_Create(&mutex, plContext));
 
         subTest("Starting thread");
         thread = PR_CreateThread(PR_USER_THREAD,
                                 t1,
                                 NULL,
--- a/security/nss/cmd/libpkix/pkix_pl/system/test_object.c
+++ b/security/nss/cmd/libpkix/pkix_pl/system/test_object.c
@@ -280,32 +280,23 @@ cleanup:
         PKIX_TEST_RETURN();
 }
 
 int test_object(int argc, char *argv[]) {
 
         PKIX_PL_Object *obj, *obj2, *obj3, *obj4;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
 
         PKIX_TEST_STD_VARS();
 
         startTests("Objects");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         subTest("PKIX_PL_Object_Create");
         createObjects(&obj, &obj2, &obj3, &obj4);
 
         PKIX_TEST_EQ_HASH_TOSTR_DUP(obj, obj3, obj2, NULL, Object, PKIX_FALSE);
 
         subTest("PKIX_PL_Object_GetType");
         testGetType(obj, obj2, obj3);
--- a/security/nss/cmd/libpkix/pkix_pl/system/test_oid.c
+++ b/security/nss/cmd/libpkix/pkix_pl/system/test_oid.c
@@ -159,17 +159,16 @@ cleanup:
 
 int test_oid(int argc, char *argv[]) {
 
         PKIX_PL_OID *testOID[6] = {NULL};
         PKIX_PL_OID *badTestOID = NULL;
         PKIX_UInt32 i, size = 6;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
 
         char* validOID[6] = {
                 "2.11.22222.33333",
                 "1.2.3.004.5.6.7",
                 "2.11.22222.33333",
                 "1.2.3.4.5.6.7",
                 "1.2.3",
                 "2.39.3"
@@ -197,26 +196,18 @@ int test_oid(int argc, char *argv[]) {
                 "000000000000000000000000000000000000000010.3.2",
                 "1"
         };
 
         PKIX_TEST_STD_VARS();
 
         startTests("OIDs");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         for (i = 0; i < size; i++) {
                 subTest("PKIX_PL_OID_Create");
                 createOID(&testOID[i], validOID[i], PKIX_FALSE);
         }
 
         PKIX_TEST_EQ_HASH_TOSTR_DUP
                 (testOID[0],
--- a/security/nss/cmd/libpkix/pkix_pl/system/test_rwlock.c
+++ b/security/nss/cmd/libpkix/pkix_pl/system/test_rwlock.c
@@ -118,33 +118,24 @@ static void reader2(void) {
         (void) printf("\t[Thread #3 Read UNLock #2.]\n");
 }
 
 
 
 int test_rwlock() {
         PKIX_PL_String* outputString = NULL;
         PKIX_UInt32 j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
         PKIX_Boolean bool;
         PKIX_UInt32 actualMinorVersion;
 
         PKIX_TEST_STD_VARS();
         startTests("RWLocks");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         (void) printf("Attempting to create new rwlock...\n");
 
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_RWLock_Create(&rwlock, plContext));
 
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_RWLock_Create(&rwlock2, plContext));
 
         PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_RWLock_Create(&rwlock3, plContext));
--- a/security/nss/cmd/libpkix/pkix_pl/system/test_string.c
+++ b/security/nss/cmd/libpkix/pkix_pl/system/test_string.c
@@ -402,32 +402,23 @@ int test_string(int argc, char *argv[]) 
                 "Encode &amp; with &amp;amp; in ASCII",
                 "&#x00A1;",
                 "&amp;",
                 "string with\nnewlines and\ttabs"
         };
 
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
 
         PKIX_TEST_STD_VARS();
 
         startTests("Strings");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         subTest("PKIX_PL_String_Create <ascii format>");
         for (i = 0; i < size; i++) {
                 testString[i] = NULL;
                 createString
                         (&testString[i],
                         PKIX_ESCASCII,
                         plainText[i],
--- a/security/nss/cmd/libpkix/pkix_pl/system/test_string2.c
+++ b/security/nss/cmd/libpkix/pkix_pl/system/test_string2.c
@@ -310,32 +310,23 @@ cleanup:
 }
 
 int test_string2(int argc, char *argv[]) {
 
         PKIX_PL_String *vivaEspanaString, *straussString, *testUTF16String;
         PKIX_PL_String *chineseString, *jeanRenoString, *gorbachevString;
         PKIX_UInt32 actualMinorVersion;
         PKIX_UInt32 j = 0;
-        PKIX_Boolean useArenas = PKIX_FALSE;
 
         PKIX_TEST_STD_VARS();
 
         startTests("Unicode Strings");
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         subTest("PKIX_PL_String_Create");
         createString(&vivaEspanaString,
                     &straussString,
                     &gorbachevString,
                     &testUTF16String,
                     &chineseString,
                     &jeanRenoString);
--- a/security/nss/cmd/libpkix/pkixutil/pkixutil.c
+++ b/security/nss/cmd/libpkix/pkixutil/pkixutil.c
@@ -38,16 +38,20 @@
  * testwrapper.c
  *
  * Wrpper programm for libpkix tests.
  *
  */
 
 #include <stdio.h>
 
+#include "nspr.h"
+#include "plgetopt.h"
+
+#include "nss.h"
 #include "secport.h"
 
 typedef int (*mainTestFn)(int argc, char* argv[]);
 
 extern int libpkix_buildthreads(int argc, char *argv[]);
 extern int nss_threads(int argc, char *argv[]);
 extern int test_certselector(int argc, char *argv[]);
 extern int test_comcertselparams(int argc, char *argv[]);
@@ -193,46 +197,139 @@ testFunctionRef testFnRefTable[] = {
     {"dumpcert",                       dumpcert},
     {"dumpcrl",                        dumpcrl},
     {"validate_chain",                 validate_chain},
     {NULL,                             NULL },
 };
 
 static
 void printUsage(char *cmdName) {
-    int fnCounter = 0, totalCharLen = 0;
+    int fnCounter = 0;
 
     fprintf(stderr, "Usage: %s [test name] [arg1]...[argN]\n\n", cmdName);
     fprintf(stderr, "List of possible names for the tests:");
     while (testFnRefTable[fnCounter].fnName != NULL) {
         if (fnCounter % 2 == 0) {
             fprintf(stderr, "\n");
         }
         fprintf(stderr, "  %-35s ", testFnRefTable[fnCounter].fnName);
         fnCounter += 1;
     }
     fprintf(stderr, "\n");
 }
 
+static SECStatus
+getTestArguments(int         argc,
+                 char      **argv,
+                 mainTestFn *ptestFn,
+                 char      **pdbPath,
+                 int        *pargc,
+                 char     ***pargv)
+{
+    PLOptState *optstate = NULL;
+    PLOptStatus status;
+    mainTestFn testFunction = NULL;
+    char **wArgv = NULL;
+    char  *dbPath = NULL;
+    char  *fnName = NULL;
+    int    wArgc = 0;
+    int    fnCounter = 0;
+    
+    if (argc < 2) {
+        printf("ERROR: insufficient number of arguments: %s.\n", fnName);
+        return SECFailure;
+    }
+
+    fnName = argv[1];
+    while (testFnRefTable[fnCounter].fnName != NULL) {
+        if (!PORT_Strcmp(fnName, testFnRefTable[fnCounter].fnName)) {
+            testFunction = testFnRefTable[fnCounter].fnPointer;
+            break;
+        }
+        fnCounter += 1;
+    }
+    if (!testFunction) {
+        printf("ERROR: unknown name of the test: %s.\n", fnName);
+        return SECFailure;
+    }
+
+    wArgv = PORT_ZNewArray(char*, argc);
+    if (!wArgv) {
+        return SECFailure;
+    }
+
+    /* set name of the function as a first arg and increment arg count. */
+    wArgv[0] = fnName;
+    wArgc += 1;
+
+    optstate = PL_CreateOptState(argc - 1, argv + 1, "d:");
+    while ((status = PL_GetNextOpt(optstate)) == PL_OPT_OK) {
+        switch (optstate->option) {
+        case 'd':
+            dbPath = (char*)optstate->value;
+            break;
+
+        default:
+            wArgv[wArgc] = (char*)optstate->value;
+            wArgc += 1;
+            break;
+        }
+    }
+    PL_DestroyOptState(optstate);
+
+    *ptestFn = testFunction;
+    *pdbPath = dbPath;
+    *pargc = wArgc;
+    *pargv = wArgv;
+    
+    return SECSuccess;
+}
+
+
+static
+int runCmd(mainTestFn fnPointer,
+           int argc,
+           char **argv,
+           char *dbPath)
+{
+    int retStat = 0;
+    
+    /*  Initialize NSPR and NSS.  */
+    PR_Init(PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1);
+    
+    /* if using databases, use NSS_Init and not NSS_NoDB_Init */
+    if (dbPath && PORT_Strlen(dbPath) != 0) {
+        if (NSS_Init(dbPath) != SECSuccess)
+            return SECFailure;
+    } else {
+        if (NSS_NoDB_Init(NULL) != 0)
+            return SECFailure;
+    }
+    retStat = fnPointer(argc, argv);
+
+    if (NSS_Shutdown() != SECSuccess) {
+        exit(1);
+    }
+    PR_Cleanup();
+    return retStat;
+}
 
 int main(int argc, char **argv) {
-    char *fnName = NULL;
-    int fnCounter = 0;
+    mainTestFn testFunction = NULL;
+    char *dbPath = NULL;
+    char **testArgv = NULL;
+    int testArgc = 0;
+    int rv = 0;
 
-    if (argc < 2) {
+    rv = getTestArguments(argc, argv, &testFunction, &dbPath,
+                          &testArgc, &testArgv);
+    if (rv != SECSuccess) {
         printUsage(argv[0]);
         return 1;
     }
     
-    fnName = argv[1];
-    while (testFnRefTable[fnCounter].fnName != NULL) {
-        int fnNameLen = PORT_Strlen(testFnRefTable[fnCounter].fnName);
-        if (!PORT_Strncmp(fnName, testFnRefTable[fnCounter].fnName,
-                          fnNameLen)) {
-            return testFnRefTable[fnCounter].fnPointer(argc - 1, argv + 1);
-        }
-        fnCounter += 1;
-    }
-    printf("ERROR: unknown name of the test: %s.\n", fnName);
-    printUsage(argv[0]);
-    return -1;
+    rv = runCmd(testFunction, testArgc, testArgv, dbPath);
+
+    PORT_Free(testArgv);
+
+    return rv;
 }
 
--- a/security/nss/cmd/libpkix/sample_apps/validate_chain.c
+++ b/security/nss/cmd/libpkix/sample_apps/validate_chain.c
@@ -151,35 +151,26 @@ int validate_chain(int argc, char *argv[
         char *trustedCertFile = NULL;
         char *chainCertFile = NULL;
         PKIX_PL_Cert *trustedCert = NULL;
         PKIX_PL_Cert *chainCert = NULL;
         PKIX_UInt32 chainLength = 0;
         PKIX_UInt32 i = 0;
         PKIX_UInt32 j = 0;
         PKIX_UInt32 actualMinorVersion;
-        PKIX_Boolean useArenas = PKIX_FALSE;
 
         PKIX_TEST_STD_VARS();
 
         if (argc < 3){
                 printUsage();
                 return (0);
         }
 
-        useArenas = PKIX_TEST_ARENAS_ARG(argv[1]);
-
-        PKIX_TEST_EXPECT_NO_ERROR(PKIX_Initialize
-                                    (PKIX_TRUE, /* nssInitNeeded */
-                                    useArenas,
-                                    PKIX_MAJOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    PKIX_MINOR_VERSION,
-                                    &actualMinorVersion,
-                                    &plContext));
+        PKIX_TEST_EXPECT_NO_ERROR(
+            PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext));
 
         chainLength = (argc - j) - 2;
 
         /* create processing params with list of trust anchors */
         trustedCertFile = argv[1+j];
         trustedCert = createCert(trustedCertFile);
 
         PKIX_TEST_EXPECT_NO_ERROR
--- a/security/nss/cmd/libpkix/testutil/testutil.h
+++ b/security/nss/cmd/libpkix/testutil/testutil.h
@@ -269,17 +269,17 @@ extern "C" {
         do { \
                 if (!obj){ \
                         goto cleanup; \
                 } \
         } while (0)
 
 #define PKIX_TEST_ARENAS_ARG(arena) \
         (arena? \
-        (PORT_Strcmp(arena, "-arenas") ? PKIX_FALSE : (j++, PKIX_TRUE)): \
+        (PORT_Strcmp(arena, "arenas") ? PKIX_FALSE : (j++, PKIX_TRUE)): \
         PKIX_FALSE)
 
 #define PKIX_TEST_ERROR_RECEIVED (pkixTestErrorMsg || pkixTestErrorResult)
 
 /* see source file for function documentation */
 
 void startTests(char *testName);
 
--- a/security/nss/tests/libpkix/pkix_pl_tests/module/runPLTests.sh
+++ b/security/nss/tests/libpkix/pkix_pl_tests/module/runPLTests.sh
@@ -101,17 +101,17 @@ fi
 
 ParseArgs $*
 
 SOCKETTRACE=0
 export SOCKETTRACE
 
 RunTests <<EOF
 pkixutil test_colcertstore NIST-Test-Files-Used rev_data/local ${HOSTDIR}
-pkixutil test_pk11certstore ../../pkix_pl_tests/module ../../pkix_tests/top/rev_data/crlchecker
+pkixutil test_pk11certstore -d ../../pkix_pl_tests/module ../../pkix_tests/top/rev_data/crlchecker
 pkixutil test_ekuchecker "Test-EKU-without-OID" ENE "" rev_data test_eku_codesigning_clientauth.crt test_eku_clientauth.crt test_eku_clientauthEE.crt
 pkixutil test_ekuchecker "Test-EKU-with-good-OID" ENE "1.3.6.1.5.5.7.3.3" rev_data test_eku_codesigning_clientauth.crt test_eku_clientauth.crt test_eku_clientauthEE.crt 
 pkixutil test_ekuchecker "Test-EKU-with-bad-OID" EE "1.3.6.1.5.5.7.3.4" rev_data test_eku_codesigning_clientauth.crt test_eku_clientauth.crt test_eku_clientauthEE.crt 
 pkixutil test_ekuchecker "Test-EKU-with-good-and-bad-OID" EE "1.3.6.1.5.5.7.3.3,1.3.6.1.5.5.7.3.4" rev_data test_eku_codesigning_clientauth.crt test_eku_clientauth.crt test_eku_clientauthEE.crt
 pkixutil test_ekuchecker "Test-EKU-only-EE-with-good-OID" ENE "E1.3.6.1.5.5.7.3.3" rev_data test_eku_codesigning_clientauth.crt test_eku_clientauth.crt test_eku_clientauthEE.crt
 pkixutil test_ekuchecker "Test-EKU-only-EE-with-bad-OID" EE "E1.3.6.1.5.5.7.3.4" rev_data test_eku_codesigning_clientauth.crt test_eku_clientauth.crt test_eku_clientauthEE.crt
 pkixutil test_ekuchecker "Test-EKU-serverAuth" ENE "1.3.6.1.5.5.7.3.1" rev_data test_eku_all.crt test_eku_allbutcodesigningEE.crt
 pkixutil test_ekuchecker "Test-EKU-clientAuth" ENE "1.3.6.1.5.5.7.3.2" rev_data test_eku_all.crt test_eku_allbutcodesigningEE.crt
--- a/security/nss/tests/libpkix/pkix_tests/top/runTests.sh
+++ b/security/nss/tests/libpkix/pkix_tests/top/runTests.sh
@@ -101,20 +101,25 @@ Display "#    EE = expect error (validat
 Display ""
 
 LOGGING=1
 SOCKETTRACE=1
 export LOGGING SOCKETTRACE
 
 RunTests <<EOF
 pkixutil test_validatechain_NB NIST-Test.4.1.1 ENE $NIST TrustAnchorRootCertificate.crt GoodCACert.crt ValidCertificatePathTest1EE.crt
+pkixutil_or test_validatechain_NB NIST-Test.4.1.1 ENE $NIST TrustAnchorRootCertificate.crt GoodCACert.crt ValidCertificatePathTest1EE.crt
 pkixutil test_validatechain_NB NIST-Test.4.1.2 EE $NIST TrustAnchorRootCertificate.crt BadSignedCACert.crt InvalidCASignatureTest2EE.crt
+pkixutil_or test_validatechain_NB NIST-Test.4.1.2 EE $NIST TrustAnchorRootCertificate.crt BadSignedCACert.crt InvalidCASignatureTest2EE.crt
 pkixutil test_validatechain_NB NIST-Test.4.1.3 EE $NIST TrustAnchorRootCertificate.crt GoodCACert.crt  InvalidEESignatureTest3EE.crt
+pkixutil_or test_validatechain_NB NIST-Test.4.1.3 EE $NIST TrustAnchorRootCertificate.crt GoodCACert.crt  InvalidEESignatureTest3EE.crt
 pkixutil test_validatechain_NB NIST-Test.4.1.4 ENE $NIST TrustAnchorRootCertificate.crt DSACACert.crt ValidDSASignaturesTest4EE.crt
+pkixutil_or test_validatechain_NB NIST-Test.4.1.4 ENE $NIST TrustAnchorRootCertificate.crt DSACACert.crt ValidDSASignaturesTest4EE.crt
 pkixutil test_validatechain_NB NIST-Test.4.1.5 ENE $NIST TrustAnchorRootCertificate.crt DSACACert.crt DSAParametersInheritedCACert.crt ValidDSAParameterInheritanceTest5EE.crt
+pkixutil_or test_validatechain_NB NIST-Test.4.1.5 ENE $NIST TrustAnchorRootCertificate.crt DSACACert.crt DSAParametersInheritedCACert.crt ValidDSAParameterInheritanceTest5EE.crt
 EOF
 
 tracedErrors=$?
 
 LOGGING=0
 SOCKETTRACE=0
 
 RunTests <<EOF
@@ -494,18 +499,18 @@ pkixutil test_buildchain ${LDAP}  NIST-T
 pkixutil test_buildchain ${LDAP}  NIST-Test.4.13.36 ENE $NIST ValidURInameConstraintsTest36EE.crt nameConstraintsURI2CACert.crt TrustAnchorRootCertificate.crt 
 pkixutil test_buildchain ${LDAP}  NIST-Test.4.13.37 EE $NIST InvalidURInameConstraintsTest37EE.crt nameConstraintsURI2CACert.crt TrustAnchorRootCertificate.crt 
 pkixutil test_buildchain ${LDAP}  NIST-Test.4.13.38 EE $NIST InvalidDNSnameConstraintsTest38EE.crt nameConstraintsDNS1CACert.crt TrustAnchorRootCertificate.crt 
 pkixutil test_buildchain_partialchain ${LDAP}  NIST-Test.4.6.14 ENE $NIST ValidpathLenConstraintTest14EE.crt pathLenConstraint6subsubsubCA41XCert.crt pathLenConstraint6subsubCA41Cert.crt pathLenConstraint6subCA4Cert.crt pathLenConstraint6CACert.crt TrustAnchorRootCertificate.crt 
 pkixutil test_buildchain_partialchain ${LDAP}  NIST-Test.4.6.14 ENE $NIST ValidpathLenConstraintTest14EE.crt pathLenConstraint6subsubsubCA41XCert.crt pathLenConstraint6subsubCA41Cert.crt TrustAnchorRootCertificate.crt pathLenConstraint6subCA4Cert.crt pathLenConstraint6CACert.crt TrustAnchorRootCertificate.crt 
 pkixutil test_buildchain_partialchain ${LDAP}  NIST-Test.4.13.13 EE $NIST InvalidDNnameConstraintsTest13EE.crt nameConstraintsDN1subCA2Cert.crt nameConstraintsDN1subCA2Cert.crt nameConstraintsDN1CACert.crt TrustAnchorRootCertificate.crt
 pkixutil test_buildchain_partialchain ${LDAP}  NIST-Test.4.13.27 ENE $NIST ValidDNandRFC822nameConstraintsTest27EE.crt nameConstraintsDN1subCA3Cert.crt nameConstraintsDN1subCA2Cert.crt TrustAnchorRootCertificate.crt 
 pkixutil test_buildchain ${LDAP} NIST-PDTest ENE ${NIST_PDTEST} certs/BasicHTTPURIPathDiscoveryTest2EE.crt certs/BasicHTTPURITrustAnchorRootCert.crt
-pkixutil test_ocsp OCSP-Test ENE ${HOSTDIR}/ocsp anchorcert.crt goodcert.crt
-pkixutil test_ocsp OCSP-Test EE ${HOSTDIR}/ocsp anchorcert.crt revokedcert.crt
+pkixutil test_ocsp -d ${HOSTDIR}/ocsp OCSP-Test ENE ${HOSTDIR}/ocsp anchorcert.crt goodcert.crt
+pkixutil test_ocsp -d ${HOSTDIR}/ocsp OCSP-Test EE ${HOSTDIR}/ocsp anchorcert.crt revokedcert.crt
 EOF
 
 totalErrors=$?
 totalErrors=`expr ${totalErrors} + ${tracedErrors}`
 
 html_msg ${totalErrors} 0 "&nbsp;&nbsp;&nbsp;${testunit}: passed ${passed} of ${numtests} tests"
 exit ${totalErrors}
 
--- a/security/nss/tests/libpkix/sample_apps/runPerf.sh
+++ b/security/nss/tests/libpkix/sample_apps/runPerf.sh
@@ -122,17 +122,17 @@ loopTest()
     Display ""
     Display "*******************************************************************************"
     Display "START OF TESTS FOR PKIX PERFORMANCE SANITY LOOP (${totalLoop} times)"
 Display "*******************************************************************************"
     Display ""
 
     errors=0
     iLoop=0
-    perfPgm="${DIST_BIN}/pkixutil libpkix_buildthreads 5 8 ValidCertificatePathTest1EE"
+    perfPgm="${DIST_BIN}/pkixutil libpkix_buildthreads -d . 5 8 ValidCertificatePathTest1EE"
 
     while [ $iLoop -lt $totalLoop ]
     do
         iLoop=`expr $iLoop + 1`
         numtests=`expr ${numtests} + 1`
 
         Display "Running ${perfPgm}"
         ${perfPgm} > ${testOut} 2>&1
@@ -149,22 +149,21 @@ Display "*******************************
         fi
     done
 
     return ${errors}
 
 }
 
 #main
-
 perfTest <<EOF
-pkixutil libpkix_buildthreads 5 1 ValidCertificatePathTest1EE
-pkixutil libpkix_buildthreads 5 8 ValidCertificatePathTest1EE
-pkixutil nss_threads 5 1 ValidCertificatePathTest1EE
-pkixutil nss_threads 5 8 ValidCertificatePathTest1EE
+pkixutil libpkix_buildthreads -d . 5 1 ValidCertificatePathTest1EE
+pkixutil libpkix_buildthreads -d . 5 8 ValidCertificatePathTest1EE
+pkixutil nss_threads -d . 5 1 ValidCertificatePathTest1EE
+pkixutil nss_threads -d . 5 8 ValidCertificatePathTest1EE
 EOF
 
 totalErrors=$?
 html_msg ${totalErrors} 0 "&nbsp;&nbsp;&nbsp;performance test: passed ${passed} of ${numtests} tests"
 
 numtests=0
 passed=0
 loopTest