Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

testdbmfederation.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "dbm/dbmfederation.h"
#include "dbm/mingraph.h"
#include "dbm/dbm.h"
#include "dbm/print.h"
#include "dbm/gen.h"
#include "debug/c_allocator.h"
#include "debug/utils.h"
#include "debug/macros.h"

Defines

#define NTOOEXPENSIVE
#define SHOW_TEST()   fputc('.', stdout); fflush(stdout)
#define SKIP_TEST()   fputc('?', stdout); fflush(stdout)
#define NO_TEST()   fputc('*', stdout); fflush(stdout)
#define PROGRESS()   debug_spin(stderr)
#define NB_LOOPS   (dim > 5 ? 1000 : 2000)

Functions

void dbmf_print (FILE *out, const DBMList_t *dbmList, cindex_t dim)
 Straight-forward print.
static BOOL test_isPointIn (const int32_t *pt, const DBMList_t *dbmList, cindex_t dim)
 Test that a discrete point is in a DBM list.
static BOOL test_isRealPointIn (const double *pt, const DBMList_t *dbmList, cindex_t dim)
 Test that a real point is in a DBM list.
static DBMList_ttest_allocGen (DBMAllocator_t *factory, cindex_t dim, size_t n)
 Allocate and generate n DBMs.
static const DBMList_ttest_getDBM (size_t size, const DBMList_t *dbmList)
 Pick one DBM from a list of DBMs.
static BOOL test_generateRealPoint (double *pt, cindex_t dim, const DBMList_t *dbmList, size_t size)
 Generate a real point in a DBM list.
static BOOL test_generatePoint (int32_t *pt, cindex_t dim, const DBMList_t *dbmList, size_t size)
 Generate a discrete point in a DBM list.
static BOOL test_isIncluded (const raw_t *dbm, cindex_t dim, const DBMList_t *dbmList)
 Test if a dbm is <= in a list.
static BOOL test_isIncludedInOther (const raw_t *dbm, cindex_t dim, const DBMList_t *dbmList)
 Test if a dbm is <= in a list, skipping dbm itself.
static void test_addDBMs (DBMAllocator_t *factory, DBMFederation_t *fed, size_t nb)
 Add some superset/subset DBMs to a federation.
static DBMList_ttest_allocGenArg (DBMAllocator_t *factory, cindex_t dim, const DBMList_t *dbmList, size_t n, BOOL *superOrDiff)
 Allocate and generate DBMs arguments for an operation with a DBM list.
static size_t test_genConstraints (cindex_t dim, const DBMList_t *dbmList, size_t n, constraint_t *constraints)
 Generate constraints for a federation.
static void test_mix (DBMList_t **dbmList)
 Mix a DBM list: misuse of quicksort.
static void test_addZero (cindex_t dim, DBMAllocator_t *factory)
 Test dbmf_addZero.
static void test_addInit (cindex_t dim, DBMAllocator_t *factory)
 Test dbmf_addInit.
static void test_copyDBM (cindex_t dim, DBMAllocator_t *factory)
 Test dbmf_copyDBM.
static void test_copyDBM2List (cindex_t dim, DBMAllocator_t *factory)
 Test dbmf_copyDBM2List.
static void test_union (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_union.
static void test_convexUnion (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_convexUnion.
static void test_convexUnionWithSelf (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_convexUnionWithSelf.
static void test_intersection (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_intersection.
static void test_intersectsDBM (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_intersectsDBM.
static void test_intersectsFederation (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_intersectsFederation.
static void test_intersectionWithFederation (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_intersectionWithFederation.
static void test_constrainN (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_constrainN.
static void test_constrain1 (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_constrain1.
static void test_up (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_up.
static void test_down (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_down.
static void test_reduce (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_reduce.
static BOOL isTooExpensive (cindex_t dim, size_t size)
 See if the expensiveReduce test is too expensive by computing the worst case for the number of splits.
static void test_expensiveReduce (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_expensiveReduce.
static void test_freeClock (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_freeClock.
static void test_updateValue (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_updateValue.
static void test_updateClock (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_updateClock.
static void test_updateIncrement (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_updateIncrement.
static void test_update (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_update.
static void test_satisfies (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_satisfy.
static void test_isEmpty (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_isEmpty.
static BOOL test_dbmfIsUnbounded (const DBMFederation_t fed)
 Debug implementation of isUnbounded.
static void test_isUnbounded (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_isUnbounded.
static void test_partialRelation (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_partialRelation.
static void test_relation (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_relation.
static void test_stretchUp (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_stretchUp.
static void test_stretchDown (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_stretchDown.
static void test_microDelay (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_microDelay.
static void test_copy (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_copy.
static void test_areEqual (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_areEqual.
static void test_isPointIncluded (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_isPointIncluded.
static void test_subFedFromDBM (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_substractFederationFromDBM.
static void test_subDBMFromDBM (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_substractDBMFromDBM.
static void test_subDBMFromFed (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_substractDBMFromFederation.
static void test_subFedFromFed (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_substractFederationFromFederation.
static void test_subDBM (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_substractDBM.
static void test_subFed (cindex_t dim, DBMAllocator_t *factory, size_t fedSize)
 Test dbmf_substractFederation.
static void test (cindex_t dim, cindex_t dimEnd, size_t fedSize)
 Main test function: from dim to dimEnd and call all the individual tests.
int main (int argc, char *argv[])

Define Documentation

#define NB_LOOPS   (dim > 5 ? 1000 : 2000)
 

 
#define NO_TEST  )     fputc('*', stdout); fflush(stdout)
 

#define NTOOEXPENSIVE
 

 
#define PROGRESS  )     debug_spin(stderr)
 

 
#define SHOW_TEST  )     fputc('.', stdout); fflush(stdout)
 

 
#define SKIP_TEST  )     fputc('?', stdout); fflush(stdout)
 


Function Documentation

void dbmf_print FILE *  out,
const DBMList_t dbmList,
cindex_t  dim
 

Straight-forward print.

Parameters:
out,: where to print
dbmList,: DBM list to print
dim,: dimension of all the DBMs

static BOOL isTooExpensive cindex_t  dim,
size_t  size
[static]
 

See if the expensiveReduce test is too expensive by computing the worst case for the number of splits.

int main int  argc,
char *  argv[]
 

static void test cindex_t  dim,
cindex_t  dimEnd,
size_t  fedSize
[static]
 

Main test function: from dim to dimEnd and call all the individual tests.

Parameters:
dim,: starting dimension
dimEnd,: ending dimension
fedSize,: federation size to test

static void test_addDBMs DBMAllocator_t factory,
DBMFederation_t fed,
size_t  nb
[static]
 

Add some superset/subset DBMs to a federation.

Parameters:
factory,: compatible factory
fed,: federation to add the supersets/subsets
nb,: maximal number of supersets/subsets to add

static void test_addInit cindex_t  dim,
DBMAllocator_t factory
[static]
 

Test dbmf_addInit.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.

static void test_addZero cindex_t  dim,
DBMAllocator_t factory
[static]
 

Test dbmf_addZero.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.

static DBMList_t* test_allocGen DBMAllocator_t factory,
cindex_t  dim,
size_t  n
[static]
 

Allocate and generate n DBMs.

Parameters:
factory,: factory for allocation.
dim,: dimension of DBMs to generate
n,: number of DBMs to generate.
Precondition:
dim <= factory->maxDim && n > 0
Returns:
n allocated and generated DBMs.

static DBMList_t* test_allocGenArg DBMAllocator_t factory,
cindex_t  dim,
const DBMList_t dbmList,
size_t  n,
BOOL superOrDiff
[static]
 

Allocate and generate DBMs arguments for an operation with a DBM list.

Generation may include supersets, equal, subset, or different DBMs compared with the ones in dbmList.

Parameters:
factory,: compatible factory
dim,: dimension of DBMs
dbmList,: list of DBMs to base the generation on
n,: upper bound for the number of generated DBMs (min == 1)
superOrDiff,: where to write the type of generated arguments. If one superset or different DBM is generated then *superOrDiff = TRUE, otherwise *superOrDiff = FALSE.
Returns:
the generated DBMs.
Precondition:
n > 0, dim > 0, factory->maxDim >= dim

static void test_areEqual cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_areEqual.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_constrain1 cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_constrain1.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_constrainN cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_constrainN.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_convexUnion cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_convexUnion.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_convexUnionWithSelf cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_convexUnionWithSelf.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_copy cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_copy.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_copyDBM cindex_t  dim,
DBMAllocator_t factory
[static]
 

Test dbmf_copyDBM.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_copyDBM2List cindex_t  dim,
DBMAllocator_t factory
[static]
 

Test dbmf_copyDBM2List.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static BOOL test_dbmfIsUnbounded const DBMFederation_t  fed  )  [static]
 

Debug implementation of isUnbounded.

static void test_down cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_down.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_expensiveReduce cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_expensiveReduce.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_freeClock cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_freeClock.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static size_t test_genConstraints cindex_t  dim,
const DBMList_t dbmList,
size_t  n,
constraint_t constraints
[static]
 

Generate constraints for a federation.

Parameters:
dim,: dimension of DBMs
dbmList,: list of DBMs
n,: number of constraints to generate
constraints,: where to generate
Postcondition:
by constraining dbmList with constraints the result is not empty (if dbmList is not empty)
Returns:
number of generated constraints (may be < n)

static BOOL test_generatePoint int32_t *  pt,
cindex_t  dim,
const DBMList_t dbmList,
size_t  size
[static]
 

Generate a discrete point in a DBM list.

Parameters:
pt,: point to generate
dbmList,: list of DBMs
size,: size of the list
dim,: dimension of the DBMs and the point
Returns:
TRUE if a point is generated successfully, FALSE otherwise

static BOOL test_generateRealPoint double *  pt,
cindex_t  dim,
const DBMList_t dbmList,
size_t  size
[static]
 

Generate a real point in a DBM list.

Parameters:
pt,: point to generate
dbmList,: list of DBMs
size,: size of the list
dim,: dimension of the DBMs and the point
Returns:
TRUE if a point is generated successfully, FALSE otherwise

static const DBMList_t* test_getDBM size_t  size,
const DBMList_t dbmList
[static]
 

Pick one DBM from a list of DBMs.

Parameters:
size,: size of the list.
dbmList,: list of DBMs.
Returns:
one DBM of the list.
Precondition:
size > 0, dbmList != NULL

static void test_intersection cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_intersection.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_intersectionWithFederation cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_intersectionWithFederation.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_intersectsDBM cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_intersectsDBM.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_intersectsFederation cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_intersectsFederation.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_isEmpty cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_isEmpty.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static BOOL test_isIncluded const raw_t dbm,
cindex_t  dim,
const DBMList_t dbmList
[static]
 

Test if a dbm is <= in a list.

Parameters:
dbm,dim,: DBM of dimension dim.
dbmList,: list of DBMs.
Returns:
TRUE if dbm <= dbmList

static BOOL test_isIncludedInOther const raw_t dbm,
cindex_t  dim,
const DBMList_t dbmList
[static]
 

Test if a dbm is <= in a list, skipping dbm itself.

Parameters:
dbm,dim,: DBM of dimension dim.
dbmList,: list of DBMs.
Returns:
TRUE if dbm <= dbmList

static BOOL test_isPointIn const int32_t *  pt,
const DBMList_t dbmList,
cindex_t  dim
[static]
 

Test that a discrete point is in a DBM list.

Parameters:
pt,: point
dbmList,: list of DBMs
dim,: dimension of the DBMs and the point
Returns:
TRUE if pt included in dbmList, FALSE otherwise

static void test_isPointIncluded cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_isPointIncluded.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static BOOL test_isRealPointIn const double *  pt,
const DBMList_t dbmList,
cindex_t  dim
[static]
 

Test that a real point is in a DBM list.

Parameters:
pt,: point
dbmList,: list of DBMs
dim,: dimension of the DBMs and the point
Returns:
TRUE if pt included in dbmList, FALSE otherwise

static void test_isUnbounded cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_isUnbounded.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_microDelay cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_microDelay.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_mix DBMList_t **  dbmList  )  [static]
 

Mix a DBM list: misuse of quicksort.

We can swap indices randomly too, but this is simpler (and quite cool).

Parameters:
dbmList,: list of DBMs
Precondition:
size <= 2^16

static void test_partialRelation cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_partialRelation.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_reduce cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_reduce.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_relation cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_relation.

Simple test: it is difficult to generate overlap cases.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_satisfies cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_satisfy.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_stretchDown cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_stretchDown.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_stretchUp cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_stretchUp.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_subDBM cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_substractDBM.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_subDBMFromDBM cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_substractDBMFromDBM.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_subDBMFromFed cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_substractDBMFromFederation.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_subFed cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_substractFederation.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_subFedFromDBM cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_substractFederationFromDBM.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_subFedFromFed cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_substractFederationFromFederation.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_union cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_union.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_up cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_up.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_update cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_update.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_updateClock cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_updateClock.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_updateIncrement cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_updateIncrement.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.

static void test_updateValue cindex_t  dim,
DBMAllocator_t factory,
size_t  fedSize
[static]
 

Test dbmf_updateValue.

Parameters:
dim,: dimension of DBMs to test.
factory,: DBM factory.
fedSize,: size of federation to test.


Generated on Fri Jun 30 00:02:46 2006 for Module dbm by  doxygen 1.4.2