-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
34 lines (32 loc) · 1.52 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# FIO Automated Testing - Daniel Zhou
import yaml
import argparse
import os
import time
import platform
import tester
from dotenv import load_dotenv
load_dotenv()
#If you use -f argument, loads configuration from file, otherwise uses defaults (If options arent fully specified default overrides)
parser = argparse.ArgumentParser()
parser.add_argument("-f", "--filename", help="configuration file FIOTester should use")
parser.add_argument("-d", "--device", help="device name FIOTester should write to")
parser.add_argument("-n", "--test_name", help="names the test")
args = parser.parse_args()
with open("defaults.yml") as default:
defaults = yaml.safe_load(default)
with open("precondition.yml") as precondition:
precondition = yaml.safe_load(precondition)
if args.filename and args.device and args.test_name:
with open(args.filename) as file:
config = yaml.safe_load(file)
precondition = config.get("precondition")
if precondition:
config.remove("precondition")
tester.run_test_from_file(platform.system(), args.device, args.test_name + " precondition", precondition,
precondition)
tester.run_test_from_file(platform.system(), args.device, args.test_name, config, defaults)
elif args.device and args.test_name:
tester.run_test_from_file(platform.system(), args.device, args.test_name, defaults, defaults)
else:
print(" Please select a device name using the -d flag and a test name using the -n flag")