[apparmor] [patch 07/10] libapparmor - in C test, restructure event case.

Tyler Hicks tyhicks at canonical.com
Fri Sep 6 18:32:03 UTC 2013


On 2013-09-05 01:37:02, Steve Beattie wrote:
> This patch wraps the event record output cases in a macro, for
> consistent generation.
> 
> Signed-off-by: Steve Beattie <steve at nxnw.org>

Acked-by: Tyler Hicks <tyhicks at canonical.com>

> 
> ---
>  libraries/libapparmor/testsuite/test_multi.c |   55 +++++++--------------------
>  1 file changed, 16 insertions(+), 39 deletions(-)
> 
> Index: b/libraries/libapparmor/testsuite/test_multi.c
> ===================================================================
> --- a/libraries/libapparmor/testsuite/test_multi.c
> +++ b/libraries/libapparmor/testsuite/test_multi.c
> @@ -63,52 +63,29 @@ int main(int argc, char **argv)
>  		printf("%s: %ld\n", (description), (var)); \
>  	}
>  
> +#define event_case(event) \
> +	case event: { \
> +		print_string("Event type", #event ); \
> +		break; \
> +	}
> +
>  int print_results(aa_log_record *record)
>  {
> -		printf("Event type: ");
>  		switch(record->event)
>  		{
> -			case AA_RECORD_ERROR:
> -			{
> -				printf("AA_RECORD_ERROR\n");
> -				break;
> -			}
> -			case AA_RECORD_INVALID:
> -			{
> -				printf("AA_RECORD_INVALID\n");
> -				break;
> -			}
> -			case AA_RECORD_AUDIT:
> -			{
> -				printf("AA_RECORD_AUDIT\n");
> -				break;
> -			}
> -			case AA_RECORD_ALLOWED:
> -			{
> -				printf("AA_RECORD_ALLOWED\n");
> -				break;
> -			}
> -			case AA_RECORD_DENIED:
> -			{
> -				printf("AA_RECORD_DENIED\n");
> -				break;
> -			}
> -			case AA_RECORD_HINT:
> -			{
> -				printf("AA_RECORD_HINT\n");
> -				break;
> -			}
> -			case AA_RECORD_STATUS:
> -			{
> -				printf("AA_RECORD_STATUS\n");
> -				break;
> -			}
> -			default:
> -			{
> -				printf("UNKNOWN EVENT TYPE\n");
> +			event_case(AA_RECORD_ERROR);
> +			event_case(AA_RECORD_INVALID);
> +			event_case(AA_RECORD_AUDIT);
> +			event_case(AA_RECORD_ALLOWED);
> +			event_case(AA_RECORD_DENIED);
> +			event_case(AA_RECORD_HINT);
> +			event_case(AA_RECORD_STATUS);
> +			default: {
> +				print_string("Event type", "UNKNOWN EVENT TYPE");
>  				break;
>  			}
>  		}
> +
>  		print_string("Audit ID", record->audit_id);
>  		print_string("Operation", record->operation);
>  		print_string("Mask", record->requested_mask);
> 
> 
> -- 
> AppArmor mailing list
> AppArmor at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20130906/3ac603d6/attachment.pgp>


More information about the AppArmor mailing list