From bcbc7e4bdba2f584acb999faf9fcd67829dea275 Mon Sep 17 00:00:00 2001 From: Esben Haabendal <esben.haabendal@huawei.com> Date: Tue, 21 Jun 2022 09:49:04 +0200 Subject: [PATCH] openharmony-standard: Add support for ptest fixture setup/teardown This adds support in the run-ptest script used by all openharmony-standard components for providing fixture setup and teardown scripts. Signed-off-by: Esben Haabendal <esben.haabendal@huawei.com> --- .../openharmony/files/run-ptest | 40 ++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/recipes-openharmony/openharmony/files/run-ptest b/recipes-openharmony/openharmony/files/run-ptest index 06526987..f2793aa6 100644 --- a/recipes-openharmony/openharmony/files/run-ptest +++ b/recipes-openharmony/openharmony/files/run-ptest @@ -13,6 +13,11 @@ if [ -f systemd-units ] ; then done fi +# Component level test fixture setup +if [ -f setup.sh ]; then + source setup.sh +fi + TEST_RESULT=0 find_tcs() { @@ -25,17 +30,32 @@ find_tcs() { } for ts in unittest moduletest systemtest ; do - for tc in $(find_tcs $ts) ; do - echo "RUNNING $tc" - ./$tc - test_result=$? - if test "$test_result" -eq 0; then - echo "PASS: $tc" - else - echo "FAIL: $tc" - TEST_RESULT=1 + ( + # Test suite level test fixture setup + if [ -f $ts/setup.sh ]; then + source $ts/setup.sh fi - done + for tc in $(find_tcs $ts) ; do + echo "RUNNING $tc" + ./$tc + test_result=$? + if test "$test_result" -eq 0; then + echo "PASS: $tc" + else + echo "FAIL: $tc" + TEST_RESULT=1 + fi + done + # Test suite level test fixture teardown + if [ -f $ts/teardown.sh ]; then + source $ts/teardown.sh + fi + ) done +# Component level test fixture teardown +if [ -f setup.sh ]; then + source teardown.sh +fi + exit $TEST_RESULT -- GitLab