Merge "Add Symbols parsing."
diff --git a/debuggerd/client/debuggerd_client.cpp b/debuggerd/client/debuggerd_client.cpp
index 224444f..3b84853 100644
--- a/debuggerd/client/debuggerd_client.cpp
+++ b/debuggerd/client/debuggerd_client.cpp
@@ -58,28 +58,31 @@
}
bool debuggerd_trigger_dump(pid_t pid, unique_fd output_fd, DebuggerdDumpType dump_type,
- int timeout_ms) {
+ unsigned int timeout_ms) {
LOG(INFO) << "libdebuggerd_client: started dumping process " << pid;
unique_fd sockfd;
const auto end = std::chrono::steady_clock::now() + std::chrono::milliseconds(timeout_ms);
- auto time_left = [timeout_ms, &end]() { return end - std::chrono::steady_clock::now(); };
+ auto time_left = [&end]() { return end - std::chrono::steady_clock::now(); };
auto set_timeout = [timeout_ms, &time_left](int sockfd) {
if (timeout_ms <= 0) {
- return -1;
+ return sockfd;
}
auto remaining = time_left();
if (remaining < decltype(remaining)::zero()) {
- LOG(ERROR) << "timeout expired";
+ LOG(ERROR) << "libdebuggerd_client: timeout expired";
return -1;
}
+
struct timeval timeout;
populate_timeval(&timeout, remaining);
if (setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) != 0) {
+ PLOG(ERROR) << "libdebuggerd_client: failed to set receive timeout";
return -1;
}
if (setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout)) != 0) {
+ PLOG(ERROR) << "libdebuggerd_client: failed to set send timeout";
return -1;
}
@@ -158,8 +161,10 @@
// Forward output from the pipe to the output fd.
while (true) {
- auto remaining_ms = std::chrono::duration_cast<std::chrono::milliseconds>(time_left());
- if (remaining_ms <= 1ms) {
+ auto remaining_ms = std::chrono::duration_cast<std::chrono::milliseconds>(time_left()).count();
+ if (timeout_ms <= 0) {
+ remaining_ms = -1;
+ } else if (remaining_ms < 0) {
LOG(ERROR) << "libdebuggerd_client: timeout expired";
return false;
}
@@ -168,7 +173,7 @@
.fd = pipe_read.get(), .events = POLLIN, .revents = 0,
};
- rc = poll(&pfd, 1, remaining_ms.count());
+ rc = poll(&pfd, 1, remaining_ms);
if (rc == -1) {
if (errno == EINTR) {
continue;
diff --git a/debuggerd/client/debuggerd_client_test.cpp b/debuggerd/client/debuggerd_client_test.cpp
index 86d0314..aff03e5 100644
--- a/debuggerd/client/debuggerd_client_test.cpp
+++ b/debuggerd/client/debuggerd_client_test.cpp
@@ -89,3 +89,23 @@
EXPECT_EQ(1, found_end) << "\nOutput: \n" << result;
}
+
+TEST(debuggerd_client, no_timeout) {
+ unique_fd pipe_read, pipe_write;
+ ASSERT_TRUE(Pipe(&pipe_read, &pipe_write));
+
+ pid_t forkpid = fork();
+ ASSERT_NE(-1, forkpid);
+ if (forkpid == 0) {
+ pipe_write.reset();
+ char dummy;
+ TEMP_FAILURE_RETRY(read(pipe_read.get(), &dummy, sizeof(dummy)));
+ exit(0);
+ }
+
+ pipe_read.reset();
+
+ unique_fd output_read, output_write;
+ ASSERT_TRUE(Pipe(&output_read, &output_write));
+ ASSERT_TRUE(debuggerd_trigger_dump(forkpid, std::move(output_write), kDebuggerdBacktrace, 0));
+}
diff --git a/debuggerd/debuggerd_test.cpp b/debuggerd/debuggerd_test.cpp
index fa2838e..b705e27 100644
--- a/debuggerd/debuggerd_test.cpp
+++ b/debuggerd/debuggerd_test.cpp
@@ -500,9 +500,6 @@
TEST(crash_dump, zombie) {
pid_t forkpid = fork();
- int pipefd[2];
- ASSERT_EQ(0, pipe2(pipefd, O_CLOEXEC));
-
pid_t rc;
int status;
diff --git a/debuggerd/include/debuggerd/client.h b/debuggerd/include/debuggerd/client.h
index 91f143b..01de57b 100644
--- a/debuggerd/include/debuggerd/client.h
+++ b/debuggerd/include/debuggerd/client.h
@@ -28,9 +28,9 @@
};
// Trigger a dump of specified process to output_fd.
-// output_fd is *not* consumed, timeouts <= 0 will wait forever.
+// output_fd is consumed, timeout of 0 will wait forever.
bool debuggerd_trigger_dump(pid_t pid, android::base::unique_fd output_fd,
- enum DebuggerdDumpType dump_type, int timeout_ms);
+ enum DebuggerdDumpType dump_type, unsigned int timeout_ms);
int dump_backtrace_to_file(pid_t tid, int fd);
int dump_backtrace_to_file_timeout(pid_t tid, int fd, int timeout_secs);
diff --git a/libappfuse/Android.bp b/libappfuse/Android.bp
index f729faf..e659f79 100644
--- a/libappfuse/Android.bp
+++ b/libappfuse/Android.bp
@@ -24,6 +24,7 @@
cc_test {
name: "libappfuse_test",
+ test_suites: ["device-tests"],
defaults: ["libappfuse_defaults"],
shared_libs: ["libappfuse"],
srcs: [
diff --git a/libappfuse/AndroidTest.xml b/libappfuse/AndroidTest.xml
new file mode 100644
index 0000000..a9cd754
--- /dev/null
+++ b/libappfuse/AndroidTest.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration description="Config for libappfuse_test">
+ <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
+ <option name="cleanup" value="true" />
+ <option name="push" value="libappfuse_test->/data/local/tmp/libappfuse_test" />
+ </target_preparer>
+ <option name="test-suite-tag" value="apct" />
+ <test class="com.android.tradefed.testtype.GTest" >
+ <option name="native-test-device-path" value="/data/local/tmp" />
+ <option name="module-name" value="libappfuse_test" />
+ </test>
+</configuration>
\ No newline at end of file
diff --git a/libcutils/tests/Android.bp b/libcutils/tests/Android.bp
index c663a5d..a0b1d7b 100644
--- a/libcutils/tests/Android.bp
+++ b/libcutils/tests/Android.bp
@@ -62,6 +62,7 @@
cc_test {
name: "libcutils_test",
+ test_suites: ["device-tests"],
defaults: ["libcutils_test_default"],
host_supported: true,
shared_libs: test_libraries,
diff --git a/libcutils/tests/AndroidTest.xml b/libcutils/tests/AndroidTest.xml
index c945f4d..dd7aca2 100644
--- a/libcutils/tests/AndroidTest.xml
+++ b/libcutils/tests/AndroidTest.xml
@@ -13,14 +13,14 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<configuration description="Config for libcutils_test_static">
+<configuration description="Config for libcutils_test">
<target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
<option name="cleanup" value="true" />
- <option name="push" value="libcutils_test_static->/data/local/tmp/libcutils_test_static" />
+ <option name="push" value="libcutils_test->/data/local/tmp/libcutils_test" />
</target_preparer>
<option name="test-suite-tag" value="apct" />
<test class="com.android.tradefed.testtype.GTest" >
<option name="native-test-device-path" value="/data/local/tmp" />
- <option name="module-name" value="libcutils_test_static" />
+ <option name="module-name" value="libcutils_test" />
</test>
</configuration>
\ No newline at end of file
diff --git a/liblog/tests/liblog_test.cpp b/liblog/tests/liblog_test.cpp
index 0538c4c..70b8a28 100644
--- a/liblog/tests/liblog_test.cpp
+++ b/liblog/tests/liblog_test.cpp
@@ -1984,6 +1984,8 @@
EXPECT_EQ(0, setuid(AID_SYSTEM)); // only one that can read security buffer
+ uid = getuid();
+ gid = getgid();
pid_t pid = getpid();
ASSERT_TRUE(NULL !=
diff --git a/logcat/Android.mk b/logcat/Android.mk
index f564f0f..4e11ca9 100644
--- a/logcat/Android.mk
+++ b/logcat/Android.mk
@@ -15,6 +15,16 @@
include $(CLEAR_VARS)
+LOCAL_MODULE := logcatd
+LOCAL_MODULE_TAGS := debug
+LOCAL_SRC_FILES := logcatd_main.cpp event.logtags
+LOCAL_SHARED_LIBRARIES := liblogcat $(logcatLibs)
+LOCAL_CFLAGS := -Werror
+
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+
LOCAL_MODULE := liblogcat
LOCAL_SRC_FILES := logcat.cpp getopt_long.cpp logcat_system.cpp
LOCAL_SHARED_LIBRARIES := $(logcatLibs)
diff --git a/logcat/logcatd.rc b/logcat/logcatd.rc
index b082a64..06cc90d 100644
--- a/logcat/logcatd.rc
+++ b/logcat/logcatd.rc
@@ -34,9 +34,6 @@
on property:logd.logpersistd.enable=true && property:logd.logpersistd=logcatd
# all exec/services are called with umask(077), so no gain beyond 0700
mkdir /data/misc/logd 0700 logd log
- # logd for write to /data/misc/logd, log group for read from pstore (-L)
- # b/28788401 b/30041146 b/30612424
- # exec - logd log -- /system/bin/logcat -L -b ${logd.logpersistd.buffer:-all} -v threadtime -v usec -v printable -D -f /data/misc/logd/logcat -r 1024 -n ${logd.logpersistd.size:-256} --id=${ro.build.id}
start logcatd
# stop logcatd service and clear data
@@ -57,7 +54,7 @@
stop logcatd
# logcatd service
-service logcatd /system/bin/logcat -b ${logd.logpersistd.buffer:-all} -v threadtime -v usec -v printable -D -f /data/misc/logd/logcat -r 1024 -n ${logd.logpersistd.size:-256} --id=${ro.build.id}
+service logcatd /system/bin/logcatd -L -b ${logd.logpersistd.buffer:-all} -v threadtime -v usec -v printable -D -f /data/misc/logd/logcat -r 1024 -n ${logd.logpersistd.size:-256} --id=${ro.build.id}
class late_start
disabled
# logd for write to /data/misc/logd, log group for read from log daemon
diff --git a/logcat/logcatd_main.cpp b/logcat/logcatd_main.cpp
new file mode 100644
index 0000000..9109eb1
--- /dev/null
+++ b/logcat/logcatd_main.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <string>
+#include <vector>
+
+#include <log/logcat.h>
+
+int main(int argc, char** argv, char** envp) {
+ android_logcat_context ctx = create_android_logcat();
+ if (!ctx) return -1;
+
+ signal(SIGPIPE, exit);
+
+ // Save and detect presence of -L or --last flag
+ std::vector<std::string> args;
+ bool last = false;
+ for (int i = 0; i < argc; ++i) {
+ if (!argv[i]) continue;
+ args.push_back(std::string(argv[i]));
+ if (!strcmp(argv[i], "-L") || !strcmp(argv[i], "--last")) last = true;
+ }
+
+ // Generate argv from saved content
+ std::vector<const char*> argv_hold;
+ for (auto& str : args) argv_hold.push_back(str.c_str());
+ argv_hold.push_back(nullptr);
+
+ int ret = 0;
+ if (last) {
+ // Run logcat command with -L flag
+ ret = android_logcat_run_command(ctx, -1, -1, argv_hold.size() - 1,
+ (char* const*)&argv_hold[0], envp);
+ // Remove -L and --last flags from argument list
+ for (std::vector<const char*>::iterator it = argv_hold.begin();
+ it != argv_hold.end();) {
+ if (!*it || (strcmp(*it, "-L") && strcmp(*it, "--last"))) {
+ ++it;
+ } else {
+ it = argv_hold.erase(it);
+ }
+ }
+ // fall through to re-run the command regardless of the arguments
+ // passed in. For instance, we expect -h to report help stutter.
+ }
+
+ // Run logcat command without -L flag
+ int retval = android_logcat_run_command(ctx, -1, -1, argv_hold.size() - 1,
+ (char* const*)&argv_hold[0], envp);
+ if (!ret) ret = retval;
+ retval = android_logcat_destroy(&ctx);
+ if (!ret) ret = retval;
+ return ret;
+}
diff --git a/logcat/tests/Android.mk b/logcat/tests/Android.mk
index 22aca17..defd3c4 100644
--- a/logcat/tests/Android.mk
+++ b/logcat/tests/Android.mk
@@ -50,6 +50,7 @@
test_src_files := \
logcat_test.cpp \
+ logcatd_test.cpp \
liblogcat_test.cpp \
# Build tests for the device (with .so). Run with:
diff --git a/logcat/tests/logcat_test.cpp b/logcat/tests/logcat_test.cpp
index d802b26..21868f2 100644
--- a/logcat/tests/logcat_test.cpp
+++ b/logcat/tests/logcat_test.cpp
@@ -20,6 +20,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/cdefs.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
@@ -39,6 +40,10 @@
#define logcat_pclose(context, fp) pclose(fp)
#define logcat_system(command) system(command)
#endif
+#ifndef logcat_executable
+#define USING_LOGCAT_EXECUTABLE_DEFAULT
+#define logcat_executable "logcat"
+#endif
#define BIG_BUFFER (5 * 1024)
@@ -64,14 +69,13 @@
#undef LOG_TAG
#define LOG_TAG "inject"
- RLOGE("logcat.buckets");
+ RLOGE(logcat_executable ".buckets");
sleep(1);
- ASSERT_TRUE(
- NULL !=
- (fp = logcat_popen(
- ctx,
- "logcat -b radio -b events -b system -b main -d 2>/dev/null")));
+ ASSERT_TRUE(NULL !=
+ (fp = logcat_popen(
+ ctx, logcat_executable
+ " -b radio -b events -b system -b main -d 2>/dev/null")));
char buffer[BIG_BUFFER];
@@ -101,8 +105,8 @@
logcat_define(ctx);
ASSERT_TRUE(NULL !=
- (fp = logcat_popen(ctx,
- "logcat -b events -d -s auditd "
+ (fp = logcat_popen(ctx, logcat_executable
+ " -b events -d -s auditd "
"am_proc_start am_pss am_proc_bound "
"dvm_lock_sample am_wtf 2>/dev/null")));
@@ -170,10 +174,9 @@
#endif
strftime(needle, sizeof(needle), "[ %Y-", ptm);
- ASSERT_TRUE(
- NULL !=
- (fp = logcat_popen(
- ctx, "logcat -v long -v year -b all -t 3 2>/dev/null")));
+ ASSERT_TRUE(NULL != (fp = logcat_popen(
+ ctx, logcat_executable
+ " -v long -v year -b all -t 3 2>/dev/null")));
char buffer[BIG_BUFFER];
@@ -237,8 +240,8 @@
logcat_define(ctx);
ASSERT_TRUE(NULL !=
- (fp = logcat_popen(ctx,
- "logcat -v long -v America/Los_Angeles "
+ (fp = logcat_popen(ctx, logcat_executable
+ " -v long -v America/Los_Angeles "
"-b all -t 3 2>/dev/null")));
char buffer[BIG_BUFFER];
@@ -264,10 +267,9 @@
FILE* fp;
logcat_define(ctx);
- ASSERT_TRUE(NULL !=
- (fp = logcat_popen(ctx,
- "logcat -v long -v America/Los_Angeles -v "
- "zone -b all -t 3 2>/dev/null")));
+ ASSERT_TRUE(NULL != (fp = logcat_popen(ctx, logcat_executable
+ " -v long -v America/Los_Angeles -v "
+ "zone -b all -t 3 2>/dev/null")));
char buffer[BIG_BUFFER];
@@ -435,11 +437,11 @@
}
TEST(logcat, tail_time) {
- do_tail_time("logcat -v long -v nsec -b all");
+ do_tail_time(logcat_executable " -v long -v nsec -b all");
}
TEST(logcat, tail_time_epoch) {
- do_tail_time("logcat -v long -v nsec -v epoch -b all");
+ do_tail_time(logcat_executable " -v long -v nsec -v epoch -b all");
}
TEST(logcat, End_to_End) {
@@ -452,8 +454,8 @@
FILE* fp;
logcat_define(ctx);
ASSERT_TRUE(NULL !=
- (fp = logcat_popen(
- ctx, "logcat -v brief -b events -t 100 2>/dev/null")));
+ (fp = logcat_popen(ctx, logcat_executable
+ " -v brief -b events -t 100 2>/dev/null")));
char buffer[BIG_BUFFER];
@@ -492,8 +494,8 @@
size_t num = 0;
do {
EXPECT_TRUE(NULL !=
- (fp[num] = logcat_popen(
- ctx[num], "logcat -v brief -b events -t 100")));
+ (fp[num] = logcat_popen(ctx[num], logcat_executable
+ " -v brief -b events -t 100")));
if (!fp[num]) {
fprintf(stderr,
"WARNING: limiting to %zu simultaneous logcat operations\n",
@@ -604,22 +606,23 @@
}
TEST(logcat, get_size) {
- ASSERT_EQ(4, get_groups("logcat -v brief -b radio -b events -b system -b "
+ ASSERT_EQ(4, get_groups(logcat_executable
+ " -v brief -b radio -b events -b system -b "
"main -g 2>/dev/null"));
}
// duplicate test for get_size, but use comma-separated list of buffers
TEST(logcat, multiple_buffer) {
ASSERT_EQ(
- 4, get_groups(
- "logcat -v brief -b radio,events,system,main -g 2>/dev/null"));
+ 4, get_groups(logcat_executable
+ " -v brief -b radio,events,system,main -g 2>/dev/null"));
}
TEST(logcat, bad_buffer) {
- ASSERT_EQ(
- 0,
- get_groups(
- "logcat -v brief -b radio,events,bogo,system,main -g 2>/dev/null"));
+ ASSERT_EQ(0,
+ get_groups(
+ logcat_executable
+ " -v brief -b radio,events,bogo,system,main -g 2>/dev/null"));
}
#ifndef logcat
@@ -774,8 +777,8 @@
char buf[sizeof(form)];
ASSERT_TRUE(NULL != mkdtemp(strcpy(buf, form)));
- static const char comm[] =
- "logcat -b radio -b events -b system -b main"
+ static const char comm[] = logcat_executable
+ " -b radio -b events -b system -b main"
" -d -f %s/log.txt -n 7 -r 1";
char command[sizeof(buf) + sizeof(comm)];
snprintf(command, sizeof(command), comm, buf);
@@ -820,8 +823,8 @@
char tmp_out_dir[sizeof(tmp_out_dir_form)];
ASSERT_TRUE(NULL != mkdtemp(strcpy(tmp_out_dir, tmp_out_dir_form)));
- static const char logcat_cmd[] =
- "logcat -b radio -b events -b system -b main"
+ static const char logcat_cmd[] = logcat_executable
+ " -b radio -b events -b system -b main"
" -d -f %s/log.txt -n 10 -r 1";
char command[sizeof(tmp_out_dir) + sizeof(logcat_cmd)];
snprintf(command, sizeof(command), logcat_cmd, tmp_out_dir);
@@ -880,7 +883,7 @@
static const char log_filename[] = "log.txt";
static const char logcat_cmd[] =
- "logcat -b all -v nsec -d -f %s/%s -n 256 -r 1024";
+ logcat_executable " -b all -v nsec -d -f %s/%s -n 256 -r 1024";
static const char cleanup_cmd[] = "rm -rf %s";
char command[sizeof(tmp_out_dir) + sizeof(logcat_cmd) + sizeof(log_filename)];
snprintf(command, sizeof(command), logcat_cmd, tmp_out_dir, log_filename);
@@ -1005,7 +1008,8 @@
static const char log_filename[] = "log.txt";
static const unsigned num_val = 32;
- static const char logcat_cmd[] = "logcat -b all -d -f %s/%s -n %d -r 1";
+ static const char logcat_cmd[] =
+ logcat_executable " -b all -d -f %s/%s -n %d -r 1";
static const char clear_cmd[] = " -c";
static const char cleanup_cmd[] = "rm -rf %s";
char command[sizeof(tmp_out_dir) + sizeof(logcat_cmd) +
@@ -1109,9 +1113,9 @@
TEST(logcat, logrotate_id) {
static const char logcat_cmd[] =
- "logcat -b all -d -f %s/%s -n 32 -r 1 --id=test";
+ logcat_executable " -b all -d -f %s/%s -n 32 -r 1 --id=test";
static const char logcat_short_cmd[] =
- "logcat -b all -t 10 -f %s/%s -n 32 -r 1 --id=test";
+ logcat_executable " -b all -t 10 -f %s/%s -n 32 -r 1 --id=test";
static const char tmp_out_dir_form[] =
"/data/local/tmp/logcat.logrotate.XXXXXX";
static const char log_filename[] = "log.txt";
@@ -1155,8 +1159,8 @@
TEST(logcat, logrotate_nodir) {
// expect logcat to error out on writing content and not exit(0) for nodir
- static const char command[] =
- "logcat -b all -d"
+ static const char command[] = logcat_executable
+ " -b all -d"
" -f /das/nein/gerfingerpoken/logcat/log.txt"
" -n 256 -r 1024";
EXPECT_FALSE(IsFalse(0 == logcat_system(command), command));
@@ -1292,7 +1296,7 @@
FILE* fp;
logcat_define(ctx);
- fp = logcat_popen(ctx, "logcat -p 2>/dev/null");
+ fp = logcat_popen(ctx, logcat_executable " -p 2>/dev/null");
if (fp == NULL) {
fprintf(stderr, "ERROR: logcat -p 2>/dev/null\n");
return false;
@@ -1330,7 +1334,8 @@
char buffer[BIG_BUFFER];
- snprintf(buffer, sizeof(buffer), "logcat -P '%s' 2>&1", list ? list : "");
+ snprintf(buffer, sizeof(buffer), logcat_executable " -P '%s' 2>&1",
+ list ? list : "");
fp = logcat_popen(ctx, buffer);
if (fp == NULL) {
fprintf(stderr, "ERROR: %s\n", buffer);
@@ -1392,15 +1397,11 @@
int count = 0;
char buffer[BIG_BUFFER];
-// Have to make liblogcat data unique from logcat data injection
-#ifdef logcat
-#define logcat_regex_prefix "lolcat_test"
-#else
-#define logcat_regex_prefix "logcat_test"
-#endif
+#define logcat_regex_prefix ___STRING(logcat) "_test"
snprintf(buffer, sizeof(buffer),
- "logcat --pid %d -d -e " logcat_regex_prefix "_a+b", getpid());
+ logcat_executable " --pid %d -d -e " logcat_regex_prefix "_a+b",
+ getpid());
LOG_FAILURE_RETRY(__android_log_print(ANDROID_LOG_WARN, logcat_regex_prefix,
logcat_regex_prefix "_ab"));
@@ -1437,8 +1438,8 @@
char buffer[BIG_BUFFER];
- snprintf(buffer, sizeof(buffer), "logcat --pid %d -d --max-count 3",
- getpid());
+ snprintf(buffer, sizeof(buffer),
+ logcat_executable " --pid %d -d --max-count 3", getpid());
LOG_FAILURE_RETRY(
__android_log_print(ANDROID_LOG_WARN, "logcat_test", "logcat_test"));
@@ -1663,10 +1664,11 @@
}
TEST(logcat, security) {
- EXPECT_FALSE(reportedSecurity("logcat -b all -g 2>&1"));
- EXPECT_TRUE(reportedSecurity("logcat -b security -g 2>&1"));
- EXPECT_TRUE(reportedSecurity("logcat -b security -c 2>&1"));
- EXPECT_TRUE(reportedSecurity("logcat -b security -G 256K 2>&1"));
+ EXPECT_FALSE(reportedSecurity(logcat_executable " -b all -g 2>&1"));
+ EXPECT_TRUE(reportedSecurity(logcat_executable " -b security -g 2>&1"));
+ EXPECT_TRUE(reportedSecurity(logcat_executable " -b security -c 2>&1"));
+ EXPECT_TRUE(
+ reportedSecurity(logcat_executable " -b security -G 256K 2>&1"));
}
static size_t commandOutputSize(const char* command) {
@@ -1682,8 +1684,14 @@
}
TEST(logcat, help) {
- size_t logcatHelpTextSize = commandOutputSize("logcat -h 2>&1");
+ size_t logcatHelpTextSize = commandOutputSize(logcat_executable " -h 2>&1");
EXPECT_LT(4096UL, logcatHelpTextSize);
- size_t logcatLastHelpTextSize = commandOutputSize("logcat -L -h 2>&1");
+ size_t logcatLastHelpTextSize =
+ commandOutputSize(logcat_executable " -L -h 2>&1");
+#ifdef USING_LOGCAT_EXECUTABLE_DEFAULT // logcat and liblogcat
EXPECT_EQ(logcatHelpTextSize, logcatLastHelpTextSize);
+#else
+ // logcatd -L -h prints the help twice, as designed.
+ EXPECT_EQ(logcatHelpTextSize * 2, logcatLastHelpTextSize);
+#endif
}
diff --git a/logcat/tests/logcatd_test.cpp b/logcat/tests/logcatd_test.cpp
new file mode 100644
index 0000000..bb7534e
--- /dev/null
+++ b/logcat/tests/logcatd_test.cpp
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define logcat logcatd
+#define logcat_executable "logcatd"
+
+#include "logcat_test.cpp"
diff --git a/rootdir/init.rc b/rootdir/init.rc
index d48b892..ff96c14 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -301,6 +301,9 @@
start logd
start hwservicemanager
+ # HALs required before data is mounted
+ class_start early_hal
+
# once everything is setup, no need to modify /
mount rootfs rootfs / ro remount
# Mount shared so changes propagate into child namespaces