File tree 1 file changed +18
-1
lines changed
1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ mod scchannel_tests {
86
86
}
87
87
88
88
#[ test]
89
- fn test_writer_close_watchdog ( ) {
89
+ fn test_writer_close_watchdog_with_write ( ) {
90
90
sync:: model ( || {
91
91
let channel = sync:: Arc :: new ( SelfContainedChannel :: < u32 > :: new ( ) ) ;
92
92
let writer = {
@@ -112,6 +112,23 @@ mod scchannel_tests {
112
112
} )
113
113
}
114
114
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
+
115
132
#[ test]
116
133
fn test_channel_reuse ( ) {
117
134
// Test reusing channels, using another channel to synchronize.
You can’t perform that action at this time.
0 commit comments