xref: /OK3568_Linux_fs/kernel/tools/testing/selftests/tc-testing/TdcPlugin.py (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun#!/usr/bin/env python3
2*4882a593Smuzhiyun
3*4882a593Smuzhiyunclass TdcPlugin:
4*4882a593Smuzhiyun    def __init__(self):
5*4882a593Smuzhiyun        super().__init__()
6*4882a593Smuzhiyun        print(' -- {}.__init__'.format(self.sub_class))
7*4882a593Smuzhiyun
8*4882a593Smuzhiyun    def pre_suite(self, testcount, testidlist):
9*4882a593Smuzhiyun        '''run commands before test_runner goes into a test loop'''
10*4882a593Smuzhiyun        self.testcount = testcount
11*4882a593Smuzhiyun        self.testidlist = testidlist
12*4882a593Smuzhiyun        if self.args.verbose > 1:
13*4882a593Smuzhiyun            print(' -- {}.pre_suite'.format(self.sub_class))
14*4882a593Smuzhiyun
15*4882a593Smuzhiyun    def post_suite(self, index):
16*4882a593Smuzhiyun        '''run commands after test_runner completes the test loop
17*4882a593Smuzhiyun        index is the last ordinal number of test that was attempted'''
18*4882a593Smuzhiyun        if self.args.verbose > 1:
19*4882a593Smuzhiyun            print(' -- {}.post_suite'.format(self.sub_class))
20*4882a593Smuzhiyun
21*4882a593Smuzhiyun    def pre_case(self, caseinfo, test_skip):
22*4882a593Smuzhiyun        '''run commands before test_runner does one test'''
23*4882a593Smuzhiyun        if self.args.verbose > 1:
24*4882a593Smuzhiyun            print(' -- {}.pre_case'.format(self.sub_class))
25*4882a593Smuzhiyun        self.args.caseinfo = caseinfo
26*4882a593Smuzhiyun        self.args.test_skip = test_skip
27*4882a593Smuzhiyun
28*4882a593Smuzhiyun    def post_case(self):
29*4882a593Smuzhiyun        '''run commands after test_runner does one test'''
30*4882a593Smuzhiyun        if self.args.verbose > 1:
31*4882a593Smuzhiyun            print(' -- {}.post_case'.format(self.sub_class))
32*4882a593Smuzhiyun
33*4882a593Smuzhiyun    def pre_execute(self):
34*4882a593Smuzhiyun        '''run command before test-runner does the execute step'''
35*4882a593Smuzhiyun        if self.args.verbose > 1:
36*4882a593Smuzhiyun            print(' -- {}.pre_execute'.format(self.sub_class))
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun    def post_execute(self):
39*4882a593Smuzhiyun        '''run command after test-runner does the execute step'''
40*4882a593Smuzhiyun        if self.args.verbose > 1:
41*4882a593Smuzhiyun            print(' -- {}.post_execute'.format(self.sub_class))
42*4882a593Smuzhiyun
43*4882a593Smuzhiyun    def adjust_command(self, stage, command):
44*4882a593Smuzhiyun        '''adjust the command'''
45*4882a593Smuzhiyun        if self.args.verbose > 1:
46*4882a593Smuzhiyun            print(' -- {}.adjust_command {}'.format(self.sub_class, stage))
47*4882a593Smuzhiyun
48*4882a593Smuzhiyun        # if stage == 'pre':
49*4882a593Smuzhiyun        #     pass
50*4882a593Smuzhiyun        # elif stage == 'setup':
51*4882a593Smuzhiyun        #     pass
52*4882a593Smuzhiyun        # elif stage == 'execute':
53*4882a593Smuzhiyun        #     pass
54*4882a593Smuzhiyun        # elif stage == 'verify':
55*4882a593Smuzhiyun        #     pass
56*4882a593Smuzhiyun        # elif stage == 'teardown':
57*4882a593Smuzhiyun        #     pass
58*4882a593Smuzhiyun        # elif stage == 'post':
59*4882a593Smuzhiyun        #     pass
60*4882a593Smuzhiyun        # else:
61*4882a593Smuzhiyun        #     pass
62*4882a593Smuzhiyun
63*4882a593Smuzhiyun        return command
64*4882a593Smuzhiyun
65*4882a593Smuzhiyun    def add_args(self, parser):
66*4882a593Smuzhiyun        '''Get the plugin args from the command line'''
67*4882a593Smuzhiyun        self.argparser = parser
68*4882a593Smuzhiyun        return self.argparser
69*4882a593Smuzhiyun
70*4882a593Smuzhiyun    def check_args(self, args, remaining):
71*4882a593Smuzhiyun        '''Check that the args are set correctly'''
72*4882a593Smuzhiyun        self.args = args
73*4882a593Smuzhiyun        if self.args.verbose > 1:
74*4882a593Smuzhiyun            print(' -- {}.check_args'.format(self.sub_class))
75