chromium/third_party/perfetto/src/trace_redaction/prune_package_list_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 <cstdint>
#include <memory>
#include <string>

#include "src/trace_redaction/prune_package_list.h"
#include "test/gtest_and_gmock.h"

#include "protos/perfetto/trace/android/packages_list.gen.h"
#include "protos/perfetto/trace/ps/process_tree.gen.h"
#include "protos/perfetto/trace/trace_packet.gen.h"

namespace perfetto::trace_redaction {

namespace {
using PackageList = protos::gen::PackagesList;
using TracePacket = protos::gen::TracePacket;
using ProcessTree = protos::gen::ProcessTree;

constexpr uint64_t kPackageUid =;
constexpr std::string_view kPackageName =;

void AddPackage(uint64_t uid, std::string_view name, PackageList* list) {}

std::string CreateTestPacket() {}

// packet {
//   process_tree {
//     processes {
//       pid: 23022
//       ppid: 1
//       cmdline: "/vendor/bin/hw/wpa_supplicant"
//       cmdline: "-O/data/vendor/wifi/wpa/sockets"
//       cmdline: "-dd"
//       cmdline: "-g@android:wpa_wlan0"
//       uid: 1010
//     }
//     threads {
//       tid: 6382
//       tgid: 18176
//     }
//     threads {
//      tid: 18419
//       tgid: 18176
//     }
//     threads {
//       tid: 18434
//       tgid: 18176
//     }
//     collection_end_timestamp: 333724398314653
//   }
//   trusted_uid: 9999
//   timestamp: 333724396714922
//   trusted_packet_sequence_id: 3
//   trusted_pid: 1085
// }
std::string CreateNoPackageListPacket() {}
}  // namespace

TEST(PrunePackageListTest, ReturnsErrorWhenPackageUidIsMissing) {}

TEST(PrunePackageListTest, NoopWhenThereIsNoPackageList) {}

// PrunePackageList should not drop packets, instead it should drop individual
// PackageInfo entries.
TEST(PrunePackageListTest, RemovesPackagesInfoFromPackageList) {}

}  // namespace perfetto::trace_redaction