From patchwork Tue Feb 20 20:01:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexis_Lothor=C3=A9?= X-Patchwork-Id: 39822 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43D8EC5478A for ; Tue, 20 Feb 2024 20:02:18 +0000 (UTC) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by mx.groups.io with SMTP id smtpd.web11.23172.1708459329348752513 for ; Tue, 20 Feb 2024 12:02:09 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=O0xpDdKC; spf=pass (domain: bootlin.com, ip: 217.70.183.200, mailfrom: alexis.lothore@bootlin.com) Received: by mail.gandi.net (Postfix) with ESMTPSA id 7774320004; Tue, 20 Feb 2024 20:02:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708459327; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V65Jjte45q8m7VpMT0lSUFIVcFT9uvkDPGqTNQM8EO0=; b=O0xpDdKC0D9RDhFwMZTRr+nIXtsD5nNe7+gaYJVlvKn2WMi767htoVMloLoijMPfdoSzF8 Gh7/Fmv56fPm1mB5HzWJzfXNN3wqOgiSyBluxOajGAOb/IdAkfXA0sTdWxppKcz3jcP2Pv 5iO6P0tuGIiXxVOqT7oJZOaewNXImBaxj07sdnAAl2kNMhquW5QB+Y273I+YuDKc4Fpi6R aWxddxQ5RvN+l5m0rEddB3+zkd1ZIOP6jEE20mYxeWDXxdL0C4lApcDrQ8pkqg0AiQryYD YHFPr+h6sbx2PQKR23R5iEPzIZcYZ3VaUOmJdwMNG6jScsQfFjHj+zVfvEW8eQ== From: =?utf-8?q?Alexis_Lothor=C3=A9?= To: Cc: Thomas Petazzoni , Alexandre Belloni Subject: [OE-Core][PATCH 1/4] testimage: create a list of failed test post actions Date: Tue, 20 Feb 2024 21:01:56 +0100 Message-ID: <20240220200159.13419-2-alexis.lothore@bootlin.com> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240220200159.13419-1-alexis.lothore@bootlin.com> References: <20240220200159.13419-1-alexis.lothore@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: alexis.lothore@bootlin.com List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 20 Feb 2024 20:02:18 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/195927 From: Alexis Lothoré testimage is able to detect whenever a test run leads to some tests failing, and execute some actions in this case. The only action currently defined in such case is to retrieve artifacts from the target under test, as listed in TESTIMAGE_FAILED_QA_ARTIFACTS In order to be able to add multiple actions, define a central function to gather all "post actions" to run whenever a test has failed (run_failed_tests_post_actions). This function contains a table listing all functions to be called whenever a test fails. Any function in this table will be provided with bitbake internal data dictionary ("d") and the current runtime testing context ("tc"). Isolate all this feature in a dedicated bbclass file inherited by testimage. This patch does not bring any functional change. Signed-off-by: Alexis Lothoré --- .../failed-tests-post-actions.bbclass | 64 +++++++++++++++++++ meta/classes-recipe/testimage.bbclass | 42 +----------- 2 files changed, 66 insertions(+), 40 deletions(-) create mode 100644 meta/classes-recipe/failed-tests-post-actions.bbclass diff --git a/meta/classes-recipe/failed-tests-post-actions.bbclass b/meta/classes-recipe/failed-tests-post-actions.bbclass new file mode 100644 index 000000000000..7c7d3391298f --- /dev/null +++ b/meta/classes-recipe/failed-tests-post-actions.bbclass @@ -0,0 +1,64 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + + +################################################################## +# Artifacts retrieval +################################################################## + +def get_artifacts_list(target, raw_list): + result = [] + # Passed list may contains patterns in paths, expand them directly on target + for raw_path in raw_list.split(): + cmd = f"for p in {raw_path}; do if [ -e $p ]; then echo $p; fi; done" + try: + status, output = target.run(cmd) + if status != 0 or not output: + raise Exception() + result += output.split() + except: + bb.note(f"No file/directory matching path {raw_path}") + + return result + +def retrieve_test_artifacts(target, artifacts_list, target_dir): + import shutil + + local_artifacts_dir = os.path.join(target_dir, "artifacts") + if os.path.isdir(local_artifacts_dir): + shutil.rmtree(local_artifacts_dir) + + os.makedirs(local_artifacts_dir) + for artifact_path in artifacts_list: + if not os.path.isabs(artifact_path): + bb.warn(f"{artifact_path} is not an absolute path") + continue + try: + dest_dir = os.path.join(local_artifacts_dir, os.path.dirname(artifact_path[1:])) + os.makedirs(dest_dir, exist_ok=True) + target.copyFrom(artifact_path, dest_dir) + except Exception as e: + bb.warn(f"Can not retrieve {artifact_path} from test target: {e}") + +def list_and_fetch_failed_tests_artifacts(d, tc): + artifacts_list = get_artifacts_list(tc.target, d.getVar("TESTIMAGE_FAILED_QA_ARTIFACTS")) + if not artifacts_list: + bb.warn("Could not load artifacts list, skip artifacts retrieval") + else: + retrieve_test_artifacts(tc.target, artifacts_list, get_testimage_json_result_dir(d)) + + +################################################################## +# General post actions runner +################################################################## + +def run_failed_tests_post_actions(d, tc): + post_actions=[ + list_and_fetch_failed_tests_artifacts + ] + + for action in post_actions: + action(d, tc) diff --git a/meta/classes-recipe/testimage.bbclass b/meta/classes-recipe/testimage.bbclass index bee19674ef4f..d2b525d40f41 100644 --- a/meta/classes-recipe/testimage.bbclass +++ b/meta/classes-recipe/testimage.bbclass @@ -4,6 +4,7 @@ inherit metadata_scm inherit image-artifact-names +inherit failed-tests-post-actions # testimage.bbclass enables testing of qemu images using python unittests. # Most of the tests are commands run on target image over ssh. @@ -177,40 +178,6 @@ def get_testimage_boot_patterns(d): boot_patterns[flag] = flagval.encode().decode('unicode-escape') return boot_patterns -def get_artifacts_list(target, raw_list): - result = [] - # Passed list may contains patterns in paths, expand them directly on target - for raw_path in raw_list.split(): - cmd = f"for p in {raw_path}; do if [ -e $p ]; then echo $p; fi; done" - try: - status, output = target.run(cmd) - if status != 0 or not output: - raise Exception() - result += output.split() - except: - bb.note(f"No file/directory matching path {raw_path}") - - return result - -def retrieve_test_artifacts(target, artifacts_list, target_dir): - import shutil - - local_artifacts_dir = os.path.join(target_dir, "artifacts") - if os.path.isdir(local_artifacts_dir): - shutil.rmtree(local_artifacts_dir) - - os.makedirs(local_artifacts_dir) - for artifact_path in artifacts_list: - if not os.path.isabs(artifact_path): - bb.warn(f"{artifact_path} is not an absolute path") - continue - try: - dest_dir = os.path.join(local_artifacts_dir, os.path.dirname(artifact_path[1:])) - os.makedirs(dest_dir, exist_ok=True) - target.copyFrom(artifact_path, dest_dir) - except Exception as e: - bb.warn(f"Can not retrieve {artifact_path} from test target: {e}") - def testimage_main(d): import os import json @@ -406,12 +373,7 @@ def testimage_main(d): results = tc.runTests() complete = True if results.hasAnyFailingTest(): - artifacts_list = get_artifacts_list(tc.target, d.getVar("TESTIMAGE_FAILED_QA_ARTIFACTS")) - if not artifacts_list: - bb.warn("Could not load artifacts list, skip artifacts retrieval") - else: - bb.warn(f"Retrieving artifacts: {d.getVar('TESTIMAGE_FAILED_QA_ARTIFACTS')}") - retrieve_test_artifacts(tc.target, artifacts_list, get_testimage_json_result_dir(d)) + run_failed_tests_post_actions(d, tc) except (KeyboardInterrupt, BlockingIOError) as err: if isinstance(err, KeyboardInterrupt): bb.error('testimage interrupted, shutting down...') From patchwork Tue Feb 20 20:01:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexis_Lothor=C3=A9?= X-Patchwork-Id: 39820 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36074C5475B for ; Tue, 20 Feb 2024 20:02:18 +0000 (UTC) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by mx.groups.io with SMTP id smtpd.web10.22974.1708459329268751122 for ; Tue, 20 Feb 2024 12:02:09 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=VtMEa9vo; spf=pass (domain: bootlin.com, ip: 217.70.183.200, mailfrom: alexis.lothore@bootlin.com) Received: by mail.gandi.net (Postfix) with ESMTPSA id BF89220003; Tue, 20 Feb 2024 20:02:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708459327; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YHhGs47w5dQa+H5Jg5OzVm74M5su9sy5srEBl7R6260=; b=VtMEa9vo1yXf7qCzLpfHWcdUN7dygjDlPmXUwoZ3j0fZDF66uViqu5rKZdfXnlkIfcHYSH 4TLvFDShdDUIE8Huj4n5aC+ArukOdcK+oAUJW8bYzGH+ucOozxKmi/MDnxM01+YfjK2TSI 88T0V+hsma0CmqRyd8dxoLrM7/qEdU9UhwkVWeDFeKyql7wc2LDRTcM9aiy+0KmJWgj8mm 8If/4SXMgL9GiTSbwTT9AvPHNhQSY9sGPBGeEeBXna/hWDSppOKZ7oao0Qn34NlTSevqzg spgFerpNG38GzGHVqQTKtXLmZ3vrqiEBCpWyFvmd9pdLBbZAU06XfDZxC02wSQ== From: =?utf-8?q?Alexis_Lothor=C3=A9?= To: Cc: Thomas Petazzoni , Alexandre Belloni Subject: [OE-Core][PATCH 2/4] testimage: isolate artifacts directory creation in dedicated post action Date: Tue, 20 Feb 2024 21:01:57 +0100 Message-ID: <20240220200159.13419-3-alexis.lothore@bootlin.com> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240220200159.13419-1-alexis.lothore@bootlin.com> References: <20240220200159.13419-1-alexis.lothore@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: alexis.lothore@bootlin.com List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 20 Feb 2024 20:02:18 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/195926 From: Alexis Lothoré In order to be able to create actions that could store new files during failed test post actions, we need to split artifacts directory creation from artifacts retrieval. Create a new dedicated action to create artifacts main directory so we can add actions creating files in this new directory, without worrying about actions order if at least this action is set first. Signed-off-by: Alexis Lothoré --- .../failed-tests-post-actions.bbclass | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/meta/classes-recipe/failed-tests-post-actions.bbclass b/meta/classes-recipe/failed-tests-post-actions.bbclass index 7c7d3391298f..eaf08fb792f3 100644 --- a/meta/classes-recipe/failed-tests-post-actions.bbclass +++ b/meta/classes-recipe/failed-tests-post-actions.bbclass @@ -9,6 +9,15 @@ # Artifacts retrieval ################################################################## +def create_artifacts_directory(d, tc): + import shutil + + local_artifacts_dir = os.path.join(get_testimage_json_result_dir(d), "artifacts") + if os.path.isdir(local_artifacts_dir): + shutil.rmtree(local_artifacts_dir) + + os.makedirs(local_artifacts_dir) + def get_artifacts_list(target, raw_list): result = [] # Passed list may contains patterns in paths, expand them directly on target @@ -25,13 +34,7 @@ def get_artifacts_list(target, raw_list): return result def retrieve_test_artifacts(target, artifacts_list, target_dir): - import shutil - local_artifacts_dir = os.path.join(target_dir, "artifacts") - if os.path.isdir(local_artifacts_dir): - shutil.rmtree(local_artifacts_dir) - - os.makedirs(local_artifacts_dir) for artifact_path in artifacts_list: if not os.path.isabs(artifact_path): bb.warn(f"{artifact_path} is not an absolute path") @@ -57,6 +60,7 @@ def list_and_fetch_failed_tests_artifacts(d, tc): def run_failed_tests_post_actions(d, tc): post_actions=[ + create_artifacts_directory, list_and_fetch_failed_tests_artifacts ] From patchwork Tue Feb 20 20:01:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexis_Lothor=C3=A9?= X-Patchwork-Id: 39821 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51446C54764 for ; Tue, 20 Feb 2024 20:02:18 +0000 (UTC) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by mx.groups.io with SMTP id smtpd.web11.23174.1708459329531732445 for ; Tue, 20 Feb 2024 12:02:09 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=jhr5sBzy; spf=pass (domain: bootlin.com, ip: 217.70.183.200, mailfrom: alexis.lothore@bootlin.com) Received: by mail.gandi.net (Postfix) with ESMTPSA id 10B0520007; Tue, 20 Feb 2024 20:02:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708459328; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z1s9kAAWZKHNfU82tB4qbyZ2nTQ4GbfNLuVvL5KKFEU=; b=jhr5sBzyr72oEO/V2OkkgYMelauZtR+9g5evLACUzsf4LwZX/Yiy472N3dJDYU3bR3bosE mbL2fhFkIj2+CWhYQ7N2vmxaZeo53M5dfM7gVlxxqwJtk70ABD2ovAv7RN1N0a6k4T0mMB U4Rm6u4CK44vQSxFXilh0/7JN+/dP1skJu1i8QOu1rqED1sK3pxjUruK9pabrVrYEaB/Yp wMOQjRBv8xIF6ZY6HPGNr+yUAhc+2w4yNTt78Pz3dWZkzXWpsXYcHypHXm7uNHmvYOPrhH vtjZunkzV5aJP8HZJTxaPbOy2XQRHtfQe6ArkiUiUXt4i8KE/q6n/60LIbFHyg== From: =?utf-8?q?Alexis_Lothor=C3=A9?= To: Cc: Thomas Petazzoni , Alexandre Belloni Subject: [OE-Core][PATCH 3/4] testimage: add target disk usage stat as post action Date: Tue, 20 Feb 2024 21:01:58 +0100 Message-ID: <20240220200159.13419-4-alexis.lothore@bootlin.com> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240220200159.13419-1-alexis.lothore@bootlin.com> References: <20240220200159.13419-1-alexis.lothore@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: alexis.lothore@bootlin.com List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 20 Feb 2024 20:02:18 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/195928 From: Alexis Lothoré In order to debug issues related to disk space (see [1]), add a failed tests post action to retrieve disk usage on the target. Rely on the test context object to run the corresponding command onto the target [1] https://bugzilla.yoctoproject.org/show_bug.cgi?id=15220 Signed-off-by: Alexis Lothoré --- .../failed-tests-post-actions.bbclass | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/meta/classes-recipe/failed-tests-post-actions.bbclass b/meta/classes-recipe/failed-tests-post-actions.bbclass index eaf08fb792f3..a8604fca2b9d 100644 --- a/meta/classes-recipe/failed-tests-post-actions.bbclass +++ b/meta/classes-recipe/failed-tests-post-actions.bbclass @@ -5,6 +5,20 @@ # +################################################################## +# Host/target statistics +################################################################## + +def get_target_disk_usage(d, tc): + output_file = os.path.join(get_testimage_json_result_dir(d), "artifacts", "target_disk_usage.txt") + try: + (status, output) = tc.target.run('df -hl') + with open(output_file, 'w') as f: + f.write(output) + f.write("\n") + except Exception as e: + bb.warn(f"Can not get target disk usage: {e}") + ################################################################## # Artifacts retrieval ################################################################## @@ -61,7 +75,8 @@ def list_and_fetch_failed_tests_artifacts(d, tc): def run_failed_tests_post_actions(d, tc): post_actions=[ create_artifacts_directory, - list_and_fetch_failed_tests_artifacts + list_and_fetch_failed_tests_artifacts, + get_target_disk_usage ] for action in post_actions: From patchwork Tue Feb 20 20:01:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexis_Lothor=C3=A9?= X-Patchwork-Id: 39819 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27F5EC48BC3 for ; Tue, 20 Feb 2024 20:02:18 +0000 (UTC) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by mx.groups.io with SMTP id smtpd.web11.23175.1708459329836060093 for ; Tue, 20 Feb 2024 12:02:10 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=bri4XesI; spf=pass (domain: bootlin.com, ip: 217.70.183.200, mailfrom: alexis.lothore@bootlin.com) Received: by mail.gandi.net (Postfix) with ESMTPSA id 518302000A; Tue, 20 Feb 2024 20:02:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708459328; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rYxA5U2cbhi3R2QGW83h0hasmcBuwobpKYnEGYnDebU=; b=bri4XesIKSaAL06tWNDCil9XoFHHMnsUM2E/SbAIY5405GB1TtlxVbrsjOuHiEKGngZ7hM oZu9zTEquAFna6VR8n643WiGUi1taOuvajY8v4mtsEWhdlcNFqimJn3akWlHqN32VZdo2X KXyvsSpC915aL94d+YV+yMHecOOC4QWsJ7cko3JFg/KPSqnrIUSg26yc9ctqyVI5wm7beI 9QVKi/LDlHWopYuezd2DTsN+Q3SdXr9gx0N3WirkAsH70JFEOjgwhqMLTkoEJl55bj0oYA 4zWIgUUaqskxT/zlJ5QZfyvCy3+6Hyv+UTY4O0FytGfOtKzNLVUIzkeZCmZ0jQ== From: =?utf-8?q?Alexis_Lothor=C3=A9?= To: Cc: Thomas Petazzoni , Alexandre Belloni Subject: [OE-Core][PATCH 4/4] testimage: add host disk usage stat as post action Date: Tue, 20 Feb 2024 21:01:59 +0100 Message-ID: <20240220200159.13419-5-alexis.lothore@bootlin.com> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240220200159.13419-1-alexis.lothore@bootlin.com> References: <20240220200159.13419-1-alexis.lothore@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: alexis.lothore@bootlin.com List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 20 Feb 2024 20:02:18 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/195929 From: Alexis Lothoré Since the target under test can be a virtualized guest, when some tests fail because of disk usage (see [1]), also fetch disk usage statistics from host to allow checking whether a host disk space saturation could affect running tests. [1] https://bugzilla.yoctoproject.org/show_bug.cgi?id=15220 Signed-off-by: Alexis Lothoré --- .../failed-tests-post-actions.bbclass | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/meta/classes-recipe/failed-tests-post-actions.bbclass b/meta/classes-recipe/failed-tests-post-actions.bbclass index a8604fca2b9d..a9e92aa2427e 100644 --- a/meta/classes-recipe/failed-tests-post-actions.bbclass +++ b/meta/classes-recipe/failed-tests-post-actions.bbclass @@ -19,6 +19,16 @@ def get_target_disk_usage(d, tc): except Exception as e: bb.warn(f"Can not get target disk usage: {e}") +def get_host_disk_usage(d, tc): + import subprocess + + output_file = os.path.join(get_testimage_json_result_dir(d), "artifacts", "host_disk_usage.txt") + try: + with open(output_file, 'w') as f: + output = subprocess.run(['/usr/bin/df', '-hl'], check=True, text=True, stdout=f) + except Exception as e: + bb.warn(f"Can not get host disk usage: {e}") + ################################################################## # Artifacts retrieval ################################################################## @@ -76,7 +86,8 @@ def run_failed_tests_post_actions(d, tc): post_actions=[ create_artifacts_directory, list_and_fetch_failed_tests_artifacts, - get_target_disk_usage + get_target_disk_usage, + get_host_disk_usage ] for action in post_actions: