Kevin Rocard | 19b3e43 | 2017-05-24 11:01:34 -0700 | [diff] [blame] | 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 | |
Kevin Rocard | 6dcc713 | 2017-08-21 18:32:49 -0700 | [diff] [blame] | 17 | #include <string> |
| 18 | #include <unistd.h> |
| 19 | |
Kevin Rocard | 19b3e43 | 2017-05-24 11:01:34 -0700 | [diff] [blame] | 20 | #include "utility/ValidateXml.h" |
| 21 | |
| 22 | TEST(CheckConfig, audioPolicyConfigurationValidation) { |
Kevin Rocard | 6dcc713 | 2017-08-21 18:32:49 -0700 | [diff] [blame] | 23 | const char* configName = "audio_policy_configuration.xml"; |
| 24 | const char* possibleConfigLocations[] = {"/odm/etc", "/vendor/etc", "/system/etc"}; |
| 25 | const char* configSchemaPath = "/data/local/tmp/audio_policy_configuration.xsd"; |
| 26 | |
Kevin Rocard | 6dcc713 | 2017-08-21 18:32:49 -0700 | [diff] [blame] | 27 | for (std::string folder : possibleConfigLocations) { |
| 28 | const auto configPath = folder + '/' + configName; |
| 29 | if (access(configPath.c_str(), R_OK) == 0) { |
Kevin Rocard | 6dcc713 | 2017-08-21 18:32:49 -0700 | [diff] [blame] | 30 | ASSERT_VALID_XML(configPath.c_str(), configSchemaPath); |
Kevin Rocard | ff7dcd7 | 2017-09-13 18:11:14 -0700 | [diff] [blame] | 31 | return; // The framework does not read past the first config file found |
Kevin Rocard | 6dcc713 | 2017-08-21 18:32:49 -0700 | [diff] [blame] | 32 | } |
| 33 | } |
Kevin Rocard | 19b3e43 | 2017-05-24 11:01:34 -0700 | [diff] [blame] | 34 | } |