[PATCH] YES! test: build on machines with only one cpu
Mattias Ryrlén
mattias.ryrlen at op5.com
Fri Aug 30 15:46:02 CEST 2013
Take 2
Bonus, added one more testing and it goes through in our CI-Environment on
our try-master :)
On Fri, Aug 30, 2013 at 2:18 PM, Andreas Ericsson <ae at op5.se> wrote:
> On 2013-08-29 14:42, Mattias Ryrlén wrote:
>
>> commit f0054ac856059183f6c7bc3f9e8a80**965a8c0368 (HEAD, master)
>> Author: Mattias Ryrlén <mattiasr at op5.com>
>> 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 <mattiasr at op5.com>
>>
>>
> 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 at 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.
>
--
Vänliga hälsningar / Best Regards
Mattias Ryrlén
__________________________
op5 AB
Första Långgatan 19
SE-413 27 Göteborg
Mobil: +46 735-17 70 99
Support: +46 31-774 09 24
www.op5.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20130830/69399595/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-test-Allow-to-build-on-single-core-cpus.patch
Type: application/octet-stream
Size: 2736 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20130830/69399595/attachment.obj>
-------------- next part --------------
------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
-------------- next part --------------
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel
More information about the Developers
mailing list