@@ -784,6 +784,7 @@ func TestPassExtraFiles(t *testing.T) {
784784 ExtraFiles : []* os.File {pipein1 , pipein2 },
785785 Stdin : nil ,
786786 Stdout : & stdout ,
787+ Stderr : new (strings.Builder ),
787788 Init : true ,
788789 }
789790 err = container .Run (& process )
@@ -1074,11 +1075,14 @@ func TestHook(t *testing.T) {
10741075 container , err := newContainer (t , config )
10751076 ok (t , err )
10761077
1077- // e.g: 'ls /prestart ...'
10781078 var cmd strings.Builder
10791079 cmd .WriteString ("ls " )
10801080 for _ , hook := range hookFiles {
1081- cmd .WriteString ("/" + hook + " " )
1081+ // The poststart hook is racing with this ls command (run as the
1082+ // container init), so we don't check that hook worked here yet.
1083+ if hook != "poststart" {
1084+ cmd .WriteString ("/" + hook + " " )
1085+ }
10821086 }
10831087
10841088 var stdout strings.Builder
@@ -1097,6 +1101,13 @@ func TestHook(t *testing.T) {
10971101 // Wait for process
10981102 waitProcess (& pconfig , t )
10991103
1104+ // Check that poststart hook worked.
1105+ f , err = os .Open (config .Rootfs + "/poststart" )
1106+ if err != nil {
1107+ t .Fatalf ("poststart hook failed: %s" , err )
1108+ }
1109+ f .Close ()
1110+
11001111 if err := container .Destroy (); err != nil {
11011112 t .Fatalf ("container destroy %s" , err )
11021113 }
0 commit comments