summaryrefslogtreecommitdiffstats
path: root/nsprpub/pr/tests/dlltest.c
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2020-01-02 21:01:38 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-01-02 21:01:38 +0100
commitf7d30133221896638f7bf4f66c504255c4b14f48 (patch)
tree5f3e07a049f388a3a309a615b8884318f6668a98 /nsprpub/pr/tests/dlltest.c
parent26b297510a11758727438df4669357a2a2bc42ce (diff)
downloadUXP-f7d30133221896638f7bf4f66c504255c4b14f48.tar
UXP-f7d30133221896638f7bf4f66c504255c4b14f48.tar.gz
UXP-f7d30133221896638f7bf4f66c504255c4b14f48.tar.lz
UXP-f7d30133221896638f7bf4f66c504255c4b14f48.tar.xz
UXP-f7d30133221896638f7bf4f66c504255c4b14f48.zip
Issue #1338 - Part 1: Update NSPR to 4.24
Diffstat (limited to 'nsprpub/pr/tests/dlltest.c')
-rw-r--r--nsprpub/pr/tests/dlltest.c74
1 files changed, 50 insertions, 24 deletions
diff --git a/nsprpub/pr/tests/dlltest.c b/nsprpub/pr/tests/dlltest.c
index 1cf82bc84..d68732281 100644
--- a/nsprpub/pr/tests/dlltest.c
+++ b/nsprpub/pr/tests/dlltest.c
@@ -11,12 +11,12 @@
**
** Modification History:
** 14-May-97 AGarcia- Converted the test to accomodate the debug_mode flag.
-** The debug mode will print all of the printfs associated with this test.
-** The regress mode will be the default mode. Since the regress tool limits
+** The debug mode will print all of the printfs associated with this test.
+** The regress mode will be the default mode. Since the regress tool limits
** the output to a one line status:PASS or FAIL,all of the printf statements
-** have been handled with an if (debug_mode) statement.
+** have been handled with an if (debug_mode) statement.
** 04-June-97 AGarcia removed the Test_Result function. Regress tool has been updated to
-** recognize the return code from tha main program.
+** recognize the return code from tha main program.
** 12-June-97 Revert to return code 0 and 1.
***********************************************************************/
@@ -61,7 +61,9 @@ int main(int argc, char** argv)
*/
libName = PR_GetLibraryName("dll", "my");
- if (debug_mode) printf("Loading library %s\n", libName);
+ if (debug_mode) {
+ printf("Loading library %s\n", libName);
+ }
lib = PR_LoadLibrary(libName);
PR_FreeLibraryName(libName);
if (lib == NULL) {
@@ -72,7 +74,9 @@ int main(int argc, char** argv)
fprintf(
stderr, "PR_LoadLibrary failed (%d, %d, %s)\n",
PR_GetError(), PR_GetOSError(), text);
- if (!debug_mode) failed_already=1;
+ if (!debug_mode) {
+ failed_already=1;
+ }
}
getFcn = (GetFcnType) PR_FindSymbol(lib, "My_GetValue");
setFcn = (SetFcnType) PR_FindFunctionSymbol(lib, "My_SetValue");
@@ -80,9 +84,13 @@ int main(int argc, char** argv)
value = (*getFcn)();
if (value != 888) {
fprintf(stderr, "Test 1 failed: set value to 888, but got %d\n", value);
- if (!debug_mode) failed_already=1;
+ if (!debug_mode) {
+ failed_already=1;
+ }
+ }
+ if (debug_mode) {
+ printf("Test 1 passed\n");
}
- if (debug_mode) printf("Test 1 passed\n");
/*
* Test 2: get a second handle to the same library (this should increment
@@ -93,24 +101,32 @@ int main(int argc, char** argv)
getFcn = (GetFcnType) PR_FindSymbolAndLibrary("My_GetValue", &lib2);
if (NULL == getFcn || lib != lib2) {
fprintf(stderr, "Test 2 failed: handles for the same library are not "
- "equal: handle 1: %p, handle 2: %p\n", lib, lib2);
- if (!debug_mode) failed_already=1;
+ "equal: handle 1: %p, handle 2: %p\n", lib, lib2);
+ if (!debug_mode) {
+ failed_already=1;
+ }
}
setFcn = (SetFcnType) PR_FindSymbol(lib2, "My_SetValue");
value = (*getFcn)();
if (value != 888) {
fprintf(stderr, "Test 2 failed: value should be 888, but got %d\n",
- value);
- if (!debug_mode) failed_already=1;
+ value);
+ if (!debug_mode) {
+ failed_already=1;
+ }
}
(*setFcn)(777);
value = (*getFcn)();
if (value != 777) {
fprintf(stderr, "Test 2 failed: set value to 777, but got %d\n", value);
- if (!debug_mode) failed_already=1;
+ if (!debug_mode) {
+ failed_already=1;
+ }
goto exit_now;
}
- if (debug_mode) printf("Test 2 passed\n");
+ if (debug_mode) {
+ printf("Test 2 passed\n");
+ }
/*
* Test 3: unload the library. The library should still be accessible
@@ -120,8 +136,10 @@ int main(int argc, char** argv)
status = PR_UnloadLibrary(lib);
if (PR_FAILURE == status) {
fprintf(stderr, "Test 3 failed: cannot unload library: (%d, %d)\n",
- PR_GetError(), PR_GetOSError());
- if (!debug_mode) failed_already=1;
+ PR_GetError(), PR_GetOSError());
+ if (!debug_mode) {
+ failed_already=1;
+ }
goto exit_now;
}
getFcn = (GetFcnType) PR_FindFunctionSymbol(lib2, "My_GetValue");
@@ -130,10 +148,14 @@ int main(int argc, char** argv)
value = (*getFcn)();
if (value != 666) {
fprintf(stderr, "Test 3 failed: set value to 666, but got %d\n", value);
- if (!debug_mode) failed_already=1;
+ if (!debug_mode) {
+ failed_already=1;
+ }
goto exit_now;
}
- if (debug_mode) printf("Test 3 passed\n");
+ if (debug_mode) {
+ printf("Test 3 passed\n");
+ }
/*
* Test 4: unload the library, testing the reference count mechanism.
@@ -142,15 +164,19 @@ int main(int argc, char** argv)
status = PR_UnloadLibrary(lib2);
if (PR_FAILURE == status) {
fprintf(stderr, "Test 4 failed: cannot unload library: (%d, %d)\n",
- PR_GetError(), PR_GetOSError());
- if (!debug_mode) failed_already=1;
+ PR_GetError(), PR_GetOSError());
+ if (!debug_mode) {
+ failed_already=1;
+ }
goto exit_now;
}
getFcn = (GetFcnType) PR_FindFunctionSymbolAndLibrary("My_GetValue", &lib2);
if (NULL != getFcn) {
fprintf(stderr, "Test 4 failed: how can we find a symbol "
- "in an already unloaded library?\n");
- if (!debug_mode) failed_already=1;
+ "in an already unloaded library?\n");
+ if (!debug_mode) {
+ failed_already=1;
+ }
goto exit_now;
}
if (debug_mode) {
@@ -163,7 +189,7 @@ int main(int argc, char** argv)
{
PRStaticLinkTable slt[10];
PRLibrary *lib;
-
+
lib = PR_LoadStaticLibrary( "my.dll", slt );
if ( lib == NULL )
{
@@ -177,7 +203,7 @@ int main(int argc, char** argv)
}
goto exit_now;
-exit_now:
+exit_now:
PR_Cleanup();
if (failed_already) {