Fix position_sensor_sim's latched_pot value
I noticed it was changing every cycle, which is inaccurate and was
bothering me.
Change-Id: I288ce04ba43d4907a82f9e6c235357d7467e4dde
diff --git a/aos/testing/BUILD b/aos/testing/BUILD
index 8656d23..a8dce04 100644
--- a/aos/testing/BUILD
+++ b/aos/testing/BUILD
@@ -72,3 +72,15 @@
],
testonly = True,
)
+
+cc_library(
+ name = 'random_seed',
+ visibility = ['//visibility:public'],
+ srcs = [
+ 'random_seed.cc',
+ ],
+ hdrs = [
+ 'random_seed.h',
+ ],
+ testonly = True,
+)
diff --git a/aos/testing/random_seed.cc b/aos/testing/random_seed.cc
new file mode 100644
index 0000000..9e7136f
--- /dev/null
+++ b/aos/testing/random_seed.cc
@@ -0,0 +1,17 @@
+#include "aos/testing/random_seed.h"
+
+#include <stdlib.h>
+
+namespace aos {
+namespace testing {
+
+int RandomSeed() {
+ const char *from_environment = getenv("TEST_RANDOM_SEED");
+ if (from_environment != nullptr) {
+ return atoi(from_environment);
+ }
+ return 1;
+}
+
+} // namespace testing
+} // namespace aos
diff --git a/aos/testing/random_seed.h b/aos/testing/random_seed.h
new file mode 100644
index 0000000..825e7b1
--- /dev/null
+++ b/aos/testing/random_seed.h
@@ -0,0 +1,15 @@
+#ifndef AOS_TESTING_RANDOM_SEED_H_
+#define AOS_TESTING_RANDOM_SEED_H_
+
+namespace aos {
+namespace testing {
+
+// Returns the random seed to use for testing.
+//
+// This is ${TEST_RANDOM_SEED} if it is set or 1.
+int RandomSeed();
+
+} // namespace testing
+} // namespace aos
+
+#endif // AOS_TESTING_RANDOM_SEED_H_