Windows compatibility for struct stat

This commit is contained in:
Sebastian Messmer 2018-09-03 07:41:38 -07:00
parent a7ee4e5446
commit 2d757b028d
3 changed files with 18 additions and 9 deletions

View File

@ -6,7 +6,8 @@ using ::testing::Values;
class FuseLstatReturnATimeTest: public FuseLstatReturnTest<time_t>, public WithParamInterface<time_t> {
private:
void set(struct stat *stat, time_t value) override {
stat->st_atime = value;
stat->st_atim.tv_sec = value;
stat->st_atim.tv_nsec = 0;
}
};
INSTANTIATE_TEST_CASE_P(FuseLstatReturnATimeTest, FuseLstatReturnATimeTest, Values(
@ -18,10 +19,12 @@ INSTANTIATE_TEST_CASE_P(FuseLstatReturnATimeTest, FuseLstatReturnATimeTest, Valu
TEST_P(FuseLstatReturnATimeTest, ReturnedFileAtimeIsCorrect) {
struct ::stat result = CallFileLstatWithValue(GetParam());
EXPECT_EQ(GetParam(), result.st_atime);
EXPECT_EQ(GetParam(), result.st_atim.tv_sec);
EXPECT_EQ(0, result.st_atim.tv_nsec);
}
TEST_P(FuseLstatReturnATimeTest, ReturnedDirAtimeIsCorrect) {
struct ::stat result = CallDirLstatWithValue(GetParam());
EXPECT_EQ(GetParam(), result.st_atime);
EXPECT_EQ(GetParam(), result.st_atim.tv_sec);
EXPECT_EQ(0, result.st_atim.tv_nsec);
}

View File

@ -6,7 +6,8 @@ using ::testing::Values;
class FuseLstatReturnCtimeTest: public FuseLstatReturnTest<time_t>, public WithParamInterface<time_t> {
private:
void set(struct stat *stat, time_t value) override {
stat->st_ctime = value;
stat->st_ctim.tv_sec = value;
stat->st_ctim.tv_nsec = 0;
}
};
INSTANTIATE_TEST_CASE_P(FuseLstatReturnCtimeTest, FuseLstatReturnCtimeTest, Values(
@ -18,10 +19,12 @@ INSTANTIATE_TEST_CASE_P(FuseLstatReturnCtimeTest, FuseLstatReturnCtimeTest, Valu
TEST_P(FuseLstatReturnCtimeTest, ReturnedFileCtimeIsCorrect) {
struct ::stat result = CallFileLstatWithValue(GetParam());
EXPECT_EQ(GetParam(), result.st_ctime);
EXPECT_EQ(GetParam(), result.st_ctim.tv_sec);
EXPECT_EQ(0, result.st_ctim.tv_nsec);
}
TEST_P(FuseLstatReturnCtimeTest, ReturnedDirCtimeIsCorrect) {
struct ::stat result = CallDirLstatWithValue(GetParam());
EXPECT_EQ(GetParam(), result.st_ctime);
EXPECT_EQ(GetParam(), result.st_ctim.tv_sec);
EXPECT_EQ(0, result.st_ctim.tv_nsec);
}

View File

@ -6,7 +6,8 @@ using ::testing::Values;
class FuseLstatReturnMtimeTest: public FuseLstatReturnTest<time_t>, public WithParamInterface<time_t> {
private:
void set(struct stat *stat, time_t value) override {
stat->st_mtime = value;
stat->st_mtim.tv_sec = value;
stat->st_mtim.tv_nsec = 0;
}
};
INSTANTIATE_TEST_CASE_P(FuseLstatReturnMtimeTest, FuseLstatReturnMtimeTest, Values(
@ -18,10 +19,12 @@ INSTANTIATE_TEST_CASE_P(FuseLstatReturnMtimeTest, FuseLstatReturnMtimeTest, Valu
TEST_P(FuseLstatReturnMtimeTest, ReturnedFileMtimeIsCorrect) {
struct ::stat result = CallFileLstatWithValue(GetParam());
EXPECT_EQ(GetParam(), result.st_mtime);
EXPECT_EQ(GetParam(), result.st_mtim.tv_sec);
EXPECT_EQ(0, result.st_mtim.tv_nsec);
}
TEST_P(FuseLstatReturnMtimeTest, ReturnedDirMtimeIsCorrect) {
struct ::stat result = CallDirLstatWithValue(GetParam());
EXPECT_EQ(GetParam(), result.st_mtime);
EXPECT_EQ(GetParam(), result.st_mtim.tv_sec);
EXPECT_EQ(0, result.st_mtim.tv_nsec);
}