Skip to contentSkip to conversation

patchtest-send-results: prevent false positives due to commit subject

PATCH In review Alexis Lothoré 2 participants 4 messages Feb 5, 2024 – Feb 6, 2024

lore
Share & tools
lore
#0 lore raw

cover patchtest-send-results: prevent false positives due to commit subject

Hello,
this small series aims to prevent patchtest-send-results from sending reports to submitters in a specific case: if the commit message contains the word "FAIL", it will (wrongly) send a report to submitter despite all tests passing / being skipped.

The first patch is a trivial cleanup while the second patch brings in the real fix.

Alexis Lothoré (2):
patchtest-send-results: remove unused variable
patchtest-send-results: properly parse test status

 scripts/patchtest-send-results | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/2 patchtest-send-results: remove unused variable

From: Alexis Lothoré <[email protected]>

result_basename is declared but not used in the script

---
 scripts/patchtest-send-results | 1 -
 1 file changed, 1 deletion(-)
scripts/patchtest-send-results +0 -1
index 71b73f0940f0..024be003ceb7 100755
@@ -45,7 +45,6 @@ elif not os.path.exists(args.patch + ".testresult"):
     sys.exit(1)
 
 result_file = args.patch + ".testresult"
-result_basename = os.path.basename(args.patch)
 testresult = None
 
 with open(result_file, "r") as f:
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/2 patchtest-send-results: properly parse test status

In reply to Alexis Lothoré

From: Alexis Lothoré <[email protected]>

patchtest-send-results currently search the word "FAIL" in the whole testresults file to decide whether it should send a report to patch submitter or not. This global search can lead to false positives, for example if the commit subject contains the word "FAIL" (as observed in [1])

Prevent those false positives by explicitely parsing the test status from each line. Each test result line, generated by the patchtest script, is expected to have the following format:
<STATUS>: <some info, depending on the status>

[1] https://lore.kernel.org/openembedded-core/0101018d79bfe020-06f2ce89-ea19-456b-92e7-66ee1c710fd1-000000@us-west-2.amazonses.com/

---
 scripts/patchtest-send-results | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
scripts/patchtest-send-results +4 -1
index 024be003ceb7..075b60d8f7d5 100755
@@ -33,6 +33,9 @@ under 'Yocto Project Subprojects'). For more information on specific
 failures, see: https://wiki.yoctoproject.org/wiki/Patchtest. Thank
 you!"""
 
+def has_a_failed_test(raw_results):
+    return any(raw_result.split(':')[0] == "FAIL" for raw_result in raw_results.splitlines())
+
 parser = argparse.ArgumentParser(description="Send patchtest results to a submitter for a given patch")
 parser.add_argument("-p", "--patch", dest="patch", required=True, help="The patch file to summarize")
 args = parser.parse_args()
@@ -69,7 +72,7 @@ from_address = "[email protected]"
 # mailing list to CC
 cc_address = "[email protected]"
 
-if "FAIL" in testresult:
+if has_a_failed_test(testresult):
     reply_contents = None
     if len(max(open(result_file, 'r'), key=len)) > 220:
         warning = "Tests failed for the patch, but the results log could not be processed due to excessive result line length."
Signature · 1 line
2.43.0
#3 lore raw
In reply to Alexis Lothoré
Quoted 8 lines · Alexis Lothoré via lists.openembedded.org

Hello,
this small series aims to prevent patchtest-send-results from sending reports to submitters in a specific case: if the commit message contains the word "FAIL", it will (wrongly) send a report to submitter despite all tests passing / being skipped.

The first patch is a trivial cleanup while the second patch brings in the real fix.

Sorry for the late reply. Thanks for sending these out, nice catch!

Quoted 17 lines

Alexis Lothoré (2):
patchtest-send-results: remove unused variable
patchtest-send-results: properly parse test status

  scripts/patchtest-send-results | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)

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