Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndris Zeila <andris.zeila@zabbix.com>2022-01-24 18:27:58 +0300
committerVladislavs Sokurenko <vladislavs.sokurenko@zabbix.com>2022-01-24 18:27:58 +0300
commit0092bb2e83c791c49a884765913762ab71afd3cc (patch)
tree12135e760c0604c08a1d4c9e1be7f54ab2d9224b /tests
parent044b2d5b8b8a67155a290fcb6cd55fc60bbe13e7 (diff)
parentabbd7ab8d1cb2e8774f46a272016f58251f2d818 (diff)
.......PS. [ZBXNEXT-7411] replaced signals with IPC messages for most of internal runtime control option processing
.......PS. [ZBXNEXT-7411] replaced signals with IPC messages for most of internal runtime control option processing * commit 'abbd7ab8d1cb2e8774f46a272016f58251f2d818': (38 commits) ........S. [ZBXNEXT-7411] removed duplicated diaginfo sections .......P.. [ZBXNEXT-7411] fixed active proxy configuration syncer to get configuration from server after startup without delays .......PS. [ZBXNEXT-7411] include, comment fixes according to pr comments .......PS. [ZBXNEXT-7411] fixed discoverer to keep the discovery schedule after processing rtc notifications (snmp cache reload) .......PS. [ZBXNEXT-7411] fixed exit in the case of insufficient configuration cache size .......PS. [ZBXNEXT-7411] removed debug comment ........S. [ZBXNEXT-7411] fixed housekeeper sleep time calculation .......... [ZBXNEXT-7411] removed unused function .......... [ZBXNEXT-7411] removed redundant include .......PS. [ZBXNEXT-7411] fixed warning ........S. [ZBXNEXT-7411] changed server configuration sync delay to count from sync end to sync start rather from star to start ........S. [ZBXNEXT-7411] added nextcheck intialization in configuration syncer .......PS. [ZBXNEXT-7411] added handling of rtc shutdown notification in all processes using rtc subscriptions ........S. [ZBXNEXT-7411] simplified server configuration syncer delay checks ........S. [ZBXNEXT-7411] restored warning messages when service manager cache is reloaded with rtc option .......P.. [ZBXNEXT-7411] removed signal handler setup ........S. [ZBXNEXT-7411] removed unused signal handler ........S. [ZBXNEXT-7411] reset rtc service when switching server from active to standby mode .......PS. [ZBXNEXT-7411] fixed snmp cache realoading check .......P.. [ZBXNEXT-7411] changed proxy configuration syncer sleep time to ignore sync time ...
Diffstat (limited to 'tests')
-rw-r--r--tests/conf_tests.m450
-rw-r--r--tests/libs/zbxalgo/queue.c2
-rw-r--r--tests/libs/zbxeval/zbx_eval_execute.c17
-rw-r--r--tests/libs/zbxserver/macro_fmttime.c42
-rw-r--r--tests/libs/zbxsysinfo/aix/Makefile.am1
-rw-r--r--tests/libs/zbxsysinfo/freebsd/Makefile.am1
-rw-r--r--tests/libs/zbxsysinfo/hpux/Makefile.am1
-rw-r--r--tests/libs/zbxsysinfo/netbsd/Makefile.am1
-rw-r--r--tests/libs/zbxsysinfo/openbsd/Makefile.am1
-rw-r--r--tests/libs/zbxsysinfo/osf/Makefile.am1
-rw-r--r--tests/libs/zbxsysinfo/osx/Makefile.am1
-rw-r--r--tests/libs/zbxsysinfo/solaris/Makefile.am1
-rw-r--r--tests/libs/zbxsysinfo/unknown/Makefile.am1
-rw-r--r--tests/zabbix_server/service/Makefile.am4
-rw-r--r--tests/zbxmockexit.c10
-rw-r--r--tests/zbxmockfile.c10
-rw-r--r--tests/zbxmocktest.c2
-rw-r--r--tests/zbxmockutil.c2
18 files changed, 135 insertions, 13 deletions
diff --git a/tests/conf_tests.m4 b/tests/conf_tests.m4
index 84b091db560..9a25dc1c2b7 100644
--- a/tests/conf_tests.m4
+++ b/tests/conf_tests.m4
@@ -17,8 +17,9 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
-AC_DEFUN([CONF_TESTS],[
- AM_COND_IF([$1],[
+AC_DEFUN([CONF_TESTS],
+[
+ AM_COND_IF([ZBXCMOCKA],[
AC_CONFIG_FILES([
tests/Makefile
tests/libs/Makefile
@@ -37,7 +38,6 @@ AC_DEFUN([CONF_TESTS],[
tests/libs/zbxserver/Makefile
tests/libs/zbxsysinfo/Makefile
tests/libs/zbxsysinfo/common/Makefile
- tests/libs/zbxsysinfo/linux/Makefile
tests/libs/zbxtrends/Makefile
tests/zabbix_server/Makefile
tests/zabbix_server/preprocessor/Makefile
@@ -49,4 +49,48 @@ AC_DEFUN([CONF_TESTS],[
])
AC_DEFINE([HAVE_TESTS], [1], ["Define to 1 if tests directory is present"])
])
+
+ case "$ARCH" in
+ linux)
+ AC_CONFIG_FILES([tests/libs/zbxsysinfo/linux/Makefile])
+ ;;
+ aix)
+ AC_CONFIG_FILES([tests/libs/zbxsysinfo/aix/Makefile])
+ ;;
+ osx)
+ AC_CONFIG_FILES([tests/libs/zbxsysinfo/osx/Makefile])
+ ;;
+ solaris)
+ AC_CONFIG_FILES([tests/libs/zbxsysinfo/solaris/Makefile])
+ ;;
+ hpux)
+ AC_CONFIG_FILES([tests/libs/zbxsysinfo/hpux/Makefile])
+ ;;
+ freebsd)
+ AC_CONFIG_FILES([tests/libs/zbxsysinfo/freebsd/Makefile])
+ ;;
+ netbsd)
+ AC_CONFIG_FILES([tests/libs/zbxsysinfo/netbsd/Makefile])
+ ;;
+ osf)
+ AC_CONFIG_FILES([tests/libs/zbxsysinfo/osf/Makefile])
+ ;;
+ openbsd)
+ AC_CONFIG_FILES([tests/libs/zbxsysinfo/openbsd/Makefile])
+ ;;
+ unknown)
+ AC_CONFIG_FILES([tests/libs/zbxsysinfo/unknown/Makefile])
+ ;;
+ esac
+
+
+AC_TRY_LINK(
+[
+#include <stdlib.h>
+],
+[
+ __fxstat(0, 0, NULL);
+],
+AC_DEFINE([HAVE_FXSTAT], [1], [Define to 1 if fxstat function is available]))
+
])
diff --git a/tests/libs/zbxalgo/queue.c b/tests/libs/zbxalgo/queue.c
index 014e97d0568..7a5facce8bd 100644
--- a/tests/libs/zbxalgo/queue.c
+++ b/tests/libs/zbxalgo/queue.c
@@ -21,7 +21,7 @@
#include "zbxmockdata.h"
#include "zbxmockassert.h"
#include "zbxmockutil.h"
-#include <malloc.h>
+#include <stdlib.h>
#include "zbxalgo.h"
diff --git a/tests/libs/zbxeval/zbx_eval_execute.c b/tests/libs/zbxeval/zbx_eval_execute.c
index e52f15dea88..97d58b01c1d 100644
--- a/tests/libs/zbxeval/zbx_eval_execute.c
+++ b/tests/libs/zbxeval/zbx_eval_execute.c
@@ -77,8 +77,23 @@ void zbx_mock_test_entry(void **state)
if (SUCCEED == expected_ret)
{
- zbx_mock_assert_str_eq("output value", zbx_mock_get_parameter_string("out.value"),
+ /* use custom epsilon for floating point values to account for */
+ /* rounding differences with various systems/libs */
+ if (ZBX_VARIANT_DBL == value.type)
+ {
+ double expected_value;
+
+ expected_value = atof(zbx_mock_get_parameter_string("out.value"));
+
+ if (1e-12 < fabs(value.data.dbl - expected_value))
+ fail_msg("Expected value \"%f\" while got \"%f\"", expected_value, value.data.dbl);
+ }
+ else
+ {
+ zbx_mock_assert_str_eq("output value", zbx_mock_get_parameter_string("out.value"),
zbx_variant_value_desc(&value));
+ }
+
zbx_variant_clear(&value);
}
out:
diff --git a/tests/libs/zbxserver/macro_fmttime.c b/tests/libs/zbxserver/macro_fmttime.c
index 6ff357093b9..a2e8bee1eb1 100644
--- a/tests/libs/zbxserver/macro_fmttime.c
+++ b/tests/libs/zbxserver/macro_fmttime.c
@@ -25,10 +25,52 @@
#include "common.h"
#include "macrofunc.h"
#include "log.h"
+#include "zbxserver.h"
#include "valuecache.h"
#include "mocks/valuecache/valuecache_mock.h"
+int __wrap_substitute_simple_macros(zbx_uint64_t *actionid, const DB_EVENT *event, const DB_EVENT *r_event,
+ zbx_uint64_t *userid, const zbx_uint64_t *hostid, const DC_HOST *dc_host, const DC_ITEM *dc_item,
+ DB_ALERT *alert, const DB_ACKNOWLEDGE *ack, const zbx_service_alarm_t *service_alarm,
+ const DB_SERVICE *service, const char *tz, char **data, int macro_type, char *error,
+ int maxerrlen);
+
+int __wrap_DCget_data_expected_from(zbx_uint64_t itemid, int *seconds);
+
+int __wrap_substitute_simple_macros(zbx_uint64_t *actionid, const DB_EVENT *event, const DB_EVENT *r_event,
+ zbx_uint64_t *userid, const zbx_uint64_t *hostid, const DC_HOST *dc_host, const DC_ITEM *dc_item,
+ DB_ALERT *alert, const DB_ACKNOWLEDGE *ack, const zbx_service_alarm_t *service_alarm,
+ const DB_SERVICE *service, const char *tz, char **data, int macro_type, char *error,
+ int maxerrlen)
+{
+ ZBX_UNUSED(actionid);
+ ZBX_UNUSED(event);
+ ZBX_UNUSED(r_event);
+ ZBX_UNUSED(userid);
+ ZBX_UNUSED(hostid);
+ ZBX_UNUSED(dc_host);
+ ZBX_UNUSED(dc_item);
+ ZBX_UNUSED(alert);
+ ZBX_UNUSED(ack);
+ ZBX_UNUSED(tz);
+ ZBX_UNUSED(data);
+ ZBX_UNUSED(macro_type);
+ ZBX_UNUSED(error);
+ ZBX_UNUSED(maxerrlen);
+ ZBX_UNUSED(service_alarm);
+ ZBX_UNUSED(service);
+
+ return SUCCEED;
+}
+
+int __wrap_DCget_data_expected_from(zbx_uint64_t itemid, int *seconds)
+{
+ ZBX_UNUSED(itemid);
+ *seconds = zbx_vcmock_get_ts().sec - 600;
+ return SUCCEED;
+}
+
void zbx_mock_test_entry(void **state)
{
const size_t macro_pos = 1, macro_pos_end = 6, func_pos = 8, func_param_pos = 15;
diff --git a/tests/libs/zbxsysinfo/aix/Makefile.am b/tests/libs/zbxsysinfo/aix/Makefile.am
new file mode 100644
index 00000000000..a53a4f35a6f
--- /dev/null
+++ b/tests/libs/zbxsysinfo/aix/Makefile.am
@@ -0,0 +1 @@
+noinst_PROGRAMS = $(AGENT_tests)
diff --git a/tests/libs/zbxsysinfo/freebsd/Makefile.am b/tests/libs/zbxsysinfo/freebsd/Makefile.am
new file mode 100644
index 00000000000..a53a4f35a6f
--- /dev/null
+++ b/tests/libs/zbxsysinfo/freebsd/Makefile.am
@@ -0,0 +1 @@
+noinst_PROGRAMS = $(AGENT_tests)
diff --git a/tests/libs/zbxsysinfo/hpux/Makefile.am b/tests/libs/zbxsysinfo/hpux/Makefile.am
new file mode 100644
index 00000000000..a53a4f35a6f
--- /dev/null
+++ b/tests/libs/zbxsysinfo/hpux/Makefile.am
@@ -0,0 +1 @@
+noinst_PROGRAMS = $(AGENT_tests)
diff --git a/tests/libs/zbxsysinfo/netbsd/Makefile.am b/tests/libs/zbxsysinfo/netbsd/Makefile.am
new file mode 100644
index 00000000000..a53a4f35a6f
--- /dev/null
+++ b/tests/libs/zbxsysinfo/netbsd/Makefile.am
@@ -0,0 +1 @@
+noinst_PROGRAMS = $(AGENT_tests)
diff --git a/tests/libs/zbxsysinfo/openbsd/Makefile.am b/tests/libs/zbxsysinfo/openbsd/Makefile.am
new file mode 100644
index 00000000000..a53a4f35a6f
--- /dev/null
+++ b/tests/libs/zbxsysinfo/openbsd/Makefile.am
@@ -0,0 +1 @@
+noinst_PROGRAMS = $(AGENT_tests)
diff --git a/tests/libs/zbxsysinfo/osf/Makefile.am b/tests/libs/zbxsysinfo/osf/Makefile.am
new file mode 100644
index 00000000000..a53a4f35a6f
--- /dev/null
+++ b/tests/libs/zbxsysinfo/osf/Makefile.am
@@ -0,0 +1 @@
+noinst_PROGRAMS = $(AGENT_tests)
diff --git a/tests/libs/zbxsysinfo/osx/Makefile.am b/tests/libs/zbxsysinfo/osx/Makefile.am
new file mode 100644
index 00000000000..a53a4f35a6f
--- /dev/null
+++ b/tests/libs/zbxsysinfo/osx/Makefile.am
@@ -0,0 +1 @@
+noinst_PROGRAMS = $(AGENT_tests)
diff --git a/tests/libs/zbxsysinfo/solaris/Makefile.am b/tests/libs/zbxsysinfo/solaris/Makefile.am
new file mode 100644
index 00000000000..a53a4f35a6f
--- /dev/null
+++ b/tests/libs/zbxsysinfo/solaris/Makefile.am
@@ -0,0 +1 @@
+noinst_PROGRAMS = $(AGENT_tests)
diff --git a/tests/libs/zbxsysinfo/unknown/Makefile.am b/tests/libs/zbxsysinfo/unknown/Makefile.am
new file mode 100644
index 00000000000..a53a4f35a6f
--- /dev/null
+++ b/tests/libs/zbxsysinfo/unknown/Makefile.am
@@ -0,0 +1 @@
+noinst_PROGRAMS = $(AGENT_tests)
diff --git a/tests/zabbix_server/service/Makefile.am b/tests/zabbix_server/service/Makefile.am
index f9b85c60d95..08aa9e3a7a0 100644
--- a/tests/zabbix_server/service/Makefile.am
+++ b/tests/zabbix_server/service/Makefile.am
@@ -20,12 +20,16 @@ COMMON_LIBS = \
$(top_srcdir)/src/zabbix_server/availability/libavailability.a \
$(top_srcdir)/src/libs/zbxipcservice/libzbxipcservice.a \
$(top_srcdir)/src/libs/zbxtrends/libzbxtrends.a \
+ $(top_srcdir)/src/libs/zbxtrends/libzbxtrends_baseline.a \
$(top_srcdir)/src/zabbix_server/libzbxserver.a \
$(top_srcdir)/src/libs/zbxserver/libzbxserver.a \
$(top_srcdir)/src/libs/zbxservice/libzbxservice.a \
$(top_srcdir)/src/zabbix_server/service/libservice.a \
+ $(top_srcdir)/src/libs/zbxxml/libzbxxml.a \
$(top_srcdir)/src/libs/zbxeval/libzbxeval.a \
$(top_srcdir)/src/libs/zbxsysinfo/libzbxserversysinfo.a \
+ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_httpmetrics.a \
+ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_http.a \
$(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo.a \
$(top_srcdir)/src/libs/zbxsysinfo/simple/libsimplesysinfo.a \
$(top_srcdir)/src/libs/zbxhistory/libzbxhistory.a \
diff --git a/tests/zbxmockexit.c b/tests/zbxmockexit.c
index 932aa63bec6..2a1d5a73dd2 100644
--- a/tests/zbxmockexit.c
+++ b/tests/zbxmockexit.c
@@ -34,10 +34,12 @@ void __wrap_exit(int status)
int expected_status;
if (ZBX_MOCK_NO_EXIT_CODE == (error = zbx_mock_exit_code(&expected_status)))
- fail_msg("exit() was not expected, exitcode: %d.", status);
-
- if (ZBX_MOCK_SUCCESS != error)
- fail_msg("Cannot get exit code from test case data: %s", zbx_mock_error_string(error));
+ expected_status = EXIT_SUCCESS;
+ else
+ {
+ if (ZBX_MOCK_SUCCESS != error)
+ fail_msg("Cannot get exit code from test case data: %s", zbx_mock_error_string(error));
+ }
switch (status)
{
diff --git a/tests/zbxmockfile.c b/tests/zbxmockfile.c
index de129859439..2b15d2cfe2a 100644
--- a/tests/zbxmockfile.c
+++ b/tests/zbxmockfile.c
@@ -45,16 +45,20 @@ struct zbx_mock_IO_FILE
FILE *__wrap_fopen(const char *path, const char *mode);
int __wrap_fclose(FILE *fp);
char *__wrap_fgets(char *s, int size, FILE *stream);
-int __wrap_connect(int socket, __CONST_SOCKADDR_ARG addr, socklen_t address_len);
+int __wrap_connect(int socket, void *addr, socklen_t address_len);
ssize_t __wrap_read(int fildes, void *buf, size_t nbyte);
int __wrap_open(const char *path, int oflag, ...);
int __wrap_stat(const char *path, struct stat *buf);
int __wrap___xstat(int ver, const char *pathname, struct stat *buf);
+#ifdef HAVE_FXSTAT
int __wrap___fxstat(int __ver, int __fildes, struct stat *__stat_buf);
+#endif
int __real_open(const char *path, int oflag, ...);
int __real_stat(const char *path, struct stat *buf);
+#ifdef HAVE_FXSTAT
int __real___fxstat(int __ver, int __fildes, struct stat *__stat_buf);
+#endif
static int is_profiler_path(const char *path)
{
@@ -168,7 +172,7 @@ char *__wrap_fgets(char *s, int size, FILE *stream)
return s;
}
-int __wrap_connect(int socket, __CONST_SOCKADDR_ARG addr, socklen_t address_len)
+int __wrap_connect(int socket, void *addr, socklen_t address_len)
{
zbx_mock_error_t error;
@@ -283,6 +287,7 @@ int __wrap___xstat(int ver, const char *pathname, struct stat *buf)
return __wrap_stat(pathname, buf);
}
+#ifdef HAVE_FXSTAT
int __wrap___fxstat(int __ver, int __fildes, struct stat *__stat_buf)
{
if (__fildes != INT_MAX)
@@ -292,3 +297,4 @@ int __wrap___fxstat(int __ver, int __fildes, struct stat *__stat_buf)
return 0;
}
+#endif
diff --git a/tests/zbxmocktest.c b/tests/zbxmocktest.c
index 13c844c3d07..bc42f2fc478 100644
--- a/tests/zbxmocktest.c
+++ b/tests/zbxmocktest.c
@@ -57,7 +57,7 @@ int CONFIG_PREPROCESSOR_FORKS = 3;
int CONFIG_HISTORYPOLLER_FORKS = 5;
int CONFIG_AVAILMAN_FORKS = 1;
int CONFIG_SERVICEMAN_FORKS = 0;
-int CONFIG_PROBLEMHOUSEKEEPER_FORKS = 0;
+int CONFIG_TRIGGERHOUSEKEEPER_FORKS = 0;
int CONFIG_ODBCPOLLER_FORKS = 5;
int CONFIG_LISTEN_PORT = 0;
diff --git a/tests/zbxmockutil.c b/tests/zbxmockutil.c
index 187980dba8e..7e8f9b0521c 100644
--- a/tests/zbxmockutil.c
+++ b/tests/zbxmockutil.c
@@ -26,7 +26,7 @@
#include "module.h"
#include "zbxvariant.h"
-#include <malloc.h>
+#include <stdlib.h>
const char *zbx_mock_get_parameter_string(const char *path)
{