diff options
author | Artjoms Rimdjonoks <artjoms.rimdjonoks@zabbix.com> | 2022-10-26 16:03:59 +0300 |
---|---|---|
committer | Artjoms Rimdjonoks <artjoms.rimdjonoks@zabbix.com> | 2022-10-26 16:03:59 +0300 |
commit | 29c8a52027b3b7c62a27bd7e390de8a87666f525 (patch) | |
tree | 2c059d3591e9836eaba48d7247767e593504da8f /tests | |
parent | 68c1be585a21eb76f15c06d9016d48b23ef560e2 (diff) | |
parent | 0d0dfe1f9525776cda9c5bb3d6dbfc667b973ea3 (diff) |
.......... [DEV-2176] updated to latest master
Diffstat (limited to 'tests')
-rw-r--r-- | tests/conf_tests.m4 | 1 | ||||
-rw-r--r-- | tests/libs/Makefile.am | 1 | ||||
-rw-r--r-- | tests/libs/zbxalgo/Makefile.am | 1 | ||||
-rw-r--r-- | tests/libs/zbxcommon/Makefile.am | 1 | ||||
-rw-r--r-- | tests/libs/zbxconf/Makefile.am | 1 | ||||
-rw-r--r-- | tests/libs/zbxdbhigh/Makefile.am | 1 | ||||
-rwxr-xr-x | tests/libs/zbxeval/Makefile.am | 1 | ||||
-rwxr-xr-x | tests/libs/zbxserver/Makefile.am | 1 | ||||
-rw-r--r-- | tests/libs/zbxsysinfo/Makefile.am | 1 | ||||
-rw-r--r-- | tests/libs/zbxtime/Makefile.am | 44 | ||||
-rw-r--r-- | tests/libs/zbxtime/zbx_iso8601_utc.c | 54 | ||||
-rw-r--r-- | tests/libs/zbxtime/zbx_iso8601_utc.yaml | 222 | ||||
-rw-r--r-- | tests/zabbix_server/service/mock_service.c | 3 | ||||
-rw-r--r-- | tests/zbxmocktest.c | 4 |
14 files changed, 324 insertions, 12 deletions
diff --git a/tests/conf_tests.m4 b/tests/conf_tests.m4 index 74c219a4782..bc02e63b371 100644 --- a/tests/conf_tests.m4 +++ b/tests/conf_tests.m4 @@ -39,6 +39,7 @@ AC_DEFUN([CONF_TESTS], tests/libs/zbxsysinfo/Makefile tests/libs/zbxsysinfo/common/Makefile tests/libs/zbxtrends/Makefile + tests/libs/zbxtime/Makefile tests/zabbix_server/Makefile tests/zabbix_server/pinger/Makefile tests/zabbix_server/poller/Makefile diff --git a/tests/libs/Makefile.am b/tests/libs/Makefile.am index 3493efe46dc..9d14c351e9c 100644 --- a/tests/libs/Makefile.am +++ b/tests/libs/Makefile.am @@ -14,4 +14,5 @@ SUBDIRS = \ zbxregexp \ zbxserver \ zbxtrends \ + zbxtime \ zbxeval diff --git a/tests/libs/zbxalgo/Makefile.am b/tests/libs/zbxalgo/Makefile.am index 1dba4f3b856..23d5adffa0b 100644 --- a/tests/libs/zbxalgo/Makefile.am +++ b/tests/libs/zbxalgo/Makefile.am @@ -25,7 +25,6 @@ COMMON_LIB_FILES = \ $(top_srcdir)/src/zabbix_server/httppoller/libzbxhttppoller.a \ $(top_srcdir)/src/zabbix_server/escalator/libzbxescalator.a \ $(top_srcdir)/src/zabbix_server/proxypoller/libzbxproxypoller.a \ - $(top_srcdir)/src/zabbix_server/selfmon/libzbxselfmon.a \ $(top_srcdir)/src/zabbix_server/vmware/libzbxvmware.a \ $(top_srcdir)/src/zabbix_server/taskmanager/libzbxtaskmanager.a \ $(top_srcdir)/src/zabbix_server/ipmi/libipmi.a \ diff --git a/tests/libs/zbxcommon/Makefile.am b/tests/libs/zbxcommon/Makefile.am index b8f87fe8e6a..3957328946d 100644 --- a/tests/libs/zbxcommon/Makefile.am +++ b/tests/libs/zbxcommon/Makefile.am @@ -52,7 +52,6 @@ COMMON_LIB_FILES = \ $(top_srcdir)/src/zabbix_server/httppoller/libzbxhttppoller.a \ $(top_srcdir)/src/zabbix_server/escalator/libzbxescalator.a \ $(top_srcdir)/src/zabbix_server/proxypoller/libzbxproxypoller.a \ - $(top_srcdir)/src/zabbix_server/selfmon/libzbxselfmon.a \ $(top_srcdir)/src/zabbix_server/vmware/libzbxvmware.a \ $(top_srcdir)/src/zabbix_server/taskmanager/libzbxtaskmanager.a \ $(top_srcdir)/src/zabbix_server/ipmi/libipmi.a \ diff --git a/tests/libs/zbxconf/Makefile.am b/tests/libs/zbxconf/Makefile.am index ca13f36b06f..e2d0cf4c6bd 100644 --- a/tests/libs/zbxconf/Makefile.am +++ b/tests/libs/zbxconf/Makefile.am @@ -19,7 +19,6 @@ parse_cfg_file_LDADD = \ $(top_srcdir)/src/zabbix_server/httppoller/libzbxhttppoller.a \ $(top_srcdir)/src/zabbix_server/escalator/libzbxescalator.a \ $(top_srcdir)/src/zabbix_server/proxypoller/libzbxproxypoller.a \ - $(top_srcdir)/src/zabbix_server/selfmon/libzbxselfmon.a \ $(top_srcdir)/src/zabbix_server/vmware/libzbxvmware.a \ $(top_srcdir)/src/zabbix_server/taskmanager/libzbxtaskmanager.a \ $(top_srcdir)/src/zabbix_server/ipmi/libipmi.a \ diff --git a/tests/libs/zbxdbhigh/Makefile.am b/tests/libs/zbxdbhigh/Makefile.am index 06936c3a5cd..0ab3589a6f8 100644 --- a/tests/libs/zbxdbhigh/Makefile.am +++ b/tests/libs/zbxdbhigh/Makefile.am @@ -74,7 +74,6 @@ SERVER_COMMON_LIB = \ $(top_srcdir)/src/zabbix_server/httppoller/libzbxhttppoller.a \ $(top_srcdir)/src/zabbix_server/escalator/libzbxescalator.a \ $(top_srcdir)/src/zabbix_server/proxypoller/libzbxproxypoller.a \ - $(top_srcdir)/src/zabbix_server/selfmon/libzbxselfmon.a \ $(top_srcdir)/src/zabbix_server/vmware/libzbxvmware.a \ $(top_srcdir)/src/zabbix_server/taskmanager/libzbxtaskmanager.a \ $(top_srcdir)/src/zabbix_server/ipmi/libipmi.a \ diff --git a/tests/libs/zbxeval/Makefile.am b/tests/libs/zbxeval/Makefile.am index a5ea73ddb67..2292d2c1963 100755 --- a/tests/libs/zbxeval/Makefile.am +++ b/tests/libs/zbxeval/Makefile.am @@ -31,7 +31,6 @@ COMMON_LIB_FILES = \ $(top_srcdir)/src/zabbix_server/httppoller/libzbxhttppoller.a \ $(top_srcdir)/src/zabbix_server/escalator/libzbxescalator.a \ $(top_srcdir)/src/zabbix_server/proxypoller/libzbxproxypoller.a \ - $(top_srcdir)/src/zabbix_server/selfmon/libzbxselfmon.a \ $(top_srcdir)/src/zabbix_server/vmware/libzbxvmware.a \ $(top_srcdir)/src/zabbix_server/taskmanager/libzbxtaskmanager.a \ $(top_srcdir)/src/zabbix_server/ipmi/libipmi.a \ diff --git a/tests/libs/zbxserver/Makefile.am b/tests/libs/zbxserver/Makefile.am index 01a32437cd6..4ecef916cf6 100755 --- a/tests/libs/zbxserver/Makefile.am +++ b/tests/libs/zbxserver/Makefile.am @@ -28,7 +28,6 @@ COMMON_LIB_FILES = \ $(top_srcdir)/src/zabbix_server/httppoller/libzbxhttppoller.a \ $(top_srcdir)/src/zabbix_server/escalator/libzbxescalator.a \ $(top_srcdir)/src/zabbix_server/proxypoller/libzbxproxypoller.a \ - $(top_srcdir)/src/zabbix_server/selfmon/libzbxselfmon.a \ $(top_srcdir)/src/zabbix_server/vmware/libzbxvmware.a \ $(top_srcdir)/src/zabbix_server/taskmanager/libzbxtaskmanager.a \ $(top_srcdir)/src/zabbix_server/ipmi/libipmi.a \ diff --git a/tests/libs/zbxsysinfo/Makefile.am b/tests/libs/zbxsysinfo/Makefile.am index ed212762c5e..3107c5c9dc3 100644 --- a/tests/libs/zbxsysinfo/Makefile.am +++ b/tests/libs/zbxsysinfo/Makefile.am @@ -48,7 +48,6 @@ parse_item_key_LDADD = \ $(top_srcdir)/src/zabbix_server/httppoller/libzbxhttppoller.a \ $(top_srcdir)/src/zabbix_server/escalator/libzbxescalator.a \ $(top_srcdir)/src/zabbix_server/proxypoller/libzbxproxypoller.a \ - $(top_srcdir)/src/zabbix_server/selfmon/libzbxselfmon.a \ $(top_srcdir)/src/zabbix_server/vmware/libzbxvmware.a \ $(top_srcdir)/src/zabbix_server/taskmanager/libzbxtaskmanager.a \ $(top_srcdir)/src/zabbix_server/ipmi/libipmi.a \ diff --git a/tests/libs/zbxtime/Makefile.am b/tests/libs/zbxtime/Makefile.am new file mode 100644 index 00000000000..4cd52c8082b --- /dev/null +++ b/tests/libs/zbxtime/Makefile.am @@ -0,0 +1,44 @@ +if SERVER +SERVER_tests = \ + zbx_iso8601_utc +endif + +noinst_PROGRAMS = $(SERVER_tests) + +if SERVER +COMMON_SRC_FILES = \ + ../../zbxmocktest.h + +COMMON_LIB_FILES = \ + $(top_srcdir)/src/libs/zbxtime/libzbxtime.a \ + $(top_srcdir)/src/libs/zbxnix/libzbxnix.a \ + $(top_srcdir)/src/libs/zbxlog/libzbxlog.a \ + $(top_srcdir)/src/libs/zbxconf/libzbxconf.a \ + $(top_srcdir)/src/libs/zbxthreads/libzbxthreads.a \ + $(top_srcdir)/src/libs/zbxmutexs/libzbxmutexs.a \ + $(top_srcdir)/src/libs/zbxalgo/libzbxalgo.a \ + $(top_srcdir)/src/libs/zbxip/libzbxip.a \ + $(top_srcdir)/src/libs/zbxstr/libzbxstr.a \ + $(top_srcdir)/src/libs/zbxnum/libzbxnum.a \ + $(top_srcdir)/src/libs/zbxcommon/libzbxcommon.a \ + $(top_srcdir)/tests/libzbxmocktest.a \ + $(top_srcdir)/tests/libzbxmockdata.a + +COMMON_COMPILER_FLAGS = -I@top_srcdir@/tests + + +zbx_iso8601_utc_SOURCES = \ + zbx_iso8601_utc.c \ + $(COMMON_SRC_FILES) + +zbx_iso8601_utc_LDADD = \ + $(COMMON_LIB_FILES) + +zbx_iso8601_utc_LDADD += @SERVER_LIBS@ + +zbx_iso8601_utc_LDFLAGS = @SERVER_LDFLAGS@ + +zbx_iso8601_utc_CFLAGS = $(COMMON_COMPILER_FLAGS) + + +endif diff --git a/tests/libs/zbxtime/zbx_iso8601_utc.c b/tests/libs/zbxtime/zbx_iso8601_utc.c new file mode 100644 index 00000000000..7ef08429d99 --- /dev/null +++ b/tests/libs/zbxtime/zbx_iso8601_utc.c @@ -0,0 +1,54 @@ +/* +** Zabbix +** Copyright (C) 2001-2022 Zabbix SIA +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +**/ + +#include "zbxmocktest.h" +#include "zbxmockdata.h" +#include "zbxmockassert.h" +#include "zbxmockutil.h" +#include <stdlib.h> + +#include "zbxtime.h" + +void zbx_mock_test_entry(void **state) +{ + const char *param; + int expected_ret, returned_ret; + time_t ut; + + ZBX_UNUSED(state); + + param = zbx_mock_get_parameter_string("in.param"); + + expected_ret = zbx_mock_str_to_return_code(zbx_mock_get_parameter_string("out.return")); + returned_ret = zbx_iso8601_utc(param, &ut); + + zbx_mock_assert_result_eq("zbx_iso8601_datetime()", expected_ret, returned_ret); + + if (SUCCEED == returned_ret) + { + zbx_timespec_t dt; + time_t t_out; + + if (ZBX_MOCK_SUCCESS != zbx_strtime_to_timespec(zbx_mock_get_parameter_string("out.datetime"), &dt)) + fail_msg("Invalid date time format"); + + t_out = dt.sec; + zbx_mock_assert_time_eq("zbx_iso8601_datetime() incorrect parsing:", t_out, ut); + } +} diff --git a/tests/libs/zbxtime/zbx_iso8601_utc.yaml b/tests/libs/zbxtime/zbx_iso8601_utc.yaml new file mode 100644 index 00000000000..3de01c960fa --- /dev/null +++ b/tests/libs/zbxtime/zbx_iso8601_utc.yaml @@ -0,0 +1,222 @@ +--- +test case: Invalid value '' +in: + param: +out: + return: FAIL +--- +test case: Invalid value 'xxx' +in: + param: xxx +out: + return: FAIL +--- +test case: Invalid value '123' +in: + param: 123 +out: + return: FAIL +--- +test case: Invalid value '2022x09-12T14:46:15' +in: + param: 2022x09-12T14:46:15 +out: + return: FAIL +--- +test case: Invalid value '2022-09x12T14:46:15' +in: + param: 2022-09x12T14:46:15 +out: + return: FAIL +--- +test case: Invalid value '2022-09-12x14:46:15' +in: + param: 2022-09-12x14:46:15 +out: + return: FAIL +--- +test case: Invalid value '2022-09-12T14x46:15' +in: + param: 2022-09-12T14x46:15 +out: + return: FAIL +--- +test case: Invalid value '2022-09-12T14:46x15' +in: + param: 2022-09-12T14:46x15 +out: + return: FAIL + + +--- +test case: Valid yyyy-mm-ddThh:mm:ss +in: + param: 2022-09-12T14:46:15 +out: + datetime: 2022-09-12 14:46:15 + return: SUCCEED +--- +test case: Valid yyyy-mm-ddThh:mm:ssZ +in: + param: 2022-09-12T14:46:15Z +out: + datetime: 2022-09-12 14:46:15Z + return: SUCCEED +--- +test case: Valid yyyy-mm-ddThh:mm:ss+hh:mm +in: + param: 2022-09-12T14:46:15+04:00 +out: + datetime: 2022-09-12 14:46:15 +04:00 + return: SUCCEED +--- +test case: Valid yyyy-mm-ddThh:mm:ss-hh:mm +in: + param: 2022-09-12T14:46:15-04:00 +out: + datetime: 2022-09-12 14:46:15 -04:00 + return: SUCCEED +--- +test case: Valid yyyy-mm-ddThh:mm:ss +hh:mm +in: + param: 2022-09-12T14:46:15 +04:00 +out: + datetime: 2022-09-12 14:46:15 +04:00 + return: SUCCEED +--- +test case: Valid yyyy-mm-ddThh:mm:ss -hh:mm +in: + param: 2022-09-12T14:46:15 -04:00 +out: + datetime: 2022-09-12 14:46:15 -04:00 + return: SUCCEED +--- +test case: Valid yyyy-mm-ddThh:mm:ss.ccc +in: + param: 2022-09-12T14:46:15.123 +out: + datetime: 2022-09-12 14:46:15.123 + return: SUCCEED +--- +test case: Valid yyyy-mm-ddThh:mm:ss.cccZ +in: + param: 2022-09-12T14:46:15.123Z +out: + datetime: 2022-09-12 14:46:15.123Z + return: SUCCEED +--- +test case: Valid yyyy-mm-ddThh:mm:ss.ccc+hh:mm +in: + param: 2022-09-12T14:46:15.123+04:00 +out: + datetime: 2022-09-12 14:46:15.123 +04:00 + return: SUCCEED +--- +test case: Valid yyyy-mm-ddThh:mm:ss.ccc-hh:mm +in: + param: 2022-09-12T14:46:15.123-04:00 +out: + datetime: 2022-09-12 14:46:15.123 -04:00 + return: SUCCEED +--- +test case: Valid yyyy-mm-ddThh:mm:ss.ccc +hh:mm +in: + param: 2022-09-12T14:46:15.123 +04:00 +out: + datetime: 2022-09-12 14:46:15.123 +04:00 + return: SUCCEED +--- +test case: Valid yyyy-mm-ddThh:mm:ss.ccc -hh:mm +in: + param: 2022-09-12T14:46:15.123 -04:00 +out: + datetime: 2022-09-12 14:46:15.123 -04:00 + return: SUCCEED + + + +--- +test case: Valid yyyy-mm-dd hh:mm:ss +in: + param: 2022-09-12 14:46:15 +out: + datetime: 2022-09-12 14:46:15 + return: SUCCEED +--- +test case: Valid yyyy-mm-dd hh:mm:ssZ +in: + param: 2022-09-12 14:46:15Z +out: + datetime: 2022-09-12 14:46:15Z + return: SUCCEED +--- +test case: Valid yyyy-mm-dd hh:mm:ss+hh:mm +in: + param: 2022-09-12 14:46:15+04:00 +out: + datetime: 2022-09-12 14:46:15 +04:00 + return: SUCCEED +--- +test case: Valid yyyy-mm-dd hh:mm:ss-hh:mm +in: + param: 2022-09-12 14:46:15-04:00 +out: + datetime: 2022-09-12 14:46:15 -04:00 + return: SUCCEED +--- +test case: Valid yyyy-mm-dd hh:mm:ss +hh:mm +in: + param: 2022-09-12 14:46:15 +04:00 +out: + datetime: 2022-09-12 14:46:15 +04:00 + return: SUCCEED +--- +test case: Valid yyyy-mm-dd hh:mm:ss -hh:mm +in: + param: 2022-09-12 14:46:15 -04:00 +out: + datetime: 2022-09-12 14:46:15 -04:00 + return: SUCCEED +--- +test case: Valid yyyy-mm-dd hh:mm:ss.ccc +in: + param: 2022-09-12 14:46:15.123 +out: + datetime: 2022-09-12 14:46:15.123 + return: SUCCEED +--- +test case: Valid yyyy-mm-dd hh:mm:ss.cccZ +in: + param: 2022-09-12 14:46:15.123Z +out: + datetime: 2022-09-12 14:46:15.123Z + return: SUCCEED +--- +test case: Valid yyyy-mm-dd hh:mm:ss.ccc+hh:mm +in: + param: 2022-09-12 14:46:15.123+04:00 +out: + datetime: 2022-09-12 14:46:15.123 +04:00 + return: SUCCEED +--- +test case: Valid yyyy-mm-dd hh:mm:ss.ccc-hh:mm +in: + param: 2022-09-12 14:46:15.123-04:00 +out: + datetime: 2022-09-12 14:46:15.123 -04:00 + return: SUCCEED +--- +test case: Valid yyyy-mm-dd hh:mm:ss.ccc +hh:mm +in: + param: 2022-09-12 14:46:15.123 +04:00 +out: + datetime: 2022-09-12 14:46:15.123 +04:00 + return: SUCCEED +--- +test case: Valid yyyy-mm-dd hh:mm:ss.ccc -hh:mm +in: + param: 2022-09-12 14:46:15.123 -04:00 +out: + datetime: 2022-09-12 14:46:15.123 -04:00 + return: SUCCEED + diff --git a/tests/zabbix_server/service/mock_service.c b/tests/zabbix_server/service/mock_service.c index 52cc09b451d..a614f129ade 100644 --- a/tests/zabbix_server/service/mock_service.c +++ b/tests/zabbix_server/service/mock_service.c @@ -47,9 +47,10 @@ int CONFIG_SERVICEMAN_SYNC_FREQUENCY = 0; pid_t *threads; int threads_num; -void zbx_update_selfmon_counter(unsigned char state) +void zbx_update_selfmon_counter(const zbx_thread_info_t *info, unsigned char state) { ZBX_UNUSED(state); + ZBX_UNUSED(info); } int get_process_info_by_thread(int local_server_num, unsigned char *local_process_type, int *local_process_num) diff --git a/tests/zbxmocktest.c b/tests/zbxmocktest.c index 2423769b6da..2d7773b2cda 100644 --- a/tests/zbxmocktest.c +++ b/tests/zbxmocktest.c @@ -26,10 +26,6 @@ unsigned char program_type = 0; -ZBX_THREAD_LOCAL unsigned char process_type = 0; -ZBX_THREAD_LOCAL int process_num = 0; -ZBX_THREAD_LOCAL int server_num = 0; - int CONFIG_ALERTER_FORKS = 3; int CONFIG_DISCOVERER_FORKS = 1; int CONFIG_HOUSEKEEPER_FORKS = 1; |