/* * Copyright (C) 2024 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_redaction/redact_sched_events.h" #include "test/gtest_and_gmock.h" #include "protos/perfetto/trace/ftrace/ftrace_event.gen.h" #include "protos/perfetto/trace/ftrace/ftrace_event_bundle.gen.h" #include "protos/perfetto/trace/ftrace/sched.gen.h" #include "protos/perfetto/trace/trace.gen.h" #include "protos/perfetto/trace/trace_packet.gen.h" namespace perfetto::trace_redaction { namespace { constexpr int32_t kPackageUid = …; } // namespace class FilterSchedWakingEventsTest : public testing::Test { … }; TEST_F(FilterSchedWakingEventsTest, ReturnsErrorForNullPacket) { … } TEST_F(FilterSchedWakingEventsTest, ReturnsErrorForEmptyPacket) { … } TEST_F(FilterSchedWakingEventsTest, ReturnsErrorForNoTimeline) { … } TEST_F(FilterSchedWakingEventsTest, ReturnsErrorForMissingPackage) { … } // Assume that the traces has a series of events like the events below. All // constants will come from these packets: // // event { // timestamp: 6702093757720043 // pid: 0 // sched_switch { // prev_comm: "swapper/0" // prev_pid: 0 // prev_prio: 120 // prev_state: 0 // next_comm: "Job.worker 5" // next_pid: 7147 // next_prio: 120 // } // } // event { // timestamp: 6702093757727075 // pid: 7147 <- This pid woke up... // sched_waking { // comm: "Job.worker 6" // pid: 7148 <- ... this pid // prio: 120 // success: 1 // target_cpu: 6 // } // } // // The waking event is configured to be retained (see // KeepsWakingWhenBothPidsConnectToPackage for more information on how). Because // this transform only affects waking events, the sched switch event should be // retain. TEST_F(FilterSchedWakingEventsTest, RetainsNonWakingEvents) { … } // When the wake target's pid is connected to the target package, the event // should be present after redaction. TEST_F(FilterSchedWakingEventsTest, KeepsIncludedWakeEvents) { … } // When the wake target's pid is NOT connected to the target package, the event // should NOT be present after redaction. TEST_F(FilterSchedWakingEventsTest, DropsExcludedWakeEvents) { … } } // namespace perfetto::trace_redaction