summaryrefslogtreecommitdiff
diff options
-rwxr-xr-xbin/cpufreq_test.py28
-rwxr-xr-xbin/cpuid.py2
-rwxr-xr-xbin/ubuntucore_image_checks.py2
-rwxr-xr-xbin/virtualization.py142
-rw-r--r--units/firmware/test-plan.pxu27
-rw-r--r--units/miscellanea/snap-auto-connection.pxu15
-rw-r--r--units/virtualization/jobs.pxu8
7 files changed, 209 insertions, 15 deletions
diff --git a/bin/cpufreq_test.py b/bin/cpufreq_test.py
index ec3cf6c..73fa651 100755
--- a/bin/cpufreq_test.py
+++ b/bin/cpufreq_test.py
@@ -20,7 +20,7 @@
"""Test and validate SUT CPU scaling capabilities via CPUFreq."""
-from os import path
+from os import path, geteuid
import multiprocessing
import collections
import threading
@@ -390,24 +390,29 @@ class CpuFreqTest:
# prove that we are single-threaded again
logging.info('* active threads: %i\n', threading.active_count())
- # display results
- logging.warning('[CpuFreqTest Results]') # for --quiet mode
+ # process, then display results
+ results = self._process_results()
+ # provide time under test for debug/verbose output
+ end_time = time.time() - start_time
+
+ print('[CpuFreqTest Results]')
+ logging.debug('[Test Took: %.3fs]', end_time)
logging.info(
' - legend:\n'
' {core: {target_freq:'
'[sampled_med_%, P/F, sampled_median],:.\n')
- # format result dict for human consumption
- logging.info(
- pprint.pformat(self._process_results()))
- # provide time under test for debug/verbose output
- end_time = time.time() - start_time
- logging.debug('[Test Took: %.3fs]', end_time)
+
if self.fail_count:
+ print(
+ pprint.pformat(results))
print('\n[Test Failed]\n'
'* core fail_count =', self.fail_count)
return 1
+ logging.info(
+ pprint.pformat(results))
print('\n[Test Passed]')
+
return 0
def spawn_core_test(self):
@@ -752,12 +757,17 @@ def parse_arg_logging():
def main():
# configure and start logging
user_arg = parse_arg_logging()
+ # Make sure we're running with root permissions
+ if geteuid() != 0:
+ logging.error('You must be root to run this script')
+ return 1
# instantiate CpuFreqTest as cpu_freq_test
cpu_freq_test = CpuFreqTest()
# provide access to reset() method
if user_arg.reset:
print('[Reset CpuFreq Sysfs]')
return cpu_freq_test.reset()
+
return cpu_freq_test.execute_test()
diff --git a/bin/cpuid.py b/bin/cpuid.py
index 4e1d2da..05a9629 100755
--- a/bin/cpuid.py
+++ b/bin/cpuid.py
@@ -115,7 +115,7 @@ CPUIDS = {
'0x806ea', '0x906ea', '0x906eb', '0x906ec', '0x906ed'],
"Cooper Lake": ['0x5065a', '0x5065b'],
"Haswell": ['0x306c', '0x4065', '0x4066', '0x306f'],
- "Ice Lake": ['0x606e6', '0x606e8', '0x706e'],
+ "Ice Lake": ['0x606e6', '0x606a6', '0x706e6'],
"Ivy Bridge": ['0x306a', '0x306e'],
"Kaby Lake": ['0x806e9', '0x906e9'],
"Knights Landing": ['0x5067'],
diff --git a/bin/ubuntucore_image_checks.py b/bin/ubuntucore_image_checks.py
index 214fc42..a7866dc 100755
--- a/bin/ubuntucore_image_checks.py
+++ b/bin/ubuntucore_image_checks.py
@@ -107,7 +107,7 @@ def main():
elif action == 'model-authority':
modelinfo.test_model_authority()
elif action == 'model-brand':
- modelinfo.test_model_authority()
+ modelinfo.test_model_brand()
else:
raise SystemExit('ERROR: unrecognised action')
diff --git a/bin/virtualization.py b/bin/virtualization.py
index 10b827b..939a8a6 100755
--- a/bin/virtualization.py
+++ b/bin/virtualization.py
@@ -531,6 +531,123 @@ class RunCommand(object):
self.returncode = proc.returncode
+class UVTKVMTest(object):
+
+ def __init__(self, image=None):
+ self.image = image
+ self.release = lsb_release.get_distro_information()["CODENAME"]
+ self.arch = check_output(['dpkg', '--print-architecture'],
+ universal_newlines=True).strip()
+ self.name = tempfile.mktemp()[5:]
+
+ def run_command(self, cmd):
+ task = RunCommand(cmd)
+ if task.returncode != 0:
+ logging.error('Command {} returnd a code of {}'.format(
+ task.cmd, task.returncode))
+ logging.error(' STDOUT: {}'.format(task.stdout))
+ logging.error(' STDERR: {}'.format(task.stderr))
+ return False
+ else:
+ logging.debug('Command {}:'.format(task.cmd))
+ if task.stdout != '':
+ logging.debug(' STDOUT: {}'.format(task.stdout))
+ elif task.stderr != '':
+ logging.debug(' STDERR: {}'.format(task.stderr))
+ else:
+ logging.debug(' Command returned no output')
+ return True
+
+ def get_image_or_source(self):
+ """
+ An image can be specifed in a filesytem path and used directly in
+ uvt-create with the backing-image option or a url can be
+ specifed and used in uvt-simpletreams to generate an image.
+ """
+ url = urlparse(self.image)
+
+ if url.scheme == 'file':
+ logging.debug("Cloud image exists locally at %s" % url.path)
+ self.image = url.path
+ else:
+ cmd = ("uvt-simplestreams-libvirt sync release={} "
+ "arch={}".format(self.release, self.arch))
+
+ if url.scheme == 'http':
+ # Path specified to use -source option
+ logging.debug("Using --source option for uvt-simpletreams")
+ cmd = cmd + " --source {} ".format(self.image)
+
+ logging.debug("uvt-simplestreams-libvirt sync")
+ if not self.run_command(cmd):
+ return False
+ return True
+
+ def cleanup(self):
+ """
+ A combination of virsh destroy/undefine is used instead of
+ uvt-kvm destroy. When using uvt-kvm destroy the following bug
+ is seen:
+ https://bugs.launchpad.net/ubuntu/+source/uvtool/+bug/1452095
+ """
+ # Destroy vm
+ logging.debug("Destroy VM")
+ if not self.run_command('virsh destroy {}'.format(self.name)):
+ return False
+
+ # Virsh undefine
+ logging.debug("Undefine VM")
+ if not self.run_command('virsh undefine {}'.format(self.name)):
+ return False
+
+ # Purge/Remove simplestreams image
+ if not self.run_command("uvt-simplestreams-libvirt purge"):
+ return False
+ return True
+
+ def start(self):
+ # Generate ssh key if needed
+ home_dir = os.environ['HOME']
+ ssh_key_file = "{}/.ssh/id_rsa".format(home_dir)
+
+ if not os.path.exists(ssh_key_file):
+ self.run_command("mkdir -p {}/.ssh".format(home_dir))
+
+ cmd = ('ssh-keygen -f {} -t rsa -N \'\''.format(ssh_key_file))
+ if not self.run_command(cmd):
+ return False
+
+ # Create vm
+ logging.debug("Creating VM")
+ cmd = ('uvt-kvm create {} arch={}'.format(self.name, self.arch))
+
+ if self.image.find(".img") > 0:
+ cmd = cmd + " --backing-image-file {} ".format(self.image)
+
+ if not self.run_command(cmd):
+ return False
+
+ logging.debug("Wait for VM to complete creation")
+ if not self.run_command('uvt-kvm wait {}'.format(self.name)):
+ return False
+
+ logging.debug("List newly created vm")
+ cmd = ("uvt-kvm list")
+ if not self.run_command(cmd):
+ return False
+
+ logging.debug("Verify VM was created with ssh")
+ if not self.run_command('uvt-kvm ssh {}'.format(self.name)):
+ return False
+
+ logging.debug("Verify VM was created with ssh and run a command")
+ if not self.run_command('uvt-kvm ssh {} \"lsb_release -a \"'
+ .format(self.name)):
+ return False
+
+ return True
+
+
class LXDTest(object):
def __init__(self, template=None, rootfs=None):
@@ -696,6 +813,24 @@ class LXDTest(object):
return True
+def test_uvtkvm(args):
+ logging.debug("Executing UVT KVM Test")
+
+ image = args.image or os.environ['UVT_IMAGE_OR_SOURCE']
+
+ uvt_test = UVTKVMTest(image)
+ uvt_test.get_image_or_source()
+ result = uvt_test.start()
+ uvt_test.cleanup()
+
+ if result:
+ print("PASS: VM was succssfully started and checked")
+ sys.exit(0)
+ else:
+ print("FAIL: VM was not started and/or checked")
+ sys.exit(1)
+
+
def test_lxd(args):
logging.debug("Executing LXD Test")
@@ -770,6 +905,8 @@ def main():
# Main cli options
kvm_test_parser = subparsers.add_parser(
'kvm', help=("Run kvm virtualization test"))
+ uvt_kvm_test_parser = subparsers.add_parser(
+ 'uvt', help=("Run uvt kvm virtualization test"))
lxd_test_parser = subparsers.add_parser(
'lxd', help=("Run the LXD validation test"))
parser.add_argument('--debug', dest='log_level',
@@ -786,6 +923,11 @@ def main():
help="Location for debugging output log. Defaults to %(default)s.")
kvm_test_parser.set_defaults(func=test_kvm)
+ # Sub test options
+ uvt_kvm_test_parser.add_argument(
+ '-i', '--image', type=str)
+ uvt_kvm_test_parser.set_defaults(func=test_uvtkvm)
+
lxd_test_parser.add_argument(
'--template', type=str, default=None)
lxd_test_parser.add_argument(
diff --git a/units/firmware/test-plan.pxu b/units/firmware/test-plan.pxu
index 1765ced..7db724d 100644
--- a/units/firmware/test-plan.pxu
+++ b/units/firmware/test-plan.pxu
@@ -36,3 +36,30 @@ include:
firmware/tcglog-required-algs-sha256
firmware/tcglog-require-pe-image-digests
firmware/tcglog-dump-attachment
+
+
+id: iot-fwts-full
+unit: test plan
+_name: Test fwts diagnosis with iot project
+_description: Test fwts diagnosis with iot project
+include:
+nested_part:
+ iot-fwts-manual
+ iot-fwts-automated
+
+
+id: iot-fwts-manual
+unit: test plan
+_name: Test fwts diagnosis with iot project (manual)
+_description: Test fwts diagnosis with project (manual)
+include:
+
+
+id: iot-fwts-automated
+unit: test plan
+_name: Test fwts diagnosis with iot project (automated)
+_description: Test fwts diagnosis with iot project (automated)
+include:
+ firmware/fwts_desktop_diagnosis
+ firmware/fwts_desktop_diagnosis_results.log.gz
+
diff --git a/units/miscellanea/snap-auto-connection.pxu b/units/miscellanea/snap-auto-connection.pxu
new file mode 100644
index 0000000..1dee3f3
--- /dev/null
+++ b/units/miscellanea/snap-auto-connection.pxu
@@ -0,0 +1,15 @@
+# This template job can be used to check any required snap interface connections.
+# For example, if you wish to check that the "home"
+# plug of the "multipass" snap is connected to a corresponding slot,
+# simply run the job com.canonical.certification::miscellanea/check-plug_multipass_home
+unit: template
+template-engine: jinja2
+template-resource: interface
+template-filter: interface.type == 'plug'
+id: miscellanea/check-plug_{{ snap }}_{{ name }}
+_summary: Ensure the {{ snap }} snap's {{ name }} plug is connected
+plugin: shell
+command:
+ plug_connected_test.py {{ snap }} {{ name }}
+category_id: com.canonical.plainbox::miscellanea
+estimated_duration: 1.0
diff --git a/units/virtualization/jobs.pxu b/units/virtualization/jobs.pxu
index 9471031..2b6fd99 100644
--- a/units/virtualization/jobs.pxu
+++ b/units/virtualization/jobs.pxu
@@ -2,13 +2,13 @@ plugin: shell
category_id: com.canonical.plainbox::virtualization
id: virtualization/kvm_check_vm
user: root
-environ: KVM_TIMEOUT KVM_IMAGE http_proxy https_proxy
+environ: UVT_IMAGE_OR_SOURCE http_proxy https_proxy
estimated_duration: 300.0
requires:
- package.name == 'qemu-system'
- package.name == 'qemu-utils'
+ package.name == 'uvtool'
+ package.name == 'uvtool-libvirt'
virtualization.kvm == 'supported'
-command: virtualization.py --debug kvm --log-file="$PLAINBOX_SESSION_SHARE"/virt_debug
+command: virtualization.py --debug uvt
_description:
Verifies that a KVM guest can be created and booted using an Ubuntu Server
cloud image.