-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from smitterl/avocado_list
[filter_avocado_list] add script to integrate with avocado list
- Loading branch information
Showing
3 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import re | ||
import subprocess | ||
import sys | ||
from filter import pairwise | ||
|
||
# holds the vt only filter | ||
ONLY = [] | ||
PRINT_ORIGINAL = False | ||
SHOW_STATS = False | ||
|
||
def print_help(exit_code): | ||
print(sys.argv[0] + " [-t] [-s] <--vt-only-filter argument>") | ||
print() | ||
print(" <vt-only-filter> is a comma separated list of test names") | ||
print(" by passing flag -t the avocado command result is printed and not filtered") | ||
print(" by passing flag -s the number of original test names and filtered ones are shown") | ||
sys.exit(exit_code) | ||
|
||
def parse_args(): | ||
if len(sys.argv) == 1: | ||
print_help(1) | ||
|
||
global ONLY | ||
ONLY = sys.argv[-1] | ||
|
||
if ONLY.startswith("-h"): | ||
print_help(0) | ||
|
||
if "-t" in sys.argv: | ||
global PRINT_ORIGINAL | ||
PRINT_ORIGINAL = True | ||
|
||
if "-s" in sys.argv: | ||
global SHOW_STATS | ||
SHOW_STATS = True | ||
|
||
def get_avocado_list(): | ||
test_names = [] | ||
command = ("avocado list --vt-type libvirt --vt-machine-type s390-virtio" | ||
" --vt-only-filter %s --paginator off" % ONLY) | ||
output = subprocess.check_output(command, shell=True).decode() | ||
for row in output.split('\n'): | ||
if not row.startswith("VT"): | ||
continue | ||
test_names.append(re.sub("VT\\s+.*autotest-libvirt.", "", row)) | ||
return test_names | ||
|
||
|
||
if __name__ == '__main__': | ||
parse_args() | ||
test_names = get_avocado_list() | ||
if PRINT_ORIGINAL: | ||
for name in test_names: | ||
print(name) | ||
sys.exit(0) | ||
|
||
filtered_test_names = pairwise(test_names) | ||
for name in filtered_test_names: | ||
print(name) | ||
|
||
if SHOW_STATS: | ||
print() | ||
print("The number of test cases was reduced" | ||
" from %s to %s." % (len(test_names), | ||
len(filtered_test_names))) |