1// Copyright 2018 The Fuchsia Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef ZIRCON_SYSTEM_ULIB_RUNTESTS_UTILS_INCLUDE_RUNTESTS_UTILS_FUCHSIA_RUN_TEST_H_ 6#define ZIRCON_SYSTEM_ULIB_RUNTESTS_UTILS_INCLUDE_RUNTESTS_UTILS_FUCHSIA_RUN_TEST_H_ 7 8#include <stdio.h> 9 10#include <fbl/string.h> 11#include <fbl/unique_ptr.h> 12#include <runtests-utils/runtests-utils.h> 13 14namespace runtests { 15 16// If tests are in this path, they can run as a component if corresponding cmx 17// file is present. 18// 19// https://fuchsia.googlesource.com/docs/+/master/the-book/package_metadata.md#component-manifest 20constexpr char kPkgPrefix[] = "/pkgfs/packages/"; 21 22// If |path| starts with |kPkgPrefix|, this function will generate corresponding 23// cmx file path and component url. 24// 25// if test binary path is: /pkgfs/packages/my_tests/0/test/test_binary, the cmx path 26// would be: /pkgfs/packages/my_tests/0/meta/test_binary.cmx 27// 28// component_url for above path would be: 29// fuchsia-pkg://fuchsia.com/my_tests#meta/test_binary.cmx 30// 31// Code which uses this url: 32// https://fuchsia.googlesource.com/garnet/+/master/bin/appmgr/root_loader.cc 33// 34void TestFileComponentInfo(const fbl::String path, 35 fbl::String* component_url_out, 36 fbl::String* cmx_file_path_out); 37 38// Invokes a Fuchsia test binary and writes its output to a file. 39// 40// |argv| is a null-terminated array of argument strings passed to the test 41// program. 42// |output_filename| is the name of the file to which the test binary's output 43// will be written. May be nullptr, in which case the output will not be 44// redirected. 45fbl::unique_ptr<Result> FuchsiaRunTest(const char* argv[], 46 const char* output_dir, 47 const char* output_filename); 48 49} // namespace runtests 50 51#endif // ZIRCON_SYSTEM_ULIB_RUNTESTS_UTILS_INCLUDE_RUNTESTS_UTILS_FUCHSIA_RUN_TEST_H_ 52