From fcdef83aedc767c6e6e56e80780c51dc8447bc31 Mon Sep 17 00:00:00 2001 From: hades Date: Thu, 31 Aug 2000 12:44:20 +0000 Subject: [PATCH] *** empty log message *** --- allParam/ca/caParam.c | 38 +++++++++++---------- allParam/file/fileParam.c | 18 +++++----- allParam/ora/oraParam.pc | 7 ++-- allParam/psql/psqlParam.c | 22 +++++++------ allParam/tcl/tclParam.c | 49 ++++++++++++++++++++------- allParam/test/Makefile | 46 ++++++++++++++++++++++++++ allParam/test/param.tcl | 47 ++++++++++++++++++++++++++ allParam/test/suite.c | 64 ++++++++++++++++++++++++++++++++++++ allParam/test/test1.c | 29 ++++++++++++++++ allParam/test/test1.h | 8 +++++ allParam/test/test10.c | 29 ++++++++++++++++ allParam/test/test10.h | 8 +++++ allParam/test/test11.c | 29 ++++++++++++++++ allParam/test/test11.h | 8 +++++ allParam/test/test12.c | 29 ++++++++++++++++ allParam/test/test12.h | 8 +++++ allParam/test/test13.c | 36 ++++++++++++++++++++ allParam/test/test13.h | 10 ++++++ allParam/test/test14.c | 31 ++++++++++++++++++ allParam/test/test14.h | 10 ++++++ allParam/test/test15.c | 45 +++++++++++++++++++++++++ allParam/test/test15.h | 11 +++++++ allParam/test/test16.c | 34 +++++++++++++++++++ allParam/test/test16.h | 11 +++++++ allParam/test/test17.c | 41 +++++++++++++++++++++++ allParam/test/test17.h | 11 +++++++ allParam/test/test18.c | 34 +++++++++++++++++++ allParam/test/test18.h | 11 +++++++ allParam/test/test19.c | 69 +++++++++++++++++++++++++++++++++++++++ allParam/test/test19.h | 10 ++++++ allParam/test/test2.c | 29 ++++++++++++++++ allParam/test/test2.h | 8 +++++ allParam/test/test20.c | 31 ++++++++++++++++++ allParam/test/test20.h | 10 ++++++ allParam/test/test3.c | 54 ++++++++++++++++++++++++++++++ allParam/test/test3.h | 10 ++++++ allParam/test/test4.c | 38 +++++++++++++++++++++ allParam/test/test4.h | 10 ++++++ allParam/test/test5.c | 29 ++++++++++++++++ allParam/test/test5.h | 8 +++++ allParam/test/test6.c | 29 ++++++++++++++++ allParam/test/test6.h | 8 +++++ allParam/test/test7.c | 54 ++++++++++++++++++++++++++++++ allParam/test/test7.h | 10 ++++++ allParam/test/test8.c | 38 +++++++++++++++++++++ allParam/test/test8.h | 10 ++++++ allParam/test/test9.c | 29 ++++++++++++++++ allParam/test/test9.h | 8 +++++ 48 files changed, 1166 insertions(+), 50 deletions(-) create mode 100644 allParam/test/Makefile create mode 100644 allParam/test/param.tcl create mode 100644 allParam/test/suite.c create mode 100644 allParam/test/test1.c create mode 100644 allParam/test/test1.h create mode 100644 allParam/test/test10.c create mode 100644 allParam/test/test10.h create mode 100644 allParam/test/test11.c create mode 100644 allParam/test/test11.h create mode 100644 allParam/test/test12.c create mode 100644 allParam/test/test12.h create mode 100644 allParam/test/test13.c create mode 100644 allParam/test/test13.h create mode 100644 allParam/test/test14.c create mode 100644 allParam/test/test14.h create mode 100644 allParam/test/test15.c create mode 100644 allParam/test/test15.h create mode 100644 allParam/test/test16.c create mode 100644 allParam/test/test16.h create mode 100644 allParam/test/test17.c create mode 100644 allParam/test/test17.h create mode 100644 allParam/test/test18.c create mode 100644 allParam/test/test18.h create mode 100644 allParam/test/test19.c create mode 100644 allParam/test/test19.h create mode 100644 allParam/test/test2.c create mode 100644 allParam/test/test2.h create mode 100644 allParam/test/test20.c create mode 100644 allParam/test/test20.h create mode 100644 allParam/test/test3.c create mode 100644 allParam/test/test3.h create mode 100644 allParam/test/test4.c create mode 100644 allParam/test/test4.h create mode 100644 allParam/test/test5.c create mode 100644 allParam/test/test5.h create mode 100644 allParam/test/test6.c create mode 100644 allParam/test/test6.h create mode 100644 allParam/test/test7.c create mode 100644 allParam/test/test7.h create mode 100644 allParam/test/test8.c create mode 100644 allParam/test/test8.h create mode 100644 allParam/test/test9.c create mode 100644 allParam/test/test9.h diff --git a/allParam/ca/caParam.c b/allParam/ca/caParam.c index 16b48f3..f076256 100644 --- a/allParam/ca/caParam.c +++ b/allParam/ca/caParam.c @@ -11,7 +11,7 @@ static chid Param_openChannel(const Param *, const char *, int *); static int Param_closeChannel(const Param *, chid, char *); static char *Param_returnPVName(const char *, const char *, int); -static void Param_strerror(const Param *, const char *); +static void Param_strerror(Param *, const char *); int conParam(Param *my) { @@ -37,7 +37,7 @@ int Param_getString(const Param *my, const char *name, const char *idx, int *row int i; if(ca_task_initialize() != ECA_NORMAL) { - Param_strerror(my, "Cannot establish ca connection.\n"); + Param_strerror((Param *) my, "Cannot establish ca connection.\n"); return -1; } @@ -45,7 +45,7 @@ int Param_getString(const Param *my, const char *name, const char *idx, int *row chan = Param_openChannel(my, pPVName, &found); switch (found) { case(-1): - Param_strerror(my, "Cannot establish ca connection.\n"); + Param_strerror((Param *) my, "Cannot establish ca connection.\n"); break; case(0): *row = 0; @@ -53,7 +53,7 @@ int Param_getString(const Param *my, const char *name, const char *idx, int *row case(1): *row = 1; if(ca_bget(chan, val) != ECA_NORMAL) { - Param_strerror(my, "Did not receive correct data via ca.\n"); + Param_strerror((Param *) my, "Did not receive correct data via ca.\n"); return -1; } retVal = Param_closeChannel(my, chan, pPVName); @@ -61,7 +61,7 @@ int Param_getString(const Param *my, const char *name, const char *idx, int *row } if(ca_task_exit() != ECA_NORMAL) { - Param_strerror(my, "Cannot close ca connection.\n"); + Param_strerror((Param *) my, "Cannot close ca connection.\n"); return -1; } @@ -77,7 +77,7 @@ int Param_getIntArray(const Param *my, const char *name, const char *idx, int ma int i; if(ca_task_initialize() != ECA_NORMAL) { - Param_strerror(my, "Cannot establish ca connection.\n"); + Param_strerror((Param *) my, "Cannot establish ca connection.\n"); return -1; } @@ -85,7 +85,7 @@ int Param_getIntArray(const Param *my, const char *name, const char *idx, int ma chan = Param_openChannel(my, pPVName, &found); switch (found) { case(-1): - Param_strerror(my, "Cannot establish ca connection.\n"); + Param_strerror((Param *) my, "Cannot establish ca connection.\n"); break; case(0): *rows = 0; @@ -93,7 +93,7 @@ int Param_getIntArray(const Param *my, const char *name, const char *idx, int ma case(1): *rows = maxrows; if(ca_array_get(DBR_LONG, maxrows, chan, val) != ECA_NORMAL) { - Param_strerror(my, "Did not receive correct data via ca.\n"); + Param_strerror((Param *) my, "Did not receive correct data via ca.\n"); retVal = -1; } retVal|= Param_closeChannel(my, chan, pPVName); @@ -101,7 +101,7 @@ int Param_getIntArray(const Param *my, const char *name, const char *idx, int ma } if(ca_task_exit() != ECA_NORMAL) { - Param_strerror(my, "Cannot close ca connection.\n"); + Param_strerror((Param *) my, "Cannot close ca connection.\n"); return -1; } return retVal; @@ -116,7 +116,7 @@ int Param_getStringArray(const Param *my, const char *name, const char *idx, int int i; if(ca_task_initialize() != ECA_NORMAL) { - Param_strerror(my, "Cannot establish ca connection.\n"); + Param_strerror((Param *) my, "Cannot establish ca connection.\n"); return -1; } @@ -126,7 +126,7 @@ int Param_getStringArray(const Param *my, const char *name, const char *idx, int chan = Param_openChannel(my, pPVName, &found); switch (found) { case(-1): - Param_strerror(my, "Cannot establish ca connection.\n"); + Param_strerror((Param *) my, "Cannot establish ca connection.\n"); return -1; break; case(0): @@ -134,7 +134,7 @@ int Param_getStringArray(const Param *my, const char *name, const char *idx, int break; case(1): if(ca_bget(chan, val) != ECA_NORMAL) { - Param_strerror(my, "Did not receive correct data via ca.\n"); + Param_strerror((Param *) my, "Did not receive correct data via ca.\n"); retVal = -1; } else { *rows++; @@ -145,7 +145,7 @@ int Param_getStringArray(const Param *my, const char *name, const char *idx, int } if(ca_task_exit() != ECA_NORMAL) { - Param_strerror(my, "Cannot close ca connection.\n"); + Param_strerror((Param *) my, "Cannot close ca connection.\n"); return -1; } @@ -170,7 +170,7 @@ static chid Param_openChannel(const Param *my, const char *pPVName, int *found) } if(ca_pend_io(TIMEOUT) != ECA_NORMAL) { - Param_strerror(my, "Cannot switch to asynchronous mode.\n"); + Param_strerror((Param *) my, "Cannot switch to asynchronous mode.\n"); } return chan; } @@ -178,7 +178,7 @@ static chid Param_openChannel(const Param *my, const char *pPVName, int *found) static int Param_closeChannel(const Param *my, chid chan, char *pPVName) { if(ca_pend_io(TIMEOUT) != ECA_NORMAL) { - Param_strerror(my, "Cannot switch to asynchronous mode.\n"); + Param_strerror((Param *) my, "Cannot switch to asynchronous mode.\n"); } free(pPVName); if(ca_clear_channel(chan) != ECA_NORMAL) { @@ -206,9 +206,11 @@ static char *Param_returnPVName(const char *name, const char *idx, int num) return pPVName; } -static void Param_strerror(const Param *my, const char *strerror) +static void Param_strerror(Param *my, const char *strerror) { - realloc(my->strerror, strlen(strerror)); - strcpy(my->strerror, strerror); + my->strerror = realloc(my->strerror, strlen(strerror) + 1); + if(my->strerror != NULL) { + strcpy(my->strerror, strerror); + } } diff --git a/allParam/file/fileParam.c b/allParam/file/fileParam.c index 8ceaef3..4992e13 100644 --- a/allParam/file/fileParam.c +++ b/allParam/file/fileParam.c @@ -11,7 +11,7 @@ #define BUFFERSIZE 130 static int Param_getParamNumber(const Param *, const char *, const char *); -static void Param_strerror(const Param *, const char *); +static void Param_strerror(Param *, const char *); int conParam(Param *my) { @@ -67,7 +67,7 @@ int Param_getInt(const Param *my, const char *name, const char *idx, int *row, u } *val = strtoul(valstr, &endptr, 0); if (*endptr == '\0') { - Param_strerror(my, "Value seems to be no integer.\n"); + Param_strerror((Param *) my, "Value seems to be no integer.\n"); retVal = -1; } return retVal; @@ -79,7 +79,7 @@ int Param_getString(const Param *my, const char *name, const char *idx, int *row n = Param_getParamNumber(my, name, idx); if (n == -1) { strcpy(val, ""); - Param_strerror(my, "Parameter not found.\n"); + Param_strerror((Param *) my, "Parameter not found.\n"); *row = 0; } else { strcpy(val, my->value[n]); @@ -97,7 +97,7 @@ int Param_getIntArray(const Param *my, const char *name, const char *idx, int ma for (i = 0 ; i < maxrows ; i++) { sprintf(index,"%s%d", idx, i); if(retVal |= Param_getInt(my, name, index, &row, val + i) == 0) { - *rows+= row; + *rows += row; } else { i = maxrows; } @@ -115,7 +115,7 @@ int Param_getStringArray(const Param *my, const char *name, const char *idx, int for (i = 0 ; i < maxrows ; i++) { sprintf(index,"%s%d", idx, i); if(retVal |= Param_getString(my, name, index, &row, val[i]) == 0) { - *rows+= row; + *rows += row; } else { i = maxrows; } @@ -144,9 +144,11 @@ static int Param_getParamNumber(const Param *my, const char *name, const char *i return retVal; } -static void Param_strerror(const Param *my, const char *strerror) +static void Param_strerror(Param *my, const char *strerror) { - realloc(my->strerror, strlen(strerror)); - strcpy(my->strerror, strerror); + my->strerror = realloc(my->strerror, strlen(strerror) + 1); + if(my->strerror != NULL) { + strcpy(my->strerror, strerror); + } } diff --git a/allParam/ora/oraParam.pc b/allParam/ora/oraParam.pc index 9b81871..b56f033 100644 --- a/allParam/ora/oraParam.pc +++ b/allParam/ora/oraParam.pc @@ -111,7 +111,10 @@ const char *Param_getErrStr(const Param *my) static void Param_strerror(const Param *my, const char *strerror) { - realloc(my->strerror, strlen(strerror)); - strcpy(my->strerror, strerror); + (Param *) my; + my->strerror = realloc(my->strerror, strlen(strerror) + 1); + if(my->strerror != NULL) { + strcpy(my->strerror, strerror); + } } diff --git a/allParam/psql/psqlParam.c b/allParam/psql/psqlParam.c index 3b93ebf..4e03092 100644 --- a/allParam/psql/psqlParam.c +++ b/allParam/psql/psqlParam.c @@ -7,7 +7,7 @@ #include "param.h" -static void Param_strerror(const Param *, const char *); +static void Param_strerror(Param *, const char *); int conParam(Param *my) { @@ -46,17 +46,17 @@ int Param_getIntArray(const Param *my, const char *name, const char *idx, int ma result = PQexec(conn, query); if(PQresultStatus(result) != PGRES_TUPLES_OK) { - Param_strerror(my, "The PostgreSQL query result is not correct.\n"); + Param_strerror((Param *) my, "The PostgreSQL query result is not correct.\n"); return -1; } fnum = PQfnumber(result, "value"); if ((*rows = PQntuples(result)) > maxrows) { - Param_strerror(my, "Result has to many rows. Returning only 'maxrows' rows.\n"); + Param_strerror((Param *) my, "Result has to many rows. Returning only 'maxrows' rows.\n"); for (i = 0 ; i < maxrows ; i++) { val[i] = strtoul(PQgetvalue(result, i, fnum), &endptr, 0); if(*endptr != '\0') { - Param_strerror(my, "Value seems to be no integer.\n"); + Param_strerror((Param *) my, "Value seems to be no integer.\n"); retVal = -1; } } @@ -65,7 +65,7 @@ int Param_getIntArray(const Param *my, const char *name, const char *idx, int ma for (i = 0 ; i < *rows ; i++) { val[i] = strtoul(PQgetvalue(result, i, fnum), &endptr, 0); if(*endptr != '\0') { - Param_strerror(my, "Value seems to be no integer.\n"); + Param_strerror((Param *) my, "Value seems to be no integer.\n"); retVal = -1; } } @@ -95,13 +95,13 @@ int Param_getStringArray(const Param *my, const char *name, const char *idx, int result = PQexec(conn, query); if(PQresultStatus(result) != PGRES_TUPLES_OK) { - Param_strerror(my, "The PostgreSQL query result is not correct.\n"); + Param_strerror((Param *) my, "The PostgreSQL query result is not correct.\n"); return -1; } fnum = PQfnumber(result, "value"); if ((*rows = PQntuples(result)) > maxrows) { - Param_strerror(my, "Result has to many rows. Returning only 'maxrows' rows.\n"); + Param_strerror((Param *) my, "Result has to many rows. Returning only 'maxrows' rows.\n"); for (i = 0 ; i < maxrows ; i++) { strcpy(val[i], PQgetvalue(result, i, fnum)); } @@ -125,9 +125,11 @@ const char *Param_getErrStr(const Param *my) return my->strerror; } -static void Param_strerror(const Param *my, const char *strerror) +static void Param_strerror(Param *my, const char *strerror) { - realloc(my->strerror, strlen(strerror)); - strcpy(my->strerror, strerror); + my->strerror = realloc(my->strerror, strlen(strerror) + 1); + if(my->strerror != NULL) { + strcpy(my->strerror, strerror); + } } diff --git a/allParam/tcl/tclParam.c b/allParam/tcl/tclParam.c index df5c10b..145266f 100644 --- a/allParam/tcl/tclParam.c +++ b/allParam/tcl/tclParam.c @@ -5,10 +5,11 @@ #include #include #include +#include #include "param.h" -static void Param_strerror(const Param *, const char *); +static void Param_strerror(Param *, const char *); int conParam(Param *my) { @@ -27,7 +28,7 @@ int conParam(Param *my) if (*my->interp->result != 0) { Param_strerror(my, my->interp->result); } else { - Param_strerror(my, "Tcl interpreter cannot read file correctly and does not deliver an error string.\n"); + Param_strerror((Param *) my, "Tcl interpreter cannot read file correctly and does not deliver an error string.\n"); } retVal = -1; } else { @@ -45,28 +46,50 @@ int Param_getInt(const Param *my, const char *name, const char *idx, int *row, u { char valstr[PARAM_MAX_VALUE_LEN]; char *endptr; + if (Param_getString(my, name, idx, row, valstr) != 0) { return -1; + } else if(*row == 0) { + return 0; } if(valstr == NULL) { *row = 0; } else { *val = strtoul(valstr, &endptr, 0); - if (*endptr == '\0') { - Param_strerror(my, "Value seems to be no integer.\n"); + if (*endptr != '\0') { + Param_strerror((Param *) my, "Value seems to be no integer.\n"); + *row = 0; return -1; + } else { + *row = 1; } - *row = 1; } return 0; } int Param_getString(const Param *my, const char *name, const char *idx, int *row, char *val) { - strcpy(val, Tcl_GetVar2(my->interp, (char *) name, (char *) idx, 0)); - if (val == NULL) { + int retVal; + int i; + char lname[strlen(name) + 1]; + char lidx[strlen(idx) + 1]; + i = 0; + while(name[i] != '\0') { + lname[i] = tolower(name[i]); + i++; + } + lname[i] = '\0'; + i = 0; + while(idx[i] != '\0') { + lidx[i] = tolower(idx[i]); + i++; + } + lidx[i] = '\0'; + + if(Tcl_GetVar2(my->interp, lname, lidx, 0) == 0) { *row = 0; } else { + strcpy(val, Tcl_GetVar2(my->interp, lname, lidx, 0)); *row = 1; } return 0; @@ -82,7 +105,7 @@ int Param_getIntArray(const Param *my, const char *name, const char *idx, int ma for (i = 0 ; i < maxrows ; i++) { sprintf(index,"%s%d", idx, i); if(((retVal |= Param_getInt(my, name, index, &row, &val[i])) == 0) && (row == 1)) { - *rows++; + (*rows)++; } else { return retVal; } @@ -101,7 +124,7 @@ int Param_getStringArray(const Param *my, const char *name, const char *idx, int for (i = 0 ; i < maxrows ; i++) { sprintf(index,"%s%d", idx, i); if(((retVal |= Param_getString(my, name, index, &row, val[i])) == 0) && (row == 1)) { - *rows++; + (*rows)++; } else { return retVal; } @@ -115,9 +138,11 @@ const char *Param_getErrStr(const Param *my) return my->strerror; } -void Param_strerror(const Param *my, const char *strerror) +void Param_strerror(Param *my, const char *strerror) { - realloc(my->strerror, strlen(strerror)); - strcpy(my->strerror, strerror); + my->strerror = realloc(my->strerror, strlen(strerror) + 1); + if(my->strerror != NULL) { + strcpy(my->strerror, strerror); + } } diff --git a/allParam/test/Makefile b/allParam/test/Makefile new file mode 100644 index 0000000..c57c7cc --- /dev/null +++ b/allParam/test/Makefile @@ -0,0 +1,46 @@ +# Tcl test +CFLAGS = -I$(HOME)/include/tcl +LOADLIBES = -L$(HOME)/lib/$(SYSTYPE) -ltclParam -ltcl -lm -ldl + +# File test +#CFLAGS = -I$(HOME)/include/file +#LOADLIBES = -L$(HOME)/lib/$(SYSTYPE) -lfileParam + +# Oracle test +#ORACLE_HOME = /usr/local/oracle/product/8.0.5 +#CFLAGS = -I$(HOME)/include/ora +#LOADLIBES = -L$(HOME)/lib/$(SYSTYPE) -L$(ORACLE_HOME)/lib \ +# -loraParam -lsql -lclntsh -lcommon -lcore4 -lnlsrtl3 + +# PostgreSQL test +#CFLAGS = -I$(HOME)/include/psql +#LOADLIBES = -L$(HOME)/lib/$(SYSTYPE) -lpsqlParam -lpq -lcrypt + +# Channel Access test +#HOST_ARCH = Linux +#EPICS_HOME = $(HOME)/hades/epics +#EPICS_BASE = $(EPICS_HOME)/base +#CFLAGS = -I$(HOME)/include/ca +#LOADLIBES = -L$(HOME)/lib/$(SYSTYPE) -L$(EPICS_HOME)/lib/$(HOST_ARCH) \ +# -lcaParam -lca -lCom + +TESTS = test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 \ + test12 test13 test14 test15 test16 test17 test18 test19 test20 + +OBJS = suite.o $(addsuffix .o,$(TESTS)) + +suite : $(OBJS) + $(CC) $(LDFLAGS) $(OBJS) $(LOADLIBES) -o $@ + +new : + $(MAKE) -W suite.o suite + +suite.o : suite.c $(addsuffix .h, $(TESTS)) +$(addsuffix .o, $(TESTS)) : $(patsubst %.o,%.c,$@) $(patsubst %.o,%.h,$@) + +clean : + rm -f *.o + +bin_clean : + rm *.o suite + diff --git a/allParam/test/param.tcl b/allParam/test/param.tcl new file mode 100644 index 0000000..76e67b8 --- /dev/null +++ b/allParam/test/param.tcl @@ -0,0 +1,47 @@ +set crate_id(herakles) test0 + +set race0(se_id) 100 + +set race0(fefpgafile0) daq_cas/vme/race/conf/5frontend.rbt +set race0(fefpgafile1) daq_cas/vme/race/conf/5frontend.rbt +set race0(fefpgafile2) daq_cas/vme/race/conf/5frontend.rbt +set race0(fefpgafile3) daq_cas/vme/race/conf/5frontend.rbt +set race0(fefpgafile4) daq_cas/vme/race/conf/4frontend.rbt +set race0(fefpgafile5) daq_cas/vme/race/conf/4frontend.rbt +set race0(fefpgafile6) daq_cas/vme/race/conf/4frontend.rbt +set race0(fefpgafile7) daq_cas/vme/race/conf/5frontend.rbt +set race0(fefpgafile9) daq_cas/vme/race/conf/5frontend.rbt + +set tof_tdc0(threshold0) 0 +set tof_tdc0(threshold1) 0 +set tof_tdc0(threshold2) 0 +set tof_tdc0(threshold3) 0 +set tof_tdc0(threshold4) 0 +set tof_tdc0(threshold5) 0 +set tof_tdc0(threshold6) 0 +set tof_tdc0(threshold7) 0 +set tof_tdc0(threshold8) 0 +set tof_tdc0(threshold9) 0 +set tof_tdc0(threshold10) 0 +set tof_tdc0(threshold11) 0 +set tof_tdc0(threshold12) 0 +set tof_tdc0(threshold13) 0 +set tof_tdc0(threshold14) 0 +set tof_tdc0(threshold15) 0 +set tof_tdc0(threshold16) 0 +set tof_tdc0(threshold17) 0 +set tof_tdc0(threshold18) 0 +set tof_tdc0(threshold19) 0 +set tof_tdc0(threshold20) 0 +set tof_tdc0(threshold21) 0 +set tof_tdc0(threshold22) 0 +set tof_tdc0(threshold23) 0 +set tof_tdc0(threshold24) 0 +set tof_tdc0(threshold25) 0 +set tof_tdc0(threshold26) 0 +set tof_tdc0(threshold27) 0 +set tof_tdc0(threshold28) 0 +set tof_tdc0(threshold29) 0 +set tof_tdc0(threshold30) 0 +set tof_tdc0(threshold31) 0 + diff --git a/allParam/test/suite.c b/allParam/test/suite.c new file mode 100644 index 0000000..d7c40ea --- /dev/null +++ b/allParam/test/suite.c @@ -0,0 +1,64 @@ +#include +#include + +#include + +#include "test1.h" +#include "test2.h" +#include "test3.h" +#include "test4.h" +#include "test5.h" +#include "test6.h" +#include "test7.h" +#include "test8.h" +#include "test9.h" +#include "test10.h" +#include "test11.h" +#include "test12.h" +#include "test13.h" +#include "test14.h" +#include "test15.h" +#include "test16.h" +#include "test17.h" +#include "test18.h" +#include "test19.h" +#include "test20.h" + +int main(int argc, char *argv[]) { + Param *param; + int errors = 0; + + param = malloc(sizeof(Param)); + conParam(param); + + printf("================================================================================\n"); + errors -= test1("Test 1", param); + errors -= test2("Test 2", param); + errors -= test3("Test 3", param); + errors -= test4("Test 4", param); + errors -= test5("Test 5", param); + errors -= test6("Test 6", param); + errors -= test7("Test 7", param); + errors -= test8("Test 8", param); + errors -= test9("Test 9", param); + errors -= test10("Test 10", param); + errors -= test11("Test 11", param); + errors -= test12("Test 12", param); + errors -= test13("Test 13", param); + errors -= test14("Test 14", param); + errors -= test15("Test 15", param); + errors -= test16("Test 16", param); + errors -= test17("Test 17", param); + errors -= test18("Test 18", param); + errors -= test19("Test 19", param); + errors -= test20("Test 20", param); + + desParam(param); + free(param); + + printf("================================================================================\n"); + printf("%s : %d errors detected.\n", argv[0], errors); + printf("================================================================================\n"); + return 0; +} + diff --git a/allParam/test/test1.c b/allParam/test/test1.c new file mode 100644 index 0000000..8b0360f --- /dev/null +++ b/allParam/test/test1.c @@ -0,0 +1,29 @@ +#include +#include + +#include + +#include "test1.h" + +int test1(const char *testid, const Param *param) { + char *name = "crate_id"; + char *idx = "herakles"; + char result[PARAM_MAX_VALUE_LEN]; + int rows; + int retVal; + int myRetVal; + + printf("%s : Param_getString: Lowercase input on correct statements.\n", testid); + + retVal = Param_getString(param, name, idx, &rows, result); + if ((rows == 1) && result && (strcmp(result, "test0") == 0) && (retVal == 0)) { + myRetVal = 0; + printf("%s : Passed.\n", testid); + } else { + printf("%s : Failed. Rows: %d, result: \'%s\', return Value: %d.\n", testid, rows, result, retVal); + printf("%s : Error string: %s\n", testid, Param_getErrStr(param)); + myRetVal = -1; + } + return myRetVal; +} + diff --git a/allParam/test/test1.h b/allParam/test/test1.h new file mode 100644 index 0000000..d64f69e --- /dev/null +++ b/allParam/test/test1.h @@ -0,0 +1,8 @@ +#ifndef TEST1_H +#define TEST1_H + +#include + +int test1(const char *, const Param *); + +#endif diff --git a/allParam/test/test10.c b/allParam/test/test10.c new file mode 100644 index 0000000..1da27cd --- /dev/null +++ b/allParam/test/test10.c @@ -0,0 +1,29 @@ +#include +#include + +#include + +#include "test10.h" + +int test10(const char *testid, const Param *param) { + char *name = "race0"; + char *idx = "bla"; + unsigned long int result; + int rows; + int retVal; + int myRetVal; + + printf("%s : Param_getInt: Non-existing idx.\n", testid); + + retVal = Param_getInt(param, name, idx, &rows, &result); + if ((rows == 0) && (retVal == 0)) { + myRetVal = 0; + printf("%s : Passed.\n", testid); + } else { + printf("%s : Failed. Rows: %d, return Value: %d.\n", testid, rows, retVal); + printf("%s : Error string: %s\n", testid, Param_getErrStr(param)); + myRetVal = -1; + } + return myRetVal; +} + diff --git a/allParam/test/test10.h b/allParam/test/test10.h new file mode 100644 index 0000000..4b9e218 --- /dev/null +++ b/allParam/test/test10.h @@ -0,0 +1,8 @@ +#ifndef TEST10_H +#define TEST10_H + +#include + +int test10(const char *, const Param *); + +#endif diff --git a/allParam/test/test11.c b/allParam/test/test11.c new file mode 100644 index 0000000..d8d780b --- /dev/null +++ b/allParam/test/test11.c @@ -0,0 +1,29 @@ +#include +#include + +#include + +#include "test11.h" + +int test11(const char *testid, const Param *param) { + char *name = "race0"; + char *idx = "se_id"; + char result[PARAM_MAX_VALUE_LEN]; + int rows; + int retVal; + int myRetVal; + + printf("%s : Param_getString: String is wanted but int-like value found.\n", testid); + + retVal = Param_getString(param, name, idx, &rows, result); + if ((rows == 1) && result && (strcmp(result, "100") == 0) && (retVal == 0)) { + myRetVal = 0; + printf("%s : Passed.\n", testid); + } else { + printf("%s : Failed. Rows: %d, result: \'%s\', return Value: %d.\n", testid, rows, result, retVal); + printf("%s : Error string: %s\n", testid, Param_getErrStr(param)); + myRetVal = -1; + } + return myRetVal; +} + diff --git a/allParam/test/test11.h b/allParam/test/test11.h new file mode 100644 index 0000000..2550cb0 --- /dev/null +++ b/allParam/test/test11.h @@ -0,0 +1,8 @@ +#ifndef TEST11_H +#define TEST11_H + +#include + +int test11(const char *, const Param *); + +#endif diff --git a/allParam/test/test12.c b/allParam/test/test12.c new file mode 100644 index 0000000..b998a6d --- /dev/null +++ b/allParam/test/test12.c @@ -0,0 +1,29 @@ +#include +#include + +#include + +#include "test12.h" + +int test12(const char *testid, const Param *param) { + char *name = "crate_id"; + char *idx = "herakles"; + unsigned long int result; + int rows; + int retVal; + int myRetVal; + + printf("%s : Param_getInt: Integer is wanted but string-like value found.\n", testid); + + retVal = Param_getInt(param, name, idx, &rows, &result); + if ((rows == 0) && (retVal == -1)) { + myRetVal = 0; + printf("%s : Passed.\n", testid); + } else { + printf("%s : Failed. Rows: %d, return Value: %d.\n", testid, rows, retVal); + printf("%s : Error string: %s\n", testid, Param_getErrStr(param)); + myRetVal = -1; + } + return myRetVal; +} + diff --git a/allParam/test/test12.h b/allParam/test/test12.h new file mode 100644 index 0000000..4ca71e0 --- /dev/null +++ b/allParam/test/test12.h @@ -0,0 +1,8 @@ +#ifndef TEST12_H +#define TEST12_H + +#include + +int test12(const char *, const Param *); + +#endif diff --git a/allParam/test/test13.c b/allParam/test/test13.c new file mode 100644 index 0000000..90d9d5a --- /dev/null +++ b/allParam/test/test13.c @@ -0,0 +1,36 @@ +#include +#include + +#include + +#include "test13.h" + +int test13(const char *testid, const Param *param) { + char *name = "race0"; + char *idx = "blub"; + char *result[NUM1]; + int rows; + int retVal; + int myRetVal; + int i; + + for (i = 0 ; i < NUM1 ; i++) { + result[i] = malloc(PARAM_MAX_VALUE_LEN * sizeof(char)); + } + printf("%s : Param_getStringArray: Non-existing idx.\n", testid); + + retVal = Param_getStringArray(param, name, idx, NUM1, &rows, result); + if ((rows == 0) && (retVal == 0)) { + myRetVal = 0; + printf("%s : Passed.\n", testid); + } else { + printf("%s : Failed. Rows: %d, return Value: %d.\n", testid, rows, retVal); + printf("%s : Error string: %s\n", testid, Param_getErrStr(param)); + myRetVal = -1; + } + for (i = 0 ; i < NUM1 ; i++) { + free(result[i]); + } + return myRetVal; +} + diff --git a/allParam/test/test13.h b/allParam/test/test13.h new file mode 100644 index 0000000..0cc5448 --- /dev/null +++ b/allParam/test/test13.h @@ -0,0 +1,10 @@ +#ifndef TEST13_H +#define TEST13_H + +#include + +#define NUM1 8 + +int test13(const char *, const Param *); + +#endif diff --git a/allParam/test/test14.c b/allParam/test/test14.c new file mode 100644 index 0000000..e949e4a --- /dev/null +++ b/allParam/test/test14.c @@ -0,0 +1,31 @@ +#include +#include + +#include + +#include "test14.h" + +int test14(const char *testid, const Param *param) { + char *name = "tof_tdc0"; + char *idx = "blub"; + unsigned long int result[NUM2]; + int rows; + int resultsum = 1; + int i; + int retVal; + int myRetVal; + + printf("%s : Param_getIntArray: Non-existing idx.\n", testid); + + retVal = Param_getIntArray(param, name, idx, NUM2, &rows, result); + if ((rows == 0) && (retVal == 0)) { + myRetVal = 0; + printf("%s : Passed.\n", testid); + } else { + printf("%s : Failed. Rows: %d, return Value: %d\n", testid, rows, retVal); + printf("%s : Error string: %s\n", testid, Param_getErrStr(param)); + myRetVal = -1; + } + return myRetVal; +} + diff --git a/allParam/test/test14.h b/allParam/test/test14.h new file mode 100644 index 0000000..a0bd53b --- /dev/null +++ b/allParam/test/test14.h @@ -0,0 +1,10 @@ +#ifndef TEST14_H +#define TEST14_H + +#include + +#define NUM2 32 + +int test14(const char *, const Param *); + +#endif diff --git a/allParam/test/test15.c b/allParam/test/test15.c new file mode 100644 index 0000000..a5561b2 --- /dev/null +++ b/allParam/test/test15.c @@ -0,0 +1,45 @@ +#include +#include + +#include + +#include "test15.h" + +int test15(const char *testid, const Param *param) { + char *name = "race0"; + char *idx = "fefpgafile"; + char *result[NUM3]; + int rows; + int retVal; + int myRetVal; + int i; + + for (i = 0 ; i < NUM3 ; i++) { + result[i] = malloc(PARAM_MAX_VALUE_LEN * sizeof(char)); + } + printf("%s : Param_getStringArray: To few array members available.\n", testid); + + retVal = Param_getStringArray(param, name, idx, NUM3, &rows, result); + if ((rows == NUM1) && + result[0] && (strcmp(result[0], "daq_cas/vme/race/conf/5frontend.rbt") == 0) && + result[1] && (strcmp(result[1], "daq_cas/vme/race/conf/5frontend.rbt") == 0) && + result[2] && (strcmp(result[2], "daq_cas/vme/race/conf/5frontend.rbt") == 0) && + result[3] && (strcmp(result[3], "daq_cas/vme/race/conf/5frontend.rbt") == 0) && + result[4] && (strcmp(result[4], "daq_cas/vme/race/conf/4frontend.rbt") == 0) && + result[5] && (strcmp(result[5], "daq_cas/vme/race/conf/4frontend.rbt") == 0) && + result[6] && (strcmp(result[6], "daq_cas/vme/race/conf/4frontend.rbt") == 0) && + result[7] && (strcmp(result[7], "daq_cas/vme/race/conf/5frontend.rbt") == 0) && + (retVal == 0)) { + myRetVal = 0; + printf("%s : Passed.\n", testid); + } else { + printf("%s : Failed. Rows: %d, return Value: %d.\n", testid, rows, retVal); + printf("%s : Error string: %s\n", testid, Param_getErrStr(param)); + myRetVal = -1; + } + for (i = 0 ; i < NUM3 ; i++) { + free(result[i]); + } + return myRetVal; +} + diff --git a/allParam/test/test15.h b/allParam/test/test15.h new file mode 100644 index 0000000..298af3e --- /dev/null +++ b/allParam/test/test15.h @@ -0,0 +1,11 @@ +#ifndef TEST15_H +#define TEST15_H + +#include + +#define NUM1 8 +#define NUM3 16 + +int test15(const char *, const Param *); + +#endif diff --git a/allParam/test/test16.c b/allParam/test/test16.c new file mode 100644 index 0000000..f2e5af3 --- /dev/null +++ b/allParam/test/test16.c @@ -0,0 +1,34 @@ +#include +#include + +#include + +#include "test16.h" + +int test16(const char *testid, const Param *param) { + char *name = "tof_tdc0"; + char *idx = "threshold"; + unsigned long int result[NUM4]; + int rows; + int resultsum = 1; + int i; + int retVal; + int myRetVal; + + printf("%s : Param_getIntArray: To few array members available.\n", testid); + + retVal = Param_getIntArray(param, name, idx, NUM4, &rows, result); + for(i = 0 ; i < NUM2 ; i++) { + resultsum &= (result[i] == 0); + } + if ((rows == NUM2) && resultsum && (retVal == 0)) { + myRetVal = 0; + printf("%s : Passed.\n", testid); + } else { + printf("%s : Failed. Rows: %d, return Value: %d\n", testid, rows, retVal); + printf("%s : Error string: %s\n", testid, Param_getErrStr(param)); + myRetVal = -1; + } + return myRetVal; +} + diff --git a/allParam/test/test16.h b/allParam/test/test16.h new file mode 100644 index 0000000..02d02fe --- /dev/null +++ b/allParam/test/test16.h @@ -0,0 +1,11 @@ +#ifndef TEST16_H +#define TEST16_H + +#include + +#define NUM2 32 +#define NUM4 64 + +int test16(const char *, const Param *); + +#endif diff --git a/allParam/test/test17.c b/allParam/test/test17.c new file mode 100644 index 0000000..b7ec3c3 --- /dev/null +++ b/allParam/test/test17.c @@ -0,0 +1,41 @@ +#include +#include + +#include + +#include "test17.h" + +int test17(const char *testid, const Param *param) { + char *name = "race0"; + char *idx = "fefpgafile"; + char *result[NUM5]; + int rows; + int retVal; + int myRetVal; + int i; + + for (i = 0 ; i < NUM5 ; i++) { + result[i] = malloc(PARAM_MAX_VALUE_LEN * sizeof(char)); + } + printf("%s : Param_getStringArray: To many array members available.\n", testid); + + retVal = Param_getStringArray(param, name, idx, NUM5, &rows, result); + if ((rows == NUM5) && + result[0] && (strcmp(result[0], "daq_cas/vme/race/conf/5frontend.rbt") == 0) && + result[1] && (strcmp(result[1], "daq_cas/vme/race/conf/5frontend.rbt") == 0) && + result[2] && (strcmp(result[2], "daq_cas/vme/race/conf/5frontend.rbt") == 0) && + result[3] && (strcmp(result[3], "daq_cas/vme/race/conf/5frontend.rbt") == 0) && + (retVal == 0)) { + myRetVal = 0; + printf("%s : Passed.\n", testid); + } else { + printf("%s : Failed. Rows: %d, return Value: %d.\n", testid, rows, retVal); + printf("%s : Error string: %s\n", testid, Param_getErrStr(param)); + myRetVal = -1; + } + for (i = 0 ; i < NUM5 ; i++) { + free(result[i]); + } + return myRetVal; +} + diff --git a/allParam/test/test17.h b/allParam/test/test17.h new file mode 100644 index 0000000..f8a3d03 --- /dev/null +++ b/allParam/test/test17.h @@ -0,0 +1,11 @@ +#ifndef TEST17_H +#define TEST17_H + +#include + +#define NUM1 8 +#define NUM5 4 + +int test17(const char *, const Param *); + +#endif diff --git a/allParam/test/test18.c b/allParam/test/test18.c new file mode 100644 index 0000000..55edf7d --- /dev/null +++ b/allParam/test/test18.c @@ -0,0 +1,34 @@ +#include +#include + +#include + +#include "test18.h" + +int test18(const char *testid, const Param *param) { + char *name = "tof_tdc0"; + char *idx = "threshold"; + unsigned long int result[NUM6]; + int rows; + int resultsum = 1; + int i; + int retVal; + int myRetVal; + + printf("%s : Param_getIntArray: To many array members available.\n", testid); + + retVal = Param_getIntArray(param, name, idx, NUM6, &rows, result); + for(i = 0 ; i < NUM6 ; i++) { + resultsum &= (result[i] == 0); + } + if ((rows == NUM6) && resultsum && (retVal == 0)) { + myRetVal = 0; + printf("%s : Passed.\n", testid); + } else { + printf("%s : Failed. Rows: %d, return Value: %d\n", testid, rows, retVal); + printf("%s : Error string: %s\n", testid, Param_getErrStr(param)); + myRetVal = -1; + } + return myRetVal; +} + diff --git a/allParam/test/test18.h b/allParam/test/test18.h new file mode 100644 index 0000000..9ad80d2 --- /dev/null +++ b/allParam/test/test18.h @@ -0,0 +1,11 @@ +#ifndef TEST18_H +#define TEST18_H + +#include + +#define NUM2 32 +#define NUM6 16 + +int test18(const char *, const Param *); + +#endif diff --git a/allParam/test/test19.c b/allParam/test/test19.c new file mode 100644 index 0000000..4a79ee6 --- /dev/null +++ b/allParam/test/test19.c @@ -0,0 +1,69 @@ +#include +#include + +#include + +#include "test19.h" + +int test19(const char *testid, const Param *param) { + char *name = "tof_tdc0"; + char *idx = "threshold"; + char *result[NUM2]; + int rows; + int retVal; + int myRetVal; + int i; + + for (i = 0 ; i < NUM2 ; i++) { + result[i] = malloc(PARAM_MAX_VALUE_LEN * sizeof(char)); + } + printf("%s : Param_getStringArray: String is wanted but Int-like values found.\n", testid); + + retVal = Param_getStringArray(param, name, idx, NUM2, &rows, result); + if ((rows == NUM2) && + result[0] && (strcmp(result[0], "0") == 0) && + result[1] && (strcmp(result[1], "0") == 0) && + result[2] && (strcmp(result[2], "0") == 0) && + result[3] && (strcmp(result[3], "0") == 0) && + result[4] && (strcmp(result[4], "0") == 0) && + result[5] && (strcmp(result[5], "0") == 0) && + result[6] && (strcmp(result[6], "0") == 0) && + result[7] && (strcmp(result[7], "0") == 0) && + result[8] && (strcmp(result[8], "0") == 0) && + result[9] && (strcmp(result[9], "0") == 0) && + result[10] && (strcmp(result[10], "0") == 0) && + result[11] && (strcmp(result[11], "0") == 0) && + result[12] && (strcmp(result[12], "0") == 0) && + result[13] && (strcmp(result[13], "0") == 0) && + result[14] && (strcmp(result[14], "0") == 0) && + result[15] && (strcmp(result[15], "0") == 0) && + result[16] && (strcmp(result[16], "0") == 0) && + result[17] && (strcmp(result[17], "0") == 0) && + result[18] && (strcmp(result[18], "0") == 0) && + result[19] && (strcmp(result[19], "0") == 0) && + result[20] && (strcmp(result[20], "0") == 0) && + result[21] && (strcmp(result[21], "0") == 0) && + result[22] && (strcmp(result[22], "0") == 0) && + result[23] && (strcmp(result[23], "0") == 0) && + result[24] && (strcmp(result[24], "0") == 0) && + result[25] && (strcmp(result[25], "0") == 0) && + result[26] && (strcmp(result[26], "0") == 0) && + result[27] && (strcmp(result[27], "0") == 0) && + result[28] && (strcmp(result[28], "0") == 0) && + result[29] && (strcmp(result[29], "0") == 0) && + result[30] && (strcmp(result[30], "0") == 0) && + result[31] && (strcmp(result[31], "0") == 0) && + (retVal == 0)) { + myRetVal = 0; + printf("%s : Passed.\n", testid); + } else { + printf("%s : Failed. Rows: %d, return Value: %d.\n", testid, rows, retVal); + printf("%s : Error string: %s\n", testid, Param_getErrStr(param)); + myRetVal = -1; + } + for (i = 0 ; i < NUM2 ; i++) { + free(result[i]); + } + return myRetVal; +} + diff --git a/allParam/test/test19.h b/allParam/test/test19.h new file mode 100644 index 0000000..0e2d5bb --- /dev/null +++ b/allParam/test/test19.h @@ -0,0 +1,10 @@ +#ifndef TEST19_H +#define TEST19_H + +#include + +#define NUM2 32 + +int test19(const char *, const Param *); + +#endif diff --git a/allParam/test/test2.c b/allParam/test/test2.c new file mode 100644 index 0000000..224a4bc --- /dev/null +++ b/allParam/test/test2.c @@ -0,0 +1,29 @@ +#include +#include + +#include + +#include "test2.h" + +int test2(const char *testid, const Param *param) { + char *name = "race0"; + char *idx = "se_id"; + unsigned long int result; + int rows; + int retVal; + int myRetVal; + + printf("%s : Param_getInt: Lowercase input on correct statements.\n", testid); + + retVal = Param_getInt(param, name, idx, &rows, &result); + if ((rows == 1) && (result == 100) && (retVal == 0)) { + myRetVal = 0; + printf("%s : Passed.\n", testid); + } else { + printf("%s : Failed. Rows: %d, result: \'%d\', return Value: %d.\n", testid, rows, result, retVal); + printf("%s : Error string: %s\n", testid, Param_getErrStr(param)); + myRetVal = -1; + } + return myRetVal; +} + diff --git a/allParam/test/test2.h b/allParam/test/test2.h new file mode 100644 index 0000000..9cd4a0b --- /dev/null +++ b/allParam/test/test2.h @@ -0,0 +1,8 @@ +#ifndef TEST2_H +#define TEST2_H + +#include + +int test2(const char *, const Param *); + +#endif diff --git a/allParam/test/test20.c b/allParam/test/test20.c new file mode 100644 index 0000000..e1b79ce --- /dev/null +++ b/allParam/test/test20.c @@ -0,0 +1,31 @@ +#include +#include + +#include + +#include "test20.h" + +int test20(const char *testid, const Param *param) { + char *name = "race0"; + char *idx = "fefpgafile"; + unsigned long int result[NUM1]; + int rows; + int resultsum = 1; + int i; + int retVal; + int myRetVal; + + printf("%s : Param_getIntArray: Int is wanted but String-like values found.\n", testid); + + retVal = Param_getIntArray(param, name, idx, NUM1, &rows, result); + if ((rows == 0) && (retVal == -1)) { + myRetVal = 0; + printf("%s : Passed.\n", testid); + } else { + printf("%s : Failed. Rows: %d, return Value: %d\n", testid, rows, retVal); + printf("%s : Error string: %s\n", testid, Param_getErrStr(param)); + myRetVal = -1; + } + return myRetVal; +} + diff --git a/allParam/test/test20.h b/allParam/test/test20.h new file mode 100644 index 0000000..c4d0b6e --- /dev/null +++ b/allParam/test/test20.h @@ -0,0 +1,10 @@ +#ifndef TEST20_H +#define TEST20_H + +#include + +#define NUM1 8 + +int test20(const char *, const Param *); + +#endif diff --git a/allParam/test/test3.c b/allParam/test/test3.c new file mode 100644 index 0000000..3610ff4 --- /dev/null +++ b/allParam/test/test3.c @@ -0,0 +1,54 @@ +#include +#include + +#include + +#include "test3.h" + +int test3(const char *testid, const Param *param) { + char *name = "race0"; + char *idx = "fefpgafile"; + char *result[NUM1]; + int rows; + int retVal; + int myRetVal; + int i; + + for (i = 0 ; i < NUM1 ; i++) { + result[i] = malloc(PARAM_MAX_VALUE_LEN * sizeof(char)); + } + printf("%s : Param_getStringArray: Lowercase input on correct statements.\n", testid); + + retVal = Param_getStringArray(param, name, idx, NUM1, &rows, result); + if ((rows == NUM1) && + result[0] && (strcmp(result[0], "daq_cas/vme/race/conf/5frontend.rbt") == 0) && + result[1] && (strcmp(result[1], "daq_cas/vme/race/conf/5frontend.rbt") == 0) && + result[2] && (strcmp(result[2], "daq_cas/vme/race/conf/5frontend.rbt") == 0) && + result[3] && (strcmp(result[3], "daq_cas/vme/race/conf/5frontend.rbt") == 0) && + result[4] && (strcmp(result[4], "daq_cas/vme/race/conf/4frontend.rbt") == 0) && + result[5] && (strcmp(result[5], "daq_cas/vme/race/conf/4frontend.rbt") == 0) && + result[6] && (strcmp(result[6], "daq_cas/vme/race/conf/4frontend.rbt") == 0) && + result[7] && (strcmp(result[7], "daq_cas/vme/race/conf/5frontend.rbt") == 0) && + (retVal == 0)) { + myRetVal = 0; + printf("%s : Passed.\n", testid); + } else { + printf("%s : Failed. Rows: %d, result array:\n%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s\nreturn Value: %d.\n", testid, rows, + result[0], + result[1], + result[2], + result[3], + result[4], + result[5], + result[6], + result[7], + retVal); + printf("%s : Error string: %s\n", testid, Param_getErrStr(param)); + myRetVal = -1; + } + for (i = 0 ; i < NUM1 ; i++) { + free(result[i]); + } + return myRetVal; +} + diff --git a/allParam/test/test3.h b/allParam/test/test3.h new file mode 100644 index 0000000..4d053dd --- /dev/null +++ b/allParam/test/test3.h @@ -0,0 +1,10 @@ +#ifndef TEST3_H +#define TEST3_H + +#include + +#define NUM1 8 + +int test3(const char *, const Param *); + +#endif diff --git a/allParam/test/test4.c b/allParam/test/test4.c new file mode 100644 index 0000000..947c52f --- /dev/null +++ b/allParam/test/test4.c @@ -0,0 +1,38 @@ +#include +#include + +#include + +#include "test4.h" + +int test4(const char *testid, const Param *param) { + char *name = "tof_tdc0"; + char *idx = "threshold"; + unsigned long int result[NUM2]; + int rows; + int resultsum = 1; + int i; + int retVal; + int myRetVal; + + printf("%s : Param_getIntArray: Lowercase input on correct statements.\n", testid); + + retVal = Param_getIntArray(param, name, idx, NUM2, &rows, result); + for(i = 0 ; i < NUM2 ; i++) { + resultsum &=(result[i] == 0); + } + if ((rows == NUM2) && resultsum && (retVal == 0)) { + myRetVal = 0; + printf("%s : Passed.\n", testid); + } else { + printf("%s : Failed. Rows: %d, result array:\n", testid, rows); + for(i = 0 ; i < NUM2 ; i++) { + printf("result[%d]: %d.\n", i, result[i]); + } + printf("return Value: %d.\n", retVal); + printf("%s : Error string: %s\n", testid, Param_getErrStr(param)); + myRetVal = -1; + } + return myRetVal; +} + diff --git a/allParam/test/test4.h b/allParam/test/test4.h new file mode 100644 index 0000000..95e178d --- /dev/null +++ b/allParam/test/test4.h @@ -0,0 +1,10 @@ +#ifndef TEST4_H +#define TEST4_H + +#include + +#define NUM2 32 + +int test4(const char *, const Param *); + +#endif diff --git a/allParam/test/test5.c b/allParam/test/test5.c new file mode 100644 index 0000000..c987038 --- /dev/null +++ b/allParam/test/test5.c @@ -0,0 +1,29 @@ +#include +#include + +#include + +#include "test5.h" + +int test5(const char *testid, const Param *param) { + char *name = "CRATE_ID"; + char *idx = "HERAKLES"; + char result[PARAM_MAX_VALUE_LEN]; + int rows; + int retVal; + int myRetVal; + + printf("%s : Param_getString: Uppercase input on correct statements.\n", testid); + + retVal = Param_getString(param, name, idx, &rows, result); + if ((rows == 1) && result && (strcmp(result, "test0") == 0) && (retVal == 0)) { + myRetVal = 0; + printf("%s : Passed.\n", testid); + } else { + printf("%s : Failed. Rows: %d, result: \'%s\', return Value: %d.\n", testid, rows, result, retVal); + printf("%s : Error string: %s\n", testid, Param_getErrStr(param)); + myRetVal = -1; + } + return myRetVal; +} + diff --git a/allParam/test/test5.h b/allParam/test/test5.h new file mode 100644 index 0000000..5459560 --- /dev/null +++ b/allParam/test/test5.h @@ -0,0 +1,8 @@ +#ifndef TEST5_H +#define TEST5_H + +#include + +int test5(const char *, const Param *); + +#endif diff --git a/allParam/test/test6.c b/allParam/test/test6.c new file mode 100644 index 0000000..62d5e15 --- /dev/null +++ b/allParam/test/test6.c @@ -0,0 +1,29 @@ +#include +#include + +#include + +#include "test6.h" + +int test6(const char *testid, const Param *param) { + char *name = "RACE0"; + char *idx = "SE_ID"; + unsigned long int result; + int rows; + int retVal; + int myRetVal; + + printf("%s : Param_getInt: Uppercase input on correct statements.\n", testid); + + retVal = Param_getInt(param, name, idx, &rows, &result); + if ((rows == 1) && (result == 100) && (retVal == 0)) { + myRetVal = 0; + printf("%s : Passed.\n", testid); + } else { + printf("%s : Failed. Rows: %d, result: \'%d\', return Value: %d.\n", testid, rows, result, retVal); + printf("%s : Error string: %s\n", testid, Param_getErrStr(param)); + myRetVal = -1; + } + return myRetVal; +} + diff --git a/allParam/test/test6.h b/allParam/test/test6.h new file mode 100644 index 0000000..2673262 --- /dev/null +++ b/allParam/test/test6.h @@ -0,0 +1,8 @@ +#ifndef TEST6_H +#define TEST6_H + +#include + +int test6(const char *, const Param *); + +#endif diff --git a/allParam/test/test7.c b/allParam/test/test7.c new file mode 100644 index 0000000..77ccc2a --- /dev/null +++ b/allParam/test/test7.c @@ -0,0 +1,54 @@ +#include +#include + +#include + +#include "test7.h" + +int test7(const char *testid, const Param *param) { + char *name = "RACE0"; + char *idx = "FEFPGAFILE"; + char *result[NUM1]; + int rows; + int retVal; + int myRetVal; + int i; + + for (i = 0 ; i < NUM1 ; i++) { + result[i] = malloc(PARAM_MAX_VALUE_LEN * sizeof(char)); + } + printf("%s : Param_getStringArray: Uppercase input on correct statements.\n", testid); + + retVal = Param_getStringArray(param, name, idx, NUM1, &rows, result); + if ((rows == NUM1) && + result[0] && (strcmp(result[0], "daq_cas/vme/race/conf/5frontend.rbt") == 0) && + result[1] && (strcmp(result[1], "daq_cas/vme/race/conf/5frontend.rbt") == 0) && + result[2] && (strcmp(result[2], "daq_cas/vme/race/conf/5frontend.rbt") == 0) && + result[3] && (strcmp(result[3], "daq_cas/vme/race/conf/5frontend.rbt") == 0) && + result[4] && (strcmp(result[4], "daq_cas/vme/race/conf/4frontend.rbt") == 0) && + result[5] && (strcmp(result[5], "daq_cas/vme/race/conf/4frontend.rbt") == 0) && + result[6] && (strcmp(result[6], "daq_cas/vme/race/conf/4frontend.rbt") == 0) && + result[7] && (strcmp(result[7], "daq_cas/vme/race/conf/5frontend.rbt") == 0) && + (retVal == 0)) { + myRetVal = 0; + printf("%s : Passed.\n", testid); + } else { + printf("%s : Failed. Rows: %d, result array:\n%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s\nreturn Value: %d.\n", testid, rows, + result[0], + result[1], + result[2], + result[3], + result[4], + result[5], + result[6], + result[7], + retVal); + printf("%s : Error string: %s\n", testid, Param_getErrStr(param)); + myRetVal = -1; + } + for (i = 0 ; i < NUM1 ; i++) { + free(result[i]); + } + return myRetVal; +} + diff --git a/allParam/test/test7.h b/allParam/test/test7.h new file mode 100644 index 0000000..0ba6047 --- /dev/null +++ b/allParam/test/test7.h @@ -0,0 +1,10 @@ +#ifndef TEST7_H +#define TEST7_H + +#include + +#define NUM1 8 + +int test7(const char *, const Param *); + +#endif diff --git a/allParam/test/test8.c b/allParam/test/test8.c new file mode 100644 index 0000000..cfed94e --- /dev/null +++ b/allParam/test/test8.c @@ -0,0 +1,38 @@ +#include +#include + +#include + +#include "test8.h" + +int test8(const char *testid, const Param *param) { + char *name = "TOF_TDC0"; + char *idx = "THRESHOLD"; + unsigned long int result[NUM2]; + int rows; + int resultsum = 1; + int i; + int retVal; + int myRetVal; + + printf("%s : Param_getIntArray: Uppercase input on correct statements.\n", testid); + + retVal = Param_getIntArray(param, name, idx, NUM2, &rows, result); + for(i = 0 ; i < NUM2 ; i++) { + resultsum &=(result[i] == 0); + } + if ((rows == NUM2) && resultsum && (retVal == 0)) { + myRetVal = 0; + printf("%s : Passed.\n", testid); + } else { + printf("%s : Failed. Rows: %d, result array:\n", testid, rows); + for(i = 0 ; i < NUM2 ; i++) { + printf("result[%d]: %d.\n", i, result[i]); + } + printf("return Value: %d.\n", retVal); + printf("%s : Error string: %s\n", testid, Param_getErrStr(param)); + myRetVal = -1; + } + return myRetVal; +} + diff --git a/allParam/test/test8.h b/allParam/test/test8.h new file mode 100644 index 0000000..95e178d --- /dev/null +++ b/allParam/test/test8.h @@ -0,0 +1,10 @@ +#ifndef TEST4_H +#define TEST4_H + +#include + +#define NUM2 32 + +int test4(const char *, const Param *); + +#endif diff --git a/allParam/test/test9.c b/allParam/test/test9.c new file mode 100644 index 0000000..da51da8 --- /dev/null +++ b/allParam/test/test9.c @@ -0,0 +1,29 @@ +#include +#include + +#include + +#include "test9.h" + +int test9(const char *testid, const Param *param) { + char *name = "crate_id"; + char *idx = "blub"; + char result[PARAM_MAX_VALUE_LEN]; + int rows; + int retVal; + int myRetVal; + + printf("%s : Param_getString: Non-existing idx.\n", testid); + + retVal = Param_getString(param, name, idx, &rows, result); + if ((rows == 0) && (retVal == 0)) { + myRetVal = 0; + printf("%s : Passed.\n", testid); + } else { + printf("%s : Failed. Rows: %d, return Value: %d.\n", testid, rows, retVal); + printf("%s : Error string: %s\n", testid, Param_getErrStr(param)); + myRetVal = -1; + } + return myRetVal; +} + diff --git a/allParam/test/test9.h b/allParam/test/test9.h new file mode 100644 index 0000000..c898869 --- /dev/null +++ b/allParam/test/test9.h @@ -0,0 +1,8 @@ +#ifndef TEST9_H +#define TEST9_H + +#include + +int test9(const char *, const Param *); + +#endif -- 2.43.0