From b2a1ea3a526d32c4f19669913a56f018ccf26a01 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 24 Apr 2001 23:04:59 +0000 Subject: 2001-04-24 Joel Sherrill * psxfile01/test.c, psxfile01/psxfile01.scn : Added test case for open, write, reopen, append twice from Andrew Bythell that tripped an initialization problem in the IMFS. --- testsuites/psxtests/psxfile01/test.c | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'testsuites/psxtests/psxfile01/test.c') diff --git a/testsuites/psxtests/psxfile01/test.c b/testsuites/psxtests/psxfile01/test.c index d935babd9f..4f42e32a38 100644 --- a/testsuites/psxtests/psxfile01/test.c +++ b/testsuites/psxtests/psxfile01/test.c @@ -35,6 +35,8 @@ #include #include +void test_case_reopen_append(void); + char test_write_buffer[ 1024 ]; /* @@ -498,8 +500,48 @@ int main( rtems_status = rtems_io_register_name( "/dev/console", 0, 0 ); + test_case_reopen_append(); + printf( "*** END OF FILE TEST 1 ***\n" ); exit( 0 ); } +/* + * Open/Create a File and write to it + * + * Test case submitted by Andrew Bythell . + * + */ + +void test_file (char *filename, char *mode); + +void test_case_reopen_append(void) +{ + printf ("Writing First File\n"); + test_file ("/one.txt", "a"); + test_file ("/one.txt", "a"); + + /* but not the second time - this will insert junk. + the number of ^@'s seems to equal the number of + actual characters in the file */ + + printf ("Writing Second File\n"); + test_file ("/two.txt", "a"); + test_file ("/two.txt", "a"); + + test_cat( "/one.txt", 0, 1024 ); + test_cat( "/two.txt", 0, 1024 ); +} + +void test_file (char *filename, char *mode) +{ + FILE *fp; + fp = fopen (filename, mode); + if (!fp) + perror ("fopen"); + fprintf (fp, "this is a test line\n"); + if (fclose (fp)) + perror ("fclose"); +} + -- cgit v1.2.3