[apparmor] test-aa-easyprof.py fails because of UsrMove

Seth Arnold seth.arnold at canonical.com
Mon Mar 3 20:25:38 UTC 2014


On Mon, Mar 03, 2014 at 11:03:20AM -0800, Steve Beattie wrote:
> Stylistically, I'd rather do something like the following patch. I'd
> prefer not to add more code to the __main__ section, because it acts
> as an impediment to getting tools like nosetests[1] functioning for
> the tests, which lets you cherry pick out an individual test or two,
> useful for debugging a failing test without needing to run them
> all. While test-aa-easyprof.py has other things going in __main__
> that prevent this from working, we shouldn't add to it.
> 
> [1] See https://nose.readthedocs.org/en/latest/
> 
> Signed-off-by: Steve Beattie <steve at nxnw.org>

I like this, feels simple.

Acked-by: Seth Arnold <seth.arnold at canonical.com>

Thanks

> ---
>  utils/test/test-aa-easyprof.py |   10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> Index: b/utils/test/test-aa-easyprof.py
> ===================================================================
> --- a/utils/test/test-aa-easyprof.py
> +++ b/utils/test/test-aa-easyprof.py
> @@ -100,6 +100,10 @@ class Manifest(object):
>  # Our test class
>  #
>  class T(unittest.TestCase):
> +
> +    # work around UsrMove
> +    ls = os.path.realpath('/bin/ls')
> +
>      def setUp(self):
>          '''Setup for tests'''
>          global topdir
> @@ -424,14 +428,14 @@ POLICYGROUPS_DIR="%s/templates"
>  #
>      def test_binary_without_profile_name(self):
>          '''Test binary (<binary> { })'''
> -        easyprof.AppArmorEasyProfile('/bin/ls', self.options)
> +        easyprof.AppArmorEasyProfile(self.ls, self.options)
>  
>      def test_binary_with_profile_name(self):
>          '''Test binary (profile <name> <binary> { })'''
>          args = self.full_args
>          args += ['--profile-name=some-profile-name']
>          (self.options, self.args) = easyprof.parse_args(args)
> -        easyprof.AppArmorEasyProfile('/bin/ls', self.options)
> +        easyprof.AppArmorEasyProfile(self.ls, self.options)
>  
>      def test_binary_omitted_with_profile_name(self):
>          '''Test binary (profile <name> { })'''
> @@ -1206,7 +1210,7 @@ POLICYGROUPS_DIR="%s/templates"
>      def test_gen_manifest_policy_with_binary_with_profile_name(self):
>          '''Test gen_manifest_policy (binary with profile name)'''
>          m = Manifest("test_gen_manifest_policy")
> -        m.add_binary('/bin/ls')
> +        m.add_binary(self.ls)
>          self._gen_manifest_policy(m)
>  
>      def test_gen_manifest_policy_without_binary_with_profile_name(self):
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20140303/dd44d224/attachment.pgp>


More information about the AppArmor mailing list