[PATCH v3] smpstrongapa01: Improve readability
Richi Dubey
richidubey at gmail.com
Tue Jun 30 05:54:42 UTC 2020
---
testsuites/smptests/smpstrongapa01/init.c | 60 ++++++++++++++---------
1 file changed, 38 insertions(+), 22 deletions(-)
diff --git a/testsuites/smptests/smpstrongapa01/init.c b/testsuites/smptests/smpstrongapa01/init.c
index bf8bc05231..d067f2b5b9 100644
--- a/testsuites/smptests/smpstrongapa01/init.c
+++ b/testsuites/smptests/smpstrongapa01/init.c
@@ -16,7 +16,7 @@
#include "config.h"
#endif
-#include "tmacros.h"
+#include <tmacros.h>
#include <rtems.h>
@@ -30,9 +30,22 @@ const char rtems_test_name[] = "SMPSTRONGAPA 1";
#define ALL ((UINT32_C(1) << CPU_COUNT) - 1)
-#define IDLE UINT8_C(255)
+typedef enum {
+ T0,
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ IDLE
+} task_index;
-#define NAME rtems_build_name('S', 'A', 'P', 'A')
typedef struct {
enum {
@@ -43,7 +56,7 @@ typedef struct {
KIND_UNBLOCK
} kind;
- size_t index;
+ task_index index;
struct {
rtems_task_priority priority;
@@ -102,17 +115,17 @@ typedef struct {
static const test_action test_actions[] = {
RESET,
- UNBLOCK( 0, 0, IDLE, IDLE, IDLE),
- UNBLOCK( 1, 0, 1, IDLE, IDLE),
- UNBLOCK( 2, 0, 1, 2, IDLE),
- UNBLOCK( 3, 0, 1, 2, 3),
- UNBLOCK( 5, 0, 1, 2, 3),
- SET_PRIORITY( 3, P(4), 0, 1, 2, 3),
- SET_PRIORITY( 5, P(3), 0, 1, 2, 5),
- BLOCK( 5, 0, 1, 2, 3),
- SET_AFFINITY( 5, ALL, 0, 1, 2, 3),
+ UNBLOCK( T0, T0, IDLE, IDLE, IDLE),
+ UNBLOCK( T1, T0, T1, IDLE, IDLE),
+ UNBLOCK( T2, T0, T1, T2, IDLE),
+ UNBLOCK( T3, T0, T1, T2, T3),
+ UNBLOCK( T5, T0, T1, T2, T3),
+ SET_PRIORITY( T3, P(4), T0, T1, T2, T3),
+ SET_PRIORITY( T5, P(3), T0, T1, T2, T5),
+ BLOCK( T5, T0, T1, T2, T3),
+ SET_AFFINITY( T5, ALL, T0, T1, T2, T3),
RESET,
- UNBLOCK( 0, 0, IDLE, IDLE, IDLE),
+ UNBLOCK( T0, T0, IDLE, IDLE, IDLE),
RESET
};
@@ -130,7 +143,7 @@ static void set_affinity(rtems_id id, uint32_t cpu_set_32)
{
rtems_status_code sc;
cpu_set_t cpu_set;
- size_t i;
+ task_index i;
CPU_ZERO(&cpu_set);
@@ -147,7 +160,7 @@ static void set_affinity(rtems_id id, uint32_t cpu_set_32)
static void reset(test_context *ctx)
{
rtems_status_code sc;
- size_t i;
+ task_index i;
for (i = CPU_COUNT; i < TASK_COUNT; ++i) {
set_priority(ctx->task_ids[i], P(i));
@@ -179,10 +192,10 @@ static void reset(test_context *ctx)
static void check_cpu_allocations(test_context *ctx, const test_action *action)
{
- size_t i;
+ task_index i;
for (i = 0; i < CPU_COUNT; ++i) {
- size_t e;
+ task_index e;
const Per_CPU_Control *c;
const Thread_Control *h;
@@ -206,7 +219,7 @@ static void timer(rtems_id id, void *arg)
{
test_context *ctx;
rtems_status_code sc;
- size_t i;
+ task_index i;
ctx = arg;
i = ctx->action_index;
@@ -271,7 +284,7 @@ static void test(void)
{
test_context *ctx;
rtems_status_code sc;
- size_t i;
+ task_index i;
ctx = &test_instance;
@@ -279,7 +292,7 @@ static void test(void)
for (i = 0; i < TASK_COUNT; ++i) {
sc = rtems_task_create(
- NAME,
+ rtems_build_name(' ', ' ', 'T', '0' + i),
P(i),
RTEMS_MINIMUM_STACK_SIZE,
RTEMS_DEFAULT_MODES,
@@ -292,7 +305,10 @@ static void test(void)
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}
- sc = rtems_timer_create(NAME, &ctx->timer_id);
+ sc = rtems_timer_create(
+ rtems_build_name('S', 'A', 'P', 'A'),
+ &ctx->timer_id
+ );
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
sc = rtems_timer_fire_after(ctx->timer_id, 1, timer, ctx);
--
2.17.1
More information about the devel
mailing list