adbd: improve coverage by compiling less code.

Test: ./coverage/gen_coverage.sh && ./coverage/report.sh
Change-Id: I26f823e2587435b7ec2c6ca05955adef5cfc23a0
This commit is contained in:
Josh Gao 2020-04-20 19:22:05 -07:00
parent f099105f07
commit 073c8d2394
3 changed files with 19 additions and 14 deletions

View File

@ -165,7 +165,6 @@ libadb_srcs = [
"adb_unique_fd.cpp", "adb_unique_fd.cpp",
"adb_utils.cpp", "adb_utils.cpp",
"fdevent/fdevent.cpp", "fdevent/fdevent.cpp",
"fdevent/fdevent_poll.cpp",
"services.cpp", "services.cpp",
"sockets.cpp", "sockets.cpp",
"socket_spec.cpp", "socket_spec.cpp",
@ -176,6 +175,17 @@ libadb_srcs = [
"types.cpp", "types.cpp",
] ]
libadb_darwin_srcs = [
"fdevent/fdevent_poll.cpp",
]
libadb_windows_srcs = [
"fdevent/fdevent_poll.cpp",
"sysdeps_win32.cpp",
"sysdeps/win32/errno.cpp",
"sysdeps/win32/stat.cpp",
]
libadb_posix_srcs = [ libadb_posix_srcs = [
"sysdeps_unix.cpp", "sysdeps_unix.cpp",
"sysdeps/posix/network.cpp", "sysdeps/posix/network.cpp",
@ -219,7 +229,7 @@ cc_library_host_static {
srcs: ["client/usb_linux.cpp"] + libadb_linux_srcs, srcs: ["client/usb_linux.cpp"] + libadb_linux_srcs,
}, },
darwin: { darwin: {
srcs: ["client/usb_osx.cpp"], srcs: ["client/usb_osx.cpp"] + libadb_darwin_srcs,
}, },
not_windows: { not_windows: {
srcs: libadb_posix_srcs, srcs: libadb_posix_srcs,
@ -228,10 +238,7 @@ cc_library_host_static {
enabled: true, enabled: true,
srcs: [ srcs: [
"client/usb_windows.cpp", "client/usb_windows.cpp",
"sysdeps_win32.cpp", ] + libadb_windows_srcs,
"sysdeps/win32/errno.cpp",
"sysdeps/win32/stat.cpp",
],
shared_libs: ["AdbWinApi"], shared_libs: ["AdbWinApi"],
}, },
}, },

View File

@ -89,18 +89,13 @@ void start_device_log(void) {
int adb_trace_mask; int adb_trace_mask;
std::string get_trace_setting_from_env() { std::string get_trace_setting() {
#if ADB_HOST
const char* setting = getenv("ADB_TRACE"); const char* setting = getenv("ADB_TRACE");
if (setting == nullptr) { if (setting == nullptr) {
setting = ""; setting = "";
} }
return setting;
return std::string(setting);
}
std::string get_trace_setting() {
#if ADB_HOST
return get_trace_setting_from_env();
#else #else
return android::base::GetProperty("persist.adb.trace_mask", ""); return android::base::GetProperty("persist.adb.trace_mask", "");
#endif #endif

View File

@ -27,7 +27,10 @@
#include "adb_utils.h" #include "adb_utils.h"
#include "fdevent.h" #include "fdevent.h"
#include "fdevent_epoll.h" #include "fdevent_epoll.h"
#if !defined(__linux__)
#include "fdevent_poll.h" #include "fdevent_poll.h"
#endif
using namespace std::chrono_literals; using namespace std::chrono_literals;
using std::chrono::duration_cast; using std::chrono::duration_cast;