chromium/third_party/perfetto/src/trace_redaction/redact_process_events_unittest.cc

/*
 * 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_process_events.h"
#include "src/base/test/status_matchers.h"
#include "test/gtest_and_gmock.h"

#include "protos/perfetto/trace/ftrace/ftrace.gen.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/power.gen.h"
#include "protos/perfetto/trace/ftrace/sched.gen.h"
#include "protos/perfetto/trace/ftrace/task.gen.h"
#include "protos/perfetto/trace/trace.gen.h"
#include "protos/perfetto/trace/trace_packet.gen.h"

namespace perfetto::trace_redaction {

namespace {
constexpr uint64_t kCpu =;

constexpr uint64_t kUidA =;
constexpr uint64_t kUidB =;

constexpr int32_t kNoParent =;
constexpr int32_t kPidA =;
constexpr int32_t kPidB =;

// Used as a child of kPidA.
constexpr int32_t kPidAA =;

constexpr uint64_t kTimeA =;
constexpr uint64_t kTimeB =;

constexpr std::string_view kCommA =;
constexpr std::string_view kCommB =;
}  // namespace

class RedactProcessEventsTest : public testing::Test {};

TEST_F(RedactProcessEventsTest, RejectMissingPackageUid) {}

TEST_F(RedactProcessEventsTest, RejectMissingTimeline) {}

TEST_F(RedactProcessEventsTest, RejectMissingPacket) {}

TEST_F(RedactProcessEventsTest, EmptyMissingPacket) {}

// Tests which nested messages and fields are removed.
class RedactNewTaskTest : public testing::Test {};

TEST_F(RedactNewTaskTest, KeepCommInPackage) {}

TEST_F(RedactNewTaskTest, ClearCommOutsidePackage) {}

TEST_F(RedactNewTaskTest, KeepTaskInPackage) {}

TEST_F(RedactNewTaskTest, DropTaskOutsidePackage) {}

class RedactProcessFree : public testing::Test {};

TEST_F(RedactProcessFree, KeepsCommInPackage) {}

TEST_F(RedactProcessFree, DropsCommOutsidePackage) {}

TEST_F(RedactProcessFree, KeepsCommAtProcessFree) {}

TEST_F(RedactProcessFree, KeepTaskInPackage) {}

TEST_F(RedactProcessFree, DropTaskOutsidePackage) {}

class RedactRenameTest : public testing::Test {};

TEST_F(RedactRenameTest, KeepCommInsidePackage) {}

TEST_F(RedactRenameTest, ClearCommOutsidePackage) {}

TEST_F(RedactRenameTest, KeepTaskInsidePackage) {}

TEST_F(RedactRenameTest, DropTaskOutsidePackage) {}

class RedactPrintTest : public testing::Test {};

TEST_F(RedactPrintTest, KeepTaskInsidePackage) {}

TEST_F(RedactPrintTest, DropTaskOutsidePackage) {}

class RedactSuspendResumeTest : public testing::Test {};

TEST_F(RedactSuspendResumeTest, KeepTaskInsidePackage) {}

// Only actions in the allowlist should be allowed.
//
// TODO(vaage): The allowlist is not configurable right now. If moved into the
// context, it could be configured.
TEST_F(RedactSuspendResumeTest, FiltersByAllowlist) {}

TEST_F(RedactSuspendResumeTest, DropTaskOutsidePackage) {}

class RedactSchedBlockReasonTest : public testing::Test {};

// Implementation detail: No events are removed, only inner messages.
TEST_F(RedactSchedBlockReasonTest, KeepTaskInsidePackage) {}

// Implementation detail: No events are removed, only inner messages.
TEST_F(RedactSchedBlockReasonTest, DropTaskOutsidePackage) {}

}  // namespace perfetto::trace_redaction