-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathy_vts.c
216 lines (171 loc) · 8.21 KB
/
y_vts.c
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/*
* Ylib Loadrunner function library.
* Copyright (C) 2009-2010 Raymond de Jongh <[email protected]> | <[email protected]>
* Copyright (C) 2010,2014 Floris Kraak <[email protected]> | <[email protected]>
*
* 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.
*/
/*
* Documentation generated from this source code can be found here: http://randakar.github.io/y-lib/
* Main git repitory can be found at https://github.com/randakar/y-lib
*/
/*!
\file y_vts.c
\brief VTS functions for LR 11.5 and above.
Library wrapperrs for talking to a VTS-server.
This is part of LR 11.5 and needs to be installed seperately.
For LR versions older than 11.5, see the old y_vts.c.
\warning This y_vts.c is NOT compatible with the vts version that was shipped before LR 11.5, and the older y_vts.c is NOT compatible with the version in LR 11.5 either.
*/
#ifndef _Y_VTS_FUNC_C_
//! \cond include_protection
#define _Y_VTS_FUNC_C_
//! \endcond
/* \brief Standardised error reporting for all VTS functions.
\author Floris Kraak
*/
void y_vts_report_error(char* message)
{
lr_error_message("****** VTS ERROR: %s", message);
}
/*!
\brief Error translation and reporting facility for VTS return codes.
This will emit VTS errors using lr_error_message() in human readable form, if the code represents a VTS error.
\param returncode An error code as returned by VTS
\returns the returncode
This is what the header file vts2.h tells us about error codes:
\code
//VTS Error Codes
#define VTCERR_OK 0
#define VTCERR_INVALID_CONNECTION_INFO -10000
#define VTCERR_FAILED_TO_RESOLVE_ADDR -10001
#define VTCERR_FAILED_TO_CREATE_SOCKET -10002
#define VTCERR_FAILED_TO_CONNECT -10003
#define VTCERR_INCOMPLETE_REQUEST -10100
#define VTCERR_FAILED_TO_RECV_RESPONSE -10101
#define VTCERR_INCOMPLETE_RESPONSE -10102
#define VTCERR_RESPONSE_ARGS_UNMATCH -10103
// --- Operation Error Base
#define VTCERR_OPERATION_ERROR_BASE -11000
#define VTCERR_SERVER_IS_BUSY (VTCERR_OPERATION_ERROR_BASE - 0xFF)
#define VTCERR_CLIENT_REQUEST_ERROR (VTCERR_OPERATION_ERROR_BASE - 0xFE)
\endcode
Loadrunner 11.52 expanded that a little, to the following definition in the help files:
\code
VTCERR_OK 0 Success
VTCERR_INVALID_CONNECTION_INFO -10000 The corresponding handle does not exist or the connection information is corrupted. Disconnect and reconnect.
VTCERR_FAILED_TO_RESOLVE_ADDR -10001 Failed to find server.
VTCERR_FAILED_TO_CREATE_SOCKET -10002 Failed to create socket.
VTCERR_FAILED_TO_CONNECT -10003 Failed to connect. Check the server name, port number, network connectivity, and whether server is on line.
VTCERR_INVALID_API_CALL -10004 Failed to get the API entry. <-- NEW
VTCERR_INCOMPLETE_REQUEST -10100 Communications packet from client is invalid.
VTCERR_FAILED_TO_RECV_RESPONSE -10101 No response received from server.
VTCERR_INCOMPLETE_RESPONSE -10102 Communications packet from server is invalid.
VTCERR_RESPONSE_ARGS_UNMATCH -10103 Unexpected count of arguments in server response.
VTCERR_INVALID_ARGUMENT -10104 Invalid argument. <-- NEW
VTCERR_HANDLE_NOT_EXIST -10105 Connection handle does not exist. <-- NEW
VTCERR_INNER_JSON_CONVERT -10106 Cannot parse server response. <-- NEW
VTCERR_INNER_UTF8_CONVERT -10107 Cannot convert between UTF8 and Locale. <-- NEW
VTCERR_COL_FORMAT_ERROR -10108 Invalid or empty column name. <-- NEW
VTCERR_COL_VALUE_NO_MATCH -10109 Column names list and messages list do not have the same number of values. Check delimiters. <-- NEW
VTCERR_EVAL_STRING -10110 Error evaluating parameter value. <-- NEW
VTCERR_DATA_NOT_EXIST -10111 There is no data at the specified column and row. <-- NEW
\endcode
.. note however that the "Operation Error Base" codes are gone.
\author Floris Kraak
*/
int y_vts_process_returncode(int returncode)
{
char* errortext;
// Encode the above information in a simple lookup table.
switch(returncode)
{
case VTCERR_OK:
//errortext = "INFO: VTS command succeeded.";
//lr_log_message(errortext);
return returncode;
break; // <-- never reached, but kept for readability.
case VTCERR_INVALID_CONNECTION_INFO:
errortext = "The corresponding handle does not exist or the connection information is corrupted. Disconnect and reconnect.";
break;
case VTCERR_FAILED_TO_RESOLVE_ADDR:
errortext = "Failed to resolve server address.";
break;
case VTCERR_FAILED_TO_CREATE_SOCKET:
errortext = "Failed to create socket.";
break;
case VTCERR_FAILED_TO_CONNECT:
errortext = "Failed to connect. Check the server name, port number, network connectivity, and whether server is on line."; // LR 11.52 simply calls lr_abort() if this happens.
break;
case VTCERR_INVALID_API_CALL:
errortext = "Failed to get the API entry.";
break;
case VTCERR_INCOMPLETE_REQUEST:
errortext = "Communications packet from client is invalid.";
break;
case VTCERR_FAILED_TO_RECV_RESPONSE:
errortext = "No response received from server.";
break;
case VTCERR_INCOMPLETE_RESPONSE:
errortext = "Response from server is incomplete.";
break;
case VTCERR_RESPONSE_ARGS_UNMATCH:
errortext = "Unexpected count of arguments in server response.";
break;
case VTCERR_INVALID_ARGUMENT:
errortext = "Invalid argument.";
break;
case VTCERR_HANDLE_NOT_EXIST:
errortext = "Connection handle does not exist.";
break;
case VTCERR_INNER_JSON_CONVERT:
errortext = "Cannot parse server (JSON) response.";
break;
case VTCERR_INNER_UTF8_CONVERT:
errortext = "Cannot convert between UTF8 and Locale.";
break;
case VTCERR_COL_FORMAT_ERROR:
errortext = "Invalid or empty column name.";
break;
case VTCERR_COL_VALUE_NO_MATCH:
errortext = "Column names list and messages list do not have the same number of values. Check delimiters.";
break;
case VTCERR_EVAL_STRING:
errortext = "Error evaluating parameter value.";
break;
case VTCERR_DATA_NOT_EXIST:
errortext = "There is no data at the specified column and row.";
break;
// These operation base errors may not exist in LR 11.52. The documentation no longer mentions them.
case VTCERR_OPERATION_ERROR_BASE:
errortext = "Received error code VTCERR_OPERATION_ERROR_BASE.";
break;
case VTCERR_SERVER_IS_BUSY:
errortext = "Server is busy. Go away.";
break;
case VTCERR_CLIENT_REQUEST_ERROR:
errortext = "Client request error.";
break;
default:
errortext = "Unknown VTC error code.";
break;
}
// Report the error to the user. (The "All OK" case jumped out of this function earlier ..)
y_vts_report_error(errortext);
// At this point it might be an idea to call lr_abort() or lr_exit(LR_EXIT_VUSER, LR_FAIL)
return returncode;
}
// --------------------------------------------------------------------------------------------------
#endif // _Y_VTS_FUNC_C_