wxMaxima
Loading...
Searching...
No Matches
test
fuzz
fuzz_init.h
1
// Shared helper for the fuzz harnesses.
2
//
3
// wxGTK routes font/DC work through GTK, which needs an X display. Locally we run
4
// the fuzzers under `xvfb-run` (so DISPLAY is already set). In a headless
5
// environment such as OSS-Fuzz there is no display, so we start our own Xvfb
6
// once during initialization. No-op when a display is already available.
7
#ifndef WXM_FUZZ_INIT_H
8
#define WXM_FUZZ_INIT_H
9
10
#include <cstdlib>
11
#include <unistd.h>
12
13
static
inline
void
EnsureDisplay() {
14
if
(getenv(
"DISPLAY"
) || getenv(
"WAYLAND_DISPLAY"
))
15
return
;
16
// Best-effort: requires Xvfb to be installed (the OSS-Fuzz Dockerfile does).
17
if
(system(
"Xvfb :99 -screen 0 1280x1024x24 >/dev/null 2>&1 &"
) == 0) {
18
setenv(
"DISPLAY"
,
":99"
, 1);
19
sleep(1);
// let Xvfb come up before GTK connects
20
}
21
}
22
23
#endif
Generated by
1.9.6