mirror of
https://github.com/rwinkhart/go-winio.git
synced 2026-09-01 22:57:35 -04:00
add DialPipeContext
This commit is contained in:
@@ -3,6 +3,7 @@ package winio
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"io"
|
||||
"net"
|
||||
"os"
|
||||
@@ -37,6 +38,26 @@ func TestDialListenerTimesOut(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDialListenerGetsCancelled(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
l, err := ListenPipe(testPipeName, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ch := make(chan error)
|
||||
defer l.Close()
|
||||
go func(ctx context.Context, ch chan error) {
|
||||
_, err := DialPipeContext(ctx, testPipeName)
|
||||
ch <- err
|
||||
}(ctx, ch)
|
||||
time.Sleep(time.Millisecond * 30)
|
||||
cancel()
|
||||
err = <-ch
|
||||
if err == nil {
|
||||
t.Fatalf("expected ErrTimeout, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDialAccessDeniedWithRestrictedSD(t *testing.T) {
|
||||
c := PipeConfig{
|
||||
SecurityDescriptor: "D:P(A;;0x1200FF;;;WD)",
|
||||
|
||||
Reference in New Issue
Block a user