Cleaup and review comments addressed

1. Removed prefix thread_ from all elements of mbed_stats_thread_t
2. #if conditions aligned to rest of the file
pull/6795/head
deepikabhavnani 2018-05-03 10:52:46 -05:00 committed by Deepika
parent bb8ccbd373
commit f43b16ffd9
3 changed files with 33 additions and 33 deletions

View File

@ -22,7 +22,7 @@
#include "mbed.h"
#if !defined(MBED_THREAD_STATS_ENABLED)
#warning [NOT_SUPPORTED] test not supported
#warning [NOT_SUPPORTED] test not supported
#endif
using namespace utest::v1;
@ -63,9 +63,9 @@ void test_case_single_thread_stats()
TEST_ASSERT_EQUAL(1, (count-old_count));
for(int i = 0; i < count; i++) {
if(0 == strcmp(stats[i].thread_name, "Th1")) {
TEST_ASSERT_EQUAL(TEST_STACK_SIZE, stats[i].thread_stack_size);
TEST_ASSERT_EQUAL(osPriorityNormal, stats[i].thread_priority);
if(0 == strcmp(stats[i].name, "Th1")) {
TEST_ASSERT_EQUAL(TEST_STACK_SIZE, stats[i].stack_size);
TEST_ASSERT_EQUAL(osPriorityNormal, stats[i].priority);
break;
}
}
@ -98,13 +98,13 @@ void test_case_multi_threads_blocked()
int count = mbed_stats_thread_get_each(stats, MAX_THREAD_STATS);
TEST_ASSERT_EQUAL(2, (count-old_count));
for(int i = 0; i < count; i++) {
if(0 == strcmp(stats[i].thread_name, "Th2")) {
TEST_ASSERT_EQUAL(TEST_STACK_SIZE, stats[i].thread_stack_size);
TEST_ASSERT_EQUAL(osPriorityNormal1, stats[i].thread_priority);
TEST_ASSERT_EQUAL(osThreadBlocked, stats[i].thread_state);
} else if(0 == strcmp (stats[i].thread_name, "Th1")) {
TEST_ASSERT_EQUAL(TEST_STACK_SIZE, stats[i].thread_stack_size);
TEST_ASSERT_EQUAL(osPriorityNormal, stats[i].thread_priority);
if(0 == strcmp(stats[i].name, "Th2")) {
TEST_ASSERT_EQUAL(TEST_STACK_SIZE, stats[i].stack_size);
TEST_ASSERT_EQUAL(osPriorityNormal1, stats[i].priority);
TEST_ASSERT_EQUAL(osThreadBlocked, stats[i].state);
} else if(0 == strcmp (stats[i].name, "Th1")) {
TEST_ASSERT_EQUAL(TEST_STACK_SIZE, stats[i].stack_size);
TEST_ASSERT_EQUAL(osPriorityNormal, stats[i].priority);
}
}
@ -137,13 +137,13 @@ void test_case_multi_threads_terminate()
TEST_ASSERT_EQUAL(2, (count-old_count));
for(int i = 0; i < count; i++) {
if(0 == strcmp(stats[i].thread_name, "Th2")) {
TEST_ASSERT_EQUAL(TEST_STACK_SIZE, stats[i].thread_stack_size);
TEST_ASSERT_EQUAL(osPriorityNormal2, stats[i].thread_priority);
} else if(0 == strcmp(stats[i].thread_name, "Th1")) {
TEST_ASSERT_EQUAL(TEST_STACK_SIZE, stats[i].thread_stack_size);
TEST_ASSERT_EQUAL(osPriorityNormal1, stats[i].thread_priority);
TEST_ASSERT_EQUAL(osThreadBlocked, stats[i].thread_state);
if(0 == strcmp(stats[i].name, "Th2")) {
TEST_ASSERT_EQUAL(TEST_STACK_SIZE, stats[i].stack_size);
TEST_ASSERT_EQUAL(osPriorityNormal2, stats[i].priority);
} else if(0 == strcmp(stats[i].name, "Th1")) {
TEST_ASSERT_EQUAL(TEST_STACK_SIZE, stats[i].stack_size);
TEST_ASSERT_EQUAL(osPriorityNormal1, stats[i].priority);
TEST_ASSERT_EQUAL(osThreadBlocked, stats[i].state);
}
}

View File

@ -70,10 +70,10 @@ size_t mbed_stats_stack_get_each(mbed_stats_stack_t *stats, size_t count)
size_t mbed_stats_thread_get_each(mbed_stats_thread_t *stats, size_t count)
{
MBED_ASSERT(stats != NULL);
memset(stats, 0, count*sizeof(mbed_stats_thread_t));
memset(stats, 0, count * sizeof(mbed_stats_thread_t));
size_t i = 0;
#if defined(MBED_THREAD_STATS_ENABLED) && MBED_CONF_RTOS_PRESENT
#if defined(MBED_THREAD_STATS_ENABLED) && defined(MBED_CONF_RTOS_PRESENT)
osThreadId_t *threads;
threads = malloc(sizeof(osThreadId_t) * count);
@ -83,12 +83,12 @@ size_t mbed_stats_thread_get_each(mbed_stats_thread_t *stats, size_t count)
count = osThreadEnumerate(threads, count);
for(i = 0; i < count; i++) {
stats[i].thread_id = (uint32_t)threads[i];
stats[i].thread_state = (uint32_t)osThreadGetState(threads[i]);
stats[i].thread_priority = (uint32_t)osThreadGetPriority(threads[i]);
stats[i].thread_stack_size = osThreadGetStackSize(threads[i]);
stats[i].thread_stack_space = osThreadGetStackSpace(threads[i]);
stats[i].thread_name = osThreadGetName(threads[i]);
stats[i].id = (uint32_t)threads[i];
stats[i].state = (uint32_t)osThreadGetState(threads[i]);
stats[i].priority = (uint32_t)osThreadGetPriority(threads[i]);
stats[i].stack_size = osThreadGetStackSize(threads[i]);
stats[i].stack_space = osThreadGetStackSpace(threads[i]);
stats[i].name = osThreadGetName(threads[i]);
}
osKernelUnlock();
free(threads);

View File

@ -52,12 +52,12 @@ typedef struct {
*/
typedef struct {
uint32_t thread_id; /**< Thread Object Identifier */
uint32_t thread_state; /**< Thread Object State */
uint32_t thread_priority; /**< Thread Priority */
uint32_t thread_stack_size; /**< Thread Stack Size */
uint32_t thread_stack_space; /**< Thread remaining stack size */
const char *thread_name; /**< Thread Object name */
uint32_t id; /**< Thread Object Identifier */
uint32_t state; /**< Thread Object State */
uint32_t priority; /**< Thread Priority */
uint32_t stack_size; /**< Thread Stack Size */
uint32_t stack_space; /**< Thread remaining stack size */
const char *name; /**< Thread Object name */
} mbed_stats_thread_t;
/**
@ -101,7 +101,7 @@ size_t mbed_stats_stack_get_each(mbed_stats_stack_t *stats, size_t count);
* @param stats A pointer to an array of mbed_stats_thread_t structures to fill
* @param count The number of mbed_stats_thread_t structures in the provided array
* @return The number of mbed_stats_thread_t structures that have been filled,
* this is equal to the number of stacks on the system.
* this is equal to the number of threads on the system.
*/
size_t mbed_stats_thread_get_each(mbed_stats_thread_t *stats, size_t count);