static void test_basics(void) { struct stat info1; struct stat info2; test_caseStart("Testing fs"); test_assertInt(mkdir("/newdir",DIR_DEF_MODE),0); fs_createFile("/newdir/file1","foobar"); fs_readFile("/newdir/file1","foobar"); test_assertInt(link("/newdir/file1","/newdir/file2"),0); test_assertInt(stat("/newdir/file1",&info1),0); test_assertInt(stat("/newdir/file2",&info2),0); test_assertInt(memcmp(&info1,&info2,sizeof(struct stat)),0); test_assertUInt(info1.st_nlink,2); test_assertInt(unlink("/newdir/file1"),0); test_assertInt(rmdir("/newdir"),-ENOTEMPTY); test_assertInt(stat("/newdir/file1",&info1),-ENOENT); test_assertInt(stat("/newdir/file2",&info2),0); test_assertUInt(info2.st_nlink,1); test_assertInt(unlink("/newdir/file2"),0); test_assertInt(rmdir("/newdir"),0); int fd = open("/",O_RDONLY); test_assertTrue(fd >= 0); test_assertInt(syncfs(fd),0); close(fd); test_caseSucceeded(); }
static void test_basics(void) { struct stat info1; struct stat info2; test_caseStart("Testing fs"); test_assertInt(mkdir("/newdir",DIR_DEF_MODE),0); fs_createFile("/newdir/file1","foobar"); fs_readFile("/newdir/file1","foobar"); test_assertInt(link("/newdir/file1","/newdir/file2"),0); test_assertInt(stat("/newdir/file1",&info1),0); test_assertInt(stat("/newdir/file2",&info2),0); // compare elements individually, because the structs might contain uninitialized padding test_assertUInt(info1.st_atime,info2.st_atime); test_assertUInt(info1.st_mtime,info2.st_mtime); test_assertUInt(info1.st_ctime,info2.st_ctime); test_assertUInt(info1.st_blocks,info2.st_blocks); test_assertUInt(info1.st_blksize,info2.st_blksize); test_assertUInt(info1.st_dev,info2.st_dev); test_assertUInt(info1.st_uid,info2.st_uid); test_assertUInt(info1.st_gid,info2.st_gid); test_assertUInt(info1.st_ino,info2.st_ino); test_assertUInt(info1.st_nlink,info2.st_nlink); test_assertUInt(info1.st_mode,info2.st_mode); test_assertUInt(info1.st_size,info2.st_size); test_assertUInt(info1.st_nlink,2); test_assertInt(unlink("/newdir/file1"),0); test_assertInt(rmdir("/newdir"),-ENOTEMPTY); test_assertInt(stat("/newdir/file1",&info1),-ENOENT); test_assertInt(stat("/newdir/file2",&info2),0); test_assertUInt(info2.st_nlink,1); test_assertInt(unlink("/newdir/file2"),0); test_assertInt(rmdir("/newdir"),0); int fd = open("/",O_RDONLY); test_assertTrue(fd >= 0); test_assertInt(syncfs(fd),0); close(fd); test_caseSucceeded(); }