2016-06-07 00:20:41 +02:00
|
|
|
#pragma once
|
|
|
|
#ifndef MESSMER_FSPP_FSTEST_FSPPDEVICETEST_TIMESTAMPS_H_
|
|
|
|
#define MESSMER_FSPP_FSTEST_FSPPDEVICETEST_TIMESTAMPS_H_
|
|
|
|
|
|
|
|
#include "testutils/TimestampTestUtils.h"
|
|
|
|
|
|
|
|
template<class ConcreteFileSystemTestFixture>
|
2017-01-21 20:16:35 +01:00
|
|
|
class FsppDeviceTest_Timestamps: public FsppNodeTest<ConcreteFileSystemTestFixture>, public TimestampTestUtils<ConcreteFileSystemTestFixture> {
|
2016-06-07 00:20:41 +02:00
|
|
|
public:
|
|
|
|
void Test_Load_While_Loaded() {
|
2016-06-07 21:48:21 +02:00
|
|
|
auto node = this->CreateNode("/mynode");
|
2017-09-16 18:45:15 +02:00
|
|
|
auto operation = [this] () {
|
2016-06-07 21:48:21 +02:00
|
|
|
this->device->Load("/mynode");
|
2016-06-07 00:20:41 +02:00
|
|
|
};
|
2017-01-21 20:16:35 +01:00
|
|
|
this->EXPECT_OPERATION_UPDATES_TIMESTAMPS_AS("/mynode", operation, {this->ExpectDoesntUpdateAnyTimestamps});
|
2016-06-07 00:20:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Test_Load_While_Not_Loaded() {
|
2018-09-14 07:38:05 +02:00
|
|
|
fspp::Node::stat_info oldStat{};
|
2016-06-07 00:20:41 +02:00
|
|
|
{
|
2016-06-07 21:48:21 +02:00
|
|
|
auto node = this->CreateNode("/mynode");
|
2017-01-21 20:16:35 +01:00
|
|
|
oldStat = this->stat(*node);
|
2016-06-10 02:47:29 +02:00
|
|
|
this->ensureNodeTimestampsAreOld(oldStat);
|
2016-06-07 00:20:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this->device->Load("/myfile");
|
|
|
|
|
2016-06-07 21:48:21 +02:00
|
|
|
auto node = this->device->Load("/mynode");
|
2016-06-07 00:20:41 +02:00
|
|
|
|
2016-06-07 21:48:21 +02:00
|
|
|
//Test that timestamps didn't change
|
2018-09-14 07:38:05 +02:00
|
|
|
fspp::Node::stat_info newStat = this->stat(*node.value());
|
|
|
|
EXPECT_EQ(oldStat.atime, newStat.atime);
|
|
|
|
EXPECT_EQ(oldStat.mtime, newStat.mtime);
|
|
|
|
EXPECT_EQ(oldStat.ctime, newStat.ctime);
|
2016-06-07 00:20:41 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
REGISTER_NODE_TEST_CASE(FsppDeviceTest_Timestamps,
|
|
|
|
Load_While_Loaded,
|
|
|
|
Load_While_Not_Loaded
|
|
|
|
);
|
|
|
|
|
|
|
|
#endif
|