Skip to content

Commit 852c36f

Browse files
committed
Organize more test commands, add test_blockwise_all()
1 parent 7efef31 commit 852c36f

File tree

2 files changed

+21
-24
lines changed

2 files changed

+21
-24
lines changed

examples/xbd-net/src/lib.rs

+5-18
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,10 @@ async fn xbd_main() -> Result<(), i8> {
103103
let req_internal_native = ("[fe80::78ec:5fff:febd:add9]:5683", "/.well-known/core");
104104
let req_external_native = ("[fe80::20be:cdff:fe0e:44a1]:5683", "/hello");
105105

106-
if 0 == 1 { // non-blocking
107-
let cb = |out| { println!("@@ out: {:?}", out); };
108-
109-
//==== native, internal server
110-
let (addr, uri) = req_internal_native;
111-
Xbd::gcoap_get(addr, uri, cb);
112-
113-
//==== native, external server -- LD_LIBRARY_PATH=./libcoap/local/lib libcoap-minimal/server 5683 fe80::20be:cdff:fe0e:44a1%tap1 &
114-
let (addr, uri) = req_external_native;
115-
Xbd::gcoap_get(addr, uri, cb);
116-
}
106+
//==== native, internal server
107+
//let (addr, uri) = req_internal_native;
108+
//==== native, external server -- LD_LIBRARY_PATH=./libcoap/local/lib libcoap-minimal/server 5683 fe80::20be:cdff:fe0e:44a1%tap1 &
109+
//let (addr, uri) = req_external_native;
117110

118111
if 1 == 1 { // async, dev, server !!!!
119112
let addr_self = "[::1]:5683";
@@ -148,17 +141,11 @@ async fn xbd_main() -> Result<(), i8> {
148141
panic!("ok");
149142
}
150143

151-
if 0 == 1 {
152-
println!("!! ======== dev calling non-blocking");
153-
Xbd::gcoap_get(addr_self, "/cli/stats", |out| { println!("!! out: {:?}", out); });
154-
Xbd::gcoap_get(addr_self, "/cli/stats", |out| { println!("!! out: {:?}", out); });
155-
}
156-
157144
// TODO async gcoap ping
158145

159146
if 0 == 1 { // fileserver, blockwise, stream
160147
test_blockwise(addr_self).await.unwrap();
161-
//panic!("debug ok"); // !!!!
148+
panic!("debug ok"); // !!!!
162149
}
163150
}
164151

examples/xbd-net/src/xbd/shell.rs

+16-6
Original file line numberDiff line numberDiff line change
@@ -126,22 +126,30 @@ async fn test_async_sleep() {
126126
println!("test_async_sleep(): $$");
127127
}
128128

129-
async fn test_async_blockwise_get() {
130-
println!("test_async_blockwise_get(): ^^");
129+
async fn test_blockwise_all() {
130+
println!("test_blockwise_all(): ^^");
131+
crate::test_blockwise("[::1]:5683").await.unwrap();
132+
println!("test_blockwise_all(): $$");
133+
}
134+
135+
async fn test_async_blockwise() {
136+
println!("test_async_blockwise(): ^^");
131137

132138
let mut bs = crate::Xbd::async_gcoap_get_blockwise(
133139
"[::1]:5683", "/const/song.txt").unwrap();
134140
while let Some(req) = bs.next().await {
135141
println!("@@ out: {:?}", req.await);
136142
}
137143

138-
println!("test_async_blockwise_get(): $$");
144+
println!("test_async_blockwise(): $$");
139145
}
140146

141147
async fn test_heapless_req() {
142148
println!("test_heapless_req(): ^^");
143-
let out = crate::Xbd::async_gcoap_get("[::1]", "/.well-known/core").await;
144-
println!("@@ out: {:?}", out);
149+
println!("-------- out-0:");
150+
println!("{:?}", crate::Xbd::async_gcoap_get("[::1]", "/.well-known/core").await);
151+
println!("-------- out-1:");
152+
println!("{:?}", crate::Xbd::async_gcoap_get("[::1]", "/cli/stats").await);
145153
println!("test_heapless_req(): $$");
146154
}
147155

@@ -162,6 +170,7 @@ const ARRAY_ALIAS_ENUMERATED: &[&str] = &[
162170

163171
const ARRAY_ALIAS_FUNCTION: &[&str] = &[
164172
"f",
173+
"b",
165174
"f0",
166175
"f1",
167176
"f2",
@@ -172,9 +181,10 @@ const ARRAY_ALIAS_FUNCTION: &[&str] = &[
172181
async fn run_function_alias(name: &str) {
173182
match name {
174183
"f" => test_heapless_req().await, // !!!!
184+
"b" => test_blockwise_all().await, // nn | a debug, b
175185
"f0" => (|| println!("hello world!"))(),
176186
"f1" => test_async_sleep().await,
177-
"f2" => test_async_blockwise_get().await,
187+
"f2" => test_async_blockwise().await,
178188
"f3" => crate::test_blockwise("[::1]:5683").await.unwrap(),
179189
_ => println!("function alias [{}] is not defined!", name),
180190
}

0 commit comments

Comments
 (0)