<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>15832</bug_id>
          
          <creation_ts>2025-04-14 21:02:05 +0000</creation_ts>
          <short_desc>Specify API between exit code of run-ptest and ptest-runner</short_desc>
          <delta_ts>2026-01-20 14:23:37 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>9</classification_id>
          <classification>Documentation</classification>
          <product>Development Manual</product>
          <component>development</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>6.0 M2</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Yoann Congal">yoann.congal</reporter>
          <assigned_to name="Antonin Godard">antonin.godard</assigned_to>
          <cc>anibal</cc>
    
    <cc>erik.schumacher</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Yes (doc changes required)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>101646</commentid>
    <comment_count>0</comment_count>
    <who name="Yoann Congal">yoann.congal</who>
    <bug_when>2025-04-14 21:02:05 +0000</bug_when>
    <thetext>Current doc [0], only mention output format:
&gt; The test generates output in the format used by Automake:
&gt; result: testname
&gt; where the result can be PASS, FAIL, or SKIP, and the testname can be any identifying string.

... but ptest-runner2 code uses exit code to determine if a test failed or not[1]:
  waitpid(child, &amp;status, 0);
  
  if (WIFEXITED(status)) {
  	exit_code = WEXITSTATUS(status);
  	if (exit_code) {
  		fprintf(fp, &quot;\nERROR: Exit status is %d\n&quot;, exit_code);
  		rc += 1;
  	}

Maybe we need to add &quot;run-ptest must exit with status code 0 only if all test cases pass. If one or more tests fail, it must return a non-zero exit code.&quot; ?

[0]: https://docs.yoctoproject.org/dev/test-manual/ptest.html#testing-packages-with-ptest
[1]: https://git.yoctoproject.org/ptest-runner2/tree/utils.c#n529</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>101900</commentid>
    <comment_count>1</comment_count>
    <who name="Yoann Congal">yoann.congal</who>
    <bug_when>2025-05-07 23:10:24 +0000</bug_when>
    <thetext>While ptest-runner itself does not care about test output, testimage does. See
* poky/meta/lib/oeqa/runtime/cases/ptest.py
* poky/meta/lib/oeqa/utils/logparser.py
having at least a &quot;PASS:&quot;, &quot;FAIL:&quot;, ... is expected. Without it, testimage gives an error:
|AssertionError:
|ptests which had no test results:
|[&apos;rpm-sequoia&apos;]

See: https://lists.openembedded.org/g/openembedded-core/message/216032</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102175</commentid>
    <comment_count>2</comment_count>
    <who name="Yoann Congal">yoann.congal</who>
    <bug_when>2025-06-06 07:13:37 +0000</bug_when>
    <thetext>Related email from Erik Schumacher:

[ptest-runner][RESEND] Documentation and behavior do not match
https://lists.yoctoproject.org/g/yocto-patches/message/1619

Le ven. 6 juin 2025 à 07:52, Erik Schumacher via lists.yoctoproject.org &lt;erik.schumacher=iris-sensing.com@lists.yoctoproject.org&gt; a écrit :

    I have created some ptests and executed them with the ptest-runner and
    realized that the documentation and the actual behavior of the ptest-
    runner don&apos;t really fit together.

    What I did:

    I used the wiki pages [1] and [2] as guidelines and also had a look at
    some existing run-ptest scripts like [3] and [4]. It&apos;s not entirely
    clear in the phrasing, but the documentation implies that a run-ptest
    script must print either &quot;PASS&quot;, &quot;FAIL&quot; or &quot;SKIP&quot; followed by the
    testname. That&apos;s what most of the existing run-ptest scripts do.
    Then I created my own run-ptest script that did something like:
    /path/to/mybinary-gtest &amp;&amp; echo &quot;PASS: mybinary&quot; || echo &quot;FAIL:
    mybinary&quot;

    What I expected:

    The script itself worked and ptest-runner was able to run it. So far,
    so good. I started to wonder when my script simulated a faulty test. My
    script printed &quot;FAIL: mybinary&quot;, but ptest-runner completed the test
    without failures (last line: &quot;TOTAL: 1 FAIL: 0&quot;). I expected &quot;FAIL: 1&quot;
    here. The same applies to the xml output, which can be consumed by
    Gitlab when the ptest-runner runs inside a CI/CD pipeline.

    What I found:

    By looking at the code of ptest-runner, it quickly became clear to me
    that a failure is only determined by the exit code of a run-ptest
    script. See [5]. It doesn&apos;t matter what the script is printing. As long
    as the exit code is 0, the test has passed. Any other exit code is
    treated as fail.

    Why I think this is a problem:

    The behavior of ptest-runner somehow contradicts the documentation,
    which describes what the output of the script should look like. The
    documentation says nothing about the exit code being relevant. There is
    no run-ptest script that explicitly returns the right exit code. There
    are some that implicitly pass the exit code of the only / or last
    command, like gzip [6].
    Using the generated xml file in a Gitlab testing pipeline will lead to
    a false sense of security that all tests would have been successful,
    even if they might not be.

    By relying on the exit code, ptest-runner also treats a run-ptest
    script as a single unit which can either pass or fail, even though a
    ptest might consists of multiple test cases ([3] or [4]).


    [1] https://wiki.yoctoproject.org/wiki/Ptest
    [2] https://docs.yoctoproject.org/test-manual/ptest.html
    [3] https://git.openembedded.org/openembedded-core/tree/meta/recipes-extended/bc/bc/run-ptest
    [4] https://git.openembedded.org/openembedded-core/tree/meta/recipes-connectivity/bluez5/bluez5/run-ptest
    [5] https://git.yoctoproject.org/ptest-runner2/tree/utils.c#n522
    [6] https://git.openembedded.org/openembedded-core/tree/meta/recipes-extended/gzip/files/run-ptest</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102367</commentid>
    <comment_count>3</comment_count>
    <who name="Antonin Godard">antonin.godard</who>
    <bug_when>2025-07-01 08:41:49 +0000</bug_when>
    <thetext>A patch referring to this bug was merged in the docs:
https://git.yoctoproject.org/yocto-docs/commit/?id=0d1fd79019883f366d796b58a01679297d7a5508

Yoann, do you consider this enough to close this ticket, or should we reiterate? I think the patch is an improvement, but is it precise enough in your opinion?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102368</commentid>
    <comment_count>4</comment_count>
    <who name="Yoann Congal">yoann.congal</who>
    <bug_when>2025-07-01 08:53:49 +0000</bug_when>
    <thetext>(In reply to Antonin Godard from comment #3)
&gt; A patch referring to this bug was merged in the docs:
&gt; https://git.yoctoproject.org/yocto-docs/commit/
&gt; ?id=0d1fd79019883f366d796b58a01679297d7a5508
&gt; 
&gt; Yoann, do you consider this enough to close this ticket, or should we
&gt; reiterate? I think the patch is an improvement, but is it precise enough in
&gt; your opinion?

Definitely a step in the right direction, but not enough in my humble opinion.

What I would love is a kind of specification of the interface that must be implemented by the run-ptest script.
Something like:
&gt; * return 0 if every sub-test passes
&gt; * return != 0 if a sub-test fails
&gt; * print at least a PASS:/FAIL:/SKIP: line (ideally one for every sub-test)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102381</commentid>
    <comment_count>5</comment_count>
    <who name="Erik Schumacher">erik.schumacher</who>
    <bug_when>2025-07-03 12:14:42 +0000</bug_when>
    <thetext>&gt; Definitely a step in the right direction, but not enough in my humble opinion.

I second this.

Changing the documentation does not fix the existing differences between the output of run-ptest scripts and the expectations of the ptest-runner. Since the run-ptest scripts all work according to the same scheme, the ptest-runner should be adapted, in my opinion. The effort involved in changing all scripts, together with the risk of introducing new bugs, is significantly greater than adapting the ptest-runner. Regardless of this, the ptest-runner also has other problems.

I started a discussion on the mailing list: https://lists.yoctoproject.org/g/yocto-patches/topic/ptest_runner_rfc_implement/113964431</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>102390</commentid>
    <comment_count>6</comment_count>
    <who name="Aníbal Limón">anibal</who>
    <bug_when>2025-07-03 15:25:32 +0000</bug_when>
    <thetext>(In reply to Erik Schumacher from comment #5)
&gt; &gt; Definitely a step in the right direction, but not enough in my humble opinion.
&gt; 
&gt; I second this.
&gt; 
&gt; Changing the documentation does not fix the existing differences between the
&gt; output of run-ptest scripts and the expectations of the ptest-runner. Since
&gt; the run-ptest scripts all work according to the same scheme, the
&gt; ptest-runner should be adapted, in my opinion. The effort involved in
&gt; changing all scripts, together with the risk of introducing new bugs, is
&gt; significantly greater than adapting the ptest-runner. Regardless of this,
&gt; the ptest-runner also has other problems.
&gt; 
&gt; I started a discussion on the mailing list:
&gt; https://lists.yoctoproject.org/g/yocto-patches/topic/
&gt; ptest_runner_rfc_implement/113964431

Yeah as commented previously on the ML [1], I&apos;m in favor to add an option (--strict?) to execute ptest-runner with log analyzer on output at post-process stage. Having it as an option enables us to look at specific ptest issues.

[1] https://lists.yoctoproject.org/g/yocto-patches/message/1622</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103700</commentid>
    <comment_count>7</comment_count>
    <who name="Antonin Godard">antonin.godard</who>
    <bug_when>2026-01-05 16:52:17 +0000</bug_when>
    <thetext>Hi,

Right now the documentation says:

&gt; During the execution ptest-runner keeps count of total and failed ptests. At end the execution summary is written to the console. If any of the run-ptest fails, ptest-runner returns ‘1’.

I&apos;ve verified and this is still the current behavior. So, from a documentation standpoint, I think we&apos;re ok and we can close this bug.

As stated in the previous comments, if there is a need to improve ptest-runner, please create another bug for it with the proper category, so the right person can try and work on it, or please adapt this one and let me know (so I don&apos;t close it).

I will close this one week from now if there are no other comments.

Thanks,
Antonin</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103753</commentid>
    <comment_count>8</comment_count>
    <who name="Yoann Congal">yoann.congal</who>
    <bug_when>2026-01-08 09:17:14 +0000</bug_when>
    <thetext>(In reply to Antonin Godard from comment #7)
&gt; Hi,
&gt; 
&gt; Right now the documentation says:
&gt; 
&gt; &gt; During the execution ptest-runner keeps count of total and failed ptests. At end the execution summary is written to the console. If any of the run-ptest fails, ptest-runner returns ‘1’.
&gt; 
&gt; I&apos;ve verified and this is still the current behavior. So, from a
&gt; documentation standpoint, I think we&apos;re ok and we can close this bug.
&gt; 
&gt; As stated in the previous comments, if there is a need to improve
&gt; ptest-runner, please create another bug for it with the proper category, so
&gt; the right person can try and work on it, or please adapt this one and let me
&gt; know (so I don&apos;t close it).
&gt; 
&gt; I will close this one week from now if there are no other comments.

IMHO, the current doc still lacks a crucial point : run-ptest must print at least a &quot;PASS:&quot;, &quot;FAIL:&quot;, ... (either by itself, or via a subprocess).
The 0/!=0 return code is for ptest-runner, the &quot;PASS:&quot; lines are for testimage/logparser.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103791</commentid>
    <comment_count>9</comment_count>
    <who name="Antonin Godard">antonin.godard</who>
    <bug_when>2026-01-09 10:46:50 +0000</bug_when>
    <thetext>(In reply to Yoann Congal from comment #8)
&gt; IMHO, the current doc still lacks a crucial point : run-ptest must print at
&gt; least a &quot;PASS:&quot;, &quot;FAIL:&quot;, ... (either by itself, or via a subprocess).
&gt; The 0/!=0 return code is for ptest-runner, the &quot;PASS:&quot; lines are for
&gt; testimage/logparser.

I sent a patch to mention this and clearly state these requirements:
https://lore.kernel.org/r/20260109-ptest-output-v1-1-29b1b2039c97@bootlin.com</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103972</commentid>
    <comment_count>10</comment_count>
    <who name="Antonin Godard">antonin.godard</who>
    <bug_when>2026-01-20 14:23:37 +0000</bug_when>
    <thetext>Patch merged, closing
https://git.yoctoproject.org/yocto-docs/commit/?id=9292f61d7ba89598c89033ea7ee3b11a20d873f3</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>