diff options
Diffstat (limited to 'meta/lib/oeqa/runtime')
29 files changed, 393 insertions, 18 deletions
diff --git a/meta/lib/oeqa/runtime/_ptest.py b/meta/lib/oeqa/runtime/_ptest.py new file mode 100644 index 0000000000..4c58dc1d7f --- /dev/null +++ b/meta/lib/oeqa/runtime/_ptest.py @@ -0,0 +1,124 @@ +import unittest, os, shutil +from oeqa.oetest import oeRuntimeTest, skipModule +from oeqa.utils.decorators import * +from oeqa.utils.logparser import * +from oeqa.utils.httpserver import HTTPService +import bb +import glob +from oe.package_manager import RpmPkgsList +import subprocess + +def setUpModule(): + if not oeRuntimeTest.hasFeature("package-management"): + skipModule("Image doesn't have package management feature") + if not oeRuntimeTest.hasPackage("smart"): + skipModule("Image doesn't have smart installed") + if "package_rpm" != oeRuntimeTest.tc.d.getVar("PACKAGE_CLASSES", True).split()[0]: + skipModule("Rpm is not the primary package manager") + +class PtestRunnerTest(oeRuntimeTest): + + # a ptest log parser + def parse_ptest(self, logfile): + parser = Lparser(test_0_pass_regex="^PASS:(.+)", test_0_fail_regex="^FAIL:(.+)", section_0_begin_regex="^BEGIN: .*/(.+)/ptest", section_0_end_regex="^END: .*/(.+)/ptest") + parser.init() + result = Result() + + with open(logfile) as f: + for line in f: + result_tuple = parser.parse_line(line) + if not result_tuple: + continue + result_tuple = line_type, category, status, name = parser.parse_line(line) + + if line_type == 'section' and status == 'begin': + current_section = name + continue + + if line_type == 'section' and status == 'end': + current_section = None + continue + + if line_type == 'test' and status == 'pass': + result.store(current_section, name, status) + continue + + if line_type == 'test' and status == 'fail': + result.store(current_section, name, status) + continue + + result.sort_tests() + return result + + @classmethod + def setUpClass(self): + #note the existing channels that are on the board before creating new ones +# self.existingchannels = set() +# (status, result) = oeRuntimeTest.tc.target.run('smart channel --show | grep "\["', 0) +# for x in result.split("\n"): +# self.existingchannels.add(x) + self.repo_server = HTTPService(oeRuntimeTest.tc.d.getVar('DEPLOY_DIR', True), oeRuntimeTest.tc.target.server_ip) + self.repo_server.start() + + @classmethod + def tearDownClass(self): + self.repo_server.stop() + #remove created channels to be able to repeat the tests on same image +# (status, result) = oeRuntimeTest.tc.target.run('smart channel --show | grep "\["', 0) +# for x in result.split("\n"): +# if x not in self.existingchannels: +# oeRuntimeTest.tc.target.run('smart channel --remove '+x[1:-1]+' -y', 0) + + def add_smart_channel(self): + image_pkgtype = self.tc.d.getVar('IMAGE_PKGTYPE', True) + deploy_url = 'http://%s:%s/%s' %(self.target.server_ip, self.repo_server.port, image_pkgtype) + pkgarchs = self.tc.d.getVar('PACKAGE_ARCHS', True).replace("-","_").split() + for arch in os.listdir('%s/%s' % (self.repo_server.root_dir, image_pkgtype)): + if arch in pkgarchs: + self.target.run('smart channel -y --add {a} type=rpm-md baseurl={u}/{a}'.format(a=arch, u=deploy_url), 0) + self.target.run('smart update', 0) + + def install_complementary(self, globs=None): + installed_pkgs_file = os.path.join(oeRuntimeTest.tc.d.getVar('WORKDIR', True), + "installed_pkgs.txt") + self.pkgs_list = RpmPkgsList(oeRuntimeTest.tc.d, oeRuntimeTest.tc.d.getVar('IMAGE_ROOTFS', True), oeRuntimeTest.tc.d.getVar('arch_var', True), oeRuntimeTest.tc.d.getVar('os_var', True)) + with open(installed_pkgs_file, "w+") as installed_pkgs: + installed_pkgs.write(self.pkgs_list.list("arch")) + + cmd = [bb.utils.which(os.getenv('PATH'), "oe-pkgdata-util"), + "glob", oeRuntimeTest.tc.d.getVar('PKGDATA_DIR', True), installed_pkgs_file, + globs] + try: + bb.note("Installing complementary packages ...") + complementary_pkgs = subprocess.check_output(cmd, stderr=subprocess.STDOUT) + except subprocess.CalledProcessError as e: + bb.fatal("Could not compute complementary packages list. Command " + "'%s' returned %d:\n%s" % + (' '.join(cmd), e.returncode, e.output)) + + return complementary_pkgs.split() + + def setUp(self): + self.buildhist_dir = oeRuntimeTest.tc.d.getVar("BUILDHISTORY_DIR_IMAGE", True) + self.assertTrue(os.path.exists(self.buildhist_dir)) + self.ptest_log = os.path.join(oeRuntimeTest.tc.d.getVar("TEST_LOG_DIR",True), "ptest-%s.log" % oeRuntimeTest.tc.d.getVar('DATETIME', True)) + + @skipUnlessPassed('test_ssh') + def test_ptestrunner(self): + self.add_smart_channel() + cond = oeRuntimeTest.hasPackage("ptest-runner") and oeRuntimeTest.hasFeature("ptest") and oeRuntimeTest.hasPackage("-ptest") + if not cond: + self.install_packages(self.install_complementary("*-ptest")) + self.install_packages(['ptest-runner']) + + self.target.run('/usr/bin/ptest-runner > /tmp/ptest.log 2>&1', 0) + self.target.copy_from('/tmp/ptest.log', self.ptest_log) + shutil.copyfile(self.ptest_log, os.path.join(self.buildhist_dir, "ptest.log")) + + result = self.parse_ptest(os.path.join(self.buildhist_dir, "ptest.log")) + log_results_to_location = "./results" + if os.path.exists(log_results_to_location): + shutil.rmtree(log_results_to_location) + os.makedirs(log_results_to_location) + + result.log_as_files(log_results_to_location, test_status = ['fail']) diff --git a/meta/lib/oeqa/runtime/buildcvs.py b/meta/lib/oeqa/runtime/buildcvs.py index f1fbf19c1f..fe6cbfbcd5 100644 --- a/meta/lib/oeqa/runtime/buildcvs.py +++ b/meta/lib/oeqa/runtime/buildcvs.py @@ -1,4 +1,4 @@ -from oeqa.oetest import oeRuntimeTest +from oeqa.oetest import oeRuntimeTest, skipModule from oeqa.utils.decorators import * from oeqa.utils.targetbuild import TargetBuildProject @@ -14,6 +14,7 @@ class BuildCvsTest(oeRuntimeTest): "http://ftp.gnu.org/non-gnu/cvs/source/feature/1.12.13/cvs-1.12.13.tar.bz2") self.project.download_archive() + @testcase(205) @skipUnlessPassed("test_ssh") def test_cvs(self): self.assertEqual(self.project.run_configure(), 0, diff --git a/meta/lib/oeqa/runtime/buildiptables.py b/meta/lib/oeqa/runtime/buildiptables.py index f6061a7f98..09e252df8c 100644 --- a/meta/lib/oeqa/runtime/buildiptables.py +++ b/meta/lib/oeqa/runtime/buildiptables.py @@ -1,4 +1,4 @@ -from oeqa.oetest import oeRuntimeTest +from oeqa.oetest import oeRuntimeTest, skipModule from oeqa.utils.decorators import * from oeqa.utils.targetbuild import TargetBuildProject @@ -14,6 +14,7 @@ class BuildIptablesTest(oeRuntimeTest): "http://netfilter.org/projects/iptables/files/iptables-1.4.13.tar.bz2") self.project.download_archive() + @testcase(206) @skipUnlessPassed("test_ssh") def test_iptables(self): self.assertEqual(self.project.run_configure(), 0, diff --git a/meta/lib/oeqa/runtime/buildsudoku.py b/meta/lib/oeqa/runtime/buildsudoku.py index a754f1d9ea..802b060010 100644 --- a/meta/lib/oeqa/runtime/buildsudoku.py +++ b/meta/lib/oeqa/runtime/buildsudoku.py @@ -1,4 +1,4 @@ -from oeqa.oetest import oeRuntimeTest +from oeqa.oetest import oeRuntimeTest, skipModule from oeqa.utils.decorators import * from oeqa.utils.targetbuild import TargetBuildProject @@ -14,6 +14,7 @@ class SudokuTest(oeRuntimeTest): "http://downloads.sourceforge.net/project/sudoku-savant/sudoku-savant/sudoku-savant-1.3/sudoku-savant-1.3.tar.bz2") self.project.download_archive() + @testcase(207) @skipUnlessPassed("test_ssh") def test_sudoku(self): self.assertEqual(self.project.run_configure(), 0, diff --git a/meta/lib/oeqa/runtime/connman.py b/meta/lib/oeqa/runtime/connman.py index c03688206f..cc537f7766 100644 --- a/meta/lib/oeqa/runtime/connman.py +++ b/meta/lib/oeqa/runtime/connman.py @@ -21,7 +21,7 @@ class ConnmanTest(oeRuntimeTest): (status, output) = self.target.run('/usr/sbin/connmand --help') self.assertEqual(status, 0, msg="status and output: %s and %s" % (status,output)) - + @testcase(221) @skipUnlessPassed('test_connmand_help') def test_connmand_running(self): (status, output) = self.target.run(oeRuntimeTest.pscmd + ' | grep [c]onnmand') diff --git a/meta/lib/oeqa/runtime/date.py b/meta/lib/oeqa/runtime/date.py index a208e29ada..97e8ee42ad 100644 --- a/meta/lib/oeqa/runtime/date.py +++ b/meta/lib/oeqa/runtime/date.py @@ -4,6 +4,7 @@ import re class DateTest(oeRuntimeTest): + @testcase(211) @skipUnlessPassed("test_ssh") def test_date(self): (status, output) = self.target.run('date +"%Y-%m-%d %T"') diff --git a/meta/lib/oeqa/runtime/df.py b/meta/lib/oeqa/runtime/df.py index b6da35027c..09569d5ff6 100644 --- a/meta/lib/oeqa/runtime/df.py +++ b/meta/lib/oeqa/runtime/df.py @@ -5,6 +5,7 @@ from oeqa.utils.decorators import * class DfTest(oeRuntimeTest): + @testcase(234) @skipUnlessPassed("test_ssh") def test_df(self): (status,output) = self.target.run("df / | sed -n '2p' | awk '{print $4}'") diff --git a/meta/lib/oeqa/runtime/dmesg.py b/meta/lib/oeqa/runtime/dmesg.py index 64247ea704..5831471e50 100644 --- a/meta/lib/oeqa/runtime/dmesg.py +++ b/meta/lib/oeqa/runtime/dmesg.py @@ -5,7 +5,8 @@ from oeqa.utils.decorators import * class DmesgTest(oeRuntimeTest): + @testcase(215) @skipUnlessPassed('test_ssh') def test_dmesg(self): - (status, output) = self.target.run('dmesg | grep -v mmci-pl18x | grep -v "error changing net interface name" | grep -iv "dma timeout" | grep -i error') + (status, output) = self.target.run('dmesg | grep -v mmci-pl18x | grep -v "error changing net interface name" | grep -iv "dma timeout" | grep -v usbhid | grep -i error') self.assertEqual(status, 1, msg = "Error messages in dmesg log: %s" % output) diff --git a/meta/lib/oeqa/runtime/files/test.cpp b/meta/lib/oeqa/runtime/files/test.cpp new file mode 100644 index 0000000000..9e1a76473d --- /dev/null +++ b/meta/lib/oeqa/runtime/files/test.cpp @@ -0,0 +1,3 @@ +#include <limits> + +int main() {}
\ No newline at end of file diff --git a/meta/lib/oeqa/runtime/gcc.py b/meta/lib/oeqa/runtime/gcc.py index b63badd3e4..a7f62e1758 100644 --- a/meta/lib/oeqa/runtime/gcc.py +++ b/meta/lib/oeqa/runtime/gcc.py @@ -14,19 +14,29 @@ class GccCompileTest(oeRuntimeTest): def setUpClass(self): oeRuntimeTest.tc.target.copy_to(os.path.join(oeRuntimeTest.tc.filesdir, "test.c"), "/tmp/test.c") oeRuntimeTest.tc.target.copy_to(os.path.join(oeRuntimeTest.tc.filesdir, "testmakefile"), "/tmp/testmakefile") + oeRuntimeTest.tc.target.copy_to(os.path.join(oeRuntimeTest.tc.filesdir, "test.cpp"), "/tmp/test.cpp") + @testcase(203) def test_gcc_compile(self): (status, output) = self.target.run('gcc /tmp/test.c -o /tmp/test -lm') self.assertEqual(status, 0, msg="gcc compile failed, output: %s" % output) (status, output) = self.target.run('/tmp/test') self.assertEqual(status, 0, msg="running compiled file failed, output %s" % output) + @testcase(200) def test_gpp_compile(self): (status, output) = self.target.run('g++ /tmp/test.c -o /tmp/test -lm') self.assertEqual(status, 0, msg="g++ compile failed, output: %s" % output) (status, output) = self.target.run('/tmp/test') self.assertEqual(status, 0, msg="running compiled file failed, output %s" % output) + def test_gpp2_compile(self): + (status, output) = self.target.run('g++ /tmp/test.cpp -o /tmp/test -lm') + self.assertEqual(status, 0, msg="g++ compile failed, output: %s" % output) + (status, output) = self.target.run('/tmp/test') + self.assertEqual(status, 0, msg="running compiled file failed, output %s" % output) + + @testcase(204) def test_make(self): (status, output) = self.target.run('cd /tmp; make -f testmakefile') self.assertEqual(status, 0, msg="running make failed, output %s" % output) diff --git a/meta/lib/oeqa/runtime/kernelmodule.py b/meta/lib/oeqa/runtime/kernelmodule.py index cbc5742eff..2e81720327 100644 --- a/meta/lib/oeqa/runtime/kernelmodule.py +++ b/meta/lib/oeqa/runtime/kernelmodule.py @@ -14,6 +14,7 @@ class KernelModuleTest(oeRuntimeTest): self.target.copy_to(os.path.join(oeRuntimeTest.tc.filesdir, "hellomod.c"), "/tmp/hellomod.c") self.target.copy_to(os.path.join(oeRuntimeTest.tc.filesdir, "hellomod_makefile"), "/tmp/Makefile") + @testcase('316') @skipUnlessPassed('test_ssh') @skipUnlessPassed('test_gcc_compile') def test_kernel_module(self): diff --git a/meta/lib/oeqa/runtime/ldd.py b/meta/lib/oeqa/runtime/ldd.py index 4374530fc4..bce56c4270 100644 --- a/meta/lib/oeqa/runtime/ldd.py +++ b/meta/lib/oeqa/runtime/ldd.py @@ -1,5 +1,5 @@ import unittest -from oeqa.oetest import oeRuntimeTest +from oeqa.oetest import oeRuntimeTest, skipModule from oeqa.utils.decorators import * def setUpModule(): @@ -13,6 +13,7 @@ class LddTest(oeRuntimeTest): (status, output) = self.target.run('which ldd') self.assertEqual(status, 0, msg = "ldd does not exist in PATH: which ldd: %s" % output) + @testcase(239) @skipUnlessPassed('test_ldd_exists') def test_ldd_rtldlist_check(self): (status, output) = self.target.run('for i in $(which ldd | xargs cat | grep "^RTLDLIST"|cut -d\'=\' -f2|tr -d \'"\'); do test -f $i && echo $i && break; done') diff --git a/meta/lib/oeqa/runtime/logrotate.py b/meta/lib/oeqa/runtime/logrotate.py index 80489a3267..86d791c300 100644 --- a/meta/lib/oeqa/runtime/logrotate.py +++ b/meta/lib/oeqa/runtime/logrotate.py @@ -19,6 +19,7 @@ class LogrotateTest(oeRuntimeTest): (status, output) = self.target.run("sed -i 's#wtmp {#wtmp {\\n olddir /home/root/logrotate_dir#' /etc/logrotate.conf") self.assertEqual(status, 0, msg = "Could not write to logrotate.conf file. Status and output: %s and %s)" % (status, output)) + @testcase(289) @skipUnlessPassed("test_1_logrotate_setup") def test_2_logrotate(self): (status, output) = self.target.run('logrotate -f /etc/logrotate.conf') diff --git a/meta/lib/oeqa/runtime/multilib.py b/meta/lib/oeqa/runtime/multilib.py index 13a3b54b18..ab0a6ccd69 100644 --- a/meta/lib/oeqa/runtime/multilib.py +++ b/meta/lib/oeqa/runtime/multilib.py @@ -10,6 +10,7 @@ def setUpModule(): class MultilibTest(oeRuntimeTest): + @testcase('279') @skipUnlessPassed('test_ssh') def test_file_connman(self): self.assertTrue(oeRuntimeTest.hasPackage('connman-gnome'), msg="This test assumes connman-gnome is installed") diff --git a/meta/lib/oeqa/runtime/pam.py b/meta/lib/oeqa/runtime/pam.py index 52e1eb88e6..c8205c9abc 100644 --- a/meta/lib/oeqa/runtime/pam.py +++ b/meta/lib/oeqa/runtime/pam.py @@ -2,7 +2,7 @@ # Note that the image under test must have "pam" in DISTRO_FEATURES import unittest -from oeqa.oetest import oeRuntimeTest +from oeqa.oetest import oeRuntimeTest, skipModule from oeqa.utils.decorators import * def setUpModule(): @@ -12,13 +12,14 @@ def setUpModule(): class PamBasicTest(oeRuntimeTest): + @testcase(287) @skipUnlessPassed('test_ssh') def test_pam(self): (status, output) = self.target.run('login --help') self.assertEqual(status, 1, msg = "login command does not work as expected. Status and output:%s and %s" %(status, output)) (status, output) = self.target.run('passwd --help') - self.assertEqual(status, 6, msg = "passwd command does not work as expected. Status and output:%s and %s" %(status, output)) + self.assertEqual(status, 0, msg = "passwd command does not work as expected. Status and output:%s and %s" %(status, output)) (status, output) = self.target.run('su --help') - self.assertEqual(status, 2, msg = "su command does not work as expected. Status and output:%s and %s" %(status, output)) + self.assertEqual(status, 0, msg = "su command does not work as expected. Status and output:%s and %s" %(status, output)) (status, output) = self.target.run('useradd --help') - self.assertEqual(status, 2, msg = "useradd command does not work as expected. Status and output:%s and %s" %(status, output)) + self.assertEqual(status, 0, msg = "useradd command does not work as expected. Status and output:%s and %s" %(status, output)) diff --git a/meta/lib/oeqa/runtime/parselogs.py b/meta/lib/oeqa/runtime/parselogs.py new file mode 100644 index 0000000000..2953742f23 --- /dev/null +++ b/meta/lib/oeqa/runtime/parselogs.py @@ -0,0 +1,202 @@ +import os +import unittest +from oeqa.oetest import oeRuntimeTest +from oeqa.utils.decorators import * + +#in the future these lists could be moved outside of module +errors = ["error", "cannot", "can\'t", "failed"] + +common_errors = [ + "(WW) warning, (EE) error, (NI) not implemented, (??) unknown.", + "dma timeout", + "can\'t add hid device:", + "usbhid: probe of ", + "_OSC failed (AE_ERROR)", + "_OSC failed (AE_SUPPORT)", + "AE_ALREADY_EXISTS" + "ACPI _OSC request failed (AE_SUPPORT)" + "can\'t disable ASPM", + "Failed to load module \"vesa\"", + "Failed to load module vesa", + "Failed to load module \"modesetting\"", + "Failed to load module modesetting", + "Failed to load module \"glx\"", + "Failed to load module glx", + "[drm] Cannot find any crtc or sizes - going 1024x768" + ] + +x86_common = [ + '[drm:psb_do_init] *ERROR* Debug is', + 'wrong ELF class', + 'Could not enable PowerButton event', + 'probe of LNXPWRBN:00 failed with error -22', +] + common_errors + +qemux86_common = [ + 'Fast TSC calibration', + '_OSC failed (AE_NOT_FOUND); disabling ASPM', + 'Open ACPI failed (/var/run/acpid.socket) (No such file or directory)', + 'wrong ELF class', +] + common_errors + +ignore_errors = { + 'default' : common_errors, + 'qemux86' : [ + 'Failed to access perfctr msr (MSR c1 is 0)', + "fail to add MMCONFIG information, can't access extended PCI configuration space under this bridge.", + ] + qemux86_common, + 'qemux86-64' : qemux86_common, + 'qemumips' : [ + 'Failed to load module "glx"', + ] + common_errors, + 'qemuppc' : [ + 'PCI 0000:00 Cannot reserve Legacy IO [io 0x0000-0x0fff]', + 'host side 80-wire cable detection failed, limiting max speed', + 'mode "640x480" test failed', + 'Failed to load module "glx"', + ] + common_errors, + 'qemuarm' : [ + 'mmci-pl18x: probe of fpga:05 failed with error -22', + 'mmci-pl18x: probe of fpga:0b failed with error -22', + 'Failed to load module "glx"' + ] + common_errors, + 'emenlow' : x86_common, + 'crownbay' : x86_common, + 'genericx86' : x86_common, + 'genericx86-64' : x86_common, + 'edgerouter' : [ + 'Fatal server error:', + ] + common_errors, + 'minnow' : [ + 'netlink init failed', + 'NETLINK INITIALIZATION FAILED', + ] + common_errors, + 'jasperforest' : [ + 'Activated service \'org.bluez\' failed:', + 'Unable to find NFC netlink family', + 'netlink init failed', + 'NETLINK INITIALIZATION FAILED', + ] + common_errors, +} + +log_locations = ["/var/log/","/var/log/dmesg", "/tmp/dmesg_output.log"] + +class ParseLogsTest(oeRuntimeTest): + + @classmethod + def setUpClass(self): + self.errors = errors + self.ignore_errors = ignore_errors + self.log_locations = log_locations + self.msg = "" + + def getMachine(self): + (status, output) = self.target.run("uname -n") + return output + + #get some information on the CPU of the machine to display at the beginning of the output. This info might be useful in some cases. + def getHardwareInfo(self): + hwi = "" + (status, cpu_name) = self.target.run("cat /proc/cpuinfo | grep \"model name\" | head -n1 | awk 'BEGIN{FS=\":\"}{print $2}'") + (status, cpu_physical_cores) = self.target.run("cat /proc/cpuinfo | grep \"cpu cores\" | head -n1 | awk {'print $4'}") + (status, cpu_logical_cores) = self.target.run("cat /proc/cpuinfo | grep \"processor\" | wc -l") + (status, cpu_arch) = self.target.run("uname -m") + hwi += "Machine information: \n" + hwi += "*******************************\n" + hwi += "Machine name: "+self.getMachine()+"\n" + hwi += "CPU: "+str(cpu_name)+"\n" + hwi += "Arch: "+str(cpu_arch)+"\n" + hwi += "Physical cores: "+str(cpu_physical_cores)+"\n" + hwi += "Logical cores: "+str(cpu_logical_cores)+"\n" + hwi += "*******************************\n" + return hwi + + #go through the log locations provided and if it's a folder create a list with all the .log files in it, if it's a file just add + #it to that list + def getLogList(self, log_locations): + logs = [] + for location in log_locations: + (status, output) = self.target.run("test -f "+str(location)) + if (status == 0): + logs.append(str(location)) + else: + (status, output) = self.target.run("test -d "+str(location)) + if (status == 0): + (status, output) = self.target.run("find "+str(location)+"/*.log -maxdepth 1 -type f") + if (status == 0): + output = output.splitlines() + for logfile in output: + logs.append(os.path.join(location,str(logfile))) + return logs + + #build the grep command to be used with filters and exclusions + def build_grepcmd(self, errors, ignore_errors, log): + grepcmd = "grep " + grepcmd +="-Ei \"" + for error in errors: + grepcmd += error+"|" + grepcmd = grepcmd[:-1] + grepcmd += "\" "+str(log)+" | grep -Eiv \'" + try: + errorlist = ignore_errors[self.getMachine()] + except KeyError: + self.msg += "No ignore list found for this machine, using default\n" + errorlist = ignore_errors['default'] + for ignore_error in errorlist: + ignore_error = ignore_error.replace("(", "\(") + ignore_error = ignore_error.replace(")", "\)") + ignore_error = ignore_error.replace("'", ".") + ignore_error = ignore_error.replace("?", "\?") + ignore_error = ignore_error.replace("[", "\[") + ignore_error = ignore_error.replace("]", "\]") + ignore_error = ignore_error.replace("*", "\*") + grepcmd += ignore_error+"|" + grepcmd = grepcmd[:-1] + grepcmd += "\'" + return grepcmd + + #grep only the errors so that their context could be collected. Default context is 10 lines before and after the error itself + def parse_logs(self, errors, ignore_errors, logs, lines_before = 10, lines_after = 10): + results = {} + rez = [] + for log in logs: + thegrep = self.build_grepcmd(errors, ignore_errors, log) + try: + (status, result) = self.target.run(thegrep) + except: + pass + if result: + results[log] = {} + rez = result.splitlines() + for xrez in rez: + command = "grep \"\\"+str(xrez)+"\" -B "+str(lines_before)+" -A "+str(lines_after)+" "+str(log) + try: + (status, yrez) = self.target.run(command) + except: + pass + results[log][xrez]=yrez + return results + + #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") + (status, dmesg2) = self.target.run("echo \""+str(dmesg)+"\" > /tmp/dmesg_output.log") + + @skipUnlessPassed('test_ssh') + def test_parselogs(self): + self.write_dmesg() + log_list = self.getLogList(self.log_locations) + result = self.parse_logs(self.errors, self.ignore_errors, log_list) + print self.getHardwareInfo() + errcount = 0 + for log in result: + self.msg += "Log: "+log+"\n" + self.msg += "-----------------------\n" + for error in result[log]: + errcount += 1 + self.msg += "Central error: "+str(error)+"\n" + self.msg += "***********************\n" + self.msg += result[str(log)][str(error)]+"\n" + self.msg += "***********************\n" + self.msg += "%s errors found in logs." % errcount + self.assertEqual(errcount, 0, msg=self.msg) diff --git a/meta/lib/oeqa/runtime/perl.py b/meta/lib/oeqa/runtime/perl.py index c9bb684c11..65da028d4b 100644 --- a/meta/lib/oeqa/runtime/perl.py +++ b/meta/lib/oeqa/runtime/perl.py @@ -18,6 +18,7 @@ class PerlTest(oeRuntimeTest): (status, output) = self.target.run('which perl') self.assertEqual(status, 0, msg="Perl binary not in PATH or not on target.") + @testcase(208) def test_perl_works(self): (status, output) = self.target.run('perl /tmp/test.pl') self.assertEqual(status, 0, msg="Exit status was not 0. Output: %s" % output) diff --git a/meta/lib/oeqa/runtime/python.py b/meta/lib/oeqa/runtime/python.py index c037ab2c18..0387b9a03e 100644 --- a/meta/lib/oeqa/runtime/python.py +++ b/meta/lib/oeqa/runtime/python.py @@ -18,6 +18,7 @@ class PythonTest(oeRuntimeTest): (status, output) = self.target.run('which python') self.assertEqual(status, 0, msg="Python binary not in PATH or not on target.") + @testcase(965) def test_python_stdout(self): (status, output) = self.target.run('python /tmp/test.py') self.assertEqual(status, 0, msg="Exit status was not 0. Output: %s" % output) diff --git a/meta/lib/oeqa/runtime/rpm.py b/meta/lib/oeqa/runtime/rpm.py index 084d22f96b..b17e8b46a8 100644 --- a/meta/lib/oeqa/runtime/rpm.py +++ b/meta/lib/oeqa/runtime/rpm.py @@ -18,6 +18,7 @@ class RpmBasicTest(oeRuntimeTest): (status, output) = self.target.run('rpm --help') self.assertEqual(status, 0, msg="status and output: %s and %s" % (status,output)) + @testcase(191) @skipUnlessPassed('test_rpm_help') def test_rpm_query(self): (status, output) = self.target.run('rpm -q rpm') @@ -34,11 +35,13 @@ class RpmInstallRemoveTest(oeRuntimeTest): testrpmfile = f oeRuntimeTest.tc.target.copy_to(os.path.join(rpmdir,testrpmfile), "/tmp/rpm-doc.rpm") + @testcase(192) @skipUnlessPassed('test_rpm_help') def test_rpm_install(self): (status, output) = self.target.run('rpm -ivh /tmp/rpm-doc.rpm') self.assertEqual(status, 0, msg="Failed to install rpm-doc package: %s" % output) + @testcase(194) @skipUnlessPassed('test_rpm_install') def test_rpm_remove(self): (status,output) = self.target.run('rpm -e rpm-doc') diff --git a/meta/lib/oeqa/runtime/scanelf.py b/meta/lib/oeqa/runtime/scanelf.py index b9abf24640..43a024ab9a 100644 --- a/meta/lib/oeqa/runtime/scanelf.py +++ b/meta/lib/oeqa/runtime/scanelf.py @@ -11,6 +11,7 @@ class ScanelfTest(oeRuntimeTest): def setUp(self): self.scancmd = 'scanelf --quiet --recursive --mount --ldpath --path' + @testcase(966) @skipUnlessPassed('test_ssh') def test_scanelf_textrel(self): # print TEXTREL information @@ -18,6 +19,7 @@ class ScanelfTest(oeRuntimeTest): (status, output) = self.target.run(self.scancmd) self.assertEqual(output.strip(), "", "\n".join([self.scancmd, output])) + @testcase(967) @skipUnlessPassed('test_ssh') def test_scanelf_rpath(self): # print RPATH information diff --git a/meta/lib/oeqa/runtime/scp.py b/meta/lib/oeqa/runtime/scp.py index 03095bf966..48e87d2d0b 100644 --- a/meta/lib/oeqa/runtime/scp.py +++ b/meta/lib/oeqa/runtime/scp.py @@ -1,6 +1,6 @@ import os from oeqa.oetest import oeRuntimeTest, skipModule -from oeqa.utils.decorators import skipUnlessPassed +from oeqa.utils.decorators import skipUnlessPassed, testcase def setUpModule(): if not (oeRuntimeTest.hasPackage("dropbear") or oeRuntimeTest.hasPackage("openssh-sshd")): @@ -8,6 +8,7 @@ def setUpModule(): class ScpTest(oeRuntimeTest): + @testcase(220) @skipUnlessPassed('test_ssh') def test_scp_file(self): test_log_dir = oeRuntimeTest.tc.d.getVar("TEST_LOG_DIR", True) diff --git a/meta/lib/oeqa/runtime/skeletoninit.py b/meta/lib/oeqa/runtime/skeletoninit.py index 557e715a3e..7c7f402e5d 100644 --- a/meta/lib/oeqa/runtime/skeletoninit.py +++ b/meta/lib/oeqa/runtime/skeletoninit.py @@ -2,7 +2,7 @@ # Note that the image under test must have meta-skeleton layer in bblayers and IMAGE_INSTALL_append = " service" in local.conf import unittest -from oeqa.oetest import oeRuntimeTest +from oeqa.oetest import oeRuntimeTest, skipModule from oeqa.utils.decorators import * def setUpModule(): @@ -20,6 +20,7 @@ class SkeletonBasicTest(oeRuntimeTest): (status, output) = self.target.run('ls /usr/sbin/skeleton-test') self.assertEqual(status, 0, msg = "skeleton-test not found. Output:\n%s" % output) + @testcase(284) @skipUnlessPassed('test_skeleton_availability') @unittest.skipIf("systemd" == oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager"), "Not appropiate for systemd image") def test_skeleton_script(self): diff --git a/meta/lib/oeqa/runtime/smart.py b/meta/lib/oeqa/runtime/smart.py index 195f1170c6..3b49314df7 100644 --- a/meta/lib/oeqa/runtime/smart.py +++ b/meta/lib/oeqa/runtime/smart.py @@ -1,6 +1,6 @@ import unittest import re -from oeqa.oetest import oeRuntimeTest +from oeqa.oetest import oeRuntimeTest, skipModule from oeqa.utils.decorators import * from oeqa.utils.httpserver import HTTPService @@ -25,6 +25,7 @@ class SmartTest(oeRuntimeTest): class SmartBasicTest(SmartTest): + @testcase(716) @skipUnlessPassed('test_ssh') def test_smart_help(self): self.smart('--help') @@ -32,15 +33,19 @@ class SmartBasicTest(SmartTest): def test_smart_version(self): self.smart('--version') + @testcase(721) def test_smart_info(self): self.smart('info python-smartpm') + @testcase(421) def test_smart_query(self): self.smart('query python-smartpm') + @testcase(720) def test_smart_search(self): self.smart('search python-smartpm') + @testcase(722) def test_smart_stats(self): self.smart('stats') @@ -58,6 +63,7 @@ class SmartRepoTest(SmartTest): def test_smart_channel(self): self.smart('channel', 1) + @testcase(719) def test_smart_channel_add(self): image_pkgtype = self.tc.d.getVar('IMAGE_PKGTYPE', True) deploy_url = 'http://%s:%s/%s' %(self.target.server_ip, self.repo_server.port, image_pkgtype) @@ -76,6 +82,7 @@ class SmartRepoTest(SmartTest): def test_smart_channel_show(self): self.smart('channel --show') + @testcase(717) def test_smart_channel_rpmsys(self): self.smart('channel --show rpmsys') self.smart('channel --disable rpmsys') @@ -86,17 +93,20 @@ class SmartRepoTest(SmartTest): self.smart('remove -y psplash-default') self.smart('install -y psplash-default') + @testcase(728) @skipUnlessPassed('test_smart_install') def test_smart_install_dependency(self): self.smart('remove -y psplash') self.smart('install -y psplash-default') + @testcase(723) @skipUnlessPassed('test_smart_channel_add') def test_smart_install_from_disk(self): self.smart('remove -y psplash-default') self.smart('download psplash-default') self.smart('install -y ./psplash-default*') + @testcase(725) @skipUnlessPassed('test_smart_channel_add') def test_smart_install_from_http(self): output = self.smart('download --urls psplash-default') @@ -105,6 +115,7 @@ class SmartRepoTest(SmartTest): self.smart('remove -y psplash-default') self.smart('install -y %s' % url.group(0)) + @testcase(729) @skipUnlessPassed('test_smart_install') def test_smart_reinstall(self): self.smart('reinstall -y psplash-default') diff --git a/meta/lib/oeqa/runtime/ssh.py b/meta/lib/oeqa/runtime/ssh.py index e64866019f..0e76d5d512 100644 --- a/meta/lib/oeqa/runtime/ssh.py +++ b/meta/lib/oeqa/runtime/ssh.py @@ -10,6 +10,7 @@ def setUpModule(): class SshTest(oeRuntimeTest): + @testcase(224) @skipUnlessPassed('test_ping') def test_ssh(self): (status, output) = self.target.run('uname -a') diff --git a/meta/lib/oeqa/runtime/syslog.py b/meta/lib/oeqa/runtime/syslog.py index b95b36175a..7fa018e97f 100644 --- a/meta/lib/oeqa/runtime/syslog.py +++ b/meta/lib/oeqa/runtime/syslog.py @@ -13,6 +13,7 @@ class SyslogTest(oeRuntimeTest): (status,output) = self.target.run('/sbin/syslogd --help') self.assertEqual(status, 0, msg="status and output: %s and %s" % (status,output)) + @testcase(201) @skipUnlessPassed("test_syslog_help") def test_syslog_running(self): (status,output) = self.target.run(oeRuntimeTest.pscmd + ' | grep -i [s]yslogd') @@ -33,6 +34,7 @@ class SyslogTestConfig(oeRuntimeTest): else: (status,output) = self.target.run('systemctl restart syslog.service') + @testcase(202) @skipUnlessPassed("test_syslog_restart") @skipUnlessPassed("test_syslog_logger") @unittest.skipIf("systemd" == oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager"), "Not appropiate for systemd image") diff --git a/meta/lib/oeqa/runtime/systemd.py b/meta/lib/oeqa/runtime/systemd.py index 6de84f891b..1451698bb3 100644 --- a/meta/lib/oeqa/runtime/systemd.py +++ b/meta/lib/oeqa/runtime/systemd.py @@ -28,6 +28,7 @@ class SystemdBasicTests(SystemdTest): def test_systemd_basic(self): self.systemctl('--version') + @testcase(551) @skipUnlessPassed('test_system_basic') def test_systemd_list(self): self.systemctl('list-unit-files') @@ -51,6 +52,7 @@ class SystemdBasicTests(SystemdTest): return (False, output) time.sleep(10) + @testcase(550) @skipUnlessPassed('test_systemd_basic') def test_systemd_failed(self): settled, output = self.settle() @@ -69,6 +71,7 @@ class SystemdServiceTests(SystemdTest): def test_systemd_status(self): self.systemctl('status --full', 'avahi-daemon.service') + @testcase(695) @skipUnlessPassed('test_systemd_status') def test_systemd_stop_start(self): self.systemctl('stop', 'avahi-daemon.service') @@ -76,6 +79,7 @@ class SystemdServiceTests(SystemdTest): self.systemctl('start','avahi-daemon.service') self.systemctl('is-active', 'avahi-daemon.service', verbose=True) + @testcase(696) @skipUnlessPassed('test_systemd_basic') def test_systemd_disable_enable(self): self.systemctl('disable', 'avahi-daemon.service') diff --git a/meta/lib/oeqa/runtime/vnc.py b/meta/lib/oeqa/runtime/vnc.py index 5ed10727bc..f31deff306 100644 --- a/meta/lib/oeqa/runtime/vnc.py +++ b/meta/lib/oeqa/runtime/vnc.py @@ -1,4 +1,4 @@ -from oeqa.oetest import oeRuntimeTest +from oeqa.oetest import oeRuntimeTest, skipModuleUnless from oeqa.utils.decorators import * import re @@ -7,6 +7,7 @@ def setUpModule(): class VNCTest(oeRuntimeTest): + @testcase(213) @skipUnlessPassed('test_ssh') def test_vnc(self): (status, output) = self.target.run('x11vnc -display :0 -bg -o x11vnc.log') diff --git a/meta/lib/oeqa/runtime/x32lib.py b/meta/lib/oeqa/runtime/x32lib.py index 6bad201b12..ce5e214035 100644 --- a/meta/lib/oeqa/runtime/x32lib.py +++ b/meta/lib/oeqa/runtime/x32lib.py @@ -10,6 +10,7 @@ def setUpModule(): class X32libTest(oeRuntimeTest): + @testcase(281) @skipUnlessPassed("test_ssh") def test_x32_file(self): status1 = self.target.run("readelf -h /bin/ls | grep Class | grep ELF32")[0] diff --git a/meta/lib/oeqa/runtime/xorg.py b/meta/lib/oeqa/runtime/xorg.py index 12dccd8198..a07031e5c8 100644 --- a/meta/lib/oeqa/runtime/xorg.py +++ b/meta/lib/oeqa/runtime/xorg.py @@ -14,8 +14,4 @@ class XorgTest(oeRuntimeTest): (status, output) = self.target.run(oeRuntimeTest.pscmd + ' | grep -v xinit | grep [X]org') self.assertEqual(status, 0, msg="Xorg does not appear to be running %s" % self.target.run(oeRuntimeTest.pscmd)[1]) - @skipUnlessPassed('test_ssh') - def test_xorg_error(self): - (status, output) = self.target.run('cat /var/log/Xorg.0.log | grep -v "(EE) error," | grep -v "PreInit" | grep -v "evdev:" | grep -v "glx" | grep "(EE)"') - self.assertEqual(status, 1, msg="Errors in Xorg log: %s" % output) |