diff options
Diffstat (limited to 'runtime/exec_utils.h')
| -rw-r--r-- | runtime/exec_utils.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/runtime/exec_utils.h b/runtime/exec_utils.h index 5e22639a08..7ce0a9c20a 100644 --- a/runtime/exec_utils.h +++ b/runtime/exec_utils.h @@ -17,6 +17,8 @@ #ifndef ART_RUNTIME_EXEC_UTILS_H_ #define ART_RUNTIME_EXEC_UTILS_H_ +#include <time.h> + #include <string> #include <vector> @@ -37,6 +39,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_ |