From patchwork Wed Nov 21 16:24:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 200800 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id AA8DE2C00AC for ; Thu, 22 Nov 2012 03:25:00 +1100 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1TbD6f-0005B6-3Z; Wed, 21 Nov 2012 16:24:57 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1TbD6Z-00059x-VK for fwts-devel@lists.ubuntu.com; Wed, 21 Nov 2012 16:24:52 +0000 Received: from cpc3-craw6-2-0-cust180.croy.cable.virginmedia.com ([77.100.248.181] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1TbD6W-00021y-GI for fwts-devel@lists.ubuntu.com; Wed, 21 Nov 2012 16:24:48 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH 6/6] lib: fwts_framework: make test priority a strongly typed enum Date: Wed, 21 Nov 2012 16:24:45 +0000 Message-Id: <1353515085-8053-7-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1353515085-8053-1-git-send-email-colin.king@canonical.com> References: <1353515085-8053-1-git-send-email-colin.king@canonical.com> X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: fwts-devel-bounces@lists.ubuntu.com Errors-To: fwts-devel-bounces@lists.ubuntu.com From: Colin Ian King 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 Acked-by: Keng-Yu Lin Acked-by: Ivan Hu --- 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;