diff options
-rw-r--r-- | meta/lib/oeqa/runtime/cases/dnf.py | 12 | ||||
-rw-r--r-- | meta/lib/oeqa/runtime/cases/logrotate.py | 40 | ||||
-rw-r--r-- | meta/lib/oeqa/runtime/cases/pam.py | 17 | ||||
-rw-r--r-- | meta/lib/oeqa/runtime/cases/parselogs.py | 10 | ||||
-rw-r--r-- | meta/lib/oeqa/runtime/cases/rpm.py | 54 | ||||
-rw-r--r-- | meta/lib/oeqa/runtime/cases/ssh.py | 9 | ||||
-rw-r--r-- | meta/lib/oeqa/runtime/cases/systemd.py | 3 | ||||
-rw-r--r-- | meta/lib/oeqa/runtime/cases/weston.py | 13 |
8 files changed, 43 insertions, 115 deletions
diff --git a/meta/lib/oeqa/runtime/cases/dnf.py b/meta/lib/oeqa/runtime/cases/dnf.py index 3ccb18ce834..d22056138e1 100644 --- a/meta/lib/oeqa/runtime/cases/dnf.py +++ b/meta/lib/oeqa/runtime/cases/dnf.py @@ -135,10 +135,8 @@ class DnfRepoTest(DnfTest): self.target.run('cp /bin/sh %s/bin' % rootpath, 1500) self.target.run('mount -o bind /dev %s/dev/' % rootpath, 1500) self.dnf_with_repo('install --installroot=%s -v -y --rpmverbosity=debug busybox' % rootpath) - status, output = self.target.run('test -e %s/var/cache/dnf' % rootpath, 1500) - self.assertEqual(0, status, output) - status, output = self.target.run('test -e %s/bin/busybox' % rootpath, 1500) - self.assertEqual(0, status, output) + self.target.run('test -e %s/var/cache/dnf' % rootpath, 1500) + self.target.run('test -e %s/bin/busybox' % rootpath, 1500) @OETestDepends(['dnf.DnfRepoTest.test_dnf_makecache']) @skipIfNotInDataVar('DISTRO_FEATURES', 'usrmerge', 'Test run when enable usrmerge') @@ -159,10 +157,8 @@ class DnfRepoTest(DnfTest): self.target.run('cp /bin/busybox %s/bin/sh' % rootpath) self.target.run('mount -o bind /dev %s/dev/' % rootpath) self.dnf_with_repo('install --installroot=%s -v -y --rpmverbosity=debug busybox' % rootpath) - status, output = self.target.run('test -e %s/var/cache/dnf' % rootpath) - self.assertEqual(0, status, output) - status, output = self.target.run('test -e %s/bin/busybox' % rootpath) - self.assertEqual(0, status, output) + self.target.run('test -e %s/var/cache/dnf' % rootpath) + self.target.run('test -e %s/bin/busybox' % rootpath) @OETestDepends(['dnf.DnfRepoTest.test_dnf_makecache']) def test_dnf_exclude(self): diff --git a/meta/lib/oeqa/runtime/cases/logrotate.py b/meta/lib/oeqa/runtime/cases/logrotate.py index 6ad980cb6ad..abe70d2ff0d 100644 --- a/meta/lib/oeqa/runtime/cases/logrotate.py +++ b/meta/lib/oeqa/runtime/cases/logrotate.py @@ -15,50 +15,34 @@ class LogrotateTest(OERuntimeTestCase): @classmethod def setUpClass(cls): - cls.tc.target.run('cp /etc/logrotate.d/wtmp $HOME/wtmp.oeqabak') + cls.tc.target.run('test -f /etc/logrotate.d/wtmp && cp /etc/logrotate.d/wtmp $HOME/wtmp.oeqabak', ignore_status=True) @classmethod def tearDownClass(cls): - cls.tc.target.run('mv -f $HOME/wtmp.oeqabak /etc/logrotate.d/wtmp && rm -rf /var/log//logrotate_dir') - cls.tc.target.run('rm -rf /var/log/logrotate_testfile && rm -rf /etc/logrotate.d/logrotate_testfile') + cls.tc.target.run('test -f $HOME/wtmp.oeqabak && mv -f $HOME/wtmp.oeqabak /etc/logrotate.d/wtmp', ignore_status=True) + cls.tc.target.run('rm -rf /var/log/logrotate_dir /var/log/logrotate_testfile /etc/logrotate.d/logrotate_testfile') @OETestDepends(['ssh.SSHTest.test_ssh']) @OEHasPackage(['logrotate']) def test_logrotate_wtmp(self): - # /var/log/wtmp may not always exist initially, so use touch to ensure it is present - status, output = self.target.run('touch /var/log/wtmp') - msg = ('Could not create/update /var/log/wtmp with touch') - self.assertEqual(status, 0, msg = msg) + self.target.run('touch /var/log/wtmp') - status, output = self.target.run('mkdir /var/log//logrotate_dir') - msg = ('Could not create logrotate_dir. Output: %s' % output) - self.assertEqual(status, 0, msg = msg) + self.target.run('mkdir /var/log/logrotate_dir') - status, output = self.target.run('echo "create \n olddir /var/log//logrotate_dir \n include /etc/logrotate.d/wtmp" > /tmp/logrotate-test.conf') - msg = ('Could not write to /tmp/logrotate-test.conf') - self.assertEqual(status, 0, msg = msg) + self.target.run('echo "create \n olddir /var/log//logrotate_dir \n include /etc/logrotate.d/wtmp" > /tmp/logrotate-test.conf') # If logrotate fails to rotate the log, view the verbose output of logrotate to see what prevented it - _, logrotate_output = self.target.run('logrotate -vf /tmp/logrotate-test.conf') + self.target.run('logrotate -vf /tmp/logrotate-test.conf') status, _ = self.target.run('find /var/log//logrotate_dir -type f | grep wtmp.1') - msg = ("logrotate did not successfully rotate the wtmp log. Output from logrotate -vf: \n%s" % (logrotate_output)) - self.assertEqual(status, 0, msg = msg) - + @OETestDepends(['logrotate.LogrotateTest.test_logrotate_wtmp']) def test_logrotate_newlog(self): + self.target.run('echo "oeqa logrotate test file" > /var/log/logrotate_testfile') - status, output = self.target.run('echo "oeqa logrotate test file" > /var/log/logrotate_testfile') - msg = ('Could not create logrotate test file in /var/log') - self.assertEqual(status, 0, msg = msg) - - status, output = self.target.run('echo "/var/log/logrotate_testfile {\n missingok \n monthly \n rotate 1" > /etc/logrotate.d/logrotate_testfile') - msg = ('Could not write to /etc/logrotate.d/logrotate_testfile') - self.assertEqual(status, 0, msg = msg) + self.target.run('echo "/var/log/logrotate_testfile {\n missingok \n monthly \n rotate 1" > /etc/logrotate.d/logrotate_testfile') - status, output = self.target.run('echo "create \n olddir /var/log//logrotate_dir \n include /etc/logrotate.d/logrotate_testfile" > /tmp/logrotate-test2.conf') - msg = ('Could not write to /tmp/logrotate_test2.conf') - self.assertEqual(status, 0, msg = msg) + self.target.run('echo "create \n olddir /var/log//logrotate_dir \n include /etc/logrotate.d/logrotate_testfile" > /tmp/logrotate-test2.conf') status, output = self.target.run('find /var/log//logrotate_dir -type f | grep logrotate_testfile.1') msg = ('A rotated log for logrotate_testfile is already present in logrotate_dir') @@ -69,5 +53,3 @@ class LogrotateTest(OERuntimeTestCase): status, _ = self.target.run('find /var/log//logrotate_dir -type f | grep logrotate_testfile.1') msg = ('logrotate did not successfully rotate the logrotate_test log. Output from logrotate -vf: \n%s' % (logrotate_output)) self.assertEqual(status, 0, msg = msg) - - diff --git a/meta/lib/oeqa/runtime/cases/pam.py b/meta/lib/oeqa/runtime/cases/pam.py index b3e8b56c3c2..e6050f1708f 100644 --- a/meta/lib/oeqa/runtime/cases/pam.py +++ b/meta/lib/oeqa/runtime/cases/pam.py @@ -19,22 +19,13 @@ class PamBasicTest(OERuntimeTestCase): @OEHasPackage(['shadow']) @OEHasPackage(['shadow-base']) def test_pam(self): - status, output = self.target.run('login --help') + status, output = self.target.run('login --help', ignore_status=True) msg = ('login command does not work as expected. ' 'Status and output:%s and %s' % (status, output)) self.assertEqual(status, 1, msg = msg) - status, output = self.target.run('passwd --help') - msg = ('passwd command does not work as expected. ' - 'Status and output:%s and %s' % (status, output)) - self.assertEqual(status, 0, msg = msg) + self.target.run('passwd --help') - status, output = self.target.run('su --help') - msg = ('su command does not work as expected. ' - 'Status and output:%s and %s' % (status, output)) - self.assertEqual(status, 0, msg = msg) + self.target.run('su --help') - status, output = self.target.run('useradd --help') - msg = ('useradd command does not work as expected. ' - 'Status and output:%s and %s' % (status, output)) - self.assertEqual(status, 0, msg = msg) + self.target.run('useradd --help') diff --git a/meta/lib/oeqa/runtime/cases/parselogs.py b/meta/lib/oeqa/runtime/cases/parselogs.py index e67d3750dad..8e188824204 100644 --- a/meta/lib/oeqa/runtime/cases/parselogs.py +++ b/meta/lib/oeqa/runtime/cases/parselogs.py @@ -227,7 +227,7 @@ class ParseLogsTest(OERuntimeTestCase): cls.ignore_errors = ignore_errors cls.log_locations = log_locations cls.msg = '' - is_lsb, _ = cls.tc.target.run("which LSB_Test.sh") + is_lsb, _ = cls.tc.target.run("which LSB_Test.sh", ignore_status=True) if is_lsb == 0: for machine in cls.ignore_errors: cls.ignore_errors[machine] = cls.ignore_errors[machine] \ @@ -273,14 +273,14 @@ class ParseLogsTest(OERuntimeTestCase): def getLogList(self, log_locations): logs = [] for location in log_locations: - status, _ = self.target.run('test -f ' + str(location)) + status, _ = self.target.run('test -f ' + str(location), ignore_status=True) if status == 0: logs.append(str(location)) else: - status, _ = self.target.run('test -d ' + str(location)) + status, _ = self.target.run('test -d ' + str(location), ignore_status=True) if status == 0: cmd = 'find ' + str(location) + '/*.log -maxdepth 1 -type f' - status, output = self.target.run(cmd) + status, output = self.target.run(cmd, ignore_status=True) if status == 0: output = output.splitlines() for logfile in output: @@ -371,7 +371,7 @@ class ParseLogsTest(OERuntimeTestCase): # Get the output of dmesg and write it in a file. # This file is added to log_locations. def write_dmesg(self): - (status, dmesg) = self.target.run('dmesg > /tmp/dmesg_output.log') + self.target.run('dmesg > /tmp/dmesg_output.log') @OETestDepends(['ssh.SSHTest.test_ssh']) def test_parselogs(self): diff --git a/meta/lib/oeqa/runtime/cases/rpm.py b/meta/lib/oeqa/runtime/cases/rpm.py index a4ba4e67698..6d0d2dba658 100644 --- a/meta/lib/oeqa/runtime/cases/rpm.py +++ b/meta/lib/oeqa/runtime/cases/rpm.py @@ -36,20 +36,12 @@ class RpmBasicTest(OERuntimeTestCase): def test_rpm_query_nonroot(self): def set_up_test_user(u): - status, output = self.target.run('id -u %s' % u) - if status: - status, output = self.target.run('useradd %s' % u) - msg = 'Failed to create new user: %s' % output - self.assertTrue(status == 0, msg=msg) + self.target.run('id -u %s || useradd %s' % (u, u)) def exec_as_test_user(u): - status, output = self.target.run('su -c id %s' % u) - msg = 'Failed to execute as new user' - self.assertTrue("({0})".format(u) in output, msg=msg) + self.target.run('su -c id %s' % u) - status, output = self.target.run('su -c "rpm -qa" %s ' % u) - msg = 'status: %s. Cannot run rpm -qa: %s' % (status, output) - self.assertEqual(status, 0, msg=msg) + self.target.run('su -c "rpm -qa" %s ' % u) def wait_for_no_process_for_user(u, timeout = 120): timeout_at = time.time() + timeout @@ -96,50 +88,20 @@ class RpmInstallRemoveTest(OERuntimeTestCase): @OETestDepends(['rpm.RpmBasicTest.test_rpm_query']) def test_rpm_install(self): self.tc.target.copyTo(self.test_file, self.dst) - status, output = self.target.run('rpm -ivh /tmp/base-passwd-doc.rpm') - msg = 'Failed to install base-passwd-doc package: %s' % output - self.assertEqual(status, 0, msg=msg) + self.target.run('rpm -ivh /tmp/base-passwd-doc.rpm') self.tc.target.run('rm -f %s' % self.dst) @OETestDepends(['rpm.RpmInstallRemoveTest.test_rpm_install']) def test_rpm_remove(self): - status,output = self.target.run('rpm -e base-passwd-doc') - msg = 'Failed to remove base-passwd-doc package: %s' % output - self.assertEqual(status, 0, msg=msg) + self.target.run('rpm -e base-passwd-doc') @OETestDepends(['rpm.RpmInstallRemoveTest.test_rpm_remove']) - def test_check_rpm_install_removal_log_file_size(self): - """ - Summary: Check that rpm writes into /var/log/messages - Expected: There should be some RPM prefixed entries in the above file. - Product: BSPs - Author: Alexandru Georgescu <alexandru.c.georgescu@intel.com> - Author: Alexander Kanavin <alex.kanavin@gmail.com> - AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com> - """ - db_files_cmd = 'ls /var/lib/rpm/rpmdb.sqlite*' - check_log_cmd = "grep RPM /var/log/messages | wc -l" - - # Make sure that some database files are under /var/lib/rpm as 'rpmdb.sqlite' - status, output = self.target.run(db_files_cmd) - msg = 'Failed to find database files under /var/lib/rpm/ as rpmdb.sqlite' - self.assertEqual(0, status, msg=msg) - + def test_check_rpm_install_stress(self): self.tc.target.copyTo(self.test_file, self.dst) - # Remove the package just in case - self.target.run('rpm -e base-passwd-doc') - # Install/Remove a package 10 times for i in range(10): - status, output = self.target.run('rpm -ivh /tmp/base-passwd-doc.rpm') - msg = 'Failed to install base-passwd-doc package. Reason: {}'.format(output) - self.assertEqual(0, status, msg=msg) - - status, output = self.target.run('rpm -e base-passwd-doc') - msg = 'Failed to remove base-passwd-doc package. Reason: {}'.format(output) - self.assertEqual(0, status, msg=msg) + self.target.run('rpm -ifvh /tmp/base-passwd-doc.rpm') + self.target.run('rpm -e base-passwd-doc') self.tc.target.run('rm -f %s' % self.dst) - - diff --git a/meta/lib/oeqa/runtime/cases/ssh.py b/meta/lib/oeqa/runtime/cases/ssh.py index 13aac543969..cb7b2cf5e78 100644 --- a/meta/lib/oeqa/runtime/cases/ssh.py +++ b/meta/lib/oeqa/runtime/cases/ssh.py @@ -13,9 +13,6 @@ class SSHTest(OERuntimeTestCase): @OETestDepends(['ping.PingTest.test_ping']) @OEHasPackage(['dropbear', 'openssh-sshd']) def test_ssh(self): - (status, output) = self.target.run('uname -a') - self.assertEqual(status, 0, msg='SSH Test failed: %s' % output) - (status, output) = self.target.run('cat /etc/controllerimage') - msg = "This isn't the right image - /etc/controllerimage " \ - "shouldn't be here %s" % output - self.assertEqual(status, 1, msg=msg) + self.target.run('uname -a') + # Check that controllerimage doesn't exist + self.target.run('test ! -f /etc/controllerimage') diff --git a/meta/lib/oeqa/runtime/cases/systemd.py b/meta/lib/oeqa/runtime/cases/systemd.py index 37f295492d3..5fefb9474ab 100644 --- a/meta/lib/oeqa/runtime/cases/systemd.py +++ b/meta/lib/oeqa/runtime/cases/systemd.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: MIT # +from codecs import ignore_errors import re import time @@ -17,7 +18,7 @@ class SystemdTest(OERuntimeTestCase): def systemctl(self, action='', target='', expected=0, verbose=False): command = 'SYSTEMD_BUS_TIMEOUT=240s systemctl %s %s' % (action, target) - status, output = self.target.run(command) + status, output = self.target.run(command, ignore_status=True) message = '\n'.join([command, output]) if status != expected and verbose: cmd = 'SYSTEMD_BUS_TIMEOUT=240s systemctl status --full %s' % target diff --git a/meta/lib/oeqa/runtime/cases/weston.py b/meta/lib/oeqa/runtime/cases/weston.py index ee4d336482e..c52f61f76c8 100644 --- a/meta/lib/oeqa/runtime/cases/weston.py +++ b/meta/lib/oeqa/runtime/cases/weston.py @@ -16,20 +16,19 @@ class WestonTest(OERuntimeTestCase): @classmethod def tearDownClass(cls): - cls.tc.target.run('rm %s' % cls.weston_log_file) + cls.tc.target.run('rm -f %s' % cls.weston_log_file) @OETestDepends(['ssh.SSHTest.test_ssh']) @OEHasPackage(['weston']) def test_weston_running(self): cmd ='%s | grep [w]eston-desktop-shell' % self.tc.target_cmds['ps'] - status, output = self.target.run(cmd) + status, output = self.target.run(cmd, ignore_status=True) msg = ('Weston does not appear to be running %s' % self.target.run(self.tc.target_cmds['ps'])[1]) self.assertEqual(status, 0, msg=msg) def get_processes_of(self, target, error_msg): status, output = self.target.run('pidof %s' % target) - self.assertEqual(status, 0, msg='Retrieve %s (%s) processes error: %s' % (target, error_msg, output)) return output.split(" ") def get_weston_command(self, cmd): @@ -59,8 +58,7 @@ class WestonTest(OERuntimeTestCase): command = 'XDG_RUNTIME_DIR=/run wayland-info' else: command = self.get_weston_command('wayland-info') - status, output = self.target.run(command) - self.assertEqual(status, 0, msg='wayland-info error: %s' % output) + self.target.run(command) @OEHasPackage(['weston']) def test_weston_can_initialize_new_wayland_compositor(self): @@ -72,13 +70,14 @@ class WestonTest(OERuntimeTestCase): new_wl_processes, try_cnt = self.get_new_wayland_processes(existing_wl_processes) existing_and_new_weston_processes = self.get_processes_of('weston', 'existing and new') new_weston_processes = [x for x in existing_and_new_weston_processes if x not in existing_weston_processes] + if not new_weston_processes: + __, weston_log = self.target.run('cat %s' % self.weston_log_file) + self.fail('Could not get new weston-desktop-shell processes (%s, try_cnt:%s) weston log: %s' % (new_wl_processes, try_cnt, weston_log)) if 'systemd' in self.tc.td['VIRTUAL-RUNTIME_init_manager']: self.target.run('systemctl stop weston-ptest.service') else: for w in new_weston_processes: self.target.run('kill -9 %s' % w) - __, weston_log = self.target.run('cat %s' % self.weston_log_file) - self.assertTrue(new_wl_processes, msg='Could not get new weston-desktop-shell processes (%s, try_cnt:%s) weston log: %s' % (new_wl_processes, try_cnt, weston_log)) @skipIfNotFeature('x11', 'Test requires x11 to be in DISTRO_FEATURES') @OEHasPackage(['weston']) |