All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cupertino Miranda <cupertino.miranda@oracle.com>
To: Eduard Zingerman <eddyz87@gmail.com>, bpf@vger.kernel.org
Cc: David Faust <david.faust@oracle.com>,
	Jose Marchesi <jose.marchesi@oracle.com>,
	Elena Zannoni <elena.zannoni@oracle.com>
Subject: Re: [PATCH] selftests/bpf: Enforce definition order for __msg macros in BPF tests
Date: Thu, 19 Mar 2026 13:45:25 +0000	[thread overview]
Message-ID: <499f79da-eef7-4495-bcda-bca6c90c6f4c@oracle.com> (raw)
In-Reply-To: <b073da2be883cf8f22a9a4c5f2dfa112d75d68f9.camel@gmail.com>

Hi Eduard,

I might be mistaken, but as it is skip_dynamic_pfx is dropping the index 
from the string that is passed to push_msg.
This is the case since it is matching the '=' in its passed macros;

   #define TEST_TAG_EXPECT_MSG_PFX "comment:test_expect_msg="

dropping the index and the other equal in the call to strchr(msg, '=').

I know the patch is rather bigger then perhaps minimally necessary but I 
did not want to change the semantics of current implementation, except 
the array ordering.

Did not really thought about string ordering it later, however, if I 
think about it, I would personally prefer to order the array at the 
push. Ordering later during a processing stage IMHO would obfuscate the 
fact that the array is ordered by its index.

If we change skip_dynamic_pfx to also return the "<index>=" then we 
could parse the string and insert it ordered in push_msg, not really 
needing to wait for a later stage.

Anyway, up to you. If you think it is worth it, I can do that.

Cheers,
Cupertino

On 18-03-2026 11:07 PM, Eduard Zingerman wrote:
> On Thu, 2026-03-05 at 13:00 +0000, Cupertino Miranda wrote:
>> Ensure that __msg macros, and similars, used for BPF test validation are
>> processed in the order they are defined in the source code.
>>
>> Neither GCC nor the C standard defines the order in which function
>> attributes are consumed. While Clang tends to preserve definition order,
>> GCC may process them out of sequence. This inconsistency causes BPF
>> tests with multiple __msg entries to fail when compiled with GCC.
>>
>> This patch fixes the test runner to explicitly sort or process these
>> attributes to guarantee predictable matching behavior across different
>> compilers.
>>
>> Signed-off-by: Cupertino Miranda <cupertino.miranda@oracle.com>
>> Cc: David Faust  <david.faust@oracle.com>
>> Cc: Jose Marchesi  <jose.marchesi@oracle.com>
>> Cc: Elena Zannoni  <elena.zannoni@oracle.com>
>> ---
> 
> Looks like this patch fell through the cracks.
> 
> It looks a bit intrusive, given the amount of places index has to be
> passed through. An alternative would be to modify parse_test_spec()
> such that it collects decl tag ids into the array first and then sorts
> the array. It will have to use strverscmp() for comparator, though.
> This way all the changes would be localized to a single function
> collecting the array.
> 
> Up to you if that is worth the hassle.
> 
> Reviewed-by: Eduard Zingerman <eddyz87@gmail.com>
> 
> [...]


  reply	other threads:[~2026-03-19 13:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-05 13:00 [PATCH] selftests/bpf: Enforce definition order for __msg macros in BPF tests Cupertino Miranda
2026-03-06  1:22 ` Kumar Kartikeya Dwivedi
2026-03-11 18:19 ` Yonghong Song
2026-03-18 23:07 ` Eduard Zingerman
2026-03-19 13:45   ` Cupertino Miranda [this message]
2026-03-19 13:47     ` Cupertino Miranda
2026-03-20  5:27     ` Eduard Zingerman
2026-03-23 13:02       ` Cupertino Miranda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=499f79da-eef7-4495-bcda-bca6c90c6f4c@oracle.com \
    --to=cupertino.miranda@oracle.com \
    --cc=bpf@vger.kernel.org \
    --cc=david.faust@oracle.com \
    --cc=eddyz87@gmail.com \
    --cc=elena.zannoni@oracle.com \
    --cc=jose.marchesi@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.