@@ -1611,3 +1611,52 @@ func TestInitJoinNetworkAndUser(t *testing.T) {
16111611 stdinW1 .Close ()
16121612 waitProcess (init1 , t )
16131613}
1614+
1615+ func TestTmpfsCopyUp (t * testing.T ) {
1616+ if testing .Short () {
1617+ return
1618+ }
1619+ root , err := newTestRoot ()
1620+ ok (t , err )
1621+ defer os .RemoveAll (root )
1622+
1623+ rootfs , err := newRootfs ()
1624+ ok (t , err )
1625+ defer remove (rootfs )
1626+
1627+ config := newTemplateConfig (rootfs )
1628+
1629+ config .Mounts = append (config .Mounts , & configs.Mount {
1630+ Source : "tmpfs" ,
1631+ Destination : "/etc" ,
1632+ Device : "tmpfs" ,
1633+ Extensions : configs .EXT_COPYUP ,
1634+ })
1635+
1636+ factory , err := libcontainer .New (root , libcontainer .Cgroupfs )
1637+ ok (t , err )
1638+
1639+ container , err := factory .Create ("test" , config )
1640+ ok (t , err )
1641+ defer container .Destroy ()
1642+
1643+ var stdout bytes.Buffer
1644+ pconfig := libcontainer.Process {
1645+ Args : []string {"ls" , "/etc/passwd" },
1646+ Env : standardEnvironment ,
1647+ Stdin : nil ,
1648+ Stdout : & stdout ,
1649+ }
1650+ err = container .Run (& pconfig )
1651+ ok (t , err )
1652+
1653+ // Wait for process
1654+ waitProcess (& pconfig , t )
1655+
1656+ outputLs := string (stdout .Bytes ())
1657+
1658+ // Check that the ls output has /etc/passwd
1659+ if ! strings .Contains (outputLs , "/etc/passwd" ) {
1660+ t .Fatalf ("/etc/passwd not copied up as expected: %v" , outputLs )
1661+ }
1662+ }
0 commit comments