[PATCH] YES! test: build on machines with only one cpu

Andreas Ericsson ae at op5.se
Fri Aug 30 14:18:55 CEST 2013


On 2013-08-29 14:42, Mattias Ryrlén wrote:
> commit f0054ac856059183f6c7bc3f9e8a80965a8c0368 (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.

------------------------------------------------------------------------------
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




More information about the Developers mailing list