chromium/third_party/perfetto/src/trace_processor/importers/proto/proto_trace_parser_impl_unittest.cc

/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "src/trace_processor/importers/proto/proto_trace_parser_impl.h"

#include <cmath>
#include <cstdint>
#include <cstring>
#include <functional>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>

#include "perfetto/base/status.h"
#include "perfetto/ext/base/string_view.h"
#include "perfetto/protozero/scattered_heap_buffer.h"
#include "perfetto/trace_processor/basic_types.h"
#include "perfetto/trace_processor/trace_blob.h"
#include "perfetto/trace_processor/trace_blob_view.h"
#include "src/trace_processor/db/column/types.h"
#include "src/trace_processor/importers/common/args_tracker.h"
#include "src/trace_processor/importers/common/args_translation_table.h"
#include "src/trace_processor/importers/common/clock_tracker.h"
#include "src/trace_processor/importers/common/cpu_tracker.h"
#include "src/trace_processor/importers/common/event_tracker.h"
#include "src/trace_processor/importers/common/flow_tracker.h"
#include "src/trace_processor/importers/common/global_args_tracker.h"
#include "src/trace_processor/importers/common/machine_tracker.h"
#include "src/trace_processor/importers/common/mapping_tracker.h"
#include "src/trace_processor/importers/common/metadata_tracker.h"
#include "src/trace_processor/importers/common/process_track_translation_table.h"
#include "src/trace_processor/importers/common/process_tracker.h"
#include "src/trace_processor/importers/common/slice_tracker.h"
#include "src/trace_processor/importers/common/slice_translation_table.h"
#include "src/trace_processor/importers/common/stack_profile_tracker.h"
#include "src/trace_processor/importers/common/track_tracker.h"
#include "src/trace_processor/importers/ftrace/ftrace_sched_event_tracker.h"
#include "src/trace_processor/importers/proto/additional_modules.h"
#include "src/trace_processor/importers/proto/default_modules.h"
#include "src/trace_processor/importers/proto/proto_trace_reader.h"
#include "src/trace_processor/sorter/trace_sorter.h"
#include "src/trace_processor/storage/metadata.h"
#include "src/trace_processor/storage/stats.h"
#include "src/trace_processor/storage/trace_storage.h"
#include "src/trace_processor/tables/metadata_tables_py.h"
#include "src/trace_processor/types/variadic.h"
#include "src/trace_processor/util/descriptors.h"
#include "test/gtest_and_gmock.h"

#include "protos/perfetto/common/builtin_clock.pbzero.h"
#include "protos/perfetto/common/sys_stats_counters.pbzero.h"
#include "protos/perfetto/config/trace_config.pbzero.h"
#include "protos/perfetto/trace/android/packages_list.pbzero.h"
#include "protos/perfetto/trace/chrome/chrome_benchmark_metadata.pbzero.h"
#include "protos/perfetto/trace/chrome/chrome_trace_event.pbzero.h"
#include "protos/perfetto/trace/clock_snapshot.pbzero.h"
#include "protos/perfetto/trace/ftrace/ftrace.pbzero.h"
#include "protos/perfetto/trace/ftrace/ftrace_event.pbzero.h"
#include "protos/perfetto/trace/ftrace/ftrace_event_bundle.pbzero.h"
#include "protos/perfetto/trace/ftrace/generic.pbzero.h"
#include "protos/perfetto/trace/ftrace/power.pbzero.h"
#include "protos/perfetto/trace/ftrace/sched.pbzero.h"
#include "protos/perfetto/trace/ftrace/task.pbzero.h"
#include "protos/perfetto/trace/interned_data/interned_data.pbzero.h"
#include "protos/perfetto/trace/profiling/profile_common.pbzero.h"
#include "protos/perfetto/trace/profiling/profile_packet.pbzero.h"
#include "protos/perfetto/trace/ps/process_tree.pbzero.h"
#include "protos/perfetto/trace/sys_stats/sys_stats.pbzero.h"
#include "protos/perfetto/trace/trace.pbzero.h"
#include "protos/perfetto/trace/trace_packet.pbzero.h"
#include "protos/perfetto/trace/trace_uuid.pbzero.h"
#include "protos/perfetto/trace/track_event/chrome_thread_descriptor.pbzero.h"
#include "protos/perfetto/trace/track_event/counter_descriptor.pbzero.h"
#include "protos/perfetto/trace/track_event/debug_annotation.pbzero.h"
#include "protos/perfetto/trace/track_event/log_message.pbzero.h"
#include "protos/perfetto/trace/track_event/process_descriptor.pbzero.h"
#include "protos/perfetto/trace/track_event/source_location.pbzero.h"
#include "protos/perfetto/trace/track_event/task_execution.pbzero.h"
#include "protos/perfetto/trace/track_event/thread_descriptor.pbzero.h"
#include "protos/perfetto/trace/track_event/track_descriptor.pbzero.h"
#include "protos/perfetto/trace/track_event/track_event.pbzero.h"

namespace perfetto::trace_processor {
namespace {

make_pair;
_;
Args;
AtLeast;
DoAll;
ElementsAreArray;
Eq;
HasSubstr;
IgnoreResult;
InSequence;
Invoke;
InvokeArgument;
NiceMock;
Pointwise;
Return;
ReturnRef;
UnorderedElementsAreArray;

namespace {
MATCHER_P(DoubleEq, exp, "Double matcher that satisfies -Wfloat-equal") {}
}  // namespace

class MockSchedEventTracker : public FtraceSchedEventTracker {};

class MockEventTracker : public EventTracker {};

class MockProcessTracker : public ProcessTracker {};

class MockBoundInserter : public ArgsTracker::BoundInserter {};

class MockSliceTracker : public SliceTracker {};

class ProtoTraceParserTest : public ::testing::Test {};

// TODO(eseckler): Refactor these into a new file for ftrace tests.

TEST_F(ProtoTraceParserTest, LoadSingleEvent) {}

TEST_F(ProtoTraceParserTest, LoadEventsIntoRaw) {}

TEST_F(ProtoTraceParserTest, LoadGenericFtrace) {}

TEST_F(ProtoTraceParserTest, LoadMultipleEvents) {}

TEST_F(ProtoTraceParserTest, LoadMultiplePackets) {}

TEST_F(ProtoTraceParserTest, RepeatedLoadSinglePacket) {}

TEST_F(ProtoTraceParserTest, LoadCpuFreq) {}

TEST_F(ProtoTraceParserTest, LoadCpuFreqKHz) {}

TEST_F(ProtoTraceParserTest, LoadCpuIdleStats) {}

TEST_F(ProtoTraceParserTest, LoadMemInfo) {}

TEST_F(ProtoTraceParserTest, LoadVmStats) {}

TEST_F(ProtoTraceParserTest, LoadThermal) {}

TEST_F(ProtoTraceParserTest, LoadProcessPacket) {}

TEST_F(ProtoTraceParserTest, LoadProcessPacket_FirstCmdline) {}

TEST_F(ProtoTraceParserTest, LoadThreadPacket) {}

TEST_F(ProtoTraceParserTest, ProcessNameFromProcessDescriptor) {}

TEST_F(ProtoTraceParserTest, ThreadNameFromThreadDescriptor) {}

TEST_F(ProtoTraceParserTest, TrackEventWithoutInternedData) {}

TEST_F(ProtoTraceParserTest, TrackEventWithoutInternedDataWithTypes) {}

TEST_F(ProtoTraceParserTest, TrackEventWithInternedData) {}

TEST_F(ProtoTraceParserTest, TrackEventAsyncEvents) {}

// TODO(eseckler): Also test instant events on separate tracks.
TEST_F(ProtoTraceParserTest, TrackEventWithTrackDescriptors) {}

TEST_F(ProtoTraceParserTest, TrackEventWithResortedCounterDescriptor) {}

TEST_F(ProtoTraceParserTest, TrackEventWithoutIncrementalStateReset) {}

TEST_F(ProtoTraceParserTest, TrackEventWithoutThreadDescriptor) {}

TEST_F(ProtoTraceParserTest, TrackEventWithDataLoss) {}

TEST_F(ProtoTraceParserTest, TrackEventMultipleSequences) {}

TEST_F(ProtoTraceParserTest, TrackEventWithDebugAnnotations) {}

TEST_F(ProtoTraceParserTest, TrackEventWithTaskExecution) {}

TEST_F(ProtoTraceParserTest, TrackEventWithLogMessage) {}

TEST_F(ProtoTraceParserTest, TrackEventParseLegacyEventIntoRawTable) {}

TEST_F(ProtoTraceParserTest, TrackEventLegacyTimestampsWithClockSnapshot) {}

TEST_F(ProtoTraceParserTest, ParseEventWithClockIdButWithoutClockSnapshot) {}

TEST_F(ProtoTraceParserTest, ParseChromeMetadataEventIntoRawTable) {}

TEST_F(ProtoTraceParserTest, ParseChromeLegacyFtraceIntoRawTable) {}

TEST_F(ProtoTraceParserTest, ParseChromeLegacyJsonIntoRawTable) {}

TEST_F(ProtoTraceParserTest, LoadChromeBenchmarkMetadata) {}

TEST_F(ProtoTraceParserTest, LoadChromeMetadata) {}

TEST_F(ProtoTraceParserTest, AndroidPackagesList) {}

TEST_F(ProtoTraceParserTest, AndroidPackagesListDuplicate) {}

TEST_F(ProtoTraceParserTest, ParseCPUProfileSamplesIntoTable) {}

TEST_F(ProtoTraceParserTest, CPUProfileSamplesTimestampsAreClockMonotonic) {}

TEST_F(ProtoTraceParserTest, ConfigUuid) {}

TEST_F(ProtoTraceParserTest, PacketUuid) {}

// If both the TraceConfig and TracePacket.trace_uuid are present, the latter
// is considered the source of truth.
TEST_F(ProtoTraceParserTest, PacketAndConfigUuid) {}

TEST_F(ProtoTraceParserTest, ConfigPbtxt) {}

}  // namespace
}  // namespace perfetto::trace_processor