Wish a headless mode, triggered by command line option
Closed this issue · 3 comments
Context
For a number of years I've been using caprice32 for automated tests in cpc-dev-tool-chain. For every test the test bench runs an instance of caprice32 with a command line looks like cap32 $(DSKNAME) -c cap32_fortest.cfg -a 'run"$(PROJNAME)' -a CAP32_WAITBREAKCAP32_SCRNSHOT -a CAP32_EXIT
where CAP32_WAITBREAK
was implemented in #112.
Situation
It was nice initially that a window appears to monitor the test progress. But:
- Sometimes I'm typing something in another window while the tested thing compiles, then the test launches, a window appears and gets keypresses from what I'm typing, which breaks the
run"sometest
command line and lets the emulator sits idle until I close it, failing the test. A non-regression test should run isolated. - As I add more tests, a number of emulator windows appear then disappear until all tests run, disrupting usability of the desktop while tests run.
- Thinking about it, an unattended test suite should not need a graphical display at all.
Wish
I wish a command line argument, like --headless
, with the following effect:
- No window opens.
- No window -> no interactive event
- No interactive event -> no desktop or test disruption (obligatory reference)
Turns out this is very easy, ref. Possible to run SDL2 headless? - SDL Development - Simple Directmedia Layer.
Before call to SDL_Init()
add SDL_SetHint(SDL_HINT_VIDEODRIVER, "offscreen");
I'm writing code for it and will open a PR.
Having a command line argument sounds good but IIRC you can already do this with an environment variable (SDL_VIDEO_DRIVER if my memory serves me well)
Having a command line argument sounds good but IIRC you can already do this with an environment variable (SDL_VIDEO_DRIVER if my memory serves me well)
Indeed, using SDL_VIDEODRIVER=dummy
does the same in practice on my setup (actually render graphics in-memory, allowing screenshots to PNG). Surprisingly, SDL_VIDEODRIVER=offscreen
also exists and in practice has the same result.
We can ditch this PR, my tests will simply use SDL_VIDEODRIVER=dummy
and SDL_AUDIODRIVER=dummy
. I confirmed using strace that the process does not try to reach X or a pulse-compatible sound service.
Thanks. Don't hesitate should you need any other feature!