From cc18d3fede354d15aa74044d7243657e1bb5591d Mon Sep 17 00:00:00 2001 From: Miao Wang Date: Wed, 5 Feb 2020 16:26:37 -0800 Subject: [PATCH] Add a VTS test to validate NNAPI driver name string. Bug: 134755158 Test: VtsHalNeuralnetworksV1_2TargetTest Change-Id: Iead93f0a251fdbbf94df6dfdf27919d3f6fd71a8 Merged-In: Iead93f0a251fdbbf94df6dfdf27919d3f6fd71a8 (cherry picked from commit 2729d825cb208f7870df221239d871ba413d36d4) --- neuralnetworks/1.2/vts/functional/BasicTests.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/neuralnetworks/1.2/vts/functional/BasicTests.cpp b/neuralnetworks/1.2/vts/functional/BasicTests.cpp index 8e82c5376e..58d3c4a403 100644 --- a/neuralnetworks/1.2/vts/functional/BasicTests.cpp +++ b/neuralnetworks/1.2/vts/functional/BasicTests.cpp @@ -79,6 +79,18 @@ TEST_P(NeuralnetworksHidlTest, GetDeviceTypeTest) { EXPECT_TRUE(ret.isOk()); } +// device name test +TEST_P(NeuralnetworksHidlTest, GetDeviceNameTest) { + const std::string deviceName = getName(GetParam()); + auto pos = deviceName.find('-'); + EXPECT_NE(pos, std::string::npos); + // The separator should not be the first or last character. + EXPECT_NE(pos, 0); + EXPECT_NE(pos, deviceName.length() - 1); + // There should only be 1 separator. + EXPECT_EQ(std::string::npos, deviceName.find('-', pos + 1)); +} + // device supported extensions test TEST_P(NeuralnetworksHidlTest, GetDeviceSupportedExtensionsTest) { Return ret = kDevice->getSupportedExtensions(