diff options
| author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-02-15 22:30:30 +0000 | 
|---|---|---|
| committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-02-15 22:30:30 +0000 | 
| commit | 9581c659da1ac440ea610f0936f23af39a81f38e (patch) | |
| tree | de266d583beb63f5f2399f469d2b8039a8aedc4a | |
| parent | Test chown behaviour (diff) | |
| download | netfs-9581c659da1ac440ea610f0936f23af39a81f38e.tar.bz2 netfs-9581c659da1ac440ea610f0936f23af39a81f38e.tar.xz netfs-9581c659da1ac440ea610f0936f23af39a81f38e.zip | |
Test utimens behaviour
| -rw-r--r-- | netfs/unittests/testCore.cpp | 27 | 
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 ) | 
