Add tests for SCLP event type Control-Program Identification
(CPI) to s390x CCW virtio tests.

Please note that these tests are skipped as the guest OS does not
trigger the SCLP event type CPI when the command
'echo 1 > /sys/firmware/cpi/set' is executed in the guest. I
believe that the guest OS must to be updated to support the SCLP
event type CPI.

Signed-off-by: Shalini Chellathurai Saroja <shal...@linux.ibm.com>
Suggested-by: Thomas Huth <th...@redhat.com>
---
 tests/functional/test_s390x_ccw_virtio.py | 24 +++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/tests/functional/test_s390x_ccw_virtio.py 
b/tests/functional/test_s390x_ccw_virtio.py
index 453711aa0f..c14379cbaa 100755
--- a/tests/functional/test_s390x_ccw_virtio.py
+++ b/tests/functional/test_s390x_ccw_virtio.py
@@ -15,6 +15,7 @@
 import tempfile
 
 from qemu_test import QemuSystemTest, Asset
+from qemu_test import exec_command
 from qemu_test import exec_command_and_wait_for_pattern
 from qemu_test import wait_for_console_pattern
 
@@ -270,5 +271,28 @@ def test_s390x_fedora(self):
                         'while ! (dmesg -c | grep Start.virtcrypto_remove) ; 
do'
                         ' sleep 1 ; done', 'Start virtcrypto_remove.')
 
+        # Test SCLP event Control-Program Identification (CPI)
+        cpi = '/sys/firmware/cpi/'
+        sclpcpi = '/machine/sclp/s390-sclp-event-facility/sclpcpi'
+        self.log.info("Test SCLP event CPI")
+        exec_command(self, 'echo TESTVM > ' + cpi + 'system_name')
+        exec_command(self, 'echo LINUX > ' + cpi + 'system_type')
+        exec_command(self, 'echo TESTPLEX > ' + cpi + 'sysplex_name')
+        exec_command(self, 'echo 1 > ' + cpi + 'set')
+        try:
+            event = self.vm.event_wait('SCLP_EVENT_CTRL_PGM_ID')
+        except TimeoutError:
+            self.skipTest('SCLP Event type CPI is not supported by guest OS')
+        ts = self.vm.cmd('qom-get', path=sclpcpi, property='timestamp')
+        self.assertNotEqual(int(ts), 0)
+        name = self.vm.cmd('qom-get', path=sclpcpi, property='system_name')
+        self.assertEqual(name, 'TESTVM')
+        typ = self.vm.cmd('qom-get', path=sclpcpi, property='system_type')
+        self.assertEqual(typ, 'LINUX')
+        sysplex = self.vm.cmd('qom-get', path=sclpcpi, property='sysplex_name')
+        self.assertEqual(sysplex, 'TESTPLEX')
+        level = self.vm.cmd('qom-get', path=sclpcpi, property='system_level')
+        self.assertNotEqual(int(level), 0)
+
 if __name__ == '__main__':
     QemuSystemTest.main()
-- 
2.49.0


Reply via email to