Ilia Samsonov | a0083530 | 2019-04-19 17:37:59 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright (c) 2019 The Chromium Authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | """Simple script for xvfb_unittest to launch. |
| 7 | |
| 8 | This script outputs formatted data to stdout for the xvfb unit tests |
| 9 | to read and compare with expected output. |
| 10 | """ |
| 11 | |
| 12 | import os |
| 13 | import signal |
| 14 | import sys |
| 15 | import time |
| 16 | |
| 17 | |
| 18 | def print_signal(sig, *_): |
| 19 | print 'Signal :{}'.format(sig) |
| 20 | |
| 21 | |
| 22 | if __name__ == '__main__': |
| 23 | signal.signal(signal.SIGTERM, print_signal) |
| 24 | signal.signal(signal.SIGINT, print_signal) |
| 25 | |
| 26 | # test if inside xvfb flag is set. |
| 27 | print 'Inside_xvfb :{}'.format( |
| 28 | os.environ.get('_CHROMIUM_INSIDE_XVFB', 'None')) |
| 29 | # test the subprocess display number. |
| 30 | print 'Display :{}'.format(os.environ.get('DISPLAY', 'None')) |
| 31 | |
| 32 | if len(sys.argv) > 1 and sys.argv[1] == '--sleep': |
| 33 | time.sleep(2) # gives process time to receive signal. |