File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1006,6 +1006,22 @@ func TestDiffTar(t *testing.T) {
10061006 fstest .CreateDir ("/d3/" , 0755 ),
10071007 ),
10081008 },
1009+ {
1010+ name : "IgnoreSockets" ,
1011+ validators : []tarEntryValidator {
1012+ fileEntry ("f2" , []byte ("content" ), 0644 ),
1013+ // There should be _no_ socket here, despite the fstest.CreateSocket below
1014+ fileEntry ("f3" , []byte ("content" ), 0644 ),
1015+ },
1016+ a : fstest .Apply (
1017+ fstest .CreateFile ("/f1" , []byte ("content" ), 0644 ),
1018+ ),
1019+ b : fstest .Apply (
1020+ fstest .CreateFile ("/f2" , []byte ("content" ), 0644 ),
1021+ fstest .CreateSocket ("/s0" , 0644 ),
1022+ fstest .CreateFile ("/f3" , []byte ("content" ), 0644 ),
1023+ ),
1024+ },
10091025 }
10101026
10111027 for _ , at := range tests {
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package fstest
22
33import (
44 "io/ioutil"
5+ "net"
56 "os"
67 "path/filepath"
78 "time"
@@ -107,6 +108,19 @@ func Link(oldname, newname string) Applier {
107108// }
108109//}
109110
111+ // CreateSocket returns a file applier which creates a unix socket
112+ func CreateSocket (name string , perm os.FileMode ) Applier {
113+ return applyFn (func (root string ) error {
114+ fullPath := filepath .Join (root , name )
115+ ln , err := net .Listen ("unix" , fullPath )
116+ if err != nil {
117+ return err
118+ }
119+ defer ln .Close ()
120+ return os .Chmod (fullPath , perm )
121+ })
122+ }
123+
110124// Apply returns a new applier from the given appliers
111125func Apply (appliers ... Applier ) Applier {
112126 return applyFn (func (root string ) error {
Original file line number Diff line number Diff line change 7474 Symlink ("libnothing.so" , "/usr/local/lib/libnothing.so.2" ),
7575 CreateDir ("/home" , 0755 ),
7676 CreateDir ("/home/derek" , 0700 ),
77+ CreateDir ("/var/run/socket" , 0700 ),
7778 )
7879
7980 // basicTest covers basic operations
You can’t perform that action at this time.
0 commit comments