Skip to content

Commit

Permalink
APK-based unittests
Browse files Browse the repository at this point in the history
Rather than chromium's LOG(ERROR) uses directly __android_log_write
for the gtest printer.
Cleans up the log and make it simpler to spot real errors.

BUG=
TEST=


Review URL: https://chromiumcodereview.appspot.com/10579040

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144428 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
bulach@chromium.org committed Jun 27, 2012
1 parent 6132fdc commit 4b59931
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions testing/android/native_test_launcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ extern int main(int argc, char** argv);

namespace {

void log_write(int level, const char* msg) {
__android_log_write(level, "chromium", msg);
}

// The list of signals which are considered to be crashes.
const int kExceptionSignals[] = {
SIGSEGV, SIGABRT, SIGFPE, SIGILL, SIGBUS, -1
Expand All @@ -46,7 +50,7 @@ struct sigaction g_old_sa[NSIG];
void SignalHandler(int sig, siginfo_t *info, void *reserved)
{
// Output the crash marker.
__android_log_write(ANDROID_LOG_ERROR, "chromium", "[ CRASHED ]");
log_write(ANDROID_LOG_ERROR, "[ CRASHED ]");
g_old_sa[sig].sa_sigaction(sig, info, reserved);
}

Expand Down Expand Up @@ -125,13 +129,13 @@ void AndroidLogPrinter::OnTestProgramStart(
const ::testing::UnitTest& unit_test) {
std::string msg = StringPrintf("[ START ] %d",
unit_test.test_to_run_count());
LOG(ERROR) << msg;
log_write(ANDROID_LOG_VERBOSE, msg.c_str());
}

void AndroidLogPrinter::OnTestStart(const ::testing::TestInfo& test_info) {
std::string msg = StringPrintf("[ RUN ] %s.%s",
test_info.test_case_name(), test_info.name());
LOG(ERROR) << msg;
log_write(ANDROID_LOG_VERBOSE, msg.c_str());
}

void AndroidLogPrinter::OnTestPartResult(
Expand All @@ -142,21 +146,21 @@ void AndroidLogPrinter::OnTestPartResult(
test_part_result.file_name(),
test_part_result.line_number(),
test_part_result.summary());
LOG(ERROR) << msg;
log_write(ANDROID_LOG_VERBOSE, msg.c_str());
}

void AndroidLogPrinter::OnTestEnd(const ::testing::TestInfo& test_info) {
std::string msg = StringPrintf("%s %s.%s",
test_info.result()->Failed() ? "[ FAILED ]" : "[ OK ]",
test_info.test_case_name(), test_info.name());
LOG(ERROR) << msg;
log_write(ANDROID_LOG_VERBOSE, msg.c_str());
}

void AndroidLogPrinter::OnTestProgramEnd(
const ::testing::UnitTest& unit_test) {
std::string msg = StringPrintf("[ END ] %d",
unit_test.successful_test_count());
LOG(ERROR) << msg;
log_write(ANDROID_LOG_VERBOSE, msg.c_str());
}

} // namespace
Expand Down

0 comments on commit 4b59931

Please sign in to comment.