Update contrib.
2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Some file manipulation via STDIO
22 #include <stdlib.h> /* definition of exit() */
27 #include <unistd.h> /* for getcwd */
28 #include <sys/fcntl.h> /* for O_RDONLY */
34 "I wandered lonely as a cloud\n",
35 "That floats on high o'er hill and vale\n",
39 char *extraline = "Something something daffodils";
42 "I wandered lonely as a cloud\n"
43 "That floats on high o'er hill and vale\n"
44 "Something something daffodils";
46 char* filename = "c:\\tfiles.txt";
49 @SYMTestCaseID SYSLIB-STDLIB-CT-1055
50 @SYMTestCaseDesc Tests for file manipulation operations
52 @SYMTestActions Create a new file and write some text into it,check for errors
53 Open a file for appending,close and open to read back the file.Check for errors
54 @SYMTestExpectedResults Test must not fail
64 test_Next("Writing simple text file");
66 out = fopen(filename, "w");
69 for (n=0; poem[n]; n++)
71 err=fputs(poem[n], out);
76 /* 2. Open a file for appending */
78 test_Next("Open file for appending");
80 out = fopen(filename, "a");
83 n = fwrite(extraline, 1, strlen(extraline), out);
84 test(n == (int)strlen(extraline));
87 /* 3. Read back the file */
89 test_Next("Read back the file using fread");
91 in = fopen(filename, "r");
97 n = fread(buf, 1, 17, in);
100 test(strncmp(buf,cp,n)==0);
107 /* 4. Read back the file a line at a time */
109 test_Next("Read back the file using fgets");
111 in = fopen(filename, "r");
117 cp = fgets(buf, sizeof(buf), in);
121 test(strcmp(cp,poem[n])==0);
125 test(strcmp(cp,extraline)==0);
133 @SYMTestCaseID SYSLIB-STDLIB-CT-1056
134 @SYMTestCaseDesc Tests for maximum files open and close operations
135 @SYMTestPriority High
136 @SYMTestActions Open a file 100 times and close them in different orders.Tests for the error code.
137 @SYMTestExpectedResults Test must not fail
146 test_Next("Open file 100 times, close in reverse order");
147 for (i=0; i<NFILES; i++)
149 fids[i] = open(filename, O_RDONLY, 0666);
152 for (i=NFILES-1; i>=0; i--)
157 test_Next("Open file 100 times, close in same order");
158 for (i=0; i<NFILES; i++)
160 fids[i] = open(filename, O_RDONLY, 0666);
163 for (i=0; i<NFILES; i++)
168 test_Next("Open file 100 times, close in mod 7 order");
169 for (i=0; i<NFILES; i++)
171 fids[i] = open(filename, O_RDONLY, 0666);
174 for (i=0,n=0; i<NFILES; i++)
203 test_Title("TFILES");
207 test_Next("Do it again using the CPosixServer (for them, not me)");
210 start_posix_server(); /* calls SpawnPosixServer from C++ code */
213 client=create_thread(allTests, "TFILES tests");
215 start_thread(client);
216 err=wait_for_thread(client);