aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessio Balsini <balsini@google.com>2023-10-13 21:59:24 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-10-13 21:59:24 +0000
commit9dcfff06d6414617f43b8808dd7f5cff2ac9af1c (patch)
treeb1e68ef742f678bee1bb14031bbe38a485f7a82d
parent28bea021e0f9ad7c9b3ebdd3d510d801610caf35 (diff)
parent5e502c3b3fa8b94f6cac114eb78ab51ca374e89d (diff)
downloaddittosuite-9dcfff06d6414617f43b8808dd7f5cff2ac9af1c.tar.gz
Use generic instruction parameters am: 8f11c3cb55 am: f140ae36c1 am: f96577cfcd am: 5e502c3b3f
Original change: https://android-review.googlesource.com/c/platform/test/dittosuite/+/2780992 Change-Id: I8c80426359e0ed2b2a1d81f5f013ec5abac303c9 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--include/ditto/binder_request.h7
-rw-r--r--include/ditto/binder_service.h3
-rw-r--r--include/ditto/close_file.h2
-rw-r--r--include/ditto/delete_file.h4
-rw-r--r--include/ditto/instruction.h7
-rw-r--r--include/ditto/instruction_factory.h2
-rw-r--r--include/ditto/instruction_set.h4
-rw-r--r--include/ditto/invalidate_cache.h2
-rw-r--r--include/ditto/multiprocessing.h2
-rw-r--r--include/ditto/multithreading.h2
-rw-r--r--include/ditto/open_file.h10
-rw-r--r--include/ditto/read_directory.h3
-rw-r--r--include/ditto/read_write_file.h14
-rw-r--r--include/ditto/resize_file.h6
-rw-r--r--src/binder_request.cpp13
-rw-r--r--src/binder_service.cpp5
-rw-r--r--src/close_file.cpp4
-rw-r--r--src/delete_file.cpp10
-rw-r--r--src/instruction.cpp4
-rw-r--r--src/instruction_factory.cpp76
-rw-r--r--src/instruction_set.cpp8
-rw-r--r--src/invalidate_cache.cpp3
-rw-r--r--src/multiprocessing.cpp4
-rw-r--r--src/multithreading.cpp4
-rw-r--r--src/open_file.cpp18
-rw-r--r--src/read_directory.cpp6
-rw-r--r--src/read_write_file.cpp25
-rw-r--r--src/resize_file.cpp10
-rw-r--r--test/close_file_test.cpp5
-rw-r--r--test/delete_file_test.cpp7
-rw-r--r--test/invalidate_cache_test.cpp3
-rw-r--r--test/open_file_test.cpp8
-rw-r--r--test/read_directory_test.cpp6
-rw-r--r--test/read_file_test.cpp83
-rw-r--r--test/resize_file_test.cpp11
-rw-r--r--test/write_file_test.cpp73
36 files changed, 234 insertions, 220 deletions
diff --git a/include/ditto/binder_request.h b/include/ditto/binder_request.h
index bec0178..3c856b2 100644
--- a/include/ditto/binder_request.h
+++ b/include/ditto/binder_request.h
@@ -29,7 +29,7 @@ namespace dittosuite {
class BinderRequest : public Instruction {
public:
- explicit BinderRequest(SyscallInterface& syscall, const std::string& kName, int repeat,
+ explicit BinderRequest(const std::string& kName, const Params& params,
const std::string& service_name);
protected:
@@ -44,8 +44,7 @@ class BinderRequestDitto : public BinderRequest {
public:
inline static const std::string kName = "binder_request_ditto";
- explicit BinderRequestDitto(SyscallInterface& syscall, int repeat,
- const std::string& service_name);
+ explicit BinderRequestDitto(const Params& params, const std::string& service_name);
protected:
void RunSingle() override;
@@ -61,7 +60,7 @@ class BinderRequestMountService : public BinderRequest {
public:
inline static const std::string kName = "binder_request_ms";
- explicit BinderRequestMountService(SyscallInterface& syscall, int repeat);
+ explicit BinderRequestMountService(const Params& params);
protected:
void RunSingle() override;
diff --git a/include/ditto/binder_service.h b/include/ditto/binder_service.h
index fd71d62..7099053 100644
--- a/include/ditto/binder_service.h
+++ b/include/ditto/binder_service.h
@@ -29,8 +29,7 @@ class BinderService : public Instruction {
public:
inline static const std::string kName = "binder_service";
- explicit BinderService(SyscallInterface& syscall, int repeat, const std::string& name,
- int64_t threads);
+ explicit BinderService(const Params& params, const std::string& name, int64_t threads);
protected:
int64_t threads_;
diff --git a/include/ditto/close_file.h b/include/ditto/close_file.h
index c373e8a..48cf3a1 100644
--- a/include/ditto/close_file.h
+++ b/include/ditto/close_file.h
@@ -22,7 +22,7 @@ class CloseFile : public Instruction {
public:
inline static const std::string kName = "close_file";
- explicit CloseFile(SyscallInterface& syscall, int repeat, int input_fd_key);
+ explicit CloseFile(const Params& params, int input_fd_key);
private:
void RunSingle() override;
diff --git a/include/ditto/delete_file.h b/include/ditto/delete_file.h
index 5b61765..5054cab 100644
--- a/include/ditto/delete_file.h
+++ b/include/ditto/delete_file.h
@@ -24,8 +24,8 @@ class DeleteFile : public Instruction {
public:
inline static const std::string kName = "delete_file";
- explicit DeleteFile(SyscallInterface& syscall, int repeat, const std::string& path_name);
- explicit DeleteFile(SyscallInterface& syscall, int repeat, int input_key);
+ explicit DeleteFile(const Params& params, const std::string& path_name);
+ explicit DeleteFile(const Params& params, int input_key);
private:
void SetUpSingle() override;
diff --git a/include/ditto/instruction.h b/include/ditto/instruction.h
index 317e8e0..99ae207 100644
--- a/include/ditto/instruction.h
+++ b/include/ditto/instruction.h
@@ -31,7 +31,12 @@ enum class Reseeding { kOnce, kEachRoundOfCycles, kEachCycle };
class Instruction {
public:
- explicit Instruction(SyscallInterface& syscall, const std::string& name, int repeat);
+ struct Params {
+ SyscallInterface& syscall;
+ int repeat;
+ };
+
+ explicit Instruction(const std::string& name, const Params& params);
virtual ~Instruction() = default;
virtual void SetUp();
diff --git a/include/ditto/instruction_factory.h b/include/ditto/instruction_factory.h
index 57796c3..33fa75a 100644
--- a/include/ditto/instruction_factory.h
+++ b/include/ditto/instruction_factory.h
@@ -32,7 +32,7 @@ namespace dittosuite {
class InstructionFactory {
public:
static std::unique_ptr<InstructionSet> CreateFromProtoInstructionSet(
- const std::list<int>& thread_ids, int repeat,
+ const dittosuite::Instruction::Params& params, const std::list<int>& thread_ids,
const dittosuiteproto::InstructionSet& proto_instruction_set);
static std::unique_ptr<Instruction> CreateFromProtoInstruction(
const std::list<int>& thread_ids, const dittosuiteproto::Instruction& proto_instruction);
diff --git a/include/ditto/instruction_set.h b/include/ditto/instruction_set.h
index a01f128..557db59 100644
--- a/include/ditto/instruction_set.h
+++ b/include/ditto/instruction_set.h
@@ -27,10 +27,10 @@ class InstructionSet : public Instruction {
public:
inline static const std::string kName = "instruction_set";
- explicit InstructionSet(SyscallInterface& syscall, int repeat,
+ explicit InstructionSet(const Params& params,
std::vector<std::unique_ptr<Instruction>> instructions, int list_key,
int item_key, Order order, Reseeding reseeding, uint32_t seed);
- explicit InstructionSet(SyscallInterface& syscall, int repeat,
+ explicit InstructionSet(const Params& params,
std::vector<std::unique_ptr<Instruction>> instructions);
std::unique_ptr<Result> CollectResults(const std::string& prefix) override;
diff --git a/include/ditto/invalidate_cache.h b/include/ditto/invalidate_cache.h
index 305fa88..f34313e 100644
--- a/include/ditto/invalidate_cache.h
+++ b/include/ditto/invalidate_cache.h
@@ -22,7 +22,7 @@ class InvalidateCache : public Instruction {
public:
inline static const std::string kName = "invalidate_cache";
- explicit InvalidateCache(SyscallInterface& syscall, int repeat);
+ explicit InvalidateCache(const Params& params);
private:
void RunSingle() override;
diff --git a/include/ditto/multiprocessing.h b/include/ditto/multiprocessing.h
index e07b278..b685f55 100644
--- a/include/ditto/multiprocessing.h
+++ b/include/ditto/multiprocessing.h
@@ -25,7 +25,7 @@ class Multiprocessing : public Instruction {
public:
inline static const std::string kName = "multiprocessing";
- explicit Multiprocessing(SyscallInterface& syscall, int repeat,
+ explicit Multiprocessing(const Params& params,
std::vector<std::unique_ptr<Instruction>> instructions,
std::vector<std::string> thread_names);
std::unique_ptr<Result> CollectResults(const std::string& prefix) override;
diff --git a/include/ditto/multithreading.h b/include/ditto/multithreading.h
index 8d941df..5641a29 100644
--- a/include/ditto/multithreading.h
+++ b/include/ditto/multithreading.h
@@ -24,7 +24,7 @@ class Multithreading : public Instruction {
public:
inline static const std::string kName = "multithreading";
- explicit Multithreading(SyscallInterface& syscall, int repeat,
+ explicit Multithreading(const Params& params,
std::vector<std::unique_ptr<Instruction>> instructions);
std::unique_ptr<Result> CollectResults(const std::string& prefix) override;
diff --git a/include/ditto/open_file.h b/include/ditto/open_file.h
index 739dfd2..10c0447 100644
--- a/include/ditto/open_file.h
+++ b/include/ditto/open_file.h
@@ -26,12 +26,12 @@ class OpenFile : public Instruction {
inline static const std::string kName = "open_file";
enum class AccessMode { kReadOnly, kWriteOnly, kReadWrite };
- explicit OpenFile(SyscallInterface& syscall, int repeat, const std::string& path_name,
- bool create, bool direct_io, int output_fd_key, AccessMode access_mode);
- explicit OpenFile(SyscallInterface& syscall, int repeat, int input_key, bool create,
- bool direct_io, int output_fd_key, AccessMode access_mode);
- explicit OpenFile(SyscallInterface& syscall, int repeat, bool create, bool direct_io,
+ explicit OpenFile(const Params& params, const std::string& path_name, bool create, bool direct_io,
int output_fd_key, AccessMode access_mode);
+ explicit OpenFile(const Params& params, int input_key, bool create, bool direct_io,
+ int output_fd_key, AccessMode access_mode);
+ explicit OpenFile(const Params& params, bool create, bool direct_io, int output_fd_key,
+ AccessMode access_mode);
private:
void SetUpSingle() override;
diff --git a/include/ditto/read_directory.h b/include/ditto/read_directory.h
index 3376617..7a97270 100644
--- a/include/ditto/read_directory.h
+++ b/include/ditto/read_directory.h
@@ -24,8 +24,7 @@ class ReadDirectory : public Instruction {
public:
inline static const std::string kName = "read_directory";
- explicit ReadDirectory(SyscallInterface& syscall, int repeat, const std::string& directory_name,
- int output_key);
+ explicit ReadDirectory(const Params& params, const std::string& directory_name, int output_key);
private:
void RunSingle() override;
diff --git a/include/ditto/read_write_file.h b/include/ditto/read_write_file.h
index 0e6a677..12a6702 100644
--- a/include/ditto/read_write_file.h
+++ b/include/ditto/read_write_file.h
@@ -27,9 +27,9 @@ namespace dittosuite {
class ReadWriteFile : public Instruction {
public:
- explicit ReadWriteFile(SyscallInterface& syscall, const std::string& name, int repeat,
- int64_t size, int64_t block_size, int64_t starting_offset,
- Order access_order, uint32_t seed, Reseeding reseeding, int input_fd_key);
+ explicit ReadWriteFile(const std::string& name, const Params& params, int64_t size,
+ int64_t block_size, int64_t starting_offset, Order access_order,
+ uint32_t seed, Reseeding reseeding, int input_fd_key);
std::unique_ptr<Result> CollectResults(const std::string& prefix) override;
protected:
@@ -65,7 +65,7 @@ class WriteFile : public ReadWriteFile {
public:
inline static const std::string kName = "write_file";
- explicit WriteFile(SyscallInterface& syscall, int repeat, int64_t size, int64_t block_size,
+ explicit WriteFile(const Params& params, int64_t size, int64_t block_size,
int64_t starting_offset, Order access_order, uint32_t seed,
Reseeding reseeding, bool fsync, int input_fd_key);
@@ -79,9 +79,9 @@ class ReadFile : public ReadWriteFile {
public:
inline static const std::string kName = "read_file";
- explicit ReadFile(SyscallInterface& syscall, int repeat, int64_t size, int64_t block_size,
- int64_t starting_offset, Order access_order, uint32_t seed, Reseeding reseeding,
- int fadvise, int input_fd_key);
+ explicit ReadFile(const Params& params, int64_t size, int64_t block_size, int64_t starting_offset,
+ Order access_order, uint32_t seed, Reseeding reseeding, int fadvise,
+ int input_fd_key);
private:
void SetUpSingle() override;
diff --git a/include/ditto/resize_file.h b/include/ditto/resize_file.h
index 6dad29f..31ca166 100644
--- a/include/ditto/resize_file.h
+++ b/include/ditto/resize_file.h
@@ -25,7 +25,7 @@ class ResizeFile : public Instruction {
public:
inline static const std::string kName = "resize_file";
- explicit ResizeFile(SyscallInterface& syscall, int repeat, int64_t size, int input_fd_key);
+ explicit ResizeFile(const Params& params, int64_t size, int input_fd_key);
protected:
void RunSingle() override;
@@ -36,8 +36,8 @@ class ResizeFile : public Instruction {
class ResizeFileRandom : public ResizeFile {
public:
- explicit ResizeFileRandom(SyscallInterface& syscall, int repeat, int64_t min, int64_t max,
- uint64_t seed, Reseeding reseeding, int input_fd_key);
+ explicit ResizeFileRandom(const Params& params, int64_t min, int64_t max, uint64_t seed,
+ Reseeding reseeding, int input_fd_key);
private:
void SetUp() override;
diff --git a/src/binder_request.cpp b/src/binder_request.cpp
index 88da522..a99efcd 100644
--- a/src/binder_request.cpp
+++ b/src/binder_request.cpp
@@ -20,13 +20,12 @@
namespace dittosuite {
-BinderRequest::BinderRequest(SyscallInterface& syscall, const std::string& kName, int repeat,
+BinderRequest::BinderRequest(const std::string& kName, const Params& params,
const std::string& service_name)
- : Instruction(syscall, kName, repeat), service_name_(service_name) {}
+ : Instruction(kName, params), service_name_(service_name) {}
-BinderRequestDitto::BinderRequestDitto(SyscallInterface& syscall, int repeat,
- const std::string& service_name)
- : BinderRequest(syscall, kName, repeat, service_name) {}
+BinderRequestDitto::BinderRequestDitto(const Params& params, const std::string& service_name)
+ : BinderRequest(kName, params, service_name) {}
void BinderRequestDitto::RunSingle() {
const char c = 1;
@@ -53,8 +52,8 @@ void BinderRequestDitto::TearDownSingle(bool is_last) {
}
}
-BinderRequestMountService::BinderRequestMountService(SyscallInterface& syscall, int repeat)
- : BinderRequest(syscall, kName, repeat, "mount") {}
+BinderRequestMountService::BinderRequestMountService(const Params& params)
+ : BinderRequest(kName, params, "mount") {}
void BinderRequestMountService::RunSingle() {
bool ret = service_->isUsbMassStorageConnected();
diff --git a/src/binder_service.cpp b/src/binder_service.cpp
index 8097c0a..fc0ee17 100644
--- a/src/binder_service.cpp
+++ b/src/binder_service.cpp
@@ -29,9 +29,8 @@ using android::defaultServiceManager;
namespace dittosuite {
-BinderService::BinderService(SyscallInterface& syscall, int repeat, const std::string& name,
- int64_t threads)
- : Instruction(syscall, kName, repeat), threads_(threads), name_(name) {
+BinderService::BinderService(const Params& params, const std::string& name, int64_t threads)
+ : Instruction(kName, params), threads_(threads), name_(name) {
pthread_mutex_init(&s_work_lock, nullptr);
pthread_cond_init(&s_work_cond, nullptr);
}
diff --git a/src/close_file.cpp b/src/close_file.cpp
index 37dc7a0..97a8e6e 100644
--- a/src/close_file.cpp
+++ b/src/close_file.cpp
@@ -19,8 +19,8 @@
namespace dittosuite {
-CloseFile::CloseFile(SyscallInterface& syscall, int repeat, int input_fd_key)
- : Instruction(syscall, kName, repeat), input_fd_key_(input_fd_key) {}
+CloseFile::CloseFile(const Params& params, int input_fd_key)
+ : Instruction(kName, params), input_fd_key_(input_fd_key) {}
void CloseFile::RunSingle() {
int fd = std::get<int>(SharedVariables::Get(input_fd_key_));
diff --git a/src/delete_file.cpp b/src/delete_file.cpp
index 43f2803..641e5a6 100644
--- a/src/delete_file.cpp
+++ b/src/delete_file.cpp
@@ -19,13 +19,11 @@
namespace dittosuite {
-DeleteFile::DeleteFile(SyscallInterface& syscall, int repeat, const std::string& path_name)
- : Instruction(syscall, kName, repeat),
- path_name_(GetAbsolutePath() + path_name),
- input_key_(-1) {}
+DeleteFile::DeleteFile(const Params& params, const std::string& path_name)
+ : Instruction(kName, params), path_name_(GetAbsolutePath() + path_name), input_key_(-1) {}
-DeleteFile::DeleteFile(SyscallInterface& syscall, int repeat, int input_key)
- : Instruction(syscall, kName, repeat), input_key_(input_key) {}
+DeleteFile::DeleteFile(const Params& params, int input_key)
+ : Instruction(kName, params), input_key_(input_key) {}
void DeleteFile::SetUpSingle() {
if (input_key_ != -1) {
diff --git a/src/instruction.cpp b/src/instruction.cpp
index 2e52019..c2c582d 100644
--- a/src/instruction.cpp
+++ b/src/instruction.cpp
@@ -18,8 +18,8 @@
namespace dittosuite {
-Instruction::Instruction(SyscallInterface& syscall, const std::string& name, int repeat)
- : syscall_(syscall), name_(name), repeat_(repeat) {}
+Instruction::Instruction(const std::string& name, const Params& params)
+ : syscall_(params.syscall), name_(name), repeat_(params.repeat) {}
void Instruction::SetUp() {}
diff --git a/src/instruction_factory.cpp b/src/instruction_factory.cpp
index 291a09e..7f466c7 100644
--- a/src/instruction_factory.cpp
+++ b/src/instruction_factory.cpp
@@ -26,8 +26,8 @@
#include <ditto/instruction_set.h>
#include <ditto/invalidate_cache.h>
#include <ditto/logger.h>
-#include <ditto/multithreading.h>
#include <ditto/multiprocessing.h>
+#include <ditto/multithreading.h>
#include <ditto/open_file.h>
#include <ditto/read_directory.h>
#include <ditto/read_write_file.h>
@@ -40,7 +40,7 @@ typedef dittosuiteproto::Instruction::InstructionOneofCase InstructionType;
typedef dittosuiteproto::BinderRequest::ServiceOneofCase RequestService;
std::unique_ptr<InstructionSet> InstructionFactory::CreateFromProtoInstructionSet(
- const std::list<int>& thread_ids, const int repeat,
+ const dittosuite::Instruction::Params& instruction_params, const std::list<int>& thread_ids,
const dittosuiteproto::InstructionSet& proto_instruction_set) {
std::vector<std::unique_ptr<Instruction>> instructions;
for (const auto& instruction : proto_instruction_set.instructions()) {
@@ -61,20 +61,23 @@ std::unique_ptr<InstructionSet> InstructionFactory::CreateFromProtoInstructionSe
seed = time(nullptr);
}
- return std::make_unique<InstructionSet>(Syscall::GetSyscall(), repeat, std::move(instructions),
- list_key, item_key, access_order, reseeding, seed);
+ return std::make_unique<InstructionSet>(instruction_params, std::move(instructions), list_key,
+ item_key, access_order, reseeding, seed);
} else {
- return std::make_unique<InstructionSet>(Syscall::GetSyscall(), repeat, std::move(instructions));
+ return std::make_unique<InstructionSet>(instruction_params, std::move(instructions));
}
}
std::unique_ptr<Instruction> InstructionFactory::CreateFromProtoInstruction(
const std::list<int>& thread_ids, const dittosuiteproto::Instruction& proto_instruction) {
- int repeat = proto_instruction.repeat();
+ Instruction::Params instruction_params{
+ .syscall = Syscall::GetSyscall(),
+ .repeat = proto_instruction.repeat(),
+ };
switch (proto_instruction.instruction_oneof_case()) {
case InstructionType::kInstructionSet: {
- return InstructionFactory::CreateFromProtoInstructionSet(thread_ids, repeat,
+ return InstructionFactory::CreateFromProtoInstructionSet(instruction_params, thread_ids,
proto_instruction.instruction_set());
}
case InstructionType::kOpenFile: {
@@ -105,16 +108,14 @@ std::unique_ptr<Instruction> InstructionFactory::CreateFromProtoInstruction(
if (options.has_input()) {
int input_key = SharedVariables::GetKey(thread_ids, options.input());
- return std::make_unique<OpenFile>(Syscall::GetSyscall(), repeat, input_key,
- options.create(), options.direct_io(), fd_key,
- access_mode);
+ return std::make_unique<OpenFile>(instruction_params, input_key, options.create(),
+ options.direct_io(), fd_key, access_mode);
} else if (options.has_path_name()) {
- return std::make_unique<OpenFile>(Syscall::GetSyscall(), repeat, options.path_name(),
- options.create(), options.direct_io(), fd_key,
- access_mode);
- } else {
- return std::make_unique<OpenFile>(Syscall::GetSyscall(), repeat, options.create(),
+ return std::make_unique<OpenFile>(instruction_params, options.path_name(), options.create(),
options.direct_io(), fd_key, access_mode);
+ } else {
+ return std::make_unique<OpenFile>(instruction_params, options.create(), options.direct_io(),
+ fd_key, access_mode);
}
}
case InstructionType::kDeleteFile: {
@@ -122,9 +123,9 @@ std::unique_ptr<Instruction> InstructionFactory::CreateFromProtoInstruction(
if (options.has_input()) {
int input_key = SharedVariables::GetKey(thread_ids, options.input());
- return std::make_unique<DeleteFile>(Syscall::GetSyscall(), repeat, input_key);
+ return std::make_unique<DeleteFile>(instruction_params, input_key);
} else {
- return std::make_unique<DeleteFile>(Syscall::GetSyscall(), repeat, options.path_name());
+ return std::make_unique<DeleteFile>(instruction_params, options.path_name());
}
}
case InstructionType::kCloseFile: {
@@ -132,14 +133,14 @@ std::unique_ptr<Instruction> InstructionFactory::CreateFromProtoInstruction(
int fd_key = SharedVariables::GetKey(thread_ids, options.input_fd());
- return std::make_unique<CloseFile>(Syscall::GetSyscall(), repeat, fd_key);
+ return std::make_unique<CloseFile>(instruction_params, fd_key);
}
case InstructionType::kResizeFile: {
const auto& options = proto_instruction.resize_file();
int fd_key = SharedVariables::GetKey(thread_ids, options.input_fd());
- return std::make_unique<ResizeFile>(Syscall::GetSyscall(), repeat, options.size(), fd_key);
+ return std::make_unique<ResizeFile>(instruction_params, options.size(), fd_key);
}
case InstructionType::kWriteFile: {
const auto& options = proto_instruction.write_file();
@@ -154,9 +155,9 @@ std::unique_ptr<Instruction> InstructionFactory::CreateFromProtoInstruction(
auto reseeding = ConvertReseeding(options.reseeding());
int fd_key = SharedVariables::GetKey(thread_ids, options.input_fd());
- return std::make_unique<WriteFile>(Syscall::GetSyscall(), repeat, options.size(),
- options.block_size(), options.starting_offset(),
- access_order, seed, reseeding, options.fsync(), fd_key);
+ return std::make_unique<WriteFile>(instruction_params, options.size(), options.block_size(),
+ options.starting_offset(), access_order, seed, reseeding,
+ options.fsync(), fd_key);
}
case InstructionType::kReadFile: {
const auto& options = proto_instruction.read_file();
@@ -172,17 +173,17 @@ std::unique_ptr<Instruction> InstructionFactory::CreateFromProtoInstruction(
auto reseeding = ConvertReseeding(options.reseeding());
int fd_key = SharedVariables::GetKey(thread_ids, options.input_fd());
- return std::make_unique<ReadFile>(Syscall::GetSyscall(), repeat, options.size(),
- options.block_size(), options.starting_offset(),
- access_order, seed, reseeding, fadvise, fd_key);
+ return std::make_unique<ReadFile>(instruction_params, options.size(), options.block_size(),
+ options.starting_offset(), access_order, seed, reseeding,
+ fadvise, fd_key);
}
case InstructionType::kReadDirectory: {
const auto& options = proto_instruction.read_directory();
int output_key = SharedVariables::GetKey(thread_ids, options.output());
- return std::make_unique<ReadDirectory>(Syscall::GetSyscall(), repeat,
- options.directory_name(), output_key);
+ return std::make_unique<ReadDirectory>(instruction_params, options.directory_name(),
+ output_key);
}
case InstructionType::kResizeFileRandom: {
const auto& options = proto_instruction.resize_file_random();
@@ -195,8 +196,8 @@ std::unique_ptr<Instruction> InstructionFactory::CreateFromProtoInstruction(
auto reseeding = ConvertReseeding(options.reseeding());
int fd_key = SharedVariables::GetKey(thread_ids, options.input_fd());
- return std::make_unique<ResizeFileRandom>(Syscall::GetSyscall(), repeat, options.min(),
- options.max(), seed, reseeding, fd_key);
+ return std::make_unique<ResizeFileRandom>(instruction_params, options.min(), options.max(),
+ seed, reseeding, fd_key);
}
case InstructionType::kMultithreading: {
const auto& options = proto_instruction.multithreading();
@@ -218,15 +219,14 @@ std::unique_ptr<Instruction> InstructionFactory::CreateFromProtoInstruction(
}
if (options.fork()) {
- return std::make_unique<Multiprocessing>(Syscall::GetSyscall(), repeat,
- std::move(instructions), std::move(thread_names));
+ return std::make_unique<Multiprocessing>(instruction_params, std::move(instructions),
+ std::move(thread_names));
} else {
- return std::make_unique<Multithreading>(Syscall::GetSyscall(), repeat,
- std::move(instructions));
+ return std::make_unique<Multithreading>(instruction_params, std::move(instructions));
}
}
case InstructionType::kInvalidateCache: {
- return std::make_unique<InvalidateCache>(Syscall::GetSyscall(), repeat);
+ return std::make_unique<InvalidateCache>(instruction_params);
}
#if __ANDROID__
case InstructionType::kBinderRequest: {
@@ -234,12 +234,11 @@ std::unique_ptr<Instruction> InstructionFactory::CreateFromProtoInstruction(
switch (binder_request.service_oneof_case()) {
case RequestService::kServiceName: {
const auto& options = proto_instruction.binder_request();
- return std::make_unique<BinderRequestDitto>(Syscall::GetSyscall(), repeat,
- options.service_name());
+ return std::make_unique<BinderRequestDitto>(instruction_params, options.service_name());
break;
}
case RequestService::kRunningService: {
- return std::make_unique<BinderRequestMountService>(Syscall::GetSyscall(), repeat);
+ return std::make_unique<BinderRequestMountService>(instruction_params);
break;
}
case RequestService::SERVICE_ONEOF_NOT_SET: {
@@ -251,8 +250,7 @@ std::unique_ptr<Instruction> InstructionFactory::CreateFromProtoInstruction(
case InstructionType::kBinderService: {
const auto& options = proto_instruction.binder_service();
- return std::make_unique<BinderService>(Syscall::GetSyscall(), repeat, options.name(),
- options.threads());
+ return std::make_unique<BinderService>(instruction_params, options.name(), options.threads());
}
#endif /*__ANDROID__*/
case InstructionType::INSTRUCTION_ONEOF_NOT_SET: {
diff --git a/src/instruction_set.cpp b/src/instruction_set.cpp
index 1da105c..68997e3 100644
--- a/src/instruction_set.cpp
+++ b/src/instruction_set.cpp
@@ -28,10 +28,10 @@ struct overloaded : Ts... {
template <class... Ts>
overloaded(Ts...) -> overloaded<Ts...>;
-InstructionSet::InstructionSet(SyscallInterface& syscall, int repeat,
+InstructionSet::InstructionSet(const Params& params,
std::vector<std::unique_ptr<Instruction>> instructions, int list_key,
int item_key, Order access_order, Reseeding reseeding, uint32_t seed)
- : Instruction(syscall, kName, repeat),
+ : Instruction(kName, params),
instructions_(std::move(instructions)),
list_key_(list_key),
item_key_(item_key),
@@ -40,9 +40,9 @@ InstructionSet::InstructionSet(SyscallInterface& syscall, int repeat,
seed_(seed),
gen_(seed) {}
-InstructionSet::InstructionSet(SyscallInterface& syscall, int repeat,
+InstructionSet::InstructionSet(const Params& params,
std::vector<std::unique_ptr<Instruction>> instructions)
- : Instruction(syscall, kName, repeat),
+ : Instruction(kName, params),
instructions_(std::move(instructions)),
list_key_(-1),
item_key_(-1) {}
diff --git a/src/invalidate_cache.cpp b/src/invalidate_cache.cpp
index 083d73e..2381289 100644
--- a/src/invalidate_cache.cpp
+++ b/src/invalidate_cache.cpp
@@ -18,8 +18,7 @@
namespace dittosuite {
-InvalidateCache::InvalidateCache(SyscallInterface& syscall, int repeat)
- : Instruction(syscall, kName, repeat) {}
+InvalidateCache::InvalidateCache(const Params& params) : Instruction(kName, params) {}
void InvalidateCache::RunSingle() {
syscall_.Sync();
diff --git a/src/multiprocessing.cpp b/src/multiprocessing.cpp
index 6bd7fda..c939dd6 100644
--- a/src/multiprocessing.cpp
+++ b/src/multiprocessing.cpp
@@ -22,10 +22,10 @@
namespace dittosuite {
-Multiprocessing::Multiprocessing(SyscallInterface& syscall, int repeat,
+Multiprocessing::Multiprocessing(const Params& params,
std::vector<std::unique_ptr<Instruction>> instructions,
std::vector<std::string> thread_names)
- : Instruction(syscall, kName, repeat),
+ : Instruction(kName, params),
instructions_(std::move(instructions)),
thread_names_(std::move(thread_names)) {}
diff --git a/src/multithreading.cpp b/src/multithreading.cpp
index d31fdbc..8f4e803 100644
--- a/src/multithreading.cpp
+++ b/src/multithreading.cpp
@@ -16,9 +16,9 @@
namespace dittosuite {
-Multithreading::Multithreading(SyscallInterface& syscall, int repeat,
+Multithreading::Multithreading(const Params& params,
std::vector<std::unique_ptr<Instruction>> instructions)
- : Instruction(syscall, kName, repeat), instructions_(std::move(instructions)) {}
+ : Instruction(kName, params), instructions_(std::move(instructions)) {}
void Multithreading::SetUpSingle() {
for (const auto& instruction : instructions_) {
diff --git a/src/open_file.cpp b/src/open_file.cpp
index 167df74..6bde1b2 100644
--- a/src/open_file.cpp
+++ b/src/open_file.cpp
@@ -20,9 +20,9 @@
namespace dittosuite {
-OpenFile::OpenFile(SyscallInterface& syscall, int repeat, const std::string& path_name, bool create,
- bool direct_io, int output_fd_key, AccessMode access_mode)
- : Instruction(syscall, kName, repeat),
+OpenFile::OpenFile(const Params& params, const std::string& path_name, bool create, bool direct_io,
+ int output_fd_key, AccessMode access_mode)
+ : Instruction(kName, params),
random_name_(false),
path_name_(GetAbsolutePath() + path_name),
create_(create),
@@ -31,9 +31,9 @@ OpenFile::OpenFile(SyscallInterface& syscall, int repeat, const std::string& pat
output_fd_key_(output_fd_key),
access_mode_(access_mode) {}
-OpenFile::OpenFile(SyscallInterface& syscall, int repeat, int input_key, bool create,
- bool direct_io, int output_fd_key, AccessMode access_mode)
- : Instruction(syscall, kName, repeat),
+OpenFile::OpenFile(const Params& params, int input_key, bool create, bool direct_io,
+ int output_fd_key, AccessMode access_mode)
+ : Instruction(kName, params),
random_name_(false),
create_(create),
direct_io_(direct_io),
@@ -41,9 +41,9 @@ OpenFile::OpenFile(SyscallInterface& syscall, int repeat, int input_key, bool cr
output_fd_key_(output_fd_key),
access_mode_(access_mode) {}
-OpenFile::OpenFile(SyscallInterface& syscall, int repeat, bool create, bool direct_io,
- int output_fd_key, AccessMode access_mode)
- : Instruction(syscall, kName, repeat),
+OpenFile::OpenFile(const Params& params, bool create, bool direct_io, int output_fd_key,
+ AccessMode access_mode)
+ : Instruction(kName, params),
random_name_(true),
create_(create),
direct_io_(direct_io),
diff --git a/src/read_directory.cpp b/src/read_directory.cpp
index b8024cd..689eaea 100644
--- a/src/read_directory.cpp
+++ b/src/read_directory.cpp
@@ -20,9 +20,9 @@
namespace dittosuite {
-ReadDirectory::ReadDirectory(SyscallInterface& syscall, int repeat,
- const std::string& directory_name, int output_key)
- : Instruction(syscall, kName, repeat),
+ReadDirectory::ReadDirectory(const Params& params, const std::string& directory_name,
+ int output_key)
+ : Instruction(kName, params),
directory_name_(GetAbsolutePath() + directory_name),
output_key_(output_key) {}
diff --git a/src/read_write_file.cpp b/src/read_write_file.cpp
index 7bbd2c8..f2e8329 100644
--- a/src/read_write_file.cpp
+++ b/src/read_write_file.cpp
@@ -21,11 +21,10 @@
namespace dittosuite {
-ReadWriteFile::ReadWriteFile(SyscallInterface& syscall, const std::string& name, int repeat,
- int64_t size, int64_t block_size, int64_t starting_offset,
- Order access_order, uint32_t seed, Reseeding reseeding,
- int input_fd_key)
- : Instruction(syscall, name, repeat),
+ReadWriteFile::ReadWriteFile(const std::string& name, const Params& params, int64_t size,
+ int64_t block_size, int64_t starting_offset, Order access_order,
+ uint32_t seed, Reseeding reseeding, int input_fd_key)
+ : Instruction(name, params),
size_(size),
block_size_(block_size),
starting_offset_(starting_offset),
@@ -112,11 +111,11 @@ void ReadWriteFile::SetUpSingle() {
void ReadWriteFile::RunSingle() {}
-WriteFile::WriteFile(SyscallInterface& syscall, int repeat, int64_t size, int64_t block_size,
+WriteFile::WriteFile(const Params& params, int64_t size, int64_t block_size,
int64_t starting_offset, Order access_order, uint32_t seed,
Reseeding reseeding, bool fsync, int input_fd_key)
- : ReadWriteFile(syscall, kName, repeat, size, block_size, starting_offset, access_order, seed,
- reseeding, input_fd_key),
+ : ReadWriteFile(kName, params, size, block_size, starting_offset, access_order, seed, reseeding,
+ input_fd_key),
fsync_(fsync) {}
void WriteFile::RunSingle() {
@@ -133,11 +132,11 @@ void WriteFile::RunSingle() {
}
}
-ReadFile::ReadFile(SyscallInterface& syscall, int repeat, int64_t size, int64_t block_size,
- int64_t starting_offset, Order access_order, uint32_t seed, Reseeding reseeding,
- int fadvise, int input_fd_key)
- : ReadWriteFile(syscall, kName, repeat, size, block_size, starting_offset, access_order, seed,
- reseeding, input_fd_key),
+ReadFile::ReadFile(const Params& params, int64_t size, int64_t block_size, int64_t starting_offset,
+ Order access_order, uint32_t seed, Reseeding reseeding, int fadvise,
+ int input_fd_key)
+ : ReadWriteFile(kName, params, size, block_size, starting_offset, access_order, seed, reseeding,
+ input_fd_key),
fadvise_(fadvise) {}
void ReadFile::SetUpSingle() {
diff --git a/src/resize_file.cpp b/src/resize_file.cpp
index 03c360c..ce0e84a 100644
--- a/src/resize_file.cpp
+++ b/src/resize_file.cpp
@@ -21,8 +21,8 @@
namespace dittosuite {
-ResizeFile::ResizeFile(SyscallInterface& syscall, int repeat, int64_t size, int input_fd_key)
- : Instruction(syscall, kName, repeat), size_(size), input_fd_key_(input_fd_key) {}
+ResizeFile::ResizeFile(const Params& params, int64_t size, int input_fd_key)
+ : Instruction(kName, params), size_(size), input_fd_key_(input_fd_key) {}
void ResizeFile::RunSingle() {
int fd = std::get<int>(SharedVariables::Get(input_fd_key_));
@@ -39,9 +39,9 @@ void ResizeFile::RunSingle() {
}
}
-ResizeFileRandom::ResizeFileRandom(SyscallInterface& syscall, int repeat, int64_t min, int64_t max,
- uint64_t seed, Reseeding reseeding, int input_fd_key)
- : ResizeFile(syscall, repeat, -1, input_fd_key),
+ResizeFileRandom::ResizeFileRandom(const Params& params, int64_t min, int64_t max, uint64_t seed,
+ Reseeding reseeding, int input_fd_key)
+ : ResizeFile(params, -1, input_fd_key),
min_(min),
max_(max),
gen_(seed),
diff --git a/test/close_file_test.cpp b/test/close_file_test.cpp
index 7282bd9..5bffc75 100644
--- a/test/close_file_test.cpp
+++ b/test/close_file_test.cpp
@@ -17,6 +17,7 @@
#include <ditto/close_file.h>
#include <ditto/syscall.h>
+using ::dittosuite::Instruction;
using ::dittosuite::SharedVariables;
using ::testing::_;
using ::testing::Return;
@@ -39,7 +40,7 @@ using CloseFileDeathTest = CloseFileTest;
TEST_F(CloseFileTest, ClosedFile) {
EXPECT_CALL(syscall_, Close(fd_));
- dittosuite::CloseFile instruction(syscall_, 1, input_key_);
+ dittosuite::CloseFile instruction((Instruction::Params){syscall_, 1}, input_key_);
instruction.Run();
}
@@ -47,6 +48,6 @@ TEST_F(CloseFileDeathTest, DiedDueToInvalidFd) {
SharedVariables::Set(input_key_, -1);
EXPECT_CALL(syscall_, Close(_)).WillRepeatedly(Return(-1));
- dittosuite::CloseFile instruction(syscall_, 1, input_key_);
+ dittosuite::CloseFile instruction((Instruction::Params){syscall_, 1}, input_key_);
EXPECT_DEATH(instruction.Run(), _);
}
diff --git a/test/delete_file_test.cpp b/test/delete_file_test.cpp
index 8c41fd1..755a6c4 100644
--- a/test/delete_file_test.cpp
+++ b/test/delete_file_test.cpp
@@ -20,6 +20,8 @@
#include <ditto/delete_file.h>
#include <ditto/syscall.h>
+using dittosuite::Instruction;
+
class DeleteFileTest : public InstructionTest {
protected:
std::string file_name = "test";
@@ -35,7 +37,8 @@ class DeleteFileTest : public InstructionTest {
};
TEST_F(DeleteFileTest, FileDeletedWithPathName) {
- dittosuite::DeleteFile instruction(dittosuite::Syscall::GetSyscall(), 1, file_name);
+ dittosuite::DeleteFile instruction((Instruction::Params){dittosuite::Syscall::GetSyscall(), 1},
+ file_name);
instruction.Run();
ASSERT_EQ(access(path.c_str(), F_OK), -1);
@@ -43,7 +46,7 @@ TEST_F(DeleteFileTest, FileDeletedWithPathName) {
TEST_F(DeleteFileTest, FileDeletedWithVariable) {
dittosuite::SharedVariables::Set(thread_ids, "input", path);
- dittosuite::DeleteFile instruction(dittosuite::Syscall::GetSyscall(), 1,
+ dittosuite::DeleteFile instruction((Instruction::Params){dittosuite::Syscall::GetSyscall(), 1},
dittosuite::SharedVariables::GetKey(thread_ids, "input"));
instruction.Run();
diff --git a/test/invalidate_cache_test.cpp b/test/invalidate_cache_test.cpp
index f129113..86bdd95 100644
--- a/test/invalidate_cache_test.cpp
+++ b/test/invalidate_cache_test.cpp
@@ -17,6 +17,7 @@
#include <ditto/invalidate_cache.h>
#include <ditto/syscall.h>
+using dittosuite::Instruction;
using ::testing::_;
class InvalidateCacheTest : public InstructionTest {};
@@ -27,6 +28,6 @@ TEST_F(InvalidateCacheTest, InvalidatedCache) {
EXPECT_CALL(syscall_, Write(_, _, sizeof(char), 0));
EXPECT_CALL(syscall_, Close(_));
- dittosuite::InvalidateCache instruction(syscall_, 1);
+ dittosuite::InvalidateCache instruction((Instruction::Params){syscall_, 1});
instruction.Run();
}
diff --git a/test/open_file_test.cpp b/test/open_file_test.cpp
index c44b007..18ec602 100644
--- a/test/open_file_test.cpp
+++ b/test/open_file_test.cpp
@@ -17,6 +17,8 @@
#include <ditto/open_file.h>
#include <ditto/syscall.h>
+using dittosuite::Instruction;
+
class OpenFileTest : public InstructionTestWithParam<dittosuite::OpenFile::AccessMode> {
protected:
std::string file_name = "test";
@@ -28,8 +30,8 @@ class OpenFileTest : public InstructionTestWithParam<dittosuite::OpenFile::Acces
TEST_P(OpenFileTest, FileCreatedWithPathName) {
dittosuite::OpenFile::AccessMode access_mode = GetParam();
- dittosuite::OpenFile instruction(dittosuite::Syscall::GetSyscall(), 1, file_name, true, false, -1,
- access_mode);
+ dittosuite::OpenFile instruction((Instruction::Params){dittosuite::Syscall::GetSyscall(), 1},
+ file_name, true, false, -1, access_mode);
instruction.Run();
ASSERT_EQ(access(path.c_str(), F_OK), 0);
@@ -38,7 +40,7 @@ TEST_P(OpenFileTest, FileCreatedWithPathName) {
TEST_P(OpenFileTest, FileCreatedWithVariable) {
dittosuite::OpenFile::AccessMode access_mode = GetParam();
dittosuite::SharedVariables::Set(thread_ids, "input", path);
- dittosuite::OpenFile instruction(dittosuite::Syscall::GetSyscall(), 1,
+ dittosuite::OpenFile instruction((Instruction::Params){dittosuite::Syscall::GetSyscall(), 1},
dittosuite::SharedVariables::GetKey(thread_ids, "input"), true,
false, -1, access_mode);
instruction.Run();
diff --git a/test/read_directory_test.cpp b/test/read_directory_test.cpp
index 6fc3844..97b3d21 100644
--- a/test/read_directory_test.cpp
+++ b/test/read_directory_test.cpp
@@ -20,6 +20,8 @@
#include <ditto/read_directory.h>
#include <ditto/syscall.h>
+using dittosuite::Instruction;
+
class ReadDirectoryTest : public InstructionTest {
protected:
std::string directory_name = "test_directory";
@@ -46,8 +48,8 @@ class ReadDirectoryTest : public InstructionTest {
TEST_F(ReadDirectoryTest, ReadDirectoryTestRun) {
auto output_key = dittosuite::SharedVariables::GetKey(thread_ids, "file_list");
- dittosuite::ReadDirectory instruction(dittosuite::Syscall::GetSyscall(), 1, directory_name,
- output_key);
+ dittosuite::ReadDirectory instruction((Instruction::Params){dittosuite::Syscall::GetSyscall(), 1},
+ directory_name, output_key);
instruction.Run();
auto output = std::get<std::vector<std::string>>(dittosuite::SharedVariables::Get(output_key));
diff --git a/test/read_file_test.cpp b/test/read_file_test.cpp
index 9a62172..75f128c 100644
--- a/test/read_file_test.cpp
+++ b/test/read_file_test.cpp
@@ -19,6 +19,7 @@
#include <ditto/instruction_set.h>
#include <ditto/read_write_file.h>
+using ::dittosuite::Instruction;
using ::dittosuite::SharedVariables;
using ::testing::_;
using ::testing::InSequence;
@@ -45,18 +46,18 @@ TEST_F(ReadFileTest, SetFAdvise) {
EXPECT_CALL(syscall_, FAdvise(fd_, 0, MockSyscall::kDefaultFileSize, fadvise));
- auto read_file = dittosuite::ReadFile(syscall_, 1, -1, MockSyscall::kDefaultFileSize, 0,
- dittosuite::Order::kSequential, 0,
- dittosuite::Reseeding::kOnce, fadvise, input_key_);
+ auto read_file = dittosuite::ReadFile(
+ (Instruction::Params){syscall_, 1}, -1, MockSyscall::kDefaultFileSize, 0,
+ dittosuite::Order::kSequential, 0, dittosuite::Reseeding::kOnce, fadvise, input_key_);
read_file.Run();
}
TEST_F(ReadFileTest, ReadSingleBlockSequential) {
EXPECT_CALL(syscall_, Read(fd_, _, MockSyscall::kDefaultFileSize, 0));
- auto read_file = dittosuite::ReadFile(syscall_, 1, -1, MockSyscall::kDefaultFileSize, 0,
- dittosuite::Order::kSequential, 0,
- dittosuite::Reseeding::kOnce, 0, input_key_);
+ auto read_file = dittosuite::ReadFile(
+ (Instruction::Params){syscall_, 1}, -1, MockSyscall::kDefaultFileSize, 0,
+ dittosuite::Order::kSequential, 0, dittosuite::Reseeding::kOnce, 0, input_key_);
read_file.Run();
}
@@ -64,18 +65,18 @@ TEST_F(ReadFileTest, ReadSingleBlockSequentialRepeated) {
int repeat = 2;
EXPECT_CALL(syscall_, Read(fd_, _, MockSyscall::kDefaultFileSize, 0)).Times(repeat);
- auto read_file = dittosuite::ReadFile(syscall_, repeat, -1, MockSyscall::kDefaultFileSize, 0,
- dittosuite::Order::kSequential, 0,
- dittosuite::Reseeding::kOnce, 0, input_key_);
+ auto read_file = dittosuite::ReadFile(
+ (Instruction::Params){syscall_, repeat}, -1, MockSyscall::kDefaultFileSize, 0,
+ dittosuite::Order::kSequential, 0, dittosuite::Reseeding::kOnce, 0, input_key_);
read_file.Run();
}
TEST_F(ReadFileTest, ReadSingleBlockRandom) {
EXPECT_CALL(syscall_, Read(fd_, _, MockSyscall::kDefaultFileSize, 0));
- auto read_file = dittosuite::ReadFile(syscall_, 1, -1, MockSyscall::kDefaultFileSize, 0,
- dittosuite::Order::kRandom, 0, dittosuite::Reseeding::kOnce,
- 0, input_key_);
+ auto read_file = dittosuite::ReadFile(
+ (Instruction::Params){syscall_, 1}, -1, MockSyscall::kDefaultFileSize, 0,
+ dittosuite::Order::kRandom, 0, dittosuite::Reseeding::kOnce, 0, input_key_);
read_file.Run();
}
@@ -83,9 +84,9 @@ TEST_F(ReadFileTest, ReadSingleBlockRandomRepeated) {
int repeat = 2;
EXPECT_CALL(syscall_, Read(fd_, _, MockSyscall::kDefaultFileSize, 0)).Times(repeat);
- auto read_file = dittosuite::ReadFile(syscall_, repeat, -1, MockSyscall::kDefaultFileSize, 0,
- dittosuite::Order::kRandom, 0, dittosuite::Reseeding::kOnce,
- 0, input_key_);
+ auto read_file = dittosuite::ReadFile(
+ (Instruction::Params){syscall_, repeat}, -1, MockSyscall::kDefaultFileSize, 0,
+ dittosuite::Order::kRandom, 0, dittosuite::Reseeding::kOnce, 0, input_key_);
read_file.Run();
}
@@ -95,12 +96,10 @@ TEST_F(ReadFileTest, ReadMultipleBlocksSequential) {
// Check that file size is requested two times in each SetUpSingle() and
// pass needed file size for this test
- EXPECT_CALL(syscall_, FStat(fd_, _))
- .Times(2)
- .WillRepeatedly(Invoke([&](int, struct stat64* buf) {
- buf->st_size = size;
- return 0;
- }));
+ EXPECT_CALL(syscall_, FStat(fd_, _)).Times(2).WillRepeatedly(Invoke([&](int, struct stat64* buf) {
+ buf->st_size = size;
+ return 0;
+ }));
{
InSequence sq;
@@ -110,9 +109,9 @@ TEST_F(ReadFileTest, ReadMultipleBlocksSequential) {
EXPECT_CALL(syscall_, Read(fd_, _, block_size, block_size * 3));
}
- auto read_file =
- dittosuite::ReadFile(syscall_, 1, size, block_size, 0, dittosuite::Order::kSequential, 0,
- dittosuite::Reseeding::kOnce, 0, input_key_);
+ auto read_file = dittosuite::ReadFile((Instruction::Params){syscall_, 1}, size, block_size, 0,
+ dittosuite::Order::kSequential, 0,
+ dittosuite::Reseeding::kOnce, 0, input_key_);
read_file.Run();
}
@@ -140,9 +139,9 @@ TEST_F(ReadFileTest, ReadMultipleBlocksSequentialRepeated) {
}
}
- auto read_file =
- dittosuite::ReadFile(syscall_, repeat, size, block_size, 0, dittosuite::Order::kSequential, 0,
- dittosuite::Reseeding::kOnce, 0, input_key_);
+ auto read_file = dittosuite::ReadFile((Instruction::Params){syscall_, repeat}, size, block_size,
+ 0, dittosuite::Order::kSequential, 0,
+ dittosuite::Reseeding::kOnce, 0, input_key_);
read_file.Run();
}
@@ -173,11 +172,12 @@ TEST_F(ReadFileTest, ReadMultipleBlocksRandomRepeatedReseededOnce) {
}));
auto read_file = std::make_unique<dittosuite::ReadFile>(
- syscall_, repeat, size, block_size, 0, dittosuite::Order::kRandom, 0,
+ (Instruction::Params){syscall_, repeat}, size, block_size, 0, dittosuite::Order::kRandom, 0,
dittosuite::Reseeding::kOnce, 0, input_key_);
std::vector<std::unique_ptr<dittosuite::Instruction>> instructions;
instructions.push_back(std::move(read_file));
- auto instruction_set = dittosuite::InstructionSet(syscall_, repeat, std::move(instructions));
+ auto instruction_set =
+ dittosuite::InstructionSet((Instruction::Params){syscall_, repeat}, std::move(instructions));
instruction_set.Run();
// Check that the number of unique blocks, that were collected, matches the expected number
@@ -211,11 +211,12 @@ TEST_F(ReadFileTest, ReadMultipleBlocksRandomRepeatedReseededEachRoundOfCycles)
}));
auto read_file = std::make_unique<dittosuite::ReadFile>(
- syscall_, repeat, size, block_size, 0, dittosuite::Order::kRandom, 0,
+ (Instruction::Params){syscall_, repeat}, size, block_size, 0, dittosuite::Order::kRandom, 0,
dittosuite::Reseeding::kEachRoundOfCycles, 0, input_key_);
std::vector<std::unique_ptr<dittosuite::Instruction>> instructions;
instructions.push_back(std::move(read_file));
- auto instruction_set = dittosuite::InstructionSet(syscall_, repeat, std::move(instructions));
+ auto instruction_set =
+ dittosuite::InstructionSet((Instruction::Params){syscall_, repeat}, std::move(instructions));
instruction_set.Run();
// Check that the number of unique blocks, that were collected, matches the expected number
@@ -249,11 +250,12 @@ TEST_F(ReadFileTest, ReadMultipleBlocksRandomRepeatedReseededEachCycle) {
}));
auto read_file = std::make_unique<dittosuite::ReadFile>(
- syscall_, repeat, size, block_size, 0, dittosuite::Order::kRandom, 0,
+ (Instruction::Params){syscall_, repeat}, size, block_size, 0, dittosuite::Order::kRandom, 0,
dittosuite::Reseeding::kEachCycle, 0, input_key_);
std::vector<std::unique_ptr<dittosuite::Instruction>> instructions;
instructions.push_back(std::move(read_file));
- auto instruction_set = dittosuite::InstructionSet(syscall_, repeat, std::move(instructions));
+ auto instruction_set =
+ dittosuite::InstructionSet((Instruction::Params){syscall_, repeat}, std::move(instructions));
instruction_set.Run();
// Check that the number of unique blocks, that were collected, matches the expected number
@@ -264,7 +266,8 @@ TEST_F(ReadFileTest, UsedFileSize) {
// Expect a single Read() with the correct block_size (equal to file size)
EXPECT_CALL(syscall_, Read(fd_, _, MockSyscall::kDefaultFileSize, _));
- auto read_file = dittosuite::ReadFile(syscall_, 1, -1, -1, 0, dittosuite::Order::kSequential, 0,
+ auto read_file = dittosuite::ReadFile((Instruction::Params){syscall_, 1}, -1, -1, 0,
+ dittosuite::Order::kSequential, 0,
dittosuite::Reseeding::kOnce, 0, input_key_);
read_file.Run();
}
@@ -285,17 +288,17 @@ TEST_F(ReadFileTest, UsedFileSizeRepeated) {
}
}
- auto read_file =
- dittosuite::ReadFile(syscall_, sizes.size(), -1, -1, 0, dittosuite::Order::kSequential, 0,
- dittosuite::Reseeding::kOnce, 0, input_key_);
+ auto read_file = dittosuite::ReadFile(
+ (Instruction::Params){syscall_, static_cast<int>(sizes.size())}, -1, -1, 0,
+ dittosuite::Order::kSequential, 0, dittosuite::Reseeding::kOnce, 0, input_key_);
read_file.Run();
}
TEST_F(ReadFileDeathTest, DiedDueToInvalidFd) {
SharedVariables::Set(input_key_, -1);
- auto read_file = dittosuite::ReadFile(syscall_, 1, -1, MockSyscall::kDefaultFileSize, 0,
- dittosuite::Order::kRandom, 0, dittosuite::Reseeding::kOnce,
- 0, input_key_);
+ auto read_file = dittosuite::ReadFile(
+ (Instruction::Params){syscall_, 1}, -1, MockSyscall::kDefaultFileSize, 0,
+ dittosuite::Order::kRandom, 0, dittosuite::Reseeding::kOnce, 0, input_key_);
// Will fail when GetFileSize() is called for an invalid fd during setup
EXPECT_CALL(syscall_, FStat(-1, _)).WillRepeatedly(Return(-1));
diff --git a/test/resize_file_test.cpp b/test/resize_file_test.cpp
index 9caf4d1..934c3c3 100644
--- a/test/resize_file_test.cpp
+++ b/test/resize_file_test.cpp
@@ -23,6 +23,8 @@
#include <ditto/resize_file.h>
#include <ditto/syscall.h>
+using dittosuite::Instruction;
+
class ResizeFileTest : public InstructionTestWithParam<dittosuite::OpenFile::AccessMode> {
protected:
std::string file_name = "test";
@@ -38,14 +40,15 @@ TEST_P(ResizeFileTest, ResizeFileTestRun) {
dittosuite::OpenFile::AccessMode access_mode = GetParam();
int fd_key = dittosuite::SharedVariables::GetKey(thread_ids, "test_file");
- dittosuite::OpenFile open_file_instruction(dittosuite::Syscall::GetSyscall(), repeat, file_name,
- true, false, fd_key, access_mode);
+ dittosuite::OpenFile open_file_instruction(
+ (Instruction::Params){dittosuite::Syscall::GetSyscall(), repeat}, file_name, true, false,
+ fd_key, access_mode);
open_file_instruction.Run();
ASSERT_EQ(access(path.c_str(), F_OK), 0);
- dittosuite::ResizeFile resize_file_instruction(dittosuite::Syscall::GetSyscall(), repeat, size,
- fd_key);
+ dittosuite::ResizeFile resize_file_instruction(
+ (Instruction::Params){dittosuite::Syscall::GetSyscall(), repeat}, size, fd_key);
if (access_mode == dittosuite::OpenFile::AccessMode::kReadOnly) {
ASSERT_DEATH(resize_file_instruction.Run(), ".*");
} else {
diff --git a/test/write_file_test.cpp b/test/write_file_test.cpp
index 124ccfd..bfe7f41 100644
--- a/test/write_file_test.cpp
+++ b/test/write_file_test.cpp
@@ -19,6 +19,7 @@
#include <ditto/instruction_set.h>
#include <ditto/read_write_file.h>
+using ::dittosuite::Instruction;
using ::dittosuite::SharedVariables;
using ::testing::_;
using ::testing::InSequence;
@@ -43,18 +44,18 @@ using WriteFileDeathTest = WriteFileTest;
TEST_F(WriteFileTest, CalledFSync) {
EXPECT_CALL(syscall_, FSync(fd_));
- auto write_file = dittosuite::WriteFile(syscall_, 1, -1, MockSyscall::kDefaultFileSize, 0,
- dittosuite::Order::kSequential, 0,
- dittosuite::Reseeding::kOnce, true, input_key_);
+ auto write_file = dittosuite::WriteFile(
+ (Instruction::Params){syscall_, 1}, -1, MockSyscall::kDefaultFileSize, 0,
+ dittosuite::Order::kSequential, 0, dittosuite::Reseeding::kOnce, true, input_key_);
write_file.Run();
}
TEST_F(WriteFileTest, WroteSingleBlockSequential) {
EXPECT_CALL(syscall_, Write(fd_, _, MockSyscall::kDefaultFileSize, 0));
- auto write_file = dittosuite::WriteFile(syscall_, 1, -1, MockSyscall::kDefaultFileSize, 0,
- dittosuite::Order::kSequential, 0,
- dittosuite::Reseeding::kOnce, false, input_key_);
+ auto write_file = dittosuite::WriteFile(
+ (Instruction::Params){syscall_, 1}, -1, MockSyscall::kDefaultFileSize, 0,
+ dittosuite::Order::kSequential, 0, dittosuite::Reseeding::kOnce, false, input_key_);
write_file.Run();
}
@@ -62,18 +63,18 @@ TEST_F(WriteFileTest, WroteSingleBlockSequentialRepeated) {
int repeat = 2;
EXPECT_CALL(syscall_, Write(fd_, _, MockSyscall::kDefaultFileSize, 0)).Times(repeat);
- auto write_file = dittosuite::WriteFile(syscall_, repeat, -1, MockSyscall::kDefaultFileSize, 0,
- dittosuite::Order::kSequential, 0,
- dittosuite::Reseeding::kOnce, false, input_key_);
+ auto write_file = dittosuite::WriteFile(
+ (Instruction::Params){syscall_, repeat}, -1, MockSyscall::kDefaultFileSize, 0,
+ dittosuite::Order::kSequential, 0, dittosuite::Reseeding::kOnce, false, input_key_);
write_file.Run();
}
TEST_F(WriteFileTest, WroteSingleBlockRandom) {
EXPECT_CALL(syscall_, Write(fd_, _, MockSyscall::kDefaultFileSize, 0));
- auto write_file = dittosuite::WriteFile(syscall_, 1, -1, MockSyscall::kDefaultFileSize, 0,
- dittosuite::Order::kRandom, 0,
- dittosuite::Reseeding::kOnce, false, input_key_);
+ auto write_file = dittosuite::WriteFile(
+ (Instruction::Params){syscall_, 1}, -1, MockSyscall::kDefaultFileSize, 0,
+ dittosuite::Order::kRandom, 0, dittosuite::Reseeding::kOnce, false, input_key_);
write_file.Run();
}
@@ -81,9 +82,9 @@ TEST_F(WriteFileTest, WroteSingleBlockRandomRepeated) {
int repeat = 2;
EXPECT_CALL(syscall_, Write(fd_, _, MockSyscall::kDefaultFileSize, 0)).Times(repeat);
- auto write_file = dittosuite::WriteFile(syscall_, repeat, -1, MockSyscall::kDefaultFileSize, 0,
- dittosuite::Order::kRandom, 0,
- dittosuite::Reseeding::kOnce, false, input_key_);
+ auto write_file = dittosuite::WriteFile(
+ (Instruction::Params){syscall_, repeat}, -1, MockSyscall::kDefaultFileSize, 0,
+ dittosuite::Order::kRandom, 0, dittosuite::Reseeding::kOnce, false, input_key_);
write_file.Run();
}
@@ -106,9 +107,9 @@ TEST_F(WriteFileTest, WroteMultipleBlocksSequential) {
EXPECT_CALL(syscall_, Write(fd_, _, block_size, block_size * 3));
}
- auto write_file =
- dittosuite::WriteFile(syscall_, 1, size, block_size, 0, dittosuite::Order::kSequential, 0,
- dittosuite::Reseeding::kOnce, false, input_key_);
+ auto write_file = dittosuite::WriteFile((Instruction::Params){syscall_, 1}, size, block_size, 0,
+ dittosuite::Order::kSequential, 0,
+ dittosuite::Reseeding::kOnce, false, input_key_);
write_file.Run();
}
@@ -136,9 +137,9 @@ TEST_F(WriteFileTest, WroteMultipleBlocksSequentialRepeated) {
}
}
- auto write_file =
- dittosuite::WriteFile(syscall_, repeat, size, block_size, 0, dittosuite::Order::kSequential,
- 0, dittosuite::Reseeding::kOnce, false, input_key_);
+ auto write_file = dittosuite::WriteFile((Instruction::Params){syscall_, repeat}, size, block_size,
+ 0, dittosuite::Order::kSequential, 0,
+ dittosuite::Reseeding::kOnce, false, input_key_);
write_file.Run();
}
@@ -169,11 +170,12 @@ TEST_F(WriteFileTest, WroteMultipleBlocksRandomRepeatedReseededOnce) {
}));
auto write_file = std::make_unique<dittosuite::WriteFile>(
- syscall_, repeat, size, block_size, 0, dittosuite::Order::kRandom, 0,
+ (Instruction::Params){syscall_, repeat}, size, block_size, 0, dittosuite::Order::kRandom, 0,
dittosuite::Reseeding::kOnce, false, input_key_);
std::vector<std::unique_ptr<dittosuite::Instruction>> instructions;
instructions.push_back(std::move(write_file));
- auto instruction_set = dittosuite::InstructionSet(syscall_, repeat, std::move(instructions));
+ auto instruction_set =
+ dittosuite::InstructionSet((Instruction::Params){syscall_, repeat}, std::move(instructions));
instruction_set.Run();
// Check that the number of unique blocks, that were collected, matches the expected number
@@ -207,11 +209,12 @@ TEST_F(WriteFileTest, WroteMultipleBlocksRandomRepeatedReseededEachRoundOfCycles
}));
auto write_file = std::make_unique<dittosuite::WriteFile>(
- syscall_, repeat, size, block_size, 0, dittosuite::Order::kRandom, 0,
+ (Instruction::Params){syscall_, repeat}, size, block_size, 0, dittosuite::Order::kRandom, 0,
dittosuite::Reseeding::kEachRoundOfCycles, false, input_key_);
std::vector<std::unique_ptr<dittosuite::Instruction>> instructions;
instructions.push_back(std::move(write_file));
- auto instruction_set = dittosuite::InstructionSet(syscall_, repeat, std::move(instructions));
+ auto instruction_set =
+ dittosuite::InstructionSet((Instruction::Params){syscall_, repeat}, std::move(instructions));
instruction_set.Run();
// Check that the number of unique blocks, that were collected, matches the expected number
@@ -245,11 +248,12 @@ TEST_F(WriteFileTest, WroteMultipleBlocksRandomRepeatedReseededEachCycle) {
}));
auto write_file = std::make_unique<dittosuite::WriteFile>(
- syscall_, repeat, size, block_size, 0, dittosuite::Order::kRandom, 0,
+ (Instruction::Params){syscall_, repeat}, size, block_size, 0, dittosuite::Order::kRandom, 0,
dittosuite::Reseeding::kEachCycle, false, input_key_);
std::vector<std::unique_ptr<dittosuite::Instruction>> instructions;
instructions.push_back(std::move(write_file));
- auto instruction_set = dittosuite::InstructionSet(syscall_, repeat, std::move(instructions));
+ auto instruction_set =
+ dittosuite::InstructionSet((Instruction::Params){syscall_, repeat}, std::move(instructions));
instruction_set.Run();
// Check that the number of unique blocks, that were collected, matches the expected number
@@ -260,7 +264,8 @@ TEST_F(WriteFileTest, UsedFileSize) {
// Expect a single Write() with the correct block_size (equal to file size)
EXPECT_CALL(syscall_, Write(fd_, _, MockSyscall::kDefaultFileSize, _));
- auto write_file = dittosuite::WriteFile(syscall_, 1, -1, -1, 0, dittosuite::Order::kSequential, 0,
+ auto write_file = dittosuite::WriteFile((Instruction::Params){syscall_, 1}, -1, -1, 0,
+ dittosuite::Order::kSequential, 0,
dittosuite::Reseeding::kOnce, false, input_key_);
write_file.Run();
}
@@ -279,17 +284,17 @@ TEST_F(WriteFileTest, UsedFileSizeRepeated) {
}
}
- auto write_file =
- dittosuite::WriteFile(syscall_, sizes.size(), -1, -1, 0, dittosuite::Order::kSequential, 0,
- dittosuite::Reseeding::kOnce, false, input_key_);
+ auto write_file = dittosuite::WriteFile(
+ (Instruction::Params){syscall_, static_cast<int>(sizes.size())}, -1, -1, 0,
+ dittosuite::Order::kSequential, 0, dittosuite::Reseeding::kOnce, false, input_key_);
write_file.Run();
}
TEST_F(WriteFileDeathTest, DiedDueToInvalidFd) {
SharedVariables::Set(input_key_, -1);
- auto instruction = dittosuite::WriteFile(syscall_, 1, -1, MockSyscall::kDefaultFileSize, 0,
- dittosuite::Order::kRandom, 0,
- dittosuite::Reseeding::kOnce, false, input_key_);
+ auto instruction = dittosuite::WriteFile(
+ (Instruction::Params){syscall_, 1}, -1, MockSyscall::kDefaultFileSize, 0,
+ dittosuite::Order::kRandom, 0, dittosuite::Reseeding::kOnce, false, input_key_);
// Will fail when GetFileSize() is called for an invalid fd during setup
EXPECT_CALL(syscall_, FStat(-1, _)).WillRepeatedly(Return(-1));