diff options
| author | Patrick Vacek <patrickvacek@gmail.com> | 2017-11-07 17:34:13 +0100 |
|---|---|---|
| committer | Patrick Vacek <patrickvacek@gmail.com> | 2017-11-13 17:18:48 +0100 |
| commit | 9d5ad230a7558ae9adea42ea69d633d489c6dec0 (patch) | |
| tree | d9ea3ac3b86e98e826c833bb60aff84bcaa9d927 | |
| parent | 95e2f81a149142b67076a3132e1b00d9f64bd031 (diff) | |
| download | meta-updater-9d5ad230a7558ae9adea42ea69d633d489c6dec0.tar.gz | |
Rough draft of a run-qemu-ota test.
Not very useful yet. Could be made into a function for the purpose of
running arbitrary commands via SSH, for example. However, I had plenty
of trouble even getting this far.
Note that I created a softlink to qemucommand to get around the Python
path issues in oe-selftest. I'm not sure if there's a better way to
handle that, since manipulating the path is seemingly impossible.
| -rw-r--r-- | .gitignore | 1 | ||||
| l--------- | lib/oeqa/selftest/qemucommand.py | 1 | ||||
| -rw-r--r-- | lib/oeqa/selftest/updater.py | 33 | ||||
| -rw-r--r-- | scripts/qemucommand.py | 4 |
4 files changed, 37 insertions, 2 deletions
| @@ -1 +1,2 @@ | |||
| 1 | __pycache__ | 1 | __pycache__ |
| 2 | *.pyc | ||
diff --git a/lib/oeqa/selftest/qemucommand.py b/lib/oeqa/selftest/qemucommand.py new file mode 120000 index 0000000..bc06dde --- /dev/null +++ b/lib/oeqa/selftest/qemucommand.py | |||
| @@ -0,0 +1 @@ | |||
| ../../../scripts/qemucommand.py \ No newline at end of file | |||
diff --git a/lib/oeqa/selftest/updater.py b/lib/oeqa/selftest/updater.py index e9048fd..4cdd1a2 100644 --- a/lib/oeqa/selftest/updater.py +++ b/lib/oeqa/selftest/updater.py | |||
| @@ -4,6 +4,9 @@ import logging | |||
| 4 | 4 | ||
| 5 | from oeqa.selftest.base import oeSelfTest | 5 | from oeqa.selftest.base import oeSelfTest |
| 6 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var | 6 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var |
| 7 | import subprocess | ||
| 8 | from oeqa.selftest.qemucommand import QemuCommand | ||
| 9 | import time | ||
| 7 | 10 | ||
| 8 | class UpdaterTests(oeSelfTest): | 11 | class UpdaterTests(oeSelfTest): |
| 9 | 12 | ||
| @@ -39,3 +42,33 @@ class UpdaterTests(oeSelfTest): | |||
| 39 | def test_hsm(self): | 42 | def test_hsm(self): |
| 40 | self.write_config('SOTA_CLIENT_FEATURES="hsm hsm-test"') | 43 | self.write_config('SOTA_CLIENT_FEATURES="hsm hsm-test"') |
| 41 | bitbake('core-image-minimal') | 44 | bitbake('core-image-minimal') |
| 45 | |||
| 46 | def test_qemu(self): | ||
| 47 | print('') | ||
| 48 | # Create empty object. | ||
| 49 | args = type('', (), {})() | ||
| 50 | args.imagename = 'core-image-minimal' | ||
| 51 | args.mac = None | ||
| 52 | args.dir = 'tmp/deploy/images' | ||
| 53 | args.efi = False | ||
| 54 | args.machine = None | ||
| 55 | args.no_kvm = False | ||
| 56 | args.no_gui = True | ||
| 57 | args.gdb = False | ||
| 58 | args.pcap = None | ||
| 59 | args.overlay = None | ||
| 60 | args.dry_run = False | ||
| 61 | |||
| 62 | qemu_command = QemuCommand(args) | ||
| 63 | cmdline = qemu_command.command_line() | ||
| 64 | print('Booting image with run-qemu-ota...') | ||
| 65 | s = subprocess.Popen(cmdline) | ||
| 66 | time.sleep(10) | ||
| 67 | print('Machine name (hostname) of device is:') | ||
| 68 | ssh_cmd = ['ssh', '-q', '-o', 'UserKnownHostsFile=/dev/null', '-o', 'StrictHostKeyChecking=no', 'root@localhost', '-p', str(qemu_command.ssh_port), 'hostname'] | ||
| 69 | s2 = subprocess.Popen(ssh_cmd) | ||
| 70 | time.sleep(5) | ||
| 71 | try: | ||
| 72 | s.terminate() | ||
| 73 | except KeyboardInterrupt: | ||
| 74 | pass | ||
diff --git a/scripts/qemucommand.py b/scripts/qemucommand.py index ed14d9b..a75ffb6 100644 --- a/scripts/qemucommand.py +++ b/scripts/qemucommand.py | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | from os.path import exists, join, realpath | 1 | from os.path import exists, join, realpath, abspath |
| 2 | from os import listdir | 2 | from os import listdir |
| 3 | import random | 3 | import random |
| 4 | import socket | 4 | import socket |
| @@ -49,7 +49,7 @@ class QemuCommand(object): | |||
| 49 | if args.efi: | 49 | if args.efi: |
| 50 | self.bios = 'OVMF.fd' | 50 | self.bios = 'OVMF.fd' |
| 51 | else: | 51 | else: |
| 52 | uboot = join(args.dir, self.machine, 'u-boot-qemux86-64.rom') | 52 | uboot = abspath(join(args.dir, self.machine, 'u-boot-qemux86-64.rom')) |
| 53 | if not exists(uboot): | 53 | if not exists(uboot): |
| 54 | raise ValueError("U-Boot image %s does not exist" % uboot) | 54 | raise ValueError("U-Boot image %s does not exist" % uboot) |
| 55 | self.bios = uboot | 55 | self.bios = uboot |
