-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathtestbasics
executable file
·102 lines (88 loc) · 3.23 KB
/
testbasics
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/sh
# ccnd/testbasics
#
# Part of the CCNx distribution.
#
# Copyright (C) 2009, 2011 Palo Alto Research Center, Inc.
#
# This work is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License version 2 as published by the
# Free Software Foundation.
# This work is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.
#
CCN_LOCAL_PORT=${CCN_LOCAL_PORT_BASE:-63000}
export CCN_LOCAL_PORT
: ${CCND_DEBUG:=0}
export CCND_DEBUG
Fail () {
echo '*** Failed' $* >&2
exit 1
}
Cleanup () {
./ccndsmoketest kill 2>/dev/null
wait
}
./ccndsmoketest kill 2>/dev/null
echo Starting ccnd with CCN_LOCAL_PORT=$CCN_LOCAL_PORT
./ccnd &
echo Making sure new ccnd is there
./ccndsmoketest 2>/dev/null || { sleep 1; ./ccndsmoketest || Fail; }
trap Cleanup 0
echo Populating ccnd with pre-signed data
./ccndsmoketest -t 10 send fortunes.ccnb recv || Fail
echo Making anything.ccnb
../cmd/ccn_xmltoccnb -w - <<'END' > anything.ccnb
<Interest>
<Name>
</Name>
</Interest>
END
echo Trying for anything a few times
./ccndsmoketest -t 200 send anything.ccnb recv send anything.ccnb recv send anything.ccnb recv > anything.out || Fail
diff anything.ref anything.out || echo Diffs above might be OK, but have a look
MATCHES=`grep -c '^recv of' anything.out`
test $MATCHES = 3 || Fail Wrong number of matches, got $MATCHES expected 3
echo Testing contentobjecthash
../cmd/ccn_xmltoccnb -w - <<'END' > contentobjecthash.ccnb
<Interest>
<Name>
<Component ccnbencoding="text">local</Component>
<Component ccnbencoding="text">test</Component>
<Component ccnbencoding="text">fortunes</Component>
<Component ccnbencoding="text">doubt</Component>
<Component ccnbencoding="text">0</Component>
<Component ccnbencoding="hexBinary">f7638fb36c69d8c6e18cadac0616801a63876949425ca19379166e91d1e70b97</Component>
</Name>
</Interest>
END
./ccndsmoketest -t 300 send contentobjecthash.ccnb recv > contentobjecthash.out || Fail
diff contentobjecthash.ref contentobjecthash.out || Fail contentobjecthash.out does not match expected
echo Testing that fetch with bad hash does not succeed
../cmd/ccn_xmltoccnb -w - <<'END' > contentmishash.ccnb
<Interest>
<Name>
<Component ccnbencoding="text">local</Component>
<Component ccnbencoding="text">test</Component>
<Component ccnbencoding="text">fortunes</Component>
<Component ccnbencoding="text">doubt</Component>
<Component ccnbencoding="text">0</Component>
<Component ccnbencoding="hexBinary">f7638fb36c69d8c6e18cadac0616803a63876949425ca19379166e91d1e70b97</Component>
</Name>
</Interest>
END
./ccndsmoketest -t 200 send contentmishash.ccnb recv | grep 'recv timed out' || Fail contentmishash
echo Testing MinSuffixComponents
../cmd/ccn_xmltoccnb -w - <<'END' > minsuffix.ccnb
<Interest>
<Name>
<Component ccnbencoding="text">local</Component>
<Component ccnbencoding="text">test</Component>
</Name>
<MinSuffixComponents>5</MinSuffixComponents>
</Interest>
END
./ccndsmoketest -t 300 send minsuffix.ccnb recv > minsuffix.out || Fail
diff minsuffix.ref minsuffix.out || Fail minsuffix.out does not match expected
echo $0 TESTS PASSED