summaryrefslogtreecommitdiffstats
path: root/lib/oeqa/selftest/updater.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/oeqa/selftest/updater.py')
-rw-r--r--lib/oeqa/selftest/updater.py125
1 files changed, 125 insertions, 0 deletions
diff --git a/lib/oeqa/selftest/updater.py b/lib/oeqa/selftest/updater.py
new file mode 100644
index 0000000..6339e6e
--- /dev/null
+++ b/lib/oeqa/selftest/updater.py
@@ -0,0 +1,125 @@
1import unittest
2import os
3import logging
4import subprocess
5import time
6
7from oeqa.selftest.base import oeSelfTest
8from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars
9from oeqa.selftest.qemucommand import QemuCommand
10
11
12class SotaToolsTests(oeSelfTest):
13
14 @classmethod
15 def setUpClass(cls):
16 logger = logging.getLogger("selftest")
17 logger.info('Running bitbake to build aktualizr-native tools')
18 bitbake('aktualizr-native')
19
20 def test_push_help(self):
21 bb_vars = get_bb_vars(['SYSROOT_DESTDIR', 'bindir'], 'aktualizr-native')
22 p = bb_vars['SYSROOT_DESTDIR'] + bb_vars['bindir'] + "/" + "garage-push"
23 self.assertTrue(os.path.isfile(p), msg = "No garage-push found (%s)" % p)
24 result = runCmd('%s --help' % p, ignore_status=True)
25 self.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output)
26
27 def test_deploy_help(self):
28 bb_vars = get_bb_vars(['SYSROOT_DESTDIR', 'bindir'], 'aktualizr-native')
29 p = bb_vars['SYSROOT_DESTDIR'] + bb_vars['bindir'] + "/" + "garage-deploy"
30 self.assertTrue(os.path.isfile(p), msg = "No garage-deploy found (%s)" % p)
31 result = runCmd('%s --help' % p, ignore_status=True)
32 self.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output)
33
34
35class GarageSignTests(oeSelfTest):
36
37 @classmethod
38 def setUpClass(cls):
39 logger = logging.getLogger("selftest")
40 logger.info('Running bitbake to build garage-sign-native')
41 bitbake('garage-sign-native')
42
43 def test_help(self):
44 bb_vars = get_bb_vars(['SYSROOT_DESTDIR', 'bindir'], 'garage-sign-native')
45 p = bb_vars['SYSROOT_DESTDIR'] + bb_vars['bindir'] + "/" + "garage-sign"
46 self.assertTrue(os.path.isfile(p), msg = "No garage-sign found (%s)" % p)
47 result = runCmd('%s --help' % p, ignore_status=True)
48 self.assertEqual(result.status, 0, "Status not equal to 0. output: %s" % result.output)
49
50
51class HsmTests(oeSelfTest):
52
53 def test_hsm(self):
54 self.write_config('SOTA_CLIENT_FEATURES="hsm hsm-test"')
55 bitbake('core-image-minimal')
56
57
58class GeneralTests(oeSelfTest):
59
60 def test_java(self):
61 result = runCmd('which java', ignore_status=True)
62 self.assertEqual(result.status, 0, "Java not found.")
63
64 def test_add_package(self):
65 print('')
66 deploydir = get_bb_var('DEPLOY_DIR_IMAGE')
67 imagename = get_bb_var('IMAGE_LINK_NAME', 'core-image-minimal')
68 image_path = deploydir + '/' + imagename + '.otaimg'
69 logger = logging.getLogger("selftest")
70
71 logger.info('Running bitbake with man in the image package list')
72 self.write_config('IMAGE_INSTALL_append = " man "')
73 bitbake('-c cleanall man')
74 bitbake('core-image-minimal')
75 result = runCmd('oe-pkgdata-util find-path /usr/bin/man')
76 self.assertEqual(result.output, 'man: /usr/bin/man')
77 path1 = os.path.realpath(image_path)
78 size1 = os.path.getsize(path1)
79 logger.info('First image %s has size %i' % (path1, size1))
80
81 logger.info('Running bitbake without man in the image package list')
82 self.write_config('IMAGE_INSTALL_remove = " man "')
83 bitbake('-c cleanall man')
84 bitbake('core-image-minimal')
85 result = runCmd('oe-pkgdata-util find-path /usr/bin/man', ignore_status=True)
86 self.assertEqual(result.status, 1, "Status different than 1. output: %s" % result.output)
87 self.assertEqual(result.output, 'ERROR: Unable to find any package producing path /usr/bin/man')
88 path2 = os.path.realpath(image_path)
89 size2 = os.path.getsize(path2)
90 logger.info('Second image %s has size %i' % (path2, size2))
91 self.assertNotEqual(path1, path2, "Image paths are identical; image was not rebuilt.")
92 self.assertNotEqual(size1, size2, "Image sizes are identical; image was not rebuilt.")
93
94 def test_qemu(self):
95 print('')
96 # Create empty object.
97 args = type('', (), {})()
98 args.imagename = 'core-image-minimal'
99 args.mac = None
100 # Could use DEPLOY_DIR_IMAGE her but it's already in the machine
101 # subdirectory.
102 args.dir = 'tmp/deploy/images'
103 args.efi = False
104 args.machine = None
105 args.no_kvm = False
106 args.no_gui = True
107 args.gdb = False
108 args.pcap = None
109 args.overlay = None
110 args.dry_run = False
111
112 qemu_command = QemuCommand(args)
113 cmdline = qemu_command.command_line()
114 print('Booting image with run-qemu-ota...')
115 s = subprocess.Popen(cmdline)
116 time.sleep(10)
117 print('Machine name (hostname) of device is:')
118 ssh_cmd = ['ssh', '-q', '-o', 'UserKnownHostsFile=/dev/null', '-o', 'StrictHostKeyChecking=no', 'root@localhost', '-p', str(qemu_command.ssh_port), 'hostname']
119 s2 = subprocess.Popen(ssh_cmd)
120 time.sleep(5)
121 try:
122 s.terminate()
123 except KeyboardInterrupt:
124 pass
125