| 80 | |
| 81 | |
| 82 | def generate_test_method(path): |
| 83 | def template(self): |
| 84 | try: |
| 85 | run_cmd('%s run file %s' % (bessctl, path)) |
| 86 | except CommandError: |
| 87 | # bessd may have crashed. Relaunch for next tests. |
| 88 | run_cmd('%s daemon start' % bessctl) |
| 89 | raise |
| 90 | |
| 91 | # 0.5 seconds should be enough to detect packet leaks in the datapath. |
| 92 | time.sleep(0.5) |
| 93 | |
| 94 | # Check if bessd crushed. |
| 95 | try: |
| 96 | run_cmd('%s show version' % bessctl) |
| 97 | run_cmd('%s daemon reset' % bessctl) |
| 98 | except CommandError: |
| 99 | # bessd may have crashed. Relaunch for next tests. |
| 100 | run_cmd('%s daemon start' % bessctl) |
| 101 | raise |
| 102 | |
| 103 | return template |
| 104 | |
| 105 | |
| 106 | for root, _, file_names in os.walk(sample_dir): |