diff options
| author | 2018-07-16 15:54:50 +0000 | |
|---|---|---|
| committer | 2018-07-16 15:54:50 +0000 | |
| commit | eb577ebe86a7d13a6ab18f7975a55a8b592f0e4c (patch) | |
| tree | 5fe593b0006e3ab2db9292f10bfa08af2cc6689b /libartbase/base/common_art_test.h | |
| parent | 06a45b7588830c04dec723beee365a2e4c1c52f2 (diff) | |
| parent | 38aa0b53545a647581411b7e84cd229c5023a3c1 (diff) | |
Merge "ART: Clean up test exec code"
Diffstat (limited to 'libartbase/base/common_art_test.h')
| -rw-r--r-- | libartbase/base/common_art_test.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/libartbase/base/common_art_test.h b/libartbase/base/common_art_test.h index 0ace09de1a..62834c7d35 100644 --- a/libartbase/base/common_art_test.h +++ b/libartbase/base/common_art_test.h @@ -19,8 +19,11 @@ #include <gtest/gtest.h> +#include <functional> #include <string> +#include <sys/wait.h> + #include <android-base/logging.h> #include "base/globals.h" @@ -125,6 +128,29 @@ class CommonArtTestImpl { return true; } + struct ForkAndExecResult { + enum Stage { + kLink, + kFork, + kWaitpid, + kFinished, + }; + Stage stage; + int status_code; + + bool StandardSuccess() { + return stage == kFinished && WIFEXITED(status_code) && WEXITSTATUS(status_code) == 0; + } + }; + using OutputHandlerFn = std::function<void(char*, size_t)>; + using PostForkFn = std::function<bool()>; + static ForkAndExecResult ForkAndExec(const std::vector<std::string>& argv, + const PostForkFn& post_fork, + const OutputHandlerFn& handler); + static ForkAndExecResult ForkAndExec(const std::vector<std::string>& argv, + const PostForkFn& post_fork, + std::string* output); + protected: static bool IsHost() { return !kIsTargetBuild; |