public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: Mikko Rapeli <mikko.rapeli@linaro.org>
To: openembedded-core@lists.openembedded.org
Cc: Mikko Rapeli <mikko.rapeli@linaro.org>
Subject: [PATCH 1/2] oeqa: add utils/data.py with get_data() function
Date: Thu, 17 Nov 2022 09:12:22 +0200	[thread overview]
Message-ID: <20221117071223.107064-2-mikko.rapeli@linaro.org> (raw)
In-Reply-To: <20221117071223.107064-1-mikko.rapeli@linaro.org>

get_data() uses oeqa test method name and an optional
key to get data from image specific "testimage_data.json"
file located in image deploy directory. Image recipes can
provide custom versions of this file which configures
generic tests for a specific image when testing with
testimage.bbclass

For example, the parselogs.py runtime test needs image
specific configuration when the image has new errors from
the kernel which acceptable and can be ignored.

Same machine can be used to generate multiple images with different
runtime behavior so using image as the key and not machine.

Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org>
---
 meta/lib/oeqa/utils/data.py | 41 +++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 meta/lib/oeqa/utils/data.py

diff --git a/meta/lib/oeqa/utils/data.py b/meta/lib/oeqa/utils/data.py
new file mode 100644
index 0000000000..4b8c10c1d0
--- /dev/null
+++ b/meta/lib/oeqa/utils/data.py
@@ -0,0 +1,41 @@
+# Copyright (C) 2022 Linaro Limited
+#
+# SPDX-License-Identifier: MIT
+
+import os
+import json
+
+from oeqa.core.utils.test import getCaseID, getCaseFile, getCaseMethod
+
+
+def get_data(self, key = None):
+    """get_data() returns test case specific data to the test case implementation.
+    Data is stored in image specific json file called "testimage_data.json" in
+    image deploy directory. Image recipes can provide custom versions of this file.
+    Data matching test method name and an optional key is returned to the test case.
+    This data can then be used by generic test cases to match image specific functionality
+    and expected behavior. For example list of expected kernel error strings, list
+    of active systemd services etc. can be image specific while the test case
+    implementation to check them is generic. Example json file for runtime
+    test parselogs.py to ignore image specific kernel error strings in dmesg:
+
+    {"test_parselogs":{"ignore_errors":[
+        "Error to be ignored in dmesg"
+    ]}}
+    """
+    test_method = getCaseMethod(self)
+    self.logger.info("%s: get_data() called by test_method =  %s, key = %s" % (__file__, test_method, key))
+
+    json_file_name = os.path.join(self.td['DEPLOY_DIR_IMAGE'], "testimage_data.json")
+    self.logger.debug("%s: json_file_name = %s" % (__file__, json_file_name))
+
+    with open(json_file_name) as json_file:
+        self.logger.debug("%s: json_file = %s" % (__file__, json_file))
+        json_data = json.load(json_file)
+        self.logger.debug("%s: json_data = %s" % (__file__, json_data))
+        if key:
+            data = json_data[test_method][key]
+        else:
+            data = json_data[test_method]
+        self.logger.debug("%s: data = %s" % (__file__, data))
+        return data
-- 
2.34.1



  reply	other threads:[~2022-11-17  7:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-17  7:12 [PATCH 0/2] image specific configuration with oeqa runtime tests Mikko Rapeli
2022-11-17  7:12 ` Mikko Rapeli [this message]
2022-11-17  7:12 ` [PATCH 2/2] oeqa parselogs.py: use get_data() to fetch image specific error list Mikko Rapeli
2022-11-17 14:22 ` [OE-core] [PATCH 0/2] image specific configuration with oeqa runtime tests Alexandre Belloni
2022-11-17 14:28   ` Mikko Rapeli
2022-11-17 15:17 ` Richard Purdie
2022-11-17 15:39   ` Mikko Rapeli
2022-11-17 16:57     ` Richard Purdie
2022-11-18 14:32       ` Mikko Rapeli
2022-11-18 15:04         ` Richard Purdie
2022-11-18 15:57           ` Mikko Rapeli
2022-11-18 16:04             ` Richard Purdie
2022-11-18 16:09               ` Mikko Rapeli
2022-11-18 16:11             ` Richard Purdie

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=20221117071223.107064-2-mikko.rapeli@linaro.org \
    --to=mikko.rapeli@linaro.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox