Commit 084101e9 authored by Victor Lopez's avatar Victor Lopez

Adjusts tests for systems with few CPUs

parent b408eca5
......@@ -30,6 +30,7 @@
#include <cstdlib>
#include <assert.h>
#include "cpuset.hpp"
#include "os.hpp"
#include <iostream>
using namespace nanos;
......@@ -82,40 +83,43 @@ int main(int argc, char *argv[])
assert(empty_set.isSubsetOf(empty_set));
assert(empty_set.isSupersetOf(empty_set));
// First and last methods
CpuSet set3; /* 0000 */
assert(set3.first()==0);
assert(set3.last()==0);
set3.set(0); /* 0001 */
assert(set3.first()==0);
assert(set3.last()==1);
set3.set(1); /* 0011 */
assert(set3.first()==0);
assert(set3.last()==2);
set3.set(3); /* 1011 */
assert(set3.first()==0);
assert(set3.last()==4);
set3.clear(0); /* 1010 */
assert(set3.first()==1);
assert(set3.last()==4);
// Iterators tests need at least 4 CPUs
if (OS::getMaxProcessors() >= 4) {
// First and last methods
CpuSet set3; /* 0000 */
assert(set3.first()==0);
assert(set3.last()==0);
set3.set(0); /* 0001 */
assert(set3.first()==0);
assert(set3.last()==1);
set3.set(1); /* 0011 */
assert(set3.first()==0);
assert(set3.last()==2);
set3.set(3); /* 1011 */
assert(set3.first()==0);
assert(set3.last()==4);
set3.clear(0); /* 1010 */
assert(set3.first()==1);
assert(set3.last()==4);
// Iterators
CpuSet::const_iterator it = set3.begin();
assert( *it == 1 );
++it;
assert( *it == 3 );
++it;
assert( it == set3.end() );
++it;
assert( it == set3.end() );
--it;
assert( *it == 3 );
--it;
assert( *it == 1 );
assert( it == set3.begin() );
--it;
assert( *it == 1 );
assert( it == set3.begin() );
// Iterators
CpuSet::const_iterator it = set3.begin();
assert( *it == 1 );
++it;
assert( *it == 3 );
++it;
assert( it == set3.end() );
++it;
assert( it == set3.end() );
--it;
assert( *it == 3 );
--it;
assert( *it == 1 );
assert( it == set3.begin() );
--it;
assert( *it == 1 );
assert( it == set3.begin() );
}
return EXIT_SUCCESS;
}
......@@ -19,6 +19,7 @@
#include <stdio.h>
#include "system.hpp"
#include "os.hpp"
/*
<testinfo>
......@@ -45,13 +46,15 @@ int main ( int argc, char *argv[])
);
if ( myThread->getTeam()->getFinalSize() != NTHREADS_PHASE_1 ) error++;
sys.updateActiveWorkers( NTHREADS_PHASE_2 );
if ( OS::getMaxProcessors() >= NTHREADS_PHASE_2 ) {
sys.updateActiveWorkers( NTHREADS_PHASE_2 );
fprintf(stdout,"Thread team final size is %d and %d is expected\n",
(int) myThread->getTeam()->getFinalSize(),
NTHREADS_PHASE_2
);
if ( myThread->getTeam()->getFinalSize() != NTHREADS_PHASE_2 ) error++;
fprintf(stdout,"Thread team final size is %d and %d is expected\n",
(int) myThread->getTeam()->getFinalSize(),
NTHREADS_PHASE_2
);
if ( myThread->getTeam()->getFinalSize() != NTHREADS_PHASE_2 ) error++;
}
fprintf(stdout,"Result is %s\n", error? "UNSUCCESSFUL":"successful");
......
......@@ -19,6 +19,7 @@
#include <stdio.h>
#include "system.hpp"
#include "os.hpp"
/*
<testinfo>
......@@ -45,13 +46,15 @@ int main ( int argc, char *argv[])
);
if ( myThread->getTeam()->getFinalSize() != NTHREADS_PHASE_1 ) error++;
sys.updateActiveWorkers( NTHREADS_PHASE_2 );
if ( OS::getMaxProcessors() >= NTHREADS_PHASE_2 ) {
sys.updateActiveWorkers( NTHREADS_PHASE_2 );
fprintf(stdout,"Thread team final size is %d and %d is expected\n",
(int) myThread->getTeam()->getFinalSize(),
NTHREADS_PHASE_2
);
if ( myThread->getTeam()->getFinalSize() != NTHREADS_PHASE_2 ) error++;
fprintf(stdout,"Thread team final size is %d and %d is expected\n",
(int) myThread->getTeam()->getFinalSize(),
NTHREADS_PHASE_2
);
if ( myThread->getTeam()->getFinalSize() != NTHREADS_PHASE_2 ) error++;
}
sys.updateActiveWorkers( NTHREADS_PHASE_1 );
......
......@@ -19,6 +19,7 @@
#include <stdio.h>
#include "system.hpp"
#include "os.hpp"
/*
<testinfo>
......@@ -38,11 +39,11 @@ int main ( int argc, char *argv[])
{
int i, error = 0;
unsigned nths = 0;
int max_threads = std::min( OS::getMaxProcessors(), 4 );
for ( i=0; i<ITERS; i++ ) {
nths = ((nths) % 4) + 1;
nths = (nths % max_threads) + 1;
sys.updateActiveWorkers( nths );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment