Re: [Nagios-devel] [PATCH] YES! test: build on machines with only

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

Re: [Nagios-devel] [PATCH] YES! test: build on machines with only

Post by Guest »

On 2013-08-29 14:42, Mattias Ryrlén wrote:
> commit f0054ac856059183f6c7bc3f9e8a80965a8c0368 (HEAD, master)
> Author: Mattias Ryrlén
> Date: Thu Aug 29 14:34:39 2013 +0200
>
> YES! test: build on machines with only one cpu
>
> There might be someone out there who still have only one cpu/core, let
> those
> build too.
>
> Signed-off-by: Mattias Ryrlén
>

While I sort of agree that tests should pass on single-cpu machines as
well, this change renders the whole test useless, since we *always*
return > 0 from online_cpus().

Adding a function (real_online_cpus()) which returns 0 when it can't
reliably test for number of online cpus, and letting that be wrapped
by online_cpus() so that the latter can retain its current behaviour
would solve the problem. online_cpus() should then look like this:

unsigned int online_cpus(void)
{
unsigned int cpus = real_online_cpus();
return cpus ? cpus : 1;
}

while the new function real_online_cpus() must take the body of the
current online_cpus() function but be changed so that the fallback is
to return 0. The test must then be changed to use real_online_cpus()
instead.

Would you like to reroll, or should I make the necessary changes and
credit you with an "Reported-by"?

> diff --git a/lib/test-nsutils.c b/lib/test-nsutils.c
> index 1a23ee1..f835d67 100644
> --- a/lib/test-nsutils.c
> +++ b/lib/test-nsutils.c
> @@ -31,10 +31,10 @@ int main(int argc, char **argv)
> asprintf(&s1, "arg varg foo %d", 12);
> s2 = mkstr("arg varg foo %d", 12);
> ok_str(s1, s2, "mkstr() must build proper strings");
> - if (online_cpus() > 1) {
> + if (online_cpus() > 0) {
> t_pass("%d online cpus detected", online_cpus());
> } else {
> - t_fail("Do you really have only one cpu core?");
> + t_fail("No online cpus detected");
> }
> return t_end();
> }
>


--
Andreas Ericsson andreas.ericsson@op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: ae@op5.se
Locked