Added a VTS test to validate the schema of uuid config xml
A new VTS test is added to the OMAPI VTS to validate the schema of the hal_uuid_map_config.xml file. Bug: b/180640274 Test: atest --rebuild-module-info VtsHalOmapiSeServiceV1_TargetTest Change-Id: Ib1ae39c0c33c066973ddc3fcb0b0c37535fa515e
This commit is contained in:
parent
cc2c6a0783
commit
6ed8558bdb
26
omapi/aidl/vts/functional/config/Android.bp
Normal file
26
omapi/aidl/vts/functional/config/Android.bp
Normal file
@ -0,0 +1,26 @@
|
||||
//
|
||||
// Copyright (C) 2022 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.
|
||||
//
|
||||
|
||||
package {
|
||||
default_applicable_licenses: ["Android-Apache-2.0"],
|
||||
}
|
||||
|
||||
xsd_config {
|
||||
name: "omapi_uuid_map_config",
|
||||
srcs: ["omapi_uuid_map_config.xsd"],
|
||||
api_dir: "schema",
|
||||
package_name: "omapi.uuid.map.config",
|
||||
}
|
40
omapi/aidl/vts/functional/config/omapi_uuid_map_config.xsd
Normal file
40
omapi/aidl/vts/functional/config/omapi_uuid_map_config.xsd
Normal file
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright (C) 2022 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.
|
||||
-->
|
||||
<xs:schema version="2.0"
|
||||
attributeFormDefault="unqualified"
|
||||
elementFormDefault="qualified"
|
||||
xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<xs:element name="ref_do">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="uuid_ref_do" maxOccurs="unbounded" minOccurs="0">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="uids">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element type="xs:short" name="uid" maxOccurs="unbounded" minOccurs="0"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element type="xs:string" name="uuid"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
30
omapi/aidl/vts/functional/config/schema/current.txt
Normal file
30
omapi/aidl/vts/functional/config/schema/current.txt
Normal file
@ -0,0 +1,30 @@
|
||||
// Signature format: 2.0
|
||||
package omapi.uuid.map.config {
|
||||
|
||||
public class RefDo {
|
||||
ctor public RefDo();
|
||||
method public java.util.List<omapi.uuid.map.config.RefDo.UuidRefDo> getUuid_ref_do();
|
||||
}
|
||||
|
||||
public static class RefDo.UuidRefDo {
|
||||
ctor public RefDo.UuidRefDo();
|
||||
method public omapi.uuid.map.config.RefDo.UuidRefDo.Uids getUids();
|
||||
method public String getUuid();
|
||||
method public void setUids(omapi.uuid.map.config.RefDo.UuidRefDo.Uids);
|
||||
method public void setUuid(String);
|
||||
}
|
||||
|
||||
public static class RefDo.UuidRefDo.Uids {
|
||||
ctor public RefDo.UuidRefDo.Uids();
|
||||
method public java.util.List<java.lang.Short> getUid();
|
||||
}
|
||||
|
||||
public class XmlParser {
|
||||
ctor public XmlParser();
|
||||
method public static omapi.uuid.map.config.RefDo read(java.io.InputStream) throws javax.xml.datatype.DatatypeConfigurationException, java.io.IOException, org.xmlpull.v1.XmlPullParserException;
|
||||
method public static String readText(org.xmlpull.v1.XmlPullParser) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
|
||||
method public static void skip(org.xmlpull.v1.XmlPullParser) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
|
||||
}
|
||||
|
||||
}
|
||||
|
1
omapi/aidl/vts/functional/config/schema/removed.txt
Normal file
1
omapi/aidl/vts/functional/config/schema/removed.txt
Normal file
@ -0,0 +1 @@
|
||||
// Signature format: 2.0
|
@ -39,6 +39,11 @@ cc_test {
|
||||
static_libs: [
|
||||
"VtsHalHidlTargetTestBase",
|
||||
"android.se.omapi-V1-ndk",
|
||||
"android.hardware.audio.common.test.utility",
|
||||
"libxml2",
|
||||
],
|
||||
data: [
|
||||
":omapi_uuid_map_config",
|
||||
],
|
||||
cflags: [
|
||||
"-O0",
|
||||
@ -51,4 +56,5 @@ cc_test {
|
||||
"general-tests",
|
||||
"vts",
|
||||
],
|
||||
test_config: "VtsHalOmapiSeServiceV1_TargetTest.xml",
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <hidl/GtestPrinter.h>
|
||||
#include <hidl/ServiceManagement.h>
|
||||
#include <utils/String16.h>
|
||||
#include "utility/ValidateXml.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace ::testing;
|
||||
@ -176,6 +177,25 @@ class OMAPISEServiceHalTest : public TestWithParam<std::string> {
|
||||
return (deviceSupportsFeature(FEATURE_SE_OMAPI_ESE.c_str()));
|
||||
}
|
||||
|
||||
std::optional<std::string> getUuidMappingFile() {
|
||||
char value[PROPERTY_VALUE_MAX] = {0};
|
||||
int len = property_get("ro.boot.product.hardware.sku", value, "config");
|
||||
std::string uuidMappingConfigFile = UUID_MAPPING_CONFIG_PREFIX
|
||||
+ std::string(value, len)
|
||||
+ UUID_MAPPING_CONFIG_EXT;
|
||||
std::string uuidMapConfigPath;
|
||||
// Search in predefined folders
|
||||
for (auto path : UUID_MAPPING_CONFIG_PATHS) {
|
||||
uuidMapConfigPath = path + uuidMappingConfigFile;
|
||||
auto confFile = fopen(uuidMapConfigPath.c_str(), "r");
|
||||
if (confFile) {
|
||||
fclose(confFile);
|
||||
return uuidMapConfigPath;
|
||||
}
|
||||
}
|
||||
return std::optional<std::string>();
|
||||
}
|
||||
|
||||
void SetUp() override {
|
||||
LOG(INFO) << "get OMAPI service with name:" << GetParam();
|
||||
::ndk::SpAIBinder ks2Binder(AServiceManager_getService(GetParam().c_str()));
|
||||
@ -300,6 +320,10 @@ class OMAPISEServiceHalTest : public TestWithParam<std::string> {
|
||||
|
||||
std::map<std::string, std::shared_ptr<aidl::android::se::omapi::ISecureElementReader>>
|
||||
mVSReaders = {};
|
||||
|
||||
std::string UUID_MAPPING_CONFIG_PREFIX = "hal_uuid_map_";
|
||||
std::string UUID_MAPPING_CONFIG_EXT = ".xml";
|
||||
std::string UUID_MAPPING_CONFIG_PATHS[3] = {"/odm/etc/", "/vendor/etc/", "/etc/"};
|
||||
};
|
||||
|
||||
/** Tests getReaders API */
|
||||
@ -600,6 +624,14 @@ TEST_P(OMAPISEServiceHalTest, TestP2Value) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(OMAPISEServiceHalTest, TestUuidMappingConfig) {
|
||||
constexpr const char* xsd = "/data/local/tmp/omapi_uuid_map_config.xsd";
|
||||
auto uuidMappingFile = getUuidMappingFile();
|
||||
ASSERT_TRUE(uuidMappingFile.has_value()) << "Unable to determine UUID mapping config file path";
|
||||
LOG(INFO) << "UUID Mapping config file: " << uuidMappingFile.value();
|
||||
EXPECT_VALID_XML(uuidMappingFile->c_str(), xsd);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(PerInstance, OMAPISEServiceHalTest,
|
||||
testing::ValuesIn(::android::getAidlHalInstanceNames(
|
||||
aidl::android::se::omapi::ISecureElementService::descriptor)),
|
||||
|
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2022 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.
|
||||
-->
|
||||
<configuration description="Runs VtsHalOmapiSeServiceV1_TargetTest.">
|
||||
<option name="test-suite-tag" value="apct" />
|
||||
<option name="test-suite-tag" value="apct-native" />
|
||||
|
||||
<target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer">
|
||||
</target_preparer>
|
||||
|
||||
<target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
|
||||
<option name="cleanup" value="true" />
|
||||
<option name="push"
|
||||
value="omapi_uuid_map_config.xsd->/data/local/tmp/omapi_uuid_map_config.xsd" />
|
||||
<option name="push"
|
||||
value="VtsHalOmapiSeServiceV1_TargetTest->/data/local/tmp/VtsHalOmapiSeServiceV1_TargetTest" />
|
||||
</target_preparer>
|
||||
|
||||
<test class="com.android.tradefed.testtype.GTest" >
|
||||
<option name="native-test-device-path" value="/data/local/tmp" />
|
||||
<option name="module-name" value="VtsHalOmapiSeServiceV1_TargetTest" />
|
||||
</test>
|
||||
</configuration>
|
Loading…
x
Reference in New Issue
Block a user