Added file io test to test0. Added close call to libposix.

This commit is contained in:
Bahadir Balban
2008-04-18 21:17:09 +01:00
parent cff7a505e8
commit f7163b7e93
7 changed files with 83 additions and 13 deletions

View File

@@ -6,5 +6,6 @@
int shmtest(void);
int mmaptest(void);
int dirtest(void);
int fileio(void);
#endif /* __TEST0_TESTS_H__ */

View File

@@ -28,7 +28,7 @@ void main(void)
wait_pager(0);
dirtest();
fileio();
while (1)
wait_pager(0);
#if 0

33
tasks/test0/src/fileio.c Normal file
View File

@@ -0,0 +1,33 @@
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <tests.h>
int fileio(void)
{
int fd;
ssize_t cnt;
int err;
char *str = "I WROTE TO THIS FILE\n";
if ((fd = open("/home/bahadir/newfile.txt", O_RDWR | O_CREAT | O_TRUNC, S_IRWXU)) < 0) {
perror("OPEN");
return 0;
}
if ((int)(cnt = write(fd, str, strlen(str))) < 0) {
perror("WRITE");
return 0;
}
if ((err = close(fd)) < 0)
perror("CLOSE");
return 0;
}