diff mbox series

[1/2] rootfs-postcommands,testimage: Move testdata generation to own task

Message ID 20230613095148.1269420-1-peter.hoyes@arm.com
State Superseded
Headers show
Series [1/2] rootfs-postcommands,testimage: Move testdata generation to own task | expand

Commit Message

Peter Hoyes June 13, 2023, 9:51 a.m. UTC
From: Peter Hoyes <Peter.Hoyes@arm.com>

write_image_test_data is currently a ROOTFS_POSTPROCESS_COMMAND, even
though it does not act on the rootfs. Additionally it is only required
when running testimage.

Promote it to its own task, to decouple it from rootfs generation, and
move it to testimage.bbclass

Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
---
 .../rootfs-postcommands.bbclass               | 23 -------------------
 meta/classes-recipe/testimage.bbclass         | 21 +++++++++++++++++
 2 files changed, 21 insertions(+), 23 deletions(-)
diff mbox series

Patch

diff --git a/meta/classes-recipe/rootfs-postcommands.bbclass b/meta/classes-recipe/rootfs-postcommands.bbclass
index 690fa976aa..ad7e7ccd8b 100644
--- a/meta/classes-recipe/rootfs-postcommands.bbclass
+++ b/meta/classes-recipe/rootfs-postcommands.bbclass
@@ -33,9 +33,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}${IMAGE_NAME_SUFFIX}.manifest"
 ROOTFS_POSTUNINSTALL_COMMAND =+ "write_image_manifest ; "
@@ -368,26 +365,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) and link_name:
-        testdata_link = os.path.join(deploy_dir, "%s.testdata.json" % link_name)
-        if testdata_link != testdata_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-recipe/testimage.bbclass b/meta/classes-recipe/testimage.bbclass
index b48cd96575..b23340420f 100644
--- a/meta/classes-recipe/testimage.bbclass
+++ b/meta/classes-recipe/testimage.bbclass
@@ -100,6 +100,27 @@  TESTIMAGE_DUMP_DIR ?= "${LOG_DIR}/runtime-hostdump/"
 
 TESTIMAGE_UPDATE_VARS ?= "DL_DIR WORKDIR DEPLOY_DIR_IMAGE IMAGE_LINK_NAME"
 
+# Generated test data json file
+python do_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) and link_name:
+        testdata_link = os.path.join(deploy_dir, "%s.testdata.json" % link_name)
+        if testdata_link != testdata_name:
+            if os.path.lexists(testdata_link):
+                os.remove(testdata_link)
+            os.symlink(os.path.basename(testdata_name), testdata_link)
+}
+do_write_image_test_data[vardepsexclude] += "TOPDIR"
+addtask write_image_test_data after do_rootfs before do_image_complete
+
 testimage_dump_target () {
     top -bn1
     ps