summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/Makefile.in4
-rw-r--r--src/test/test_libconfig.c63
-rw-r--r--src/test/test_spinlock.c14
3 files changed, 61 insertions, 20 deletions
diff --git a/src/test/Makefile.in b/src/test/Makefile.in
index c8006e5cf..3e7549943 100644
--- a/src/test/Makefile.in
+++ b/src/test/Makefile.in
@@ -87,8 +87,8 @@ $(TESTS_ALL): test_%: ../../test_%@EXEEXT@
../../test_%@EXEEXT@: obj/test_%.o $(TEST_DEPENDS) Makefile
@echo " LD $(notdir $@)"
- @$(CC) @STATIC@ @LDFLAGS@ -o $@ $< $(COMMON_D)/obj_sql/common_sql.a \
- $(COMMON_D)/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@
+ @$(CC) @STATIC@ @LDFLAGS@ -o $@ $< $(COMMON_D)/obj_all/common.a $(COMMON_D)/obj_sql/common_sql.a \
+ $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@
# object files
diff --git a/src/test/test_libconfig.c b/src/test/test_libconfig.c
index e0a470e21..e1a767195 100644
--- a/src/test/test_libconfig.c
+++ b/src/test/test_libconfig.c
@@ -86,6 +86,8 @@ static const char *test_libconfig_init_destroy(void)
static const char *test_libconfig_read_file_src(void)
{
struct config_t config;
+ libconfig->init(&config);
+
#define FILENAME "src/test/libconfig/test.conf"
if (libconfig->read_file_src(&config, FILENAME) == CONFIG_FALSE) {
libconfig->destroy(&config);
@@ -108,6 +110,9 @@ static const char *test_libconfig_read(void)
if (!fp) {
return "File not found: '" FILENAME "'.";
}
+
+ libconfig->init(&config);
+
if (libconfig->read(&config, fp) == CONFIG_FALSE) {
fclose(fp);
libconfig->destroy(&config);
@@ -154,6 +159,8 @@ static const char *test_libconfig_write_file(void)
static const char *test_libconfig_read_string(void)
{
struct config_t config;
+ libconfig->init(&config);
+
if (libconfig->read_string(&config, "") == CONFIG_FALSE) {
libconfig->destroy(&config);
return "Unable to read from string.";
@@ -180,6 +187,8 @@ static const char *test_libconfig_syntax(void)
"Setting_List: ( );\n"
"/* End test file */\n";
+ libconfig->init(&config);
+
if (libconfig->read_string(&config, input) == CONFIG_FALSE) {
libconfig->destroy(&config);
return "Unable to read from string.";
@@ -216,6 +225,8 @@ static const char *test_libconfig_lookup(void)
"Setting_List: ( );\n"
"/* End test file */\n";
+ libconfig->init(&config);
+
if (libconfig->read_string(&config, input) == CONFIG_FALSE) {
libconfig->destroy(&config);
return "Unable to parse configuration.";
@@ -278,6 +289,8 @@ static const char *test_libconfig_setting_get(void)
"Setting_List: ( );\n"
"/* End test file */\n";
+ libconfig->init(&config);
+
if (libconfig->read_string(&config, input) == CONFIG_FALSE) {
libconfig->destroy(&config);
return "Unable to parse configuration.";
@@ -366,8 +379,8 @@ static const char *test_libconfig_setting_get(void)
static const char *test_libconfig_set(void)
{
- //int (*setting_set_int) (struct config_setting_t *setting ,int value);
- //int (*setting_set_int64) (struct config_setting_t *setting, long long value);
+ //int (*setting_set_int) (struct config_setting_t *setting, int value);
+ //int (*setting_set_int64) (struct config_setting_t *setting, int64 value);
//int (*setting_set_float) (struct config_setting_t *setting, double value);
//int (*setting_set_bool) (struct config_setting_t *setting, int value);
//int (*setting_set_string) (struct config_setting_t *setting, const char *value);
@@ -392,6 +405,8 @@ static const char *test_libconfig_setting_lookup(void)
"Setting_List: ( );\n"
"/* End test file */\n";
+ libconfig->init(&config);
+
if (libconfig->read_string(&config, input) == CONFIG_FALSE) {
libconfig->destroy(&config);
return "Unable to parse configuration.";
@@ -442,6 +457,8 @@ static const char *test_libconfig_setting_types(void)
"Setting_List: ( );\n"
"/* End test file */\n";
+ libconfig->init(&config);
+
if (libconfig->read_string(&config, input) == CONFIG_FALSE) {
libconfig->destroy(&config);
return "Unable to parse configuration.";
@@ -536,6 +553,8 @@ static const char *test_libconfig_values(void)
"Setting_IntSignedMax: 0x7fffffff;\n"
"/* End test file */\n";
+ libconfig->init(&config);
+
if (libconfig->read_string(&config, input) == CONFIG_FALSE) {
libconfig->destroy(&config);
return "Unable to parse configuration.";
@@ -599,6 +618,9 @@ static const char *test_libconfig_path_lookup(void)
" 10,\n"
");\n"
"/* End test file */\n";
+
+ libconfig->init(&config);
+
if (libconfig->read_string(&config, input) == CONFIG_FALSE) {
libconfig->destroy(&config);
return "Unable to parse configuration.";
@@ -669,28 +691,34 @@ static const char *test_libconfig_setting_names(void)
struct config_t config;
int32 i32;
const char *input = "/* Test File */\n"
- "Setting'with'apostrophes: 1;\n"
+ "1st_setting_with_numbers: 1;\n"
"Setting.with.periods: 2;\n"
"Setting: {\n"
" with: {\n"
" periods: 3;\n"
+ " 2nested: {\n"
+ " numbers1: 4;\n"
+ " };\n"
" };\n"
" nested: {\n"
" in: {\n"
- " groups: 4;\n"
+ " groups: 5;\n"
" };\n"
" };\n"
"};\n"
- "1st_setting_with_numbers: 5;\n"
+ "Setting_with_2_numbers_000: 6;\n"
"/* End test file */\n";
+
+ libconfig->init(&config);
+
if (libconfig->read_string(&config, input) == CONFIG_FALSE) {
libconfig->destroy(&config);
return "Unable to parse configuration.";
}
- if (libconfig->lookup_int(&config, "Setting'with'apostrophes", &i32) == CONFIG_FALSE || i32 != 1) {
+ if (libconfig->lookup_int(&config, "1st_setting_with_numbers", &i32) == CONFIG_FALSE || i32 != 1) {
libconfig->destroy(&config);
- return "Setting'with'apostrophes failed.";
+ return "1st_setting_with_numbers failed.";
}
if (libconfig->lookup_int(&config, "Setting.with.periods", &i32) == CONFIG_FALSE || i32 != 2) {
@@ -703,19 +731,24 @@ static const char *test_libconfig_setting_names(void)
return "Setting:with:periods failed.";
}
- if (libconfig->lookup_int(&config, "Setting:nested:in:groups", &i32) == CONFIG_FALSE || i32 != 4) {
+ if (libconfig->lookup_int(&config, "Setting/with/2nested/numbers1", &i32) == CONFIG_FALSE || i32 != 4) {
+ libconfig->destroy(&config);
+ return "Setting/with/2nested/numbers1 failed.";
+ }
+
+ if (libconfig->lookup_int(&config, "Setting:nested:in:groups", &i32) == CONFIG_FALSE || i32 != 5) {
libconfig->destroy(&config);
return "Setting:nested:in:groups failed.";
}
- if (libconfig->lookup_int(&config, "Setting/nested/in/groups", &i32) == CONFIG_FALSE || i32 != 4) {
+ if (libconfig->lookup_int(&config, "Setting/nested/in/groups", &i32) == CONFIG_FALSE || i32 != 5) {
libconfig->destroy(&config);
return "Setting/nested/in/groups failed.";
}
- if (libconfig->lookup_int(&config, "1st_setting_with_numbers", &i32) == CONFIG_FALSE || i32 != 5) {
+ if (libconfig->lookup_int(&config, "Setting_with_2_numbers_000", &i32) == CONFIG_FALSE || i32 != 6) {
libconfig->destroy(&config);
- return "1st_setting_with_numbers failed.";
+ return "Setting_with_2_numbers_000 failed.";
}
libconfig->destroy(&config);
@@ -736,6 +769,9 @@ static const char *test_libconfig_duplicate_keys(void)
" Duplicate: 4;\n"
"};\n"
"/* End test file */\n";
+
+ libconfig->init(&config);
+
if (libconfig->read_string(&config, input) == CONFIG_FALSE) {
libconfig->destroy(&config);
return "Unable to parse configuration.";
@@ -780,6 +816,9 @@ static const char *test_libconfig_special_string_syntax(void)
const char *input = "/* Test File */\n"
"SpecialString: <\"This is an \"Item_Script\" Special String\n\tWith a line-break inside.\">;\n"
"/* End test file */\n";
+
+ libconfig->init(&config);
+
if (libconfig->read_string(&config, input) == CONFIG_FALSE) {
libconfig->destroy(&config);
return "Unable to parse configuration.";
@@ -818,7 +857,7 @@ int do_init(int argc, char **argv)
//int (*setting_set_format) (struct config_setting_t *setting, short format);
//short (*setting_get_format) (const struct config_setting_t *setting);
//struct config_setting_t * (*setting_set_int_elem) (struct config_setting_t *setting, int idx, int value);
- //struct config_setting_t * (*setting_set_int64_elem) (struct config_setting_t *setting, int idx, long long value);
+ //struct config_setting_t * (*setting_set_int64_elem) (struct config_setting_t *setting, int idx, int64 value);
//struct config_setting_t * (*setting_set_float_elem) (struct config_setting_t *setting, int idx, double value);
//struct config_setting_t * (*setting_set_bool_elem) (struct config_setting_t *setting, int idx, int value);
//struct config_setting_t * (*setting_set_string_elem) (struct config_setting_t *setting, int idx, const char *value);
diff --git a/src/test/test_spinlock.c b/src/test/test_spinlock.c
index 34102a845..1c0390d66 100644
--- a/src/test/test_spinlock.c
+++ b/src/test/test_spinlock.c
@@ -2,7 +2,7 @@
* This file is part of Hercules.
* http://herc.ws - http://github.com/HerculesWS/Hercules
*
- * Copyright (C) 2012-2015 Hercules Dev Team
+ * Copyright (C) 2012-2016 Hercules Dev Team
* Copyright (C) Athena Dev Teams
*
* Hercules is free software: you can redistribute it and/or modify
@@ -81,6 +81,7 @@ int do_init(int argc, char **argv)
for(i =0; i < THRC; i++){
t[i] = thread->create_opt(worker, NULL, 1024*512, THREADPRIO_NORMAL);
}
+ (void)t;
while(1){
if(InterlockedCompareExchange(&done_threads, THRC, THRC) == THRC)
@@ -100,14 +101,13 @@ int do_init(int argc, char **argv)
}
- if(ok != LOOPS){
+ if (ok != LOOPS) {
ShowFatalError("Test failed.\n");
exit(1);
- }else{
- ShowStatus("Test passed.\n");
- exit(0);
}
- return 0;
+
+ core->runflag = CORE_ST_STOP;
+ return EXIT_SUCCESS;
}//end: do_init()
void do_abort(void) {
@@ -118,6 +118,8 @@ void set_server_type(void) {
}//end: set_server_type()
int do_final(void) {
+ ShowStatus("Test passed.\n");
+
return EXIT_SUCCESS;
}//end: do_final()