Added GPIO support for update engine automated test.
New functionality in update engine for discovering and reading the
dut_flaga/b GPIOs; we use the dut_flaga value as trigger for using
a different update server URL.
Note: in the future, we will migrate all GPIO functionality outside of
update engine, into its own dedicated package.
CQ-DEPEND=I82cdd28a87f5227e63586810534b92922d43ae52
BUG=chromium-os:25397
TEST=GPIOs were discovered and read on x86-alex, w/ and w/o servo.
Change-Id: Ice3a7ee9669c0916956b492c9524e4b5808d6fb3
Reviewed-on: https://gerrit.chromium.org/gerrit/16554
Commit-Ready: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
diff --git a/update_attempter.h b/update_attempter.h
index 882893a..a1ae772 100644
--- a/update_attempter.h
+++ b/update_attempter.h
@@ -14,6 +14,7 @@
#include <base/time.h>
#include <glib.h>
#include <gtest/gtest_prod.h> // for FRIEND_TEST
+#include <libudev.h>
#include "update_engine/action_processor.h"
#include "update_engine/chrome_browser_proxy_resolver.h"
@@ -136,6 +137,9 @@
void BroadcastStatus();
private:
+ // Update server URL for automated lab test.
+ static const char* const kTestUpdateUrl;
+
friend class UpdateAttempterTest;
FRIEND_TEST(UpdateAttempterTest, ActionCompletedDownloadTest);
FRIEND_TEST(UpdateAttempterTest, ActionCompletedErrorTest);
@@ -212,6 +216,26 @@
// update has been applied.
void PingOmaha();
+ // Gets the fully qualified sysfs name of a dutflag device. |udev| is a live
+ // libudev instance; |gpio_dutflag_str| is the identifier for the requested
+ // dutflag GPIO. The output is stored in the string pointed to by
+ // |dutflag_dev_name_p|. Returns true upon success, false otherwise.
+ bool GetDutflagGpioDevName(struct udev* udev,
+ const std::string& gpio_dutflag_str,
+ std::string* dutflag_dev_name_p);
+
+ // Gets the dut_flaga/b GPIO device names and copies them into the two string
+ // arguments, respectively. The function caches these strings, which are
+ // assumed to be hardware constants. Returns true upon success, false
+ // otherwise.
+ bool GetDutflagGpioDevNames(std::string* dutflaga_dev_name_p,
+ std::string* dutflagb_dev_name_p);
+
+ // Writes the dut_flaga GPIO status into its argument, where true/false stand
+ // for "on"/"off", respectively. Returns true upon success, false otherwise
+ // (in which case no value is written to |status|).
+ bool GetDutflagaGpio(bool* status);
+
// Last status notification timestamp used for throttling. Use monotonic
// TimeTicks to ensure that notifications are sent even if the system clock is
// set back in the middle of an update.
@@ -293,6 +317,10 @@
// Used for fetching information about the device policy.
scoped_ptr<policy::PolicyProvider> policy_provider_;
+ // Dutflaga/b GPIO device names.
+ std::string dutflaga_dev_name_;
+ std::string dutflagb_dev_name_;
+
DISALLOW_COPY_AND_ASSIGN(UpdateAttempter);
};