summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--netfs/unittests/testCore.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/netfs/unittests/testCore.cpp b/netfs/unittests/testCore.cpp
index f72770c..2e82b32 100644
--- a/netfs/unittests/testCore.cpp
+++ b/netfs/unittests/testCore.cpp
@@ -325,6 +325,33 @@ BOOST_AUTO_TEST_CASE( chown )
BOOST_REQUIRE_EQUAL(fuse->rmdir("/dir"), 0);
}
+BOOST_AUTO_TEST_CASE( utimens )
+{
+ BOOST_REQUIRE_EQUAL(fuse->mknod("/file", 0600, 0), 0);
+ struct timespec times[2];
+ times[0].tv_sec = 1;
+ times[0].tv_nsec = 100;
+ times[1].tv_sec = 2;
+ times[1].tv_nsec = 200;
+ BOOST_REQUIRE_EQUAL(fuse->utimens("/file", times), 0);
+ times[1].tv_nsec = -200;
+ BOOST_REQUIRE_EQUAL(fuse->utimens("/file", times), -EINVAL);
+ struct stat st;
+ memset(&st, 0, sizeof(st));
+ BOOST_REQUIRE_EQUAL(fuse->getattr("/file", &st), 0);
+ BOOST_REQUIRE_EQUAL(st.st_atim.tv_sec, 1);
+ BOOST_REQUIRE_EQUAL(st.st_mtim.tv_sec, 2);
+ // Protocol discards nsec
+ BOOST_REQUIRE_EQUAL(st.st_atim.tv_nsec, 0);
+ BOOST_REQUIRE_EQUAL(st.st_mtim.tv_nsec, 0);
+ // Real file doesn't
+ BOOST_REQUIRE_EQUAL(lstat((binDir / testExport / "file").c_str(), &st), 0);
+ BOOST_REQUIRE_EQUAL(st.st_atim.tv_sec, 1);
+ BOOST_REQUIRE_EQUAL(st.st_mtim.tv_sec, 2);
+ BOOST_REQUIRE_EQUAL(st.st_atim.tv_nsec, 100);
+ BOOST_REQUIRE_EQUAL(st.st_mtim.tv_nsec, 200);
+}
+
BOOST_AUTO_TEST_SUITE_END();
BOOST_AUTO_TEST_CASE( testNoAuthNoPass )