blob: de7248e06d606166704a6c9692503614ea92b955 [file] [log] [blame]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Note this file may be used for multiple guest integration test binaries. Do not add any logic
// to this file that is specific to any one test binary or suite.
#include <gtest/gtest.h>
#include "logger.h"
#include "src/lib/fxl/test/test_settings.h"
// This test event listener dumps the guest's serial logs when a test fails.
class LoggerOutputListener : public ::testing::EmptyTestEventListener {
void OnTestEnd(const ::testing::TestInfo& info) override {
if (!info.result()->Failed()) {
std::cout << "[----------] Begin guest output\n";
std::cout << Logger::Get().Buffer();
std::cout << "\n[----------] End guest output\n";
int main(int argc, char** argv) {
if (!fxl::SetTestSettings(argc, argv)) {
// Switch to line buffering of stdout/stderr, so that we don't lose
// log lines if a test hangs.
// TODO( Solve this globally for everyone, not just for this
// test suite.
std::setvbuf(stdout, nullptr, _IOLBF, BUFSIZ);
std::setvbuf(stderr, nullptr, _IOLBF, BUFSIZ);
LoggerOutputListener listener;
testing::InitGoogleTest(&argc, argv);
int status = RUN_ALL_TESTS();
return status;