aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/agl_test_utils.py
blob: b1204a036303018956ae1d2c1b2e325ae525b8e2 (plain)
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
import subprocess

from plugins.agl_test_conf import REPORT_LOGS_DIR
from plugins.agl_test_conf import TMP_LOGS_DIR
from plugins.agl_test_conf import TMP_TEST_REPORT


#Check if there is the command that we needed
def find_cmd(cmd):
    output = subprocess.run(['which',cmd],stdout=subprocess.PIPE)
    if output.returncode==0:
        return 0
    else:
        print("error: {} is not found".format(cmd))
        return 1

#Make dir for THIS_TEST to save the log
def create_dir(THIS_TEST):
    TMP_THIS_TEST_LOG = TMP_LOGS_DIR + THIS_TEST + "/log/"
    TMP_TEST_REPORT_THIS = TMP_TEST_REPORT + THIS_TEST
    subprocess.run(['mkdir','-p',TMP_THIS_TEST_LOG])
    subprocess.run(['mkdir','-p',TMP_TEST_REPORT_THIS])

# print errors
def printe(msg):
    print("**** ERROR: " + msg)

# print debug info
def printd(msg):
    # TODO
    print("==== DEBUG: " + msg)