// S : tags kleetodo c $TAGS // S : expect --result valid // S : cc -o test.bc $CC_OPT $file // S : verify $V_OPT -o nofail:vfs test.bc #include #include #include #include #include #include int main() { int fd = creat( "file", S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH ); assert( fd != -1 ); int bytes = write( fd, "hello\n", 6 ); __dios_trace_f( "bytes = %d, errno = %d", bytes, errno ); assert( bytes == 6 ); close( fd ); fd = open( "file", O_RDONLY ); assert( fd != -1 ); char buf[6]; bytes = read( fd, &buf, 6 ); __dios_trace_f( "bytes = %d", bytes ); assert( bytes == 6 ); assert( buf[0] == 'h' && buf[1] == 'e' && buf[2] == 'l' && buf[3] == 'l' && buf[4] == 'o' && buf[5] == '\n' ); close( fd ); return 0; }