From: Paulo Neves <ptsneves@gmail.com>
To: openembedded-core@lists.openembedded.org
Subject: [meta-oe][PATCH v2 4/4] testimage: Moved write_image_test_data to testimage bbclass.
Date: Thu, 30 Aug 2018 19:49:36 +0200 [thread overview]
Message-ID: <1535651376-25467-4-git-send-email-ptsneves@gmail.com> (raw)
In-Reply-To: <1535651376-25467-1-git-send-email-ptsneves@gmail.com>
Previously the write_image_test_data was a rootfs post
process command. This function ran only when the rootfs
task was ran. Due to this if a variable was changed
or added to the datastore that would not trigger the do_rootfs
task, the variable would never be written into the json
file. Consequently the do_testimage task was potentially
unreproduceable and could fail if for some reason this
variable was then used.
In this commit we move the recording of the datastore to the
start of the do_testimage task. The do_testimage
task then reads this freshly generated json and passes it into
the normal test machinery. This approach allows for the test
machinery to still be loosely coupled to bitbake, and thus
still allows for the tests to be exported and used independently
from bitbake. The caveat is, if there are datastore changes
then the bitbake testimage task should be run before the tests
can be ran independently again.
Signed-off-by: Paulo Neves <ptsneves@gmail.com>
---
meta/classes/rootfs-postcommands.bbclass | 22 ----------------------
meta/classes/testimage.bbclass | 19 ++++++++++++++++++-
2 files changed, 18 insertions(+), 23 deletions(-)
diff --git a/meta/classes/rootfs-postcommands.bbclass b/meta/classes/rootfs-postcommands.bbclass
index e816824..a396c04 100644
--- a/meta/classes/rootfs-postcommands.bbclass
+++ b/meta/classes/rootfs-postcommands.bbclass
@@ -25,9 +25,6 @@ ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("IMAGE_FEATURES", "read-only
# and we don't want to disable such a default that by setting a value here.
APPEND_append = '${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", " ro", "", d)}'
-# Generates test data file with data store variables expanded in json format
-ROOTFS_POSTPROCESS_COMMAND += "write_image_test_data ; "
-
# Write manifest
IMAGE_MANIFEST = "${IMGDEPLOYDIR}/${IMAGE_NAME}.rootfs.manifest"
ROOTFS_POSTUNINSTALL_COMMAND =+ "write_image_manifest ; "
@@ -312,25 +309,6 @@ rootfs_sysroot_relativelinks () {
sysroot-relativelinks.py ${SDK_OUTPUT}/${SDKTARGETSYSROOT}
}
-# Generated test data json file
-python write_image_test_data() {
- from oe.data import export2json
-
- deploy_dir = d.getVar('IMGDEPLOYDIR')
- link_name = d.getVar('IMAGE_LINK_NAME')
- testdata_name = os.path.join(deploy_dir, "%s.testdata.json" % d.getVar('IMAGE_NAME'))
-
- searchString = "%s/"%(d.getVar("TOPDIR")).replace("//","/")
- export2json(d, testdata_name, searchString=searchString, replaceString="")
-
- if os.path.exists(testdata_name):
- testdata_link = os.path.join(deploy_dir, "%s.testdata.json" % link_name)
- if os.path.lexists(testdata_link):
- os.remove(testdata_link)
- os.symlink(os.path.basename(testdata_name), testdata_link)
-}
-write_image_test_data[vardepsexclude] += "TOPDIR"
-
# Check for unsatisfied recommendations (RRECOMMENDS)
python rootfs_log_check_recommends() {
log_path = d.expand("${T}/log.do_rootfs")
diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
index f58d11d..192febd 100644
--- a/meta/classes/testimage.bbclass
+++ b/meta/classes/testimage.bbclass
@@ -137,6 +137,21 @@ def testimage_sanity(d):
bb.fatal('When TEST_TARGET is set to "simpleremote" '
'TEST_TARGET_IP and TEST_SERVER_IP are needed too.')
+# Generated test data json file
+def write_image_test_data(d):
+ from oe.data import export2json
+
+ testdata = "%s/%s.testdata.json" % (d.getVar('DEPLOY_DIR_IMAGE'), d.getVar('IMAGE_NAME'))
+ testdata_link = "%s/%s.testdata.json" % (d.getVar('DEPLOY_DIR_IMAGE'), d.getVar('IMAGE_LINK_NAME'))
+
+ bb.utils.mkdirhier(os.path.dirname(testdata))
+ searchString = "%s/"%(d.getVar("TOPDIR")).replace("//","/")
+ export2json(d, testdata,searchString=searchString,replaceString="")
+ if testdata_link != testdata:
+ if os.path.lexists(testdata_link):
+ os.remove(testdata_link)
+ os.symlink(os.path.basename(testdata), testdata_link)
+
def testimage_main(d):
import os
import json
@@ -170,12 +185,14 @@ def testimage_main(d):
image_name = ("%s/%s" % (d.getVar('DEPLOY_DIR_IMAGE'),
d.getVar('IMAGE_LINK_NAME')))
+
+ write_image_test_data(d)
+
tdname = "%s.testdata.json" % image_name
try:
td = json.load(open(tdname, "r"))
except (FileNotFoundError) as err:
bb.fatal('File %s Not Found. Have you built the image with INHERIT+="testimage" in the conf/local.conf?' % tdname)
-
# Some variables need to be updates (mostly paths) with the
# ones of the current environment because some tests require them.
updateTestData(d, td, d.getVar('TESTIMAGE_UPDATE_VARS').split())
--
2.7.4
next prev parent reply other threads:[~2018-08-30 17:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-30 17:49 [meta-oe][PATCH v2 1/4] testimage: Refactoring and fixing Paulo Neves
2018-08-30 17:49 ` [meta-oe][PATCH v2 2/4] testimage: target.start exceptions not masked Paulo Neves
2018-08-30 17:49 ` [meta-oe][PATCH v2 3/4] masterimage: Check for rootfs path instead of file Paulo Neves
2018-08-30 17:49 ` Paulo Neves [this message]
2018-09-04 10:30 ` [meta-oe][PATCH v2 4/4] testimage: Moved write_image_test_data to testimage bbclass Richard Purdie
2018-10-02 8:19 ` Paulo Neves
2018-10-03 16:13 ` 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=1535651376-25467-4-git-send-email-ptsneves@gmail.com \
--to=ptsneves@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox