@@ -154,6 +154,8 @@ def path_query_tshark_filter_count(t_outfile, filter_fun):
154
154
pred = get_key_str (line )
155
155
(pkt_count , byte_count ) = predwise_count .get (pred , (0 , 0 ))
156
156
predwise_count [pred ] = (pkt_count + 1 , byte_count + bytes_fun (line ))
157
+ (pkt_count , byte_count ) = predwise_count .get ('total' , (0 , 0 ))
158
+ predwise_count ['total' ] = (pkt_count + 1 , byte_count + bytes_fun (line ))
157
159
return predwise_count
158
160
159
161
def ctlr_counts (c_outfile , c_name ):
@@ -336,17 +338,83 @@ def bucket_write_passfail_info(success_file, tshark_counts, buckets_counts):
336
338
passfail .close ()
337
339
338
340
def path_query_write_passfail_info (success_file , tshark_counts , buckets_counts ):
339
- print "In path query passfail info. I got the following counts:"
340
- print "TShark:"
341
- print "Bucket references:" , tshark_counts .keys ()
342
- for vals in tshark_counts .values ():
343
- for (k , v ) in vals .iteritems ():
344
- print k , v
345
- print "Buckets:"
346
- print "Bucket references:" , buckets_counts .keys ()
347
- for vals in buckets_counts .values ():
348
- for (k , v ) in vals .iteritems ():
349
- print k , v
341
+ """ Write pass/fail information summary for this test. This function takes
342
+ the following steps to determine if the output of the path query controller
343
+ is acceptable.
344
+ 1. ensure the query references obtained from tshark & buckets are the same.
345
+ For each query reference,
346
+ 2. is the total packet count the same?
347
+ 3. is the difference between total byte counts bounded?*
348
+ 4. is the set of keys generated from tshark & buckets the same?
349
+ For each key of each query reference,
350
+ 5. is the packet count the same?
351
+ 6. is the difference between byte counts bounded?*
352
+
353
+ * TODO(ngsrinivas): some packets show a 4 byte increase in payload size when
354
+ they come into the packet interpreter. This needs more investigation.
355
+ """
356
+ passfail = open (success_file , 'w' )
357
+ output_str = ''
358
+ if set (tshark_counts .keys ()) != set (buckets_counts .keys ()):
359
+ """ Test numbers mismatch. """
360
+ output_str += 'FAIL\n '
361
+ output_str += 'Query references mismatch:\n '
362
+ output_str += 'TShark: %s\n ' % str (tshark_counts .keys ())
363
+ output_str += 'Bucket: %s\n ' % str (buckets_counts .keys ())
364
+ elif True :
365
+ """ Per-query-test checks. """
366
+ for q in tshark_counts .keys ():
367
+ tc = tshark_counts [q ]
368
+ bc = buckets_counts [q ]
369
+ (tc_total_pkts , tc_total_bytes ) = tc ['total' ]
370
+ (bc_total_pkts , bc_total_bytes ) = bc ['total' ]
371
+ if tc_total_pkts != bc_total_pkts :
372
+ output_str += 'FAIL\n '
373
+ output_str += 'Query: %s\n ' % q
374
+ output_str += 'Total packet counts mismatch:\n '
375
+ output_str += 'TShark: %d\n ' % tc_total_pkts
376
+ output_str += 'Bucket: %d\n ' % bc_total_pkts
377
+ break
378
+ elif abs (tc_total_bytes - bc_total_bytes ) > 4 * tc_total_pkts :
379
+ output_str += 'FAIL\n '
380
+ output_str += 'Query: %s\n ' % q
381
+ output_str += 'Total byte count mismatch out of bounds:\n '
382
+ output_str += 'TShark: %d\n ' % tc_total_bytes
383
+ output_str += 'Bucket: %d\n ' % bc_total_bytes
384
+ break
385
+ elif set (tc .keys ()) != set (bc .keys ()):
386
+ output_str += 'FAIL\n '
387
+ output_str += 'Query: %s\n ' % q
388
+ output_str += 'Groups of packets counted differ:\n '
389
+ output_str += 'TShark:\n %s\n ' % ('\n ' .join (tc .keys ()))
390
+ output_str += 'Bucket:\n %s\n ' % ('\n ' .join (bc .keys ()))
391
+ break
392
+ elif True :
393
+ for pred in tc .keys ():
394
+ """ Check each predicate within each query. """
395
+ (tc_pred_pkts , tc_pred_bytes ) = tc [pred ]
396
+ (bc_pred_pkts , bc_pred_bytes ) = bc [pred ]
397
+ if tc_pred_pkts != bc_pred_pkts :
398
+ output_str += 'FAIL\n '
399
+ output_str += 'Query: %s\n ' % q
400
+ output_str += 'Predicate pkt counts mismatch:\n '
401
+ output_str += 'Predicate: %s\n ' % pred
402
+ output_str += 'TShark: %d\n ' % tc_pred_pkts
403
+ output_str += 'Bucket: %d\n ' % bc_pred_pkts
404
+ break
405
+ elif abs (tc_pred_bytes - bc_pred_bytes ) > 4 * tc_pred_pkts :
406
+ output_str += 'FAIL\n '
407
+ output_str += 'Query: %s\n ' % q
408
+ output_str += 'Predicate byte count mismatch out of bounds:\n '
409
+ output_str += 'Predicate: %s\n ' % pred
410
+ output_str += 'TShark: %d\n ' % tc_pred_bytes
411
+ output_str += 'Bucket: %d\n ' % bc_pred_bytes
412
+ break
413
+ if output_str == '' :
414
+ output_str += 'PASS\n '
415
+ print output_str
416
+ passfail .write (output_str )
417
+ passfail .close ()
350
418
351
419
### Helpers to extract specific headers from tshark output ###
352
420
ints_map = {}
0 commit comments