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)
{
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;
}
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;
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);
}
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;
}
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;
}
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;
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);
}
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;
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;
}
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):
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++;
}
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;
}
}
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;
}
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) {
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);
+ }
}
#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)
{
}
*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;
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]);
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;
}
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;
}
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);
+ }
}
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);
+ }
}
#include "param.h"
-static void Param_strerror(const Param *, const char *);
+static void Param_strerror(Param *, const char *);
int conParam(Param *my)
{
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;
}
}
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;
}
}
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));
}
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);
+ }
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
#include "param.h"
-static void Param_strerror(const Param *, const char *);
+static void Param_strerror(Param *, const char *);
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 {
{
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;
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;
}
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;
}
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);
+ }
}
--- /dev/null
+# 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
+
--- /dev/null
+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
+
--- /dev/null
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <param.h>
+
+#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;
+}
+
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+
+#include <param.h>
+
+#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;
+}
+
--- /dev/null
+#ifndef TEST1_H
+#define TEST1_H
+
+#include <param.h>
+
+int test1(const char *, const Param *);
+
+#endif
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+
+#include <param.h>
+
+#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;
+}
+
--- /dev/null
+#ifndef TEST10_H
+#define TEST10_H
+
+#include <param.h>
+
+int test10(const char *, const Param *);
+
+#endif
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+
+#include <param.h>
+
+#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;
+}
+
--- /dev/null
+#ifndef TEST11_H
+#define TEST11_H
+
+#include <param.h>
+
+int test11(const char *, const Param *);
+
+#endif
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+
+#include <param.h>
+
+#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;
+}
+
--- /dev/null
+#ifndef TEST12_H
+#define TEST12_H
+
+#include <param.h>
+
+int test12(const char *, const Param *);
+
+#endif
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+
+#include <param.h>
+
+#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;
+}
+
--- /dev/null
+#ifndef TEST13_H
+#define TEST13_H
+
+#include <param.h>
+
+#define NUM1 8
+
+int test13(const char *, const Param *);
+
+#endif
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+
+#include <param.h>
+
+#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;
+}
+
--- /dev/null
+#ifndef TEST14_H
+#define TEST14_H
+
+#include <param.h>
+
+#define NUM2 32
+
+int test14(const char *, const Param *);
+
+#endif
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+
+#include <param.h>
+
+#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;
+}
+
--- /dev/null
+#ifndef TEST15_H
+#define TEST15_H
+
+#include <param.h>
+
+#define NUM1 8
+#define NUM3 16
+
+int test15(const char *, const Param *);
+
+#endif
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+
+#include <param.h>
+
+#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;
+}
+
--- /dev/null
+#ifndef TEST16_H
+#define TEST16_H
+
+#include <param.h>
+
+#define NUM2 32
+#define NUM4 64
+
+int test16(const char *, const Param *);
+
+#endif
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+
+#include <param.h>
+
+#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;
+}
+
--- /dev/null
+#ifndef TEST17_H
+#define TEST17_H
+
+#include <param.h>
+
+#define NUM1 8
+#define NUM5 4
+
+int test17(const char *, const Param *);
+
+#endif
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+
+#include <param.h>
+
+#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;
+}
+
--- /dev/null
+#ifndef TEST18_H
+#define TEST18_H
+
+#include <param.h>
+
+#define NUM2 32
+#define NUM6 16
+
+int test18(const char *, const Param *);
+
+#endif
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+
+#include <param.h>
+
+#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;
+}
+
--- /dev/null
+#ifndef TEST19_H
+#define TEST19_H
+
+#include <param.h>
+
+#define NUM2 32
+
+int test19(const char *, const Param *);
+
+#endif
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+
+#include <param.h>
+
+#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;
+}
+
--- /dev/null
+#ifndef TEST2_H
+#define TEST2_H
+
+#include <param.h>
+
+int test2(const char *, const Param *);
+
+#endif
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+
+#include <param.h>
+
+#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;
+}
+
--- /dev/null
+#ifndef TEST20_H
+#define TEST20_H
+
+#include <param.h>
+
+#define NUM1 8
+
+int test20(const char *, const Param *);
+
+#endif
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+
+#include <param.h>
+
+#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;
+}
+
--- /dev/null
+#ifndef TEST3_H
+#define TEST3_H
+
+#include <param.h>
+
+#define NUM1 8
+
+int test3(const char *, const Param *);
+
+#endif
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+
+#include <param.h>
+
+#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;
+}
+
--- /dev/null
+#ifndef TEST4_H
+#define TEST4_H
+
+#include <param.h>
+
+#define NUM2 32
+
+int test4(const char *, const Param *);
+
+#endif
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+
+#include <param.h>
+
+#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;
+}
+
--- /dev/null
+#ifndef TEST5_H
+#define TEST5_H
+
+#include <param.h>
+
+int test5(const char *, const Param *);
+
+#endif
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+
+#include <param.h>
+
+#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;
+}
+
--- /dev/null
+#ifndef TEST6_H
+#define TEST6_H
+
+#include <param.h>
+
+int test6(const char *, const Param *);
+
+#endif
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+
+#include <param.h>
+
+#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;
+}
+
--- /dev/null
+#ifndef TEST7_H
+#define TEST7_H
+
+#include <param.h>
+
+#define NUM1 8
+
+int test7(const char *, const Param *);
+
+#endif
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+
+#include <param.h>
+
+#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;
+}
+
--- /dev/null
+#ifndef TEST4_H
+#define TEST4_H
+
+#include <param.h>
+
+#define NUM2 32
+
+int test4(const char *, const Param *);
+
+#endif
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+
+#include <param.h>
+
+#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;
+}
+
--- /dev/null
+#ifndef TEST9_H
+#define TEST9_H
+
+#include <param.h>
+
+int test9(const char *, const Param *);
+
+#endif