blob: 18361a6f0838149c42a2ff44e99b6afdeebd93ea [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.
// This is a utility program for running integration tests by hand.
#include <stdlib.h>
#include <iostream>
#include <lib/async-loop/cpp/loop.h>
#include <lib/component/cpp/startup_context.h>
#include <lib/fxl/command_line.h>
#include <lib/fxl/log_settings_command_line.h>
#include <lib/fxl/logging.h>
#include "garnet/bin/trace/tests/run_test.h"
// Note: /data is no longer large enough in qemu sessions
const char kOutputFilePath[] = "/tmp/test.trace";
const char kUsageString[] = {
"Usage: run "
"fuchsia-pkg://fuchsia.com/trace_tests#meta/run_integration_test.cmx\n"
" [options] /pkg/data/<test>.tspec\n"
"\n"
"Options:\n"
" --quiet[=LEVEL] set quietness level (opposite of verbose)\n"
" --verbose[=LEVEL] set debug verbosity level\n"
" --log-file=FILE write log output to FILE\n"};
static void PrintUsageString() { std::cout << kUsageString << std::endl; }
int main(int argc, char *argv[]) {
auto cl = fxl::CommandLineFromArgcArgv(argc, argv);
if (!fxl::SetLogSettingsFromCommandLine(cl))
return EXIT_FAILURE;
if (cl.HasOption("help", nullptr)) {
PrintUsageString();
return EXIT_SUCCESS;
}
auto args = cl.positional_args();
if (args.size() != 1) {
FXL_LOG(ERROR) << "Missing tspec file";
return EXIT_FAILURE;
}
auto tspec_path = args[0];
if (!RunTspec(tspec_path, kOutputFilePath)) {
return EXIT_FAILURE;
}
// |CreateFromStartupInfo()| needs a loop, it uses the default dispatcher.
std::unique_ptr<component::StartupContext> context;
{
async::Loop loop(&kAsyncLoopConfigAttachToThread);
context = component::StartupContext::CreateFromStartupInfo();
FXL_DCHECK(context);
}
if (!VerifyTspec(context.get(), tspec_path, kOutputFilePath)) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}