Skip to content

Commit b138594

Browse files
committed
scchannel test close without write
1 parent 0626b05 commit b138594

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/lib/vasi-sync/tests/scchannel-tests.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ mod scchannel_tests {
8686
}
8787

8888
#[test]
89-
fn test_writer_close_watchdog() {
89+
fn test_writer_close_watchdog_with_write() {
9090
sync::model(|| {
9191
let channel = sync::Arc::new(SelfContainedChannel::<u32>::new());
9292
let writer = {
@@ -112,6 +112,23 @@ mod scchannel_tests {
112112
})
113113
}
114114

115+
#[test]
116+
fn test_writer_close_watchdog_without_write() {
117+
sync::model(|| {
118+
let channel = sync::Arc::new(SelfContainedChannel::<u32>::new());
119+
let reader = {
120+
let channel = channel.clone();
121+
sync::thread::spawn(move || unsafe { channel.receive() })
122+
};
123+
// Parallel with channel.receive()
124+
channel.close_writer();
125+
let res = reader.join().unwrap();
126+
// We should either get the written value, or an error, depending on
127+
// the execution order.
128+
assert_eq!(res, Err(SelfContainedChannelError::WriterIsClosed));
129+
})
130+
}
131+
115132
#[test]
116133
fn test_channel_reuse() {
117134
// Test reusing channels, using another channel to synchronize.

0 commit comments

Comments
 (0)