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:
authorMichael Veksler <Mihails.Vekslers@zabbix.com>2022-10-12 15:27:53 +0300
committerMichael Veksler <Mihails.Vekslers@zabbix.com>2022-10-12 19:52:17 +0300
commit50009bd954fdcb44e7228d82be26e97166bd46e7 (patch)
tree4f6c1bfb64fafd93b171a259c8a9928fb422a981 /tests
parent64837b8e0e45c5eec797cbd82110505a824ff006 (diff)
.......PS. [ZBXNEXT-6401] added oldest* fields to vm snapshot json
Diffstat (limited to 'tests')
-rw-r--r--tests/conf_tests.m41
-rw-r--r--tests/libs/Makefile.am1
-rw-r--r--tests/libs/zbxtime/Makefile.am44
-rw-r--r--tests/libs/zbxtime/zbx_iso8601_utc.c54
-rw-r--r--tests/libs/zbxtime/zbx_iso8601_utc.yaml222
5 files changed, 322 insertions, 0 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/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
+