]> pd.if.org Git - pdclib/commitdiff
Switched to tmpfile() where appropriate.
authorsolar <unknown>
Wed, 1 Dec 2010 22:01:42 +0000 (22:01 +0000)
committersolar <unknown>
Wed, 1 Dec 2010 22:01:42 +0000 (22:01 +0000)
Makefile
functions/stdio/clearerr.c
functions/stdio/fprintf.c
functions/stdio/fputs.c
functions/stdio/fread.c
functions/stdio/ftell.c
functions/stdio/fwrite.c
functions/stdio/setbuf.c
functions/stdio/setvbuf.c
functions/stdio/vfprintf.c

index 2fbf9c76d434e77a41460a859b1cadce287f3e15..1d902001d6e615989146b2447d2bb4db523b7fc0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -96,7 +96,6 @@ links:
        @echo "Linking platform/$(PLATFORM)..."
        @cd internals && ln -s ../platform/$(PLATFORM)/internals/_PDCLIB_config.h
        @cd includes && ln -s ../platform/$(PLATFORM)/includes/float.h
-       @cd testing && ln -s ../platform/$(PLATFORM)/testing/printf_reference.txt
        @cd functions/_PDCLIB && for file in $(PATCHFILES1); do basfile=`basename $$file`; if [ ! -f $$basfile ]; then ln -s `ls ../../$$file` .; fi; done
        @cd functions/stdlib && for file in $(PATCHFILES2); do basfile=`basename $$file`; if [ ! -f $$basfile ]; then ln -s `ls ../../$$file` .; fi; done
        @cd functions/stdio && for file in $(PATCHFILES3); do basfile=`basename $$file`; if [ ! -f $$basfile ]; then ln -s `ls ../../$$file` .; fi; done
@@ -105,7 +104,6 @@ unlink:
        @echo "Unlinking platform files..."
        @if [ -f internals/_PDCLIB_config.h ]; then rm internals/_PDCLIB_config.h; fi
        @if [ -f includes/float.h ]; then rm includes/float.h; fi
-       @if [ -f testing/printf_reference.txt ]; then rm testing/printf_reference.txt; fi
        @cd functions/_PDCLIB && for file in $(PATCHFILES1); do basfile=`basename $$file`; if [ -f $$basfile ]; then rm $$basfile; fi; done
        @cd functions/stdlib && for file in $(PATCHFILES2); do basfile=`basename $$file`; if [ -f $$basfile ]; then rm $$basfile; fi; done
        @cd functions/stdio && for file in $(PATCHFILES3); do basfile=`basename $$file`; if [ -f $$basfile ]; then rm $$basfile; fi; done
index 810e62d7606d99f79613df9faa97ec520f13819d..af25029032f1fc4d79ec89654bb4bd690a81592e 100644 (file)
@@ -23,8 +23,7 @@ void clearerr( struct _PDCLIB_file_t * stream )
 int main( void )
 {
     FILE * fh;
-    remove( "testing/testfile" );
-    TESTCASE( ( fh = fopen( "testing/testfile", "w+" ) ) != NULL );
+    TESTCASE( ( fh = tmpfile() ) != NULL );
     /* Flags should be clear */
     TESTCASE( ! ferror( fh ) );
     TESTCASE( ! feof( fh ) );
@@ -46,7 +45,6 @@ int main( void )
     TESTCASE( ! ferror( fh ) );
     TESTCASE( ! feof( fh ) );
     TESTCASE( fclose( fh ) == 0 );
-    remove( "testing/testfile" );
     return TEST_RESULTS;
 }
 
index 38fb9b81fdae0dcd819820006c9caf7cac7902fe..bac19bce869ef3972ad83845847f1f32590c0a45 100644 (file)
@@ -36,10 +36,9 @@ int fprintf( struct _PDCLIB_file_t * _PDCLIB_restrict stream, const char * _PDCL
 int main( void )
 {
     FILE * target;
-    TESTCASE( ( target = fopen( "testing/testfile", "wb+" ) ) != NULL );
+    TESTCASE( ( target = tmpfile() ) != NULL );
 #include "printf_testcases.incl"
     TESTCASE( fclose( target ) == 0 );
-    TESTCASE( remove( "testing/testfile" ) == 0 );
     return TEST_RESULTS;
 }
 
index 1df0ebfa465cab4e81be1983fad5bdc5fe38ca56..2c5e1fa1e1d78b1ee7e17cd5410c1cf631536ffe 100644 (file)
@@ -53,8 +53,7 @@ int main( void )
 {
     char const * const message = "SUCCESS testing fputs()";
     FILE * fh;
-    remove( testfile );
-    TESTCASE( ( fh = fopen( testfile, "w+" ) ) != NULL );
+    TESTCASE( ( fh = tmpfile() ) != NULL );
     TESTCASE( fputs( message, fh ) >= 0 );
     rewind( fh );
     for ( size_t i = 0; i < 23; ++i )
@@ -62,7 +61,6 @@ int main( void )
         TESTCASE( fgetc( fh ) == message[i] );
     }
     TESTCASE( fclose( fh ) == 0 );
-    TESTCASE( remove( testfile ) == 0 );
     return TEST_RESULTS;
 }
 
index c457d481b6d4d22ddd42387627d41b231f0b35de..51e6a7b37a5d8766134dc581e395808d4a2b57de 100644 (file)
@@ -48,12 +48,10 @@ size_t fread( void * _PDCLIB_restrict ptr, size_t size, size_t nmemb, struct _PD
 int main( void )
 {
     FILE * fh;
-    remove( testfile );
-    TESTCASE( ( fh = fopen( testfile, "w" ) ) != NULL );
+    TESTCASE( ( fh = tmpfile() ) != NULL );
     TESTCASE( fwrite( "SUCCESS testing fwrite()\n", 1, 25, fh ) == 25 );
-    TESTCASE( fclose( fh ) == 0 );
     /* TODO: Add readback test. */
-    TESTCASE( remove( testfile ) == 0 );
+    TESTCASE( fclose( fh ) == 0 );
     return TEST_RESULTS;
 }
 
index 09dd17fe189113739befd74e293b4229b57b8738..892c7b282b043f373da705166936886b81d52a13 100644 (file)
@@ -48,8 +48,7 @@ int main( void )
     */
     char * buffer = (char*)malloc( 4 );
     FILE * fh;
-    remove( testfile );
-    TESTCASE( ( fh = fopen( testfile, "w+" ) ) != NULL );
+    TESTCASE( ( fh = tmpfile() ) != NULL );
     TESTCASE( setvbuf( fh, buffer, _IOLBF, 4 ) == 0 );
     TESTCASE( fputc( '1', fh ) == '1' );
     TESTCASE( fputc( '2', fh ) == '2' );
@@ -75,9 +74,8 @@ int main( void )
     TESTCASE_NOREG( fh->bufidx == 0 );
     /* Reading back first character after rewind for basic read check */
     TESTCASE( fgetc( fh ) == '1' );
-    TESTCASE( fclose( fh ) == 0 );
     /* TODO: t.b.c. */
-    remove( testfile );
+    TESTCASE( fclose( fh ) == 0 );
     return TEST_RESULTS;
 }
 
index ca439674045b1c31ed1b1bda6bf8296b46545755..4eabd22943db112e85f8cc07f2cf1ff83b909a72 100644 (file)
@@ -87,12 +87,10 @@ size_t fwrite( const void * _PDCLIB_restrict ptr, size_t size, size_t nmemb, str
 int main( void )
 {
     FILE * fh;
-    remove( testfile );
-    TESTCASE( ( fh = fopen( testfile, "w" ) ) != NULL );
+    TESTCASE( ( fh = tmpfile() ) != NULL );
     TESTCASE( fwrite( "SUCCESS testing fwrite()\n", 1, 25, fh ) == 25 );
-    TESTCASE( fclose( fh ) == 0 );
     /* TODO: Add readback test. */
-    TESTCASE( remove( testfile ) == 0 );
+    TESTCASE( fclose( fh ) == 0 );
     return TEST_RESULTS;
 }
 
index 46db8e3374c109a92494b705e042635db67347a7..fe83277586bfbca905781d63a83dbd01e444ca1a 100644 (file)
@@ -34,21 +34,18 @@ int main( void )
 #ifndef REGTEST
     char buffer[ BUFSIZ + 1 ];
     FILE * fh;
-    remove( testfile );
     /* full buffered */
-    TESTCASE( ( fh = fopen( testfile, "w" ) ) != NULL );
+    TESTCASE( ( fh = tmpfile() ) != NULL );
     setbuf( fh, buffer );
     TESTCASE( fh->buffer == buffer );
     TESTCASE( fh->bufsize == BUFSIZ );
     TESTCASE( ( fh->status & ( _IOFBF | _IONBF | _IOLBF ) ) == _IOFBF );
     TESTCASE( fclose( fh ) == 0 );
-    TESTCASE( remove( testfile ) == 0 );
     /* not buffered */
-    TESTCASE( ( fh = fopen( testfile, "w" ) ) != NULL );
+    TESTCASE( ( fh = tmpfile() ) != NULL );
     setbuf( fh, NULL );
     TESTCASE( ( fh->status & ( _IOFBF | _IONBF | _IOLBF ) ) == _IONBF );
     TESTCASE( fclose( fh ) == 0 );
-    TESTCASE( remove( testfile ) == 0 );
 #else
     puts( " NOTEST setbuf() test driver is PDCLib-specific." );
 #endif
index 2c333382be537002c621b6299ff2fb14ae37545a..ecb0be5e20f7a4063100f2ac8456e747f92f2dbd 100644 (file)
@@ -82,29 +82,25 @@ int main( void )
 #ifndef REGTEST
     char buffer[ BUFFERSIZE ];
     FILE * fh;
-    remove( testfile );
     /* full buffered, user-supplied buffer */
-    TESTCASE( ( fh = fopen( testfile, "w" ) ) != NULL );
+    TESTCASE( ( fh = tmpfile() ) != NULL );
     TESTCASE( setvbuf( fh, buffer, _IOFBF, BUFFERSIZE ) == 0 );
     TESTCASE( fh->buffer == buffer );
     TESTCASE( fh->bufsize == BUFFERSIZE );
     TESTCASE( ( fh->status & ( _IOFBF | _IONBF | _IOLBF ) ) == _IOFBF );
     TESTCASE( fclose( fh ) == 0 );
-    TESTCASE( remove( testfile ) == 0 );
     /* line buffered, lib-supplied buffer */
-    TESTCASE( ( fh = fopen( testfile, "w" ) ) != NULL );
+    TESTCASE( ( fh = tmpfile() ) != NULL );
     TESTCASE( setvbuf( fh, NULL, _IOLBF, BUFFERSIZE ) == 0 );
     TESTCASE( fh->buffer != NULL );
     TESTCASE( fh->bufsize == BUFFERSIZE );
     TESTCASE( ( fh->status & ( _IOFBF | _IONBF | _IOLBF ) ) == _IOLBF );
     TESTCASE( fclose( fh ) == 0 );
-    TESTCASE( remove( testfile ) == 0 );
     /* not buffered, user-supplied buffer */
-    TESTCASE( ( fh = fopen( testfile, "w" ) ) != NULL );
+    TESTCASE( ( fh = tmpfile() ) != NULL );
     TESTCASE( setvbuf( fh, buffer, _IONBF, BUFFERSIZE ) == 0 );
     TESTCASE( ( fh->status & ( _IOFBF | _IONBF | _IOLBF ) ) == _IONBF );
     TESTCASE( fclose( fh ) == 0 );
-    TESTCASE( remove( testfile ) == 0 );
 #else
     puts( " NOTEST setvbuf() test driver is PDCLib-specific." );
 #endif
index 7ab3167499a8d2f57360d01a1b3a458abf4b477d..44c86358783e6b13b3ee13d6ef39e8c71c8add0f 100644 (file)
@@ -69,10 +69,9 @@ static int testprintf( FILE * stream, const char * format, ... )
 int main( void )
 {
     FILE * target;
-    TESTCASE( ( target = fopen( testfile, "wb+" ) ) != NULL );
+    TESTCASE( ( target = tmpfile() ) != NULL );
 #include "printf_testcases.incl"
     TESTCASE( fclose( target ) == 0 );
-    TESTCASE( remove( testfile ) == 0 );
     return TEST_RESULTS;
 }