i3 - improved tiling WM


Testcases: rename StartXDummy to StartXServer

Patch status: merged

Patch by Tony Crisci

Long description:

Rename the package StartXDummy to StartXServer in the testcases library
because XDummy is no longer used.

No logic changes.

To apply this patch, use:
curl http://cr.i3wm.org/patch/652/raw.patch | git am

b/testcases/complete-run.pl

21
@@ -19,7 +19,7 @@ use Time::HiRes qw(time);
22
 use IO::Handle;
23
 # these are shipped with the testsuite
24
 use lib qw(lib);
25
-use StartXDummy;
26
+use StartXServer;
27
 use StatusLine;
28
 use TestWorker;
29
 # the following modules are not shipped with Perl
30
@@ -133,7 +133,7 @@ for my $display (@displays) {
31
 
32
 # Read previous timing information, if available. We will be able to roughly
33
 # predict the test duration and schedule a good order for the tests.
34
-my $timingsjson = StartXDummy::slurp('.last_run_timings.json');
35
+my $timingsjson = StartXServer::slurp('.last_run_timings.json');
36
 %timings = %{decode_json($timingsjson)} if length($timingsjson) > 0;
37
 
38
 # Re-order the files so that those which took the longest time in the previous
39
@@ -222,7 +222,7 @@ printf("\t%s with %.2f seconds\n", $_, $timings{$_})
40
 if ($numtests == 1) {
41
     say '';
42
     say 'Test output:';
43
-    say StartXDummy::slurp($logfile);
44
+    say StartXServer::slurp($logfile);
45
 }
46
 
47
 END { cleanup() }

/dev/null

53
@@ -1,122 +0,0 @@
54
-package StartXDummy;
55
-# vim:ts=4:sw=4:expandtab
56
-
57
-use strict;
58
-use warnings;
59
-use Exporter 'import';
60
-use Time::HiRes qw(sleep);
61
-use v5.10;
62
-
63
-our @EXPORT = qw(start_xserver);
64
-
65
-my @pids;
66
-my $x_socketpath = '/tmp/.X11-unix/X';
67
-
68
-# reads in a whole file
69
-sub slurp {
70
-    open(my $fh, '<', shift) or return '';
71
-    local $/;
72
-    <$fh>;
73
-}
74
-
75
-# forks an X server process
76
-sub fork_xserver {
77
-    my $keep_xserver_output = shift;
78
-    my $displaynum = shift;
79
-    my $pid = fork();
80
-    die "Could not fork: $!" unless defined($pid);
81
-    if ($pid == 0) {
82
-        # Child, close stdout/stderr, then start Xephyr
83
-        if (!$keep_xserver_output) {
84
-            close STDOUT;
85
-            close STDERR;
86
-        }
87
-
88
-        exec @_;
89
-        exit 1;
90
-    }
91
-    push(@complete_run::CLEANUP, sub {
92
-        kill(15, $pid);
93
-        # Unlink the X11 socket, Xdmx seems to leave it there.
94
-        unlink($x_socketpath . $displaynum);
95
-    });
96
-
97
-    push @pids, $pid;
98
-
99
-    return $x_socketpath . $displaynum;
100
-}
101
-
102
-# Blocks until the socket paths specified in the given array reference actually
103
-# exist.
104
-sub wait_for_x {
105
-    my ($sockets_waiting) = @_;
106
-
107
-    # Wait until Xdmx actually runs. Pretty ugly solution, but as long as we
108
-    # can’t socket-activate X11…
109
-    while (1) {
110
-        @$sockets_waiting = grep { ! -S $_ } @$sockets_waiting;
111
-        last unless @$sockets_waiting;
112
-        sleep 0.1;
113
-    }
114
-}
115
-
116
-=head2 start_xserver($parallel)
117
-
118
-Starts C<$parallel> (or number of cores * 2 if undef) Xephyr processes (see
119
-http://www.freedesktop.org/wiki/Software/Xephyr/) and returns two arrayrefs: a
120
-list of X11 display numbers to the Xephyr processes and a list of PIDs of the
121
-processes.
122
-
123
-=cut
124
-
125
-sub start_xserver {
126
-    my ($parallel, $numtests, $keep_xserver_output) = @_;
127
-
128
-    my @displays = ();
129
-    my @childpids = ();
130
-
131
-    $SIG{CHLD} = sub {
132
-        my $child = waitpid -1, POSIX::WNOHANG;
133
-        @pids = grep { $_ != $child } @pids;
134
-        return unless @pids == 0;
135
-        print STDERR "All X server processes died.\n";
136
-        print STDERR "Use ./complete-run.pl --parallel 1 --keep-xserver-output\n";
137
-        exit 1;
138
-    };
139
-
140
-    # Yeah, I know it’s non-standard, but Perl’s POSIX module doesn’t have
141
-    # _SC_NPROCESSORS_CONF.
142
-    my $cpuinfo = slurp('/proc/cpuinfo');
143
-    my $num_cores = scalar grep { /model name/ } split("\n", $cpuinfo);
144
-    # If /proc/cpuinfo does not exist, we fall back to 2 cores.
145
-    $num_cores ||= 2;
146
-
147
-    # If unset, we use num_cores * 2.
148
-    $parallel ||= ($num_cores * 2);
149
-
150
-    # If we are running a small number of tests, don’t over-parallelize.
151
-    $parallel = $numtests if $numtests < $parallel;
152
-
153
-    # First get the last used display number, then increment it by one.
154
-    # Effectively falls back to 1 if no X server is running.
155
-    my ($displaynum) = map { /(\d+)$/ } reverse sort glob($x_socketpath . '*');
156
-    $displaynum++;
157
-
158
-    say "Starting $parallel Xephyr instances, starting at :$displaynum...";
159
-
160
-    my @sockets_waiting;
161
-    for (1 .. $parallel) {
162
-        my $socket = fork_xserver($keep_xserver_output, $displaynum,
163
-                'Xephyr', ":$displaynum", '-screen', '1280x800',
164
-                '-nolisten', 'tcp');
165
-        push(@displays, ":$displaynum");
166
-        push(@sockets_waiting, $socket);
167
-        $displaynum++;
168
-    }
169
-
170
-    wait_for_x(\@sockets_waiting);
171
-
172
-    return @displays;
173
-}
174
-
175
-1

b/testcases/lib/StartXServer.pm

181
@@ -0,0 +1,122 @@
182
+package StartXServer;
183
+# vim:ts=4:sw=4:expandtab
184
+
185
+use strict;
186
+use warnings;
187
+use Exporter 'import';
188
+use Time::HiRes qw(sleep);
189
+use v5.10;
190
+
191
+our @EXPORT = qw(start_xserver);
192
+
193
+my @pids;
194
+my $x_socketpath = '/tmp/.X11-unix/X';
195
+
196
+# reads in a whole file
197
+sub slurp {
198
+    open(my $fh, '<', shift) or return '';
199
+    local $/;
200
+    <$fh>;
201
+}
202
+
203
+# forks an X server process
204
+sub fork_xserver {
205
+    my $keep_xserver_output = shift;
206
+    my $displaynum = shift;
207
+    my $pid = fork();
208
+    die "Could not fork: $!" unless defined($pid);
209
+    if ($pid == 0) {
210
+        # Child, close stdout/stderr, then start Xephyr
211
+        if (!$keep_xserver_output) {
212
+            close STDOUT;
213
+            close STDERR;
214
+        }
215
+
216
+        exec @_;
217
+        exit 1;
218
+    }
219
+    push(@complete_run::CLEANUP, sub {
220
+        kill(15, $pid);
221
+        # Unlink the X11 socket, Xdmx seems to leave it there.
222
+        unlink($x_socketpath . $displaynum);
223
+    });
224
+
225
+    push @pids, $pid;
226
+
227
+    return $x_socketpath . $displaynum;
228
+}
229
+
230
+# Blocks until the socket paths specified in the given array reference actually
231
+# exist.
232
+sub wait_for_x {
233
+    my ($sockets_waiting) = @_;
234
+
235
+    # Wait until Xdmx actually runs. Pretty ugly solution, but as long as we
236
+    # can’t socket-activate X11…
237
+    while (1) {
238
+        @$sockets_waiting = grep { ! -S $_ } @$sockets_waiting;
239
+        last unless @$sockets_waiting;
240
+        sleep 0.1;
241
+    }
242
+}
243
+
244
+=head2 start_xserver($parallel)
245
+
246
+Starts C<$parallel> (or number of cores * 2 if undef) Xephyr processes (see
247
+http://www.freedesktop.org/wiki/Software/Xephyr/) and returns two arrayrefs: a
248
+list of X11 display numbers to the Xephyr processes and a list of PIDs of the
249
+processes.
250
+
251
+=cut
252
+
253
+sub start_xserver {
254
+    my ($parallel, $numtests, $keep_xserver_output) = @_;
255
+
256
+    my @displays = ();
257
+    my @childpids = ();
258
+
259
+    $SIG{CHLD} = sub {
260
+        my $child = waitpid -1, POSIX::WNOHANG;
261
+        @pids = grep { $_ != $child } @pids;
262
+        return unless @pids == 0;
263
+        print STDERR "All X server processes died.\n";
264
+        print STDERR "Use ./complete-run.pl --parallel 1 --keep-xserver-output\n";
265
+        exit 1;
266
+    };
267
+
268
+    # Yeah, I know it’s non-standard, but Perl’s POSIX module doesn’t have
269
+    # _SC_NPROCESSORS_CONF.
270
+    my $cpuinfo = slurp('/proc/cpuinfo');
271
+    my $num_cores = scalar grep { /model name/ } split("\n", $cpuinfo);
272
+    # If /proc/cpuinfo does not exist, we fall back to 2 cores.
273
+    $num_cores ||= 2;
274
+
275
+    # If unset, we use num_cores * 2.
276
+    $parallel ||= ($num_cores * 2);
277
+
278
+    # If we are running a small number of tests, don’t over-parallelize.
279
+    $parallel = $numtests if $numtests < $parallel;
280
+
281
+    # First get the last used display number, then increment it by one.
282
+    # Effectively falls back to 1 if no X server is running.
283
+    my ($displaynum) = map { /(\d+)$/ } reverse sort glob($x_socketpath . '*');
284
+    $displaynum++;
285
+
286
+    say "Starting $parallel Xephyr instances, starting at :$displaynum...";
287
+
288
+    my @sockets_waiting;
289
+    for (1 .. $parallel) {
290
+        my $socket = fork_xserver($keep_xserver_output, $displaynum,
291
+                'Xephyr', ":$displaynum", '-screen', '1280x800',
292
+                '-nolisten', 'tcp');
293
+        push(@displays, ":$displaynum");
294
+        push(@sockets_waiting, $socket);
295
+        $displaynum++;
296
+    }
297
+
298
+    wait_for_x(\@sockets_waiting);
299
+
300
+    return @displays;
301
+}
302
+
303
+1