15

I'm attempting to automate some tests of a GUI application on a headless Mac.

I'm able to run theses tests from the terminal on a desktop Mac, and there's no issues and they run as expected (without popping up a window). However, when I attempt to run them on a headless server, I'm not able to get them to work. They error out with issues related to getting a display. (Specifically, CGLChoosePixelFormat() is returning an error.)

For our Linux platform tests, we've had similar issues, and can solve that by using xvfb to create a "virtual" display.

Looking around, it does seems like it is possible to use xvfb itself on Mac ... if you install a whole X display subsystem first. This seems rather suboptimal to me. Ideally, I'd like to test on Mac using the same display system a regular Mac uses, not a different, testing-only display system.

Is there an equivalent to xvfb for the native Mac display? That is, is there a way to launch a "virtual" display on a headless Mac server?

R.M.
  • 261
  • Virtual displays definitely exist on macOS. – user7886229 Jul 25 '18 at 16:23
  • https://serverfault.com/questions/239075/xvfb-alternative-for-mac-server – user7886229 Jul 25 '18 at 16:26
  • https://stackoverflow.com/questions/25451133/xvfb-run-on-os-x/32786365#32786365 – user7886229 Jul 25 '18 at 16:27
  • @JBis If you know of a virtual display on macOS which use the native Mac display system and can be used for automated testing on a headless Mac, I welcome that as an answer. However, those links don't really address the issue. The latter's answer is to install X on Mac - which is what I'm trying to avoid. What the former adds to that is about manual interaction with the GUI (remote desktop), not automated testing. – R.M. Jul 25 '18 at 16:44
  • The X-11 system is required to run any of those types of programs. Why don't you want to install it? – user7886229 Jul 25 '18 at 16:46
  • @JBis Partly because I want to test with the same windowing system (native Mac) as we normally run with, but mostly because I suspect that if I post "I'm having problems running xvfb on a headless Mac" type questions here, I'll get a bunch of "Why do you want to run xvfb on a Mac? Macs don't use X-11! Use instead." type comments. I asked this question to try to skip the intermediate stages and figure out what is from the start. – R.M. Jul 25 '18 at 17:13
  • We appreciate you not asking X-Y problem questions. | I am not understanding "with the same windowing system (native Mac) as we normally run with". Xquatrtz is a version of the same X Window System on the Linux machines so you are effectively using the same setup just a version for Mac. | But either way why do you care about using the same exact setup. A slight modification won't impact anything major and will have the same results. – user7886229 Jul 25 '18 at 17:20
  • The tests on Mac are to test how things run on Macs. By "normally run with" I meant "normally run with on Macs". In a typical Mac installation, X-11 isn't installed. -- I'm not dead set against installing X-11/Xquatrtz, I'd just prefer to avoid it if there's a workable alternative ... hence this question to figure out if there's a workable alternative. – R.M. Jul 25 '18 at 17:25
  • I think this is an instance where "if its not broken don't fix it" holds true. I would just suggest install X-11. +1 anyway. It's a good question just may not need an answer. – user7886229 Jul 25 '18 at 17:27
  • Consider using virtual machines on a Mac running macOS as a guest in the VM. That should simulate it enough to run your tests. – James Brickley May 27 '21 at 03:28
  • @JamesBrickley Which machines the tests are running on are fixed. They don't have displays. If there's a way to run a guest-OS with a (pseudo)display on a host-OS and host machine without a display, that's probably worth an answer, but would likely require details about the specifics to get it to work. (e.g. how do you convince the guest that there's a working display when the host doesn't have one.) – R.M. May 27 '21 at 15:32
  • Virtual machines emulate the hardware. Therefore there will be a native macOS display within the VM. Where headless physical machine might have an issue. Another advantage of VMs is you can run multiple on the same physical host and for testing, snapshot and rollback as needed would be quite useful. FYI, VMware ESXi runs on Macs. As does Docker and Kubernetes depending on specific needs. – James Brickley May 27 '21 at 16:00

2 Answers2

4

I don't think a xvfb-equivalent is required (Mac OS X provides the required parts).

We use EDID emulator/dummy plugs to do this on a large fleet of Mac Minis that test desktop applications. The plugs emulate a display so the GPU and associated parts of the OS activate.

The new M1 Mac Minis don't seem to require the plugs (it just works).

aerickson
  • 101
3

you can install it from https://www.xquartz.org/ or with homebrew by

brew install XQuartz