[apparmor] [patch] Post merge test fixes

Kshitij Gupta kgupta8592 at gmail.com
Thu Feb 27 13:04:42 UTC 2014


Hello,

I ran the tests locally using apparmor/utils/test/runtests-py2.sh and
ended up with a lot of broken tests. I've fixed the tests for the
tools, which required adapting to new directory structure and fixing a
couple of values. The following patch fixes them.

However, I still get errors from test-aa-decode.py and test-aa-easyprof.py.

Regards,

Kshitij Gupta

=== modified file 'utils/test/config_test.py'
--- utils/test/config_test.py	2014-02-13 00:59:27 +0000
+++ utils/test/config_test.py	2014-02-27 12:35:48 +0000
@@ -37,8 +37,8 @@
         shell_config.CONF_DIR = '.'
         conf = shell_config.read_config('easyprof.conf')
         easyprof_sections = ['POLICYGROUPS_DIR', 'TEMPLATES_DIR']
-        easyprof_Policygroup = '/usr/share/apparmor/easyprof/policygroups'
-        easyprof_Templates = '/usr/share/apparmor/easyprof/templates'
+        easyprof_Policygroup = './policygroups'
+        easyprof_Templates = './templates'

         self.assertEqual(sorted(list(conf[''].keys())),
sorted(easyprof_sections))
         self.assertEqual(conf['']['POLICYGROUPS_DIR'], easyprof_Policygroup)

=== modified file 'utils/test/minitools_test.py'
--- utils/test/minitools_test.py	2014-02-13 00:59:27 +0000
+++ utils/test/minitools_test.py	2014-02-27 12:38:53 +0000
@@ -34,57 +34,57 @@

     def test_audit(self):
         #Set ntpd profile to audit mode and check if it was correctly set
-        str(subprocess.check_output('%s ./../Tools/aa-audit -d
./profiles %s'%(python_interpreter, test_path), shell=True))
+        str(subprocess.check_output('%s ./../aa-audit -d ./profiles
%s'%(python_interpreter, test_path), shell=True))

         self.assertEqual(apparmor.get_profile_flags(local_profilename,
test_path), 'audit', 'Audit flag could not be set in profile
%s'%local_profilename)

         #Remove audit mode from ntpd profile and check if it was
correctly removed
-        subprocess.check_output('%s ./../Tools/aa-audit -d ./profiles
-r %s'%(python_interpreter, test_path), shell=True)
+        subprocess.check_output('%s ./../aa-audit -d ./profiles -r
%s'%(python_interpreter, test_path), shell=True)

         self.assertEqual(apparmor.get_profile_flags(local_profilename,
test_path), None, 'Complain flag could not be removed in profile
%s'%local_profilename)


     def test_complain(self):
         #Set ntpd profile to complain mode and check if it was correctly set
-        subprocess.check_output('%s ./../Tools/aa-complain -d
./profiles %s'%(python_interpreter, test_path), shell=True)
+        subprocess.check_output('%s ./../aa-complain -d ./profiles
%s'%(python_interpreter, test_path), shell=True)

         self.assertEqual(os.path.islink('./profiles/force-complain/%s'%os.path.basename(local_profilename)),
True, 'Failed to create a symlink for %s in
force-complain'%local_profilename)
         self.assertEqual(apparmor.get_profile_flags(local_profilename,
test_path), 'complain', 'Complain flag could not be set in profile
%s'%local_profilename)

         #Set ntpd profile to enforce mode and check if it was correctly set
-        subprocess.check_output('%s ./../Tools/aa-complain -d
./profiles -r %s'%(python_interpreter, test_path), shell=True)
+        subprocess.check_output('%s ./../aa-complain -d ./profiles -r
%s'%(python_interpreter, test_path), shell=True)

         self.assertEqual(os.path.islink('./profiles/force-complain/%s'%os.path.basename(local_profilename)),
False, 'Failed to remove symlink for %s from
force-complain'%local_profilename)
         self.assertEqual(os.path.islink('./profiles/disable/%s'%os.path.basename(local_profilename)),
False, 'Failed to remove symlink for %s from
disable'%local_profilename)
         self.assertEqual(apparmor.get_profile_flags(local_profilename,
test_path), None, 'Complain flag could not be removed in profile
%s'%local_profilename)

         # Set audit flag and then complain flag in a profile
-        subprocess.check_output('%s ./../Tools/aa-audit -d ./profiles
%s'%(python_interpreter, test_path), shell=True)
-        subprocess.check_output('%s ./../Tools/aa-complain -d
./profiles %s'%(python_interpreter, test_path), shell=True)
+        subprocess.check_output('%s ./../aa-audit -d ./profiles
%s'%(python_interpreter, test_path), shell=True)
+        subprocess.check_output('%s ./../aa-complain -d ./profiles
%s'%(python_interpreter, test_path), shell=True)

         self.assertEqual(os.path.islink('./profiles/force-complain/%s'%os.path.basename(local_profilename)),
True, 'Failed to create a symlink for %s in
force-complain'%local_profilename)
         self.assertEqual(apparmor.get_profile_flags(local_profilename,
test_path), 'audit,complain', 'Complain flag could not be set in
profile %s'%local_profilename)

         #Remove complain flag first i.e. set to enforce mode
-        subprocess.check_output('%s ./../Tools/aa-complain -d
./profiles -r %s'%(python_interpreter, test_path), shell=True)
+        subprocess.check_output('%s ./../aa-complain -d ./profiles -r
%s'%(python_interpreter, test_path), shell=True)

         self.assertEqual(os.path.islink('./profiles/force-complain/%s'%os.path.basename(local_profilename)),
False, 'Failed to remove symlink for %s from
force-complain'%local_profilename)
         self.assertEqual(os.path.islink('./profiles/disable/%s'%os.path.basename(local_profilename)),
False, 'Failed to remove symlink for %s from
disable'%local_profilename)
         self.assertEqual(apparmor.get_profile_flags(local_profilename,
test_path), 'audit', 'Complain flag could not be removed in profile
%s'%local_profilename)

         #Remove audit flag
-        subprocess.check_output('%s ./../Tools/aa-audit -d ./profiles
-r %s'%(python_interpreter, test_path), shell=True)
+        subprocess.check_output('%s ./../aa-audit -d ./profiles -r
%s'%(python_interpreter, test_path), shell=True)

     def test_enforce(self):
         #Set ntpd profile to complain mode and check if it was correctly set
-        subprocess.check_output('%s ./../Tools/aa-enforce -d
./profiles -r %s'%(python_interpreter, test_path), shell=True)
+        subprocess.check_output('%s ./../aa-enforce -d ./profiles -r
%s'%(python_interpreter, test_path), shell=True)

         self.assertEqual(os.path.islink('./profiles/force-complain/%s'%os.path.basename(local_profilename)),
True, 'Failed to create a symlink for %s in
force-complain'%local_profilename)
         self.assertEqual(apparmor.get_profile_flags(local_profilename,
test_path), 'complain', 'Complain flag could not be set in profile
%s'%local_profilename)


         #Set ntpd profile to enforce mode and check if it was correctly set
-        subprocess.check_output('%s ./../Tools/aa-enforce -d
./profiles %s'%(python_interpreter, test_path), shell=True)
+        subprocess.check_output('%s ./../aa-enforce -d ./profiles
%s'%(python_interpreter, test_path), shell=True)

         self.assertEqual(os.path.islink('./profiles/force-complain/%s'%os.path.basename(local_profilename)),
False, 'Failed to remove symlink for %s from
force-complain'%local_profilename)
         self.assertEqual(os.path.islink('./profiles/disable/%s'%os.path.basename(local_profilename)),
False, 'Failed to remove symlink for %s from
disable'%local_profilename)
@@ -93,12 +93,12 @@

     def test_disable(self):
         #Disable the ntpd profile and check if it was correctly disabled
-        subprocess.check_output('%s ./../Tools/aa-disable -d
./profiles %s'%(python_interpreter, test_path), shell=True)
+        subprocess.check_output('%s ./../aa-disable -d ./profiles
%s'%(python_interpreter, test_path), shell=True)

         self.assertEqual(os.path.islink('./profiles/disable/%s'%os.path.basename(local_profilename)),
True, 'Failed to create a symlink for %s in
disable'%local_profilename)

         #Enable the ntpd profile and check if it was correctly re-enabled
-        subprocess.check_output('%s ./../Tools/aa-disable -d
./profiles -r %s'%(python_interpreter, test_path), shell=True)
+        subprocess.check_output('%s ./../aa-disable -d ./profiles -r
%s'%(python_interpreter, test_path), shell=True)

         self.assertEqual(os.path.islink('./profiles/disable/%s'%os.path.basename(local_profilename)),
False, 'Failed to remove a symlink for %s from
disable'%local_profilename)

@@ -107,9 +107,9 @@
         pass

     def test_unconfined(self):
-        output = subprocess.check_output('%s
./../Tools/aa-unconfined'%python_interpreter, shell=True)
+        output = subprocess.check_output('%s
./../aa-unconfined'%python_interpreter, shell=True)

-        output_force = subprocess.check_output('%s
./../Tools/aa-unconfined --paranoid'%python_interpreter, shell=True)
+        output_force = subprocess.check_output('%s ./../aa-unconfined
--paranoid'%python_interpreter, shell=True)

         self.assertIsNot(output, '', 'Failed to run aa-unconfined')

@@ -124,7 +124,7 @@
         #Our silly test program whose profile we wish to clean
         cleanprof_test = '/usr/bin/a/simple/cleanprof/test/profile'

-        subprocess.check_output('%s ./../Tools/aa-cleanprof  -d
./profiles -s %s' % (python_interpreter, cleanprof_test), shell=True)
+        subprocess.check_output('%s ./../aa-cleanprof  -d ./profiles
-s %s' % (python_interpreter, cleanprof_test), shell=True)

         #Strip off the first line (#modified line)
         subprocess.check_output('sed -i 1d
./profiles/%s'%(input_file), shell=True)



More information about the AppArmor mailing list