|
1 # |
|
2 # Copyright 2007 Intel Corporation |
|
3 # |
|
4 # Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 # you may not use this file except in compliance with the License. |
|
6 # You may obtain a copy of the License at |
|
7 # |
|
8 # http://www.apache.org/licenses/LICENSE-2.0 |
|
9 # |
|
10 # Unless required by applicable law or agreed to in writing, software |
|
11 # distributed under the License is distributed on an "AS IS" BASIS, |
|
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 # See the License for the specific language governing permissions and |
|
14 # limitations under the License. |
|
15 # |
|
16 |
|
17 test::name is-singleton |
|
18 net::num_nodes 1 |
|
19 manifest::file apps/dtnsend/dtnsend dtnsend |
|
20 dtn::config |
|
21 dtn::config_topology_common false |
|
22 |
|
23 test::script { |
|
24 testlog "Running dtnd" |
|
25 dtn::run_dtnd 0 |
|
26 |
|
27 testlog "Waiting for dtnd to start up" |
|
28 dtn::wait_for_dtnd * |
|
29 |
|
30 testlog "Setting up flamebox ignores" |
|
31 dtn::tell_dtnd 0 log /test always \ |
|
32 "flamebox-ignore ign1 client disconnected without calling dtn_close" |
|
33 dtn::tell_dtnd 0 log /test always \ |
|
34 "flamebox-ignore ign2 bundle destination .* in unknown scheme and app did not assert.*" |
|
35 dtn::tell_dtnd 0 log /test always \ |
|
36 "flamebox-ignore ign3 error sending bundle.*" |
|
37 |
|
38 testlog "Adding some registrations" |
|
39 dtn::tell_dtnd 0 tcl_registration dtn://host-0*/* |
|
40 dtn::tell_dtnd 0 tcl_registration str:string |
|
41 dtn::tell_dtnd 0 tcl_registration str:string* |
|
42 dtn::tell_dtnd 0 tcl_registration unknown:something |
|
43 |
|
44 proc test {dest opts is_singleton} { |
|
45 testlog "Testing $dest with opts \"$opts\"" |
|
46 |
|
47 set pid [dtn::run_app 0 dtnsend "-s dtn://host-0/source -t d -d $dest $opts"] |
|
48 run::wait_for_pid_exit 0 $pid |
|
49 |
|
50 if {$is_singleton == "fail"} { |
|
51 global net::host run::dirs |
|
52 set log [run::run_cmd $net::host(0) cat $run::dirs(0)/dtnsend.out] |
|
53 if {$log != "error sending bundle: -1 (invalid argument)"} { |
|
54 error "expected failure, output is \"$log\"" |
|
55 } |
|
56 # clear the output file |
|
57 run::run_cmd $net::host(0) echo "" > $run::dirs(0)/dtnsend.out |
|
58 |
|
59 } else { |
|
60 dtn::wait_for_bundle_stats 0 {1 delivered} |
|
61 set guid [lindex [tell_dtnd 0 array names bundle_info] 0] |
|
62 dtn::check_bundle_data 0 $guid singleton_dest $is_singleton |
|
63 } |
|
64 |
|
65 dtn::tell_dtnd 0 bundle reset_stats |
|
66 dtn::tell_dtnd 0 array unset bundle_info |
|
67 } |
|
68 |
|
69 testlog "" |
|
70 testlog "Testing known schemes..." |
|
71 testlog "" |
|
72 test dtn://host-0/foo "" 1 |
|
73 test \"dtn://host-*/foo\" "" 0 |
|
74 test dtn://host-0/foo "-1" 1 |
|
75 test dtn://host-0/foo "-N" 0 |
|
76 test \"dtn://host-*/foo\" "-1" 1 |
|
77 test \"dtn://host-*/foo\" "-N" 0 |
|
78 |
|
79 test str:string "" 1 |
|
80 test str:string* "" 1 |
|
81 test str:string "-1" 1 |
|
82 test str:string* "-1" 1 |
|
83 test str:string "-N" 0 |
|
84 test str:string* "-N" 0 |
|
85 |
|
86 |
|
87 testlog "" |
|
88 testlog "Testing unknown scheme..." |
|
89 testlog "" |
|
90 |
|
91 test unknown:something "" 0 |
|
92 testlog "Setting is_singleton_default to singleton" |
|
93 tell_dtnd 0 param set is_singleton_default singleton |
|
94 test unknown:something "" 1 |
|
95 |
|
96 testlog "Setting is_singleton_default to unknown" |
|
97 tell_dtnd 0 param set is_singleton_default unknown |
|
98 test unknown:something "" fail |
|
99 test unknown:something "-1" 1 |
|
100 test unknown:something "-N" 0 |
|
101 |
|
102 |
|
103 testlog "Test success!" |
|
104 } |
|
105 |
|
106 test::exit_script { |
|
107 testlog "Clearing flamebox ignores" |
|
108 tell_dtnd 0 log /test always "flamebox-ignore-cancel ign1" |
|
109 tell_dtnd 0 log /test always "flamebox-ignore-cancel ign2" |
|
110 tell_dtnd 0 log /test always "flamebox-ignore-cancel ign3" |
|
111 |
|
112 testlog "Stopping all dtnds" |
|
113 dtn::stop_dtnd * |
|
114 } |