Skip to content

Commit

Permalink
#1111: backport: test: implement addAdditionalArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
cz4rs committed Dec 21, 2020
1 parent 3036beb commit dde46c1
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/unit/test_parallel_harness.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,41 @@ struct TestParallelHarnessAny : TestHarnessAny<TestBase> {

TestHarnessAny<TestBase>::TearDown();
}

protected:
template <typename Arg>
void addArgs(Arg& arg) {
this->additional_args_.emplace_back(&arg[0]);
}

template <typename Arg, typename... Args>
void addArgs(Arg& arg, Args&... args) {
this->additional_args_.emplace_back(&arg[0]);
addArgs(args...);
}

private:
/**
* \internal \brief Add additional arguments used during initialization of vt
* components
*
* To add additional arguments override this function in your class and add
* needed arguments to `additional_args_` vector.
*
* Example:
* struct TestParallelHarnessWithStatsDumping : TestParallelHarnessParam<int> {
* virtual void addAdditionalArgs() override {
* static char vt_lb_stats[]{"--vt_lb_stats"};
* static char vt_lb_stats_dir[]{"--vt_lb_stats_dir=test_stats_dir"};
* static char vt_lb_stats_file[]{"--vt_lb_stats_file=test_stats_outfile"};
*
* addArgs(vt_lb_stats, vt_lb_stats_dir, vt_lb_stats_file);
* }
* };
*/
virtual void addAdditionalArgs() {}

std::vector<char*> additional_args_;
};

using TestParallelHarness = TestParallelHarnessAny<testing::Test>;
Expand Down

0 comments on commit dde46c1

Please sign in to comment.