correctly set the team number for tests
Without this, it's going to pick some random team number on some
computers and fail on others (depending on the network configuration).
Change-Id: I182ed50299170de737812eadee68ff418e6518e6
diff --git a/aos/common/controls/control_loop_test.cc b/aos/common/controls/control_loop_test.cc
index 899b96b..40357b2 100644
--- a/aos/common/controls/control_loop_test.cc
+++ b/aos/common/controls/control_loop_test.cc
@@ -32,7 +32,7 @@
new_state->enabled = enabled;
new_state->autonomous = false;
- new_state->team_id = 971;
+ new_state->team_id = team_id_;
new_state.Send();
}
diff --git a/aos/common/controls/control_loop_test.h b/aos/common/controls/control_loop_test.h
index 13c4f0d..a1165a9 100644
--- a/aos/common/controls/control_loop_test.h
+++ b/aos/common/controls/control_loop_test.h
@@ -19,6 +19,9 @@
ControlLoopTest();
virtual ~ControlLoopTest();
+ void set_team_id(uint16_t team_id) { team_id_ = team_id; }
+ uint16_t team_id() const { return team_id_; }
+
// Sends out all of the required queue messages.
void SendMessages(bool enabled);
// Ticks time for a single control loop cycle.
@@ -37,6 +40,8 @@
static constexpr ::aos::time::Time kDSPacketTime =
::aos::time::Time::InMS(20);
+ uint16_t team_id_ = 971;
+
::aos::time::Time last_ds_time_ = ::aos::time::Time::InSeconds(0);
::aos::time::Time current_time_ = ::aos::time::Time::InSeconds(0);
diff --git a/aos/common/network/team_number.cc b/aos/common/network/team_number.cc
index 38b169a..626d1e6 100644
--- a/aos/common/network/team_number.cc
+++ b/aos/common/network/team_number.cc
@@ -11,7 +11,7 @@
namespace network {
namespace {
-uint16_t override_team = 0;
+uint16_t override_team;
uint16_t *DoGetTeamNumber() {
if (override_team != 0) return &override_team;
diff --git a/aos/common/network/team_number.h b/aos/common/network/team_number.h
index 08103ed..520b9ba 100644
--- a/aos/common/network/team_number.h
+++ b/aos/common/network/team_number.h
@@ -15,6 +15,7 @@
// before GetTeamNumber() is ever called.
// Overriding to team 0 won't work.
// Intended only for tests.
+// Guaranteed to be safe to call during static initialization time.
void OverrideTeamNumber(uint16_t team);
} // namespace network