aboutsummaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/base/targetrunner.py
blob: 4e988a8eb933c4f4a6d05679fcdc7d2786a92227 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
# Copyright (C) 2013 Intel Corporation
#
# Released under the MIT license (see COPYING.MIT)

# test runner which support run testing on target device

"""test runner for target device"""
import sys
from optparse import make_option
from baserunner import TestRunnerBase

class TargetTestRunner(TestRunnerBase):
    '''test runner which support target DUT access'''
    def __init__(self, context=None):
        super(TargetTestRunner, self).__init__(context)
        self.option_list.extend([
            make_option("-c", "--controller", dest="controller",
                    help="the target controller to bridge host and target")])

    def _get_arg_val(self, dest_name, store_val=True):
        '''get arg value from testrunner args'''
        args = sys.argv
        for opt in self.option_list:
            if opt.dest == dest_name:
                arg_names = opt._short_opts + opt._long_opts
                break
        else:
            return None

        for cur_arg in arg_names:
            try:
                ind = args.index(cur_arg)
                return args[ind+1] if store_val else True
            except:
                pass
        return None

    def configure(self, options):
        '''configure before testing'''
        super(TargetTestRunner, self).configure(options)
        print "configure target test runner"

if __name__ == "__main__":
    runner = TargetTestRunner()
    runner.configure(runner.get_options())
    suite = runner.filtertest(runner.loadtest())
    print "Found %s tests" % suite.countTestCases()
    runner.start(suite)