summaryrefslogtreecommitdiff
path: root/pr/tests/anonfm.c
diff options
context:
space:
mode:
Diffstat (limited to 'pr/tests/anonfm.c')
-rw-r--r--pr/tests/anonfm.c104
1 files changed, 56 insertions, 48 deletions
diff --git a/pr/tests/anonfm.c b/pr/tests/anonfm.c
index 1c3468f3..529be6fa 100644
--- a/pr/tests/anonfm.c
+++ b/pr/tests/anonfm.c
@@ -73,37 +73,37 @@ static void ClientOne( void )
PRStatus rc;
PR_LOG(lm, msgLevel,
- ("ClientOne() starting"));
+ ("ClientOne() starting"));
fmString = PR_GetEnv( fmEnvName );
if ( NULL == fmString ) {
failed_already = 1;
PR_LOG(lm, msgLevel,
- ("ClientOne(): PR_Getenv() failed"));
+ ("ClientOne(): PR_Getenv() failed"));
return;
}
PR_LOG(lm, msgLevel,
- ("ClientOne(): PR_Getenv(): found: %s", fmString));
+ ("ClientOne(): PR_Getenv(): found: %s", fmString));
fm = PR_ImportFileMapFromString( fmString );
if ( NULL == fm ) {
failed_already = 1;
PR_LOG(lm, msgLevel,
- ("ClientOne(): PR_ImportFileMapFromString() failed"));
+ ("ClientOne(): PR_ImportFileMapFromString() failed"));
return;
}
PR_LOG(lm, msgLevel,
- ("ClientOne(): PR_ImportFileMapFromString(): fm: %p", fm ));
+ ("ClientOne(): PR_ImportFileMapFromString(): fm: %p", fm ));
addr = PR_MemMap( fm, LL_ZERO, fmSize );
if ( NULL == addr ) {
failed_already = 1;
PR_LOG(lm, msgLevel,
- ("ClientOne(): PR_MemMap() failed, OSError: %d", PR_GetOSError() ));
+ ("ClientOne(): PR_MemMap() failed, OSError: %d", PR_GetOSError() ));
return;
}
PR_LOG(lm, msgLevel,
- ("ClientOne(): PR_MemMap(): addr: %p", addr ));
+ ("ClientOne(): PR_MemMap(): addr: %p", addr ));
/* write to memory map to release server */
*addr = 1;
@@ -111,17 +111,17 @@ static void ClientOne( void )
rc = PR_MemUnmap( addr, fmSize );
PR_ASSERT( rc == PR_SUCCESS );
PR_LOG(lm, msgLevel,
- ("ClientOne(): PR_MemUnap(): success" ));
+ ("ClientOne(): PR_MemUnap(): success" ));
rc = PR_CloseFileMap( fm );
if ( PR_FAILURE == rc ) {
failed_already = 1;
PR_LOG(lm, msgLevel,
- ("ClientOne(): PR_MemUnap() failed, OSError: %d", PR_GetOSError() ));
+ ("ClientOne(): PR_MemUnap() failed, OSError: %d", PR_GetOSError() ));
return;
}
PR_LOG(lm, msgLevel,
- ("ClientOne(): PR_CloseFileMap(): success" ));
+ ("ClientOne(): PR_CloseFileMap(): success" ));
return;
} /* end ClientOne() */
@@ -150,23 +150,23 @@ static void ServerOne( void )
PRInt32 exit_status;
PR_LOG(lm, msgLevel,
- ("ServerOne() starting"));
+ ("ServerOne() starting"));
fm = PR_OpenAnonFileMap( dirName, fmSize, fmProt );
if ( NULL == fm ) {
failed_already = 1;
PR_LOG(lm, msgLevel,
- ("PR_OpenAnonFileMap() failed"));
+ ("PR_OpenAnonFileMap() failed"));
return;
}
PR_LOG(lm, msgLevel,
- ("ServerOne(): FileMap: %p", fm ));
+ ("ServerOne(): FileMap: %p", fm ));
rc = PR_ExportFileMapAsString( fm, sizeof(fmString), fmString );
if ( PR_FAILURE == rc ) {
failed_already = 1;
PR_LOG(lm, msgLevel,
- ("PR_ExportFileMap() failed"));
+ ("PR_ExportFileMap() failed"));
return;
}
@@ -180,16 +180,17 @@ static void ServerOne( void )
if ( NULL == addr ) {
failed_already = 1;
PR_LOG(lm, msgLevel,
- ("PR_MemMap() failed"));
+ ("PR_MemMap() failed"));
return;
}
/* set initial value for client */
- for (i = 0; i < (PRIntn)fmSize ; i++ )
+ for (i = 0; i < (PRIntn)fmSize ; i++ ) {
*(addr+i) = 0x00;
+ }
PR_LOG(lm, msgLevel,
- ("ServerOne(): PR_MemMap(): addr: %p", addr ));
+ ("ServerOne(): PR_MemMap(): addr: %p", addr ));
/*
** set arguments for child process
@@ -202,22 +203,24 @@ static void ServerOne( void )
proc = PR_CreateProcess(child_argv[0], child_argv, NULL, NULL);
PR_ASSERT( proc );
PR_LOG(lm, msgLevel,
- ("ServerOne(): PR_CreateProcess(): proc: %x", proc ));
+ ("ServerOne(): PR_CreateProcess(): proc: %x", proc ));
/*
** ClientOne() will set the memory to 1
*/
PR_LOG(lm, msgLevel,
- ("ServerOne(): waiting on Client, *addr: %x", *addr ));
+ ("ServerOne(): waiting on Client, *addr: %x", *addr ));
while( *addr == 0x00 ) {
- if ( debug )
+ if ( debug ) {
fprintf(stderr, ".");
+ }
PR_Sleep(PR_MillisecondsToInterval(300));
}
- if ( debug )
+ if ( debug ) {
fprintf(stderr, "\n");
+ }
PR_LOG(lm, msgLevel,
- ("ServerOne(): Client responded" ));
+ ("ServerOne(): Client responded" ));
rc = PR_WaitProcess( proc, &exit_status );
PR_ASSERT( PR_FAILURE != rc );
@@ -226,21 +229,21 @@ static void ServerOne( void )
if ( PR_FAILURE == rc ) {
failed_already = 1;
PR_LOG(lm, msgLevel,
- ("PR_MemUnmap() failed"));
+ ("PR_MemUnmap() failed"));
return;
}
PR_LOG(lm, msgLevel,
- ("ServerOne(): PR_MemUnmap(): success" ));
+ ("ServerOne(): PR_MemUnmap(): success" ));
rc = PR_CloseFileMap(fm);
if ( PR_FAILURE == rc ) {
failed_already = 1;
PR_LOG(lm, msgLevel,
- ("PR_CloseFileMap() failed"));
+ ("PR_CloseFileMap() failed"));
return;
}
PR_LOG(lm, msgLevel,
- ("ServerOne(): PR_CloseFileMap() success" ));
+ ("ServerOne(): PR_CloseFileMap() success" ));
return;
} /* end ServerOne() */
@@ -251,7 +254,7 @@ static void ServerOne( void )
static void ServerTwo( void )
{
PR_LOG(lm, msgLevel,
- ("ServerTwo(): Not implemented yet" ));
+ ("ServerTwo(): Not implemented yet" ));
} /* end ServerTwo() */
@@ -264,30 +267,32 @@ int main(int argc, char **argv)
PLOptStatus os;
PLOptState *opt = PL_CreateOptState(argc, argv, "hdC:");
- while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
+ while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
{
- if (PL_OPT_BAD == os) continue;
+ if (PL_OPT_BAD == os) {
+ continue;
+ }
switch (opt->option)
{
- case 'C': /* Client style */
- client = atol(opt->value);
- break;
- case 's': /* file size */
- fmSize = atol( opt->value ) * 1024;
- break;
- case 'd': /* debug */
- debug = 1;
- msgLevel = PR_LOG_DEBUG;
- break;
- case 'h': /* help message */
- Help();
- break;
- default:
- strcpy(dirName, opt->value);
- break;
+ case 'C': /* Client style */
+ client = atol(opt->value);
+ break;
+ case 's': /* file size */
+ fmSize = atol( opt->value ) * 1024;
+ break;
+ case 'd': /* debug */
+ debug = 1;
+ msgLevel = PR_LOG_DEBUG;
+ break;
+ case 'h': /* help message */
+ Help();
+ break;
+ default:
+ strcpy(dirName, opt->value);
+ break;
}
}
- PL_DestroyOptState(opt);
+ PL_DestroyOptState(opt);
}
lm = PR_NewLogModule("Test"); /* Initialize logging */
@@ -298,13 +303,16 @@ int main(int argc, char **argv)
ClientTwo();
} else {
ServerOne();
- if ( failed_already ) goto Finished;
+ if ( failed_already ) {
+ goto Finished;
+ }
ServerTwo();
}
Finished:
- if ( debug )
+ if ( debug ) {
printf("%s\n", (failed_already)? "FAIL" : "PASS");
+ }
return( (failed_already == PR_TRUE )? 1 : 0 );
} /* main() */
/* end anonfm.c */