Made a quick fix to server/core/test/testhash.c. In makefile there is one call for multiple tests and so it makes sense to check return value of the test program.

This commit is contained in:
VilhoRaatikka 2014-02-11 14:57:27 +02:00
parent e57944ef44
commit 83bdc15b54
2 changed files with 43 additions and 47 deletions

View File

@ -23,22 +23,18 @@ buildtests :
$(CC) $(CFLAGS) \
-I$(ROOT_PATH)/server/include \
-I$(ROOT_PATH)/utils \
testhash.c ../hashtable.o ../atomic.o ../spinlock.o -o testhash \
testhash.c ../hashtable.o ../atomic.o ../spinlock.o -o testhash
runtests:
runtests:
@echo "" >> $(TESTLOG)
@echo "-------------------------------" >> $(TESTLOG)
@echo $(shell date) >> $(TESTLOG)
@echo "Test MaxScale core" >> $(TESTLOG)
@echo "-------------------------------" >> $(TESTLOG)
@./testhash 0 1 2>> $(TESTLOG)
@./testhash 10 1 2>> $(TESTLOG)
@./testhash 1000 10 2>> $(TESTLOG)
@./testhash 10 0 2>> $(TESTLOG)
@./testhash 1500 17 2>> $(TESTLOG)
@./testhash 1 1 2>> $(TESTLOG)
@./testhash 10000 133 2>> $(TESTLOG)
@./testhash 1000 1000 2>> $(TESTLOG)
@./testhash 1000 100000 2>> $(TESTLOG)
@-./testhash 2>> $(TESTLOG)
ifeq ($?, 0)
@echo "MaxScale core PASSED" >> $(TESTLOG)
else
@echo "MaxScale core FAILED" >> $(TESTLOG)
endif
@echo "" >> $(TESTLOG)

View File

@ -28,46 +28,18 @@ static int cmpfun(
}
/**
* @node Simple test which creates hashtable and frees it. Size and number of entries
* sre specified by user and passed as arguments.
*
* Parameters:
* @param argc - <usage>
* <description>
*
* @param argv - <usage>
* <description>
*
* @return
*
*
* @details (write detailed description here)
*
*/
int main(int argc, char** argv)
static bool do_hashtest(
int argelems,
int argsize)
{
bool succp = true;
HASHTABLE* h;
int nelems;
int i;
int* val_arr;
int argsize;
int hsize;
int argelems;
int longest;
if (argc != 3) {
fprintf(stderr, "\nWrong number of arguments. Usage "
":\n\n\ttesthash <# of elements> <# hash size> "
"<hash function> <compare function>\n\n");
return 1;
}
argelems = strtol(argv[1], NULL, 10);
argsize = strtol(argv[2], NULL, 10);
ss_dfprintf(stderr,
"testhash : creating hash table of size %d, including %d "
"elements in total.",
@ -100,9 +72,37 @@ int main(int argc, char** argv)
CHK_HASHTABLE(h);
hashtable_free(h);
return 0;
return_succp:
return succp;
}
/**
* @node Simple test which creates hashtable and frees it. Size and number of entries
* sre specified by user and passed as arguments.
*
*
* @return 0 if succeed, 1 if failed.
*
*
* @details (write detailed description here)
*
*/
int main(void)
{
int rc = 1;
if (!do_hashtest(0, 1)) goto return_rc;
if (!do_hashtest(10, 1)) goto return_rc;
if (!do_hashtest(1000, 10)) goto return_rc;
if (!do_hashtest(10, 0)) goto return_rc;
if (!do_hashtest(1500, 17)) goto return_rc;
if (!do_hashtest(1, 1)) goto return_rc;
if (!do_hashtest(10000, 133)) goto return_rc;
if (!do_hashtest(1000, 1000)) goto return_rc;
if (!do_hashtest(1000, 100000)) goto return_rc;
rc = 0;
return_rc:
return rc;
}