diff options
author | Daniel Norman <danielnorman@google.com> | 2019-08-02 16:40:33 -0700 |
---|---|---|
committer | Daniel Norman <danielnorman@google.com> | 2019-08-05 16:08:05 -0700 |
commit | bf4ed32bb1f50531fe11f48b880664d4917a45b6 (patch) | |
tree | c193043af3ddef2b3e67868a10feffd83d02050b /transport/base | |
parent | 5ea7f14be528d0cad546ce04afb7bd9de767f805 (diff) | |
download | libhidl-bf4ed32bb1f50531fe11f48b880664d4917a45b6.tar.gz |
Tests services provide all declared interfaces.
Bug: 138114550
Test: /data/nativetest64/vts_ibase_test/vts_ibase_test
Change-Id: I513c7eaf12cd302c7d0e6b5fc1d4bc974ad208ec
Diffstat (limited to 'transport/base')
-rw-r--r-- | transport/base/1.0/vts/functional/vts_ibase_test.cpp | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/transport/base/1.0/vts/functional/vts_ibase_test.cpp b/transport/base/1.0/vts/functional/vts_ibase_test.cpp index 38acf8a..a0b4e71 100644 --- a/transport/base/1.0/vts/functional/vts_ibase_test.cpp +++ b/transport/base/1.0/vts/functional/vts_ibase_test.cpp @@ -13,11 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#define LOG_TAG "vts_ibase_test" + #include <algorithm> #include <functional> #include <map> #include <string> +#include <android-base/logging.h> #include <android-base/properties.h> #include <android-base/strings.h> #include <android/hidl/base/1.0/IBase.h> @@ -63,7 +66,7 @@ std::string FqInstancesToString(const std::set<FqInstance>& instances) { for (const FqInstance& instance : instances) { instance_strings.insert(instance.string()); } - return android::base::Join(instance_strings, " "); + return android::base::Join(instance_strings, "\n"); } pid_t GetServiceDebugPid(const std::string& service) { @@ -212,19 +215,25 @@ TEST_F(VtsHalBaseV1_0TargetTest, HashChain) { }); } -// TODO(b/138114550): Also test that services serve all declared interfaces. -TEST_F(VtsHalBaseV1_0TargetTest, ServiceDeclaresAllServedInterfaces) { +TEST_F(VtsHalBaseV1_0TargetTest, ServiceProvidesAndDeclaresTheSameInterfaces) { Result<ServiceInterfacesMap> service_interfaces_map = android::init::GetOnDeviceServiceInterfacesMap(); ASSERT_TRUE(service_interfaces_map) << service_interfaces_map.error(); PidInterfacesMap pid_interfaces_map = GetPidInterfacesMap(); - for (const auto& [service, declared_interfaces] : *service_interfaces_map) { + for (auto [service, declared_interfaces] : *service_interfaces_map) { if (declared_interfaces.empty()) { - std::cout << "[WARNING] Service '" << service << "' does not declare any interfaces" + LOG(INFO) << "Service '" << service << "' does not declare any interfaces." << std::endl; continue; } + for (auto it = declared_interfaces.begin(); it != declared_interfaces.end();) { + if (it->getFqName() == android::gIBaseFqName) { + it = declared_interfaces.erase(it); + } else { + ++it; + } + } pid_t pid = GetServiceDebugPid(service); // TODO(b/138114550): Check lazy services that are not currently running // (when pid == 0). @@ -234,10 +243,22 @@ TEST_F(VtsHalBaseV1_0TargetTest, ServiceDeclaresAllServedInterfaces) { EXPECT_TRUE(diff.empty()) << "Service '" << service << "' serves interfaces that it does not declare." << std::endl - << " Served: '" << FqInstancesToString(served_interfaces) << "'" << std::endl - << " Declared: '" << FqInstancesToString(declared_interfaces) << "'" + << " Served:" << std::endl + << FqInstancesToString(served_interfaces) << std::endl + << " Declared: " << std::endl + << FqInstancesToString(declared_interfaces) << std::endl + << " Difference: " << std::endl + << FqInstancesToString(diff); + diff = SetDifference(declared_interfaces, served_interfaces); + EXPECT_TRUE(diff.empty()) + << "Service '" << service << "' declares interfaces that it does not serve." << std::endl - << " Difference: '" << FqInstancesToString(diff) << "'"; + << " Declared: " << std::endl + << FqInstancesToString(declared_interfaces) << std::endl + << " Served:" << std::endl + << FqInstancesToString(served_interfaces) << std::endl + << " Difference: " << std::endl + << FqInstancesToString(diff); } } } |