blob: 3b497f064bdaa3eeb0b0bfc36e0deabb3f46a631 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/*
** Zabbix
** Copyright (C) 2001-2017 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 "../include/common.h"
#include "../include/zbxalgo.h"
#include "../include/log.h"
#include "../include/zbxserver.h"
#include "../include/zbxtasks.h"
/* Mandatory headers needed by cmocka */
#include <stdbool.h>
#include <stdarg.h>
#include <setjmp.h>
#include <cmocka.h>
#ifndef ZABBIX_TESTS_H
#define ZABBIX_TESTS_H
#undef strcpy
#define ZBX_TEST_DATA_TYPE_UNKNOWN 0
#define ZBX_TEST_DATA_TYPE_CASE 1
#define ZBX_TEST_DATA_TYPE_PARAM_IN 2
#define ZBX_TEST_DATA_TYPE_PARAM_OUT 3
#define ZBX_TEST_DATA_TYPE_DB_DATA 4
#define ZBX_TEST_DATA_TYPE_FUNCTION 5
#define ZBX_TEST_DATA_TYPE_IN_PARAM 8
#define ZBX_TEST_DATA_TYPE_IN_VALUE 9
#define ZBX_TEST_DATA_TYPE_OUT_PARAM 10
#define ZBX_TEST_DATA_TYPE_OUT_VALUE 11
#define ZBX_TEST_DATA_TYPE_DB_FIELD 12
#define ZBX_TEST_DATA_TYPE_DB_ROW 13
#define ZBX_TEST_DATA_TYPE_FUNC_OUT 14
#define ZBX_TEST_DATA_TYPE_FUNC_VALUE 15
#define ZBX_TEST_DATA_TYPE_TESTED_FUNC 16
typedef struct
{
char **names;
char **values;
int data_num;
}
zbx_test_data_t;
typedef struct
{
char **values;
int value_num;
}
zbx_test_row_t;
typedef struct
{
char *source_name;
char **field_names;
int field_num;
zbx_test_row_t *rows;
int row_num;
}
zbx_test_datasource_t;
typedef struct
{
char *name;
zbx_test_data_t data;
}
zbx_test_function_t;
typedef struct
{
char *case_name;
char *tested_function;
int datasource_num;
int function_num;
zbx_test_data_t in_params;
zbx_test_data_t out_params;
zbx_test_datasource_t *datasources;
zbx_test_function_t *functions;
}
zbx_test_case_t;
zbx_test_case_t *cases;
int case_num;
char *get_in_param_by_index(int idx);
char *get_out_param_by_index(int idx);
char *get_in_param_by_name(const char *name);
char *get_out_param_by_name(const char *name);
char *get_out_func_param_by_idx(int idx);
char *get_out_func_param_by_name(const char *name);
int load_data(char *file_name);
void free_data();
void debug_print_cases();
struct zbx_db_result
{
char *data_source; /* "<table name>_" + "<table name>" + ... */
char *case_name;
char *sql;
DB_ROW *rows;
int rows_num;
int cur_row_idx;
};
#endif
|