@@ -40,6 +40,7 @@ import (
4040	"github.com/containerd/nerdctl/mod/tigron/tig" 
4141
4242	"github.com/containerd/nerdctl/v2/cmd/nerdctl/helpers" 
43+ 	"github.com/containerd/nerdctl/v2/pkg/rootlessutil" 
4344	"github.com/containerd/nerdctl/v2/pkg/testutil" 
4445	"github.com/containerd/nerdctl/v2/pkg/testutil/nerdtest" 
4546)
@@ -1058,3 +1059,47 @@ HEALTHCHECK --interval=30s --timeout=10s CMD wget -q --spider http://localhost:8
10581059
10591060	testCase .Run (t )
10601061}
1062+ 
1063+ func  countFIFOFiles (root  string ) (int , error ) {
1064+ 	count  :=  0 
1065+ 	err  :=  filepath .Walk (root , func (path  string , info  os.FileInfo , err  error ) error  {
1066+ 		if  err  !=  nil  {
1067+ 			return  err 
1068+ 		}
1069+ 		if  info .Mode ()& os .ModeNamedPipe  !=  0  {
1070+ 			count ++ 
1071+ 		}
1072+ 		return  nil 
1073+ 	})
1074+ 	return  count , err 
1075+ }
1076+ func  TestCleanupFIFOs (t  * testing.T ) {
1077+ 	if  rootlessutil .IsRootless () {
1078+ 		t .Skip ("/run/containerd/fifo/ doesn't exist on rootless" )
1079+ 	}
1080+ 	if  runtime .GOOS  ==  "windows"  {
1081+ 		t .Skip ("test is not compatible with windows" )
1082+ 	}
1083+ 	testutil .DockerIncompatible (t )
1084+ 	testCase  :=  nerdtest .Setup ()
1085+ 	testCase .NoParallel  =  true 
1086+ 	testCase .Setup  =  func (data  test.Data , helpers  test.Helpers ) {
1087+ 		cmd  :=  helpers .Command ("run" , "-it" , "--rm" , testutil .CommonImage , "date" )
1088+ 		cmd .WithPseudoTTY ()
1089+ 		cmd .Run (& test.Expected {
1090+ 			ExitCode : 0 ,
1091+ 		})
1092+ 		oldNumFifos , err  :=  countFIFOFiles ("/run/containerd/fifo/" )
1093+ 		assert .NilError (t , err )
1094+ 
1095+ 		cmd  =  helpers .Command ("run" , "-it" , "--rm" , testutil .CommonImage , "date" )
1096+ 		cmd .WithPseudoTTY ()
1097+ 		cmd .Run (& test.Expected {
1098+ 			ExitCode : 0 ,
1099+ 		})
1100+ 		newNumFifos , err  :=  countFIFOFiles ("/run/containerd/fifo/" )
1101+ 		assert .NilError (t , err )
1102+ 		assert .Equal (t , oldNumFifos , newNumFifos )
1103+ 	}
1104+ 	testCase .Run (t )
1105+ }
0 commit comments