// S : tags 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 int main() { char buf[ 8 ] = {}; int fd = open( "file", O_CREAT | O_RDWR, 0644 ); int dupfd; assert( fd >= 0 ); assert( write( fd, "tralala", 7 ) == 7 ); dupfd = dup( fd ); assert( dupfd >= 0 ); assert( dupfd != fd ); assert( lseek( dupfd, 0, SEEK_CUR ) == 7 ); assert( lseek( dupfd, 0, SEEK_SET ) == 0 ); assert( lseek( fd, 0, SEEK_CUR ) == 0 ); assert( close( fd ) == 0 ); assert( read( dupfd, buf, 7 ) == 7 ); assert( strcmp( buf, "tralala" ) == 0 ); assert( close( dupfd ) == 0 ); return 0; }