[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Fix biased shuffle by avoiding already "struck" elements
From: |
Sergei Trofimovich |
Subject: |
Re: [PATCH] Fix biased shuffle by avoiding already "struck" elements |
Date: |
Tue, 9 Jul 2024 22:51:58 +0100 |
On Fri, 21 Jun 2024 11:36:16 -0400
Dmitry Goncharov <dgoncharov@users.sf.net> wrote:
> On Fri, Jun 21, 2024 at 10:30 AM Paul Smith <psmith@gnu.org> wrote:
> >
> > On Fri, 2024-06-21 at 09:11 -0400, Dmitry Goncharov wrote:
> > > i hope, Paul approves adding tests of this nature.
> >
> > I have no problems with adding unit tests, as long as we can find a way
> > to integrate it into the test suite in a reasonable way.
>
> Glad to hear.
>
> >
> > But this particular thing doesn't really feel like a "test" per se. I
> > mean we wouldn't run this as part of the regression tests...?
>
> Not in its current shape. It should be possible to replace printf
> statements in a.c with test assertions and modify a.c to exit with 0
> on success and some positive value when the test fails. Then, it'll be
> possible to have `make check' run the binary built from a.c.
>
> E.g. this is an excerpt from `make check' output with patches from sv65588
>
> ...
> gcc -C -Wall -Wextra -Werror -Wwrite-strings -Wshadow
> -Wdeclaration-after-statement -Wbad-function-cast -Wformat-security
> -Wtype-limits -Wunused-but-set-parameter -Wlogical-op -Wpointer-arith
> -Wignored-qualifiers -Wformat-signedness -Wduplicated-cond -Wall
> -Wextra -ggdb -m64 -DMAKE_MAINTAINER_MODE=1 -fsanitize=address
> -fsanitize=leak -fsanitize=undefined
> -fsanitize-undefined-trap-on-error -Wno-error -Wl,--export-dynamic
> -fsanitize=address -fsanitize=leak -fsanitize=undefined
> -fsanitize-undefined-trap-on-error -ldl -m64 -o token.t.tsk
> src/token.t.o
> make[2]: Leaving directory '/home/dgoncharov/src/make/l64'
> /home/dgoncharov/src/make/l64/./make check-local
> make[2]: Entering directory '/home/dgoncharov/src/make/l64'
> rm -f test-suite.log token_test.log tests/.test-result
> tests/.token_test-result
> (./token.t.tsk; echo $? >tests/.token_test-result) 2>&1 | tee token_test.log
> token test 169
> token test 175
> token test 181
> ...
> 0 failed tests, 2443 total tests
> ...
> cd tests && perl -w
> /home/dgoncharov/src/make/l64/../tests/run_make_tests.pl -make ../make
> ...
>
> -------------------------------------------------------------------------------
> Running tests for GNU Make on linux
> GNU Make 4.4.90
> -------------------------------------------------------------------------------
>
> Finding tests in /home/dgoncharov/src/make/tests/scripts...
> Searching for tests...
> Creating dirs in work...
>
> features/archives ....................................... ok (16 passed)
> ...
>
> i suggest, that we introduce a naming convention for this type of
> tests. E.g. this one
> https://file.savannah.gnu.org/file/sv65588_part2.diff?file_id=55942 is
> token.h and token.c (impl) and token.t.c (test) and the binary is
> token.t.tsk. If we decide to follow this naming, then a.c becomes
> shuffle.t.c and the binary becomes shuffle.t.tsk.
Sounds good. It will take me some time to come up with a working test.
Would it be reasonable to apply the fix as is and consider the follow-up
test separately? If it helps I drew a few explanatory pictures at
https://trofi.github.io/posts/319-probabilities-are-hard.html
--
Sergei
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [PATCH] Fix biased shuffle by avoiding already "struck" elements,
Sergei Trofimovich <=