Open mikepurvis opened 11 years ago
I agree that making the tests more flexible and portable would be awesome. Do you think the virtual serial program is better than the pty slaving?
For Windows it seems difficult to setup something automated, but it would be really nice.
Well, the vserver program is pty slaving. :)
I can't see either how it could be automated on Windows—but by switching to testing with a pair of Serial instances rather than a Serial instance and an fd, we'd have the capability to at least run manually on Windows the tests that are automatic on linux/darwin.
An alternative to bringing in more source and another binary is just using socat for this—the following invocation wires a pair of /dev/pts devices to each other.
socat -d -d pty,link=/tmp/tty1,raw,echo=0 pty,link=/tmp/tty2,raw,echo=0
Will experiment a bit and see if this could be workable for testing things like timing.
Windows have these days CONPTY devices which are modeled from the traditional Unix PTY devices. This is new stuff with possible rough corners, but looking at the docs it looks like a descent replacement for the Unix PTYs in the test code.
Right now, the test source advertises that you need a hardware loopback, which isn't actually the case: it hooks up a Serial instance to a pty slave and talks to it using the corresponding master fd, all very posix-centric voodoo.
The obvious advantage of doing tests through a loopback is that the same test source could test both implementations—either using a hardware peripheral or software loopbacks.
On Windows, the magical com0com driver can provide a pair of virtual serial ports connected up to each other.
On Linux, we actually used to ship with Kingfisher a simple virtual serial program which did the same thing—provided a serial loopback pair.
At least on Linux, it could be automatic: the CMake target which runs the tests would have some pre- and post- rules attached to it which bring up and down the loopback, and then pass the port names/strings into the test via environment variables. It being automatic would allow the tests to run on Travis (which does not presently happen, but probably should).