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>
|
2016-06-07 22:07:22 +02:00
|
|
|
class FsppDeviceTest_Timestamps: public FsppNodeTest<ConcreteFileSystemTestFixture>, public TimestampTestUtils<fspp::Node> {
|
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");
|
|
|
|
auto operation = [this, &node] () {
|
|
|
|
this->device->Load("/mynode");
|
2016-06-07 00:20:41 +02:00
|
|
|
};
|
2016-06-08 05:48:29 +02:00
|
|
|
this->EXPECT_OPERATION_UPDATES_TIMESTAMPS_AS(*node, operation, {ExpectDoesntUpdateAnyTimestamps});
|
2016-06-07 00:20:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Test_Load_While_Not_Loaded() {
|
|
|
|
struct stat oldStat;
|
|
|
|
{
|
2016-06-07 21:48:21 +02:00
|
|
|
auto node = this->CreateNode("/mynode");
|
|
|
|
oldStat = stat(*node);
|
|
|
|
this->ensureNodeTimestampsAreOld(*node);
|
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
|
|
|
|
struct stat newStat = stat(*node.value());
|
2016-06-07 00:20:41 +02:00
|
|
|
EXPECT_EQ(oldStat.st_atim, newStat.st_atim);
|
|
|
|
EXPECT_EQ(oldStat.st_mtim, newStat.st_mtim);
|
|
|
|
EXPECT_EQ(oldStat.st_ctim, newStat.st_ctim);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
REGISTER_NODE_TEST_CASE(FsppDeviceTest_Timestamps,
|
|
|
|
Load_While_Loaded,
|
|
|
|
Load_While_Not_Loaded
|
|
|
|
);
|
|
|
|
|
|
|
|
#endif
|