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