1# Copyright 2014 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5 6from pylib.gtest import gtest_test_instance 7from pylib.instrumentation import instrumentation_test_instance 8from pylib.junit import junit_test_instance 9from pylib.monkey import monkey_test_instance 10from pylib.utils import device_dependencies 11 12 13def CreateTestInstance(args, error_func): 14 15 if args.command == 'gtest': 16 return gtest_test_instance.GtestTestInstance( 17 args, device_dependencies.GetDataDependencies, error_func) 18 if args.command == 'instrumentation': 19 return instrumentation_test_instance.InstrumentationTestInstance( 20 args, device_dependencies.GetDataDependencies, error_func) 21 if args.command == 'junit': 22 return junit_test_instance.JunitTestInstance(args, error_func) 23 if args.command == 'monkey': 24 return monkey_test_instance.MonkeyTestInstance(args, error_func) 25 26 error_func('Unable to create %s test instance.' % args.command) 27 raise RuntimeError('error_func must call exit inside.') 28