On Tue, Oct 11, 2016 at 12:39:58PM -0700, Seth Arnold wrote:
> On Sun, Oct 09, 2016 at 08:32:48PM +0200, Christian Boltz wrote:
> > +class AamodeTest_str_to_mode(AATest):
> > + tests = [
> > + ('x', apparmor.aamode.AA_MAY_EXEC),
> > + ('w', apparmor.aamode.AA_MAY_WRITE),
> > + ('r', apparmor.aamode.AA_MAY_READ),
> > + ('a', apparmor.aamode.AA_MAY_APPEND),
> > + ('l', apparmor.aamode.AA_MAY_LINK),
> > + ('k', apparmor.aamode.AA_MAY_LOCK),
> > + ('m', apparmor.aamode.AA_EXEC_MMAP),
> > + ('i', apparmor.aamode.AA_EXEC_INHERIT),
> > + ('u', apparmor.aamode.AA_EXEC_UNCONFINED |
> > apparmor.aamode.AA_EXEC_UNSAFE),
> > + ('U', apparmor.aamode.AA_EXEC_UNCONFINED),
> > + ('p', apparmor.aamode.AA_EXEC_PROFILE |
> > apparmor.aamode.AA_EXEC_UNSAFE),
> > + ('P', apparmor.aamode.AA_EXEC_PROFILE),
> > + ('c', apparmor.aamode.AA_EXEC_CHILD |
> > apparmor.aamode.AA_EXEC_UNSAFE),
> > + ('C', apparmor.aamode.AA_EXEC_CHILD),
> > + ]
>
> I didn't find where this 'tests' array is actually used in the patch.
>
> Also, 'tests' is a bit generic -- is there a better description of what
> this array mapping actually provides?
>
> A dictionary would allow quicker lookups from key to value; an array
> makes more sense if it's only ever iterated, or if lookups can go both
> directions. But since I didn't find any use of this array it's hard to
> guess which would be better. :)The AATest class in the common_test.py that AamodeTest_str_to_mode is subsclassing from causes it to be used. Basically, the way it works is you define a 'tests' array, a _run_test() method, and make a call to setup_all_loops() in your test script, and test methods will be generated based on the array entries being passed to _run_test(). The idea here is to avoid code duplication when running many similar tests, as well as trying to make adding tests as simple as adding an additional entry in array (c.f. my followup to the original patch). -- Steve Beattie <[email protected]> http://NxNW.org/~steve/
signature.asc
Description: PGP signature
-- AppArmor mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
