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
diff options
context:
space:
mode:
authorJurijs Klopovskis <jurijs.klopovskis@zabbix.com>2021-10-08 14:52:18 +0300
committerJurijs Klopovskis <jurijs.klopovskis@zabbix.com>2021-10-08 17:15:28 +0300
commit0039036f930212e7184a174b963a3681cb61dd94 (patch)
treecba284b739f33fc51f569ef0883ce2ba015163cd /tests/libs/zbxsysinfo
parent8804282a959bb4561717720d2358196016708889 (diff)
...G...... [ZBX-20008] removed curl and ldap linkage from agent2
cherry-picked from 938d0afc139eb45eb6d8dfab67a0f57f45e35eee conflicts: tests/libs/zbxserver/Makefile.am
Diffstat (limited to 'tests/libs/zbxsysinfo')
-rw-r--r--tests/libs/zbxsysinfo/Makefile.am31
-rw-r--r--tests/libs/zbxsysinfo/common/Makefile.am2
-rw-r--r--tests/libs/zbxsysinfo/linux/Makefile.am2
-rw-r--r--tests/libs/zbxsysinfo/process.c33
-rw-r--r--tests/libs/zbxsysinfo/process.yaml15
-rw-r--r--tests/libs/zbxsysinfo/process_http.c99
-rw-r--r--tests/libs/zbxsysinfo/process_http.yaml16
7 files changed, 146 insertions, 52 deletions
diff --git a/tests/libs/zbxsysinfo/Makefile.am b/tests/libs/zbxsysinfo/Makefile.am
index a721aa4bbcb..17de2bbc969 100644
--- a/tests/libs/zbxsysinfo/Makefile.am
+++ b/tests/libs/zbxsysinfo/Makefile.am
@@ -9,6 +9,7 @@ endif
if AGENT
AGENT_tests = \
process \
+ process_http \
check_key_access_rules
endif
@@ -49,6 +50,8 @@ parse_item_key_LDADD = \
$(top_srcdir)/src/libs/zbxserver/libzbxserver.a \
$(top_srcdir)/src/libs/zbxsysinfo/libzbxserversysinfo.a \
$(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo.a \
+ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_httpmetrics.a \
+ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_http.a \
$(top_srcdir)/src/libs/zbxsysinfo/simple/libsimplesysinfo.a \
$(top_srcdir)/src/libs/zbxdbcache/libzbxdbcache.a \
$(top_srcdir)/src/libs/zbxhistory/libzbxhistory.a \
@@ -96,6 +99,7 @@ COMMON_LIB_FILES = \
$(top_srcdir)/src/libs/zbxsysinfo/agent/libagentsysinfo.a \
$(top_srcdir)/src/libs/zbxsysinfo/simple/libsimplesysinfo.a \
$(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo.a \
+ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_httpmetrics.a \
$(top_srcdir)/src/libs/zbxlog/libzbxlog.a \
$(top_srcdir)/src/libs/zbxregexp/libzbxregexp.a \
$(top_srcdir)/src/libs/zbxalgo/libzbxalgo.a \
@@ -118,13 +122,12 @@ process_SOURCES = \
process.c \
../../zbxmocktest.h
-process_LDADD = $(COMMON_LIB_FILES)
+process_LDADD = $(COMMON_LIB_FILES) \
+ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_http.a \
+ $(top_srcdir)/src/libs/zbxhttp/libzbxhttp.a
process_WRAP_FUNCS = \
-Wl,--wrap=SYSTEM_LOCALTIME \
- -Wl,--wrap=WEB_PAGE_GET \
- -Wl,--wrap=WEB_PAGE_PERF \
- -Wl,--wrap=WEB_PAGE_REGEXP \
-Wl,--wrap=VFS_FILE_SIZE \
-Wl,--wrap=VFS_FILE_TIME \
-Wl,--wrap=VFS_FILE_EXISTS \
@@ -144,6 +147,25 @@ process_LDFLAGS = @AGENT_LDFLAGS@ $(process_WRAP_FUNCS)
process_CFLAGS = -DZABBIX_DAEMON -I@top_srcdir@/tests
+# process_http
+
+process_http_SOURCES = \
+ process_http.c \
+ ../../zbxmocktest.h
+
+process_http_LDADD = $(COMMON_LIB_FILES)
+
+process_http_WRAP_FUNCS = \
+ -Wl,--wrap=WEB_PAGE_GET \
+ -Wl,--wrap=WEB_PAGE_PERF \
+ -Wl,--wrap=WEB_PAGE_REGEXP
+
+process_http_LDADD += @AGENT_LIBS@
+
+process_http_LDFLAGS = @AGENT_LDFLAGS@
+
+process_http_CFLAGS = $(process_http_WRAP_FUNCS) -I@top_srcdir@/tests
+
# check_key_access_rules
check_key_access_rules_SOURCES = \
@@ -152,6 +174,7 @@ check_key_access_rules_SOURCES = \
check_key_access_rules_LDADD = $(COMMON_LIB_FILES) \
$(top_srcdir)/src/libs/zbxjson/libzbxjson.a \
+ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_http.a \
$(top_srcdir)/src/libs/zbxhttp/libzbxhttp.a
check_key_access_rules_LDADD += @AGENT_LIBS@
diff --git a/tests/libs/zbxsysinfo/common/Makefile.am b/tests/libs/zbxsysinfo/common/Makefile.am
index d6f7fa874be..b66785e1c36 100644
--- a/tests/libs/zbxsysinfo/common/Makefile.am
+++ b/tests/libs/zbxsysinfo/common/Makefile.am
@@ -18,6 +18,8 @@ COMMON_LIB_FILES = \
$(top_srcdir)/src/libs/zbxsysinfo/agent/libagentsysinfo.a \
$(top_srcdir)/src/libs/zbxsysinfo/simple/libsimplesysinfo.a \
$(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo.a \
+ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_httpmetrics.a \
+ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_http.a \
$(top_srcdir)/src/libs/zbxlog/libzbxlog.a \
$(top_srcdir)/src/libs/zbxregexp/libzbxregexp.a \
$(top_srcdir)/src/libs/zbxalgo/libzbxalgo.a \
diff --git a/tests/libs/zbxsysinfo/linux/Makefile.am b/tests/libs/zbxsysinfo/linux/Makefile.am
index 93ad477029f..38112ac4c52 100644
--- a/tests/libs/zbxsysinfo/linux/Makefile.am
+++ b/tests/libs/zbxsysinfo/linux/Makefile.am
@@ -26,6 +26,8 @@ COMMON_LIB_FILES = \
$(top_srcdir)/src/libs/zbxsysinfo/agent/libagentsysinfo.a \
$(top_srcdir)/src/libs/zbxsysinfo/simple/libsimplesysinfo.a \
$(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo.a \
+ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_httpmetrics.a \
+ $(top_srcdir)/src/libs/zbxsysinfo/common/libcommonsysinfo_http.a \
$(top_srcdir)/src/libs/zbxlog/libzbxlog.a \
$(top_srcdir)/src/libs/zbxregexp/libzbxregexp.a \
$(top_srcdir)/src/libs/zbxalgo/libzbxalgo.a \
diff --git a/tests/libs/zbxsysinfo/process.c b/tests/libs/zbxsysinfo/process.c
index c208b82ed56..048bd9dbc4e 100644
--- a/tests/libs/zbxsysinfo/process.c
+++ b/tests/libs/zbxsysinfo/process.c
@@ -29,9 +29,6 @@
static char *called_key = NULL;
int __wrap_SYSTEM_LOCALTIME(const char *command, AGENT_RESULT *result);
-int __wrap_WEB_PAGE_GET(const char *command, AGENT_RESULT *result);
-int __wrap_WEB_PAGE_PERF(const char *command, AGENT_RESULT *result);
-int __wrap_WEB_PAGE_REGEXP(const char *command, AGENT_RESULT *result);
int __wrap_VFS_FILE_SIZE(const char *command, AGENT_RESULT *result);
int __wrap_VFS_FILE_TIME(const char *command, AGENT_RESULT *result);
int __wrap_VFS_FILE_EXISTS(const char *command, AGENT_RESULT *result);
@@ -95,36 +92,6 @@ int __wrap_SYSTEM_LOCALTIME(const char *command, AGENT_RESULT *result)
return SUCCEED;
}
-int __wrap_WEB_PAGE_GET(const char *command, AGENT_RESULT *result)
-{
- ZBX_UNUSED(command);
- ZBX_UNUSED(result);
-
- called_key = "web.page.get";
-
- return SUCCEED;
-}
-
-int __wrap_WEB_PAGE_PERF(const char *command, AGENT_RESULT *result)
-{
- ZBX_UNUSED(command);
- ZBX_UNUSED(result);
-
- called_key = "web.page.perf";
-
- return SUCCEED;
-}
-
-int __wrap_WEB_PAGE_REGEXP(const char *command, AGENT_RESULT *result)
-{
- ZBX_UNUSED(command);
- ZBX_UNUSED(result);
-
- called_key = "web.page.regexp";
-
- return SUCCEED;
-}
-
int __wrap_VFS_FILE_SIZE(const char *command, AGENT_RESULT *result)
{
ZBX_UNUSED(command);
diff --git a/tests/libs/zbxsysinfo/process.yaml b/tests/libs/zbxsysinfo/process.yaml
index 25181ebb6b8..49655beebed 100644
--- a/tests/libs/zbxsysinfo/process.yaml
+++ b/tests/libs/zbxsysinfo/process.yaml
@@ -4,21 +4,6 @@ in:
in_command: system.localtime[utc]
flags: 4
---
-test case: successfully called WEB_PAGE_GET function
-in:
- in_command: web.page.get[localhost,,80]
- flags: 4
----
-test case: successfully called WEB_PAGE_PERF function
-in:
- in_command: web.page.perf[localhost,,80]
- flags: 4
----
-test case: successfully called WEB_PAGE_REGEXP function
-in:
- in_command: web.page.regexp[localhost,,80,OK]
- flags: 4
----
test case: successfully called VFS_FILE_SIZE function
in:
in_command: vfs.file.size[/etc/passwd]
diff --git a/tests/libs/zbxsysinfo/process_http.c b/tests/libs/zbxsysinfo/process_http.c
new file mode 100644
index 00000000000..f29e35544af
--- /dev/null
+++ b/tests/libs/zbxsysinfo/process_http.c
@@ -0,0 +1,99 @@
+/*
+** Zabbix
+** Copyright (C) 2001-2021 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 "db.h"
+#include "sysinfo.h"
+
+static char *called_key = NULL;
+
+int __wrap_WEB_PAGE_GET(const char *command, AGENT_RESULT *result);
+int __wrap_WEB_PAGE_PERF(const char *command, AGENT_RESULT *result);
+int __wrap_WEB_PAGE_REGEXP(const char *command, AGENT_RESULT *result);
+
+void zbx_mock_test_entry(void **state)
+{
+ zbx_mock_error_t error;
+ zbx_mock_handle_t in_command, in_flags;
+ const char *in_command_string, *flags_string, *p;
+ char key[ITEM_KEY_LEN];
+ unsigned flags_uint32;
+ AGENT_RESULT result;
+
+ ZBX_UNUSED(state);
+
+ if (ZBX_MOCK_SUCCESS != (error = zbx_mock_in_parameter("in_command", &in_command)) ||
+ ZBX_MOCK_SUCCESS != (error = zbx_mock_string(in_command, &in_command_string)))
+ {
+ fail_msg("Cannot get in_command from test case data: %s", zbx_mock_error_string(error));
+ }
+
+ if (ZBX_MOCK_SUCCESS != (error = zbx_mock_in_parameter("flags", &in_flags)) ||
+ ZBX_MOCK_SUCCESS != (error = zbx_mock_string(in_flags, &flags_string)))
+ {
+ fail_msg("Cannot get flags from test case data: %s", zbx_mock_error_string(error));
+ }
+ if (SUCCEED != is_uint32(flags_string, &flags_uint32))
+ fail_msg("Cannot convert flags to unsigned 32 bit integer.");
+
+ init_metrics();
+
+ process(in_command_string, flags_uint32, &result);
+
+ if (NULL != (p = strchr(in_command_string, '[')))
+ zbx_strlcpy(key, in_command_string, p - in_command_string + 1);
+
+ if (called_key == NULL || 0 != strcmp((NULL == p ? in_command_string : key), called_key))
+ {
+ fail_msg("Unexpected called item '%s' instead of '%s' as a key.",
+ ZBX_NULL2STR(called_key), in_command_string);
+ }
+}
+
+int __wrap_WEB_PAGE_GET(const char *command, AGENT_RESULT *result)
+{
+ ZBX_UNUSED(command);
+ ZBX_UNUSED(result);
+
+ called_key = "web.page.get";
+
+ return SUCCEED;
+}
+
+int __wrap_WEB_PAGE_PERF(const char *command, AGENT_RESULT *result)
+{
+ ZBX_UNUSED(command);
+ ZBX_UNUSED(result);
+
+ called_key = "web.page.perf";
+
+ return SUCCEED;
+}
+
+int __wrap_WEB_PAGE_REGEXP(const char *command, AGENT_RESULT *result)
+{
+ ZBX_UNUSED(command);
+ ZBX_UNUSED(result);
+
+ called_key = "web.page.regexp";
+
+ return SUCCEED;
+}
diff --git a/tests/libs/zbxsysinfo/process_http.yaml b/tests/libs/zbxsysinfo/process_http.yaml
new file mode 100644
index 00000000000..b2fd1b62caf
--- /dev/null
+++ b/tests/libs/zbxsysinfo/process_http.yaml
@@ -0,0 +1,16 @@
+---
+test case: successfully called WEB_PAGE_GET function
+in:
+ in_command: web.page.get[localhost,,80]
+ flags: 4
+---
+test case: successfully called WEB_PAGE_PERF function
+in:
+ in_command: web.page.perf[localhost,,80]
+ flags: 4
+---
+test case: successfully called WEB_PAGE_REGEXP function
+in:
+ in_command: web.page.regexp[localhost,,80,OK]
+ flags: 4
+...