xref: /OK3568_Linux_fs/u-boot/test/py/test.py (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun#!/usr/bin/env python2
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun# Copyright (c) 2015 Stephen Warren
4*4882a593Smuzhiyun# Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
5*4882a593Smuzhiyun#
6*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0
7*4882a593Smuzhiyun
8*4882a593Smuzhiyun# Wrapper script to invoke pytest with the directory name that contains the
9*4882a593Smuzhiyun# U-Boot tests.
10*4882a593Smuzhiyun
11*4882a593Smuzhiyunimport os
12*4882a593Smuzhiyunimport os.path
13*4882a593Smuzhiyunimport sys
14*4882a593Smuzhiyun
15*4882a593Smuzhiyun# Get rid of argv[0]
16*4882a593Smuzhiyunsys.argv.pop(0)
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun# argv; py.test test_directory_name user-supplied-arguments
19*4882a593Smuzhiyunargs = ['py.test', os.path.dirname(__file__) + '/tests']
20*4882a593Smuzhiyunargs.extend(sys.argv)
21*4882a593Smuzhiyun
22*4882a593Smuzhiyuntry:
23*4882a593Smuzhiyun    os.execvp('py.test', args)
24*4882a593Smuzhiyunexcept:
25*4882a593Smuzhiyun    # Log full details of any exception for detailed analysis
26*4882a593Smuzhiyun    import traceback
27*4882a593Smuzhiyun    traceback.print_exc()
28*4882a593Smuzhiyun    # Hint to the user that they likely simply haven't installed the required
29*4882a593Smuzhiyun    # dependencies.
30*4882a593Smuzhiyun    print >>sys.stderr, '''
31*4882a593Smuzhiyunexec(py.test) failed; perhaps you are missing some dependencies?
32*4882a593SmuzhiyunSee test/py/README.md for the list.'''
33*4882a593Smuzhiyun    sys.exit(1)
34