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:
authorVladislavs Sokurenko <vladislavs.sokurenko@zabbix.com>2022-01-14 13:13:30 +0300
committerVladislavs Sokurenko <vladislavs.sokurenko@zabbix.com>2022-01-14 13:13:30 +0300
commita2e97b410d4bcf8ede297c3978e234a37c491a88 (patch)
treeb61bc1cd79913f1cb4e1b575baf400f695641f80 /tests
parent390ba7d40198a429da4189a77465ab273e32d21a (diff)
.......... [ZBXNEXT-7411] fixed cmocka tests on non Linux systems
Diffstat (limited to 'tests')
-rw-r--r--tests/conf_tests.m439
-rw-r--r--tests/libs/zbxalgo/queue.c2
-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/zbxmockexit.c10
-rw-r--r--tests/zbxmockfile.c16
-rw-r--r--tests/zbxmockutil.c2
14 files changed, 55 insertions, 23 deletions
diff --git a/tests/conf_tests.m4 b/tests/conf_tests.m4
index 84b091db560..7ddc6c5d40e 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,37 @@ 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
])
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/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/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..3d68b50a76a 100644
--- a/tests/zbxmockfile.c
+++ b/tests/zbxmockfile.c
@@ -45,16 +45,14 @@ 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);
-int __wrap___fxstat(int __ver, int __fildes, struct stat *__stat_buf);
int __real_open(const char *path, int oflag, ...);
int __real_stat(const char *path, struct stat *buf);
-int __real___fxstat(int __ver, int __fildes, struct stat *__stat_buf);
static int is_profiler_path(const char *path)
{
@@ -168,7 +166,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;
@@ -282,13 +280,3 @@ int __wrap___xstat(int ver, const char *pathname, struct stat *buf)
return __wrap_stat(pathname, buf);
}
-
-int __wrap___fxstat(int __ver, int __fildes, struct stat *__stat_buf)
-{
- if (__fildes != INT_MAX)
- return __real___fxstat(__ver, __fildes, __stat_buf);
-
- __stat_buf->st_size = zbx_mock_get_parameter_uint64("in.file_len");
-
- return 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)
{