Re: [apparmor] [patch] utils/test/test-aa.py: skip tests that break with python2.7

2016-09-21 Thread Christian Boltz
Hello,

Am Mittwoch, 21. September 2016, 12:39:14 CEST schrieb Steve Beattie:
> On Tue, Sep 20, 2016 at 09:54:02PM +0200, Christian Boltz wrote:

> > I get similar py2 failures in AaTest_create_new_profile, so you
> > might
> > want to apply your patch to this class also. Consider this
> > 
> > Pre-Acked-by: Christian Boltz 
> 
> Interesting, I'm unable to reproduce it for that test class. Do you
> have example output?

The FileRule series [15/38] patch adds using fake_ldd to 
AaTest_create_new_profile, so it's not surprising that you don't see it 
yet ;-)

With the patch applied, you'll get

==
ERROR: test_1 (__main__.AaTest_create_new_profile)
test 'foo bar'
--
Traceback (most recent call last):
  File "/home/cb/apparmor/HEAD-clean/utils/test/common_test.py", line 88, in 
stub_test
self._run_test(test_data, expected)
  File "test-aa.py", line 126, in _run_test
profile = create_new_profile(program)
  File "/home/cb/apparmor/HEAD-clean/utils/apparmor/aa.py", line 529, in 
create_new_profile
handle_binfmt(local_profile[localfile], localfile)
  File "/home/cb/apparmor/HEAD-clean/utils/apparmor/aa.py", line 389, in 
handle_binfmt
reqs = get_reqs(path)
  File "/home/cb/apparmor/HEAD-clean/utils/apparmor/aa.py", line 383, in 
get_reqs
raise AppArmorBug('%(ldd)s %(file)s failed with exit status %(ret)s' % 
{'ldd': ldd, 'file': file, 'ret': ret})
AppArmorBug: /usr/bin/ldd /tmp/aa-test-GmA1yC/script failed with exit status 1

==
FAIL: test_0 (__main__.AaTest_create_new_profile)
test '#!/bin/bash
--
Traceback (most recent call last):
  File "/home/cb/apparmor/HEAD-clean/utils/test/common_test.py", line 88, in 
stub_test
self._run_test(test_data, expected)
  File "test-aa.py", line 130, in _run_test
'/AATest/lib64/libtinfo.so.* mr,', '/AATest/lib64/libc.so.* mr,', 
'/AATest/lib64/libdl.so.* mr,', '/AATest/lib64/libreadline.so.* mr,', 
'/AATest/lib64/ld-linux-x86-64.so.* mr,' })
AssertionError: Items in the second set but not the first:
'/AATest/lib64/libdl.so.* mr,'
'/AATest/lib64/libreadline.so.* mr,'
'/AATest/lib64/ld-linux-x86-64.so.* mr,'
'/AATest/lib64/libc.so.* mr,'
'/AATest/lib64/libtinfo.so.* mr,'

--


Since this is caused by the FileRule series, I'll send an updated [15/38] 
patch. I need to do that anyway because your little commit breaks 
applying this patch :-/ - but on the positive side, I can add skipping
that test in py2 while on it.

Note to myself: Never send out acks to little patches while a big patch 
series is pending. Especially if this big series should be reviewed 
since a month!


Regards,

Christian Boltz
-- 
> Again, apt is dead, there is no maintainership upstream -- let's
> leave this sinking ship NOW.
Don't forget we are on the sea and not at the harbour.
So leaving the ship will end in the water as long as the new ship is
not ready.   [> Christoph Thiel and Eberhard Moenkeberg in opensuse]


signature.asc
Description: This is a digitally signed message part.
-- 
AppArmor mailing list
AppArmor@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/apparmor


Re: [apparmor] [patch] utils/test/test-aa.py: skip tests that break with python2.7

2016-09-21 Thread Steve Beattie
On Tue, Sep 20, 2016 at 09:54:02PM +0200, Christian Boltz wrote:
> Am Dienstag, 20. September 2016, 12:03:57 CEST schrieb Steve Beattie:
> > Currently, the utils/ make check tests fail when run under
> > python2.7.  For reasons that aren't entirely clear, the action to set
> > apparmor.aa.cfg['settings']['ldd'] to './fake_ldd' does not actually
> > work on python2.7, so get_reqs() tries to use /usr/bin/ldd anyway
> > (printing out the contents of apparmor.aa.cfg['settings']['ldd']
> > after the set operation in _run_test() shows it to still contain
> > '/usr/bin/ldd' o.O). 
> 
> That sounds interesting[tm]. At least it isn't something only you see - 
> I can reproduce it here.
> 
> Maybe the reason is that py2 and py3 use different {c,C}onfigparser 
> python modules to read the config file (see apparmor/config.py) - but I'm 
> still surprised why the py2 result seems to be read-only and the py3 
> result isn't. And I'm even more surprised that, assuming the py2 result 
> is really read-only, we don't get an exception when trying to write to 
> it.

Yeah, it's really goofy, and I don't understand why it happens. Another
possibility is that somehow the unittest test isolation is interfering
in some way, but I don't really see how.

> > Therefore, skip these two tests when running
> > under python2.7.
> 
> That's not really nice, but the easiest solution ;-)

Yeah, was not thrilled to just skip these tests, but attempts at
getting the config to change failed.

> > +print("Skipping on python < 2.x")
> 
> This message is wrong - it should say "... python 2.x", not 
> "... python < 2.x" (which effectively means 1.x)
>
> With the skip message changed,
> Acked-by: Christian Boltz 

Nice catch, fixed and committed. Thanks for the review!

> I get similar py2 failures in AaTest_create_new_profile, so you might 
> want to apply your patch to this class also. Consider this
> Pre-Acked-by: Christian Boltz 

Interesting, I'm unable to reproduce it for that test class. Do you
have example output?

-- 
Steve Beattie

http://NxNW.org/~steve/


signature.asc
Description: PGP signature
-- 
AppArmor mailing list
AppArmor@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/apparmor


Re: [apparmor] [patch] utils/test/test-aa.py: skip tests that break with python2.7

2016-09-20 Thread Christian Boltz
Hello,

Am Dienstag, 20. September 2016, 12:03:57 CEST schrieb Steve Beattie:
> Currently, the utils/ make check tests fail when run under
> python2.7.  For reasons that aren't entirely clear, the action to set
> apparmor.aa.cfg['settings']['ldd'] to './fake_ldd' does not actually
> work on python2.7, so get_reqs() tries to use /usr/bin/ldd anyway
> (printing out the contents of apparmor.aa.cfg['settings']['ldd']
> after the set operation in _run_test() shows it to still contain
> '/usr/bin/ldd' o.O). 

That sounds interesting[tm]. At least it isn't something only you see - 
I can reproduce it here.

Maybe the reason is that py2 and py3 use different {c,C}onfigparser 
python modules to read the config file (see apparmor/config.py) - but I'm 
still surprised why the py2 result seems to be read-only and the py3 
result isn't. And I'm even more surprised that, assuming the py2 result 
is really read-only, we don't get an exception when trying to write to 
it.

> Therefore, skip these two tests when running
> under python2.7.

That's not really nice, but the easiest solution ;-)

> Signed-off-by: Steve Beattie 
> ---
>  utils/test/test-aa.py |7 +++
>  1 file changed, 7 insertions(+)
> 
> Index: b/utils/test/test-aa.py
> ===
> --- a/utils/test/test-aa.py
> +++ b/utils/test/test-aa.py
> @@ -14,6 +14,7 @@ from common_test import AATest, setup_al
>  from common_test import read_file, write_file
> 
>  import os
> +import sys
> 
>  import apparmor.aa  # needed to set global vars in some tests
>  from apparmor.aa import (check_for_apparmor, get_output, get_reqs,
> get_interpreter_and_abstraction, create_new_profile, @@ -93,6 +94,12
> @@ class AATest_get_reqs(AATest):
>  ]
> 
>  def _run_test(self, params, expected):
> +# for some reason, setting the ldd config option does not get
> +# honored in python2.7
> +# XXX KILL when python 2.7 is dropped XXX
> +if sys.version_info[0] < 3:
> +print("Skipping on python < 2.x")

This message is wrong - it should say "... python 2.x", not 
"... python < 2.x" (which effectively means 1.x)

> +return
>  apparmor.aa.cfg['settings']['ldd'] = './fake_ldd'
> 
>  self.assertEqual(get_reqs(params), expected)

With the skip message changed,
Acked-by: Christian Boltz 


I get similar py2 failures in AaTest_create_new_profile, so you might 
want to apply your patch to this class also. Consider this
Pre-Acked-by: Christian Boltz 


Regards,

Christian Boltz
-- 
Manchmal stellt man halt Fragen, auf die keiner eine Antwort hat.
(Habe ich hier auch schon hingekriegt). [Helga Fischer in opensuse-de]


signature.asc
Description: This is a digitally signed message part.
-- 
AppArmor mailing list
AppArmor@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/apparmor


[apparmor] [patch] utils/test/test-aa.py: skip tests that break with python2.7

2016-09-20 Thread Steve Beattie
Currently, the utils/ make check tests fail when run under
python2.7.  For reasons that aren't entirely clear, the action to set
apparmor.aa.cfg['settings']['ldd'] to './fake_ldd' does not actually
work on python2.7, so get_reqs() tries to use /usr/bin/ldd anyway
(printing out the contents of apparmor.aa.cfg['settings']['ldd']
after the set operation in _run_test() shows it to still contain
'/usr/bin/ldd' o.O). Therefore, skip these two tests when running
under python2.7.

Signed-off-by: Steve Beattie 
---
 utils/test/test-aa.py |7 +++
 1 file changed, 7 insertions(+)

Index: b/utils/test/test-aa.py
===
--- a/utils/test/test-aa.py
+++ b/utils/test/test-aa.py
@@ -14,6 +14,7 @@ from common_test import AATest, setup_al
 from common_test import read_file, write_file
 
 import os
+import sys
 
 import apparmor.aa  # needed to set global vars in some tests
 from apparmor.aa import (check_for_apparmor, get_output, get_reqs, 
get_interpreter_and_abstraction, create_new_profile,
@@ -93,6 +94,12 @@ class AATest_get_reqs(AATest):
 ]
 
 def _run_test(self, params, expected):
+# for some reason, setting the ldd config option does not get
+# honored in python2.7
+# XXX KILL when python 2.7 is dropped XXX
+if sys.version_info[0] < 3:
+print("Skipping on python < 2.x")
+return
 apparmor.aa.cfg['settings']['ldd'] = './fake_ldd'
 
 self.assertEqual(get_reqs(params), expected)
-- 
Steve Beattie

http://NxNW.org/~steve/


signature.asc
Description: PGP signature
-- 
AppArmor mailing list
AppArmor@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/apparmor