JustBeforeEach(func() { rlimits.Nofile = &noFileValue }) It("returns an error", func() { Expect(mgr.Apply(rlimits)).To(MatchError("container_daemon: setting rlimit: operation not permitted")) }) }) Context("Setting an RLimit", func() { var rLimitValue uint64 BeforeEach(func() { rLimitValue = 9000 rlimits.Core = &rLimitValue prevRlimit = new(syscall.Rlimit) err := syscall.Getrlimit(container_daemon.RLIMIT_CORE, prevRlimit) Expect(err).ToNot(HaveOccurred()) }) AfterEach(func() { err := syscall.Setrlimit(container_daemon.RLIMIT_CORE, prevRlimit) Expect(err).ToNot(HaveOccurred()) }) It("sets appropriate resource limit", func() { Expect(mgr.Apply(rlimits)).To(Succeed()) Expect(syscall.Getrlimit(container_daemon.RLIMIT_CORE, &systemRlimits)).To(Succeed()) Expect(systemRlimits.Cur).To(Equal(rLimitValue))