| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | |
| 3 | # |
| 4 | # Copyright 2018 Staysail Systems, Inc. <[email protected]> |
| 5 | # Copyright 2018 Capitar IT Group BV <[email protected]> |
| 6 | # |
| 7 | # This software is supplied under the terms of the MIT License, a |
| 8 | # copy of which should be located in the distribution where this |
| 9 | # file was obtained (LICENSE.txt). A copy of the license may also be |
| 10 | # found online at https://opensource.org/licenses/MIT. |
| 11 | # |
| 12 | |
| 13 | NNGCAT=${NNGCAT:=$1} |
| 14 | NNGCAT=${NNGCAT:-./nngcat} |
| 15 | ADDR="ipc:///tmp/nngcat_recvmaxsz_test" |
| 16 | OUTPUT=/tmp/nngcat_recvmaxsz_test.$$.out |
| 17 | |
| 18 | echoscip-shell system . . echo. -n "Verify maximum receive size: " |
| 19 | |
| 20 | trap "rm $OUTPUT" 0 |
| 21 | |
| 22 | ${NNGCAT} --listen ${ADDR} --count=3 --recv-maxsz=5 --pull0 --quoted > $OUTPUT 2>/dev/nullscip-shell filesystem . . `/dev/null`. & |
| 23 | sleepscip-shell system . . sleep. 1 |
| 24 | # for speed of execution, run these in the background, they should be ignored |
| 25 | ${NNGCAT} --connect ${ADDR} --push0 --data "one" |
| 26 | ${NNGCAT} --connect ${ADDR} --push0 --data "55555" |
| 27 | ${NNGCAT} --connect ${ADDR} --push0 --data "666666" |
| 28 | ${NNGCAT} --connect ${ADDR} --push0 --data "7777777" |
| 29 | ${NNGCAT} --connect ${ADDR} --push0 --data "88888" |
| 30 | |
| 31 | wait $bgid 2>/dev/nullscip-shell filesystem . . `/dev/null`. |
| 32 | |
| 33 | sum=$(cksumscip-shell system . . cksum. ${OUTPUT}) |
| 34 | sum=${sum%% *} |
| 35 | |
| 36 | # This matches 3 lines of "one", "55555", "88888". |
| 37 | if [[ ${sum} == 4122906158 ]] |
| 38 | then |
| 39 | echoscip-shell system . . echo. "pass" |
| 40 | exit 0 |
| 41 | fi |
| 42 | echoscip-shell system . . echo. "FAIL: Checksum failed (Wanted 3929078614 got ${sum})" |
| 43 | echoscip-shell system . . echo. "OUTPUT:" |
| 44 | catscip-shell system . . cat. ${OUTPUT} |
| 45 | |
| 46 | exit 1 |