Hello maintainers,

This patch fixes an issue in resulttool's JUnit output generation that occurs 
when either ptest results or image test results are missing from the 
testresults.json file.

The problem was that variables for tracking test counts and metrics 
(image_errors, image_failures, ptest_errors, etc.) were being initialized
inside the test results loop. When certain test types were completely absent 
from the JSON, these variables would remain uninitialized,
causing UnboundLocalError exceptions when the code attempted to use them later.

The fix is simple: move the variable initialization outside the loop so they 
always have default values of 0, even when test sections are missing.

This patch also adds comprehensive test coverage for three scenarios:
- Empty testresults (e.g. missing testresults.json)
- Missing image tests (only ptest results present)
- Missing ptest results (only image tests present)

These edge cases can occur in various CI/build scenarios where not all test 
types are executed, and the tool should handle them gracefully
rather than failing with exceptions.

Please review and consider for inclusion.

Best regards,
Miroslav Cernak

Miroslav Cernak (1):
  resulttool: fix UnboundLocalError when missing test results The
    junit_tree function failed when either ptest or imagetest results
    were missing from testresults.json due to uninitialized variables.
    Move variable initialization outside the loop to ensure they always
    have default values.

 .../oeqa/selftest/cases/resulttooltests.py    | 109 ++++++++++++++++++
 scripts/lib/resulttool/junit.py               |   5 +-
 2 files changed, 112 insertions(+), 2 deletions(-)

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#232790): 
https://lists.openembedded.org/g/openembedded-core/message/232790
Mute This Topic: https://lists.openembedded.org/mt/118241879/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

  • [OE-core] [PATCH 0/1] resulttoo... Miroslav Cernak via lists.openembedded.org

Reply via email to