diff options
| -rw-r--r-- | lib/oeqa/selftest/updater.py | 91 |
1 files changed, 60 insertions, 31 deletions
diff --git a/lib/oeqa/selftest/updater.py b/lib/oeqa/selftest/updater.py index 2723b4a..8ee3c69 100644 --- a/lib/oeqa/selftest/updater.py +++ b/lib/oeqa/selftest/updater.py | |||
| @@ -113,35 +113,64 @@ class GeneralTests(oeSelfTest): | |||
| 113 | self.assertNotEqual(path1, path2, "Image paths are identical; image was not rebuilt.") | 113 | self.assertNotEqual(path1, path2, "Image paths are identical; image was not rebuilt.") |
| 114 | self.assertNotEqual(size1, size2, "Image sizes are identical; image was not rebuilt.") | 114 | self.assertNotEqual(size1, size2, "Image sizes are identical; image was not rebuilt.") |
| 115 | 115 | ||
| 116 | def test_qemu(self): | 116 | |
| 117 | print('') | 117 | class QemuTests(oeSelfTest): |
| 118 | # Create empty object. | 118 | |
| 119 | args = type('', (), {})() | 119 | @classmethod |
| 120 | args.imagename = 'core-image-minimal' | 120 | def setUpClass(cls): |
| 121 | args.mac = None | 121 | logger = logging.getLogger("selftest") |
| 122 | # Could use DEPLOY_DIR_IMAGE here but it's already in the machine | 122 | logger.info('Running bitbake to build core-image-minimal') |
| 123 | # subdirectory. | 123 | bitbake('core-image-minimal') |
| 124 | args.dir = 'tmp/deploy/images' | 124 | |
| 125 | args.efi = False | 125 | def test_hostname(self): |
| 126 | args.machine = None | 126 | value, err = run_test_qemu('hostname', False, 'Checking machine name (hostname) of device:') |
| 127 | args.kvm = None # Autodetect | 127 | machine = get_bb_var('MACHINE', 'core-image-minimal') |
| 128 | args.no_gui = True | 128 | self.assertEqual(err, b'', 'Error: ' + err.decode()) |
| 129 | args.gdb = False | 129 | # Strip off line ending. |
| 130 | args.pcap = None | 130 | value_str = value.decode()[:-1] |
| 131 | args.overlay = None | 131 | self.assertEqual(value_str, machine, 'MACHINE does not match hostname: ' + machine + ', ' + value_str) |
| 132 | args.dry_run = False | 132 | print('hostname: ' + value_str) |
| 133 | 133 | ||
| 134 | qemu_command = QemuCommand(args) | 134 | def test_var_sota(self): |
| 135 | cmdline = qemu_command.command_line() | 135 | value, err = run_test_qemu('ls /var/sota', True, 'Checking contents of /var/sota:') |
| 136 | print('Booting image with run-qemu-ota...') | 136 | self.assertEqual(err, b'', 'Error: ' + err.decode()) |
| 137 | s = subprocess.Popen(cmdline) | 137 | print(value.decode()) |
| 138 | time.sleep(10) | 138 | |
| 139 | print('Machine name (hostname) of device is:') | 139 | |
| 140 | ssh_cmd = ['ssh', '-q', '-o', 'UserKnownHostsFile=/dev/null', '-o', 'StrictHostKeyChecking=no', 'root@localhost', '-p', str(qemu_command.ssh_port), 'hostname'] | 140 | def run_test_qemu(command, use_shell, message): |
| 141 | s2 = subprocess.Popen(ssh_cmd) | 141 | print('') |
| 142 | time.sleep(5) | 142 | # Create empty object. |
| 143 | try: | 143 | args = type('', (), {})() |
| 144 | s.terminate() | 144 | args.imagename = 'core-image-minimal' |
| 145 | except KeyboardInterrupt: | 145 | args.mac = None |
| 146 | pass | 146 | # Could use DEPLOY_DIR_IMAGE here but it's already in the machine |
| 147 | # subdirectory. | ||
| 148 | args.dir = 'tmp/deploy/images' | ||
| 149 | args.efi = False | ||
| 150 | args.machine = None | ||
| 151 | args.kvm = None # Autodetect | ||
| 152 | args.no_gui = True | ||
| 153 | args.gdb = False | ||
| 154 | args.pcap = None | ||
| 155 | args.overlay = None | ||
| 156 | args.dry_run = False | ||
| 157 | |||
| 158 | qemu_command = QemuCommand(args) | ||
| 159 | cmdline = qemu_command.command_line() | ||
| 160 | print('Booting image with run-qemu-ota...') | ||
| 161 | s = subprocess.Popen(cmdline) | ||
| 162 | time.sleep(10) | ||
| 163 | print(message) | ||
| 164 | if not use_shell: | ||
| 165 | command = ['ssh', '-q', '-o', 'UserKnownHostsFile=/dev/null', '-o', 'StrictHostKeyChecking=no', 'root@localhost', '-p', str(qemu_command.ssh_port), '"' + command + '"'] | ||
| 166 | else: | ||
| 167 | command = 'ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@localhost -p ' + str(qemu_command.ssh_port) + ' "' + command + '"' | ||
| 168 | s2 = subprocess.Popen(command, shell=use_shell, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
| 169 | value, err = s2.communicate() | ||
| 170 | time.sleep(5) | ||
| 171 | try: | ||
| 172 | s.terminate() | ||
| 173 | except KeyboardInterrupt: | ||
| 174 | pass | ||
| 175 | return value, err | ||
| 147 | 176 | ||
