Loading drm/1.0/vts/functional/Android.bp +5 −2 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ cc_test { srcs: [ "drm_hal_clearkey_test.cpp", "drm_hal_vendor_test.cpp", "vendor_modules.cpp" "vendor_modules.cpp", ], static_libs: [ "android.hardware.drm@1.0", Loading @@ -32,5 +32,8 @@ cc_test { "libssl", "libcrypto_static", ], test_suites: ["general-tests"], test_suites: [ "general-tests", "vts-core", ], } drm/1.0/vts/functional/drm_hal_clearkey_test.cpp +128 −86 File changed.Preview size limit exceeded, changes collapsed. Show changes drm/1.0/vts/functional/drm_hal_vendor_test.cpp +67 −83 Original line number Diff line number Diff line Loading @@ -24,16 +24,17 @@ #include <android/hardware/drm/1.0/types.h> #include <android/hidl/allocator/1.0/IAllocator.h> #include <gtest/gtest.h> #include <hidl/GtestPrinter.h> #include <hidl/ServiceManagement.h> #include <hidlmemory/mapping.h> #include <log/log.h> #include <memory> #include <openssl/aes.h> #include <memory> #include <random> #include "drm_hal_vendor_module_api.h" #include "vendor_modules.h" #include <VtsHalHidlTargetCallbackBase.h> #include <VtsHalHidlTargetTestBase.h> using ::android::hardware::drm::V1_0::BufferType; using ::android::hardware::drm::V1_0::DestinationBuffer; Loading Loading @@ -77,16 +78,16 @@ using std::vector; using ContentConfiguration = ::DrmHalVTSVendorModule_V1::ContentConfiguration; using Key = ::DrmHalVTSVendorModule_V1::ContentConfiguration::Key; using VtsTestBase = ::testing::VtsHalHidlTargetTestBase; #define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk()) #define EXPECT_OK(ret) EXPECT_TRUE(ret.isOk()) #define RETURN_IF_SKIPPED \ if (!vendorModule->isInstalled()) { \ std::cout << "[ SKIPPED ] This drm scheme not supported." << \ " library:" << GetParam() << " service-name:" << \ vendorModule->getServiceName() << std::endl; \ if (vendorModule == nullptr || !vendorModule->isInstalled()) { \ GTEST_SKIP() << "This drm scheme not supported." \ << " library:" << GetParam() << " service-name:" \ << (vendorModule == nullptr ? "N/A" : vendorModule->getServiceName()) \ << std::endl; \ return; \ } Loading @@ -97,73 +98,47 @@ static const uint8_t kInvalidUUID[16] = { static drm_vts::VendorModules* gVendorModules = nullptr; // Test environment for drm class DrmHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { public: // get the test environment singleton static DrmHidlEnvironment* Instance() { static DrmHidlEnvironment* instance = new DrmHidlEnvironment; return instance; } void registerTestServices() override { registerTestService<ICryptoFactory>(); registerTestService<IDrmFactory>(); setServiceCombMode(::testing::HalServiceCombMode::NO_COMBINATION); } private: DrmHidlEnvironment() {} GTEST_DISALLOW_COPY_AND_ASSIGN_(DrmHidlEnvironment); }; class DrmHalVendorFactoryTest : public testing::TestWithParam<std::string> { public: DrmHalVendorFactoryTest() : vendorModule(static_cast<DrmHalVTSVendorModule_V1*>( gVendorModules->getModule(GetParam()))), contentConfigurations(vendorModule->getContentConfigurations()) {} : vendorModule( static_cast<DrmHalVTSVendorModule_V1*>(gVendorModules->getModule(GetParam()))) {} virtual ~DrmHalVendorFactoryTest() {} virtual void SetUp() { const ::testing::TestInfo* const test_info = ::testing::UnitTest::GetInstance()->current_test_info(); ALOGD("Running test %s.%s from vendor module %s", test_info->test_case_name(), test_info->name(), GetParam().c_str()); ALOGD("Running test %s.%s from vendor module %s", test_info->test_case_name(), test_info->name(), GetParam().c_str()); const std::string instance = GetParam(); if (instance == "widevine") { ASSERT_NE(nullptr, vendorModule.get()); // First try the binderized service name provided by the vendor module. // If that fails, which it can on non-binderized devices, try the default // service. string name = vendorModule->getServiceName(); drmFactory = VtsTestBase::getService<IDrmFactory>(name); if (drmFactory == nullptr) { drmFactory = VtsTestBase::getService<IDrmFactory>(); } ASSERT_NE(nullptr, drmFactory.get()); // Do the same for the crypto factory cryptoFactory = VtsTestBase::getService<ICryptoFactory>(name); if (cryptoFactory == nullptr) { cryptoFactory = VtsTestBase::getService<ICryptoFactory>(); if (vendorModule == nullptr) { GTEST_SKIP() << "No vendor module available"; } else { ASSERT_EQ(instance, vendorModule->getServiceName()); contentConfigurations = vendorModule->getContentConfigurations(); } drmFactory = IDrmFactory::getService(instance); ASSERT_NE(nullptr, drmFactory.get()); cryptoFactory = ICryptoFactory::getService(instance); ASSERT_NE(nullptr, cryptoFactory.get()); // If drm scheme not installed skip subsequent tests if (!drmFactory->isCryptoSchemeSupported(getVendorUUID())) { // no GTEST_SKIP since only some tests require the module vendorModule->setInstalled(false); return; } } virtual void TearDown() override {} protected: hidl_array<uint8_t, 16> getVendorUUID() { if (vendorModule == nullptr) return {}; vector<uint8_t> uuid = vendorModule->getUUID(); return hidl_array<uint8_t, 16>(&uuid[0]); } Loading @@ -171,7 +146,7 @@ class DrmHalVendorFactoryTest : public testing::TestWithParam<std::string> { sp<IDrmFactory> drmFactory; sp<ICryptoFactory> cryptoFactory; unique_ptr<DrmHalVTSVendorModule_V1> vendorModule; const vector<ContentConfiguration> contentConfigurations; vector<ContentConfiguration> contentConfigurations; }; TEST_P(DrmHalVendorFactoryTest, ValidateConfigurations) { Loading Loading @@ -1596,17 +1571,28 @@ TEST_P(DrmHalVendorDecryptTest, AttemptDecryptWithKeysRemoved) { * Instantiate the set of test cases for each vendor module */ INSTANTIATE_TEST_CASE_P( DrmHalVendorFactoryTestCases, DrmHalVendorFactoryTest, testing::ValuesIn(gVendorModules->getPathList())); static const std::set<std::string> kAllInstances = [] { std::vector<std::string> drmInstances = android::hardware::getAllHalInstanceNames(IDrmFactory::descriptor); std::vector<std::string> cryptoInstances = android::hardware::getAllHalInstanceNames(ICryptoFactory::descriptor); std::set<std::string> allInstances; allInstances.insert(drmInstances.begin(), drmInstances.end()); allInstances.insert(cryptoInstances.begin(), cryptoInstances.end()); return allInstances; }(); INSTANTIATE_TEST_CASE_P(DrmHalVendorFactoryTestCases, DrmHalVendorFactoryTest, testing::ValuesIn(kAllInstances), android::hardware::PrintInstanceNameToString); INSTANTIATE_TEST_CASE_P( DrmHalVendorPluginTestCases, DrmHalVendorPluginTest, testing::ValuesIn(gVendorModules->getPathList())); INSTANTIATE_TEST_CASE_P(DrmHalVendorPluginTestCases, DrmHalVendorPluginTest, testing::ValuesIn(kAllInstances), android::hardware::PrintInstanceNameToString); INSTANTIATE_TEST_CASE_P( DrmHalVendorDecryptTestCases, DrmHalVendorDecryptTest, testing::ValuesIn(gVendorModules->getPathList())); INSTANTIATE_TEST_CASE_P(DrmHalVendorDecryptTestCases, DrmHalVendorDecryptTest, testing::ValuesIn(kAllInstances), android::hardware::PrintInstanceNameToString); int main(int argc, char** argv) { #if defined(__LP64__) Loading @@ -1619,9 +1605,7 @@ int main(int argc, char** argv) { std::cerr << "WARNING: No vendor modules found in " << kModulePath << ", all vendor tests will be skipped" << std::endl; } ::testing::AddGlobalTestEnvironment(DrmHidlEnvironment::Instance()); ::testing::InitGoogleTest(&argc, argv); DrmHidlEnvironment::Instance()->init(&argc, argv); int status = RUN_ALL_TESTS(); ALOGI("Test result = %d", status); return status; Loading drm/1.1/vts/functional/Android.bp +5 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ cc_test { name: "VtsHalDrmV1_1TargetTest", defaults: ["VtsHalTargetTestDefaults"], srcs: [ "drm_hal_clearkey_test.cpp" "drm_hal_clearkey_test.cpp", ], static_libs: [ "android.hardware.drm@1.0", Loading @@ -30,5 +30,8 @@ cc_test { "libnativehelper", "libssl", ], test_suites: ["general-tests"], test_suites: [ "general-tests", "vts-core", ], } drm/1.1/vts/functional/drm_hal_clearkey_test.cpp +60 −107 Original line number Diff line number Diff line Loading @@ -16,27 +16,25 @@ #define LOG_TAG "drm_hal_clearkey_test@1.1" #include <android/hardware/drm/1.1/ICryptoFactory.h> #include <android/hardware/drm/1.0/ICryptoPlugin.h> #include <android/hardware/drm/1.1/IDrmFactory.h> #include <android/hardware/drm/1.0/IDrmPlugin.h> #include <android/hardware/drm/1.1/IDrmPlugin.h> #include <android/hardware/drm/1.0/types.h> #include <android/hardware/drm/1.1/ICryptoFactory.h> #include <android/hardware/drm/1.1/IDrmFactory.h> #include <android/hardware/drm/1.1/IDrmPlugin.h> #include <android/hardware/drm/1.1/types.h> #include <android/hidl/allocator/1.0/IAllocator.h> #include <android/hidl/manager/1.2/IServiceManager.h> #include <gtest/gtest.h> #include <hidl/GtestPrinter.h> #include <hidl/HidlSupport.h> #include <hidl/ServiceManagement.h> #include <hidlmemory/mapping.h> #include <log/log.h> #include <memory> #include <openssl/aes.h> #include <memory> #include <random> #include "VtsHalHidlTargetTestBase.h" #include "VtsHalHidlTargetTestEnvBase.h" namespace drm = ::android::hardware::drm; using ::android::hardware::drm::V1_0::BufferType; using ::android::hardware::drm::V1_0::DestinationBuffer; Loading Loading @@ -94,76 +92,31 @@ static const uint8_t kClearKeyUUID[16] = { 0xE2, 0x71, 0x9D, 0x58, 0xA9, 0x85, 0xB3, 0xC9, 0x78, 0x1A, 0xB0, 0x30, 0xAF, 0x78, 0xD3, 0x0E}; // Test environment for drm class DrmHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { class DrmHalClearkeyTest : public ::testing::TestWithParam<std::string> { public: // get the test environment singleton static DrmHidlEnvironment* Instance() { static DrmHidlEnvironment* instance = new DrmHidlEnvironment; return instance; } virtual void HidlSetUp() override { ALOGI("SetUp DrmHidlEnvironment"); } virtual void HidlTearDown() override { ALOGI("TearDown DrmHidlEnvironment"); } void registerTestServices() override { registerTestService<ICryptoFactory>(); registerTestService<IDrmFactory>(); setServiceCombMode(::testing::HalServiceCombMode::NO_COMBINATION); } private: DrmHidlEnvironment() {} GTEST_DISALLOW_COPY_AND_ASSIGN_(DrmHidlEnvironment); }; class DrmHalClearkeyTest : public ::testing::VtsHalHidlTargetTestBase { public: virtual void SetUp() override { void SetUp() override { const ::testing::TestInfo* const test_info = ::testing::UnitTest::GetInstance()->current_test_info(); ALOGD("DrmHalClearkeyTest: Running test %s.%s", test_info->test_case_name(), test_info->name()); auto manager = android::hardware::defaultServiceManager1_2(); ASSERT_NE(nullptr, manager.get()); manager->listManifestByInterface(IDrmFactory::descriptor, [&](const hidl_vec<hidl_string> ®istered) { for (const auto &instance : registered) { sp<IDrmFactory> drmFactory = ::testing::VtsHalHidlTargetTestBase::getService<IDrmFactory>(instance); drmPlugin = createDrmPlugin(drmFactory); if (drmPlugin != nullptr) { break; } } } ); const std::string instance = GetParam(); manager->listManifestByInterface(ICryptoFactory::descriptor, [&](const hidl_vec<hidl_string> ®istered) { for (const auto &instance : registered) { sp<ICryptoFactory> cryptoFactory = ::testing::VtsHalHidlTargetTestBase::getService<ICryptoFactory>(instance); sp<IDrmFactory> drmFactory = IDrmFactory::getService(instance); drmPlugin = createDrmPlugin(drmFactory); sp<ICryptoFactory> cryptoFactory = ICryptoFactory::getService(instance); cryptoPlugin = createCryptoPlugin(cryptoFactory); if (cryptoPlugin != nullptr) { break; } if (drmPlugin == nullptr || cryptoPlugin == nullptr) { if (instance == "clearkey") { ASSERT_NE(nullptr, drmPlugin.get()) << "Can't get clearkey drm@1.1 plugin"; ASSERT_NE(nullptr, cryptoPlugin.get()) << "Can't get clearkey crypto@1.1 plugin"; } GTEST_SKIP() << "Instance does not support clearkey"; } ); ASSERT_NE(nullptr, drmPlugin.get()) << "Can't find clearkey drm@1.1 plugin"; ASSERT_NE(nullptr, cryptoPlugin.get()) << "Can't find clearkey crypto@1.1 plugin"; } virtual void TearDown() override {} SessionId openSession(); SessionId openSession(SecurityLevel level); void closeSession(const SessionId& sessionId); Loading @@ -176,9 +129,8 @@ public: } sp<IDrmPlugin> plugin = nullptr; auto res = drmFactory->createPlugin( kClearKeyUUID, "", [&](Status status, const sp<drm::V1_0::IDrmPlugin>& pluginV1_0) { EXPECT_EQ(Status::OK, status); kClearKeyUUID, "", [&](Status status, const sp<drm::V1_0::IDrmPlugin>& pluginV1_0) { EXPECT_EQ(Status::OK == status, pluginV1_0 != nullptr); plugin = IDrmPlugin::castFrom(pluginV1_0); }); Loading @@ -197,7 +149,7 @@ public: auto res = cryptoFactory->createPlugin( kClearKeyUUID, initVec, [&](Status status, const sp<drm::V1_0::ICryptoPlugin>& pluginV1_0) { EXPECT_EQ(Status::OK, status); EXPECT_EQ(Status::OK == status, pluginV1_0 != nullptr); plugin = pluginV1_0; }); if (!res.isOk()) { Loading Loading @@ -265,7 +217,6 @@ protected: sp<ICryptoPlugin> cryptoPlugin; }; /** * Helper method to open a session and verify that a non-empty * session ID is returned Loading Loading @@ -371,7 +322,7 @@ hidl_vec<uint8_t> DrmHalClearkeyTest::loadKeys( /** * Test openSession negative case: security level higher than supported */ TEST_F(DrmHalClearkeyTest, OpenSessionBadLevel) { TEST_P(DrmHalClearkeyTest, OpenSessionBadLevel) { auto res = drmPlugin->openSession_1_1(SecurityLevel::HW_SECURE_ALL, [&](Status status, const SessionId& /* id */) { EXPECT_EQ(Status::ERROR_DRM_CANNOT_HANDLE, status); Loading @@ -382,7 +333,7 @@ TEST_F(DrmHalClearkeyTest, OpenSessionBadLevel) { /** * Test getKeyRequest_1_1 via loadKeys */ TEST_F(DrmHalClearkeyTest, GetKeyRequest) { TEST_P(DrmHalClearkeyTest, GetKeyRequest) { auto sessionId = openSession(); loadKeys(sessionId); closeSession(sessionId); Loading @@ -391,7 +342,7 @@ TEST_F(DrmHalClearkeyTest, GetKeyRequest) { /** * A get key request should fail if no sessionId is provided */ TEST_F(DrmHalClearkeyTest, GetKeyRequestNoSession) { TEST_P(DrmHalClearkeyTest, GetKeyRequestNoSession) { SessionId invalidSessionId; hidl_vec<uint8_t> initData; hidl_string mimeType = "video/mp4"; Loading @@ -409,7 +360,7 @@ TEST_F(DrmHalClearkeyTest, GetKeyRequestNoSession) { * Test that the plugin returns the expected error code in * this case. */ TEST_F(DrmHalClearkeyTest, GetKeyRequestOfflineKeyTypeNotSupported) { TEST_P(DrmHalClearkeyTest, GetKeyRequestOfflineKeyTypeNotSupported) { auto sessionId = openSession(); hidl_vec<uint8_t> initData; hidl_string mimeType = "video/mp4"; Loading @@ -429,7 +380,7 @@ TEST_F(DrmHalClearkeyTest, GetKeyRequestOfflineKeyTypeNotSupported) { /** * Test that the plugin returns valid connected and max HDCP levels */ TEST_F(DrmHalClearkeyTest, GetHdcpLevels) { TEST_P(DrmHalClearkeyTest, GetHdcpLevels) { auto res = drmPlugin->getHdcpLevels( [&](Status status, const HdcpLevel &connectedLevel, const HdcpLevel &maxLevel) { Loading @@ -448,7 +399,7 @@ TEST_F(DrmHalClearkeyTest, GetHdcpLevels) { /** * Test that the plugin returns default open and max session counts */ TEST_F(DrmHalClearkeyTest, GetDefaultSessionCounts) { TEST_P(DrmHalClearkeyTest, GetDefaultSessionCounts) { auto res = drmPlugin->getNumberOfSessions( [&](Status status, uint32_t currentSessions, uint32_t maxSessions) { Loading @@ -464,7 +415,7 @@ TEST_F(DrmHalClearkeyTest, GetDefaultSessionCounts) { * Test that the plugin returns valid open and max session counts * after a session is opened. */ TEST_F(DrmHalClearkeyTest, GetOpenSessionCounts) { TEST_P(DrmHalClearkeyTest, GetOpenSessionCounts) { uint32_t initialSessions = 0; auto res = drmPlugin->getNumberOfSessions( [&](Status status, uint32_t currentSessions, Loading Loading @@ -505,7 +456,7 @@ TEST_F(DrmHalClearkeyTest, GetOpenSessionCounts) { * Test that the plugin returns the same security level * by default as when it is requested explicitly */ TEST_F(DrmHalClearkeyTest, GetDefaultSecurityLevel) { TEST_P(DrmHalClearkeyTest, GetDefaultSecurityLevel) { SessionId session = openSession(); SecurityLevel defaultLevel; auto res = drmPlugin->getSecurityLevel(session, Loading @@ -530,7 +481,7 @@ TEST_F(DrmHalClearkeyTest, GetDefaultSecurityLevel) { * Test that the plugin returns the lowest security level * when it is requested */ TEST_F(DrmHalClearkeyTest, GetSecurityLevel) { TEST_P(DrmHalClearkeyTest, GetSecurityLevel) { SessionId session = openSession(SecurityLevel::SW_SECURE_CRYPTO); auto res = drmPlugin->getSecurityLevel(session, [&](Status status, SecurityLevel level) { Loading @@ -545,7 +496,7 @@ TEST_F(DrmHalClearkeyTest, GetSecurityLevel) { * Test that the plugin returns the documented error * when requesting the security level for an invalid sessionId */ TEST_F(DrmHalClearkeyTest, GetSecurityLevelInvalidSessionId) { TEST_P(DrmHalClearkeyTest, GetSecurityLevelInvalidSessionId) { SessionId session; auto res = drmPlugin->getSecurityLevel(session, [&](Status status, SecurityLevel /*level*/) { Loading @@ -557,7 +508,7 @@ TEST_F(DrmHalClearkeyTest, GetSecurityLevelInvalidSessionId) { /** * Test metrics are set appropriately for open and close operations. */ TEST_F(DrmHalClearkeyTest, GetMetricsOpenClose) { TEST_P(DrmHalClearkeyTest, GetMetricsOpenClose) { SessionId sessionId = openSession(); // The first close should be successful. closeSession(sessionId); Loading Loading @@ -589,7 +540,7 @@ TEST_F(DrmHalClearkeyTest, GetMetricsOpenClose) { /** * Test that there are no secure stop ids after clearing them */ TEST_F(DrmHalClearkeyTest, GetSecureStopIdsCleared) { TEST_P(DrmHalClearkeyTest, GetSecureStopIdsCleared) { auto stat = drmPlugin->removeAllSecureStops(); EXPECT_OK(stat); Loading @@ -604,7 +555,7 @@ TEST_F(DrmHalClearkeyTest, GetSecureStopIdsCleared) { /** * Test that there are secure stop ids after loading keys once */ TEST_F(DrmHalClearkeyTest, GetSecureStopIdsOnce) { TEST_P(DrmHalClearkeyTest, GetSecureStopIdsOnce) { auto stat = drmPlugin->removeAllSecureStops(); EXPECT_OK(stat); Loading Loading @@ -639,7 +590,7 @@ TEST_F(DrmHalClearkeyTest, GetSecureStopIdsOnce) { * Test that the clearkey plugin reports no secure stops when * there are none. */ TEST_F(DrmHalClearkeyTest, GetNoSecureStops) { TEST_P(DrmHalClearkeyTest, GetNoSecureStops) { auto stat = drmPlugin->removeAllSecureStops(); EXPECT_OK(stat); Loading @@ -654,7 +605,7 @@ TEST_F(DrmHalClearkeyTest, GetNoSecureStops) { /** * Test get/remove of one secure stop */ TEST_F(DrmHalClearkeyTest, GetOneSecureStopAndRemoveIt) { TEST_P(DrmHalClearkeyTest, GetOneSecureStopAndRemoveIt) { auto stat = drmPlugin->removeAllSecureStops(); EXPECT_OK(stat); Loading Loading @@ -688,7 +639,7 @@ TEST_F(DrmHalClearkeyTest, GetOneSecureStopAndRemoveIt) { /** * Test that there are no secure stops after clearing them */ TEST_F(DrmHalClearkeyTest, GetSecureStopsCleared) { TEST_P(DrmHalClearkeyTest, GetSecureStopsCleared) { auto stat = drmPlugin->removeAllSecureStops(); EXPECT_OK(stat); Loading @@ -703,7 +654,7 @@ TEST_F(DrmHalClearkeyTest, GetSecureStopsCleared) { /** * Test that there are secure stops after loading keys once */ TEST_F(DrmHalClearkeyTest, GetSecureStopsOnce) { TEST_P(DrmHalClearkeyTest, GetSecureStopsOnce) { auto stat = drmPlugin->removeAllSecureStops(); EXPECT_OK(stat); Loading Loading @@ -738,7 +689,7 @@ TEST_F(DrmHalClearkeyTest, GetSecureStopsOnce) { * Test that releasing a secure stop with empty * release message fails with the documented error */ TEST_F(DrmHalClearkeyTest, ReleaseEmptySecureStop) { TEST_P(DrmHalClearkeyTest, ReleaseEmptySecureStop) { SecureStopRelease emptyRelease = {.opaqueData = hidl_vec<uint8_t>()}; Status status = drmPlugin->releaseSecureStops(emptyRelease); EXPECT_EQ(Status::BAD_VALUE, status); Loading @@ -763,8 +714,7 @@ SecureStopRelease makeSecureRelease(const SecureStop &stop) { /** * Test that releasing one secure stop works */ TEST_F(DrmHalClearkeyTest, ReleaseOneSecureStop) { TEST_P(DrmHalClearkeyTest, ReleaseOneSecureStop) { auto stat = drmPlugin->removeAllSecureStops(); EXPECT_OK(stat); Loading Loading @@ -792,12 +742,11 @@ TEST_F(DrmHalClearkeyTest, ReleaseOneSecureStop) { EXPECT_OK(res); } /** * Test that removing a secure stop with an empty ID returns * documented error */ TEST_F(DrmHalClearkeyTest, RemoveEmptySecureStopId) { TEST_P(DrmHalClearkeyTest, RemoveEmptySecureStopId) { hidl_vec<uint8_t> emptyId; auto stat = drmPlugin->removeSecureStop(emptyId); EXPECT_OK(stat); Loading @@ -808,7 +757,7 @@ TEST_F(DrmHalClearkeyTest, RemoveEmptySecureStopId) { * Test that removing a secure stop after it has already * been removed fails with the documented error code. */ TEST_F(DrmHalClearkeyTest, RemoveRemovedSecureStopId) { TEST_P(DrmHalClearkeyTest, RemoveRemovedSecureStopId) { auto stat = drmPlugin->removeAllSecureStops(); EXPECT_OK(stat); Loading @@ -835,7 +784,7 @@ TEST_F(DrmHalClearkeyTest, RemoveRemovedSecureStopId) { /** * Test that removing a secure stop by id works */ TEST_F(DrmHalClearkeyTest, RemoveSecureStopById) { TEST_P(DrmHalClearkeyTest, RemoveSecureStopById) { auto stat = drmPlugin->removeAllSecureStops(); EXPECT_OK(stat); Loading Loading @@ -863,12 +812,16 @@ TEST_F(DrmHalClearkeyTest, RemoveSecureStopById) { EXPECT_OK(res); } static const std::set<std::string> kAllInstances = [] { std::vector<std::string> drmInstances = android::hardware::getAllHalInstanceNames(IDrmFactory::descriptor); std::vector<std::string> cryptoInstances = android::hardware::getAllHalInstanceNames(ICryptoFactory::descriptor); std::set<std::string> allInstances; allInstances.insert(drmInstances.begin(), drmInstances.end()); allInstances.insert(cryptoInstances.begin(), cryptoInstances.end()); return allInstances; }(); int main(int argc, char** argv) { ::testing::AddGlobalTestEnvironment(DrmHidlEnvironment::Instance()); ::testing::InitGoogleTest(&argc, argv); DrmHidlEnvironment::Instance()->init(&argc, argv); int status = RUN_ALL_TESTS(); ALOGI("Test result = %d", status); return status; } INSTANTIATE_TEST_SUITE_P(PerInstance, DrmHalClearkeyTest, testing::ValuesIn(kAllInstances), android::hardware::PrintInstanceNameToString); Loading
drm/1.0/vts/functional/Android.bp +5 −2 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ cc_test { srcs: [ "drm_hal_clearkey_test.cpp", "drm_hal_vendor_test.cpp", "vendor_modules.cpp" "vendor_modules.cpp", ], static_libs: [ "android.hardware.drm@1.0", Loading @@ -32,5 +32,8 @@ cc_test { "libssl", "libcrypto_static", ], test_suites: ["general-tests"], test_suites: [ "general-tests", "vts-core", ], }
drm/1.0/vts/functional/drm_hal_clearkey_test.cpp +128 −86 File changed.Preview size limit exceeded, changes collapsed. Show changes
drm/1.0/vts/functional/drm_hal_vendor_test.cpp +67 −83 Original line number Diff line number Diff line Loading @@ -24,16 +24,17 @@ #include <android/hardware/drm/1.0/types.h> #include <android/hidl/allocator/1.0/IAllocator.h> #include <gtest/gtest.h> #include <hidl/GtestPrinter.h> #include <hidl/ServiceManagement.h> #include <hidlmemory/mapping.h> #include <log/log.h> #include <memory> #include <openssl/aes.h> #include <memory> #include <random> #include "drm_hal_vendor_module_api.h" #include "vendor_modules.h" #include <VtsHalHidlTargetCallbackBase.h> #include <VtsHalHidlTargetTestBase.h> using ::android::hardware::drm::V1_0::BufferType; using ::android::hardware::drm::V1_0::DestinationBuffer; Loading Loading @@ -77,16 +78,16 @@ using std::vector; using ContentConfiguration = ::DrmHalVTSVendorModule_V1::ContentConfiguration; using Key = ::DrmHalVTSVendorModule_V1::ContentConfiguration::Key; using VtsTestBase = ::testing::VtsHalHidlTargetTestBase; #define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk()) #define EXPECT_OK(ret) EXPECT_TRUE(ret.isOk()) #define RETURN_IF_SKIPPED \ if (!vendorModule->isInstalled()) { \ std::cout << "[ SKIPPED ] This drm scheme not supported." << \ " library:" << GetParam() << " service-name:" << \ vendorModule->getServiceName() << std::endl; \ if (vendorModule == nullptr || !vendorModule->isInstalled()) { \ GTEST_SKIP() << "This drm scheme not supported." \ << " library:" << GetParam() << " service-name:" \ << (vendorModule == nullptr ? "N/A" : vendorModule->getServiceName()) \ << std::endl; \ return; \ } Loading @@ -97,73 +98,47 @@ static const uint8_t kInvalidUUID[16] = { static drm_vts::VendorModules* gVendorModules = nullptr; // Test environment for drm class DrmHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { public: // get the test environment singleton static DrmHidlEnvironment* Instance() { static DrmHidlEnvironment* instance = new DrmHidlEnvironment; return instance; } void registerTestServices() override { registerTestService<ICryptoFactory>(); registerTestService<IDrmFactory>(); setServiceCombMode(::testing::HalServiceCombMode::NO_COMBINATION); } private: DrmHidlEnvironment() {} GTEST_DISALLOW_COPY_AND_ASSIGN_(DrmHidlEnvironment); }; class DrmHalVendorFactoryTest : public testing::TestWithParam<std::string> { public: DrmHalVendorFactoryTest() : vendorModule(static_cast<DrmHalVTSVendorModule_V1*>( gVendorModules->getModule(GetParam()))), contentConfigurations(vendorModule->getContentConfigurations()) {} : vendorModule( static_cast<DrmHalVTSVendorModule_V1*>(gVendorModules->getModule(GetParam()))) {} virtual ~DrmHalVendorFactoryTest() {} virtual void SetUp() { const ::testing::TestInfo* const test_info = ::testing::UnitTest::GetInstance()->current_test_info(); ALOGD("Running test %s.%s from vendor module %s", test_info->test_case_name(), test_info->name(), GetParam().c_str()); ALOGD("Running test %s.%s from vendor module %s", test_info->test_case_name(), test_info->name(), GetParam().c_str()); const std::string instance = GetParam(); if (instance == "widevine") { ASSERT_NE(nullptr, vendorModule.get()); // First try the binderized service name provided by the vendor module. // If that fails, which it can on non-binderized devices, try the default // service. string name = vendorModule->getServiceName(); drmFactory = VtsTestBase::getService<IDrmFactory>(name); if (drmFactory == nullptr) { drmFactory = VtsTestBase::getService<IDrmFactory>(); } ASSERT_NE(nullptr, drmFactory.get()); // Do the same for the crypto factory cryptoFactory = VtsTestBase::getService<ICryptoFactory>(name); if (cryptoFactory == nullptr) { cryptoFactory = VtsTestBase::getService<ICryptoFactory>(); if (vendorModule == nullptr) { GTEST_SKIP() << "No vendor module available"; } else { ASSERT_EQ(instance, vendorModule->getServiceName()); contentConfigurations = vendorModule->getContentConfigurations(); } drmFactory = IDrmFactory::getService(instance); ASSERT_NE(nullptr, drmFactory.get()); cryptoFactory = ICryptoFactory::getService(instance); ASSERT_NE(nullptr, cryptoFactory.get()); // If drm scheme not installed skip subsequent tests if (!drmFactory->isCryptoSchemeSupported(getVendorUUID())) { // no GTEST_SKIP since only some tests require the module vendorModule->setInstalled(false); return; } } virtual void TearDown() override {} protected: hidl_array<uint8_t, 16> getVendorUUID() { if (vendorModule == nullptr) return {}; vector<uint8_t> uuid = vendorModule->getUUID(); return hidl_array<uint8_t, 16>(&uuid[0]); } Loading @@ -171,7 +146,7 @@ class DrmHalVendorFactoryTest : public testing::TestWithParam<std::string> { sp<IDrmFactory> drmFactory; sp<ICryptoFactory> cryptoFactory; unique_ptr<DrmHalVTSVendorModule_V1> vendorModule; const vector<ContentConfiguration> contentConfigurations; vector<ContentConfiguration> contentConfigurations; }; TEST_P(DrmHalVendorFactoryTest, ValidateConfigurations) { Loading Loading @@ -1596,17 +1571,28 @@ TEST_P(DrmHalVendorDecryptTest, AttemptDecryptWithKeysRemoved) { * Instantiate the set of test cases for each vendor module */ INSTANTIATE_TEST_CASE_P( DrmHalVendorFactoryTestCases, DrmHalVendorFactoryTest, testing::ValuesIn(gVendorModules->getPathList())); static const std::set<std::string> kAllInstances = [] { std::vector<std::string> drmInstances = android::hardware::getAllHalInstanceNames(IDrmFactory::descriptor); std::vector<std::string> cryptoInstances = android::hardware::getAllHalInstanceNames(ICryptoFactory::descriptor); std::set<std::string> allInstances; allInstances.insert(drmInstances.begin(), drmInstances.end()); allInstances.insert(cryptoInstances.begin(), cryptoInstances.end()); return allInstances; }(); INSTANTIATE_TEST_CASE_P(DrmHalVendorFactoryTestCases, DrmHalVendorFactoryTest, testing::ValuesIn(kAllInstances), android::hardware::PrintInstanceNameToString); INSTANTIATE_TEST_CASE_P( DrmHalVendorPluginTestCases, DrmHalVendorPluginTest, testing::ValuesIn(gVendorModules->getPathList())); INSTANTIATE_TEST_CASE_P(DrmHalVendorPluginTestCases, DrmHalVendorPluginTest, testing::ValuesIn(kAllInstances), android::hardware::PrintInstanceNameToString); INSTANTIATE_TEST_CASE_P( DrmHalVendorDecryptTestCases, DrmHalVendorDecryptTest, testing::ValuesIn(gVendorModules->getPathList())); INSTANTIATE_TEST_CASE_P(DrmHalVendorDecryptTestCases, DrmHalVendorDecryptTest, testing::ValuesIn(kAllInstances), android::hardware::PrintInstanceNameToString); int main(int argc, char** argv) { #if defined(__LP64__) Loading @@ -1619,9 +1605,7 @@ int main(int argc, char** argv) { std::cerr << "WARNING: No vendor modules found in " << kModulePath << ", all vendor tests will be skipped" << std::endl; } ::testing::AddGlobalTestEnvironment(DrmHidlEnvironment::Instance()); ::testing::InitGoogleTest(&argc, argv); DrmHidlEnvironment::Instance()->init(&argc, argv); int status = RUN_ALL_TESTS(); ALOGI("Test result = %d", status); return status; Loading
drm/1.1/vts/functional/Android.bp +5 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ cc_test { name: "VtsHalDrmV1_1TargetTest", defaults: ["VtsHalTargetTestDefaults"], srcs: [ "drm_hal_clearkey_test.cpp" "drm_hal_clearkey_test.cpp", ], static_libs: [ "android.hardware.drm@1.0", Loading @@ -30,5 +30,8 @@ cc_test { "libnativehelper", "libssl", ], test_suites: ["general-tests"], test_suites: [ "general-tests", "vts-core", ], }
drm/1.1/vts/functional/drm_hal_clearkey_test.cpp +60 −107 Original line number Diff line number Diff line Loading @@ -16,27 +16,25 @@ #define LOG_TAG "drm_hal_clearkey_test@1.1" #include <android/hardware/drm/1.1/ICryptoFactory.h> #include <android/hardware/drm/1.0/ICryptoPlugin.h> #include <android/hardware/drm/1.1/IDrmFactory.h> #include <android/hardware/drm/1.0/IDrmPlugin.h> #include <android/hardware/drm/1.1/IDrmPlugin.h> #include <android/hardware/drm/1.0/types.h> #include <android/hardware/drm/1.1/ICryptoFactory.h> #include <android/hardware/drm/1.1/IDrmFactory.h> #include <android/hardware/drm/1.1/IDrmPlugin.h> #include <android/hardware/drm/1.1/types.h> #include <android/hidl/allocator/1.0/IAllocator.h> #include <android/hidl/manager/1.2/IServiceManager.h> #include <gtest/gtest.h> #include <hidl/GtestPrinter.h> #include <hidl/HidlSupport.h> #include <hidl/ServiceManagement.h> #include <hidlmemory/mapping.h> #include <log/log.h> #include <memory> #include <openssl/aes.h> #include <memory> #include <random> #include "VtsHalHidlTargetTestBase.h" #include "VtsHalHidlTargetTestEnvBase.h" namespace drm = ::android::hardware::drm; using ::android::hardware::drm::V1_0::BufferType; using ::android::hardware::drm::V1_0::DestinationBuffer; Loading Loading @@ -94,76 +92,31 @@ static const uint8_t kClearKeyUUID[16] = { 0xE2, 0x71, 0x9D, 0x58, 0xA9, 0x85, 0xB3, 0xC9, 0x78, 0x1A, 0xB0, 0x30, 0xAF, 0x78, 0xD3, 0x0E}; // Test environment for drm class DrmHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { class DrmHalClearkeyTest : public ::testing::TestWithParam<std::string> { public: // get the test environment singleton static DrmHidlEnvironment* Instance() { static DrmHidlEnvironment* instance = new DrmHidlEnvironment; return instance; } virtual void HidlSetUp() override { ALOGI("SetUp DrmHidlEnvironment"); } virtual void HidlTearDown() override { ALOGI("TearDown DrmHidlEnvironment"); } void registerTestServices() override { registerTestService<ICryptoFactory>(); registerTestService<IDrmFactory>(); setServiceCombMode(::testing::HalServiceCombMode::NO_COMBINATION); } private: DrmHidlEnvironment() {} GTEST_DISALLOW_COPY_AND_ASSIGN_(DrmHidlEnvironment); }; class DrmHalClearkeyTest : public ::testing::VtsHalHidlTargetTestBase { public: virtual void SetUp() override { void SetUp() override { const ::testing::TestInfo* const test_info = ::testing::UnitTest::GetInstance()->current_test_info(); ALOGD("DrmHalClearkeyTest: Running test %s.%s", test_info->test_case_name(), test_info->name()); auto manager = android::hardware::defaultServiceManager1_2(); ASSERT_NE(nullptr, manager.get()); manager->listManifestByInterface(IDrmFactory::descriptor, [&](const hidl_vec<hidl_string> ®istered) { for (const auto &instance : registered) { sp<IDrmFactory> drmFactory = ::testing::VtsHalHidlTargetTestBase::getService<IDrmFactory>(instance); drmPlugin = createDrmPlugin(drmFactory); if (drmPlugin != nullptr) { break; } } } ); const std::string instance = GetParam(); manager->listManifestByInterface(ICryptoFactory::descriptor, [&](const hidl_vec<hidl_string> ®istered) { for (const auto &instance : registered) { sp<ICryptoFactory> cryptoFactory = ::testing::VtsHalHidlTargetTestBase::getService<ICryptoFactory>(instance); sp<IDrmFactory> drmFactory = IDrmFactory::getService(instance); drmPlugin = createDrmPlugin(drmFactory); sp<ICryptoFactory> cryptoFactory = ICryptoFactory::getService(instance); cryptoPlugin = createCryptoPlugin(cryptoFactory); if (cryptoPlugin != nullptr) { break; } if (drmPlugin == nullptr || cryptoPlugin == nullptr) { if (instance == "clearkey") { ASSERT_NE(nullptr, drmPlugin.get()) << "Can't get clearkey drm@1.1 plugin"; ASSERT_NE(nullptr, cryptoPlugin.get()) << "Can't get clearkey crypto@1.1 plugin"; } GTEST_SKIP() << "Instance does not support clearkey"; } ); ASSERT_NE(nullptr, drmPlugin.get()) << "Can't find clearkey drm@1.1 plugin"; ASSERT_NE(nullptr, cryptoPlugin.get()) << "Can't find clearkey crypto@1.1 plugin"; } virtual void TearDown() override {} SessionId openSession(); SessionId openSession(SecurityLevel level); void closeSession(const SessionId& sessionId); Loading @@ -176,9 +129,8 @@ public: } sp<IDrmPlugin> plugin = nullptr; auto res = drmFactory->createPlugin( kClearKeyUUID, "", [&](Status status, const sp<drm::V1_0::IDrmPlugin>& pluginV1_0) { EXPECT_EQ(Status::OK, status); kClearKeyUUID, "", [&](Status status, const sp<drm::V1_0::IDrmPlugin>& pluginV1_0) { EXPECT_EQ(Status::OK == status, pluginV1_0 != nullptr); plugin = IDrmPlugin::castFrom(pluginV1_0); }); Loading @@ -197,7 +149,7 @@ public: auto res = cryptoFactory->createPlugin( kClearKeyUUID, initVec, [&](Status status, const sp<drm::V1_0::ICryptoPlugin>& pluginV1_0) { EXPECT_EQ(Status::OK, status); EXPECT_EQ(Status::OK == status, pluginV1_0 != nullptr); plugin = pluginV1_0; }); if (!res.isOk()) { Loading Loading @@ -265,7 +217,6 @@ protected: sp<ICryptoPlugin> cryptoPlugin; }; /** * Helper method to open a session and verify that a non-empty * session ID is returned Loading Loading @@ -371,7 +322,7 @@ hidl_vec<uint8_t> DrmHalClearkeyTest::loadKeys( /** * Test openSession negative case: security level higher than supported */ TEST_F(DrmHalClearkeyTest, OpenSessionBadLevel) { TEST_P(DrmHalClearkeyTest, OpenSessionBadLevel) { auto res = drmPlugin->openSession_1_1(SecurityLevel::HW_SECURE_ALL, [&](Status status, const SessionId& /* id */) { EXPECT_EQ(Status::ERROR_DRM_CANNOT_HANDLE, status); Loading @@ -382,7 +333,7 @@ TEST_F(DrmHalClearkeyTest, OpenSessionBadLevel) { /** * Test getKeyRequest_1_1 via loadKeys */ TEST_F(DrmHalClearkeyTest, GetKeyRequest) { TEST_P(DrmHalClearkeyTest, GetKeyRequest) { auto sessionId = openSession(); loadKeys(sessionId); closeSession(sessionId); Loading @@ -391,7 +342,7 @@ TEST_F(DrmHalClearkeyTest, GetKeyRequest) { /** * A get key request should fail if no sessionId is provided */ TEST_F(DrmHalClearkeyTest, GetKeyRequestNoSession) { TEST_P(DrmHalClearkeyTest, GetKeyRequestNoSession) { SessionId invalidSessionId; hidl_vec<uint8_t> initData; hidl_string mimeType = "video/mp4"; Loading @@ -409,7 +360,7 @@ TEST_F(DrmHalClearkeyTest, GetKeyRequestNoSession) { * Test that the plugin returns the expected error code in * this case. */ TEST_F(DrmHalClearkeyTest, GetKeyRequestOfflineKeyTypeNotSupported) { TEST_P(DrmHalClearkeyTest, GetKeyRequestOfflineKeyTypeNotSupported) { auto sessionId = openSession(); hidl_vec<uint8_t> initData; hidl_string mimeType = "video/mp4"; Loading @@ -429,7 +380,7 @@ TEST_F(DrmHalClearkeyTest, GetKeyRequestOfflineKeyTypeNotSupported) { /** * Test that the plugin returns valid connected and max HDCP levels */ TEST_F(DrmHalClearkeyTest, GetHdcpLevels) { TEST_P(DrmHalClearkeyTest, GetHdcpLevels) { auto res = drmPlugin->getHdcpLevels( [&](Status status, const HdcpLevel &connectedLevel, const HdcpLevel &maxLevel) { Loading @@ -448,7 +399,7 @@ TEST_F(DrmHalClearkeyTest, GetHdcpLevels) { /** * Test that the plugin returns default open and max session counts */ TEST_F(DrmHalClearkeyTest, GetDefaultSessionCounts) { TEST_P(DrmHalClearkeyTest, GetDefaultSessionCounts) { auto res = drmPlugin->getNumberOfSessions( [&](Status status, uint32_t currentSessions, uint32_t maxSessions) { Loading @@ -464,7 +415,7 @@ TEST_F(DrmHalClearkeyTest, GetDefaultSessionCounts) { * Test that the plugin returns valid open and max session counts * after a session is opened. */ TEST_F(DrmHalClearkeyTest, GetOpenSessionCounts) { TEST_P(DrmHalClearkeyTest, GetOpenSessionCounts) { uint32_t initialSessions = 0; auto res = drmPlugin->getNumberOfSessions( [&](Status status, uint32_t currentSessions, Loading Loading @@ -505,7 +456,7 @@ TEST_F(DrmHalClearkeyTest, GetOpenSessionCounts) { * Test that the plugin returns the same security level * by default as when it is requested explicitly */ TEST_F(DrmHalClearkeyTest, GetDefaultSecurityLevel) { TEST_P(DrmHalClearkeyTest, GetDefaultSecurityLevel) { SessionId session = openSession(); SecurityLevel defaultLevel; auto res = drmPlugin->getSecurityLevel(session, Loading @@ -530,7 +481,7 @@ TEST_F(DrmHalClearkeyTest, GetDefaultSecurityLevel) { * Test that the plugin returns the lowest security level * when it is requested */ TEST_F(DrmHalClearkeyTest, GetSecurityLevel) { TEST_P(DrmHalClearkeyTest, GetSecurityLevel) { SessionId session = openSession(SecurityLevel::SW_SECURE_CRYPTO); auto res = drmPlugin->getSecurityLevel(session, [&](Status status, SecurityLevel level) { Loading @@ -545,7 +496,7 @@ TEST_F(DrmHalClearkeyTest, GetSecurityLevel) { * Test that the plugin returns the documented error * when requesting the security level for an invalid sessionId */ TEST_F(DrmHalClearkeyTest, GetSecurityLevelInvalidSessionId) { TEST_P(DrmHalClearkeyTest, GetSecurityLevelInvalidSessionId) { SessionId session; auto res = drmPlugin->getSecurityLevel(session, [&](Status status, SecurityLevel /*level*/) { Loading @@ -557,7 +508,7 @@ TEST_F(DrmHalClearkeyTest, GetSecurityLevelInvalidSessionId) { /** * Test metrics are set appropriately for open and close operations. */ TEST_F(DrmHalClearkeyTest, GetMetricsOpenClose) { TEST_P(DrmHalClearkeyTest, GetMetricsOpenClose) { SessionId sessionId = openSession(); // The first close should be successful. closeSession(sessionId); Loading Loading @@ -589,7 +540,7 @@ TEST_F(DrmHalClearkeyTest, GetMetricsOpenClose) { /** * Test that there are no secure stop ids after clearing them */ TEST_F(DrmHalClearkeyTest, GetSecureStopIdsCleared) { TEST_P(DrmHalClearkeyTest, GetSecureStopIdsCleared) { auto stat = drmPlugin->removeAllSecureStops(); EXPECT_OK(stat); Loading @@ -604,7 +555,7 @@ TEST_F(DrmHalClearkeyTest, GetSecureStopIdsCleared) { /** * Test that there are secure stop ids after loading keys once */ TEST_F(DrmHalClearkeyTest, GetSecureStopIdsOnce) { TEST_P(DrmHalClearkeyTest, GetSecureStopIdsOnce) { auto stat = drmPlugin->removeAllSecureStops(); EXPECT_OK(stat); Loading Loading @@ -639,7 +590,7 @@ TEST_F(DrmHalClearkeyTest, GetSecureStopIdsOnce) { * Test that the clearkey plugin reports no secure stops when * there are none. */ TEST_F(DrmHalClearkeyTest, GetNoSecureStops) { TEST_P(DrmHalClearkeyTest, GetNoSecureStops) { auto stat = drmPlugin->removeAllSecureStops(); EXPECT_OK(stat); Loading @@ -654,7 +605,7 @@ TEST_F(DrmHalClearkeyTest, GetNoSecureStops) { /** * Test get/remove of one secure stop */ TEST_F(DrmHalClearkeyTest, GetOneSecureStopAndRemoveIt) { TEST_P(DrmHalClearkeyTest, GetOneSecureStopAndRemoveIt) { auto stat = drmPlugin->removeAllSecureStops(); EXPECT_OK(stat); Loading Loading @@ -688,7 +639,7 @@ TEST_F(DrmHalClearkeyTest, GetOneSecureStopAndRemoveIt) { /** * Test that there are no secure stops after clearing them */ TEST_F(DrmHalClearkeyTest, GetSecureStopsCleared) { TEST_P(DrmHalClearkeyTest, GetSecureStopsCleared) { auto stat = drmPlugin->removeAllSecureStops(); EXPECT_OK(stat); Loading @@ -703,7 +654,7 @@ TEST_F(DrmHalClearkeyTest, GetSecureStopsCleared) { /** * Test that there are secure stops after loading keys once */ TEST_F(DrmHalClearkeyTest, GetSecureStopsOnce) { TEST_P(DrmHalClearkeyTest, GetSecureStopsOnce) { auto stat = drmPlugin->removeAllSecureStops(); EXPECT_OK(stat); Loading Loading @@ -738,7 +689,7 @@ TEST_F(DrmHalClearkeyTest, GetSecureStopsOnce) { * Test that releasing a secure stop with empty * release message fails with the documented error */ TEST_F(DrmHalClearkeyTest, ReleaseEmptySecureStop) { TEST_P(DrmHalClearkeyTest, ReleaseEmptySecureStop) { SecureStopRelease emptyRelease = {.opaqueData = hidl_vec<uint8_t>()}; Status status = drmPlugin->releaseSecureStops(emptyRelease); EXPECT_EQ(Status::BAD_VALUE, status); Loading @@ -763,8 +714,7 @@ SecureStopRelease makeSecureRelease(const SecureStop &stop) { /** * Test that releasing one secure stop works */ TEST_F(DrmHalClearkeyTest, ReleaseOneSecureStop) { TEST_P(DrmHalClearkeyTest, ReleaseOneSecureStop) { auto stat = drmPlugin->removeAllSecureStops(); EXPECT_OK(stat); Loading Loading @@ -792,12 +742,11 @@ TEST_F(DrmHalClearkeyTest, ReleaseOneSecureStop) { EXPECT_OK(res); } /** * Test that removing a secure stop with an empty ID returns * documented error */ TEST_F(DrmHalClearkeyTest, RemoveEmptySecureStopId) { TEST_P(DrmHalClearkeyTest, RemoveEmptySecureStopId) { hidl_vec<uint8_t> emptyId; auto stat = drmPlugin->removeSecureStop(emptyId); EXPECT_OK(stat); Loading @@ -808,7 +757,7 @@ TEST_F(DrmHalClearkeyTest, RemoveEmptySecureStopId) { * Test that removing a secure stop after it has already * been removed fails with the documented error code. */ TEST_F(DrmHalClearkeyTest, RemoveRemovedSecureStopId) { TEST_P(DrmHalClearkeyTest, RemoveRemovedSecureStopId) { auto stat = drmPlugin->removeAllSecureStops(); EXPECT_OK(stat); Loading @@ -835,7 +784,7 @@ TEST_F(DrmHalClearkeyTest, RemoveRemovedSecureStopId) { /** * Test that removing a secure stop by id works */ TEST_F(DrmHalClearkeyTest, RemoveSecureStopById) { TEST_P(DrmHalClearkeyTest, RemoveSecureStopById) { auto stat = drmPlugin->removeAllSecureStops(); EXPECT_OK(stat); Loading Loading @@ -863,12 +812,16 @@ TEST_F(DrmHalClearkeyTest, RemoveSecureStopById) { EXPECT_OK(res); } static const std::set<std::string> kAllInstances = [] { std::vector<std::string> drmInstances = android::hardware::getAllHalInstanceNames(IDrmFactory::descriptor); std::vector<std::string> cryptoInstances = android::hardware::getAllHalInstanceNames(ICryptoFactory::descriptor); std::set<std::string> allInstances; allInstances.insert(drmInstances.begin(), drmInstances.end()); allInstances.insert(cryptoInstances.begin(), cryptoInstances.end()); return allInstances; }(); int main(int argc, char** argv) { ::testing::AddGlobalTestEnvironment(DrmHidlEnvironment::Instance()); ::testing::InitGoogleTest(&argc, argv); DrmHidlEnvironment::Instance()->init(&argc, argv); int status = RUN_ALL_TESTS(); ALOGI("Test result = %d", status); return status; } INSTANTIATE_TEST_SUITE_P(PerInstance, DrmHalClearkeyTest, testing::ValuesIn(kAllInstances), android::hardware::PrintInstanceNameToString);