All of lore.kernel.org
 help / color / mirror / Atom feed
From: Armin Kuster <akuster808@gmail.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 03/20] OEQA: Centrilize the base LTP routines
Date: Mon, 11 Nov 2019 20:33:22 -0800	[thread overview]
Message-ID: <eb15718f4975218f5c8bd5c3c2f475d24728cfc9.1573532188.git.akuster808@gmail.com> (raw)
In-Reply-To: <cover.1573532188.git.akuster808@gmail.com>

Signed-off-by: Armin Kuster <akuster808@gmail.com>
---
 meta/lib/oeqa/utils/ltp.py | 133 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 133 insertions(+)
 create mode 100644 meta/lib/oeqa/utils/ltp.py

diff --git a/meta/lib/oeqa/utils/ltp.py b/meta/lib/oeqa/utils/ltp.py
new file mode 100644
index 0000000..5e07f4d
--- /dev/null
+++ b/meta/lib/oeqa/utils/ltp.py
@@ -0,0 +1,133 @@
+# LTP base 
+#
+# Copyright (c) 2019 MontaVista Software, LLC
+#
+# SPDX-License-Identifier: GPL-2.0-only
+#
+
+import time
+import datetime
+import pprint
+
+from oeqa.runtime.case import OERuntimeTestCase
+
+class LtpBase(OERuntimeTestCase):
+    '''
+    Base routines for LTP based testing
+    '''
+
+    @classmethod
+    def setUpClass(cls):
+        cls.ltp_startup()
+
+    @classmethod
+    def tearDownClass(cls):
+        cls.ltp_finishup()
+
+    @classmethod
+    def ltp_startup(cls):
+        cls.sections = {}
+        cls.failmsg = ""
+        cls.cmd = ""
+        test_log_dir = os.path.join(cls.td.get('WORKDIR', ''), 'testimage')
+        timestamp = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
+
+        cls.ltptest_log_dir_link = os.path.join(test_log_dir, 'ltp_log')
+        cls.ltptest_log_dir = '%s.%s' % (cls.ltptest_log_dir_link, timestamp)
+        os.makedirs(cls.ltptest_log_dir)
+
+        cls.tc.target.run("mkdir -p /opt/ltp/results")
+
+        if not hasattr(cls.tc, "extraresults"):
+            cls.tc.extraresults = {}
+        cls.extras = cls.tc.extraresults
+        cls.extras['ltpresult.rawlogs'] = {'log': ""}
+
+    @classmethod
+    def runltp(cls, ltp_group):
+        starttime = time.time()
+        (status, output) = cls.tc.target.run(cls.cmd)
+        endtime = time.time()
+
+        with open(os.path.join(cls.ltptest_log_dir, "%s-raw.log" % ltp_group), 'w') as f:
+            f.write(output)
+
+        cls.extras['ltpresult.rawlogs']['log'] = cls.extras['ltpresult.rawlogs']['log'] + output
+
+        # copy nice log from DUT
+        dst = os.path.join(cls.ltptest_log_dir, "%s" %  ltp_group )
+        remote_src = "/opt/ltp/results/%s" % ltp_group 
+        (status, output) = cls.tc.target.copyFrom(remote_src, dst)
+        msg = 'File could not be copied. Output: %s' % output
+        self.assertEqual(status, 0, msg=msg)
+
+        parser = LtpParser()
+        results, sections  = parser.parse(dst)
+
+        runtime = int(endtime-starttime)
+        sections['duration'] = runtime
+        cls.sections[ltp_group] =  sections
+
+        failed_tests = {}
+        for test in results:
+            result = results[test]
+            testname = (logname + "." + ltp_group + "." + test)
+            cls.extras[testname] = {'status': result}
+            if result == 'FAILED':
+                failed_tests[ltp_group] = test 
+
+        if failed_tests:
+            cls.failmsg = cls.failmsg + "Failed ptests:\n%s" % pprint.pformat(failed_tests)
+
+class LtpTestBase(LtpBase):
+    '''
+    Ltp normal section definition
+    '''
+    @classmethod
+    def ltp_finishup(cls):
+        cls.extras['ltpresult.sections'] =  cls.sections
+
+        # update symlink to ltp_log
+        if os.path.exists(cls.ltptest_log_dir_link):
+            os.remove(cls.ltptest_log_dir_link)
+        os.symlink(os.path.basename(cls.ltptest_log_dir), cls.ltptest_log_dir_link)
+
+        if cls.failmsg:
+            cls.fail(cls.failmsg)
+
+class LtpPosixBase(LtpBase):
+    '''
+    Ltp Posix section definition
+    '''
+
+    @classmethod
+    def ltp_finishup(cls):
+        cls.extras['ltpposixresult.sections'] =  cls.sections
+
+        # update symlink to ltp_log
+        if os.path.exists(cls.ltptest_log_dir_link):
+            os.remove(cls.ltptest_log_dir_link)
+
+        os.symlink(os.path.basename(cls.ltptest_log_dir), cls.ltptest_log_dir_link)
+
+        if cls.failmsg:
+            cls.fail(cls.failmsg)
+
+
+class LtpStressBase(LtpBase):
+    '''
+    Ltp Stress test section definition
+    '''
+
+    @classmethod
+    def ltp_finishup(cls):
+        cls.extras['ltpstressresult.sections'] =  cls.sections
+
+        # update symlink to ltp_log
+        if os.path.exists(cls.ltptest_log_dir_link):
+            os.remove(cls.ltptest_log_dir_link)
+
+        os.symlink(os.path.basename(cls.ltptest_log_dir), cls.ltptest_log_dir_link)
+
+        if cls.failmsg:
+            cls.fail(cls.failmsg)
-- 
2.7.4



  parent reply	other threads:[~2019-11-12  4:33 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-12  4:33 [PATCH 00/20] QA updates Armin Kuster
2019-11-12  4:33 ` [PATCH 01/20] OEQA: Add a check for MACHINE Armin Kuster
2019-11-12  4:33 ` [PATCH 02/20] OEQA: Add qemu checks Armin Kuster
2019-11-12  4:33 ` Armin Kuster [this message]
2019-11-12  4:33 ` [PATCH 04/20] OEQA: update ltp runtimes to use new structure Armin Kuster
2019-11-14  1:53   ` Mittal, Anuj
2019-11-14  3:42     ` akuster808
2019-11-12  4:33 ` [PATCH 05/20] OEQA/runtime: Add ltp stress test Armin Kuster
2019-11-12  4:33 ` [PATCH 06/20] OEQA/manual: remove crash " Armin Kuster
2019-11-12  4:33 ` [PATCH 07/20] manual qa: drop ltpstress test Armin Kuster
2019-11-12  4:33 ` [PATCH 08/20] manual qa/bsp-qemu: remove rpm tests already done in runtime Armin Kuster
2019-11-12  4:33 ` [PATCH 09/20] manual qa/bsp-qemu: remove KVM enabled which is already done in selftest runqemu Armin Kuster
2019-11-12  4:33 ` [PATCH 10/20] manual/bsp-qemu: drop xserver test done at runtime Armin Kuster
2019-11-12  4:33 ` [PATCH 11/20] manual/bsp-qemu: remove only_one_connmand_in_background " Armin Kuster
2019-11-12  4:33 ` [PATCH 12/20] OEQA: remove postinit test done w/selftest runtime Armin Kuster
2019-11-12  4:33 ` [PATCH 13/20] OEQA: eclipse support was dropped in warrior Armin Kuster
2019-11-12  4:33 ` [PATCH 14/20] OEQA: move manual bash test to runtime Armin Kuster
2019-11-13  1:33   ` Mittal, Anuj
2019-11-13  1:49     ` akuster808
2019-11-12  4:33 ` [PATCH 15/20] OEQA: remove manual bash test Armin Kuster
2019-11-12  4:33 ` [PATCH 16/20] OEQA: remove manual useradd test Armin Kuster
2019-11-12  4:33 ` [PATCH 17/20] OEQA: move list-packageconfig-flags tests from manual to self Armin Kuster
2019-11-12  4:33 ` [PATCH 18/20] OEQA: remove manual PACKAGECONFIG_FLAGS tests Armin Kuster
2019-11-12  4:33 ` [PATCH 19/20] OEQA: add crosstab selftest Armin Kuster
2019-11-12  4:33 ` [PATCH 20/20] OEQA: remove crosstab test from manual Armin Kuster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=eb15718f4975218f5c8bd5c3c2f475d24728cfc9.1573532188.git.akuster808@gmail.com \
    --to=akuster808@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.