Merge "init: add some documentation in service_utils.h"
diff --git a/trusty/fuzz/Android.bp b/trusty/fuzz/Android.bp
index 969431c..ac49751 100644
--- a/trusty/fuzz/Android.bp
+++ b/trusty/fuzz/Android.bp
@@ -14,10 +14,8 @@
cc_defaults {
name: "trusty_fuzzer_defaults",
- static_libs: [
- "libtrusty_fuzz_utils",
- ],
shared_libs: [
+ "libtrusty_fuzz_utils",
"libbase",
"liblog",
],
@@ -36,6 +34,7 @@
srcs: ["utils.cpp"],
export_include_dirs: ["include"],
shared_libs: [
+ "libtrusty_test",
"libbase",
"liblog",
],
diff --git a/trusty/fuzz/utils.cpp b/trusty/fuzz/utils.cpp
index 240afe7..f4cf0b6 100644
--- a/trusty/fuzz/utils.cpp
+++ b/trusty/fuzz/utils.cpp
@@ -25,6 +25,7 @@
#include <linux/uio.h>
#include <log/log_read.h>
#include <time.h>
+#include <trusty/tipc.h>
#include <iostream>
using android::base::ErrnoError;
@@ -32,9 +33,6 @@
using android::base::Result;
using android::base::unique_fd;
-#define TIPC_IOC_MAGIC 'r'
-#define TIPC_IOC_CONNECT _IOW(TIPC_IOC_MAGIC, 0x80, char*)
-
namespace {
const size_t kTimeoutSeconds = 5;
@@ -80,27 +78,14 @@
: tipc_dev_(tipc_dev), ta_port_(ta_port), ta_fd_(-1) {}
Result<void> TrustyApp::Connect() {
- /*
- * TODO: We can't use libtrusty because (yet)
- * (1) cc_fuzz can't deal with vendor components (b/170753563)
- * (2) We need non-blocking behavior to detect Trusty going down.
- * (we could implement the timeout in the fuzzing code though, as
- * it needs to be around the call to read())
- */
alarm(kTimeoutSeconds);
- int fd = open(tipc_dev_.c_str(), O_RDWR);
+ int fd = tipc_connect(tipc_dev_.c_str(), ta_port_.c_str());
alarm(0);
if (fd < 0) {
return ErrnoError() << "failed to open TIPC device: ";
}
ta_fd_.reset(fd);
- // This ioctl will time out in the kernel if it can't connect.
- int rc = TEMP_FAILURE_RETRY(ioctl(ta_fd_, TIPC_IOC_CONNECT, ta_port_.c_str()));
- if (rc < 0) {
- return ErrnoError() << "failed to connect to TIPC service: ";
- }
-
return {};
}
diff --git a/trusty/libtrusty/Android.bp b/trusty/libtrusty/Android.bp
index 8dba78d..708fdbd 100644
--- a/trusty/libtrusty/Android.bp
+++ b/trusty/libtrusty/Android.bp
@@ -12,10 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-cc_library {
- name: "libtrusty",
- vendor: true,
-
+cc_defaults {
+ name: "libtrusty_defaults",
srcs: ["trusty.c"],
export_include_dirs: ["include"],
cflags: [
@@ -25,3 +23,16 @@
shared_libs: ["liblog"],
}
+
+cc_library {
+ name: "libtrusty",
+ vendor: true,
+ defaults: ["libtrusty_defaults"],
+}
+
+// TODO(b/170753563): cc_fuzz can't deal with vendor components. Build libtrusty
+// for system.
+cc_test_library {
+ name: "libtrusty_test",
+ defaults: ["libtrusty_defaults"],
+}