summaryrefslogtreecommitdiff
path: root/pr/tests/append.c
diff options
context:
space:
mode:
Diffstat (limited to 'pr/tests/append.c')
-rw-r--r--pr/tests/append.c68
1 files changed, 44 insertions, 24 deletions
diff --git a/pr/tests/append.c b/pr/tests/append.c
index 53439d5f..9d688a4f 100644
--- a/pr/tests/append.c
+++ b/pr/tests/append.c
@@ -42,27 +42,31 @@ int main(int argc, char **argv)
PLOptStatus os;
PLOptState *opt = PL_CreateOptState(argc, argv, "vd");
- 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 'd': /* debug */
- debug = 1;
- break;
- case 'v': /* verbose */
- verbose = 1;
- break;
- default:
- break;
+ case 'd': /* debug */
+ debug = 1;
+ break;
+ case 'v': /* verbose */
+ verbose = 1;
+ break;
+ default:
+ break;
}
}
- PL_DestroyOptState(opt);
+ PL_DestroyOptState(opt);
} /* end block "Get command line options" */
-/* ---------------------------------------------------------------------- */
+ /* ---------------------------------------------------------------------- */
fd = PR_Open( "/tmp/nsprAppend", (PR_APPEND | PR_CREATE_FILE | PR_TRUNCATE | PR_WRONLY), 0666 );
if ( NULL == fd ) {
- if (debug) printf("PR_Open() failed for writing: %d\n", PR_GetError());
+ if (debug) {
+ printf("PR_Open() failed for writing: %d\n", PR_GetError());
+ }
failedAlready = PR_TRUE;
goto Finished;
}
@@ -70,27 +74,35 @@ int main(int argc, char **argv)
for ( i = 0; i < addedBytes ; i++ ) {
rv = PR_Write( fd, &buf, sizeof(buf));
if ( sizeof(buf) != rv ) {
- if (debug) printf("PR_Write() failed: %d\n", PR_GetError());
+ if (debug) {
+ printf("PR_Write() failed: %d\n", PR_GetError());
+ }
failedAlready = PR_TRUE;
goto Finished;
}
- rv = PR_Seek( fd, 0 , PR_SEEK_SET );
+ rv = PR_Seek( fd, 0, PR_SEEK_SET );
if ( -1 == rv ) {
- if (debug) printf("PR_Seek() failed: %d\n", PR_GetError());
+ if (debug) {
+ printf("PR_Seek() failed: %d\n", PR_GetError());
+ }
failedAlready = PR_TRUE;
goto Finished;
}
}
rc = PR_Close( fd );
if ( PR_FAILURE == rc ) {
- if (debug) printf("PR_Close() failed after writing: %d\n", PR_GetError());
+ if (debug) {
+ printf("PR_Close() failed after writing: %d\n", PR_GetError());
+ }
failedAlready = PR_TRUE;
goto Finished;
}
-/* ---------------------------------------------------------------------- */
+ /* ---------------------------------------------------------------------- */
fd = PR_Open( "/tmp/nsprAppend", PR_RDONLY, 0 );
if ( NULL == fd ) {
- if (debug) printf("PR_Open() failed for reading: %d\n", PR_GetError());
+ if (debug) {
+ printf("PR_Open() failed for reading: %d\n", PR_GetError());
+ }
failedAlready = PR_TRUE;
goto Finished;
}
@@ -98,7 +110,9 @@ int main(int argc, char **argv)
for ( i = 0; i < addedBytes ; i++ ) {
rv = PR_Read( fd, &inBuf, sizeof(inBuf));
if ( sizeof(inBuf) != rv) {
- if (debug) printf("PR_Write() failed: %d\n", PR_GetError());
+ if (debug) {
+ printf("PR_Write() failed: %d\n", PR_GetError());
+ }
failedAlready = PR_TRUE;
goto Finished;
}
@@ -107,19 +121,25 @@ int main(int argc, char **argv)
rc = PR_Close( fd );
if ( PR_FAILURE == rc ) {
- if (debug) printf("PR_Close() failed after reading: %d\n", PR_GetError());
+ if (debug) {
+ printf("PR_Close() failed after reading: %d\n", PR_GetError());
+ }
failedAlready = PR_TRUE;
goto Finished;
}
if ( sum != addedBytes ) {
- if (debug) printf("Uh Oh! addedBytes: %d. Sum: %d\n", addedBytes, sum);
+ if (debug) {
+ printf("Uh Oh! addedBytes: %d. Sum: %d\n", addedBytes, sum);
+ }
failedAlready = PR_TRUE;
goto Finished;
}
-/* ---------------------------------------------------------------------- */
+ /* ---------------------------------------------------------------------- */
Finished:
- if (debug || verbose) printf("%s\n", (failedAlready)? "FAILED" : "PASSED" );
+ if (debug || verbose) {
+ printf("%s\n", (failedAlready)? "FAILED" : "PASSED" );
+ }
return( (failedAlready)? 1 : 0 );
} /* main() */