Create ArtifactPath function to abstract test paths
When AOS is included as an external repo and renamed, paths have to be
updated. Make a function to handle all this.
Change-Id: If1dfbfb3191809d86da1dca92981b7a0b851c51f
diff --git a/aos/events/BUILD b/aos/events/BUILD
index 1a72db9..aab764b 100644
--- a/aos/events/BUILD
+++ b/aos/events/BUILD
@@ -221,6 +221,7 @@
"//aos:configuration",
"//aos:flatbuffers",
"//aos/testing:googletest",
+ "//aos/testing:path",
],
)
@@ -315,6 +316,7 @@
"//aos/network:remote_message_fbs",
"//aos/network:testing_time_converter",
"//aos/testing:googletest",
+ "//aos/testing:path",
],
)
diff --git a/aos/events/logging/BUILD b/aos/events/logging/BUILD
index 0b6adeb..0123270 100644
--- a/aos/events/logging/BUILD
+++ b/aos/events/logging/BUILD
@@ -373,6 +373,7 @@
"//aos/events:simulated_event_loop",
"//aos/network:testing_time_converter",
"//aos/testing:googletest",
+ "//aos/testing:path",
"//aos/testing:tmpdir",
],
)
diff --git a/aos/events/logging/logger_test.cc b/aos/events/logging/logger_test.cc
index 4b0f375..a342c12 100644
--- a/aos/events/logging/logger_test.cc
+++ b/aos/events/logging/logger_test.cc
@@ -12,6 +12,7 @@
#include "aos/network/remote_message_generated.h"
#include "aos/network/testing_time_converter.h"
#include "aos/network/timestamp_generated.h"
+#include "aos/testing/path.h"
#include "aos/testing/tmpdir.h"
#include "aos/util/file.h"
#include "glog/logging.h"
@@ -26,6 +27,8 @@
namespace logger {
namespace testing {
+using aos::testing::ArtifactPath;
+
namespace chrono = std::chrono;
using aos::message_bridge::RemoteMessage;
using aos::testing::MessageCounter;
@@ -51,8 +54,8 @@
class LoggerTest : public ::testing::Test {
public:
LoggerTest()
- : config_(
- aos::configuration::ReadConfig("aos/events/pingpong_config.json")),
+ : config_(aos::configuration::ReadConfig(
+ ArtifactPath("aos/events/pingpong_config.json"))),
event_loop_factory_(&config_.message()),
ping_event_loop_(event_loop_factory_.MakeEventLoop("ping")),
ping_(ping_event_loop_.get()),
@@ -427,8 +430,8 @@
class MultinodeLoggerTest : public ::testing::TestWithParam<struct Param> {
public:
MultinodeLoggerTest()
- : config_(aos::configuration::ReadConfig(
- absl::StrCat("aos/events/logging/", GetParam().config))),
+ : config_(aos::configuration::ReadConfig(ArtifactPath(
+ absl::StrCat("aos/events/logging/", GetParam().config)))),
time_converter_(configuration::NodesCount(&config_.message())),
event_loop_factory_(&config_.message()),
pi1_(
diff --git a/aos/events/pingpong_test.cc b/aos/events/pingpong_test.cc
index 07e6d31..07340f7 100644
--- a/aos/events/pingpong_test.cc
+++ b/aos/events/pingpong_test.cc
@@ -2,19 +2,22 @@
#include "aos/events/pong_lib.h"
#include "aos/events/simulated_event_loop.h"
#include "aos/json_to_flatbuffer.h"
+#include "aos/testing/path.h"
#include "glog/logging.h"
#include "gtest/gtest.h"
namespace aos {
namespace testing {
+using aos::testing::ArtifactPath;
+
namespace chrono = std::chrono;
class PingPongTest : public ::testing::Test {
public:
PingPongTest()
- : config_(
- aos::configuration::ReadConfig("aos/events/pingpong_config.json")),
+ : config_(aos::configuration::ReadConfig(
+ ArtifactPath("aos/events/pingpong_config.json"))),
event_loop_factory_(&config_.message()),
ping_event_loop_(event_loop_factory_.MakeEventLoop("ping")),
ping_(ping_event_loop_.get()),
diff --git a/aos/events/simulated_event_loop_test.cc b/aos/events/simulated_event_loop_test.cc
index ca0060c..7191365 100644
--- a/aos/events/simulated_event_loop_test.cc
+++ b/aos/events/simulated_event_loop_test.cc
@@ -13,13 +13,14 @@
#include "aos/network/remote_message_generated.h"
#include "aos/network/testing_time_converter.h"
#include "aos/network/timestamp_generated.h"
+#include "aos/testing/path.h"
#include "gtest/gtest.h"
namespace aos {
namespace testing {
namespace {
-std::string ConfigPrefix() { return "aos/"; }
+using aos::testing::ArtifactPath;
using message_bridge::RemoteMessage;
namespace chrono = ::std::chrono;
@@ -92,7 +93,7 @@
public:
RemoteMessageSimulatedEventLoopTest()
: config(aos::configuration::ReadConfig(
- absl::StrCat(ConfigPrefix(), "events/", GetParam().config))) {
+ ArtifactPath(absl::StrCat("aos/events/", GetParam().config)))) {
LOG(INFO) << "Config " << GetParam().config;
}
@@ -762,9 +763,8 @@
// ServerStatistics correctly.
TEST(SimulatedEventLoopTest, MultinodePingPongWithOffset) {
aos::FlatbufferDetachedBuffer<aos::Configuration> config =
- aos::configuration::ReadConfig(
- ConfigPrefix() +
- "events/multinode_pingpong_test_combined_config.json");
+ aos::configuration::ReadConfig(ArtifactPath(
+ "aos/events/multinode_pingpong_test_combined_config.json"));
const Node *pi1 = configuration::GetNode(&config.message(), "pi1");
const size_t pi1_index = configuration::GetNodeIndex(&config.message(), pi1);
ASSERT_EQ(pi1_index, 0u);
@@ -1271,9 +1271,8 @@
// it gets delivered as expected.
TEST(SimulatedEventLoopTest, MultinodePingPongWithOffsetAndSlope) {
aos::FlatbufferDetachedBuffer<aos::Configuration> config =
- aos::configuration::ReadConfig(
- ConfigPrefix() +
- "events/multinode_pingpong_test_combined_config.json");
+ aos::configuration::ReadConfig(ArtifactPath(
+ "aos/events/multinode_pingpong_test_combined_config.json"));
const Node *pi1 = configuration::GetNode(&config.message(), "pi1");
const size_t pi1_index = configuration::GetNodeIndex(&config.message(), pi1);
ASSERT_EQ(pi1_index, 0u);