diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/oeqa/selftest/updater.py | 81 |
1 files changed, 44 insertions, 37 deletions
diff --git a/lib/oeqa/selftest/updater.py b/lib/oeqa/selftest/updater.py index ad99964..408f2c3 100644 --- a/lib/oeqa/selftest/updater.py +++ b/lib/oeqa/selftest/updater.py | |||
| @@ -118,49 +118,16 @@ class QemuTests(oeSelfTest): | |||
| 118 | 118 | ||
| 119 | @classmethod | 119 | @classmethod |
| 120 | def setUpClass(cls): | 120 | def setUpClass(cls): |
| 121 | logger = logging.getLogger("selftest") | 121 | cls.qemu, cls.s = qemu_launch() |
| 122 | logger.info('Running bitbake to build core-image-minimal') | ||
| 123 | bitbake('core-image-minimal') | ||
| 124 | # Create empty object. | ||
| 125 | args = type('', (), {})() | ||
| 126 | args.imagename = 'core-image-minimal' | ||
| 127 | args.mac = None | ||
| 128 | # Could use DEPLOY_DIR_IMAGE here but it's already in the machine | ||
| 129 | # subdirectory. | ||
| 130 | args.dir = 'tmp/deploy/images' | ||
| 131 | args.efi = False | ||
| 132 | args.machine = None | ||
| 133 | args.kvm = None # Autodetect | ||
| 134 | args.no_gui = True | ||
| 135 | args.gdb = False | ||
| 136 | args.pcap = None | ||
| 137 | args.overlay = None | ||
| 138 | args.dry_run = False | ||
| 139 | |||
| 140 | cls.qemu = QemuCommand(args) | ||
| 141 | cmdline = cls.qemu.command_line() | ||
| 142 | print('Booting image with run-qemu-ota...') | ||
| 143 | cls.s = subprocess.Popen(cmdline) | ||
| 144 | time.sleep(10) | ||
| 145 | 122 | ||
| 146 | @classmethod | 123 | @classmethod |
| 147 | def tearDownClass(cls): | 124 | def tearDownClass(cls): |
| 148 | try: | 125 | qemu_terminate(cls.s) |
| 149 | cls.s.terminate() | ||
| 150 | except KeyboardInterrupt: | ||
| 151 | pass | ||
| 152 | |||
| 153 | def run_test_qemu(self, command): | ||
| 154 | command = ['ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@localhost -p ' + | ||
| 155 | str(self.qemu.ssh_port) + ' "' + command + '"'] | ||
| 156 | s2 = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
| 157 | value, err = s2.communicate() | ||
| 158 | return value, err | ||
| 159 | 126 | ||
| 160 | def test_hostname(self): | 127 | def test_hostname(self): |
| 161 | print('') | 128 | print('') |
| 162 | print('Checking machine name (hostname) of device:') | 129 | print('Checking machine name (hostname) of device:') |
| 163 | value, err = self.run_test_qemu('hostname') | 130 | value, err = qemu_send_command(self.qemu.ssh_port, 'hostname') |
| 164 | machine = get_bb_var('MACHINE', 'core-image-minimal') | 131 | machine = get_bb_var('MACHINE', 'core-image-minimal') |
| 165 | self.assertEqual(err, b'', 'Error: ' + err.decode()) | 132 | self.assertEqual(err, b'', 'Error: ' + err.decode()) |
| 166 | # Strip off line ending. | 133 | # Strip off line ending. |
| @@ -172,8 +139,48 @@ class QemuTests(oeSelfTest): | |||
| 172 | def test_var_sota(self): | 139 | def test_var_sota(self): |
| 173 | print('') | 140 | print('') |
| 174 | print('Checking contents of /var/sota:') | 141 | print('Checking contents of /var/sota:') |
| 175 | value, err = self.run_test_qemu('ls /var/sota') | 142 | value, err = qemu_send_command(self.qemu.ssh_port, 'ls /var/sota') |
| 176 | self.assertEqual(err, b'', 'Error: ' + err.decode()) | 143 | self.assertEqual(err, b'', 'Error: ' + err.decode()) |
| 177 | print(value.decode()) | 144 | print(value.decode()) |
| 178 | 145 | ||
| 179 | 146 | ||
| 147 | def qemu_launch(): | ||
| 148 | logger = logging.getLogger("selftest") | ||
| 149 | logger.info('Running bitbake to build core-image-minimal') | ||
| 150 | bitbake('core-image-minimal') | ||
| 151 | # Create empty object. | ||
| 152 | args = type('', (), {})() | ||
| 153 | args.imagename = 'core-image-minimal' | ||
| 154 | args.mac = None | ||
| 155 | # Could use DEPLOY_DIR_IMAGE here but it's already in the machine | ||
| 156 | # subdirectory. | ||
| 157 | args.dir = 'tmp/deploy/images' | ||
| 158 | args.efi = False | ||
| 159 | args.machine = None | ||
| 160 | args.kvm = None # Autodetect | ||
| 161 | args.no_gui = True | ||
| 162 | args.gdb = False | ||
| 163 | args.pcap = None | ||
| 164 | args.overlay = None | ||
| 165 | args.dry_run = False | ||
| 166 | |||
| 167 | qemu = QemuCommand(args) | ||
| 168 | cmdline = qemu.command_line() | ||
| 169 | print('Booting image with run-qemu-ota...') | ||
| 170 | s = subprocess.Popen(cmdline) | ||
| 171 | time.sleep(10) | ||
| 172 | return qemu, s | ||
| 173 | |||
| 174 | def qemu_terminate(s): | ||
| 175 | try: | ||
| 176 | s.terminate() | ||
| 177 | except KeyboardInterrupt: | ||
| 178 | pass | ||
| 179 | |||
| 180 | def qemu_send_command(port, command): | ||
| 181 | command = ['ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@localhost -p ' + | ||
| 182 | str(port) + ' "' + command + '"'] | ||
| 183 | s2 = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
| 184 | value, err = s2.communicate() | ||
| 185 | return value, err | ||
| 186 | |||
