Skip to content

Commit e95d08e

Browse files
author
deepikabhavnani
committed
Greentea: Add required header file and namespace element instead add all
1. RTOS is needed only for Stack stats Move+Add all required header files for RTOS into MBED_STACK_STATS_ENABLED define. Also added 'using namespace' 2. Add heap stats only when MBED_HEAP_STATS_ENABLED
1 parent f58e103 commit e95d08e

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

features/frameworks/greentea-client/source/greentea_metrics.cpp

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@
1515
* limitations under the License.
1616
*/
1717

18-
#include "mbed_stats.h"
19-
#include "cmsis_os2.h"
2018
#include "greentea-client/test_env.h"
2119
#include "greentea-client/greentea_metrics.h"
22-
#include "SingletonPtr.h"
23-
#include "CircularBuffer.h"
20+
#include "platform/mbed_stats.h"
21+
#include <stdint.h>
2422

2523
#define THREAD_BUF_COUNT 16
2624

@@ -31,6 +29,20 @@ typedef struct {
3129
} thread_info_t;
3230

3331
#if defined(MBED_STACK_STATS_ENABLED) && MBED_STACK_STATS_ENABLED
32+
33+
#if !defined(MBED_CONF_RTOS_PRESENT) || !(MBED_CONF_RTOS_PRESENT)
34+
#error "RTOS required for Stack stats"
35+
#endif
36+
37+
#include "rtos/Mutex.h"
38+
#include "rtos/Thread.h"
39+
#include "mbed_stats.h"
40+
#include "cmsis_os2.h"
41+
#include "platform/SingletonPtr.h"
42+
#include "platform/CircularBuffer.h"
43+
using namespace mbed;
44+
using namespace rtos;
45+
3446
// Mutex to protect "buf"
3547
static SingletonPtr<Mutex> mutex;
3648
static char buf[128];
@@ -41,7 +53,9 @@ static SingletonPtr<CircularBuffer<thread_info_t, THREAD_BUF_COUNT> > queue;
4153
static void send_CPU_info(void);
4254
#endif
4355

56+
#if defined(MBED_HEAP_STATS_ENABLED ) && MBED_HEAP_STATS_ENABLED
4457
static void send_heap_info(void);
58+
#endif
4559
#if defined(MBED_STACK_STATS_ENABLED) && MBED_STACK_STATS_ENABLED
4660
static void send_stack_info(void);
4761
static void on_thread_terminate(osThreadId_t id);
@@ -62,7 +76,9 @@ void greentea_metrics_setup()
6276

6377
void greentea_metrics_report()
6478
{
79+
#if defined(MBED_HEAP_STATS_ENABLED ) && MBED_HEAP_STATS_ENABLED
6580
send_heap_info();
81+
#endif
6682
#if defined(MBED_STACK_STATS_ENABLED) && MBED_STACK_STATS_ENABLED
6783
send_stack_info();
6884
Kernel::attach_thread_terminate_hook(NULL);
@@ -85,13 +101,15 @@ static void send_CPU_info()
85101
}
86102
#endif
87103

104+
#if defined(MBED_HEAP_STATS_ENABLED ) && MBED_HEAP_STATS_ENABLED
88105
static void send_heap_info()
89106
{
90107
mbed_stats_heap_t heap_stats;
91108
mbed_stats_heap_get(&heap_stats);
92109
greentea_send_kv("max_heap_usage",heap_stats.max_size);
93110
greentea_send_kv("reserved_heap",heap_stats.reserved_size);
94111
}
112+
#endif
95113

96114
#if defined(MBED_STACK_STATS_ENABLED) && MBED_STACK_STATS_ENABLED
97115
MBED_UNUSED static void send_stack_info()

0 commit comments

Comments
 (0)