blob: d5bed50016684668085b2de61172d9511719e04b [file] [log] [blame]
// Copyright 2019 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.
#include <lib/driver-unit-test/logger.h>
#include <lib/driver-unit-test/utils.h>
#include <lib/fit/defer.h>
#include <zxtest/zxtest.h>
namespace {
zx_device_t* parent_device = nullptr;
} // namespace
namespace driver_unit_test {
void SetParent(zx_device_t* parent) { parent_device = parent; }
zx_device_t* GetParent() { return parent_device; }
bool RunZxTests(const char* name, zx_device_t* parent, zx_handle_t handle) {
zx::channel channel(handle);
SetParent(parent);
auto cleanup = fit::defer([]() {
SetParent(nullptr);
Logger::DeleteInstance();
});
if (channel) {
zx_status_t status = Logger::CreateInstance(std::move(channel));
if (status == ZX_OK) {
zxtest::Runner::GetInstance()->AddObserver(driver_unit_test::Logger::GetInstance());
}
}
const int kArgc = 1;
const char* argv[kArgc] = {name};
return RUN_ALL_TESTS(kArgc, const_cast<char**>(argv)) == 0;
}
} // namespace driver_unit_test