9.9 KiB
End-to-end tests
These drive the built CLI as a subprocess against Siemens phones. By default the phone is real firmware running under pmb887x-emu, so every listing, transfer and delete goes through the phone's own AT interpreter and FlexMem OBEX server, over a serial link QEMU exposes as a TCP chardev.
pnpm test:e2e
The same suite runs against a phone on a cable, which is the only way to cover a real link and a real flash:
SIEOBEX_E2E_DEVICE=/dev/ttyUSB0 pnpm test:e2e:device
cliSuite(target) is what both share. A PhoneTarget (target.ts) is
either an emulator the suite boots, with its model and directories known
from the table in emulator.ts, or the phone on the other end of
SIEOBEX_E2E_DEVICE, which is whatever someone plugged in.
Against a real phone
| Variable | Default | What it is |
|---|---|---|
SIEOBEX_E2E_DEVICE |
— | the port, e.g. /dev/ttyUSB0; without it the suite skips |
SIEOBEX_E2E_DIR |
/Data/Misc |
a directory the tests may write into |
SIEOBEX_E2E_SMALL_FILES_DIR |
/ |
a directory to list |
SIEOBEX_E2E_RECONNECT_WAIT_MS |
5000 |
the pause before connecting again |
SIEOBEX_E2E_READY_TIMEOUT_MS |
45000 |
how long to keep trying the first connect |
SIEOBEX_E2E_BAUDRATE |
— | pin the handshake speed instead of probing |
SIEOBEX_E2E_BAUDRATES |
115200,57600,19200 |
the speeds to run a session at, one each; empty skips |
SIEOBEX_E2E_VERBOSE |
— | 1 logs every CLI command and how long it took |
It writes to the phone. Inside SIEOBEX_E2E_DIR it creates
sieobex-e2e.bin and a sieobex-tree folder, reads them back, and deletes
them again. It touches nothing else and never writes outside that directory,
but it is a real file system: point it somewhere of no consequence.
SIEOBEX_E2E_DIR has to name a directory below the root, and the root
itself is refused.
The default for SIEOBEX_E2E_DIR suits SGOLD and NewSGOLD phones. An EGOLD
phone needs one of its own folders instead: a C60 lists a Data in its root
but refuses to enter it (setpath to "Data" failed: Forbidden), and keeps
Sounds, Pictures, Java, Animations, tmp and the rest directly in
the root. Before any test runs, the suite lists the directory and pushes a
32 byte file into it, so the wrong one fails in a second with the phone's own
answer and a listing of its root, rather than eight tests later.
Baud rates
Two of the tests are about the link speed itself. One pins a session to
each rate in SIEOBEX_E2E_BAUDRATES and reads the phone at it; the other
gives connect no speed at all and checks the probe settles on one of the
five it walks (115200, 57600, 19200, 230400, 9600) and that the session
works.
They are only fully meaningful on a cable. QEMU exposes the emulated phone
as a TCP chardev and ignores the host speed — the firmware programs USART0
itself — so against an emulator these show the option reaching the port and
coming back in status, not the wire changing speed. Each rate costs a
session, so the emulators only do two and a hardware run can be trimmed
with the variable.
Knowing what it is doing
A real phone spends seconds where an emulator spends milliseconds, so the
suite narrates itself: each phase is a [device +elapsed] line, and any
single CLI command taking more than three seconds is named as it finishes.
SIEOBEX_E2E_VERBOSE=1 names every command instead.
[/dev/ttyUSB0 +0.0s] starting the phone
[/dev/ttyUSB0 +0.0s] connecting
[/dev/ttyUSB0 +0.9s] connected in 0.9s: SIEMENS C60 v26 (EGOLD, max packet 474 bytes)
[/dev/ttyUSB0 +1.1s] checking /Sounds is a directory the tests may write into
[/dev/ttyUSB0 +2.4s] ready
A connect that fails is retried until SIEOBEX_E2E_READY_TIMEOUT_MS, each
attempt naming the phone's own error. The emulators keep the old three
minutes, because they are still booting; a real phone is either on the cable
or it is not, so 45 seconds is enough to say so.
Two things the suite cannot know about a phone it did not boot: the model
and the platform. Rather than assert them it reads them out of status,
checks the phone identified itself as something on a known platform, and
prints what it found. The listing default is the root because it is the one
directory that every phone has and that is never empty — the writable one is
empty again as soon as the suite has cleaned up after itself. Point
SIEOBEX_E2E_SMALL_FILES_DIR at a folder of real files to exercise the
sizes and dates in the long listing too.
Nothing else changes: the same nineteen tests run, the daemon still gets a
private SIEOBEX_HOME, and a failure leaves the phone disconnected rather
than mid-session.
What the emulated ones need
| Piece | Default location | Override |
|---|---|---|
pmb887x-emu binary |
tests/.emu/pmb887x-emu |
OBEX_E2E_EMU |
| Fullflash images | tests/fullflashes/ |
OBEX_E2E_FULLFLASHES |
| An X server | started automatically | DISPLAY |
Both default paths are gitignored, so a symlink into an emulator build and a
fullflash collection elsewhere is the intended setup. These are the same
variable names and defaults node-sie-serial uses, so one setup serves both
repositories.
A phone whose fullflash is missing skips its suite with the reason rather than failing, since a checkout without the images is the normal case.
QEMU opens a GTK window even with nothing to show it, so globalSetup.ts
starts one Xvfb for the run unless DISPLAY is already set.
Why the emulated ones are slow
Each emulator test file boots one phone and the tests inside it share that session. A boot is tens of seconds, and the file system behind OBEX comes up well after the AT interpreter does, so the suite waits for a real file operation to succeed rather than for a fixed time.
The suite runs with --no-file-parallelism on purpose: QEMU drives the phone
on a precise instruction clock tied to real time, so two emulators competing
for CPU boot more slowly than the tests are willing to wait.
| Phone | Platform | Notes |
|---|---|---|
| EL71 | NewSGOLD | ~8 KiB OBEX packets, fast link |
| S75 | NewSGOLD | same generation, different layout |
| CX70 | SGOLD | 1030 byte packets and a 19200 baud link, so roughly 35 times slower; it is the one that exercises the multi-packet paths |
The test payload is 1024 bytes for that reason: large enough to cross the CX70's packet limit, small enough to move over its link quickly.
Keep the payloads small for another reason too. The emulated USART hands the
guest its input far faster than a real wire would, so a bulk upload arrives as
an interrupt storm, the firmware misses a GSM deadline and panics on purpose.
An unpatched emulator dies on the first few-hundred-byte write; a patched one
is only known to survive writes of a few kilobytes. A push of a hundred
kilobytes will kill the phone and every later command times out. That is an
emulator limit, not a sieobex or phone limit, and it is why the suite does not
test large transfers. node-sie-serial/tests/README.md has the details.
Reconnecting costs a pause
The last three tests of each suite cover -d, which means taking the session
down and bringing it back up. OBEX.disconnect()'s +++ escape really does
hand the wire back to the AT interpreter, but the phone needs a few seconds
before the next handshake catches it, and connecting too early does not just
fail that attempt: it loses the session for the rest of the boot, and every
later connect answers Phone not found at every baud rate. That is what
PhoneTarget.reconnectWaitMS is for — 5 s on the x75 phones, 20 s on the
CX70, the same values the library's own suite uses, and 5 s for a real phone
unless SIEOBEX_E2E_RECONNECT_WAIT_MS says otherwise.
Most of what looked like a phone needing minutes was the daemon closing the
port on top of its own +++ escape; with that fixed a real phone
reconnects immediately, and a phone that was left in OBEX mode anyway is
escaped out of it by the next connect.
Nothing in the CLI hides this. A user who disconnects a phone and immediately
names it with -d again can hit it too, which the main README says.
Isolation
Every CLI subprocess gets SIEOBEX_HOME pointing at a private temporary
directory, so a daemon started by the tests can never collide with one the
developer is using, and nothing is left in ~/.sieobex.
The fullflash is always copied before use and the emulator runs with --rw:
writes really land in the flash image and persist, so the shared images must
not be the ones a phone writes into.
The CX70 is opt-in
SIEOBEX_E2E_CX70=1 pnpm test:e2e
It goes quiet for roughly twenty seconds at a time, which is longer than the
client's fifteen second protocol timeout, so whatever was in flight fails with
OBEX response timeout, and a session that loses one exchange usually loses
the rest. How often it happens depends on how busy the host is, because QEMU
ties the phone's clock to real time. On the machine this was written on, the
EL71 and the S75 passed every run and the CX70 lost between two and nine tests
each time, so leaving it in the default run would mean a suite that is red for
reasons that have nothing to do with the code.
It is still worth running deliberately: it is the only SGOLD phone, the only one with a 1030 byte packet limit, and the only one on a 19200 baud link, so it covers the multi-packet paths the others do not. The library's own CX70 suite sees the same stalls and carries one permanently failing test for a related quirk.
Nothing in the CLI papers over this: recovering a stalled session is the library's job, and a real phone does not behave this way.
When a phone stops answering
A firmware panic shows up as a pile of timeouts in the tests and nothing else.
The emulator prints >>EXIT<< over the serial line in that case, and the
suite dumps the emulator output when it sees it. sieobex log inside a failing
run, or connect --debug all, shows the protocol traffic.