tests: add inject_randr15 (#2573)

This tool is similar to xtrace in usage in that it intercepts traffic to
the X server. The motivating feature for writing the tool is its ability
to inject prepared reply messages instead of the server’s reply. In
this particular case, we’ll inject a RRGetMonitors reply to test i3’s
RandR 1.5 code paths.

The added testcase is a noop for now, but with the code that’s lingering
in the randr15 branch, i3 does actually detect monitors as per the
injected reply:

    2016-11-20 21:10:05 - randr.c:__randr_query_outputs:618 -
      RandR 1.5 available, querying monitors
    2016-11-20 21:10:05 - randr.c:__randr_query_outputs:628 -
      1 RandR monitors found (timestamp 0)
    2016-11-20 21:10:05 - randr.c:__randr_query_outputs:646 -
      name DP3, x 0, y 0, width 3840 px, height 2160 px, width 520 mm,
      height 290 mm, primary 1, automatic 1

This is preparation work for issue #1799
This commit is contained in:
Michael Stapelberg
2016-11-20 23:20:14 -08:00
committed by GitHub
parent aa20c416c3
commit 3e7a07e48d
5 changed files with 543 additions and 2 deletions

View File

@ -88,7 +88,10 @@ sub activate_i3 {
# the interactive signalhandler to make it crash immediately instead.
# Also disable logging to SHM since we redirect the logs anyways.
# Force Xinerama because we use Xdmx for multi-monitor tests.
my $i3cmd = q|i3 --shmlog-size=0 --disable-signalhandler --force-xinerama|;
my $i3cmd = q|i3 --shmlog-size=0 --disable-signalhandler|;
if (!defined($args{inject_randr15})) {
$i3cmd .= q| --force-xinerama|;
}
if (!$args{validate_config}) {
# We only set logging if i3 is actually started, but not if we only
# validate the config file. This is to keep logging to a minimum as
@ -139,6 +142,13 @@ sub activate_i3 {
'sh -c "export LISTEN_PID=\$\$; ' . $cmd . '"';
}
if ($args{inject_randr15}) {
# See comment in $args{strace} branch.
$cmd = 'test.inject_randr15 --getmonitors_reply="' .
$args{inject_randr15} . '" -- ' .
'sh -c "export LISTEN_PID=\$\$; ' . $cmd . '"';
}
# We need to use the shell due to using output redirections.
exec '/bin/sh', '-c', $cmd;