[go: nahoru, domu]

blob: 4feb330a98f05ee846ec09c72e3556354a81deb6 [file] [log] [blame]
Ilia Samsonova00835302019-04-19 17:37:591#!/usr/bin/env python
Avi Drissmandfd880852022-09-15 20:11:092# Copyright 2019 The Chromium Authors
Ilia Samsonova00835302019-04-19 17:37:593# 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
8This script outputs formatted data to stdout for the xvfb unit tests
9to read and compare with expected output.
10"""
11
Wenbin Zhangc56b1252021-10-05 02:49:0612from __future__ import print_function
13
Ilia Samsonova00835302019-04-19 17:37:5914import os
15import signal
16import sys
17import time
18
19
20def print_signal(sig, *_):
Matt Reichhoff36f6901c2021-11-09 18:40:1521 # print_function does not guarantee its output won't be interleaved
22 # with other logging elsewhere, but it does guarantee its output
23 # will appear intact. Because the tests parse via starts_with, prefix
24 # with a newline. These tests were previously flaky due to output like
25 # > Signal: 1 <other messages>.
26 print('\nSignal :{}'.format(sig))
Ilia Samsonova00835302019-04-19 17:37:5927
28
29if __name__ == '__main__':
30 signal.signal(signal.SIGTERM, print_signal)
31 signal.signal(signal.SIGINT, print_signal)
32
Ilia Samsonova00835302019-04-19 17:37:5933 # test the subprocess display number.
Matt Reichhoff36f6901c2021-11-09 18:40:1534 print('\nDisplay :{}'.format(os.environ.get('DISPLAY', 'None')))
Ilia Samsonova00835302019-04-19 17:37:5935
36 if len(sys.argv) > 1 and sys.argv[1] == '--sleep':
37 time.sleep(2) # gives process time to receive signal.