Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: srtp/test/rdbx_driver.c

Issue 1098043003: Update libsrtp to 1.5.2 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libsrtp@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « srtp/srtp/srtp.c ('k') | srtp/test/rtp.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * rdbx_driver.c 2 * rdbx_driver.c
3 * 3 *
4 * driver for the rdbx implementation (replay database with extended range) 4 * driver for the rdbx implementation (replay database with extended range)
5 * 5 *
6 * David A. McGrew 6 * David A. McGrew
7 * Cisco Systems, Inc. 7 * Cisco Systems, Inc.
8 */ 8 */
9 9
10 /* 10 /*
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 status = rdbx_init(&rdbx, ws); 235 status = rdbx_init(&rdbx, ws);
236 if (status) { 236 if (status) {
237 printf("replay_init failed with error code %d\n", status); 237 printf("replay_init failed with error code %d\n", status);
238 exit(1); 238 exit(1);
239 } 239 }
240 240
241 /* 241 /*
242 * test sequential insertion 242 * test sequential insertion
243 */ 243 */
244 printf("\ttesting sequential insertion..."); 244 printf("\ttesting sequential insertion...");
245 for (idx=0; idx < num_trials; idx++) { 245 for (idx=0; (int) idx < num_trials; idx++) {
246 status = rdbx_check_add(&rdbx, idx); 246 status = rdbx_check_add(&rdbx, idx);
247 if (status) 247 if (status)
248 return status; 248 return status;
249 } 249 }
250 printf("passed\n"); 250 printf("passed\n");
251 251
252 /* 252 /*
253 * test for false positives by checking all of the index 253 * test for false positives by checking all of the index
254 * values which we've just added 254 * values which we've just added
255 * 255 *
256 * note that we limit the number of trials here, since allowing the 256 * note that we limit the number of trials here, since allowing the
257 * rollover counter to roll over would defeat this test 257 * rollover counter to roll over would defeat this test
258 */ 258 */
259 num_fp_trials = num_trials % 0x10000; 259 num_fp_trials = num_trials % 0x10000;
260 if (num_fp_trials == 0) { 260 if (num_fp_trials == 0) {
261 printf("warning: no false positive tests performed\n"); 261 printf("warning: no false positive tests performed\n");
262 } 262 }
263 printf("\ttesting for false positives..."); 263 printf("\ttesting for false positives...");
264 for (idx=0; idx < num_fp_trials; idx++) { 264 for (idx=0; (int) idx < num_fp_trials; idx++) {
265 status = rdbx_check_expect_failure(&rdbx, idx); 265 status = rdbx_check_expect_failure(&rdbx, idx);
266 if (status) 266 if (status)
267 return status; 267 return status;
268 } 268 }
269 printf("passed\n"); 269 printf("passed\n");
270 270
271 /* re-initialize */ 271 /* re-initialize */
272 rdbx_dealloc(&rdbx); 272 rdbx_dealloc(&rdbx);
273 273
274 if (rdbx_init(&rdbx, ws) != err_status_ok) { 274 if (rdbx_init(&rdbx, ws) != err_status_ok) {
275 printf("replay_init failed\n"); 275 printf("replay_init failed\n");
276 return err_status_init_fail; 276 return err_status_init_fail;
277 } 277 }
278 278
279 /* 279 /*
280 * test non-sequential insertion 280 * test non-sequential insertion
281 * 281 *
282 * this test covers only fase negatives, since the values returned 282 * this test covers only fase negatives, since the values returned
283 * by ut_next_index(...) are distinct 283 * by ut_next_index(...) are distinct
284 */ 284 */
285 ut_init(&utc); 285 ut_init(&utc);
286 286
287 printf("\ttesting non-sequential insertion..."); 287 printf("\ttesting non-sequential insertion...");
288 for (idx=0; idx < num_trials; idx++) { 288 for (idx=0; (int) idx < num_trials; idx++) {
289 ircvd = ut_next_index(&utc); 289 ircvd = ut_next_index(&utc);
290 status = rdbx_check_add_unordered(&rdbx, ircvd); 290 status = rdbx_check_add_unordered(&rdbx, ircvd);
291 if (status) 291 if (status)
292 return status; 292 return status;
293 status = rdbx_check_expect_failure(&rdbx, ircvd); 293 status = rdbx_check_expect_failure(&rdbx, ircvd);
294 if (status) 294 if (status)
295 return status; 295 return status;
296 } 296 }
297 printf("passed\n"); 297 printf("passed\n");
298 298
299 /* re-initialize */ 299 /* re-initialize */
300 rdbx_dealloc(&rdbx); 300 rdbx_dealloc(&rdbx);
301 301
302 if (rdbx_init(&rdbx, ws) != err_status_ok) { 302 if (rdbx_init(&rdbx, ws) != err_status_ok) {
303 printf("replay_init failed\n"); 303 printf("replay_init failed\n");
304 return err_status_init_fail; 304 return err_status_init_fail;
305 } 305 }
306 306
307 /* 307 /*
308 * test insertion with large gaps. 308 * test insertion with large gaps.
309 * check for false positives for each insertion. 309 * check for false positives for each insertion.
310 */ 310 */
311 printf("\ttesting insertion with large gaps..."); 311 printf("\ttesting insertion with large gaps...");
312 for (idx=0, ircvd=0; idx < num_trials; idx++, ircvd += (1 << (rand() % 12))) { 312 for (idx=0, ircvd=0; (int) idx < num_trials; idx++, ircvd += (1 << (rand() % 1 2))) {
313 status = rdbx_check_add(&rdbx, ircvd); 313 status = rdbx_check_add(&rdbx, ircvd);
314 if (status) 314 if (status)
315 return status; 315 return status;
316 status = rdbx_check_expect_failure(&rdbx, ircvd); 316 status = rdbx_check_expect_failure(&rdbx, ircvd);
317 if (status) 317 if (status)
318 return status; 318 return status;
319 } 319 }
320 printf("passed\n"); 320 printf("passed\n");
321 321
322 rdbx_dealloc(&rdbx); 322 rdbx_dealloc(&rdbx);
(...skipping 15 matching lines...) Expand all
338 clock_t timer; 338 clock_t timer;
339 int failures; /* count number of failures */ 339 int failures; /* count number of failures */
340 340
341 if (rdbx_init(&rdbx, ws) != err_status_ok) { 341 if (rdbx_init(&rdbx, ws) != err_status_ok) {
342 printf("replay_init failed\n"); 342 printf("replay_init failed\n");
343 exit(1); 343 exit(1);
344 } 344 }
345 345
346 failures = 0; 346 failures = 0;
347 timer = clock(); 347 timer = clock();
348 for(i=0; i < num_trials; i++) { 348 for(i=0; (int) i < num_trials; i++) {
349 349
350 delta = index_guess(&rdbx.index, &est, i); 350 delta = index_guess(&rdbx.index, &est, i);
351 351
352 if (rdbx_check(&rdbx, delta) != err_status_ok) 352 if (rdbx_check(&rdbx, delta) != err_status_ok)
353 ++failures; 353 ++failures;
354 else 354 else
355 if (rdbx_add_index(&rdbx, delta) != err_status_ok) 355 if (rdbx_add_index(&rdbx, delta) != err_status_ok)
356 ++failures; 356 ++failures;
357 } 357 }
358 timer = clock() - timer; 358 timer = clock() - timer;
359 359
360 printf("number of failures: %d \n", failures); 360 printf("number of failures: %d \n", failures);
361 361
362 rdbx_dealloc(&rdbx); 362 rdbx_dealloc(&rdbx);
363 363
364 return (double) CLOCKS_PER_SEC * num_trials / timer; 364 return (double) CLOCKS_PER_SEC * num_trials / timer;
365 } 365 }
366 366
OLDNEW
« no previous file with comments | « srtp/srtp/srtp.c ('k') | srtp/test/rtp.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698