From ca426bdc3ce611e54c403f7eacfc51066ea28c79 Mon Sep 17 00:00:00 2001 From: amab8901 Date: Sun, 9 Apr 2023 06:23:10 +0200 Subject: [PATCH 1/3] commented out test --- applications/test_channel/src/lib.rs | 42 ++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/applications/test_channel/src/lib.rs b/applications/test_channel/src/lib.rs index ad87626cfb..24f2a7de0a 100644 --- a/applications/test_channel/src/lib.rs +++ b/applications/test_channel/src/lib.rs @@ -138,6 +138,7 @@ fn rmain(matches: Matches) -> Result<(), &'static str> { println!("Running asynchronous channel test in oneshot mode."); for _i in 0 .. iterations!() { asynchronous_test_oneshot()?; + // asynchronous_test_oneshot_drop()?; } } if matches.opt_present("m") { @@ -318,6 +319,47 @@ fn asynchronous_test_oneshot() -> Result<(), &'static str> { Ok(()) } +// Modified version of asynchronous_test_oneshot to test the drop() method of sender and receiver +// fn asynchronous_test_oneshot_drop() -> Result<(), &'static str>{ +// let my_cpu = cpu::current_cpu(); + +// let (sender, receiver) = async_channel::new_channel(2); + +// let t1 = spawn::new_task_builder(|_: ()| -> Result<(), &'static str> { +// warn!("asynchronous_test_oneshot(): Entered sender task!"); +// sender.send("hello").map_err(|error| { +// warn!("Sender task failed due to : {:?}", error); +// return "Sender task failed"; +// })?; +// Ok(()) +// }, ()) +// .name(String::from("sender_task_asynchronous_oneshot")) +// .block(); +// let t1 = pin_task!(t1, my_cpu).spawn()?; + +// let t2 = spawn::new_task_builder(|_: ()| -> Result<(), &'static str> { +// warn!("asynchronous_test_oneshot(): Entered receiver task!"); +// let msg = receiver.receive().map_err(|error| { +// warn!("Receiver task failed due to : {:?}", error); +// return "Receiver task failed" +// })?; +// warn!("asynchronous_test_oneshot(): Receiver got msg: {:?}", msg); +// Ok(()) +// }, ()) +// .name(String::from("receiver_task_asynchronous_oneshot")) +// .block(); +// let t2 = pin_task!(t2, my_cpu).spawn()?; + +// warn!("asynchronous_test_oneshot(): Finished spawning the sender and receiver tasks"); +// t2.unblock().unwrap(); +// t1.unblock().unwrap(); + +// t1.join()?; +// t2.join()?; +// warn!("asynchronous_test_oneshot(): Joined the sender and receiver tasks."); + +// Ok(()) +// } /// A simple test that spawns a sender & receiver task to send `send_count` and receive `receive_count` messages. fn asynchronous_test_multiple(send_count: usize, receive_count: usize, send_panic: Option, receive_panic: Option) -> Result<(), &'static str> { From cd3771eef36f46ebe54faa388d31c4c49016cf4b Mon Sep 17 00:00:00 2001 From: amab8901 Date: Sun, 9 Apr 2023 06:36:19 +0200 Subject: [PATCH 2/3] Bug when adding a new test --- applications/test_channel/src/lib.rs | 81 ++++++++++++++-------------- 1 file changed, 41 insertions(+), 40 deletions(-) diff --git a/applications/test_channel/src/lib.rs b/applications/test_channel/src/lib.rs index 24f2a7de0a..e90a974983 100644 --- a/applications/test_channel/src/lib.rs +++ b/applications/test_channel/src/lib.rs @@ -320,46 +320,47 @@ fn asynchronous_test_oneshot() -> Result<(), &'static str> { } // Modified version of asynchronous_test_oneshot to test the drop() method of sender and receiver -// fn asynchronous_test_oneshot_drop() -> Result<(), &'static str>{ -// let my_cpu = cpu::current_cpu(); - -// let (sender, receiver) = async_channel::new_channel(2); - -// let t1 = spawn::new_task_builder(|_: ()| -> Result<(), &'static str> { -// warn!("asynchronous_test_oneshot(): Entered sender task!"); -// sender.send("hello").map_err(|error| { -// warn!("Sender task failed due to : {:?}", error); -// return "Sender task failed"; -// })?; -// Ok(()) -// }, ()) -// .name(String::from("sender_task_asynchronous_oneshot")) -// .block(); -// let t1 = pin_task!(t1, my_cpu).spawn()?; - -// let t2 = spawn::new_task_builder(|_: ()| -> Result<(), &'static str> { -// warn!("asynchronous_test_oneshot(): Entered receiver task!"); -// let msg = receiver.receive().map_err(|error| { -// warn!("Receiver task failed due to : {:?}", error); -// return "Receiver task failed" -// })?; -// warn!("asynchronous_test_oneshot(): Receiver got msg: {:?}", msg); -// Ok(()) -// }, ()) -// .name(String::from("receiver_task_asynchronous_oneshot")) -// .block(); -// let t2 = pin_task!(t2, my_cpu).spawn()?; - -// warn!("asynchronous_test_oneshot(): Finished spawning the sender and receiver tasks"); -// t2.unblock().unwrap(); -// t1.unblock().unwrap(); - -// t1.join()?; -// t2.join()?; -// warn!("asynchronous_test_oneshot(): Joined the sender and receiver tasks."); +fn asynchronous_test_oneshot_drop() -> Result<(), &'static str>{ + let my_cpu = cpu::current_cpu(); + + let (sender, receiver) = async_channel::new_channel(2); + + let t1 = spawn::new_task_builder(|_: ()| -> Result<(), &'static str> { + warn!("asynchronous_test_oneshot(): Entered sender task!"); + sender.send("hello").map_err(|error| { + warn!("Sender task failed due to : {:?}", error); + return "Sender task failed"; + })?; + Ok(()) + }, ()) + .name(String::from("sender_task_asynchronous_oneshot")) + .block(); + let t1 = pin_task!(t1, my_cpu).spawn()?; + + let t2 = spawn::new_task_builder(|_: ()| -> Result<(), &'static str> { + warn!("asynchronous_test_oneshot(): Entered receiver task!"); + let msg = receiver.receive().map_err(|error| { + warn!("Receiver task failed due to : {:?}", error); + return "Receiver task failed" + })?; + warn!("asynchronous_test_oneshot(): Receiver got msg: {:?}", msg); + Ok(()) + }, ()) + .name(String::from("receiver_task_asynchronous_oneshot")) + .block(); + let t2 = pin_task!(t2, my_cpu).spawn()?; + + warn!("asynchronous_test_oneshot(): Finished spawning the sender and receiver tasks"); + t2.unblock().unwrap(); + t1.unblock().unwrap(); + + t1.join()?; + t2.join()?; + warn!("asynchronous_test_oneshot(): Joined the sender and receiver tasks."); -// Ok(()) -// } + Ok(()) +} + /// A simple test that spawns a sender & receiver task to send `send_count` and receive `receive_count` messages. fn asynchronous_test_multiple(send_count: usize, receive_count: usize, send_panic: Option, receive_panic: Option) -> Result<(), &'static str> { @@ -445,4 +446,4 @@ fn print_usage(opts: Options) { } const USAGE: &'static str = "Usage: test_channel OPTION ARG -Provides a selection of different tests for channel-based communication."; +Provides a selection of different tests for channel-based communication."; \ No newline at end of file From 9cd8cac829a2973d33f4f5d15e34623dcc28f908 Mon Sep 17 00:00:00 2001 From: amab8901 Date: Sun, 9 Apr 2023 08:51:56 +0200 Subject: [PATCH 3/3] (maybe) minimal reproducible example --- applications/test_channel/src/lib.rs | 42 +--------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/applications/test_channel/src/lib.rs b/applications/test_channel/src/lib.rs index e90a974983..519b211bfe 100644 --- a/applications/test_channel/src/lib.rs +++ b/applications/test_channel/src/lib.rs @@ -138,7 +138,6 @@ fn rmain(matches: Matches) -> Result<(), &'static str> { println!("Running asynchronous channel test in oneshot mode."); for _i in 0 .. iterations!() { asynchronous_test_oneshot()?; - // asynchronous_test_oneshot_drop()?; } } if matches.opt_present("m") { @@ -319,49 +318,10 @@ fn asynchronous_test_oneshot() -> Result<(), &'static str> { Ok(()) } -// Modified version of asynchronous_test_oneshot to test the drop() method of sender and receiver -fn asynchronous_test_oneshot_drop() -> Result<(), &'static str>{ - let my_cpu = cpu::current_cpu(); - - let (sender, receiver) = async_channel::new_channel(2); - - let t1 = spawn::new_task_builder(|_: ()| -> Result<(), &'static str> { - warn!("asynchronous_test_oneshot(): Entered sender task!"); - sender.send("hello").map_err(|error| { - warn!("Sender task failed due to : {:?}", error); - return "Sender task failed"; - })?; - Ok(()) - }, ()) - .name(String::from("sender_task_asynchronous_oneshot")) - .block(); - let t1 = pin_task!(t1, my_cpu).spawn()?; - - let t2 = spawn::new_task_builder(|_: ()| -> Result<(), &'static str> { - warn!("asynchronous_test_oneshot(): Entered receiver task!"); - let msg = receiver.receive().map_err(|error| { - warn!("Receiver task failed due to : {:?}", error); - return "Receiver task failed" - })?; - warn!("asynchronous_test_oneshot(): Receiver got msg: {:?}", msg); - Ok(()) - }, ()) - .name(String::from("receiver_task_asynchronous_oneshot")) - .block(); - let t2 = pin_task!(t2, my_cpu).spawn()?; - - warn!("asynchronous_test_oneshot(): Finished spawning the sender and receiver tasks"); - t2.unblock().unwrap(); - t1.unblock().unwrap(); - - t1.join()?; - t2.join()?; - warn!("asynchronous_test_oneshot(): Joined the sender and receiver tasks."); - +fn existence_of_this_function_causes_bug() -> Result<(), &'static str>{ Ok(()) } - /// A simple test that spawns a sender & receiver task to send `send_count` and receive `receive_count` messages. fn asynchronous_test_multiple(send_count: usize, receive_count: usize, send_panic: Option, receive_panic: Option) -> Result<(), &'static str> { let my_cpu = cpu::current_cpu();