[PATCH 6/6] lib: fwts_framework: make test priority a strongly typed enum

IvanHu ivan.hu at canonical.com
Tue Nov 27 14:48:19 UTC 2012


On 11/22/2012 12:24 AM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Test priority was going to be some fancy percentage ordering scheme
> but as it happens, it just tuned out to be a few settings. So lets
> make it into an enum type.
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>   src/lib/include/fwts_framework.h |   24 +++++++++++++-----------
>   src/lib/src/fwts_framework.c     |    2 +-
>   2 files changed, 14 insertions(+), 12 deletions(-)
>
> diff --git a/src/lib/include/fwts_framework.h b/src/lib/include/fwts_framework.h
> index 2f84693..ea40a07 100644
> --- a/src/lib/include/fwts_framework.h
> +++ b/src/lib/include/fwts_framework.h
> @@ -71,6 +71,17 @@ typedef struct {
>   	uint32_t infoonly;
>   } fwts_results;
>
> +/*
> + *  Where to schedule a test, priority sorted lowest first, highest last
> + */
> +typedef enum {
> +	FWTS_TEST_FIRST	= 0,
> +	FWTS_TEST_EARLY	= 1,
> +	FWTS_TEST_ANYTIME = 2,
> +	FWTS_TEST_LATE = 3,
> +	FWTS_TEST_LAST = 4
> +} fwts_priority;
> +
>   static inline void fwts_results_zero(fwts_results *results)
>   {
>   	memset(results, 0, sizeof(fwts_results));
> @@ -158,14 +169,14 @@ typedef struct fwts_framework_ops {
>   typedef struct fwts_framework_test {
>   	const char *name;
>   	fwts_framework_ops *ops;
> -	int         priority;
> +	fwts_priority priority;
>   	fwts_framework_flags flags;
>   	fwts_results results;			/* Per test results */
>   	bool	    was_run;
>   } fwts_framework_test;
>
>   int  fwts_framework_args(const int argc, char **argv);
> -void fwts_framework_test_add(const char *name, fwts_framework_ops *ops, const int priority, const fwts_framework_flags flags);
> +void fwts_framework_test_add(const char *name, fwts_framework_ops *ops, const fwts_priority priority, const fwts_framework_flags flags);
>   int  fwts_framework_compare_test_name(void *, void *);
>   void fwts_framework_show_version(FILE *fp, const char *name);
>
> @@ -219,15 +230,6 @@ static inline int fwts_tests_passed(const fwts_framework *fw)
>   }
>
>   /*
> - *  Where to schedule a test, priority sorted lowest first, highest last
> - */
> -#define FWTS_TEST_FIRST		0		
> -#define FWTS_TEST_EARLY		10
> -#define FWTS_TEST_ANYTIME	50
> -#define FWTS_TEST_LATE		75
> -#define FWTS_TEST_LAST		100
> -
> -/*
>    *  Batch (run w/o interaction) or interactive (requires user interaction) flags
>    */
>   #define FWTS_TEST_INTERACTIVE(flags)	\
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index d688edf..00b9ed7 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -119,7 +119,7 @@ static int fwts_framework_compare_priority(void *data1, void *data2)
>    */
>   void fwts_framework_test_add(const char *name,
>   	fwts_framework_ops *ops,
> -	const int priority,
> +	const fwts_priority priority,
>   	const fwts_framework_flags flags)
>   {
>   	fwts_framework_test *new_test;
>

Acked-by: Ivan Hu <ivan.hu at canonical.com>



More information about the fwts-devel mailing list