Hi Heinrich,

On 2026-10-12T14:00:39, Heinrich Schuchardt
<[email protected]> wrote:
> test: fs: allow optional date field in ls output assertion
>
> fs_ls_generic() now prints a date between the file size and filename
> when the filesystem sets FS_CAP_DATE (currently FAT and ext4).  The
> two regex patterns in test_fs1 used ' *' (zero or more spaces) to
> match whitespace between the size and filename; this no longer matches
> when a date is present.
>
> Change ' *' to ' .*' so the pattern matches both the old format
> (size + spaces + name) and the new format (size + spaces + date + name).
>
> Signed-off-by: Heinrich Schuchardt <[email protected]>
>
> test/py/tests/test_fs/test_basic.py | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

> diff --git a/test/py/tests/test_fs/test_basic.py 
> b/test/py/tests/test_fs/test_basic.py
> @@ -26,8 +26,8 @@ class TestFsBasic(object):
> -            assert(re.search('2621440000 *%s' % BIG_FILE, ''.join(output)))
> -            assert(re.search('1048576 *%s' % SMALL_FILE, ''.join(output)))
> +            assert(re.search('2621440000 .*%s' % BIG_FILE, ''.join(output)))
> +            assert(re.search('1048576 .*%s' % SMALL_FILE, ''.join(output)))

The subject says 'optional date field', but ' .*' accepts anything
between the size and the name. A broken date would still pass, e.g. an
off-by-one month or a year-1900 bug, both easy to hit with struct
rtc_time. Since you are touching this line, the test could also check
the date's format, e.g. (as a raw string):

    '2621440000 +(\d{4}-\d\d-\d\d \d\d:\d\d +)?%s'

This keeps both formats working. What do you think?

Regards,
Simon

Reply via email to