diff mbox series

API: Give user hint when checkpoints were not initialised

Message ID 20210512101738.31118-1-rpalethorpe@suse.com
State Accepted
Headers show
Series API: Give user hint when checkpoints were not initialised | expand

Commit Message

Richard Palethorpe May 12, 2021, 10:17 a.m. UTC
Currently the user gets an error about EOVERFLOW. This will hopefully
save some searching.

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 lib/tst_checkpoint.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Cyril Hrubis May 12, 2021, 12:28 p.m. UTC | #1
Hi!
> ---
>  lib/tst_checkpoint.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/tst_checkpoint.c b/lib/tst_checkpoint.c
> index 9e9dcf9e6..13d86c73b 100644
> --- a/lib/tst_checkpoint.c
> +++ b/lib/tst_checkpoint.c
> @@ -86,6 +86,9 @@ int tst_checkpoint_wait(unsigned int id, unsigned int msec_timeout)
>  	struct timespec timeout;
>  	int ret;
>  
> +	if (!tst_max_futexes)
> +		tst_brkm(TBROK, NULL, "Set test.needs_checkpoints = 1");
> +
>  	if (id >= tst_max_futexes) {
>  		errno = EOVERFLOW;
>  		return -1;
> @@ -107,7 +110,10 @@ int tst_checkpoint_wake(unsigned int id, unsigned int nr_wake,
>  {
>  	unsigned int msecs = 0, waked = 0;
>  
> -	if (id >= tst_max_futexes) {
> +	if (!tst_max_futexes)
> +		tst_brkm(TBROK, NULL, "Set test.needs_checkpoints = 1");
> +
> +        if (id >= tst_max_futexes) {
    ^
    Spaces instead of tabs...


Other than that this looks obviously fine.
Petr Vorel May 12, 2021, 1:42 p.m. UTC | #2
Hi Richie,

> Currently the user gets an error about EOVERFLOW. This will hopefully
> save some searching.

Nice! I'm for merging it before release (with that fixed whitespace).

Acked-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr
Cyril Hrubis May 12, 2021, 1:58 p.m. UTC | #3
Hi!
> > Currently the user gets an error about EOVERFLOW. This will hopefully
> > save some searching.
> 
> Nice! I'm for merging it before release (with that fixed whitespace).

Looks safe enough, I will fix the whitespaces and apply.
Richard Palethorpe May 13, 2021, 7:08 a.m. UTC | #4
Hi,

Cyril Hrubis <chrubis@suse.cz> writes:

> Hi!
>> > Currently the user gets an error about EOVERFLOW. This will hopefully
>> > save some searching.
>> 
>> Nice! I'm for merging it before release (with that fixed whitespace).
>
> Looks safe enough, I will fix the whitespaces and apply.

Thanks, but I would not put this in the release. There is no advantage
to the end user, only test authors. It can only break the tests from an
end user POV.
diff mbox series

Patch

diff --git a/lib/tst_checkpoint.c b/lib/tst_checkpoint.c
index 9e9dcf9e6..13d86c73b 100644
--- a/lib/tst_checkpoint.c
+++ b/lib/tst_checkpoint.c
@@ -86,6 +86,9 @@  int tst_checkpoint_wait(unsigned int id, unsigned int msec_timeout)
 	struct timespec timeout;
 	int ret;
 
+	if (!tst_max_futexes)
+		tst_brkm(TBROK, NULL, "Set test.needs_checkpoints = 1");
+
 	if (id >= tst_max_futexes) {
 		errno = EOVERFLOW;
 		return -1;
@@ -107,7 +110,10 @@  int tst_checkpoint_wake(unsigned int id, unsigned int nr_wake,
 {
 	unsigned int msecs = 0, waked = 0;
 
-	if (id >= tst_max_futexes) {
+	if (!tst_max_futexes)
+		tst_brkm(TBROK, NULL, "Set test.needs_checkpoints = 1");
+
+        if (id >= tst_max_futexes) {
 		errno = EOVERFLOW;
 		return -1;
 	}