1/* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#include "filter/AbiFilter.h" 18 19#include <string> 20 21#include "gtest/gtest.h" 22 23namespace aapt { 24namespace { 25 26using ::aapt::configuration::Abi; 27 28struct TestData { 29 std::string path; 30 bool kept; 31}; 32 33const TestData kTestData[] = { 34 /* Keep. */ 35 {"lib/mips/libnative.so", true}, 36 {"not/native/file.txt", true}, 37 // Not sure if this is a valid use case. 38 {"lib/listing.txt", true}, 39 {"lib/mips/foo/bar/baz.so", true}, 40 {"lib/mips/x86/foo.so", true}, 41 /* Discard. */ 42 {"lib/mips_horse/foo.so", false}, 43 {"lib/horse_mips/foo.so", false}, 44 {"lib/mips64/armeabi-v7a/foo.so", false}, 45 {"lib/mips64/x86_64/x86.so", false}, 46 {"lib/x86/libnative.so", false}, 47 {"lib/x86/foo/bar/baz.so", false}, 48 {"lib/x86/x86/foo.so", false}, 49 {"lib/x86_horse/foo.so", false}, 50 {"lib/horse_x86/foo.so", false}, 51 {"lib/x86/armeabi-v7a/foo.so", false}, 52 {"lib/x86_64/x86_64/x86.so", false}, 53}; 54 55class AbiFilterTest : public ::testing::TestWithParam<TestData> {}; 56 57TEST_P(AbiFilterTest, Keep) { 58 auto mips = AbiFilter::FromAbiList({Abi::kMips}); 59 const TestData& data = GetParam(); 60 EXPECT_EQ(mips->Keep(data.path), data.kept); 61} 62 63INSTANTIATE_TEST_CASE_P(NativePaths, AbiFilterTest, ::testing::ValuesIn(kTestData)); 64 65} // namespace 66} // namespace aapt 67