AU/unittest: postinstall tests use uniquely named stateful + working directories
This should allow these tests to be run in parallel. Also includes an
extension to PostinstallRunnerAction and two global powerwash marker
utility functions to allow testing with uniquely named marker file paths
(necessary to avoid race conditions when multiple tests are run in
parallel).
BUG=chromium:236465
TEST=Uniquely named directories created, used and removed.
Change-Id: I5dde0c0732c51e9e3bb2240cf7e0cac03bcde529
Reviewed-on: https://gerrit.chromium.org/gerrit/60864
Commit-Queue: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
diff --git a/postinstall_runner_action.h b/postinstall_runner_action.h
index 2308a0f..0136ee2 100644
--- a/postinstall_runner_action.h
+++ b/postinstall_runner_action.h
@@ -17,7 +17,9 @@
class PostinstallRunnerAction : public InstallPlanAction {
public:
- PostinstallRunnerAction(): powerwash_marker_created_(false) {}
+ PostinstallRunnerAction()
+ : powerwash_marker_created_(false),
+ powerwash_marker_file_(NULL) {}
void PerformAction();
@@ -42,6 +44,17 @@
// False otherwise. Used for cleaning up if post-install fails.
bool powerwash_marker_created_;
+ // Non-NULL value will cause post-install to override the default marker file
+ // name; used for testing.
+ const char* powerwash_marker_file_;
+
+ // Special ctor + friend declaration for testing purposes.
+ PostinstallRunnerAction(const char* powerwash_marker_file)
+ : powerwash_marker_created_(false),
+ powerwash_marker_file_(powerwash_marker_file) {}
+
+ friend class PostinstallRunnerActionTest;
+
DISALLOW_COPY_AND_ASSIGN(PostinstallRunnerAction);
};