Debian Codegraph @

src/tools/nngcat/nngcat_unlimited_test.sh

raw symbols SCIP
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_unlimited_test"
16 INPUT=/tmp/nngcat_unlimited_test.$$.in
17 OUTPUT=/tmp/nngcat_unlimited_test.$$.out
18
19 echoscip-shell system . . echo. -n "Verify unlimited receive size: "
20
21 trap "rm $OUTPUT $INPUT" 0
22
23 # 4 MB
24 ddscip-shell system . . dd. if=/dev/urandomscip-shell filesystem . . `/dev/urandom`. of=${INPUT} bs=1024 count=4096 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
25 goodsum=$(cksumscip-shell system . . cksum. ${INPUT})
26 goodsum=${goodsum%% *}
27
28 ${NNGCAT} --listen ${ADDR} --count=1 --recv-maxsz=0 --pull0 --raw > $OUTPUT 2>/dev/nullscip-shell filesystem . . `/dev/null`. &
29 sleepscip-shell system . . sleep. 1
30 # for speed of execution, run these in the background, they should be ignored
31 ${NNGCAT} --connect ${ADDR} --delay=1 --push0 --file ${INPUT}
32 wait $bgid 2>/dev/nullscip-shell filesystem . . `/dev/null`.
33
34 sum=$(cksumscip-shell system . . cksum. ${OUTPUT})
35 sum=${sum%% *}
36
37 if [[ ${sum} == ${goodsum} ]]
38 then
39 echoscip-shell system . . echo. "pass"
40 exit 0
41 fi
42 echoscip-shell system . . echo. "FAIL: Checksum failed (Wanted ${goodsum} got ${sum})"
43 echoscip-shell system . . echo. "OUTPUT:"
44 lsscip-shell system . . ls. -la ${OUTPUT}
45
46 exit 1