new file mode 100644
@@ -0,0 +1,41 @@
+# Simple functional tests for cdrom devices
+#
+# Copyright (c) 2023 Red Hat, Inc.
+#
+# Author:
+# Cleber Rosa <crosa@redhat.com>
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or
+# later. See the COPYING file in the top-level directory.
+
+import os
+
+from avocado.utils.iso9660 import iso9660
+from avocado_qemu import QemuSystemTest
+
+
+class Cdrom(QemuSystemTest):
+ """
+ :avocado: tags=block,cdrom,quick
+ :avocado: tags=machine:none
+ """
+ def setUp(self):
+ super().setUp()
+ self.iso_path = os.path.join(self.workdir, "cdrom.iso")
+ iso = iso9660(self.iso_path)
+ iso.create()
+ iso.close()
+
+ def test_plain_iso_rw(self):
+ self.vm.add_args('-drive', f'file={self.iso_path}')
+ self.vm.launch()
+ query_block_result = self.vm.qmp('query-block')['return']
+ self.assertEqual(len(query_block_result), 1)
+ self.assertFalse(query_block_result[0]["inserted"]["ro"])
+
+ def test_media_cdrom_ro(self):
+ self.vm.add_args('-drive', f'file={self.iso_path},media=cdrom')
+ self.vm.launch()
+ query_block_result = self.vm.qmp('query-block')['return']
+ self.assertEqual(len(query_block_result), 1)
+ self.assertTrue(query_block_result[0]["inserted"]["ro"])
Signed-off-by: Cleber Rosa <crosa@redhat.com> --- tests/avocado/cdrom.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/avocado/cdrom.py