mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Mark Brown <broonie@kernel.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] regmap: kunit: Ensure that changed bytes are actually different
Date: Fri, 9 Feb 2024 15:20:40 -0800	[thread overview]
Message-ID: <d2c9b610-ca76-4104-9969-7dded960d4a2@roeck-us.net> (raw)
In-Reply-To: <ZcapjWTuggJNdV/o@finisterre.sirena.org.uk>

On 2/9/24 14:39, Mark Brown wrote:
> On Fri, Feb 09, 2024 at 02:07:38PM -0800, Guenter Roeck wrote:
> 
>> This is actually worse than v1 because hw_buf[6] isn't used anywhere.
>> Making sure that the values in the val[] array don't match the values
>> in hw_buf[6..7] doesn't add any value.
> 
> Yeah, I realised after reading your earlier mail.  It's passing for me
> somehow.
> 

It is passing because the probability for it to fail is really low.
It only fails reliably with the cheat below.

>> FWIW, I had struggled with the re-use of val[0] for two different tests
>> (on hw_buf[2] and hw_buf[4]) myself. The only solution other than making sure
>> that it neither matches hw_buf[2] nor hw_buf[4] I came up with was to use a
>> separate variable for the accesses to hw_buf[4] (or hw_buf[6] in the old code).
> Indeed, it was fine with the old code due to not caring about having
> different values but we need to generate three values now.
> 
>>          get_changed_bytes(&hw_buf[6], &val[0], sizeof(val));
>> +       // Let's cheat.
>> +       // Remember, the above code doesn't look into hw_buf[2..5],
>> +       // so anything might be in there, including the values from
>> +       // the val[] array.
>> +       hw_buf[2] = val[0];
>> +       hw_buf[3] = val[1];
>> +       hw_buf[4] = val[0];
>> +       hw_buf[5] = val[1];
> 
> I don't understand how this interacts with the pre-sync check?

That is because the test expects the memory in hw_buf[] and val[] to be
different (because hw_buf[] wasn't updated to the new values). The above
cheat forces hw_buf[2,3] and val[0,1] to be the same, so the pre-sync test
fails. The post-sync test passes because the values are expected to be
the same at that time.

Guenter


  reply	other threads:[~2024-02-09 23:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-09 21:33 Mark Brown
2024-02-09 22:07 ` Guenter Roeck
2024-02-09 22:39   ` Mark Brown
2024-02-09 23:20     ` Guenter Roeck [this message]
2024-02-10 12:44       ` Mark Brown

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=d2c9b610-ca76-4104-9969-7dded960d4a2@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®