/* * 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 <string> #include <string_view> #include <vector> #include "perfetto/base/status.h" #include "src/base/test/status_matchers.h" #include "src/trace_redaction/find_package_uid.h" #include "src/trace_redaction/prune_package_list.h" #include "src/trace_redaction/trace_redaction_framework.h" #include "src/trace_redaction/trace_redaction_integration_fixture.h" #include "src/trace_redaction/trace_redactor.h" #include "test/gtest_and_gmock.h" #include "protos/perfetto/trace/android/packages_list.gen.h" #include "protos/perfetto/trace/android/packages_list.pbzero.h" #include "protos/perfetto/trace/trace.pbzero.h" #include "protos/perfetto/trace/trace_packet.gen.h" #include "protos/perfetto/trace/trace_packet.pbzero.h" namespace perfetto::trace_redaction { namespace { // Set the package name to "just some package name". If a specific package name // is needed, the test it should overwrite this value. constexpr std::string_view kPackageName = …; constexpr uint64_t kPackageUid = …; } // namespace class PrunePackageListIntegrationTest : public testing::Test, protected TraceRedactionIntegrationFixure { … }; // It is possible for two packages_list to appear in the trace. The // find_package_uid will stop after the first one is found. Package uids are // appear as n * 1,000,000 where n is some integer. It is also possible for two // packages_list to contain copies of each other - for example // "com.Unity.com.unity.multiplayer.samples.coop" appears in both packages_list. TEST_F(PrunePackageListIntegrationTest, FindsPackageAndFiltersPackageList) { … } // It is possible for multiple packages to share a uid. The names will appears // across multiple package lists. The only time the package name appears is in // the package list, so there is no way to differentiate these packages (only // the uid is used later), so each entry should remain. TEST_F(PrunePackageListIntegrationTest, RetainsAllInstancesOfUid) { … } } // namespace perfetto::trace_redaction