From 9581c659da1ac440ea610f0936f23af39a81f38e Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 15 Feb 2016 22:30:30 +0000 Subject: Test utimens behaviour --- netfs/unittests/testCore.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) 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 ) -- cgit v1.2.3