-----Original Message-----
From: [email protected] <[email protected]> On 
Behalf Of Yeoh Ee Peng
Sent: Wednesday, March 18, 2020 5:36 PM
To: [email protected]
Cc: Yeoh, Ee Peng <[email protected]>
Subject: [meta-intel] [PATCH v01] runtime/hdcp: Enable hdcp sanity test

Enable hdcp sanity testing:
 - test hdcp share library allow compile hdcp application
 - test that hdcp daemon was functioning and listening to hdcp API calls
   (HDCPCreate, HDCPEnumerateDisplay, HDCPDestroy)

Signed-off-by: Yeoh Ee Peng <[email protected]>
---
 lib/oeqa/runtime/cases/hdcp.py              | 36 +++++++++++++++++++
 lib/oeqa/runtime/files/hdcp/hdcp-sample.cpp | 55 +++++++++++++++++++++++++++++ 
 lib/oeqa/runtime/miutils/tests/hdcp_test.py | 40 +++++++++++++++++++++
 3 files changed, 131 insertions(+)
 create mode 100644 lib/oeqa/runtime/cases/hdcp.py  create mode 100644 
lib/oeqa/runtime/files/hdcp/hdcp-sample.cpp
 create mode 100644 lib/oeqa/runtime/miutils/tests/hdcp_test.py

diff --git a/lib/oeqa/runtime/cases/hdcp.py b/lib/oeqa/runtime/cases/hdcp.py 
new file mode 100644 index 0000000..825a7a1
--- /dev/null
+++ b/lib/oeqa/runtime/cases/hdcp.py
@@ -0,0 +1,36 @@
+from oeqa.runtime.case import OERuntimeTestCase from 
+oeqa.runtime.decorator.package import OEHasPackage from 
+oeqa.core.decorator.depends import OETestDepends from 
+oeqa.runtime.miutils.targets.oeqatarget import OEQATarget from 
+oeqa.runtime.miutils.tests.hdcp_test import HdcpTest
+
+class Hdcp(OERuntimeTestCase):
+    
+    @classmethod
+    def setUpClass(cls):
+        cls.hdcp = HdcpTest(OEQATarget(cls.tc.target))
+        cls.hdcp.setup()
+
+    @classmethod
+    def tearDownClass(cls):
+        cls.hdcp.tear_down()
+
+    @OEHasPackage(['hdcp'])
+    @OEHasPackage(['hdcp-dev'])
+    @OEHasPackage(['gcc'])
+    @OEHasPackage(['gcc-symlinks'])
+    @OEHasPackage(['libstdc++-dev'])
+    @OEHasPackage(['binutils'])
+    def test_hdcp_can_compile(self):
+        (status, output) = self.hdcp.test_hdcp_can_compile()
+        self.assertEqual(status, 0, msg='status and output: %s and %s' 
+ % (status, output))
+    
+    @OETestDepends(['hdcp.Hdcp.test_hdcp_can_compile'])
+    def 
test_hdcp_can_create_session_and_enumerate_display_with_hdcp_daemon_initialized(self):
+        (__, output) = self.hdcp.test_systemd_exist()
+        if not output:
+            self.skipTest('Image does not have systemd as init')
+        (status, output) = self.hdcp.start_hdcp_daemon()
+        self.assertEqual(status, 0, msg='status and output: %s and %s' % 
(status, output))
+        (status, output) = 
self.hdcp.test_hdcp_can_create_session_and_enumerate_display_with_hdcp_daemon_initialized()
+        self.assertEqual(status, 0, msg='status and output: %s and %s' 
+ % (status, output))
diff --git a/lib/oeqa/runtime/files/hdcp/hdcp-sample.cpp 
b/lib/oeqa/runtime/files/hdcp/hdcp-sample.cpp
new file mode 100644
index 0000000..020d624
--- /dev/null
+++ b/lib/oeqa/runtime/files/hdcp/hdcp-sample.cpp
@@ -0,0 +1,55 @@
+#include <iostream>
+#include <stdio.h>
+#include <hdcpapi.h>
+
+using std::cout;  // program uses cout
+using std::endl;  // program uses endl
+
+class HdcpApiTest
+{
+public:
+    static void CallBackFunction(uint32_t hdcpHandle, uint32_t portId, 
PORT_EVENT portEvent, void *context) 
+    {
+        cout << "Entering hdcp call back function" << endl;
+    }
+};
+
+int main()
+{
+    uint32_t * pHdcpHandle;
+    HDCP_STATUS hdcpCreateStatus = HDCP_STATUS_ERROR_INTERNAL;
+    HdcpApiTest hdcpTest;
+
+    hdcpCreateStatus = HDCPCreate(pHdcpHandle, HdcpApiTest::CallBackFunction, 
(void *)&hdcpTest);
+    if(hdcpCreateStatus == HDCP_STATUS_SUCCESSFUL)
+    {
+        cout << "PASS: HDCPCreate \n";
+        PortList portList;
+        HDCP_STATUS port_ret = HDCPEnumerateDisplay(*pHdcpHandle, 
+ &portList);
+
+        if(port_ret == HDCP_STATUS_SUCCESSFUL)
+        {
+            cout << "PortCount: " << portList.PortCount <<"\n";
+            cout << "PASS: HDCPEnumerateDisplay \n";
+
+        }else
+        {
+            cout << "FAIL: HDCPEnumerateDisplay \n";
+            return -1;
+        }
+
+        HDCP_STATUS ret = HDCPDestroy(*pHdcpHandle);
+        if(ret == HDCP_STATUS_SUCCESSFUL)
+        {
+            cout << "PASS: HDCPDestroy \n";
+        }else
+        {
+            cout << "FAIL: HDCPDestroy \n";
+            return -1;
+        }
+        return 0;
+    }    
+    cout << "FAIL: HDCP Create: " << endl;
+    cout << "HDCP Create status: " << hdcpCreateStatus << endl;
+    return -1;
+}

We can avoid to carry sample app source file by  building along with hdcp 
library and can be shipped as executable. 
Using ptest framework can be triggered.

\ No newline at end of file
diff --git a/lib/oeqa/runtime/miutils/tests/hdcp_test.py 
b/lib/oeqa/runtime/miutils/tests/hdcp_test.py
new file mode 100644
index 0000000..2eac40e
--- /dev/null
+++ b/lib/oeqa/runtime/miutils/tests/hdcp_test.py
@@ -0,0 +1,40 @@
+import os
+script_path = os.path.dirname(os.path.realpath(__file__))
+files_path = os.path.join(script_path, '../../files/')
+
+class HdcpTest(object):
+    hdcp_src_dir = '/tmp/'
+    hdcp_src_filename = 'hdcp-sample.cpp'
+    hdcp_target_filename = 'hdcp-sample'
+
+    def __init__(self, target):
+        self.target = target
+
+    def setup(self):
+        self.target.copy_to(os.path.join(files_path, 'hdcp', 
+ self.hdcp_src_filename), self.hdcp_src_dir)
+
+    def tear_down(self):
+        files = '%s%s %s%s' % (self.hdcp_src_dir, 
+                               self.hdcp_src_filename, 
+                               self.hdcp_src_dir, 
+                               self.hdcp_target_filename) 
+        self.target.run('rm %s' % files)
+        self.stop_hdcp_daemon()
+
+    def test_hdcp_can_compile(self):
+        return self.target.run('c++ %s%s -o %s%s -lhdcpsdk' % 
(self.hdcp_src_dir,
+                                                               
self.hdcp_src_filename, 
+                                                               
self.hdcp_src_dir, 
+                                                               
+ self.hdcp_target_filename))
+
+    def test_systemd_exist(self):
+        return self.target.run('pidof systemd')
+
+    def start_hdcp_daemon(self):
+        return self.target.run('systemctl start hdcpd')

Checks for systemd init manger should be added.
+
+    def 
test_hdcp_can_create_session_and_enumerate_display_with_hdcp_daemon_initialized(self):
+        return self.target.run('cd /tmp; ./%s' % 
+ self.hdcp_target_filename)
+
+    def stop_hdcp_daemon(self):
+        return self.target.run('systemctl stop hdcpd')
--
2.7.4

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#6426): 
https://lists.yoctoproject.org/g/meta-intel/message/6426
Mute This Topic: https://lists.yoctoproject.org/mt/72045169/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-intel/unsub  
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to