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