Merge "bootstat: Remove custom uptime parser in favor of elapsedRealtime."
diff --git a/adb/adb_utils.cpp b/adb/adb_utils.cpp
index 5a3b401..7afa616 100644
--- a/adb/adb_utils.cpp
+++ b/adb/adb_utils.cpp
@@ -313,3 +313,15 @@
void AdbCloser::Close(int fd) {
adb_close(fd);
}
+
+int usage(const char* fmt, ...) {
+ fprintf(stderr, "adb: ");
+
+ va_list ap;
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+
+ fprintf(stderr, "\n");
+ return 1;
+}
diff --git a/adb/adb_utils.h b/adb/adb_utils.h
index 16317e0..2b59034 100644
--- a/adb/adb_utils.h
+++ b/adb/adb_utils.h
@@ -21,6 +21,8 @@
#include <android-base/macros.h>
+int usage(const char*, ...);
+
void close_stdin();
bool getcwd(std::string* cwd);
diff --git a/adb/bugreport.cpp b/adb/bugreport.cpp
index 9b59d05..b7e76a6 100644
--- a/adb/bugreport.cpp
+++ b/adb/bugreport.cpp
@@ -182,11 +182,8 @@
DISALLOW_COPY_AND_ASSIGN(BugreportStandardStreamsCallback);
};
-// Implemented in commandline.cpp
-int usage();
-
int Bugreport::DoIt(TransportType transport_type, const char* serial, int argc, const char** argv) {
- if (argc > 2) return usage();
+ if (argc > 2) return usage("usage: adb bugreport [PATH]");
// Gets bugreportz version.
std::string bugz_stdout, bugz_stderr;
diff --git a/adb/commandline.cpp b/adb/commandline.cpp
index 2befa0c..3b2df2e 100644
--- a/adb/commandline.cpp
+++ b/adb/commandline.cpp
@@ -231,11 +231,6 @@
// clang-format on
}
-int usage() {
- help();
- return 1;
-}
-
#if defined(_WIN32)
// Implemented in sysdeps_win32.cpp.
@@ -1235,7 +1230,7 @@
}
static int restore(int argc, const char** argv) {
- if (argc != 2) return usage();
+ if (argc != 2) return usage("restore requires an argument");
const char* filename = argv[1];
int tarFd = adb_open(filename, O_RDONLY);
@@ -1443,19 +1438,19 @@
/* this is a special flag used only when the ADB client launches the ADB Server */
is_daemon = 1;
} else if (!strcmp(argv[0], "--reply-fd")) {
- if (argc < 2) return usage();
+ if (argc < 2) return usage("--reply-fd requires an argument");
const char* reply_fd_str = argv[1];
argc--;
argv++;
ack_reply_fd = strtol(reply_fd_str, nullptr, 10);
if (!_is_valid_ack_reply_fd(ack_reply_fd)) {
fprintf(stderr, "adb: invalid reply fd \"%s\"\n", reply_fd_str);
- return usage();
+ return 1;
}
} else if (!strncmp(argv[0], "-p", 2)) {
const char* product = nullptr;
if (argv[0][2] == '\0') {
- if (argc < 2) return usage();
+ if (argc < 2) return usage("-p requires an argument");
product = argv[1];
argc--;
argv++;
@@ -1465,13 +1460,13 @@
gProductOutPath = find_product_out_path(product);
if (gProductOutPath.empty()) {
fprintf(stderr, "adb: could not resolve \"-p %s\"\n", product);
- return usage();
+ return 1;
}
} else if (argv[0][0]=='-' && argv[0][1]=='s') {
if (isdigit(argv[0][2])) {
serial = argv[0] + 2;
} else {
- if (argc < 2 || argv[0][2] != '\0') return usage();
+ if (argc < 2 || argv[0][2] != '\0') return usage("-s requires an argument");
serial = argv[1];
argc--;
argv++;
@@ -1484,7 +1479,7 @@
gListenAll = 1;
} else if (!strncmp(argv[0], "-H", 2)) {
if (argv[0][2] == '\0') {
- if (argc < 2) return usage();
+ if (argc < 2) return usage("-H requires an argument");
server_host_str = argv[1];
argc--;
argv++;
@@ -1493,7 +1488,7 @@
}
} else if (!strncmp(argv[0], "-P", 2)) {
if (argv[0][2] == '\0') {
- if (argc < 2) return usage();
+ if (argc < 2) return usage("-P requires an argument");
server_port_str = argv[1];
argc--;
argv++;
@@ -1501,7 +1496,7 @@
server_port_str = argv[0] + 2;
}
} else if (!strcmp(argv[0], "-L")) {
- if (argc < 2) return usage();
+ if (argc < 2) return usage("-L requires an argument");
server_socket_str = argv[1];
argc--;
argv++;
@@ -1566,7 +1561,7 @@
if (no_daemon || is_daemon) {
if (is_daemon && (ack_reply_fd == -1)) {
fprintf(stderr, "reply fd for adb server to client communication not specified.\n");
- return usage();
+ return 1;
}
r = adb_server_main(is_daemon, server_socket_str, ack_reply_fd);
} else {
@@ -1579,7 +1574,8 @@
}
if (argc == 0) {
- return usage();
+ help();
+ return 1;
}
/* handle wait-for-* prefix */
@@ -1696,7 +1692,7 @@
}
}
else if (!strcmp(argv[0], "sideload")) {
- if (argc != 2) return usage();
+ if (argc != 2) return usage("sideload requires an argument");
if (adb_sideload_host(argv[1])) {
return 1;
} else {
@@ -1730,7 +1726,7 @@
bool reverse = !strcmp(argv[0], "reverse");
++argv;
--argc;
- if (argc < 1) return usage();
+ if (argc < 1) return usage("%s requires an argument", argv[0]);
// Determine the <host-prefix> for this command.
std::string host_prefix;
@@ -1750,24 +1746,24 @@
std::string cmd, error;
if (strcmp(argv[0], "--list") == 0) {
- if (argc != 1) return usage();
+ if (argc != 1) return usage("--list doesn't take any arguments");
return adb_query_command(host_prefix + ":list-forward");
} else if (strcmp(argv[0], "--remove-all") == 0) {
- if (argc != 1) return usage();
+ if (argc != 1) return usage("--remove-all doesn't take any arguments");
cmd = host_prefix + ":killforward-all";
} else if (strcmp(argv[0], "--remove") == 0) {
// forward --remove <local>
- if (argc != 2) return usage();
+ if (argc != 2) return usage("--remove requires an argument");
cmd = host_prefix + ":killforward:" + argv[1];
} else if (strcmp(argv[0], "--no-rebind") == 0) {
// forward --no-rebind <local> <remote>
- if (argc != 3) return usage();
+ if (argc != 3) return usage("--no-rebind takes two arguments");
if (forward_targets_are_valid(argv[1], argv[2], &error)) {
cmd = host_prefix + ":forward:norebind:" + argv[1] + ";" + argv[2];
}
} else {
// forward <local> <remote>
- if (argc != 2) return usage();
+ if (argc != 2) return usage("forward takes two arguments");
if (forward_targets_are_valid(argv[0], argv[1], &error)) {
cmd = host_prefix + ":forward:" + argv[0] + ";" + argv[1];
}
@@ -1796,7 +1792,7 @@
}
/* do_sync_*() commands */
else if (!strcmp(argv[0], "ls")) {
- if (argc != 2) return usage();
+ if (argc != 2) return usage("ls requires an argument");
return do_sync_ls(argv[1]) ? 0 : 1;
}
else if (!strcmp(argv[0], "push")) {
@@ -1805,7 +1801,7 @@
const char* dst = nullptr;
parse_push_pull_args(&argv[1], argc - 1, &srcs, &dst, ©_attrs);
- if (srcs.empty() || !dst) return usage();
+ if (srcs.empty() || !dst) return usage("push requires an argument");
return do_sync_push(srcs, dst) ? 0 : 1;
}
else if (!strcmp(argv[0], "pull")) {
@@ -1814,22 +1810,22 @@
const char* dst = ".";
parse_push_pull_args(&argv[1], argc - 1, &srcs, &dst, ©_attrs);
- if (srcs.empty()) return usage();
+ if (srcs.empty()) return usage("pull requires an argument");
return do_sync_pull(srcs, dst, copy_attrs) ? 0 : 1;
}
else if (!strcmp(argv[0], "install")) {
- if (argc < 2) return usage();
+ if (argc < 2) return usage("install requires an argument");
if (_use_legacy_install()) {
return install_app_legacy(transport_type, serial, argc, argv);
}
return install_app(transport_type, serial, argc, argv);
}
else if (!strcmp(argv[0], "install-multiple")) {
- if (argc < 2) return usage();
+ if (argc < 2) return usage("install-multiple requires an argument");
return install_multiple_app(transport_type, serial, argc, argv);
}
else if (!strcmp(argv[0], "uninstall")) {
- if (argc < 2) return usage();
+ if (argc < 2) return usage("uninstall requires an argument");
if (_use_legacy_install()) {
return uninstall_app_legacy(transport_type, serial, argc, argv);
}
@@ -1852,12 +1848,12 @@
// A local path or "android"/"data" arg was specified.
src = argv[1];
} else {
- return usage();
+ return usage("usage: adb sync [-l] [PARTITION]");
}
if (src != "" &&
src != "system" && src != "data" && src != "vendor" && src != "oem") {
- return usage();
+ return usage("don't know how to sync %s partition", src.c_str());
}
std::string system_src_path = product_file("system");
@@ -1909,7 +1905,7 @@
return restore(argc, argv);
}
else if (!strcmp(argv[0], "keygen")) {
- if (argc < 2) return usage();
+ if (argc != 2) return usage("keygen requires an argument");
// Always print key generation information for keygen command.
adb_trace_enable(AUTH);
return adb_auth_keygen(argv[1]);
@@ -1926,11 +1922,11 @@
/* "adb /?" is a common idiom under Windows */
- else if (!strcmp(argv[0], "help") || !strcmp(argv[0], "/?")) {
+ else if (!strcmp(argv[0], "--help") || !strcmp(argv[0], "help") || !strcmp(argv[0], "/?")) {
help();
return 0;
}
- else if (!strcmp(argv[0], "version")) {
+ else if (!strcmp(argv[0], "--version") || !strcmp(argv[0], "version")) {
fprintf(stdout, "%s", adb_version().c_str());
return 0;
}
@@ -1961,12 +1957,12 @@
std::string err;
return adb_query_command("host:reconnect-offline");
} else {
- return usage();
+ return usage("usage: adb reconnect [device|offline]");
}
}
}
- usage();
+ usage("unknown command %s", argv[0]);
return 1;
}
diff --git a/debuggerd/crash_dump.cpp b/debuggerd/crash_dump.cpp
index 58eaed7..4e083ae 100644
--- a/debuggerd/crash_dump.cpp
+++ b/debuggerd/crash_dump.cpp
@@ -18,10 +18,12 @@
#include <dirent.h>
#include <fcntl.h>
#include <stdlib.h>
-#include <syscall.h>
+#include <sys/capability.h>
+#include <sys/prctl.h>
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/un.h>
+#include <syscall.h>
#include <unistd.h>
#include <limits>
@@ -51,24 +53,25 @@
using android::base::unique_fd;
using android::base::StringPrintf;
-static bool pid_contains_tid(pid_t pid, pid_t tid) {
- std::string task_path = StringPrintf("/proc/%d/task/%d", pid, tid);
- return access(task_path.c_str(), F_OK) == 0;
+static bool pid_contains_tid(int pid_proc_fd, pid_t tid) {
+ struct stat st;
+ std::string task_path = StringPrintf("task/%d", tid);
+ return fstatat(pid_proc_fd, task_path.c_str(), &st, 0) == 0;
}
// Attach to a thread, and verify that it's still a member of the given process
-static bool ptrace_seize_thread(pid_t pid, pid_t tid, std::string* error) {
+static bool ptrace_seize_thread(int pid_proc_fd, pid_t tid, std::string* error) {
if (ptrace(PTRACE_SEIZE, tid, 0, 0) != 0) {
*error = StringPrintf("failed to attach to thread %d: %s", tid, strerror(errno));
return false;
}
// Make sure that the task we attached to is actually part of the pid we're dumping.
- if (!pid_contains_tid(pid, tid)) {
+ if (!pid_contains_tid(pid_proc_fd, tid)) {
if (ptrace(PTRACE_DETACH, tid, 0, 0) != 0) {
PLOG(FATAL) << "failed to detach from thread " << tid;
}
- *error = StringPrintf("thread %d is not in process %d", tid, pid);
+ *error = StringPrintf("thread %d is not in process", tid);
return false;
}
@@ -190,6 +193,24 @@
_exit(1);
}
+static void drop_capabilities() {
+ __user_cap_header_struct capheader;
+ memset(&capheader, 0, sizeof(capheader));
+ capheader.version = _LINUX_CAPABILITY_VERSION_3;
+ capheader.pid = 0;
+
+ __user_cap_data_struct capdata[2];
+ memset(&capdata, 0, sizeof(capdata));
+
+ if (capset(&capheader, &capdata[0]) == -1) {
+ PLOG(FATAL) << "failed to drop capabilities";
+ }
+
+ if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) != 0) {
+ PLOG(FATAL) << "failed to set PR_SET_NO_NEW_PRIVS";
+ }
+}
+
static void check_process(int proc_fd, pid_t expected_pid) {
android::procinfo::ProcessInfo proc_info;
if (!android::procinfo::GetProcessInfoFromProcPidFd(proc_fd, &proc_info)) {
@@ -263,7 +284,7 @@
check_process(target_proc_fd, target);
std::string attach_error;
- if (!ptrace_seize_thread(target, main_tid, &attach_error)) {
+ if (!ptrace_seize_thread(target_proc_fd, main_tid, &attach_error)) {
LOG(FATAL) << attach_error;
}
@@ -304,6 +325,7 @@
}
int signo = siginfo.si_signo;
+ bool fatal_signal = signo != DEBUGGER_SIGNAL;
bool backtrace = false;
uintptr_t abort_address = 0;
@@ -319,17 +341,16 @@
// Now that we have the signal that kicked things off, attach all of the
// sibling threads, and then proceed.
- bool fatal_signal = signo != DEBUGGER_SIGNAL;
- std::set<pid_t> siblings;
std::set<pid_t> attached_siblings;
- if (fatal_signal || backtrace) {
+ {
+ std::set<pid_t> siblings;
if (!android::procinfo::GetProcessTids(target, &siblings)) {
PLOG(FATAL) << "failed to get process siblings";
}
siblings.erase(main_tid);
for (pid_t sibling_tid : siblings) {
- if (!ptrace_seize_thread(target, sibling_tid, &attach_error)) {
+ if (!ptrace_seize_thread(target_proc_fd, sibling_tid, &attach_error)) {
LOG(WARNING) << attach_error;
} else {
attached_siblings.insert(sibling_tid);
@@ -337,11 +358,18 @@
}
}
+ std::unique_ptr<BacktraceMap> backtrace_map(BacktraceMap::Create(main_tid));
+ if (!backtrace_map) {
+ LOG(FATAL) << "failed to create backtrace map";
+ }
+
+ // Drop our capabilities now that we've attached to the threads we care about.
+ drop_capabilities();
+
check_process(target_proc_fd, target);
// TODO: Use seccomp to lock ourselves down.
- std::unique_ptr<BacktraceMap> backtrace_map(BacktraceMap::Create(main_tid));
std::string amfd_data;
if (backtrace) {
diff --git a/debuggerd/handler/debuggerd_handler.cpp b/debuggerd/handler/debuggerd_handler.cpp
index 9469bbd..38a7be3 100644
--- a/debuggerd/handler/debuggerd_handler.cpp
+++ b/debuggerd/handler/debuggerd_handler.cpp
@@ -39,6 +39,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/capability.h>
#include <sys/mman.h>
#include <sys/prctl.h>
#include <sys/socket.h>
@@ -207,7 +208,7 @@
}
// Don't use fork(2) to avoid calling pthread_atfork handlers.
- int forkpid = clone(nullptr, nullptr, SIGCHLD, nullptr);
+ int forkpid = clone(nullptr, nullptr, 0, nullptr);
if (forkpid == -1) {
__libc_format_log(ANDROID_LOG_FATAL, "libc", "failed to fork in debuggerd signal handler: %s",
strerror(errno));
@@ -216,6 +217,11 @@
close(pipefds[0]);
close(pipefds[1]);
+ // Set all of the ambient capability bits we can, so that crash_dump can ptrace us.
+ for (unsigned long i = 0; prctl(PR_CAPBSET_READ, i, 0, 0, 0) != -1; ++i) {
+ prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, i, 0, 0);
+ }
+
char buf[10];
snprintf(buf, sizeof(buf), "%d", thread_info->crashing_tid);
execl(CRASH_DUMP_PATH, CRASH_DUMP_NAME, buf, nullptr);
@@ -242,10 +248,12 @@
close(pipefds[0]);
// Don't leave a zombie child.
- siginfo_t child_siginfo;
- if (TEMP_FAILURE_RETRY(waitid(P_PID, forkpid, &child_siginfo, WEXITED)) != 0) {
+ int status;
+ if (TEMP_FAILURE_RETRY(waitpid(forkpid, &status, __WCLONE)) == -1 && errno != ECHILD) {
__libc_format_log(ANDROID_LOG_FATAL, "libc", "failed to wait for crash_dump helper: %s",
strerror(errno));
+ } else if (WIFSTOPPED(status) || WIFSIGNALED(status)) {
+ __libc_format_log(ANDROID_LOG_FATAL, "libc", "crash_dump helper crashed or stopped");
thread_info->crash_dump_started = false;
}
}
diff --git a/libcutils/fs_config.c b/libcutils/fs_config.c
index 013999a..b701bba 100644
--- a/libcutils/fs_config.c
+++ b/libcutils/fs_config.c
@@ -177,11 +177,8 @@
CAP_MASK_LONG(CAP_SETPCAP),
"system/bin/webview_zygote64" },
- { 00755, AID_ROOT, AID_SHELL, CAP_MASK_LONG(CAP_SYS_PTRACE),
- "system/bin/crash_dump32" },
- { 00755, AID_ROOT, AID_SHELL, CAP_MASK_LONG(CAP_SYS_PTRACE),
- "system/bin/crash_dump64" },
-
+ { 00755, AID_ROOT, AID_SHELL, 0, "system/bin/crash_dump32" },
+ { 00755, AID_ROOT, AID_SHELL, 0, "system/bin/crash_dump64" },
{ 00755, AID_ROOT, AID_SHELL, 0, "system/bin/debuggerd" },
{ 00750, AID_ROOT, AID_ROOT, 0, "system/bin/uncrypt" },
{ 00750, AID_ROOT, AID_ROOT, 0, "system/bin/install-recovery.sh" },
diff --git a/liblog/logger.h b/liblog/logger.h
index 50d1cb4..d332c03 100644
--- a/liblog/logger.h
+++ b/liblog/logger.h
@@ -39,14 +39,16 @@
struct android_log_transport_write {
struct listnode node;
- const char *name;
- unsigned logMask; /* cache of available success */
+ const char *name; /* human name to describe the transport */
+ unsigned logMask; /* mask cache of available() success */
union android_log_context context; /* Initialized by static allocation */
- int (*available)(log_id_t logId);
- int (*open)();
- void (*close)();
- int (*write)(log_id_t logId, struct timespec *ts, struct iovec *vec, size_t nr);
+ int (*available)(log_id_t logId); /* Does not cause resources to be taken */
+ int (*open)(); /* can be called multiple times, reusing current resources */
+ void (*close)(); /* free up resources */
+ /* write log to transport, returns number of bytes propagated, or -errno */
+ int (*write)(log_id_t logId, struct timespec *ts,
+ struct iovec *vec, size_t nr);
};
struct android_log_logger_list;
@@ -55,22 +57,23 @@
struct android_log_transport_read {
struct listnode node;
- const char *name;
+ const char *name; /* human name to describe the transport */
+ /* Does not cause resources to be taken */
int (*available)(log_id_t logId);
int (*version)(struct android_log_logger *logger,
struct android_log_transport_context *transp);
+ /* Release resources taken by the following interfaces */
void (*close)(struct android_log_logger_list *logger_list,
struct android_log_transport_context *transp);
-
/*
- * Expect all to instantiate open on any call, so we do not have
- * an expicit open call
+ * Expect all to instantiate open automagically on any call,
+ * so we do not have an explicit open call.
*/
int (*read)(struct android_log_logger_list *logger_list,
struct android_log_transport_context *transp,
struct log_msg *log_msg);
- /* Assumption is only called if not ANDROID_LOG_NONBLOCK */
+ /* Must only be called if not ANDROID_LOG_NONBLOCK (blocking) */
int (*poll)(struct android_log_logger_list *logger_list,
struct android_log_transport_context *transp);
@@ -117,9 +120,9 @@
struct android_log_logger_list *parent;
struct android_log_transport_read *transport;
- unsigned logMask;
- int ret;
- struct log_msg logMsg; /* valid is logMsg.len != 0 */
+ unsigned logMask; /* mask of requested log buffers */
+ int ret; /* return value associated with following data */
+ struct log_msg logMsg; /* peek at upcoming data, valid if logMsg.len != 0 */
};
/* assumes caller has structures read-locked, single threaded, or fenced */
diff --git a/liblog/logger_write.c b/liblog/logger_write.c
index 1a2d506..2599a53 100644
--- a/liblog/logger_write.c
+++ b/liblog/logger_write.c
@@ -343,7 +343,7 @@
}
}
/* tag must be nul terminated */
- if (strnlen(tag, len) >= len) {
+ if (tag && strnlen(tag, len) >= len) {
tag = NULL;
}
@@ -514,6 +514,14 @@
strcpy(buf, "Unspecified assertion failed");
}
+ // Log assertion failures to stderr for the benefit of "adb shell" users
+ // and gtests (http://b/23675822).
+ struct iovec iov[2] = {
+ { buf, strlen(buf) },
+ { (char*) "\n", 1 },
+ };
+ TEMP_FAILURE_RETRY(writev(2, iov, 2));
+
__android_log_write(ANDROID_LOG_FATAL, tag, buf);
abort(); /* abort so we have a chance to debug the situation */
/* NOTREACHED */
diff --git a/liblog/pmsg_writer.c b/liblog/pmsg_writer.c
index c1c068e..5e4ff98 100644
--- a/liblog/pmsg_writer.c
+++ b/liblog/pmsg_writer.c
@@ -285,6 +285,7 @@
__android_log_unlock();
} else if (pmsgOpen() < 0) {
__android_log_unlock();
+ free(cp);
return -EBADF;
}
}
diff --git a/libnativeloader/native_loader.cpp b/libnativeloader/native_loader.cpp
index d7b5cb5..2f23c2c 100644
--- a/libnativeloader/native_loader.cpp
+++ b/libnativeloader/native_loader.cpp
@@ -246,7 +246,9 @@
// For now we rely on CTS test to catch things like this but
// it should probably be addressed in the future.
for (const auto& soname : sonames) {
- dlopen(soname.c_str(), RTLD_NOW | RTLD_NODELETE);
+ LOG_ALWAYS_FATAL_IF(dlopen(soname.c_str(), RTLD_NOW | RTLD_NODELETE) == nullptr,
+ "Error preloading public library %s: %s",
+ soname.c_str(), dlerror());
}
public_libraries_ = base::Join(sonames, ':');
diff --git a/libutils/tests/Vector_test.cpp b/libutils/tests/Vector_test.cpp
index 671200f..e074a92 100644
--- a/libutils/tests/Vector_test.cpp
+++ b/libutils/tests/Vector_test.cpp
@@ -74,12 +74,9 @@
EXPECT_EQ(other[3], 5);
}
-// TODO: gtest isn't capable of parsing Abort messages formatted by
-// Android (fails differently on host and target), so we always need to
-// use an empty error message for death tests.
TEST_F(VectorTest, SetCapacity_Overflow) {
Vector<int> vector;
- EXPECT_DEATH(vector.setCapacity(SIZE_MAX / sizeof(int) + 1), "");
+ EXPECT_DEATH(vector.setCapacity(SIZE_MAX / sizeof(int) + 1), "Assertion failed");
}
TEST_F(VectorTest, SetCapacity_ShrinkBelowSize) {
@@ -95,20 +92,13 @@
ASSERT_EQ(8U, vector.capacity());
}
-// NOTE: All of the tests below are useless because of the "TODO" above.
-// We have no way of knowing *why* the process crashed. Given that we're
-// inserting a NULL array, we'll fail with a SIGSEGV eventually. We need
-// the ability to make assertions on the abort message to make sure we're
-// failing for the right reasons.
TEST_F(VectorTest, _grow_OverflowSize) {
Vector<int> vector;
vector.add(1);
// Checks that the size calculation (not the capacity calculation) doesn't
// overflow : the size here will be (1 + SIZE_MAX).
- //
- // EXPECT_DEATH(vector.insertArrayAt(NULL, 0, SIZE_MAX), "new_size_overflow");
- EXPECT_DEATH(vector.insertArrayAt(NULL, 0, SIZE_MAX), "");
+ EXPECT_DEATH(vector.insertArrayAt(NULL, 0, SIZE_MAX), "new_size overflow");
}
TEST_F(VectorTest, _grow_OverflowCapacityDoubling) {
@@ -116,18 +106,14 @@
// This should fail because the calculated capacity will overflow even though
// the size of the vector doesn't.
- //
- // EXPECT_DEATH(vector.insertArrayAt(NULL, 0, (SIZE_MAX - 1)), "new_capacity_overflow");
- EXPECT_DEATH(vector.insertArrayAt(NULL, 0, (SIZE_MAX - 1)), "");
+ EXPECT_DEATH(vector.insertArrayAt(NULL, 0, (SIZE_MAX - 1)), "new_capacity overflow");
}
TEST_F(VectorTest, _grow_OverflowBufferAlloc) {
Vector<int> vector;
// This should fail because the capacity * sizeof(int) overflows, even
// though the capacity itself doesn't.
- //
- // EXPECT_DEATH(vector.insertArrayAt(NULL, 0, (SIZE_MAX / 2)), "new_alloc_size overflow");
- EXPECT_DEATH(vector.insertArrayAt(NULL, 0, (SIZE_MAX / 2)), "");
+ EXPECT_DEATH(vector.insertArrayAt(NULL, 0, (SIZE_MAX / 2)), "new_alloc_size overflow");
}
TEST_F(VectorTest, editArray_Shared) {