summaryrefslogtreecommitdiff
path: root/runtime/exec_utils.h
diff options
context:
space:
mode:
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_