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 »

--089e012942aa9d05dd04e52988e8
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On Fri, Aug 30, 2013 at 2:18 PM, Andreas Ericsson wrote:

> On 2013-08-29 14:42, Mattias Ryrl=E9n wrote:
>
>> commit f0054ac856059183f6c7bc3f9e8a80**965a8c0368 (HEAD, master)
>> Author: Mattias Ryrl=E9n
>> 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=E9n
>>
>>
> 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 =3D 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"?


I reroll, have enough lvl80 chars anyway..


>
>
> 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 =3D 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.
>



--=20
V=E4nliga h=E4lsningar / Best Regards
Mattias Ryrl=E9n

__________________________
op5 AB
F=F6rsta L=E5nggatan 19
SE-413 27 G=F6teborg
Mobil: +46 735-17 70 99
Support: +46 31-774 09 24
www.op5.com

--089e012942aa9d05dd04e52988e8
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On Fri, Aug 30, 2013 at 2:18 PM, Andreas Ericsson <ae@op5.se> wrote:
On 2013-08-29 14:42, Matti=
as Ryrl=E9n wrote:

commit f0054ac856059183f6c7bc3f9e8a80965a8c0368 (HEAD, master)
Author: Mattias Ryrl=E9n <mattiasr@op5.com>
Date: =A0 Thu Aug 29 14:34:39 2013 +0200

=A0 =A0 =A0YES! test: build on machines with only one cpu

=A0 =A0 =A0There might be someone out there who still have only one cpu/cor=
e, let
those
=A0 =A0 =A0build too.

=A0 =A0 =A0Signed-off-by: Mattias Ryrl=E9n <mattiasr@op5.com>




...[email truncated]...


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