blob: f1be323e98d0a35e05d53679aeed14112d00492e [file] [log] [blame]
Yi Huang7990f092014-04-18 04:51:58 -07001#!/usr/bin/env bash
2mkdir -p logs
3
4clean_up() {
5 r=$(killall ndn-traffic-server 2>&1)
6 r=$(sudo killall nfd 2>&1)
7}
8
9# Start NFD.
10sudo nfd > logs/nfd.log 2>&1 &
11sleep 1
12
13# Start ndn-traffic-server to serve `ndn:/test-caching`, FreshnessPeriod=2800ms
14ndn-traffic-server NDNTrafficServer.conf > logs/server.log 2>&1 &
15sleep 1
16
17# Invoke ndn-tlv-peek to send Interest `ndn:/test-caching/A`, MustBeFresh=yes. Fail if this Interest is unanswered.
18output=$(ndn-tlv-peek -fp ndn:/test-caching/A)
19if [[ $output != 'AAAAAAAA' ]]
20then
21 echo "FAIL: Expected data for first interest: 'AAAAAAAA', Actual: '$output'"
22 clean_up
23 exit 1
24fi
25
26# Pause 1000ms.
27sleep 1
28
29# Invoke ndn-tlv-peek to send Interest `ndn:/test-caching/A`, MustBeFresh=yes. Fail if this Interest is unanswered.
30output=$(ndn-tlv-peek -fp ndn:/test-caching/A)
31if [[ $output != 'AAAAAAAA' ]]
32then
33 echo "FAIL: Expected data for second interest: 'AAAAAAAA', Actual: '$output'"
34 clean_up
35 exit 2
36fi
37
38# Kill ndn-traffic-server. Check "total Interests received" equals 1.
39killall ndn-traffic-server
40sleep 5
41output=$(grep 'Total Interests Received' logs/server.log | head -1 | cut -d = -f2 | cut -d' ' -f2)
42if [[ $output != '1' ]]
43then
44 echo "FAIL: Expected ndn-traffic-server receives 1 interest. Actual: $output"
45 clean_up
46 exit 3
47fi
48
49# Invoke ndn-tlv-peek to send Interest `ndn:/test-caching/A`, MustBeFresh=yes. Fail if this Interest is answered.
50output=$(ndn-tlv-peek -fp ndn:/test-caching/A)
51if [[ ! -z $output ]]
52then
53 echo "FAIL: Expected no data received for third interest. Actual data received: '$output'"
54 clean_up
55 exit 4
56fi
57sleep 1
58
59# Invoke ndn-tlv-peek to send Interest `ndn:/test-caching/A` without MustBeFresh. Fail if this Interest is unanswered.
60output=$(ndn-tlv-peek -p ndn:/test-caching/A)
61if [[ $output != 'AAAAAAAA' ]]
62then
63 echo "FAIL: Expected data for fourth interest: 'AAAAAAAA', Actual: '$output'"
64 clean_up
65 exit 5
66fi
67
68# clean up
69clean_up
70echo "ContentStore and freshness test scenario PASSED"