diff -ruN b/lib/adt_run_args.py a/lib/adt_run_args.py --- b/lib/adt_run_args.py 2016-02-23 21:56:50.000000000 +0500 +++ a/lib/adt_run_args.py 2016-03-08 01:34:01.853605039 +0500 @@ -282,6 +282,8 @@ g_setup.add_argument('--env', metavar='VAR=value', action='append', default=[], help='Set arbitrary environment variable for builds and test') + g_setup.add_argument('--no-restore-apparmor-click', action='store_true', + help='Don\'t restore apparmor rules after test run') # privileges g_priv = parser.add_argument_group('user/privilege handling options') diff -ruN b/lib/adt_testbed.py a/lib/adt_testbed.py --- b/lib/adt_testbed.py 2016-02-23 21:56:50.000000000 +0500 +++ a/lib/adt_testbed.py 2016-03-08 01:31:36.481603320 +0500 @@ -747,7 +747,7 @@ ' . ~/.profile >/dev/null 2>&1 || true; ' '[ -z "$UPSTART_SESSION" ] || /sbin/initctl --user start click-user-hooks']) - def apparmor_click(self, clickpkgs, installed_clicks): + def apparmor_click(self, clickpkgs, installed_clicks, force=True): '''Update AppArmor rules for click tests Return True if anything was modified and apparmor_restore_click() @@ -796,7 +796,11 @@ ' '.join(installed_clicks)) else: adtlog.info('Updating AppArmor rules to allow autopilot introspection for all clicks (will take a minute)...') - script += 'aa-clickhook --force --include=/var/cache/apparmor/click-ap.rules' + # Maintain backwards compatibility and always use --force, unless specified. + if force: + script += 'aa-clickhook --force --include=/var/cache/apparmor/click-ap.rules' + else: + script += 'aa-clickhook --include=/var/cache/apparmor/click-ap.rules' if self.execute(['sh', adtlog.verbosity >= 2 and '-exc' or '-ec', script], kind='install')[0] != 0: self.bomb('Failed to update click AppArmor rules') @@ -864,7 +868,7 @@ adtlog.info(' - - - - - - - - - - running shell - - - - - - - - - -') self.command('shell', [cwd or '/'] + self.install_tmp_env) - def run_test(self, tree, test, extra_env=[], shell_on_failure=False, shell=False): + def run_test(self, tree, test, extra_env=[], shell_on_failure=False, shell=False, restore_apparmor_click=True): '''Run given test in testbed tree (a Path) is the source tree root. @@ -879,7 +883,7 @@ for c in test.clicks: self.install_click(c) - need_click_restore = self.apparmor_click(test.clicks, test.installed_clicks) + need_click_restore = self.apparmor_click(test.clicks, test.installed_clicks, force=restore_apparmor_click) # record installed package versions if self.output_dir and self.execute(['which', 'dpkg-query'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)[0] == 0: @@ -1083,7 +1087,7 @@ if shell or (shell_on_failure and not test.result): self.run_shell(tree.tb) - if need_click_restore: + if restore_apparmor_click and need_click_restore: self.apparmor_restore_click(test.clicks, test.installed_clicks) else: adtlog.debug('no need to restore click AppArmor profiles') diff -ruN b/runner/adt-run a/runner/adt-run --- b/runner/adt-run 2016-02-23 21:56:50.000000000 +0500 +++ a/runner/adt-run 2016-03-08 01:28:59.321601461 +0500 @@ -148,7 +148,8 @@ binaries.publish() testbed.install_deps(t.depends, 'needs-recommends' in t.restrictions) - testbed.run_test(tree, t, opts.env, opts.shell_fail, opts.shell) + testbed.run_test(tree, t, opts.env, opts.shell_fail, opts.shell, + not opts.no_restore_apparmor_click) if not t.result: errorcode |= 4 if 'breaks-testbed' in t.restrictions: