Hello, this patch adds tests for sub_str_to_mode() and split_log_mode() in aamode.py. These are the functions that Peter's patch changes.
Those tests were written with the "old" functions in place (without Peter's patch) to make sure they match the current behaviour. Spoiler: Peter's aamode.py patch passes all tests ;-) === added file 'utils/test/test-aamode.py' --- utils/test/test-aamode.py 1970-01-01 00:00:00 +0000 +++ utils/test/test-aamode.py 2014-11-26 22:55:53 +0000 @@ -0,0 +1,48 @@ +#! /usr/bin/env python +# ------------------------------------------------------------------ +# +# Copyright (C) 2014 Christian Boltz +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License published by the Free Software Foundation. +# +# ------------------------------------------------------------------ + +import unittest + +from apparmor.aamode import split_log_mode, sub_str_to_mode + +class AamodeTest_split_log_mode(unittest.TestCase): + def test_split_log_mode_1(self): + self.assertEqual(split_log_mode(''), ('', '')) + def test_split_log_mode_2(self): + self.assertEqual(split_log_mode('r'), ('r', 'r')) + def test_split_log_mode_3(self): + self.assertEqual(split_log_mode('r::'), ('r', '')) + def test_split_log_mode_4(self): + self.assertEqual(split_log_mode('::r'), ('', 'r')) + def test_split_log_mode_5(self): + self.assertEqual(split_log_mode('r::w'), ('r', 'w')) + +class AamodeTest_sub_str_to_mode(unittest.TestCase): + def test_sub_str_to_mode_1(self): + self.assertEqual(sub_str_to_mode(''), set()) + def test_sub_str_to_mode_2(self): + self.assertEqual(sub_str_to_mode('ix'), {'i', 'x'}) + def test_sub_str_to_mode_3(self): + self.assertEqual(sub_str_to_mode('rw'), {'r', 'w'}) + def test_sub_str_to_mode_4(self): + self.assertEqual(sub_str_to_mode('rPix'), {'i', 'P', 'r', 'x'}) + def test_sub_str_to_mode_5(self): + self.assertEqual(sub_str_to_mode('rPUx'), {'P', 'r', 'U', 'x'}) + def test_sub_str_to_mode_6(self): + self.assertEqual(sub_str_to_mode('cix'), {'i', 'x', 'C', 'execunsafe'}) + def test_sub_str_to_mode_7(self): + self.assertEqual(sub_str_to_mode('rwlk'), {'k', 'r', 'l', 'w'}) + def test_sub_str_to_mode_8(self): + self.assertEqual(sub_str_to_mode('asdf42'), {'a'}) + + +if __name__ == '__main__': + unittest.main(verbosity=2) Regards, Christian Boltz -- > Was haltet ihr von Lindows?? Tonne auf, Lindows rein, Lindows 'Erfinder' dazustopfen, Tonne zu, mit Stacheldraht umwickeln, in die Sonne schiessen. Problem gelöst.. [> Glenn Charpantier und Phillip Richdale in suse-linux] -- AppArmor mailing list AppArmor@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor