diff options
Diffstat (limited to 'poky/meta/lib/oeqa/runtime/cases')
-rw-r--r-- | poky/meta/lib/oeqa/runtime/cases/date.py | 13 | ||||
-rw-r--r-- | poky/meta/lib/oeqa/runtime/cases/ethernet_ip_connman.py | 36 | ||||
-rw-r--r-- | poky/meta/lib/oeqa/runtime/cases/rtc.py | 38 | ||||
-rw-r--r-- | poky/meta/lib/oeqa/runtime/cases/suspend.py | 33 | ||||
-rw-r--r-- | poky/meta/lib/oeqa/runtime/cases/terminal.py | 21 | ||||
-rw-r--r-- | poky/meta/lib/oeqa/runtime/cases/usb_hid.py | 22 |
6 files changed, 156 insertions, 7 deletions
diff --git a/poky/meta/lib/oeqa/runtime/cases/date.py b/poky/meta/lib/oeqa/runtime/cases/date.py index fdd2a6ae58..bd6537400e 100644 --- a/poky/meta/lib/oeqa/runtime/cases/date.py +++ b/poky/meta/lib/oeqa/runtime/cases/date.py @@ -13,12 +13,12 @@ class DateTest(OERuntimeTestCase): def setUp(self): if self.tc.td.get('VIRTUAL-RUNTIME_init_manager') == 'systemd': self.logger.debug('Stopping systemd-timesyncd daemon') - self.target.run('systemctl disable --now systemd-timesyncd') + self.target.run('systemctl disable --now --runtime systemd-timesyncd') def tearDown(self): if self.tc.td.get('VIRTUAL-RUNTIME_init_manager') == 'systemd': self.logger.debug('Starting systemd-timesyncd daemon') - self.target.run('systemctl enable --now systemd-timesyncd') + self.target.run('systemctl enable --now --runtime systemd-timesyncd') @OETestDepends(['ssh.SSHTest.test_ssh']) @OEHasPackage(['coreutils', 'busybox']) @@ -28,14 +28,13 @@ class DateTest(OERuntimeTestCase): self.assertEqual(status, 0, msg=msg) oldDate = output - sampleDate = '"2016-08-09 10:00:00"' - (status, output) = self.target.run("date -s %s" % sampleDate) + sampleTimestamp = 1488800000 + (status, output) = self.target.run("date -s @%d" % sampleTimestamp) self.assertEqual(status, 0, msg='Date set failed, output: %s' % output) - (status, output) = self.target.run("date -R") - p = re.match('Tue, 09 Aug 2016 10:00:.. \+0000', output) + (status, output) = self.target.run('date +"%s"') msg = 'The date was not set correctly, output: %s' % output - self.assertTrue(p, msg=msg) + self.assertTrue(int(output) - sampleTimestamp < 300, msg=msg) (status, output) = self.target.run('date -s "%s"' % oldDate) msg = 'Failed to reset date, output: %s' % output diff --git a/poky/meta/lib/oeqa/runtime/cases/ethernet_ip_connman.py b/poky/meta/lib/oeqa/runtime/cases/ethernet_ip_connman.py new file mode 100644 index 0000000000..e010612838 --- /dev/null +++ b/poky/meta/lib/oeqa/runtime/cases/ethernet_ip_connman.py @@ -0,0 +1,36 @@ +from oeqa.runtime.case import OERuntimeTestCase +from oeqa.core.decorator.depends import OETestDepends +from oeqa.core.decorator.data import skipIfQemu + +class Ethernet_Test(OERuntimeTestCase): + + def set_ip(self, x): + x = x.split(".") + sample_host_address = '150' + x[3] = sample_host_address + x = '.'.join(x) + return x + + @skipIfQemu('qemuall', 'Test only runs on real hardware') + @OETestDepends(['ssh.SSHTest.test_ssh']) + def test_set_virtual_ip(self): + (status, output) = self.target.run("ifconfig eth0 | grep 'inet ' | awk '{print $2}'") + self.assertEqual(status, 0, msg='Failed to get ip address. Make sure you have an ethernet connection on your device, output: %s' % output) + original_ip = output + virtual_ip = self.set_ip(original_ip) + + (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)) + self.assertEqual(status, 0, msg='Failed to create virtual ip address, output: %s' % output) + + @OETestDepends(['ethernet_ip_connman.Ethernet_Test.test_set_virtual_ip']) + def test_get_ip_from_dhcp(self): + (status, output) = self.target.run("connmanctl services | grep -E '*AO Wired|*AR Wired' | awk '{print $3}'") + self.assertEqual(status, 0, msg='No wired interfaces are detected, output: %s' % output) + wired_interfaces = output + + (status, output) = self.target.run("ip route | grep default | awk '{print $3}'") + self.assertEqual(status, 0, msg='Failed to retrieve the default gateway, output: %s' % output) + default_gateway = output + + (status, output) = self.target.run("connmanctl config %s --ipv4 dhcp && sleep 2 && ping -c 5 %s" % (wired_interfaces,default_gateway)) + 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/poky/meta/lib/oeqa/runtime/cases/rtc.py b/poky/meta/lib/oeqa/runtime/cases/rtc.py new file mode 100644 index 0000000000..c4e6681324 --- /dev/null +++ b/poky/meta/lib/oeqa/runtime/cases/rtc.py @@ -0,0 +1,38 @@ +from oeqa.runtime.case import OERuntimeTestCase +from oeqa.core.decorator.depends import OETestDepends +from oeqa.runtime.decorator.package import OEHasPackage + +import re + +class RTCTest(OERuntimeTestCase): + + def setUp(self): + if self.tc.td.get('VIRTUAL-RUNTIME_init_manager') == 'systemd': + self.logger.debug('Stopping systemd-timesyncd daemon') + self.target.run('systemctl disable --now --runtime systemd-timesyncd') + + def tearDown(self): + if self.tc.td.get('VIRTUAL-RUNTIME_init_manager') == 'systemd': + self.logger.debug('Starting systemd-timesyncd daemon') + self.target.run('systemctl enable --now --runtime systemd-timesyncd') + + @OETestDepends(['ssh.SSHTest.test_ssh']) + @OEHasPackage(['coreutils', 'busybox']) + def test_rtc(self): + (status, output) = self.target.run('hwclock -r') + self.assertEqual(status, 0, msg='Failed to get RTC time, output: %s' % output) + + (status, current_datetime) = self.target.run('date +"%m%d%H%M%Y"') + self.assertEqual(status, 0, msg='Failed to get system current date & time, output: %s' % current_datetime) + + example_datetime = '062309452008' + (status, output) = self.target.run('date %s ; hwclock -w ; hwclock -r' % example_datetime) + check_hwclock = re.search('2008-06-23 09:45:..', output) + self.assertTrue(check_hwclock, msg='The RTC time was not set correctly, output: %s' % output) + + (status, output) = self.target.run('date %s' % current_datetime) + self.assertEqual(status, 0, msg='Failed to reset system date & time, output: %s' % output) + + (status, output) = self.target.run('hwclock -w') + self.assertEqual(status, 0, msg='Failed to reset RTC time, output: %s' % output) + diff --git a/poky/meta/lib/oeqa/runtime/cases/suspend.py b/poky/meta/lib/oeqa/runtime/cases/suspend.py new file mode 100644 index 0000000000..67b6f7e56f --- /dev/null +++ b/poky/meta/lib/oeqa/runtime/cases/suspend.py @@ -0,0 +1,33 @@ +from oeqa.runtime.case import OERuntimeTestCase +from oeqa.core.decorator.depends import OETestDepends +from oeqa.core.decorator.data import skipIfQemu +import threading +import time + +class Suspend_Test(OERuntimeTestCase): + + def test_date(self): + (status, output) = self.target.run('date') + self.assertEqual(status, 0, msg = 'Failed to run date command, output : %s' % output) + + def test_ping(self): + t_thread = threading.Thread(target=self.target.run, args=("ping 8.8.8.8",)) + t_thread.start() + time.sleep(2) + + status, output = self.target.run('pidof ping') + self.target.run('kill -9 %s' % output) + self.assertEqual(status, 0, msg = 'Not able to find process that runs ping, output : %s' % output) + + def set_suspend(self): + (status, output) = self.target.run('sudo rtcwake -m mem -s 10') + self.assertEqual(status, 0, msg = 'Failed to suspends your system to RAM, output : %s' % output) + + @skipIfQemu('qemuall', 'Test only runs on real hardware') + @OETestDepends(['ssh.SSHTest.test_ssh']) + def test_suspend(self): + self.test_date() + self.test_ping() + self.set_suspend() + self.test_date() + self.test_ping() diff --git a/poky/meta/lib/oeqa/runtime/cases/terminal.py b/poky/meta/lib/oeqa/runtime/cases/terminal.py new file mode 100644 index 0000000000..8fcca99f47 --- /dev/null +++ b/poky/meta/lib/oeqa/runtime/cases/terminal.py @@ -0,0 +1,21 @@ +from oeqa.runtime.case import OERuntimeTestCase +from oeqa.core.decorator.depends import OETestDepends +from oeqa.runtime.decorator.package import OEHasPackage + +import threading +import time + +class TerminalTest(OERuntimeTestCase): + + @OEHasPackage(['matchbox-terminal']) + @OETestDepends(['ssh.SSHTest.test_ssh']) + def test_terminal_running(self): + t_thread = threading.Thread(target=self.target.run, args=("export DISPLAY=:0 && matchbox-terminal -e 'sh -c \"uname -a && exec sh\"'",)) + t_thread.start() + time.sleep(2) + + status, output = self.target.run('pidof matchbox-terminal') + number_of_terminal = len(output.split()) + self.assertEqual(number_of_terminal, 1, msg='There should be only one terminal being launched. Number of terminal launched : %s' % number_of_terminal) + self.target.run('kill -9 %s' % output) + self.assertEqual(status, 0, msg='Not able to find process that runs terminal.') diff --git a/poky/meta/lib/oeqa/runtime/cases/usb_hid.py b/poky/meta/lib/oeqa/runtime/cases/usb_hid.py new file mode 100644 index 0000000000..3c292cf661 --- /dev/null +++ b/poky/meta/lib/oeqa/runtime/cases/usb_hid.py @@ -0,0 +1,22 @@ +from oeqa.runtime.case import OERuntimeTestCase +from oeqa.core.decorator.depends import OETestDepends +from oeqa.core.decorator.data import skipIfQemu +from oeqa.runtime.decorator.package import OEHasPackage + +class USB_HID_Test(OERuntimeTestCase): + + def keyboard_mouse_simulation(self): + (status, output) = self.target.run('export DISPLAY=:0 && xdotool key F2 && xdotool mousemove 100 100') + return self.assertEqual(status, 0, msg = 'Failed to simulate keyboard/mouse input event, output : %s' % output) + + def set_suspend(self): + (status, output) = self.target.run('sudo rtcwake -m mem -s 10') + return self.assertEqual(status, 0, msg = 'Failed to suspends your system to RAM, output : %s' % output) + + @OEHasPackage(['xdotool']) + @skipIfQemu('qemuall', 'Test only runs on real hardware') + @OETestDepends(['ssh.SSHTest.test_ssh']) + def test_USB_Hid_input(self): + self.keyboard_mouse_simulation() + self.set_suspend() + self.keyboard_mouse_simulation() |