summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/runtime')
-rw-r--r--meta/lib/oeqa/runtime/cases/date.py13
-rw-r--r--meta/lib/oeqa/runtime/cases/ethernet_ip_connman.py36
-rw-r--r--meta/lib/oeqa/runtime/cases/ksample.py2
-rw-r--r--meta/lib/oeqa/runtime/cases/ltp.py2
-rw-r--r--meta/lib/oeqa/runtime/cases/pam.py3
-rw-r--r--meta/lib/oeqa/runtime/cases/parselogs.py21
-rw-r--r--meta/lib/oeqa/runtime/cases/ping.py20
-rw-r--r--meta/lib/oeqa/runtime/cases/rpm.py32
-rw-r--r--meta/lib/oeqa/runtime/cases/rtc.py40
-rw-r--r--meta/lib/oeqa/runtime/cases/scp.py2
-rw-r--r--meta/lib/oeqa/runtime/cases/suspend.py33
-rw-r--r--meta/lib/oeqa/runtime/cases/terminal.py21
-rw-r--r--meta/lib/oeqa/runtime/cases/usb_hid.py22
-rw-r--r--meta/lib/oeqa/runtime/context.py33
14 files changed, 214 insertions, 66 deletions
diff --git a/meta/lib/oeqa/runtime/cases/date.py b/meta/lib/oeqa/runtime/cases/date.py
index fdd2a6ae58..bd6537400e 100644
--- a/meta/lib/oeqa/runtime/cases/date.py
+++ b/meta/lib/oeqa/runtime/cases/date.py
@@ -13,12 +13,12 @@ class DateTest(OERuntimeTestCase):
13 def setUp(self): 13 def setUp(self):
14 if self.tc.td.get('VIRTUAL-RUNTIME_init_manager') == 'systemd': 14 if self.tc.td.get('VIRTUAL-RUNTIME_init_manager') == 'systemd':
15 self.logger.debug('Stopping systemd-timesyncd daemon') 15 self.logger.debug('Stopping systemd-timesyncd daemon')
16 self.target.run('systemctl disable --now systemd-timesyncd') 16 self.target.run('systemctl disable --now --runtime systemd-timesyncd')
17 17
18 def tearDown(self): 18 def tearDown(self):
19 if self.tc.td.get('VIRTUAL-RUNTIME_init_manager') == 'systemd': 19 if self.tc.td.get('VIRTUAL-RUNTIME_init_manager') == 'systemd':
20 self.logger.debug('Starting systemd-timesyncd daemon') 20 self.logger.debug('Starting systemd-timesyncd daemon')
21 self.target.run('systemctl enable --now systemd-timesyncd') 21 self.target.run('systemctl enable --now --runtime systemd-timesyncd')
22 22
23 @OETestDepends(['ssh.SSHTest.test_ssh']) 23 @OETestDepends(['ssh.SSHTest.test_ssh'])
24 @OEHasPackage(['coreutils', 'busybox']) 24 @OEHasPackage(['coreutils', 'busybox'])
@@ -28,14 +28,13 @@ class DateTest(OERuntimeTestCase):
28 self.assertEqual(status, 0, msg=msg) 28 self.assertEqual(status, 0, msg=msg)
29 oldDate = output 29 oldDate = output
30 30
31 sampleDate = '"2016-08-09 10:00:00"' 31 sampleTimestamp = 1488800000
32 (status, output) = self.target.run("date -s %s" % sampleDate) 32 (status, output) = self.target.run("date -s @%d" % sampleTimestamp)
33 self.assertEqual(status, 0, msg='Date set failed, output: %s' % output) 33 self.assertEqual(status, 0, msg='Date set failed, output: %s' % output)
34 34
35 (status, output) = self.target.run("date -R") 35 (status, output) = self.target.run('date +"%s"')
36 p = re.match('Tue, 09 Aug 2016 10:00:.. \+0000', output)
37 msg = 'The date was not set correctly, output: %s' % output 36 msg = 'The date was not set correctly, output: %s' % output
38 self.assertTrue(p, msg=msg) 37 self.assertTrue(int(output) - sampleTimestamp < 300, msg=msg)
39 38
40 (status, output) = self.target.run('date -s "%s"' % oldDate) 39 (status, output) = self.target.run('date -s "%s"' % oldDate)
41 msg = 'Failed to reset date, output: %s' % output 40 msg = 'Failed to reset date, output: %s' % output
diff --git a/meta/lib/oeqa/runtime/cases/ethernet_ip_connman.py b/meta/lib/oeqa/runtime/cases/ethernet_ip_connman.py
new file mode 100644
index 0000000000..e010612838
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/ethernet_ip_connman.py
@@ -0,0 +1,36 @@
1from oeqa.runtime.case import OERuntimeTestCase
2from oeqa.core.decorator.depends import OETestDepends
3from oeqa.core.decorator.data import skipIfQemu
4
5class Ethernet_Test(OERuntimeTestCase):
6
7 def set_ip(self, x):
8 x = x.split(".")
9 sample_host_address = '150'
10 x[3] = sample_host_address
11 x = '.'.join(x)
12 return x
13
14 @skipIfQemu('qemuall', 'Test only runs on real hardware')
15 @OETestDepends(['ssh.SSHTest.test_ssh'])
16 def test_set_virtual_ip(self):
17 (status, output) = self.target.run("ifconfig eth0 | grep 'inet ' | awk '{print $2}'")
18 self.assertEqual(status, 0, msg='Failed to get ip address. Make sure you have an ethernet connection on your device, output: %s' % output)
19 original_ip = output
20 virtual_ip = self.set_ip(original_ip)
21
22 (status, output) = self.target.run("ifconfig eth0:1 %s netmask 255.255.255.0 && sleep 2 && ping -c 5 %s && ifconfig eth0:1 down" % (virtual_ip,virtual_ip))
23 self.assertEqual(status, 0, msg='Failed to create virtual ip address, output: %s' % output)
24
25 @OETestDepends(['ethernet_ip_connman.Ethernet_Test.test_set_virtual_ip'])
26 def test_get_ip_from_dhcp(self):
27 (status, output) = self.target.run("connmanctl services | grep -E '*AO Wired|*AR Wired' | awk '{print $3}'")
28 self.assertEqual(status, 0, msg='No wired interfaces are detected, output: %s' % output)
29 wired_interfaces = output
30
31 (status, output) = self.target.run("ip route | grep default | awk '{print $3}'")
32 self.assertEqual(status, 0, msg='Failed to retrieve the default gateway, output: %s' % output)
33 default_gateway = output
34
35 (status, output) = self.target.run("connmanctl config %s --ipv4 dhcp && sleep 2 && ping -c 5 %s" % (wired_interfaces,default_gateway))
36 self.assertEqual(status, 0, msg='Failed to get dynamic IP address via DHCP in connmand, output: %s' % output) \ No newline at end of file
diff --git a/meta/lib/oeqa/runtime/cases/ksample.py b/meta/lib/oeqa/runtime/cases/ksample.py
index a9a1620ebd..9883aa9aa8 100644
--- a/meta/lib/oeqa/runtime/cases/ksample.py
+++ b/meta/lib/oeqa/runtime/cases/ksample.py
@@ -10,7 +10,7 @@ from oeqa.core.decorator.depends import OETestDepends
10from oeqa.core.decorator.data import skipIfNotFeature 10from oeqa.core.decorator.data import skipIfNotFeature
11 11
12# need some kernel fragments 12# need some kernel fragments
13# echo "KERNEL_FEATURES_append += \" features\/kernel\-sample\/kernel\-sample.scc\"" >> local.conf 13# echo "KERNEL_FEATURES_append = \" features\/kernel\-sample\/kernel\-sample.scc\"" >> local.conf
14class KSample(OERuntimeTestCase): 14class KSample(OERuntimeTestCase):
15 def cmd_and_check(self, cmd='', match_string=''): 15 def cmd_and_check(self, cmd='', match_string=''):
16 status, output = self.target.run(cmd) 16 status, output = self.target.run(cmd)
diff --git a/meta/lib/oeqa/runtime/cases/ltp.py b/meta/lib/oeqa/runtime/cases/ltp.py
index a66d5d13d7..879f2a673c 100644
--- a/meta/lib/oeqa/runtime/cases/ltp.py
+++ b/meta/lib/oeqa/runtime/cases/ltp.py
@@ -67,7 +67,7 @@ class LtpTest(LtpTestBase):
67 def runltp(self, ltp_group): 67 def runltp(self, ltp_group):
68 cmd = '/opt/ltp/runltp -f %s -p -q -r /opt/ltp -l /opt/ltp/results/%s -I 1 -d /opt/ltp' % (ltp_group, ltp_group) 68 cmd = '/opt/ltp/runltp -f %s -p -q -r /opt/ltp -l /opt/ltp/results/%s -I 1 -d /opt/ltp' % (ltp_group, ltp_group)
69 starttime = time.time() 69 starttime = time.time()
70 (status, output) = self.target.run(cmd) 70 (status, output) = self.target.run(cmd, timeout=1200)
71 endtime = time.time() 71 endtime = time.time()
72 72
73 with open(os.path.join(self.ltptest_log_dir, "%s-raw.log" % ltp_group), 'w') as f: 73 with open(os.path.join(self.ltptest_log_dir, "%s-raw.log" % ltp_group), 'w') as f:
diff --git a/meta/lib/oeqa/runtime/cases/pam.py b/meta/lib/oeqa/runtime/cases/pam.py
index 271a1943e3..a482ded945 100644
--- a/meta/lib/oeqa/runtime/cases/pam.py
+++ b/meta/lib/oeqa/runtime/cases/pam.py
@@ -8,11 +8,14 @@
8from oeqa.runtime.case import OERuntimeTestCase 8from oeqa.runtime.case import OERuntimeTestCase
9from oeqa.core.decorator.depends import OETestDepends 9from oeqa.core.decorator.depends import OETestDepends
10from oeqa.core.decorator.data import skipIfNotFeature 10from oeqa.core.decorator.data import skipIfNotFeature
11from oeqa.runtime.decorator.package import OEHasPackage
11 12
12class PamBasicTest(OERuntimeTestCase): 13class PamBasicTest(OERuntimeTestCase):
13 14
14 @skipIfNotFeature('pam', 'Test requires pam to be in DISTRO_FEATURES') 15 @skipIfNotFeature('pam', 'Test requires pam to be in DISTRO_FEATURES')
15 @OETestDepends(['ssh.SSHTest.test_ssh']) 16 @OETestDepends(['ssh.SSHTest.test_ssh'])
17 @OEHasPackage(['shadow'])
18 @OEHasPackage(['shadow-base'])
16 def test_pam(self): 19 def test_pam(self):
17 status, output = self.target.run('login --help') 20 status, output = self.target.run('login --help')
18 msg = ('login command does not work as expected. ' 21 msg = ('login command does not work as expected. '
diff --git a/meta/lib/oeqa/runtime/cases/parselogs.py b/meta/lib/oeqa/runtime/cases/parselogs.py
index a1791b5cca..1cac59725d 100644
--- a/meta/lib/oeqa/runtime/cases/parselogs.py
+++ b/meta/lib/oeqa/runtime/cases/parselogs.py
@@ -32,7 +32,7 @@ common_errors = [
32 "Failed to load module \"fbdev\"", 32 "Failed to load module \"fbdev\"",
33 "Failed to load module fbdev", 33 "Failed to load module fbdev",
34 "Failed to load module glx", 34 "Failed to load module glx",
35 "[drm] Cannot find any crtc or sizes - going 1024x768", 35 "[drm] Cannot find any crtc or sizes",
36 "_OSC failed (AE_NOT_FOUND); disabling ASPM", 36 "_OSC failed (AE_NOT_FOUND); disabling ASPM",
37 "Open ACPI failed (/var/run/acpid.socket) (No such file or directory)", 37 "Open ACPI failed (/var/run/acpid.socket) (No such file or directory)",
38 "NX (Execute Disable) protection cannot be enabled: non-PAE kernel!", 38 "NX (Execute Disable) protection cannot be enabled: non-PAE kernel!",
@@ -61,6 +61,8 @@ common_errors = [
61 "[rdrand]: Initialization Failed", 61 "[rdrand]: Initialization Failed",
62 "[pulseaudio] authkey.c: Failed to open cookie file", 62 "[pulseaudio] authkey.c: Failed to open cookie file",
63 "[pulseaudio] authkey.c: Failed to load authentication key", 63 "[pulseaudio] authkey.c: Failed to load authentication key",
64 "was skipped because of a failed condition check",
65 "was skipped because all trigger condition checks failed",
64 ] 66 ]
65 67
66video_related = [ 68video_related = [
@@ -88,6 +90,9 @@ qemux86_common = [
88 'tsc: HPET/PMTIMER calibration failed', 90 'tsc: HPET/PMTIMER calibration failed',
89 "modeset(0): Failed to initialize the DRI2 extension", 91 "modeset(0): Failed to initialize the DRI2 extension",
90 "glamor initialization failed", 92 "glamor initialization failed",
93 "blk_update_request: I/O error, dev fd0, sector 0 op 0x0:(READ)",
94 "floppy: error",
95 'failed to IDENTIFY (I/O error, err_mask=0x4)',
91] + common_errors 96] + common_errors
92 97
93ignore_errors = { 98ignore_errors = {
@@ -293,7 +298,7 @@ class ParseLogsTest(OERuntimeTestCase):
293 grepcmd = 'grep ' 298 grepcmd = 'grep '
294 grepcmd += '-Ei "' 299 grepcmd += '-Ei "'
295 for error in errors: 300 for error in errors:
296 grepcmd += '\<' + error + '\>' + '|' 301 grepcmd += r'\<' + error + r'\>' + '|'
297 grepcmd = grepcmd[:-1] 302 grepcmd = grepcmd[:-1]
298 grepcmd += '" ' + str(log) + " | grep -Eiv \'" 303 grepcmd += '" ' + str(log) + " | grep -Eiv \'"
299 304
@@ -304,13 +309,13 @@ class ParseLogsTest(OERuntimeTestCase):
304 errorlist = ignore_errors['default'] 309 errorlist = ignore_errors['default']
305 310
306 for ignore_error in errorlist: 311 for ignore_error in errorlist:
307 ignore_error = ignore_error.replace('(', '\(') 312 ignore_error = ignore_error.replace('(', r'\(')
308 ignore_error = ignore_error.replace(')', '\)') 313 ignore_error = ignore_error.replace(')', r'\)')
309 ignore_error = ignore_error.replace("'", '.') 314 ignore_error = ignore_error.replace("'", '.')
310 ignore_error = ignore_error.replace('?', '\?') 315 ignore_error = ignore_error.replace('?', r'\?')
311 ignore_error = ignore_error.replace('[', '\[') 316 ignore_error = ignore_error.replace('[', r'\[')
312 ignore_error = ignore_error.replace(']', '\]') 317 ignore_error = ignore_error.replace(']', r'\]')
313 ignore_error = ignore_error.replace('*', '\*') 318 ignore_error = ignore_error.replace('*', r'\*')
314 ignore_error = ignore_error.replace('0-9', '[0-9]') 319 ignore_error = ignore_error.replace('0-9', '[0-9]')
315 grepcmd += ignore_error + '|' 320 grepcmd += ignore_error + '|'
316 grepcmd = grepcmd[:-1] 321 grepcmd = grepcmd[:-1]
diff --git a/meta/lib/oeqa/runtime/cases/ping.py b/meta/lib/oeqa/runtime/cases/ping.py
index f6603f75ec..498f80d0a5 100644
--- a/meta/lib/oeqa/runtime/cases/ping.py
+++ b/meta/lib/oeqa/runtime/cases/ping.py
@@ -6,6 +6,7 @@ from subprocess import Popen, PIPE
6 6
7from oeqa.runtime.case import OERuntimeTestCase 7from oeqa.runtime.case import OERuntimeTestCase
8from oeqa.core.decorator.oetimeout import OETimeout 8from oeqa.core.decorator.oetimeout import OETimeout
9from oeqa.core.exception import OEQATimeoutError
9 10
10class PingTest(OERuntimeTestCase): 11class PingTest(OERuntimeTestCase):
11 12
@@ -13,14 +14,17 @@ class PingTest(OERuntimeTestCase):
13 def test_ping(self): 14 def test_ping(self):
14 output = '' 15 output = ''
15 count = 0 16 count = 0
16 while count < 5: 17 try:
17 cmd = 'ping -c 1 %s' % self.target.ip 18 while count < 5:
18 proc = Popen(cmd, shell=True, stdout=PIPE) 19 cmd = 'ping -c 1 %s' % self.target.ip
19 output += proc.communicate()[0].decode('utf-8') 20 proc = Popen(cmd, shell=True, stdout=PIPE)
20 if proc.poll() == 0: 21 output += proc.communicate()[0].decode('utf-8')
21 count += 1 22 if proc.poll() == 0:
22 else: 23 count += 1
23 count = 0 24 else:
25 count = 0
26 except OEQATimeoutError:
27 self.fail("Ping timeout error for address %s, count %s, output: %s" % (self.target.ip, count, output))
24 msg = ('Expected 5 consecutive, got %d.\n' 28 msg = ('Expected 5 consecutive, got %d.\n'
25 'ping output is:\n%s' % (count,output)) 29 'ping output is:\n%s' % (count,output))
26 self.assertEqual(count, 5, msg = msg) 30 self.assertEqual(count, 5, msg = msg)
diff --git a/meta/lib/oeqa/runtime/cases/rpm.py b/meta/lib/oeqa/runtime/cases/rpm.py
index 8e18b426f8..203fcc8505 100644
--- a/meta/lib/oeqa/runtime/cases/rpm.py
+++ b/meta/lib/oeqa/runtime/cases/rpm.py
@@ -49,21 +49,20 @@ class RpmBasicTest(OERuntimeTestCase):
49 msg = 'status: %s. Cannot run rpm -qa: %s' % (status, output) 49 msg = 'status: %s. Cannot run rpm -qa: %s' % (status, output)
50 self.assertEqual(status, 0, msg=msg) 50 self.assertEqual(status, 0, msg=msg)
51 51
52 def check_no_process_for_user(u): 52 def wait_for_no_process_for_user(u, timeout = 120):
53 _, output = self.target.run(self.tc.target_cmds['ps']) 53 timeout_at = time.time() + timeout
54 if u + ' ' in output: 54 while time.time() < timeout_at:
55 return False 55 _, output = self.target.run(self.tc.target_cmds['ps'])
56 else: 56 if u + ' ' not in output:
57 return True 57 return
58 time.sleep(1)
59 user_pss = [ps for ps in output.split("\n") if u + ' ' in ps]
60 msg = "User %s has processes still running: %s" % (u, "\n".join(user_pss))
61 self.fail(msg=msg)
58 62
59 def unset_up_test_user(u): 63 def unset_up_test_user(u):
60 # ensure no test1 process in running 64 # ensure no test1 process in running
61 timeout = time.time() + 30 65 wait_for_no_process_for_user(u)
62 while time.time() < timeout:
63 if check_no_process_for_user(u):
64 break
65 else:
66 time.sleep(1)
67 status, output = self.target.run('userdel -r %s' % u) 66 status, output = self.target.run('userdel -r %s' % u)
68 msg = 'Failed to erase user: %s' % output 67 msg = 'Failed to erase user: %s' % output
69 self.assertTrue(status == 0, msg=msg) 68 self.assertTrue(status == 0, msg=msg)
@@ -141,13 +140,4 @@ class RpmInstallRemoveTest(OERuntimeTestCase):
141 140
142 self.tc.target.run('rm -f %s' % self.dst) 141 self.tc.target.run('rm -f %s' % self.dst)
143 142
144 # if using systemd this should ensure all entries are flushed to /var
145 status, output = self.target.run("journalctl --sync")
146 # Get the amount of entries in the log file
147 status, output = self.target.run(check_log_cmd)
148 msg = 'Failed to get the final size of the log file.'
149 self.assertEqual(0, status, msg=msg)
150 143
151 # Check that there's enough of them
152 self.assertGreaterEqual(int(output), 80,
153 'Cound not find sufficient amount of rpm entries in /var/log/messages, found {} entries'.format(output))
diff --git a/meta/lib/oeqa/runtime/cases/rtc.py b/meta/lib/oeqa/runtime/cases/rtc.py
new file mode 100644
index 0000000000..39f4d29f23
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/rtc.py
@@ -0,0 +1,40 @@
1from oeqa.runtime.case import OERuntimeTestCase
2from oeqa.core.decorator.depends import OETestDepends
3from oeqa.core.decorator.data import skipIfFeature
4from oeqa.runtime.decorator.package import OEHasPackage
5
6import re
7
8class RTCTest(OERuntimeTestCase):
9
10 def setUp(self):
11 if self.tc.td.get('VIRTUAL-RUNTIME_init_manager') == 'systemd':
12 self.logger.debug('Stopping systemd-timesyncd daemon')
13 self.target.run('systemctl disable --now --runtime systemd-timesyncd')
14
15 def tearDown(self):
16 if self.tc.td.get('VIRTUAL-RUNTIME_init_manager') == 'systemd':
17 self.logger.debug('Starting systemd-timesyncd daemon')
18 self.target.run('systemctl enable --now --runtime systemd-timesyncd')
19
20 @skipIfFeature('read-only-rootfs',
21 'Test does not work with read-only-rootfs in IMAGE_FEATURES')
22 @OETestDepends(['ssh.SSHTest.test_ssh'])
23 @OEHasPackage(['coreutils', 'busybox'])
24 def test_rtc(self):
25 (status, output) = self.target.run('hwclock -r')
26 self.assertEqual(status, 0, msg='Failed to get RTC time, output: %s' % output)
27
28 (status, current_datetime) = self.target.run('date +"%m%d%H%M%Y"')
29 self.assertEqual(status, 0, msg='Failed to get system current date & time, output: %s' % current_datetime)
30
31 example_datetime = '062309452008'
32 (status, output) = self.target.run('date %s ; hwclock -w ; hwclock -r' % example_datetime)
33 check_hwclock = re.search('2008-06-23 09:45:..', output)
34 self.assertTrue(check_hwclock, msg='The RTC time was not set correctly, output: %s' % output)
35
36 (status, output) = self.target.run('date %s' % current_datetime)
37 self.assertEqual(status, 0, msg='Failed to reset system date & time, output: %s' % output)
38
39 (status, output) = self.target.run('hwclock -w')
40 self.assertEqual(status, 0, msg='Failed to reset RTC time, output: %s' % output)
diff --git a/meta/lib/oeqa/runtime/cases/scp.py b/meta/lib/oeqa/runtime/cases/scp.py
index 3a5f292152..f2bbc947d6 100644
--- a/meta/lib/oeqa/runtime/cases/scp.py
+++ b/meta/lib/oeqa/runtime/cases/scp.py
@@ -23,7 +23,7 @@ class ScpTest(OERuntimeTestCase):
23 os.remove(cls.tmp_path) 23 os.remove(cls.tmp_path)
24 24
25 @OETestDepends(['ssh.SSHTest.test_ssh']) 25 @OETestDepends(['ssh.SSHTest.test_ssh'])
26 @OEHasPackage(['openssh-scp', 'dropbear']) 26 @OEHasPackage(['openssh-scp'])
27 def test_scp_file(self): 27 def test_scp_file(self):
28 dst = '/tmp/test_scp_file' 28 dst = '/tmp/test_scp_file'
29 29
diff --git a/meta/lib/oeqa/runtime/cases/suspend.py b/meta/lib/oeqa/runtime/cases/suspend.py
new file mode 100644
index 0000000000..67b6f7e56f
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/suspend.py
@@ -0,0 +1,33 @@
1from oeqa.runtime.case import OERuntimeTestCase
2from oeqa.core.decorator.depends import OETestDepends
3from oeqa.core.decorator.data import skipIfQemu
4import threading
5import time
6
7class Suspend_Test(OERuntimeTestCase):
8
9 def test_date(self):
10 (status, output) = self.target.run('date')
11 self.assertEqual(status, 0, msg = 'Failed to run date command, output : %s' % output)
12
13 def test_ping(self):
14 t_thread = threading.Thread(target=self.target.run, args=("ping 8.8.8.8",))
15 t_thread.start()
16 time.sleep(2)
17
18 status, output = self.target.run('pidof ping')
19 self.target.run('kill -9 %s' % output)
20 self.assertEqual(status, 0, msg = 'Not able to find process that runs ping, output : %s' % output)
21
22 def set_suspend(self):
23 (status, output) = self.target.run('sudo rtcwake -m mem -s 10')
24 self.assertEqual(status, 0, msg = 'Failed to suspends your system to RAM, output : %s' % output)
25
26 @skipIfQemu('qemuall', 'Test only runs on real hardware')
27 @OETestDepends(['ssh.SSHTest.test_ssh'])
28 def test_suspend(self):
29 self.test_date()
30 self.test_ping()
31 self.set_suspend()
32 self.test_date()
33 self.test_ping()
diff --git a/meta/lib/oeqa/runtime/cases/terminal.py b/meta/lib/oeqa/runtime/cases/terminal.py
new file mode 100644
index 0000000000..8fcca99f47
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/terminal.py
@@ -0,0 +1,21 @@
1from oeqa.runtime.case import OERuntimeTestCase
2from oeqa.core.decorator.depends import OETestDepends
3from oeqa.runtime.decorator.package import OEHasPackage
4
5import threading
6import time
7
8class TerminalTest(OERuntimeTestCase):
9
10 @OEHasPackage(['matchbox-terminal'])
11 @OETestDepends(['ssh.SSHTest.test_ssh'])
12 def test_terminal_running(self):
13 t_thread = threading.Thread(target=self.target.run, args=("export DISPLAY=:0 && matchbox-terminal -e 'sh -c \"uname -a && exec sh\"'",))
14 t_thread.start()
15 time.sleep(2)
16
17 status, output = self.target.run('pidof matchbox-terminal')
18 number_of_terminal = len(output.split())
19 self.assertEqual(number_of_terminal, 1, msg='There should be only one terminal being launched. Number of terminal launched : %s' % number_of_terminal)
20 self.target.run('kill -9 %s' % output)
21 self.assertEqual(status, 0, msg='Not able to find process that runs terminal.')
diff --git a/meta/lib/oeqa/runtime/cases/usb_hid.py b/meta/lib/oeqa/runtime/cases/usb_hid.py
new file mode 100644
index 0000000000..3c292cf661
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/usb_hid.py
@@ -0,0 +1,22 @@
1from oeqa.runtime.case import OERuntimeTestCase
2from oeqa.core.decorator.depends import OETestDepends
3from oeqa.core.decorator.data import skipIfQemu
4from oeqa.runtime.decorator.package import OEHasPackage
5
6class USB_HID_Test(OERuntimeTestCase):
7
8 def keyboard_mouse_simulation(self):
9 (status, output) = self.target.run('export DISPLAY=:0 && xdotool key F2 && xdotool mousemove 100 100')
10 return self.assertEqual(status, 0, msg = 'Failed to simulate keyboard/mouse input event, output : %s' % output)
11
12 def set_suspend(self):
13 (status, output) = self.target.run('sudo rtcwake -m mem -s 10')
14 return self.assertEqual(status, 0, msg = 'Failed to suspends your system to RAM, output : %s' % output)
15
16 @OEHasPackage(['xdotool'])
17 @skipIfQemu('qemuall', 'Test only runs on real hardware')
18 @OETestDepends(['ssh.SSHTest.test_ssh'])
19 def test_USB_Hid_input(self):
20 self.keyboard_mouse_simulation()
21 self.set_suspend()
22 self.keyboard_mouse_simulation()
diff --git a/meta/lib/oeqa/runtime/context.py b/meta/lib/oeqa/runtime/context.py
index 3826f27642..8a0dbd0736 100644
--- a/meta/lib/oeqa/runtime/context.py
+++ b/meta/lib/oeqa/runtime/context.py
@@ -5,6 +5,7 @@
5# 5#
6 6
7import os 7import os
8import sys
8 9
9from oeqa.core.context import OETestContext, OETestContextExecutor 10from oeqa.core.context import OETestContext, OETestContextExecutor
10from oeqa.core.target.ssh import OESSHTarget 11from oeqa.core.target.ssh import OESSHTarget
@@ -66,11 +67,11 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
66 % self.default_target_type) 67 % self.default_target_type)
67 runtime_group.add_argument('--target-ip', action='store', 68 runtime_group.add_argument('--target-ip', action='store',
68 default=self.default_target_ip, 69 default=self.default_target_ip,
69 help="IP address of device under test, default: %s" \ 70 help="IP address and optionally ssh port (default 22) of device under test, for example '192.168.0.7:22'. Default: %s" \
70 % self.default_target_ip) 71 % self.default_target_ip)
71 runtime_group.add_argument('--server-ip', action='store', 72 runtime_group.add_argument('--server-ip', action='store',
72 default=self.default_target_ip, 73 default=self.default_target_ip,
73 help="IP address of device under test, default: %s" \ 74 help="IP address of the test host from test target machine, default: %s" \
74 % self.default_server_ip) 75 % self.default_server_ip)
75 76
76 runtime_group.add_argument('--host-dumper-dir', action='store', 77 runtime_group.add_argument('--host-dumper-dir', action='store',
@@ -119,8 +120,7 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
119 # XXX: Don't base your targets on this code it will be refactored 120 # XXX: Don't base your targets on this code it will be refactored
120 # in the near future. 121 # in the near future.
121 # Custom target module loading 122 # Custom target module loading
122 target_modules_path = kwargs.get('target_modules_path', '') 123 controller = OERuntimeTestContextExecutor.getControllerModule(target_type)
123 controller = OERuntimeTestContextExecutor.getControllerModule(target_type, target_modules_path)
124 target = controller(logger, target_ip, server_ip, **kwargs) 124 target = controller(logger, target_ip, server_ip, **kwargs)
125 125
126 return target 126 return target
@@ -130,15 +130,15 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
130 # AttributeError raised if not found. 130 # AttributeError raised if not found.
131 # ImportError raised if a provided module can not be imported. 131 # ImportError raised if a provided module can not be imported.
132 @staticmethod 132 @staticmethod
133 def getControllerModule(target, target_modules_path): 133 def getControllerModule(target):
134 controllerslist = OERuntimeTestContextExecutor._getControllerModulenames(target_modules_path) 134 controllerslist = OERuntimeTestContextExecutor._getControllerModulenames()
135 controller = OERuntimeTestContextExecutor._loadControllerFromName(target, controllerslist) 135 controller = OERuntimeTestContextExecutor._loadControllerFromName(target, controllerslist)
136 return controller 136 return controller
137 137
138 # Return a list of all python modules in lib/oeqa/controllers for each 138 # Return a list of all python modules in lib/oeqa/controllers for each
139 # layer in bbpath 139 # layer in bbpath
140 @staticmethod 140 @staticmethod
141 def _getControllerModulenames(target_modules_path): 141 def _getControllerModulenames():
142 142
143 controllerslist = [] 143 controllerslist = []
144 144
@@ -153,9 +153,8 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
153 else: 153 else:
154 raise RuntimeError("Duplicate controller module found for %s. Layers should create unique controller module names" % module) 154 raise RuntimeError("Duplicate controller module found for %s. Layers should create unique controller module names" % module)
155 155
156 extpath = target_modules_path.split(':') 156 for p in sys.path:
157 for p in extpath: 157 controllerpath = os.path.join(p, 'oeqa', 'controllers')
158 controllerpath = os.path.join(p, 'lib', 'oeqa', 'controllers')
159 if os.path.exists(controllerpath): 158 if os.path.exists(controllerpath):
160 add_controller_list(controllerpath) 159 add_controller_list(controllerpath)
161 return controllerslist 160 return controllerslist
@@ -175,16 +174,12 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
175 # Search for and return a controller or None from given module name 174 # Search for and return a controller or None from given module name
176 @staticmethod 175 @staticmethod
177 def _loadControllerFromModule(target, modulename): 176 def _loadControllerFromModule(target, modulename):
178 obj = None
179 # import module, allowing it to raise import exception
180 module = __import__(modulename, globals(), locals(), [target])
181 # look for target class in the module, catching any exceptions as it
182 # is valid that a module may not have the target class.
183 try: 177 try:
184 obj = getattr(module, target) 178 import importlib
185 except: 179 module = importlib.import_module(modulename)
186 obj = None 180 return getattr(module, target)
187 return obj 181 except AttributeError:
182 return None
188 183
189 @staticmethod 184 @staticmethod
190 def readPackagesManifest(manifest): 185 def readPackagesManifest(manifest):