summaryrefslogtreecommitdiff
path: root/runtime/exec_utils.h
diff options
context:
space:
mode:
author Jiakai Zhang <jiakaiz@google.com> 2021-08-16 03:20:07 +0000
committer Treehugger Robot <treehugger-gerrit@google.com> 2021-08-20 12:59:57 +0000
commitb91dad2b98e8c562aed7c4471615d7c325756c08 (patch)
tree85f1d6092a86116555f785a4f906b5f852aa1fca /runtime/exec_utils.h
parent3bc03531d1ae5cbe5b0a7ac34c10d5c51f20f233 (diff)
Add unit tests for odrefresh - step 2
- Define MockableExecUtils, which is a wrapper class to make exec_utils mockable. - Add another constructor to the OnDeviceRefresh class to support injections. - Update OdrConfig to support overriding the staging directory. - Add a unit test to verify that odrefresh sets compiler filter based on "dalvik.vm.systemservercompilerfilter". Bug: 196188549 Test: atest art_standalone_odrefresh_tests Test: atest odsign_e2e_tests Change-Id: Ia7b4347bba6873878490a513b8a5ff6642122d71
Diffstat (limited to 'runtime/exec_utils.h')
-rw-r--r--runtime/exec_utils.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/runtime/exec_utils.h b/runtime/exec_utils.h
index 5e22639a08..e011c822ba 100644
--- a/runtime/exec_utils.h
+++ b/runtime/exec_utils.h
@@ -37,6 +37,28 @@ int ExecAndReturnCode(std::vector<std::string>& arg_vector,
/*out*/ bool* timed_out,
/*out*/ std::string* error_msg);
+// A wrapper class to make the functions above mockable.
+class ExecUtils {
+ public:
+ virtual ~ExecUtils() = default;
+
+ virtual bool Exec(std::vector<std::string>& arg_vector, /*out*/ std::string* error_msg) const {
+ return art::Exec(arg_vector, error_msg);
+ }
+
+ virtual int ExecAndReturnCode(std::vector<std::string>& arg_vector,
+ /*out*/ std::string* error_msg) const {
+ return art::ExecAndReturnCode(arg_vector, error_msg);
+ }
+
+ virtual int ExecAndReturnCode(std::vector<std::string>& arg_vector,
+ time_t timeout_secs,
+ /*out*/ bool* timed_out,
+ /*out*/ std::string* error_msg) const {
+ return art::ExecAndReturnCode(arg_vector, timeout_secs, timed_out, error_msg);
+ }
+};
+
} // namespace art
#endif // ART_RUNTIME_EXEC_UTILS_H_