Review Board 1.7.16


clang compiler warning: fixes for tests to be compiled using clang

Review Request #4555 - Created March 29, 2015 and submitted

Diederik de Groot
13
ASTERISK-24917
Reviewers
asterisk-dev
Asterisk
clang's static analyzer will throw quite a number warnings / errors during compilation, some of which can be very helpfull in finding corner-case bugs. 

fixes for tests to be compiled using clang
executing the tests one-by-one works fine (completes to end) (skipping /main/stdtime) -> 
test show results failed:


=================== /main/message/ ====== 
FAIL   test_message_queue_handler_nom /main/message/             31036ms
[test_message.c:int handler_wait_for_message(struct ast_test *):244]: Test timed out while waiting for handler to get message

Not sure if this is actually a fail or just a timeout. WIP


=================== /main/strings/ ====== 
FAIL   escape_semicolons              /main/strings/             1ms     
[Mar 29 20:13:43] ERROR[2521]: utils.c:493 char *ast_escape_semicolons(const char *, char *, int): FRACK!, Failed assertion string != NULL && outbuf != NULL (0)
-> explainable by the change made to the source. ast_alloca(0) is not being executed -> test2 = NULL: need to resolv the open question how to handle ast_alloca(0) before making any further changes.

(With revision 5 of this code, this test now passes without a problem, had to fix both the test and the function being tested though)


=================== /main/stdtime ====== 
"test execute all" fails, caused by the /main/stdtime/ test. 
START  /main/stdtime/ - timezone_watch 
[test_time.c:enum ast_test_result_state test_timezone_watch(struct ast_test_info *, enum ast_test_command, struct ast_test *):84]: Executing deletion test...
j62747*CLI> 
CLI becomes unresponsive / no further command completion for example.
Guess this will need a little further investigation. Maybe the source changes made to main/stdtime/ where not completely correct.

Seems to be caused by inotify_daemon, at least there is where the segfault happens. WIP
<?xml version="1.0" encoding="UTF-8"?>
<testsuite errors="0" time="181.742" tests="444" n
<properties>
<property name="version" value="SV

Diff revision 8

This is not the most recent revision of the diff. The latest diff is revision 9. See what's changed.

1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9

  1. /branches/13/tests/test_acl.c: Loading...
  2. /branches/13/tests/test_sched.c: Loading...
  3. /branches/13/tests/test_stringfields.c: Loading...
  4. /branches/13/tests/test_strings.c: Loading...
/branches/13/tests/test_acl.c
Revision 433444 New Change
[20] 119 lines
[+20] [+] struct acl {
120
 */
120
 */
121

    
   
121

   
122
#define TACL_A AST_SENSE_ALLOW
122
#define TACL_A AST_SENSE_ALLOW
123
#define TACL_D AST_SENSE_DENY
123
#define TACL_D AST_SENSE_DENY
124

    
   
124

   

    
   
125
static int build_ha(const struct acl *acl, size_t len, struct ast_ha **ha, const char *acl_name, int *err, struct ast_test *test, enum ast_test_result_state *res) 

    
   
126
{

    
   
127
	size_t i;

    
   
128

   

    
   
129
	for (i = 0; i < len; ++i) {

    
   
130
		if (!(*ha = ast_append_ha(acl[i].access, acl[i].host, *ha, err))) {
Moved from 220

    
   
131
			ast_test_status_update(test, "Failed to add rule %s with access %s to %s\n",
Moved from 221

    
   
132
					       acl[i].host, acl[i].access, acl_name);

    
   
133
			*res = AST_TEST_FAIL;
Moved from 223

    
   
134
			return -1;
Moved from 224

    
   
135
		}
Moved from 225

    
   
136
	}

    
   
137

   
Moved from 227

    
   
138
	return 0;
Moved from 228

    
   
139
}

    
   
140

   
125
AST_TEST_DEFINE(acl)
141
AST_TEST_DEFINE(acl)
126
{
142
{
127
	struct acl permitallv4 = { "0.0.0.0/0", "permit" };
143
	struct acl permitallv4 = { "0.0.0.0/0", "permit" };
128
	struct acl denyallv4 = { "0.0.0.0/0", "deny" };
144
	struct acl denyallv4 = { "0.0.0.0/0", "deny" };
129
	struct acl permitallv6 = { "::/0", "permit" };
145
	struct acl permitallv6 = { "::/0", "permit" };
[+20] [20] 79 lines
[+20] AST_TEST_DEFINE(acl)
209
	struct ast_ha *ha7 = NULL;
225
	struct ast_ha *ha7 = NULL;
210
	enum ast_test_result_state res = AST_TEST_PASS;
226
	enum ast_test_result_state res = AST_TEST_PASS;
211
	int err = 0;
227
	int err = 0;
212
	int i;
228
	int i;
213

    
   
229

   
214
	auto int build_ha(const struct acl *acl, size_t len, struct ast_ha **ha, const char *acl_name);

   
215
	auto int build_ha(const struct acl *acl, size_t len, struct ast_ha **ha, const char *acl_name) {

   
216
		size_t i;

   
217

    
   

   
218
		for (i = 0; i < len; ++i) {

   
219
			if (!(*ha = ast_append_ha(acl[i].access, acl[i].host, *ha, &err))) {

   
220
				ast_test_status_update(test, "Failed to add rule %s with access %s to %s\n",
Moved to 131

   
221
						       acl[i].host, acl[i].access, acl_name);
Moved to 132

   
222
				res = AST_TEST_FAIL;

   
223
				return -1;
Moved to 134

   
224
			}
Moved to 135

   
225
		}
Moved to 136

   
226

    
   

   
227
		return 0;
Moved to 138

   
228
	}
Moved to 139

   
229

    
   
230

   
230
	switch (cmd) {
231
	switch (cmd) {
231
	case TEST_INIT:
232
	case TEST_INIT:
232
		info->name = "acl";
233
		info->name = "acl";
233
		info->category = "/main/acl/";
234
		info->category = "/main/acl/";
[+20] [20] 27 lines
[+20] AST_TEST_DEFINE(acl)
261
		ast_test_status_update(test, "Failed to create deny_all ACL\n");
262
		ast_test_status_update(test, "Failed to create deny_all ACL\n");
262
		res = AST_TEST_FAIL;
263
		res = AST_TEST_FAIL;
263
		goto acl_cleanup;
264
		goto acl_cleanup;
264
	}
265
	}
265

    
   
266

   
266
	if (build_ha(acl1, ARRAY_LEN(acl1), &ha1, "ha1") != 0) {
267
	if (build_ha(acl1, ARRAY_LEN(acl1), &ha1, "ha1", &err, test, &res) != 0) {
267
		goto acl_cleanup;
268
		goto acl_cleanup;
268
	}
269
	}
269

    
   
270

   
270
	if (build_ha(acl2, ARRAY_LEN(acl2), &ha2, "ha2") != 0) {
271
	if (build_ha(acl2, ARRAY_LEN(acl2), &ha2, "ha2", &err, test, &res) != 0) {
271
		goto acl_cleanup;
272
		goto acl_cleanup;
272
	}
273
	}
273

    
   
274

   
274
	if (build_ha(acl3, ARRAY_LEN(acl3), &ha3, "ha3") != 0) {
275
	if (build_ha(acl3, ARRAY_LEN(acl3), &ha3, "ha3", &err, test, &res) != 0) {
275
		goto acl_cleanup;
276
		goto acl_cleanup;
276
	}
277
	}
277

    
   
278

   
278
	if (build_ha(acl4, ARRAY_LEN(acl4), &ha4, "ha4") != 0) {
279
	if (build_ha(acl4, ARRAY_LEN(acl4), &ha4, "ha4", &err, test, &res) != 0) {
279
		goto acl_cleanup;
280
		goto acl_cleanup;
280
	}
281
	}
281

    
   
282

   
282
	if (build_ha(acl5, ARRAY_LEN(acl5), &ha5, "ha5") != 0) {
283
	if (build_ha(acl5, ARRAY_LEN(acl5), &ha5, "ha5", &err, test, &res) != 0) {
283
		goto acl_cleanup;
284
		goto acl_cleanup;
284
	}
285
	}
285

    
   
286

   
286
	if (build_ha(acl6, ARRAY_LEN(acl6), &ha6, "ha6") != 0) {
287
	if (build_ha(acl6, ARRAY_LEN(acl6), &ha6, "ha6", &err, test, &res) != 0) {
287
		goto acl_cleanup;
288
		goto acl_cleanup;
288
	}
289
	}
289

    
   
290

   
290
	if (build_ha(acl7, ARRAY_LEN(acl7), &ha7, "ha7") != 0) {
291
	if (build_ha(acl7, ARRAY_LEN(acl7), &ha7, "ha7", &err, test, &res) != 0) {
291
		goto acl_cleanup;
292
		goto acl_cleanup;
292
	}
293
	}
293

    
   
294

   
294
	for (i = 0; i < ARRAY_LEN(acl_tests); ++i) {
295
	for (i = 0; i < ARRAY_LEN(acl_tests); ++i) {
295
		struct ast_sockaddr addr;
296
		struct ast_sockaddr addr;
[+20] [20] 156 lines
/branches/13/tests/test_sched.c
Revision 433444 New Change
 
/branches/13/tests/test_stringfields.c
Revision 433444 New Change
 
/branches/13/tests/test_strings.c
Revision 433444 New Change
 
  1. /branches/13/tests/test_acl.c: Loading...
  2. /branches/13/tests/test_sched.c: Loading...
  3. /branches/13/tests/test_stringfields.c: Loading...
  4. /branches/13/tests/test_strings.c: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.