On 2026-09-17 14:32, Andy Shevchenko wrote:
On Thu, Sep 17, 2026 at 11:02:52AM +0200, Jonas Rebmann wrote:
On 2026-09-17 09:45, Andy Shevchenko wrote:
On Wed, Sep 16, 2026 at 07:38:09PM +0200, Jonas Rebmann wrote:

...

+       test_string_unescape_one(test, "short buffer", UNESCAPE_HEX, "\\x41\\x41B", 4, 
"AAB", 3);
+       test_string_unescape_one(test, "unrecognized escape at end", UNESCAPE_HEX, 
"B\\qX", 4, "B\\q", 3);

Still wondering if we can incorporate this into the "combined" loop?

Both these tests really only fail without my fixes because the
destination buffer is short, barely fitting the result.

With a buffer length of 4 it yields "A\", for 5 "AA" and for 6 "AAB",
a bug because "AAB" would fit the 4 byte buffer too.

So, we need to extend the current loop to pass the buffer length like -5, -4,
-3, -2, -1, 0, +1 from the expected length and check that it's cut correctly
along with no garbage at the end. It will help all test cases, and not just
a single one or a couple.

I suppose I could for v2 rewrite test_string_unescape_combined() to test
each case individually instead of concatenating all strings. So we'd be
invoking string_unescape() once per possible flag combination and repeat
that for the inplace test.

struct test_string gets the extra field regarding destination buffer
size. However we'd need to skip the inplace test in the 'short buffer'
scenarios. Therefore I suppose we just pass the destination buffer size,
not an offset. If that size field is zero than the test can run either
inplace or with any large enough destination buffer. For nonzero values,
inplace tests are skipped.

Regards,
Jonas

--
Pengutronix e.K.                           | Jonas Rebmann               |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-9    |

Reply via email to