binder: Add execute() to host utils.

Add utility for executing commands.

This function assumes that, when a given predicate
|end| finishes, the child process does not emit any other
messages.

If this is not the case, caller to execute()
must handle these I/O in the pipes in the returned
CommandResult object. Otherwise the child program may
hang on I/O.

Test: binderUtilsTest
Bug: 190233850

Change-Id: Ib8be5db140af04a286ccbb2283cb032390aff5ac
diff --git a/libs/binder/tests/Android.bp b/libs/binder/tests/Android.bp
index c7c899f..0aa3139 100644
--- a/libs/binder/tests/Android.bp
+++ b/libs/binder/tests/Android.bp
@@ -327,3 +327,17 @@
         "libutils",
     ],
 }
+
+cc_test_host {
+    name: "binderUtilsHostTest",
+    defaults: ["binder_test_defaults"],
+    srcs: ["binderUtilsHostTest.cpp"],
+    shared_libs: [
+        "libbase",
+        "libbinder",
+    ],
+    static_libs: [
+        "libgmock",
+    ],
+    test_suites: ["general-tests"],
+}