Reland "Reland "[test] Move tracing cctest to unittests""
This is a reland of commit3b251debfb
Annotates the perfetto proto include with nogncheck, because gn's header checker doesn't understand preprocessor directives. See https://gn.googlesource.com/gn/+/main/docs/reference.md#advice-on-fixing-problems Original change's description: > Reland "[test] Move tracing cctest to unittests" > > This is a reland ofa7d6bf9662
> > Added perfetto to unittests include_rules. > > Bug: v8:12781 > Change-Id: Iabf0e62abb1de879de21ba06fbd38f5432ee4f76 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3652295 > Reviewed-by: Michael Lippautz <mlippautz@chromium.org> > Commit-Queue: Leszek Swirski <leszeks@chromium.org> > Cr-Commit-Position: refs/heads/main@{#80847} Bug: v8:12781 Change-Id: I886df9254d8fecd56f64110f04b1447937605b58 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3680299 Commit-Queue: Camillo Bruni <cbruni@chromium.org> Commit-Queue: Leszek Swirski <leszeks@chromium.org> Auto-Submit: Leszek Swirski <leszeks@chromium.org> Reviewed-by: Camillo Bruni <cbruni@chromium.org> Cr-Commit-Position: refs/heads/main@{#80866}
This commit is contained in:
parent
d5d3ecaeea
commit
f215daa819
@ -159,7 +159,6 @@ v8_source_set("cctest_sources") {
|
||||
"interpreter/test-interpreter-intrinsics.cc",
|
||||
"interpreter/test-interpreter.cc",
|
||||
"interpreter/test-source-positions.cc",
|
||||
"libplatform/test-tracing.cc",
|
||||
"manually-externalized-buffer.h",
|
||||
"parsing/test-preparser.cc",
|
||||
"print-extension.cc",
|
||||
|
@ -1,3 +0,0 @@
|
||||
include_rules = [
|
||||
"+protos/perfetto",
|
||||
]
|
@ -389,6 +389,7 @@ v8_source_set("unittests_sources") {
|
||||
"libplatform/default-worker-threads-task-runner-unittest.cc",
|
||||
"libplatform/single-threaded-default-platform-unittest.cc",
|
||||
"libplatform/task-queue-unittest.cc",
|
||||
"libplatform/tracing-unittest.cc",
|
||||
"libplatform/worker-thread-unittest.cc",
|
||||
"libsampler/sampler-unittest.cc",
|
||||
"libsampler/signals-and-mutexes-unittest.cc",
|
||||
|
@ -1,4 +1,6 @@
|
||||
include_rules = [
|
||||
"+perfetto",
|
||||
"+protos/perfetto",
|
||||
"+src",
|
||||
"+testing"
|
||||
]
|
||||
|
6
test/unittests/libplatform/DEPS
Normal file
6
test/unittests/libplatform/DEPS
Normal file
@ -0,0 +1,6 @@
|
||||
specific_include_rules = {
|
||||
"tracing-unittest\.cc": [
|
||||
"+perfetto/tracing.h",
|
||||
"+protos/perfetto"
|
||||
],
|
||||
}
|
@ -7,11 +7,12 @@
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/libplatform/default-platform.h"
|
||||
#include "src/tracing/trace-event.h"
|
||||
#include "test/cctest/cctest.h"
|
||||
#include "test/unittests/test-utils.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
#ifdef V8_USE_PERFETTO
|
||||
#include "perfetto/tracing.h"
|
||||
#include "protos/perfetto/trace/trace.pb.h"
|
||||
#include "protos/perfetto/trace/trace.pb.h" // nogncheck
|
||||
#include "src/libplatform/tracing/trace-event-listener.h"
|
||||
#include "src/tracing/traced-value.h"
|
||||
#endif // V8_USE_PERFETTO
|
||||
@ -20,8 +21,9 @@ namespace v8 {
|
||||
namespace platform {
|
||||
namespace tracing {
|
||||
|
||||
TEST(TestTraceConfig) {
|
||||
LocalContext env;
|
||||
class PlatformTracingTest : public TestWithPlatform {};
|
||||
|
||||
TEST_F(PlatformTracingTest, TestTraceConfig) {
|
||||
TraceConfig* trace_config = new TraceConfig();
|
||||
trace_config->AddIncludedCategory("v8");
|
||||
trace_config->AddIncludedCategory(TRACE_DISABLED_BY_DEFAULT("v8.runtime"));
|
||||
@ -44,7 +46,7 @@ TEST(TestTraceConfig) {
|
||||
|
||||
// Perfetto doesn't use TraceObject.
|
||||
#if !defined(V8_USE_PERFETTO)
|
||||
TEST(TestTraceObject) {
|
||||
TEST_F(PlatformTracingTest, TestTraceObject) {
|
||||
TraceObject trace_object;
|
||||
uint8_t category_enabled_flag = 41;
|
||||
trace_object.Initialize('X', &category_enabled_flag, "Test.Trace",
|
||||
@ -91,7 +93,7 @@ class MockTraceWriter : public TraceWriter {
|
||||
|
||||
// Perfetto doesn't use the ring buffer.
|
||||
#if !defined(V8_USE_PERFETTO)
|
||||
TEST(TestTraceBufferRingBuffer) {
|
||||
TEST_F(PlatformTracingTest, TestTraceBufferRingBuffer) {
|
||||
// We should be able to add kChunkSize * 2 + 1 trace events.
|
||||
const int HANDLES_COUNT = TraceBufferChunk::kChunkSize * 2 + 1;
|
||||
MockTraceWriter* writer = new MockTraceWriter();
|
||||
@ -177,7 +179,7 @@ void PopulateJSONWriter(TraceWriter* writer) {
|
||||
i::V8::SetPlatformForTesting(old_platform);
|
||||
}
|
||||
|
||||
TEST(TestJSONTraceWriter) {
|
||||
TEST_F(PlatformTracingTest, TestJSONTraceWriter) {
|
||||
std::ostringstream stream;
|
||||
TraceWriter* writer = TraceWriter::CreateJSONTraceWriter(stream);
|
||||
PopulateJSONWriter(writer);
|
||||
@ -193,7 +195,7 @@ TEST(TestJSONTraceWriter) {
|
||||
CHECK_EQ(expected_trace_str, trace_str);
|
||||
}
|
||||
|
||||
TEST(TestJSONTraceWriterWithCustomtag) {
|
||||
TEST_F(PlatformTracingTest, TestJSONTraceWriterWithCustomtag) {
|
||||
std::ostringstream stream;
|
||||
TraceWriter* writer = TraceWriter::CreateJSONTraceWriter(stream, "customTag");
|
||||
PopulateJSONWriter(writer);
|
||||
@ -226,7 +228,7 @@ void GetJSONStrings(std::vector<std::string>* ret, const std::string& str,
|
||||
|
||||
// With Perfetto the tracing controller doesn't observe events.
|
||||
#if !defined(V8_USE_PERFETTO)
|
||||
TEST(TestTracingController) {
|
||||
TEST_F(PlatformTracingTest, TestTracingController) {
|
||||
v8::Platform* old_platform = i::V8::GetCurrentPlatform();
|
||||
std::unique_ptr<v8::Platform> default_platform(
|
||||
v8::platform::NewDefaultPlatform());
|
||||
@ -258,7 +260,7 @@ TEST(TestTracingController) {
|
||||
i::V8::SetPlatformForTesting(old_platform);
|
||||
}
|
||||
|
||||
TEST(TestTracingControllerMultipleArgsAndCopy) {
|
||||
TEST_F(PlatformTracingTest, TestTracingControllerMultipleArgsAndCopy) {
|
||||
std::ostringstream stream, perfetto_stream;
|
||||
uint64_t aa = 11;
|
||||
unsigned int bb = 22;
|
||||
@ -400,7 +402,7 @@ class TraceStateObserverImpl : public TracingController::TraceStateObserver {
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(TracingObservers) {
|
||||
TEST_F(PlatformTracingTest, TracingObservers) {
|
||||
v8::Platform* old_platform = i::V8::GetCurrentPlatform();
|
||||
std::unique_ptr<v8::Platform> default_platform(
|
||||
v8::platform::NewDefaultPlatform());
|
||||
@ -495,7 +497,7 @@ class TraceWritingThread : public base::Thread {
|
||||
v8::platform::tracing::TracingController* tracing_controller_;
|
||||
};
|
||||
|
||||
TEST(AddTraceEventMultiThreaded) {
|
||||
TEST_F(PlatformTracingTest, AddTraceEventMultiThreaded) {
|
||||
v8::Platform* old_platform = i::V8::GetCurrentPlatform();
|
||||
std::unique_ptr<v8::Platform> default_platform(
|
||||
v8::platform::NewDefaultPlatform());
|
||||
@ -677,7 +679,7 @@ class TracingTestHarness {
|
||||
std::ostringstream perfetto_json_stream_;
|
||||
};
|
||||
|
||||
TEST(Perfetto) {
|
||||
TEST_F(PlatformTracingTest, Perfetto) {
|
||||
TracingTestHarness harness;
|
||||
harness.StartTracing();
|
||||
|
||||
@ -704,7 +706,7 @@ TEST(Perfetto) {
|
||||
}
|
||||
|
||||
// Replacement for 'TestTracingController'
|
||||
TEST(Categories) {
|
||||
TEST_F(PlatformTracingTest, Categories) {
|
||||
TracingTestHarness harness;
|
||||
harness.StartTracing();
|
||||
|
||||
@ -725,7 +727,7 @@ TEST(Categories) {
|
||||
}
|
||||
|
||||
// Replacement for 'TestTracingControllerMultipleArgsAndCopy'
|
||||
TEST(MultipleArgsAndCopy) {
|
||||
TEST_F(PlatformTracingTest, MultipleArgsAndCopy) {
|
||||
uint64_t aa = 11;
|
||||
unsigned int bb = 22;
|
||||
uint16_t cc = 33;
|
||||
@ -834,7 +836,7 @@ TEST(MultipleArgsAndCopy) {
|
||||
for (size_t i = 0; i < 20; i++) CHECK_EQ("E:.", harness.get_event(24 + i));
|
||||
}
|
||||
|
||||
TEST(JsonIntegrationTest) {
|
||||
TEST_F(PlatformTracingTest, JsonIntegrationTest) {
|
||||
// Check that tricky values are rendered correctly in the JSON output.
|
||||
double big_num = 1e100;
|
||||
double nan_num = std::numeric_limits<double>::quiet_NaN();
|
Loading…
Reference in New Issue
Block a user