cd filename ; $(MAKE) $@
cd int ; $(MAKE) $@
cd string ; $(MAKE) $@
- rm -f *test_protocol.txt sqlnet.log *_s.tcl storage.tcl suite.c suite.o
+ rm -f *test_protocol.txt sqlnet.log *_s.tcl storage.tcl test?.blob \
+ suite.c suite.o
bin_clean : clean
rm -f *_suite
TUM/E12
Benjamin.Sailer@ph.tum.de
Version: 0.1
-Date: 2000-09-10
+Date: 2001-03-28
test suite
==========
unfortunately is (depending on the shell you are using) not always written to
the file but sometimes only to stderr. Note that channel access is not
deterministic as timeouts can occur on a heavily used network, which can be
-tuned changing the TIMEOUT definition in ca/param.h. Of course the enviroment
-needed at runtime is also needed when testing (i.e. a channel access server
-has to provide the data in case of ca_test_suite and network connection to the
-database hosts are needed for ora_test_suite and psql_test_suite.
+tuned changing the TIMEOUT definition in ca/caParam.c. Of course the enviroment
+needed at runtime is also needed when testing (i.e. network connection to the
+database hosts are needed for ora_test_suite and psql_test_suite). As the
+parameter server is now part of this library package, the test of caParam also
+uses the server compiled here. The scripts in ./bin do the startup and kill of
+the server automatically when make <lib>_test is used.
+
+ To increase the verbosity of the tests, you can add a -DVERBOSE to the
+CFLAGS in the Makefile.
+
+ If a test_suite fails with a segmentation violation and the output in the
+test protocol therefore is no help, you can run the test manually (by typing
+
+$ ./<lib>_test_suite
+
+) to find out which test fails. By renaming the corresponding sources (i.e.
+
+$ cd int
+$ mv i_lowercase.c i_lowercase.c-
+$ mv i_lowercase.h i_lowercase.h-
+$ cd -
+$ make clean
+$ make <lib>_test
+
+), you can skip a single test.
There is also a huge field of errors not tested yet (containing all overflows
of name lengths, index lengths, param file lengths, array lengths and so on -
-#include <stdlib.h>
#include <stdio.h>
-#include <allParam.h>
-
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <allParam.h>
#include "b_lowercase.h"
-int b_lowercase(const char *testid, const Param *param) {
- char *name = "tname";
- char *idx = "tint";
- char buf[256];
+int b_lowercase(const char *testid) {
+ Param *param;
+ char *name = "file";
+ char *idx = "rname";
FILE *result;
FILE *store;
size_t size;
- size_t bufsize;
int retVal;
int myRetVal;
printf("%s : Param_getBlob: Lowercase input on correct statements.\n", testid);
#endif
+ param = malloc(sizeof(Param));
+ conParam(param);
+
retVal = Param_getBlob(param, name, idx, &size, &result);
- store = fopen("blob", "w+");
- while(bufsize = fread(buf, 1, 256, result)) {
- fwrite(buf, 1, bufsize, store);
- }
- fclose(result);
- fclose(store);
if ((size == 16368) && (retVal == 0)) {
- if (!system("diff blob BLOB")) {
+ int buf;
+ store = fopen("test0.blob", "w+");
+ while((buf = fgetc(result)) != EOF) {
+ putc(buf, store);
+ }
+ fclose(store);
+ if (!system("diff test0.blob blob/test0.blob")) {
myRetVal = 0;
printf("%s : Passed.\n", testid);
} else {
#ifdef VERBOSE
- printf("%s : Failed. Files \"blob\" and \"BLOB\" differ.\n", testid);
+ printf("%s : Failed. Files \"test0.blob\" and \"blob/test0.blob\" differ.\n", testid);
#else
printf("%s : Failed.\n", testid);
#endif
myRetVal = -1;
}
+ fclose(result);
} else {
#ifdef VERBOSE
printf("%s : Failed. Size: %d, return Value: %d.\n", testid, size, retVal);
#endif
myRetVal = -1;
}
+
+ desParam(param);
+ free(param);
+
return myRetVal;
}
#ifndef B_LOWERCASE_H
#define B_LOWERCASE_H
-#include <allParam.h>
-
-int b_lowercase(const char *, const Param *);
+int b_lowercase(const char *);
#endif
- desParam(param);
- free(param);
-
printf("================================================================================\n");
printf("%s : %d errors detected.\n", argv[0], errors);
printf("================================================================================\n");
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <allParam.h>
+
+#include "f_lowercase_abs.h"
+
+int f_lowercase_abs(const char *testid) {
+ Param *param;
+ char *name = "file";
+ char *idx = "aname";
+ char result[PARAM_MAX_VALUE_LEN];
+ int rows;
+ int retVal;
+ int myRetVal;
+
+#ifdef VERBOSE
+ printf("%s : Param_getFilename: Lowercase input on correct statements.\n", testid);
+#endif
+
+ param = malloc(sizeof(Param));
+ conParam(param);
+
+ retVal = Param_getFilename(param, name, idx, &rows, result);
+ if ((rows == 1) && result && (strcmp(result, "/test0.blob") == 0) && (retVal == 0)) {
+ myRetVal = 0;
+ printf("%s : Passed.\n", testid);
+ } else {
+#ifdef VERBOSE
+ 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;
+#else
+ printf("%s : Failed.\n", testid);
+#endif
+ }
+
+ desParam(param);
+ free(param);
+
+ return myRetVal;
+}
+
--- /dev/null
+#ifndef F_LOWERCASE_ABS_H
+#define F_LOWERCASE_ABS_H
+
+int f_lowercase_abs(const char *);
+
+#endif
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <allParam.h>
#include "f_lowercase_rel.h"
-int f_lowercase_rel(const char *testid, const Param *param) {
+int f_lowercase_rel(const char *testid) {
+ Param *param;
char *name = "file";
char *idx = "rname";
char result[PARAM_MAX_VALUE_LEN];
printf("%s : Param_getFilename: Lowercase input on correct statements.\n", testid);
#endif
+ param = malloc(sizeof(Param));
+ conParam(param);
+
retVal = Param_getFilename(param, name, idx, &rows, result);
- if ((rows == 1) && result && (strcmp(result, "test/blob/BLOB") == 0) && (retVal == 0)) {
+ if ((rows == 1) && result && (strcmp(result, "blob/test0.blob") == 0) && (retVal == 0)) {
myRetVal = 0;
printf("%s : Passed.\n", testid);
} else {
printf("%s : Failed.\n", testid);
#endif
}
+
+ desParam(param);
+ free(param);
+
return myRetVal;
}
#ifndef F_LOWERCASE_REL_H
#define F_LOWERCASE_REL_H
-#include <allParam.h>
-
-int f_lowercase_rel(const char *, const Param *);
+int f_lowercase_rel(const char *);
#endif
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <allParam.h>
+
+#include "f_lowercase_rel_no_basedir.h"
+
+int f_lowercase_rel_no_basedir(const char *testid) {
+ Param *param;
+ char *name = "file";
+ char *idx = "rname";
+ char result[PARAM_MAX_VALUE_LEN];
+ int rows;
+ int retVal;
+ int myRetVal;
+
+#ifdef VERBOSE
+ printf("%s : Param_getFilename: Lowercase input on correct statements.\n", testid);
+ printf("%s : No glob(basedir) specified in parameter source.\n", testid);
+#endif
+
+ param = malloc(sizeof(Param));
+ conSetupParam(param, "test");
+
+ retVal = Param_getFilename(param, name, idx, &rows, result);
+ if ((rows == 1) && result && (strcmp(result, "test0.blob") == 0) && (retVal == 0)) {
+ myRetVal = 0;
+ printf("%s : Passed.\n", testid);
+ } else {
+#ifdef VERBOSE
+ 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;
+#else
+ printf("%s : Failed.\n", testid);
+#endif
+ }
+
+ desParam(param);
+ free(param);
+
+ return myRetVal;
+}
+
--- /dev/null
+#ifndef F_LOWERCASE_REL_NO_BASEDIR_H
+#define F_LOWERCASE_REL_NO_BASEDIR_H
+
+int f_lowercase_rel_no_basedir(const char *);
+
+#endif
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <allParam.h>
+
+#include "fa_lowercase.h"
+
+#define NUM1 8
+
+int fa_lowercase(const char *testid) {
+ Param *param;
+ char *name = "file";
+ char *idx = "namea";
+ char *result[NUM1];
+ int rows;
+ int retVal;
+ int myRetVal;
+ int i;
+
+#ifdef VERBOSE
+ printf("%s : Param_getFilenameArray: Lowercase input on correct statements.\n", testid);
+ printf("%s : glob(basedir) set to \"blob\" in the parameter source.\n", testid);
+#endif
+
+ param = malloc(sizeof(Param));
+ conParam(param);
+
+ for (i = 0 ; i < NUM1 ; i++) {
+ result[i] = malloc(PARAM_MAX_VALUE_LEN * sizeof(char));
+ }
+
+ retVal = Param_getFilenameArray(param, name, idx, NUM1, &rows, result);
+ if ((rows == NUM1) &&
+ result[0] && (strcmp(result[0], "blob/test1.blob") == 0) &&
+ result[1] && (strcmp(result[1], "/test0.blob") == 0) &&
+ result[2] && (strcmp(result[2], "blob/test3.blob") == 0) &&
+ result[3] && (strcmp(result[3], "/test2.blob") == 0) &&
+ result[4] && (strcmp(result[4], "blob/test5.blob") == 0) &&
+ result[5] && (strcmp(result[5], "/test4.blob") == 0) &&
+ result[6] && (strcmp(result[6], "blob/test7.blob") == 0) &&
+ result[7] && (strcmp(result[7], "/test6.blob") == 0) &&
+ (retVal == 0)) {
+ myRetVal = 0;
+ printf("%s : Passed.\n", testid);
+ } else {
+#ifdef VERBOSE
+ 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));
+#else
+ printf("%s : Failed.\n", testid);
+#endif
+ myRetVal = -1;
+ }
+
+ for (i = 0 ; i < NUM1 ; i++) {
+ free(result[i]);
+ }
+
+ desParam(param);
+ free(param);
+
+ return myRetVal;
+}
+
--- /dev/null
+#ifndef FA_LOWERCASE_H
+#define FA_LOWERCASE_H
+
+int fa_lowercase(const char *);
+
+#endif
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <allParam.h>
+
+#include "fa_lowercase_no_basedir.h"
+
+#define NUM1 8
+
+int fa_lowercase_no_basedir(const char *testid) {
+ Param *param;
+ char *name = "file";
+ char *idx = "namea";
+ char *result[NUM1];
+ int rows;
+ int retVal;
+ int myRetVal;
+ int i;
+
+#ifdef VERBOSE
+ printf("%s : Param_getFilenameArray: Lowercase input on correct statements.\n", testid);
+ printf("%s : No glob(basedir) specified in the parameter source.\n", testid);
+#endif
+
+ param = malloc(sizeof(Param));
+ conSetupParam(param, "test");
+
+ for (i = 0 ; i < NUM1 ; i++) {
+ result[i] = malloc(PARAM_MAX_VALUE_LEN * sizeof(char));
+ }
+
+ retVal = Param_getFilenameArray(param, name, idx, NUM1, &rows, result);
+ if ((rows == NUM1) &&
+ result[0] && (strcmp(result[0], "test1.blob") == 0) &&
+ result[1] && (strcmp(result[1], "/test0.blob") == 0) &&
+ result[2] && (strcmp(result[2], "test3.blob") == 0) &&
+ result[3] && (strcmp(result[3], "/test2.blob") == 0) &&
+ result[4] && (strcmp(result[4], "test5.blob") == 0) &&
+ result[5] && (strcmp(result[5], "/test4.blob") == 0) &&
+ result[6] && (strcmp(result[6], "test7.blob") == 0) &&
+ result[7] && (strcmp(result[7], "/test6.blob") == 0) &&
+ (retVal == 0)) {
+ myRetVal = 0;
+ printf("%s : Passed.\n", testid);
+ } else {
+#ifdef VERBOSE
+ 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));
+#else
+ printf("%s : Failed.\n", testid);
+#endif
+ myRetVal = -1;
+ }
+
+ for (i = 0 ; i < NUM1 ; i++) {
+ free(result[i]);
+ }
+
+ desParam(param);
+ free(param);
+
+ return myRetVal;
+}
+
--- /dev/null
+#ifndef FA_LOWERCASE_NO_BASEDIR_H
+#define FA_LOWERCASE_NO_BASEDIR_H
+
+int fa_lowercase_no_basedir(const char *);
+
+#endif
int main(int argc, char *argv[]) {
- Param *param;
int errors = 0;
- param = malloc(sizeof(Param));
- conParam(param);
-
printf("================================================================================\n");
printf("%s : Starting test ...\n", argv[0]);
printf("================================================================================\n");
set glob(basedir) blob
-set file(rname) test.blob
-set file(aname) /test.blob
+set file(rname) test0.blob
+set file(aname) /test0.blob
+set file(rnamellarge) test1.blob
+set file(rnameodd) test2.blob
set file(namea0) test1.blob
set file(namea1) /test0.blob
set file(namea7) /test6.blob
set file(namea9) test10.blob
+set tname(twhitespace) "test100 whith whitespace"
set tname(tstring) test100
set tname(tint) 100
--- /dev/null
+set tname(tnewstr) "tnewvalue"
--- /dev/null
+set tname(tstring) "tnewvalue"
--- /dev/null
+set tname(tnewstr) "toldvaluex"
+set tname(tnewstr) "tnewvalue"
--- /dev/null
+set tname(tnewstr) "test new value"
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <allParam.h>
#include "s_array.h"
-int s_array(const char *testid, const Param *param) {
+int s_array(const char *testid) {
+ Param *param;
char *name = "tname";
char *idx = "tstringa";
char result[PARAM_MAX_VALUE_LEN];
printf("%s : Param_getString: Request for Array value.\n", testid);
#endif
+ param = malloc(sizeof(Param));
+ conParam(param);
+
retVal = Param_getString(param, name, idx, &rows, result);
if ((rows == 1) &&
result && (strcmp(result, "test1") == 0) &&
#endif
myRetVal = -1;
}
+
+ desParam(param);
+ free(param);
+
return myRetVal;
}
#ifndef S_ARRAY_H
#define S_ARRAY_H
-#include <allParam.h>
-
-int s_array(const char *, const Param *);
+int s_array(const char *);
#endif
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <allParam.h>
#include "s_int_available.h"
-int s_int_available(const char *testid, const Param *param) {
+int s_int_available(const char *testid) {
+ Param *param;
char *name = "tname";
char *idx = "tint";
char result[PARAM_MAX_VALUE_LEN];
printf("%s : Param_getString: String is wanted but int-like value found.\n", testid);
#endif
+ param = malloc(sizeof(Param));
+ conParam(param);
+
retVal = Param_getString(param, name, idx, &rows, result);
if ((rows == 1) && result && (strcmp(result, "100") == 0) && (retVal == 0)) {
myRetVal = 0;
#endif
myRetVal = -1;
}
+
+ desParam(param);
+ free(param);
+
return myRetVal;
}
#ifndef S_INT_AVAILABLE_H
#define S_INT_AVAILABLE_H
-#include <allParam.h>
-
-int s_int_available(const char *, const Param *);
+int s_int_available(const char *);
#endif
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <allParam.h>
#include "s_lowercase.h"
-int s_lowercase(const char *testid, const Param *param) {
+int s_lowercase(const char *testid) {
+ Param *param;
char *name = "tname";
char *idx = "tstring";
char result[PARAM_MAX_VALUE_LEN];
printf("%s : Param_getString: Lowercase input on correct statements.\n", testid);
#endif
+ param = malloc(sizeof(Param));
+ conParam(param);
+
retVal = Param_getString(param, name, idx, &rows, result);
if ((rows == 1) && result && (strcmp(result, "test100") == 0) && (retVal == 0)) {
myRetVal = 0;
printf("%s : Failed.\n", testid);
#endif
}
+
+ desParam(param);
+ free(param);
+
return myRetVal;
}
#ifndef S_LOWERCASE_H
#define S_LOWERCASE_H
-#include <allParam.h>
-
-int s_lowercase(const char *, const Param *);
+int s_lowercase(const char *);
#endif
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <allParam.h>
#include "s_no_index.h"
-int s_no_index(const char *testid, const Param *param) {
+int s_no_index(const char *testid) {
+ Param *param;
char *name = "tname";
char *idx = "bla";
char result[PARAM_MAX_VALUE_LEN];
printf("%s : Param_getString: Non-existing idx.\n", testid);
#endif
+ param = malloc(sizeof(Param));
+ conParam(param);
+
retVal = Param_getString(param, name, idx, &rows, result);
if ((rows == 0) && (retVal == 0)) {
myRetVal = 0;
#endif
myRetVal = -1;
}
+
+ desParam(param);
+ free(param);
+
return myRetVal;
}
#ifndef S_NO_INDEX_H
#define S_NO_INDEX_H
-#include <allParam.h>
-
-int s_no_index(const char *, const Param *);
+int s_no_index(const char *);
#endif
--- /dev/null
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <allParam.h>
+
+#include "s_store.h"
+
+int s_store(const char *testid) {
+ Param *param;
+ const char *name = "tname";
+ const char *idx = "tnewstr";
+ const char *tostore = "tnewvalue";
+ char result[PARAM_MAX_VALUE_LEN];
+ int rows;
+ int retVal1;
+ int retVal2;
+ int myRetVal;
+
+#ifdef VERBOSE
+ printf("%s : Param_storeString: Simple.\n", testid);
+#endif
+
+ truncate("storage.tcl", 0);
+
+ param = malloc(sizeof(Param));
+ conParam(param);
+
+ retVal1 = Param_storeString(param, name, idx, tostore);
+ retVal2 = Param_getString(param, name, idx, &rows, result);
+
+ desParam(param);
+ free(param);
+
+ if ((rows == 1) && result && (strcmp(result, tostore) == 0) && (retVal1 == 0) && (retVal2 == 0)) {
+ if(system("diff storage.tcl s_store.tcl")) {
+#ifdef VERBOSE
+ printf("%s : Failed: Files \"storage.tcl\" and \"s_store.tcl\" differ.\n", testid);
+ printf("%s : Error string: %s\n", testid, Param_getErrStr(param));
+ myRetVal = -1;
+#else
+ printf("%s : Failed.\n", testid);
+#endif
+ } else {
+ myRetVal = 0;
+ printf("%s : Passed.\n", testid);
+ }
+ } else {
+#ifdef VERBOSE
+ printf("%s : Failed. Rows: %d, result: \'%s\'\nreturn Value of store call: %d\nreturn Value of get call: %d.\n", testid, rows, result, retVal1, retVal2);
+ printf("%s : Error string: %s\n", testid, Param_getErrStr(param));
+ myRetVal = -1;
+#else
+ printf("%s : Failed.\n", testid);
+#endif
+ }
+
+ return myRetVal;
+}
+
--- /dev/null
+#ifndef S_STORE_H
+#define S_STORE_H
+
+int s_store(const char *);
+
+#endif
--- /dev/null
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <allParam.h>
+
+#include "s_store_existing.h"
+
+int s_store_existing(const char *testid) {
+ Param *param;
+ const char *name = "tname";
+ const char *idx = "tstring";
+ const char *tostore = "tnewvalue";
+ char result[PARAM_MAX_VALUE_LEN];
+ int rows;
+ int retVal1;
+ int retVal2;
+ int myRetVal;
+
+#ifdef VERBOSE
+ printf("%s : Param_storeString: Store a Parameter already existing in the source.\n", testid);
+#endif
+
+ truncate("storage.tcl", 0);
+
+ param = malloc(sizeof(Param));
+ conParam(param);
+
+ retVal1 = Param_storeString(param, name, idx, tostore);
+ retVal2 = Param_getString(param, name, idx, &rows, result);
+
+ desParam(param);
+ free(param);
+
+ if ((rows == 1) && result && (strcmp(result, tostore) == 0) && (retVal1 == 0) && (retVal2 == 0)) {
+ if(system("diff storage.tcl s_store_existing.tcl")) {
+#ifdef VERBOSE
+ printf("%s : Failed: Files \"storage.tcl\" and \"s_store_existing.tcl\" differ.\n", testid);
+ printf("%s : Error string: %s\n", testid, Param_getErrStr(param));
+ myRetVal = -1;
+#else
+ printf("%s : Failed.\n", testid);
+#endif
+ } else {
+ myRetVal = 0;
+ printf("%s : Passed.\n", testid);
+ }
+ } else {
+#ifdef VERBOSE
+ printf("%s : Failed. Rows: %d, result: \'%s\'\nreturn Value of store call: %d\nreturn Value of get call: %d.\n", testid, rows, result, retVal1, retVal2);
+ printf("%s : Error string: %s\n", testid, Param_getErrStr(param));
+ myRetVal = -1;
+#else
+ printf("%s : Failed.\n", testid);
+#endif
+ }
+
+ return myRetVal;
+}
+
--- /dev/null
+#ifndef S_STORE_H
+#define S_STORE_H
+
+int s_store_existing(const char *);
+
+#endif
--- /dev/null
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <allParam.h>
+
+#include "s_store_multiple.h"
+
+int s_store_multiple(const char *testid) {
+ Param *param;
+ const char *name = "tname";
+ const char *idx = "tnewstr";
+ const char *old = "toldvaluex";
+ const char *new = "tnewvalue";
+ char result[PARAM_MAX_VALUE_LEN];
+ int rows;
+ int retVal1;
+ int retVal2;
+ int retVal3;
+ int myRetVal;
+
+#ifdef VERBOSE
+ printf("%s : Param_storeString: Storing a value multiple.\n", testid);
+#endif
+
+ truncate("storage.tcl", 0);
+
+ param = malloc(sizeof(Param));
+ conParam(param);
+
+ retVal1 = Param_storeString(param, name, idx, old);
+ retVal2 = Param_storeString(param, name, idx, new);
+ retVal3 = Param_getString(param, name, idx, &rows, result);
+
+ desParam(param);
+ free(param);
+
+ if ((rows == 1) && result && (strcmp(result, new) == 0) && (retVal1 == 0) && (retVal2 == 0) && (retVal3 == 0)) {
+ if(system("diff storage.tcl s_store_multiple.tcl")) {
+#ifdef VERBOSE
+ printf("%s : Failed: Files \"storage.tcl\" and \"s_store_multiple.tcl\" differ.\n", testid);
+ printf("%s : Error string: %s\n", testid, Param_getErrStr(param));
+ myRetVal = -1;
+#else
+ printf("%s : Failed.\n", testid);
+#endif
+ } else {
+ myRetVal = 0;
+ printf("%s : Passed.\n", testid);
+ }
+ } else {
+#ifdef VERBOSE
+ printf("%s : Failed. Rows: %d, result: \'%s\'\nreturn Value of first store call: %d\nreturn Value of second store call: %d\nreturn Value of get call: %d.\n", testid, rows, result, retVal1, retVal2, retVal3);
+ printf("%s : Error string: %s\n", testid, Param_getErrStr(param));
+ myRetVal = -1;
+#else
+ printf("%s : Failed.\n", testid);
+#endif
+ }
+
+ return myRetVal;
+}
+
--- /dev/null
+#ifndef S_STORE_MULTIPLE_H
+#define S_STORE_MULTIPLE_H
+
+int s_store_multiple(const char *);
+
+#endif
--- /dev/null
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <allParam.h>
+
+#include "s_store_whitespace.h"
+
+int s_store_whitespace(const char *testid) {
+ Param *param;
+ const char *name = "tname";
+ const char *idx = "tnewstr";
+ const char *tostore = "test new value";
+ char result[PARAM_MAX_VALUE_LEN];
+ int rows;
+ int retVal1;
+ int retVal2;
+ int myRetVal;
+
+#ifdef VERBOSE
+ printf("%s : Param_storeString: Store a string containing a whitespace.\n", testid);
+#endif
+
+ truncate("storage.tcl", 0);
+
+ param = malloc(sizeof(Param));
+ conParam(param);
+
+ retVal1 = Param_storeString(param, name, idx, tostore);
+ retVal2 = Param_getString(param, name, idx, &rows, result);
+
+ desParam(param);
+ free(param);
+
+ if ((rows == 1) && result && (strcmp(result, tostore) == 0) && (retVal1 == 0) && (retVal2 == 0)) {
+ if(system("diff storage.tcl s_store_whitespace.tcl")) {
+#ifdef VERBOSE
+ printf("%s : Failed: Files \"storage.tcl\" and \"s_store_whitespace.tcl\" differ.\n", testid);
+ printf("%s : Error string: %s\n", testid, Param_getErrStr(param));
+ myRetVal = -1;
+#else
+ printf("%s : Failed.\n", testid);
+#endif
+ } else {
+ myRetVal = 0;
+ printf("%s : Passed.\n", testid);
+ }
+ } else {
+#ifdef VERBOSE
+ printf("%s : Failed. Rows: %d, result: \'%s\', return Value of store call: %d, return Value of get call: %d.\n", testid, rows, result, retVal1, retVal2);
+ printf("%s : Error string: %s\n", testid, Param_getErrStr(param));
+ myRetVal = -1;
+#else
+ printf("%s : Failed.\n", testid);
+#endif
+ }
+
+ return myRetVal;
+}
+
--- /dev/null
+#ifndef S_STORE_WHITESPACE_H
+#define S_STORE_WHITESPACE_H
+
+int s_store_whitespace(const char *);
+
+#endif
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <allParam.h>
#include "s_uppercase.h"
-int s_uppercase(const char *testid, const Param *param) {
+int s_uppercase(const char *testid) {
+ Param *param;
char *name = "TNAME";
char *idx = "TSTRING";
char result[PARAM_MAX_VALUE_LEN];
printf("%s : Param_getString: Uppercase input on correct statements.\n", testid);
#endif
+ param = malloc(sizeof(Param));
+ conParam(param);
+
retVal = Param_getString(param, name, idx, &rows, result);
if ((rows == 1) && result && (strcmp(result, "test100") == 0) && (retVal == 0)) {
myRetVal = 0;
#endif
myRetVal = -1;
}
+
+ desParam(param);
+ free(param);
+
return myRetVal;
}
#ifndef S_UPPERCASE_H
#define S_UPPERCASE_H
-#include <allParam.h>
-
-int s_uppercase(const char *, const Param *);
+int s_uppercase(const char *);
#endif
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <allParam.h>
+
+#include "s_whitespace.h"
+
+int s_whitespace(const char *testid) {
+ Param *param;
+ char *name = "tname";
+ char *idx = "twhitespace";
+ char result[PARAM_MAX_VALUE_LEN];
+ int rows;
+ int retVal;
+ int myRetVal;
+
+#ifdef VERBOSE
+ printf("%s : Param_getString: Lowercase input on correct statements.\n", testid);
+#endif
+
+ param = malloc(sizeof(Param));
+ conParam(param);
+
+ retVal = Param_getString(param, name, idx, &rows, result);
+ if ((rows == 1) && result && (strcmp(result, "test100 whith whitespace") == 0) && (retVal == 0)) {
+ myRetVal = 0;
+ printf("%s : Passed.\n", testid);
+ } else {
+#ifdef VERBOSE
+ 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;
+#else
+ printf("%s : Failed.\n", testid);
+#endif
+ }
+
+ desParam(param);
+ free(param);
+
+ return myRetVal;
+}
+
--- /dev/null
+#ifndef S_WHITESPACE_H
+#define S_WHITESPACE_H
+
+int s_whitespace(const char *);
+
+#endif
#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
+#include <string.h>
#include <allParam.h>
#include "sa_int_available.h"
-int sa_int_available(const char *testid, const Param *param) {
+#define NUM2 32
+
+int sa_int_available(const char *testid) {
+ Param *param;
char *name = "tname";
char *idx = "tinta";
char *result[NUM2];
int myRetVal;
int i;
- for (i = 0 ; i < NUM2 ; i++) {
- result[i] = malloc(PARAM_MAX_VALUE_LEN * sizeof(char));
- }
#ifdef VERBOSE
printf("%s : Param_getStringArray: String is wanted but Int-like values found.\n", testid);
#endif
+ param = malloc(sizeof(Param));
+ conParam(param);
+
+ for (i = 0 ; i < NUM2 ; i++) {
+ result[i] = malloc(PARAM_MAX_VALUE_LEN * sizeof(char));
+ }
+
retVal = Param_getStringArray(param, name, idx, NUM2, &rows, result);
if ((rows == NUM2) &&
result[0] && (strcmp(result[0], "1") == 0) &&
for (i = 0 ; i < NUM2 ; i++) {
free(result[i]);
}
+
+ desParam(param);
+ free(param);
+
return myRetVal;
}
#ifndef SA_INT_AVAILABLE_H
#define SA_INT_AVAILABLE_H
-#include <allParam.h>
-
-#define NUM2 32
-
-int sa_int_available(const char *, const Param *);
+int sa_int_available(const char *);
#endif
#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
+#include <string.h>
#include <allParam.h>
#include "sa_long_array.h"
-int sa_long_array(const char *testid, const Param *param) {
+#define NUM1 8
+#define NUM5 4
+
+int sa_long_array(const char *testid) {
+ Param *param;
char *name = "tname";
char *idx = "tstringa";
char *result[NUM5];
int myRetVal;
int i;
- for (i = 0 ; i < NUM5 ; i++) {
- result[i] = malloc(PARAM_MAX_VALUE_LEN * sizeof(char));
- }
#ifdef VERBOSE
printf("%s : Param_getStringArray: To many array members available.\n", testid);
#endif
+ param = malloc(sizeof(Param));
+ conParam(param);
+
+ for (i = 0 ; i < NUM5 ; i++) {
+ result[i] = malloc(PARAM_MAX_VALUE_LEN * sizeof(char));
+ }
+
retVal = Param_getStringArray(param, name, idx, NUM5, &rows, result);
if ((rows == NUM5) &&
result[0] && (strcmp(result[0], "test1") == 0) &&
for (i = 0 ; i < NUM5 ; i++) {
free(result[i]);
}
+
+ desParam(param);
+ free(param);
+
return myRetVal;
}
#ifndef SA_LONG_ARRAY_H
#define SA_LONG_ARRAY_H
-#include <allParam.h>
-
-#define NUM1 8
-#define NUM5 4
-
-int sa_long_array(const char *, const Param *);
+int sa_long_array(const char *);
#endif
#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
+#include <string.h>
#include <allParam.h>
#include "sa_lowercase.h"
-int sa_lowercase(const char *testid, const Param *param) {
+#define NUM1 8
+
+int sa_lowercase(const char *testid) {
+ Param *param;
char *name = "tname";
char *idx = "tstringa";
char *result[NUM1];
int myRetVal;
int i;
- for (i = 0 ; i < NUM1 ; i++) {
- result[i] = malloc(PARAM_MAX_VALUE_LEN * sizeof(char));
- }
#ifdef VERBOSE
printf("%s : Param_getStringArray: Lowercase input on correct statements.\n", testid);
#endif
+ param = malloc(sizeof(Param));
+ conParam(param);
+
+ for (i = 0 ; i < NUM1 ; i++) {
+ result[i] = malloc(PARAM_MAX_VALUE_LEN * sizeof(char));
+ }
+
retVal = Param_getStringArray(param, name, idx, NUM1, &rows, result);
if ((rows == NUM1) &&
result[0] && (strcmp(result[0], "test1") == 0) &&
#endif
myRetVal = -1;
}
+
for (i = 0 ; i < NUM1 ; i++) {
free(result[i]);
}
+
+ desParam(param);
+ free(param);
+
return myRetVal;
}
#ifndef SA_LOWERCASE_H
#define SA_LOWERCASE_H
-#include <allParam.h>
-
-#define NUM1 8
-
-int sa_lowercase(const char *, const Param *);
+int sa_lowercase(const char *);
#endif
#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
+#include <string.h>
#include <allParam.h>
#include "sa_no_index.h"
-int sa_no_index(const char *testid, const Param *param) {
+#define NUM1 8
+
+int sa_no_index(const char *testid) {
+ Param *param;
char *name = "tname";
char *idx = "bla";
char *result[NUM1];
int myRetVal;
int i;
- for (i = 0 ; i < NUM1 ; i++) {
- result[i] = malloc(PARAM_MAX_VALUE_LEN * sizeof(char));
- }
#ifdef VERBOSE
printf("%s : Param_getStringArray: Non-existing idx.\n", testid);
#endif
+ param = malloc(sizeof(Param));
+ conParam(param);
+
+ for (i = 0 ; i < NUM1 ; i++) {
+ result[i] = malloc(PARAM_MAX_VALUE_LEN * sizeof(char));
+ }
+
retVal = Param_getStringArray(param, name, idx, NUM1, &rows, result);
if ((rows == 0) && (retVal == 0)) {
myRetVal = 0;
#endif
myRetVal = -1;
}
+
for (i = 0 ; i < NUM1 ; i++) {
free(result[i]);
}
+
+ desParam(param);
+ free(param);
+
return myRetVal;
}
#ifndef SA_NO_INDEX_H
#define SA_NO_INDEX_H
-#include <allParam.h>
-
-#define NUM1 8
-
-int sa_no_index(const char *, const Param *);
+int sa_no_index(const char *);
#endif
#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
+#include <string.h>
#include <allParam.h>
#include "sa_scalar.h"
-int sa_scalar(const char *testid, const Param *param) {
+#define NUM1 8
+
+int sa_scalar(const char *testid) {
+ Param *param;
char *name = "tname";
char *idx = "tstring";
char *result[NUM1];
int retVal;
int myRetVal;
- for (i = 0 ; i < NUM1 ; i++) {
- result[i] = malloc(PARAM_MAX_VALUE_LEN * sizeof(char));
- }
#ifdef VERBOSE
printf("%s : Param_getStringArray: Request for a scalar value.\n", testid);
#endif
+ param = malloc(sizeof(Param));
+ conParam(param);
+
+ for (i = 0 ; i < NUM1 ; i++) {
+ result[i] = malloc(PARAM_MAX_VALUE_LEN * sizeof(char));
+ }
+
retVal = Param_getStringArray(param, name, idx, NUM1, &rows, result);
if ((rows == 1) && result && (strcmp(result[0], "test100") == 0) && (retVal == 0)) {
myRetVal = 0;
#endif
myRetVal = -1;
}
+
for (i = 0 ; i < NUM1 ; i++) {
free(result[i]);
}
+
+ desParam(param);
+ free(param);
+
return myRetVal;
}
#ifndef SA_SCALAR_H
#define SA_SCALAR_H
-#include <allParam.h>
-
-#define NUM1 8
-
-int sa_scalar(const char *, const Param *);
+int sa_scalar(const char *);
#endif
#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
+#include <string.h>
#include <allParam.h>
#include "sa_short_array.h"
-int sa_short_array(const char *testid, const Param *param) {
+#define NUM1 8
+#define NUM3 16
+
+int sa_short_array(const char *testid) {
+ Param *param;
char *name = "tname";
char *idx = "tstringa";
char *result[NUM3];
int myRetVal;
int i;
- for (i = 0 ; i < NUM3 ; i++) {
- result[i] = malloc(PARAM_MAX_VALUE_LEN * sizeof(char));
- }
#ifdef VERBOSE
printf("%s : Param_getStringArray: To few array members available.\n", testid);
#endif
+ param = malloc(sizeof(Param));
+ conParam(param);
+
+ for (i = 0 ; i < NUM3 ; i++) {
+ result[i] = malloc(PARAM_MAX_VALUE_LEN * sizeof(char));
+ }
+
retVal = Param_getStringArray(param, name, idx, NUM3, &rows, result);
if ((rows == NUM1) &&
result[0] && (strcmp(result[0], "test1") == 0) &&
#endif
myRetVal = -1;
}
+
for (i = 0 ; i < NUM3 ; i++) {
free(result[i]);
}
+
+ desParam(param);
+ free(param);
+
return myRetVal;
}
#ifndef SA_SHORT_ARRAY_H
#define SA_SHORT_ARRAY_H
-#include <allParam.h>
-
-#define NUM1 8
-#define NUM3 16
-
-int sa_short_array(const char *, const Param *);
+int sa_short_array(const char *);
#endif
#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
+#include <string.h>
#include <allParam.h>
#include "sa_uppercase.h"
-int sa_uppercase(const char *testid, const Param *param) {
+#define NUM1 8
+
+int sa_uppercase(const char *testid) {
+ Param *param;
char *name = "TNAME";
char *idx = "TSTRINGA";
char *result[NUM1];
int myRetVal;
int i;
- for (i = 0 ; i < NUM1 ; i++) {
- result[i] = malloc(PARAM_MAX_VALUE_LEN * sizeof(char));
- }
#ifdef VERBOSE
printf("%s : Param_getStringArray: Uppercase input on correct statements.\n", testid);
#endif
+ param = malloc(sizeof(Param));
+ conParam(param);
+
+ for (i = 0 ; i < NUM1 ; i++) {
+ result[i] = malloc(PARAM_MAX_VALUE_LEN * sizeof(char));
+ }
+
retVal = Param_getStringArray(param, name, idx, NUM1, &rows, result);
if ((rows == NUM1) &&
result[0] && (strcmp(result[0], "test1") == 0) &&
#endif
myRetVal = -1;
}
+
for (i = 0 ; i < NUM1 ; i++) {
free(result[i]);
}
+
+ desParam(param);
+ free(param);
+
return myRetVal;
}
#ifndef SA_UPPERCASE_H
#define SA_UPPERCASE_H
-#include <allParam.h>
-
-#define NUM1 8
-
-int sa_uppercase(const char *, const Param *);
+int sa_uppercase(const char *);
#endif
-set file(rname) test.blob
-set file(aname) /test.blob
+set file(rname) test0.blob
+set file(aname) /test0.blob
+set file(rnamellarge) test1.blob
+set file(rnameodd) test2.blob
set file(namea0) test1.blob
set file(namea1) /test0.blob