toybox/tests/netcat.test
Elliott Hughes 9f7f62615f netcat.test: reduce flake.
Starting two netcats at the same time and expecting them to be able to
talk to each is a little optimistic. I don't know whether `sleep .1`
will be sufficient, but wanted to try that before going to `sleep 1`
since neither the toybox nor the github nor the Android infrastructure
is running these tests in parallel, those seconds add up.

Right now this has a ~20% flake rate on the Android infrastructure. I
was able to reproduce the flake locally with `while true ; do make
test_netcat ; done` on my desktop before this patch, but not after.
(Though my desktop is way overpowered for just running that, whereas the
build servers tend to be pretty busy, which is why I reserve the right
to return later with a longer delay.)
2021-02-06 19:33:13 -06:00

12 lines
337 B
Bash
Executable File

#!/bin/bash
[ -f testing.sh ] && . testing.sh
#testing "name" "command" "result" "infile" "stdin"
{ dd if=/dev/zero bs=4k count=1 2>/dev/null | tr '\0' a; echo b; } > testfile
testing "more than buffer bytes left at end" \
"netcat -lp 1234 wc -c & sleep .1 && cat testfile | netcat 127.0.0.1 1234" \
"4098\n" "" ""
rm -f testfile