func (s *appArmorSuite) TestLoadProfileRunsAppArmorParserReplace(c *C) { cmd := testutil.MockCommand(c, "apparmor_parser", "") defer cmd.Restore() err := apparmor.LoadProfile("/path/to/snap.samba.smbd") c.Assert(err, IsNil) c.Assert(cmd.Calls(), DeepEquals, [][]string{ {"apparmor_parser", "--replace", "--write-cache", "-O", "no-expr-simplify", "--cache-loc=/var/cache/apparmor", "/path/to/snap.samba.smbd"}, }) }
func (s *appArmorSuite) TestLoadProfileReportsErrors(c *C) { cmd := testutil.MockCommand(c, "apparmor_parser", "exit 42") defer cmd.Restore() err := apparmor.LoadProfile("/path/to/snap.samba.smbd") c.Assert(err.Error(), Equals, `cannot load apparmor profile: exit status 42 apparmor_parser output: `) c.Assert(cmd.Calls(), DeepEquals, [][]string{ {"apparmor_parser", "--replace", "--write-cache", "-O", "no-expr-simplify", "--cache-loc=/var/cache/apparmor", "/path/to/snap.samba.smbd"}, }) }