All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH/RFC 0/2] Test failures when building sepolgen
@ 2013-05-11 18:54 Sven Vermeulen
  2013-05-11 18:56 ` [PATCH/RFC 1/2] Fix test that compares matchlist length Sven Vermeulen
  2013-05-11 18:57 ` [PATCH/RFC 2/2] Fix AttributeError: 'dict' object has no attribute 'attributes' Sven Vermeulen
  0 siblings, 2 replies; 3+ messages in thread
From: Sven Vermeulen @ 2013-05-11 18:54 UTC (permalink / raw)
  To: selinux

Please find the following two patch suggestions for test failures while
building sepolgen (and running its provided tests). Asking a bit for
comments as well since I'm not sure if a fix should go either way (i.e.
update test or update code).

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH/RFC 1/2] Fix test that compares matchlist length
  2013-05-11 18:54 [PATCH/RFC 0/2] Test failures when building sepolgen Sven Vermeulen
@ 2013-05-11 18:56 ` Sven Vermeulen
  2013-05-11 18:57 ` [PATCH/RFC 2/2] Fix AttributeError: 'dict' object has no attribute 'attributes' Sven Vermeulen
  1 sibling, 0 replies; 3+ messages in thread
From: Sven Vermeulen @ 2013-05-11 18:56 UTC (permalink / raw)
  To: selinux

When running the tests, the following failure occurs:

======================================================================
FAIL: test_append (test_matching.TestMatchList)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/var/portage/portage/dev-python/sepolgen-1.1.9-r1/work/sepolgen-1.1.9-2.7/tests/test_matching.py", line 94, in test_append
    self.assertEqual(len(ml), 1)
AssertionError: 2 != 1

>From the test code, it looks like we use the matchlist length as a way to deduce
if an .append() did the right thing or not (i.e. add to bastards or children).
However, the length for the matchlist is defined as the sum of the lengths of
both:

    def __len__(self):
        # Only return the length of the matches so
        # that this can be used to test if there is
        # a match.
        return len(self.children) + len(self.bastards)

As a result, the len(ml) should always increase with an append, and then check
the length of one of the two sublists (children or bastards) to find out if this
occurred in the right sublist.

Signed-off-by: Sven Vermeulen <sven.vermeulen@siphos.be>
---
 sepolgen/tests/test_matching.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sepolgen/tests/test_matching.py b/sepolgen/tests/test_matching.py
index 2282eca..161e001 100644
--- a/sepolgen/tests/test_matching.py
+++ b/sepolgen/tests/test_matching.py
@@ -56,7 +56,7 @@ class TestMatchList(unittest.TestCase):
         a = matching.Match()
         a.dist = 200
         ml.append(a)
-        self.assertEqual(len(ml), 1)
+        self.assertEqual(len(ml), 2)
         self.assertEqual(len(ml.bastards), 1)
 
         ml.allow_info_dir_change = False
@@ -64,7 +64,7 @@ class TestMatchList(unittest.TestCase):
         a.dist = 0
         a.info_dir_change = True
         ml.append(a)
-        self.assertEqual(len(ml), 1)
+        self.assertEqual(len(ml), 3)
         self.assertEqual(len(ml.bastards), 2)
 
     def test_sort(self):
-- 
1.8.1.5


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH/RFC 2/2] Fix AttributeError: 'dict' object has no attribute 'attributes'
  2013-05-11 18:54 [PATCH/RFC 0/2] Test failures when building sepolgen Sven Vermeulen
  2013-05-11 18:56 ` [PATCH/RFC 1/2] Fix test that compares matchlist length Sven Vermeulen
@ 2013-05-11 18:57 ` Sven Vermeulen
  1 sibling, 0 replies; 3+ messages in thread
From: Sven Vermeulen @ 2013-05-11 18:57 UTC (permalink / raw)
  To: selinux

While running the tests, the test_export one fails as follows:

======================================================================
ERROR: test_export (test_interfaces.TestInterfaceSet)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/var/portage/portage/dev-python/sepolgen-1.1.9-r1/work/sepolgen-1.1.9-2.7/tests/test_interfaces.py", line 263, in test_export
    i.add_headers(h)
  File "../src/./sepolgen/interfaces.py", line 412, in add_headers
    self.add(i, attributes)
  File "../src/./sepolgen/interfaces.py", line 407, in add
    ifv = InterfaceVector(interface, attributes)
  File "../src/./sepolgen/interfaces.py", line 257, in __init__
    self.from_interface(interface, attributes)
  File "../src/./sepolgen/interfaces.py", line 279, in from_interface
    if not attributes.attributes.has_key(attr):
AttributeError: 'dict' object has no attribute 'attributes'

Not sure about the fix here, I'm guessing those we have an "attributes" too
many.

Signed-off-by: Sven Vermeulen <sven.vermeulen@siphos.be>
---
 sepolgen/src/sepolgen/interfaces.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sepolgen/src/sepolgen/interfaces.py b/sepolgen/src/sepolgen/interfaces.py
index ae1c9c5..23d2d11 100644
--- a/sepolgen/src/sepolgen/interfaces.py
+++ b/sepolgen/src/sepolgen/interfaces.py
@@ -276,7 +276,7 @@ class InterfaceVector:
         if attributes != None:
             for typeattribute in interface.typeattributes():
                 for attr in typeattribute.attributes:
-                    if not attributes.attributes.has_key(attr):
+                    if not attributes.has_key(attr):
                         # print "missing attribute " + attr
                         continue
                     attr_vec = attributes.attributes[attr]
-- 
1.8.1.5


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-05-13  3:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-11 18:54 [PATCH/RFC 0/2] Test failures when building sepolgen Sven Vermeulen
2013-05-11 18:56 ` [PATCH/RFC 1/2] Fix test that compares matchlist length Sven Vermeulen
2013-05-11 18:57 ` [PATCH/RFC 2/2] Fix AttributeError: 'dict' object has no attribute 'attributes' Sven Vermeulen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.