0
Files
src/testing/xvfb_test_script.py
Ilia Samsonov a0083530d7 [Test Automation] Use xvfb directly instead of xvfb-run
Thereby fix signal handling for SIGTERM and SIGINT.

The steps needed to start Xvfb are drawn from:
https://github.com/cgoldberg/xvfbwrapper/blob/master/xvfbwrapper.py
https://github.com/revnode/xvfb-run/blob/master/xvfb-run

Added unit tests to presubmit to test xvfb.py


Bug: 932240
Change-Id: I3b9439991697ae94e98b93e4f1fcfd411a451536
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1548424
Commit-Queue: Ilia Samsonov <isamsonov@google.com>
Reviewed-by: Caleb Rouleau <crouleau@chromium.org>
Reviewed-by: Marc-Antoine Ruel <maruel@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Reviewed-by: John Chen <johnchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652562}
2019-04-19 17:37:59 +00:00

34 lines
925 B
Python
Executable File

#!/usr/bin/env python
# Copyright (c) 2019 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Simple script for xvfb_unittest to launch.
This script outputs formatted data to stdout for the xvfb unit tests
to read and compare with expected output.
"""
import os
import signal
import sys
import time
def print_signal(sig, *_):
print 'Signal :{}'.format(sig)
if __name__ == '__main__':
signal.signal(signal.SIGTERM, print_signal)
signal.signal(signal.SIGINT, print_signal)
# test if inside xvfb flag is set.
print 'Inside_xvfb :{}'.format(
os.environ.get('_CHROMIUM_INSIDE_XVFB', 'None'))
# test the subprocess display number.
print 'Display :{}'.format(os.environ.get('DISPLAY', 'None'))
if len(sys.argv) > 1 and sys.argv[1] == '--sleep':
time.sleep(2) # gives process time to receive signal.