@@ -1008,6 +1008,73 @@ func TestContainerAttachProcess(t *testing.T) {
10081008 <- status
10091009}
10101010
1011+ func TestContainerLoadUnexistingProcess (t * testing.T ) {
1012+ t .Parallel ()
1013+
1014+ if runtime .GOOS == "windows" {
1015+ // On windows, closing the write side of the pipe closes the read
1016+ // side, sending an EOF to it and preventing reopening it.
1017+ // Hence this test will always fails on windows
1018+ t .Skip ("invalid logic on windows" )
1019+ }
1020+
1021+ client , err := newClient (t , address )
1022+ if err != nil {
1023+ t .Fatal (err )
1024+ }
1025+ defer client .Close ()
1026+
1027+ var (
1028+ image Image
1029+ ctx , cancel = testContext (t )
1030+ id = t .Name ()
1031+ )
1032+ defer cancel ()
1033+
1034+ image , err = client .GetImage (ctx , testImage )
1035+ if err != nil {
1036+ t .Fatal (err )
1037+ }
1038+
1039+ container , err := client .NewContainer (ctx , id , WithNewSnapshot (id , image ), WithNewSpec (oci .WithImageConfig (image ), withProcessArgs ("sleep" , "100" )))
1040+ if err != nil {
1041+ t .Fatal (err )
1042+ }
1043+ defer container .Delete (ctx , WithSnapshotCleanup )
1044+
1045+ // creating IO early for easy resource cleanup
1046+ direct , err := newDirectIO (ctx , false )
1047+ if err != nil {
1048+ t .Fatal (err )
1049+ }
1050+ defer direct .Delete ()
1051+
1052+ task , err := container .NewTask (ctx , empty ())
1053+ if err != nil {
1054+ t .Fatal (err )
1055+ }
1056+ defer task .Delete (ctx )
1057+
1058+ status , err := task .Wait (ctx )
1059+ if err != nil {
1060+ t .Error (err )
1061+ }
1062+
1063+ if err := task .Start (ctx ); err != nil {
1064+ t .Fatal (err )
1065+ }
1066+
1067+ if _ , err = task .LoadProcess (ctx , "this-process-does-not-exist" , direct .IOAttach ); err == nil {
1068+ t .Fatal ("an error should have occurred when loading a process that does not exist" )
1069+ }
1070+
1071+ if err := task .Kill (ctx , syscall .SIGKILL ); err != nil {
1072+ t .Error (err )
1073+ }
1074+
1075+ <- status
1076+ }
1077+
10111078func TestContainerUserID (t * testing.T ) {
10121079 t .Parallel ()
10131080
0 commit comments