blob: 9107d1d3a7c5478cdac7fe59319cede5e04ec285 [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 shared library contains a self-contained trace-provider.
// That is libtrace-engine.so is contained within our library using
// libtrace-engine-static.a.
#include "garnet/bin/trace/tests/self_contained_provider.h"
#include <assert.h>
#include <lib/async-loop/cpp/loop.h>
#include <lib/async-loop/default.h>
#include <lib/syslog/cpp/macros.h>
#include <lib/trace-provider/provider.h>
#include <lib/trace/event.h>
#include <memory>
#include "garnet/bin/trace/tests/integration_test_utils.h"
namespace tracing {
namespace test {
static const char kName[] = "self-contained-provider";
static int SelfContainedProviderThread(void* arg) {
async::Loop loop(&kAsyncLoopConfigNoAttachToCurrentThread);
std::unique_ptr<trace::TraceProvider> provider;
if (!CreateProviderSynchronouslyAndWait(loop, kName, &provider)) {
return false;
}
WriteTestEvents(kNumSimpleTestEvents);
loop.RunUntilIdle();
return 0;
}
__EXPORT bool StartSelfContainedProvider(thrd_t* out_thread) {
if (thrd_create_with_name(out_thread, SelfContainedProviderThread, nullptr, kName) !=
thrd_success) {
FX_LOGS(ERROR) << "Error creating " << kName << " thread";
return false;
}
return true;
}
} // namespace test
} // namespace tracing