@@ -940,6 +940,73 @@ func TestContainerAttachProcess(t *testing.T) {
940940 <- status
941941}
942942
943+ func TestContainerLoadUnexistingProcess (t * testing.T ) {
944+ t .Parallel ()
945+
946+ if runtime .GOOS == "windows" {
947+ // On windows, closing the write side of the pipe closes the read
948+ // side, sending an EOF to it and preventing reopening it.
949+ // Hence this test will always fails on windows
950+ t .Skip ("invalid logic on windows" )
951+ }
952+
953+ client , err := newClient (t , address )
954+ if err != nil {
955+ t .Fatal (err )
956+ }
957+ defer client .Close ()
958+
959+ var (
960+ image Image
961+ ctx , cancel = testContext (t )
962+ id = t .Name ()
963+ )
964+ defer cancel ()
965+
966+ image , err = client .GetImage (ctx , testImage )
967+ if err != nil {
968+ t .Fatal (err )
969+ }
970+
971+ container , err := client .NewContainer (ctx , id , WithNewSnapshot (id , image ), WithNewSpec (oci .WithImageConfig (image ), withProcessArgs ("sleep" , "100" )))
972+ if err != nil {
973+ t .Fatal (err )
974+ }
975+ defer container .Delete (ctx , WithSnapshotCleanup )
976+
977+ // creating IO early for easy resource cleanup
978+ direct , err := newDirectIO (ctx , false )
979+ if err != nil {
980+ t .Fatal (err )
981+ }
982+ defer direct .Delete ()
983+
984+ task , err := container .NewTask (ctx , empty ())
985+ if err != nil {
986+ t .Fatal (err )
987+ }
988+ defer task .Delete (ctx )
989+
990+ status , err := task .Wait (ctx )
991+ if err != nil {
992+ t .Error (err )
993+ }
994+
995+ if err := task .Start (ctx ); err != nil {
996+ t .Fatal (err )
997+ }
998+
999+ if _ , err = task .LoadProcess (ctx , "this-process-does-not-exist" , direct .IOAttach ); err == nil {
1000+ t .Fatal ("an error should have occurred when loading a process that does not exist" )
1001+ }
1002+
1003+ if err := task .Kill (ctx , syscall .SIGKILL ); err != nil {
1004+ t .Error (err )
1005+ }
1006+
1007+ <- status
1008+ }
1009+
9431010func TestContainerUserID (t * testing.T ) {
9441011 t .Parallel ()
9451012
0 commit comments