• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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 "DeviceMatrixTest.h"
18 
19 #include <android-base/properties.h>
20 #include <vintf/VintfObject.h>
21 
22 using android::base::GetProperty;
23 
24 namespace android {
25 namespace vintf {
26 namespace testing {
27 
28 const string kVndkVersionProp{"ro.vndk.version"};
29 
SetUp()30 void DeviceMatrixTest::SetUp() {
31   VtsTrebleVintfTestBase::SetUp();
32 
33   vendor_matrix_ = VintfObject::GetDeviceCompatibilityMatrix();
34   ASSERT_NE(nullptr, vendor_matrix_)
35       << "Failed to get device compatibility matrix." << endl;
36 }
37 
TEST_F(DeviceMatrixTest,VndkVersion)38 TEST_F(DeviceMatrixTest, VndkVersion) {
39   if (GetBoardApiLevel() < 28) {
40     GTEST_SKIP()
41         << "VNDK version doesn't need to be set on devices before Android P";
42   }
43 
44   std::string syspropVndkVersion = GetProperty(kVndkVersionProp, "");
45   ASSERT_NE("", syspropVndkVersion)
46       << kVndkVersionProp << " must not be empty.";
47   std::string vintfVndkVersion = vendor_matrix_->getVendorNdkVersion();
48   ASSERT_NE("", vintfVndkVersion)
49       << "Device compatibility matrix does not declare proper VNDK version.";
50 
51   EXPECT_EQ(syspropVndkVersion, vintfVndkVersion)
52       << "VNDK version does not match: " << kVndkVersionProp << "="
53       << syspropVndkVersion << ", device compatibility matrix requires "
54       << vintfVndkVersion << ".";
55 }
56 
57 }  // namespace testing
58 }  // namespace vintf
59 }  // namespace android
60