tests: Remove camel case and fix coding style
Test whichever had Camel case defined for functions and variables have been replaced. Following warnings have been fixed in test cases as well. - line over 80 characters - Macros with flow control statements should be avoided - Macros with complex values should be enclosed in parentheses - break quoted strings at a space character - do not add new typedefs - Comparisons should place the constant on the right side of the test - suspect code indent for conditional statements - Missing a blank line after declarations - macros should not use a trailing semicolon - Macros with multiple statements should be enclosed in a do - while loop - do not use C99 // comments JIRA: ZEP-2249 Signed-off-by: Punit Vara <punit.vara@intel.com>
This commit is contained in:
parent
ed85dea358
commit
fe882f407d
20 changed files with 515 additions and 481 deletions
|
@ -12,13 +12,13 @@
|
||||||
|
|
||||||
/* #define EVENT_CHECK */
|
/* #define EVENT_CHECK */
|
||||||
#ifdef EVENT_CHECK
|
#ifdef EVENT_CHECK
|
||||||
static const char EventSignalErr[] = "------------ Error signalling event.\n";
|
static const char event_signal_err[] = "----------- Error signalling event.\n";
|
||||||
static const char EventTestErr[] = "------------ Error testing event.\n";
|
static const char event_test_err[] = "----------- Error testing event.\n";
|
||||||
static const char EventHandlerErr[] = "------------ Error in event handler.\n";
|
static const char event_handler_err[] = "----------- Error in event handler\n";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* global Event value */
|
/* global Event value */
|
||||||
volatile int nEventValue;
|
volatile int nevent_value;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Function prototypes.
|
* Function prototypes.
|
||||||
|
@ -37,17 +37,17 @@ int example_handler (struct k_alert *alert);
|
||||||
*/
|
*/
|
||||||
void event_test(void)
|
void event_test(void)
|
||||||
{
|
{
|
||||||
int nReturn = 0;
|
int nreturn = 0;
|
||||||
int nCounter;
|
int ncounter;
|
||||||
u32_t et; /* elapsed time */
|
u32_t et; /* elapsed time */
|
||||||
|
|
||||||
PRINT_STRING(dashline, output_file);
|
PRINT_STRING(dashline, output_file);
|
||||||
et = BENCH_START();
|
et = BENCH_START();
|
||||||
for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) {
|
for (ncounter = 0; ncounter < NR_OF_EVENT_RUNS; ncounter++) {
|
||||||
k_alert_send(&TEST_EVENT);
|
k_alert_send(&TEST_EVENT);
|
||||||
#ifdef EVENT_CHECK
|
#ifdef EVENT_CHECK
|
||||||
if (nReturn != 0) {
|
if (nreturn != 0) {
|
||||||
PRINT_STRING(EventSignalErr, output_file);
|
PRINT_STRING(event_signal_err, output_file);
|
||||||
return; /* error */
|
return; /* error */
|
||||||
}
|
}
|
||||||
#endif /* EVENT_CHECK */
|
#endif /* EVENT_CHECK */
|
||||||
|
@ -59,19 +59,19 @@ void event_test(void)
|
||||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_EVENT_RUNS));
|
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_EVENT_RUNS));
|
||||||
|
|
||||||
et = BENCH_START();
|
et = BENCH_START();
|
||||||
for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) {
|
for (ncounter = 0; ncounter < NR_OF_EVENT_RUNS; ncounter++) {
|
||||||
k_alert_send(&TEST_EVENT);
|
k_alert_send(&TEST_EVENT);
|
||||||
#ifdef EVENT_CHECK
|
#ifdef EVENT_CHECK
|
||||||
if (nReturn != 0) {
|
if (nreturn != 0) {
|
||||||
PRINT_STRING(EventSignalErr, output_file);
|
PRINT_STRING(event_signal_err, output_file);
|
||||||
k_sleep(1);
|
k_sleep(1);
|
||||||
return; /* error */
|
return; /* error */
|
||||||
}
|
}
|
||||||
#endif /* EVENT_CHECK */
|
#endif /* EVENT_CHECK */
|
||||||
k_alert_recv(&TEST_EVENT, K_NO_WAIT);
|
k_alert_recv(&TEST_EVENT, K_NO_WAIT);
|
||||||
#ifdef EVENT_CHECK
|
#ifdef EVENT_CHECK
|
||||||
if (nReturn != 0) {
|
if (nreturn != 0) {
|
||||||
PRINT_STRING(EventTestErr, output_file);
|
PRINT_STRING(event_test_err, output_file);
|
||||||
k_sleep(1);
|
k_sleep(1);
|
||||||
return; /* error */
|
return; /* error */
|
||||||
}
|
}
|
||||||
|
@ -84,18 +84,18 @@ void event_test(void)
|
||||||
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_EVENT_RUNS));
|
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_EVENT_RUNS));
|
||||||
|
|
||||||
et = BENCH_START();
|
et = BENCH_START();
|
||||||
for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) {
|
for (ncounter = 0; ncounter < NR_OF_EVENT_RUNS; ncounter++) {
|
||||||
k_alert_send(&TEST_EVENT);
|
k_alert_send(&TEST_EVENT);
|
||||||
#ifdef EVENT_CHECK
|
#ifdef EVENT_CHECK
|
||||||
if (nReturn != 0) {
|
if (nreturn != 0) {
|
||||||
PRINT_STRING(EventSignalErr, output_file);
|
PRINT_STRING(event_signal_err, output_file);
|
||||||
return; /* error */
|
return; /* error */
|
||||||
}
|
}
|
||||||
#endif /* EVENT_CHECK */
|
#endif /* EVENT_CHECK */
|
||||||
k_alert_recv(&TEST_EVENT, K_FOREVER);
|
k_alert_recv(&TEST_EVENT, K_FOREVER);
|
||||||
#ifdef EVENT_CHECK
|
#ifdef EVENT_CHECK
|
||||||
if (nReturn != 0) {
|
if (nreturn != 0) {
|
||||||
PRINT_STRING(EventTestErr, output_file);
|
PRINT_STRING(event_test_err, output_file);
|
||||||
return; /* error */
|
return; /* error */
|
||||||
}
|
}
|
||||||
#endif /* EVENT_CHECK */
|
#endif /* EVENT_CHECK */
|
||||||
|
@ -109,32 +109,32 @@ void event_test(void)
|
||||||
PRINT_STRING("| Signal event with installed handler"
|
PRINT_STRING("| Signal event with installed handler"
|
||||||
" |\n", output_file);
|
" |\n", output_file);
|
||||||
TEST_EVENT.handler = example_handler;
|
TEST_EVENT.handler = example_handler;
|
||||||
if (nReturn != 0) {
|
if (nreturn != 0) {
|
||||||
PRINT_F(output_file,
|
PRINT_F(output_file,
|
||||||
"-------- Error installing event handler.\n");
|
"-------- Error installing event handler.\n");
|
||||||
k_sleep(1);
|
k_sleep(1);
|
||||||
return; /* error */
|
return; /* error */
|
||||||
}
|
}
|
||||||
|
|
||||||
for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) {
|
for (ncounter = 0; ncounter < NR_OF_EVENT_RUNS; ncounter++) {
|
||||||
k_alert_send(&TEST_EVENT);
|
k_alert_send(&TEST_EVENT);
|
||||||
#ifdef EVENT_CHECK
|
#ifdef EVENT_CHECK
|
||||||
if (nReturn != 0) {
|
if (nreturn != 0) {
|
||||||
PRINT_STRING(EventSignalErr, output_file);
|
PRINT_STRING(event_signal_err, output_file);
|
||||||
k_sleep(1);
|
k_sleep(1);
|
||||||
return; /* error */
|
return; /* error */
|
||||||
}
|
}
|
||||||
if (nEventValue != TEST_EVENT.send_count + 1) {
|
if (nevent_value != TEST_EVENT.send_count + 1) {
|
||||||
PRINT_STRING(EventHandlerErr, output_file);
|
PRINT_STRING(event_handler_err, output_file);
|
||||||
k_sleep(1);
|
k_sleep(1);
|
||||||
return; /* error */
|
return; /* error */
|
||||||
}
|
}
|
||||||
#endif /* EVENT_CHECK */
|
#endif /* EVENT_CHECK */
|
||||||
nEventValue = 0;
|
nevent_value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_EVENT.handler = NULL;
|
TEST_EVENT.handler = NULL;
|
||||||
if (nReturn != 0) {
|
if (nreturn != 0) {
|
||||||
PRINT_F(output_file, "Error removing event handler.\n");
|
PRINT_F(output_file, "Error removing event handler.\n");
|
||||||
k_sleep(1);
|
k_sleep(1);
|
||||||
return; /* error */
|
return; /* error */
|
||||||
|
@ -160,7 +160,7 @@ void event_test(void)
|
||||||
int example_handler (struct k_alert *alert)
|
int example_handler (struct k_alert *alert)
|
||||||
{
|
{
|
||||||
ARG_UNUSED(alert);
|
ARG_UNUSED(alert);
|
||||||
nEventValue = alert->send_count + 1;
|
nevent_value = alert->send_count + 1;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,13 @@
|
||||||
|
|
||||||
#ifdef MAILBOX_BENCH
|
#ifdef MAILBOX_BENCH
|
||||||
|
|
||||||
static struct k_mbox_msg Message;
|
static struct k_mbox_msg message;
|
||||||
|
|
||||||
#ifdef FLOAT
|
#ifdef FLOAT
|
||||||
#define PRINT_HEADER() \
|
#define PRINT_HEADER() \
|
||||||
PRINT_STRING \
|
(PRINT_STRING \
|
||||||
("| size(B) | time/packet (usec) | MB/sec" \
|
("| size(B) | time/packet (usec) | MB/sec" \
|
||||||
" |\n", output_file)
|
" |\n", output_file))
|
||||||
#define PRINT_ONE_RESULT() \
|
#define PRINT_ONE_RESULT() \
|
||||||
PRINT_F(output_file, "|%11u|%32.3f|%32f|\n", putsize, puttime / 1000.0,\
|
PRINT_F(output_file, "|%11u|%32.3f|%32f|\n", putsize, puttime / 1000.0,\
|
||||||
(1000.0 * putsize) / puttime)
|
(1000.0 * putsize) / puttime)
|
||||||
|
@ -24,21 +24,21 @@ static struct k_mbox_msg Message;
|
||||||
#define PRINT_OVERHEAD() \
|
#define PRINT_OVERHEAD() \
|
||||||
PRINT_F(output_file, \
|
PRINT_F(output_file, \
|
||||||
"| message overhead: %10.3f usec/packet "\
|
"| message overhead: %10.3f usec/packet "\
|
||||||
" |\n", EmptyMsgPutTime / 1000.0)
|
" |\n", empty_msg_put_time / 1000.0)
|
||||||
|
|
||||||
#define PRINT_XFER_RATE() \
|
#define PRINT_XFER_RATE() \
|
||||||
double NettoTransferRate; \
|
double netto_transfer_rate; \
|
||||||
NettoTransferRate = 1000.0 * \
|
netto_transfer_rate = 1000.0 * \
|
||||||
(putsize >> 1) / (puttime - EmptyMsgPutTime); \
|
(putsize >> 1) / (puttime - empty_msg_put_time); \
|
||||||
PRINT_F(output_file, \
|
PRINT_F(output_file, \
|
||||||
"| raw transfer rate: %10.3f MB/sec (without" \
|
"| raw transfer rate: %10.3f MB/sec (without" \
|
||||||
" overhead) |\n", NettoTransferRate)
|
" overhead) |\n", netto_transfer_rate)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define PRINT_HEADER() \
|
#define PRINT_HEADER() \
|
||||||
PRINT_STRING \
|
(PRINT_STRING \
|
||||||
("| size(B) | time/packet (nsec) | KB/sec" \
|
("| size(B) | time/packet (nsec) | KB/sec" \
|
||||||
" |\n", output_file);
|
" |\n", output_file))
|
||||||
|
|
||||||
#define PRINT_ONE_RESULT() \
|
#define PRINT_ONE_RESULT() \
|
||||||
PRINT_F(output_file, "|%11u|%32u|%32u|\n", putsize, puttime, \
|
PRINT_F(output_file, "|%11u|%32u|%32u|\n", putsize, puttime, \
|
||||||
|
@ -47,13 +47,13 @@ static struct k_mbox_msg Message;
|
||||||
#define PRINT_OVERHEAD() \
|
#define PRINT_OVERHEAD() \
|
||||||
PRINT_F(output_file, \
|
PRINT_F(output_file, \
|
||||||
"| message overhead: %10u nsec/packet "\
|
"| message overhead: %10u nsec/packet "\
|
||||||
" |\n", EmptyMsgPutTime)
|
" |\n", empty_msg_put_time)
|
||||||
|
|
||||||
#define PRINT_XFER_RATE() \
|
#define PRINT_XFER_RATE() \
|
||||||
PRINT_F(output_file, "| raw transfer rate: %10u KB/sec (without" \
|
PRINT_F(output_file, "| raw transfer rate: %10u KB/sec (without" \
|
||||||
" overhead) |\n", \
|
" overhead) |\n", \
|
||||||
(u32_t)(1000000 * (u64_t)(putsize >> 1) \
|
(u32_t)(1000000 * (u64_t)(putsize >> 1) \
|
||||||
/ (puttime - EmptyMsgPutTime)))
|
/ (puttime - empty_msg_put_time)))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -78,8 +78,8 @@ void mailbox_test(void)
|
||||||
u32_t putsize;
|
u32_t putsize;
|
||||||
u32_t puttime;
|
u32_t puttime;
|
||||||
int putcount;
|
int putcount;
|
||||||
unsigned int EmptyMsgPutTime;
|
unsigned int empty_msg_put_time;
|
||||||
GetInfo getinfo;
|
struct getinfo getinfo;
|
||||||
|
|
||||||
PRINT_STRING(dashline, output_file);
|
PRINT_STRING(dashline, output_file);
|
||||||
PRINT_STRING("| "
|
PRINT_STRING("| "
|
||||||
|
@ -104,7 +104,7 @@ void mailbox_test(void)
|
||||||
/* waiting for ack */
|
/* waiting for ack */
|
||||||
k_msgq_get(&MB_COMM, &getinfo, K_FOREVER);
|
k_msgq_get(&MB_COMM, &getinfo, K_FOREVER);
|
||||||
PRINT_ONE_RESULT();
|
PRINT_ONE_RESULT();
|
||||||
EmptyMsgPutTime = puttime;
|
empty_msg_put_time = puttime;
|
||||||
for (putsize = 8; putsize <= MESSAGE_SIZE; putsize <<= 1) {
|
for (putsize = 8; putsize <= MESSAGE_SIZE; putsize <<= 1) {
|
||||||
mailbox_put(putsize, putcount, &puttime);
|
mailbox_put(putsize, putcount, &puttime);
|
||||||
/* waiting for ack */
|
/* waiting for ack */
|
||||||
|
@ -132,14 +132,14 @@ void mailbox_put(u32_t size, int count, u32_t *time)
|
||||||
int i;
|
int i;
|
||||||
unsigned int t;
|
unsigned int t;
|
||||||
|
|
||||||
Message.rx_source_thread = K_ANY;
|
message.rx_source_thread = K_ANY;
|
||||||
Message.tx_target_thread = K_ANY;
|
message.tx_target_thread = K_ANY;
|
||||||
|
|
||||||
/* first sync with the receiver */
|
/* first sync with the receiver */
|
||||||
k_sem_give(&SEM0);
|
k_sem_give(&SEM0);
|
||||||
t = BENCH_START();
|
t = BENCH_START();
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
k_mbox_put(&MAILB1, &Message, K_FOREVER);
|
k_mbox_put(&MAILB1, &message, K_FOREVER);
|
||||||
}
|
}
|
||||||
t = TIME_STAMP_DELTA_GET(t);
|
t = TIME_STAMP_DELTA_GET(t);
|
||||||
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, count);
|
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, count);
|
||||||
|
|
|
@ -36,7 +36,7 @@ void mailrecvtask(void)
|
||||||
int getsize;
|
int getsize;
|
||||||
unsigned int gettime;
|
unsigned int gettime;
|
||||||
int getcount;
|
int getcount;
|
||||||
GetInfo getinfo;
|
struct getinfo getinfo;
|
||||||
|
|
||||||
getcount = NR_OF_MBOX_RUNS;
|
getcount = NR_OF_MBOX_RUNS;
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
#include <tc_util.h>
|
#include <tc_util.h>
|
||||||
#include "master.h"
|
#include "master.h"
|
||||||
|
|
||||||
char Msg[MAX_MSG];
|
char msg[MAX_MSG];
|
||||||
char data_bench[OCTET_TO_SIZEOFUNIT(MESSAGE_SIZE)];
|
char data_bench[OCTET_TO_SIZEOFUNIT(MESSAGE_SIZE)];
|
||||||
|
|
||||||
#ifdef PIPE_BENCH
|
#ifdef PIPE_BENCH
|
||||||
struct k_pipe *TestPipes[] = {&PIPE_NOBUFF, &PIPE_SMALLBUFF, &PIPE_BIGBUFF};
|
struct k_pipe *test_pipes[] = {&PIPE_NOBUFF, &PIPE_SMALLBUFF, &PIPE_BIGBUFF};
|
||||||
#endif
|
#endif
|
||||||
char sline[SLINE_LEN + 1];
|
char sline[SLINE_LEN + 1];
|
||||||
const char newline[] = "\n";
|
const char newline[] = "\n";
|
||||||
|
@ -38,7 +38,7 @@ u32_t tm_off;
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
/* static allocation */
|
/* static allocation */
|
||||||
K_THREAD_DEFINE(RECVTASK, 1024, recvtask, NULL, NULL, NULL, 5, 0, K_NO_WAIT);
|
K_THREAD_DEFINE(RECVTASK, 1024, recvtask, NULL, NULL, NULL, 5, 0, K_NO_WAIT);
|
||||||
K_THREAD_DEFINE(BENCHTASK, 1024, BenchTask, NULL, NULL, NULL, 6, 0, K_NO_WAIT);
|
K_THREAD_DEFINE(BENCHTASK, 1024, bench_task, NULL, NULL, NULL, 6, 0, K_NO_WAIT);
|
||||||
|
|
||||||
K_MSGQ_DEFINE(DEMOQX1, 1, 500, 4);
|
K_MSGQ_DEFINE(DEMOQX1, 1, 500, 4);
|
||||||
K_MSGQ_DEFINE(DEMOQX4, 4, 500, 4);
|
K_MSGQ_DEFINE(DEMOQX4, 4, 500, 4);
|
||||||
|
@ -120,7 +120,7 @@ void output_close(void)
|
||||||
*
|
*
|
||||||
* @return N/A
|
* @return N/A
|
||||||
*/
|
*/
|
||||||
void BenchTask(void *p1, void *p2, void *p3)
|
void bench_task(void *p1, void *p2, void *p3)
|
||||||
{
|
{
|
||||||
int autorun = 0, continuously = 0;
|
int autorun = 0, continuously = 0;
|
||||||
|
|
||||||
|
@ -166,5 +166,4 @@ void BenchTask(void *p1, void *p2, void *p3)
|
||||||
*/
|
*/
|
||||||
void dummy_test(void)
|
void dummy_test(void)
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,12 +48,12 @@
|
||||||
#define NR_OF_EVENT_RUNS 1000
|
#define NR_OF_EVENT_RUNS 1000
|
||||||
#define NR_OF_MBOX_RUNS 128
|
#define NR_OF_MBOX_RUNS 128
|
||||||
#define NR_OF_PIPE_RUNS 256
|
#define NR_OF_PIPE_RUNS 256
|
||||||
//#define SEMA_WAIT_TIME (5 * sys_clock_ticks_per_sec)
|
/* #define SEMA_WAIT_TIME (5 * sys_clock_ticks_per_sec) */
|
||||||
#define SEMA_WAIT_TIME (5000)
|
#define SEMA_WAIT_TIME (5000)
|
||||||
/* global data */
|
/* global data */
|
||||||
extern char Msg[MAX_MSG];
|
extern char msg[MAX_MSG];
|
||||||
extern char data_bench[OCTET_TO_SIZEOFUNIT(MESSAGE_SIZE)];
|
extern char data_bench[OCTET_TO_SIZEOFUNIT(MESSAGE_SIZE)];
|
||||||
extern struct k_pipe *TestPipes[];
|
extern struct k_pipe *test_pipes[];
|
||||||
extern FILE *output_file;
|
extern FILE *output_file;
|
||||||
extern const char newline[];
|
extern const char newline[];
|
||||||
extern char sline[];
|
extern char sline[];
|
||||||
|
@ -65,11 +65,11 @@ extern char sline[];
|
||||||
|
|
||||||
|
|
||||||
/* pipe amount of content to receive (0+, 1+, all) */
|
/* pipe amount of content to receive (0+, 1+, all) */
|
||||||
typedef enum {
|
enum pipe_options {
|
||||||
_0_TO_N = 0x0,
|
_0_TO_N = 0x0,
|
||||||
_1_TO_N = 0x1,
|
_1_TO_N = 0x1,
|
||||||
_ALL_N = 0x2,
|
_ALL_N = 0x2,
|
||||||
} pipe_options;
|
};
|
||||||
|
|
||||||
/* dummy_test is a function that is mapped when we */
|
/* dummy_test is a function that is mapped when we */
|
||||||
/* do not want to test a specific Benchmark */
|
/* do not want to test a specific Benchmark */
|
||||||
|
@ -77,7 +77,7 @@ extern void dummy_test(void);
|
||||||
|
|
||||||
/* other external functions */
|
/* other external functions */
|
||||||
|
|
||||||
extern void BenchTask(void *p1, void *p2, void *p3);
|
extern void bench_task(void *p1, void *p2, void *p3);
|
||||||
extern void recvtask(void *p1, void *p2, void *p3);
|
extern void recvtask(void *p1, void *p2, void *p3);
|
||||||
|
|
||||||
#ifdef MAILBOX_BENCH
|
#ifdef MAILBOX_BENCH
|
||||||
|
@ -189,12 +189,12 @@ static inline u32_t BENCH_START(void)
|
||||||
return et;
|
return et;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define check_result() \
|
static inline void check_result(void)
|
||||||
{ \
|
{
|
||||||
if (bench_test_end() < 0) { \
|
if (bench_test_end() < 0) {
|
||||||
PRINT_OVERFLOW_ERROR(); \
|
PRINT_OVERFLOW_ERROR();
|
||||||
return; /* error */ \
|
return; /* error */
|
||||||
} \
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#ifdef FLOAT
|
#ifdef FLOAT
|
||||||
#define PRINT_ALL_TO_N_HEADER_UNIT() \
|
#define PRINT_ALL_TO_N_HEADER_UNIT() \
|
||||||
PRINT_STRING("| size(B) | time/packet (usec) | "\
|
PRINT_STRING("| size(B) | time/packet (usec) | "\
|
||||||
" MB/sec |\n", output_file);
|
" MB/sec |\n", output_file)
|
||||||
|
|
||||||
#define PRINT_ALL_TO_N() \
|
#define PRINT_ALL_TO_N() \
|
||||||
PRINT_F(output_file, \
|
PRINT_F(output_file, \
|
||||||
|
@ -25,9 +25,11 @@
|
||||||
(1000.0 * putsize) / puttime[2])
|
(1000.0 * putsize) / puttime[2])
|
||||||
|
|
||||||
#define PRINT_1_TO_N_HEADER() \
|
#define PRINT_1_TO_N_HEADER() \
|
||||||
|
do { \
|
||||||
PRINT_STRING("| size(B) | time/packet (usec) | "\
|
PRINT_STRING("| size(B) | time/packet (usec) | "\
|
||||||
" MB/sec |\n", output_file); \
|
" MB/sec |\n", output_file); \
|
||||||
PRINT_STRING(dashline, output_file);
|
PRINT_STRING(dashline, output_file);\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define PRINT_1_TO_N() \
|
#define PRINT_1_TO_N() \
|
||||||
PRINT_F(output_file, \
|
PRINT_F(output_file, \
|
||||||
|
@ -44,7 +46,7 @@
|
||||||
#else
|
#else
|
||||||
#define PRINT_ALL_TO_N_HEADER_UNIT() \
|
#define PRINT_ALL_TO_N_HEADER_UNIT() \
|
||||||
PRINT_STRING("| size(B) | time/packet (nsec) | "\
|
PRINT_STRING("| size(B) | time/packet (nsec) | "\
|
||||||
" KB/sec |\n", output_file);
|
" KB/sec |\n", output_file)
|
||||||
|
|
||||||
#define PRINT_ALL_TO_N() \
|
#define PRINT_ALL_TO_N() \
|
||||||
PRINT_F(output_file, \
|
PRINT_F(output_file, \
|
||||||
|
@ -53,12 +55,14 @@
|
||||||
puttime[2], \
|
puttime[2], \
|
||||||
(1000000 * putsize) / puttime[0], \
|
(1000000 * putsize) / puttime[0], \
|
||||||
(1000000 * putsize) / puttime[1], \
|
(1000000 * putsize) / puttime[1], \
|
||||||
(1000000 * putsize) / puttime[2]);
|
(1000000 * putsize) / puttime[2])
|
||||||
|
|
||||||
#define PRINT_1_TO_N_HEADER() \
|
#define PRINT_1_TO_N_HEADER() \
|
||||||
|
do { \
|
||||||
PRINT_STRING("| size(B) | time/packet (nsec) | "\
|
PRINT_STRING("| size(B) | time/packet (nsec) | "\
|
||||||
" KB/sec |\n", output_file); \
|
" KB/sec |\n", output_file); \
|
||||||
PRINT_STRING(dashline, output_file);
|
PRINT_STRING(dashline, output_file); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define PRINT_1_TO_N() \
|
#define PRINT_1_TO_N() \
|
||||||
PRINT_F(output_file, \
|
PRINT_F(output_file, \
|
||||||
|
@ -70,13 +74,13 @@
|
||||||
puttime[2], \
|
puttime[2], \
|
||||||
(u32_t)((1000000 * (u64_t)putsize) / puttime[0]), \
|
(u32_t)((1000000 * (u64_t)putsize) / puttime[0]), \
|
||||||
(u32_t)((1000000 * (u64_t)putsize) / puttime[1]), \
|
(u32_t)((1000000 * (u64_t)putsize) / puttime[1]), \
|
||||||
(u32_t)((1000000 * (u64_t)putsize) / puttime[2]));
|
(u32_t)((1000000 * (u64_t)putsize) / puttime[2]))
|
||||||
#endif /* FLOAT */
|
#endif /* FLOAT */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Function prototypes.
|
* Function prototypes.
|
||||||
*/
|
*/
|
||||||
int pipeput(struct k_pipe *pipe, pipe_options
|
int pipeput(struct k_pipe *pipe, enum pipe_options
|
||||||
option, int size, int count, u32_t *time);
|
option, int size, int count, u32_t *time);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -98,7 +102,7 @@ void pipe_test(void)
|
||||||
int pipe;
|
int pipe;
|
||||||
u32_t TaskPrio = UINT32_MAX;
|
u32_t TaskPrio = UINT32_MAX;
|
||||||
int prio;
|
int prio;
|
||||||
GetInfo getinfo;
|
struct getinfo getinfo;
|
||||||
|
|
||||||
k_sem_reset(&SEM0);
|
k_sem_reset(&SEM0);
|
||||||
k_sem_give(&STARTRCV);
|
k_sem_give(&STARTRCV);
|
||||||
|
@ -128,7 +132,7 @@ void pipe_test(void)
|
||||||
for (putsize = 8; putsize <= MESSAGE_SIZE_PIPE; putsize <<= 1) {
|
for (putsize = 8; putsize <= MESSAGE_SIZE_PIPE; putsize <<= 1) {
|
||||||
for (pipe = 0; pipe < 3; pipe++) {
|
for (pipe = 0; pipe < 3; pipe++) {
|
||||||
putcount = NR_OF_PIPE_RUNS;
|
putcount = NR_OF_PIPE_RUNS;
|
||||||
pipeput(TestPipes[pipe], _ALL_N, putsize, putcount,
|
pipeput(test_pipes[pipe], _ALL_N, putsize, putcount,
|
||||||
&puttime[pipe]);
|
&puttime[pipe]);
|
||||||
|
|
||||||
/* waiting for ack */
|
/* waiting for ack */
|
||||||
|
@ -162,7 +166,7 @@ void pipe_test(void)
|
||||||
for (putsize = 8; putsize <= (MESSAGE_SIZE_PIPE); putsize <<= 1) {
|
for (putsize = 8; putsize <= (MESSAGE_SIZE_PIPE); putsize <<= 1) {
|
||||||
putcount = MESSAGE_SIZE_PIPE / putsize;
|
putcount = MESSAGE_SIZE_PIPE / putsize;
|
||||||
for (pipe = 0; pipe < 3; pipe++) {
|
for (pipe = 0; pipe < 3; pipe++) {
|
||||||
pipeput(TestPipes[pipe], _1_TO_N, putsize,
|
pipeput(test_pipes[pipe], _1_TO_N, putsize,
|
||||||
putcount, &puttime[pipe]);
|
putcount, &puttime[pipe]);
|
||||||
/* size*count == MESSAGE_SIZE_PIPE */
|
/* size*count == MESSAGE_SIZE_PIPE */
|
||||||
/* waiting for ack */
|
/* waiting for ack */
|
||||||
|
@ -190,7 +194,7 @@ void pipe_test(void)
|
||||||
* @param time Total write time.
|
* @param time Total write time.
|
||||||
*/
|
*/
|
||||||
int pipeput(struct k_pipe *pipe,
|
int pipeput(struct k_pipe *pipe,
|
||||||
pipe_options option,
|
enum pipe_options option,
|
||||||
int size,
|
int size,
|
||||||
int count,
|
int count,
|
||||||
u32_t *time)
|
u32_t *time)
|
||||||
|
@ -203,22 +207,22 @@ int pipeput(struct k_pipe *pipe,
|
||||||
/* first sync with the receiver */
|
/* first sync with the receiver */
|
||||||
k_sem_give(&SEM0);
|
k_sem_give(&SEM0);
|
||||||
t = BENCH_START();
|
t = BENCH_START();
|
||||||
for (i = 0; _1_TO_N == option || (i < count); i++) {
|
for (i = 0; option == _1_TO_N || (i < count); i++) {
|
||||||
size_t sizexferd = 0;
|
size_t sizexferd = 0;
|
||||||
size_t size2xfer = min(size, size2xfer_total - sizexferd_total);
|
size_t size2xfer = min(size, size2xfer_total - sizexferd_total);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
size_t mim_num_of_bytes = 0;
|
size_t mim_num_of_bytes = 0;
|
||||||
|
|
||||||
if (option == _ALL_N) {
|
if (option == _ALL_N) {
|
||||||
mim_num_of_bytes = size2xfer;
|
mim_num_of_bytes = size2xfer;
|
||||||
}
|
}
|
||||||
ret = k_pipe_put(pipe, data_bench, size2xfer,
|
ret = k_pipe_put(pipe, data_bench, size2xfer,
|
||||||
&sizexferd, mim_num_of_bytes, K_FOREVER);
|
&sizexferd, mim_num_of_bytes, K_FOREVER);
|
||||||
|
|
||||||
if (0 != ret) {
|
if (ret != 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (_ALL_N == option && sizexferd != size2xfer) {
|
if (option == _ALL_N && sizexferd != size2xfer) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,7 +240,8 @@ int pipeput(struct k_pipe *pipe,
|
||||||
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, count);
|
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, count);
|
||||||
if (bench_test_end() < 0) {
|
if (bench_test_end() < 0) {
|
||||||
if (high_timer_overflow()) {
|
if (high_timer_overflow()) {
|
||||||
PRINT_STRING("| Timer overflow. Results are invalid ",
|
PRINT_STRING("| Timer overflow."
|
||||||
|
"Results are invalid ",
|
||||||
output_file);
|
output_file);
|
||||||
} else {
|
} else {
|
||||||
PRINT_STRING("| Tick occurred. Results may be inaccurate ",
|
PRINT_STRING("| Tick occurred. Results may be inaccurate ",
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
/*
|
/*
|
||||||
* Function prototypes.
|
* Function prototypes.
|
||||||
*/
|
*/
|
||||||
int pipeget(struct k_pipe *pipe, pipe_options option,
|
int pipeget(struct k_pipe *pipe, enum pipe_options option,
|
||||||
int size, int count, unsigned int *time);
|
int size, int count, unsigned int *time);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -37,14 +37,14 @@ void piperecvtask(void)
|
||||||
int getcount;
|
int getcount;
|
||||||
int pipe;
|
int pipe;
|
||||||
int prio;
|
int prio;
|
||||||
GetInfo getinfo;
|
struct getinfo getinfo;
|
||||||
|
|
||||||
/* matching (ALL_N) */
|
/* matching (ALL_N) */
|
||||||
|
|
||||||
for (getsize = 8; getsize <= MESSAGE_SIZE_PIPE; getsize <<= 1) {
|
for (getsize = 8; getsize <= MESSAGE_SIZE_PIPE; getsize <<= 1) {
|
||||||
for (pipe = 0; pipe < 3; pipe++) {
|
for (pipe = 0; pipe < 3; pipe++) {
|
||||||
getcount = NR_OF_PIPE_RUNS;
|
getcount = NR_OF_PIPE_RUNS;
|
||||||
pipeget(TestPipes[pipe], _ALL_N, getsize,
|
pipeget(test_pipes[pipe], _ALL_N, getsize,
|
||||||
getcount, &gettime);
|
getcount, &gettime);
|
||||||
getinfo.time = gettime;
|
getinfo.time = gettime;
|
||||||
getinfo.size = getsize;
|
getinfo.size = getsize;
|
||||||
|
@ -60,7 +60,7 @@ void piperecvtask(void)
|
||||||
getcount = MESSAGE_SIZE_PIPE / getsize;
|
getcount = MESSAGE_SIZE_PIPE / getsize;
|
||||||
for (pipe = 0; pipe < 3; pipe++) {
|
for (pipe = 0; pipe < 3; pipe++) {
|
||||||
/* size*count == MESSAGE_SIZE_PIPE */
|
/* size*count == MESSAGE_SIZE_PIPE */
|
||||||
pipeget(TestPipes[pipe], _1_TO_N,
|
pipeget(test_pipes[pipe], _1_TO_N,
|
||||||
getsize, getcount, &gettime);
|
getsize, getcount, &gettime);
|
||||||
getinfo.time = gettime;
|
getinfo.time = gettime;
|
||||||
getinfo.size = getsize;
|
getinfo.size = getsize;
|
||||||
|
@ -86,7 +86,7 @@ void piperecvtask(void)
|
||||||
* @param count Number of data chunks.
|
* @param count Number of data chunks.
|
||||||
* @param time Total write time.
|
* @param time Total write time.
|
||||||
*/
|
*/
|
||||||
int pipeget(struct k_pipe *pipe, pipe_options option, int size, int count,
|
int pipeget(struct k_pipe *pipe, enum pipe_options option, int size, int count,
|
||||||
unsigned int *time)
|
unsigned int *time)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -97,7 +97,7 @@ int pipeget(struct k_pipe *pipe, pipe_options option, int size, int count,
|
||||||
/* sync with the sender */
|
/* sync with the sender */
|
||||||
k_sem_take(&SEM0, K_FOREVER);
|
k_sem_take(&SEM0, K_FOREVER);
|
||||||
t = BENCH_START();
|
t = BENCH_START();
|
||||||
for (i = 0; _1_TO_N == option || (i < count); i++) {
|
for (i = 0; option == _1_TO_N || (i < count); i++) {
|
||||||
size_t sizexferd = 0;
|
size_t sizexferd = 0;
|
||||||
size_t size2xfer = min(size, size2xfer_total - sizexferd_total);
|
size_t size2xfer = min(size, size2xfer_total - sizexferd_total);
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -105,11 +105,11 @@ int pipeget(struct k_pipe *pipe, pipe_options option, int size, int count,
|
||||||
ret = k_pipe_get(pipe, data_recv, size2xfer,
|
ret = k_pipe_get(pipe, data_recv, size2xfer,
|
||||||
&sizexferd, option, K_FOREVER);
|
&sizexferd, option, K_FOREVER);
|
||||||
|
|
||||||
if (0 != ret) {
|
if (ret != 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_ALL_N == option && sizexferd != size2xfer) {
|
if (option == _ALL_N && sizexferd != size2xfer) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,10 +127,12 @@ int pipeget(struct k_pipe *pipe, pipe_options option, int size, int count,
|
||||||
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, count);
|
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, count);
|
||||||
if (bench_test_end() < 0) {
|
if (bench_test_end() < 0) {
|
||||||
if (high_timer_overflow()) {
|
if (high_timer_overflow()) {
|
||||||
PRINT_STRING("| Timer overflow. Results are invalid ",
|
PRINT_STRING("| Timer overflow. "
|
||||||
|
"Results are invalid ",
|
||||||
output_file);
|
output_file);
|
||||||
} else {
|
} else {
|
||||||
PRINT_STRING("| Tick occurred. Results may be inaccurate ",
|
PRINT_STRING("| Tick occurred. "
|
||||||
|
"Results may be inaccurate ",
|
||||||
output_file);
|
output_file);
|
||||||
}
|
}
|
||||||
PRINT_STRING(" |\n",
|
PRINT_STRING(" |\n",
|
||||||
|
|
|
@ -15,11 +15,11 @@
|
||||||
#include "master.h"
|
#include "master.h"
|
||||||
|
|
||||||
/* type defines. */
|
/* type defines. */
|
||||||
typedef struct {
|
struct getinfo{
|
||||||
int count;
|
int count;
|
||||||
unsigned int time;
|
unsigned int time;
|
||||||
int size;
|
int size;
|
||||||
} GetInfo;
|
};
|
||||||
|
|
||||||
/* global data */
|
/* global data */
|
||||||
extern char data_recv[OCTET_TO_SIZEOFUNIT(MESSAGE_SIZE)];
|
extern char data_recv[OCTET_TO_SIZEOFUNIT(MESSAGE_SIZE)];
|
||||||
|
|
|
@ -32,7 +32,7 @@ static const char *poll_data = "This is a POLL test.\r\n";
|
||||||
|
|
||||||
static int test_poll_in(void)
|
static int test_poll_in(void)
|
||||||
{
|
{
|
||||||
unsigned char recvChar;
|
unsigned char recv_char;
|
||||||
struct device *uart_dev = device_get_binding(UART_DEVICE_NAME);
|
struct device *uart_dev = device_get_binding(UART_DEVICE_NAME);
|
||||||
|
|
||||||
if (!uart_dev) {
|
if (!uart_dev) {
|
||||||
|
@ -44,12 +44,12 @@ static int test_poll_in(void)
|
||||||
|
|
||||||
/* Verify uart_poll_in() */
|
/* Verify uart_poll_in() */
|
||||||
while (1) {
|
while (1) {
|
||||||
while (uart_poll_in(uart_dev, &recvChar) < 0)
|
while (uart_poll_in(uart_dev, &recv_char) < 0)
|
||||||
;
|
;
|
||||||
|
|
||||||
TC_PRINT("%c", recvChar);
|
TC_PRINT("%c", recv_char);
|
||||||
|
|
||||||
if ((recvChar == '\n') || (recvChar == '\r')) {
|
if ((recv_char == '\n') || (recv_char == '\r')) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ static int test_poll_in(void)
|
||||||
static int test_poll_out(void)
|
static int test_poll_out(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unsigned char sentChar;
|
unsigned char sent_char;
|
||||||
struct device *uart_dev = device_get_binding(UART_DEVICE_NAME);
|
struct device *uart_dev = device_get_binding(UART_DEVICE_NAME);
|
||||||
|
|
||||||
if (!uart_dev) {
|
if (!uart_dev) {
|
||||||
|
@ -70,11 +70,11 @@ static int test_poll_out(void)
|
||||||
|
|
||||||
/* Verify uart_poll_out() */
|
/* Verify uart_poll_out() */
|
||||||
for (i = 0; i < strlen(poll_data); i++) {
|
for (i = 0; i < strlen(poll_data); i++) {
|
||||||
sentChar = uart_poll_out(uart_dev, poll_data[i]);
|
sent_char = uart_poll_out(uart_dev, poll_data[i]);
|
||||||
|
|
||||||
if (sentChar != poll_data[i]) {
|
if (sent_char != poll_data[i]) {
|
||||||
TC_PRINT("expect send %c, actaul send %c\n",
|
TC_PRINT("expect send %c, actaul send %c\n",
|
||||||
poll_data[i], sentChar);
|
poll_data[i], sent_char);
|
||||||
return TC_FAIL;
|
return TC_FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ static void alert_recv(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tThread_entry(void *p1, void *p2, void *p3)
|
static void thread_entry(void *p1, void *p2, void *p3)
|
||||||
{
|
{
|
||||||
alert_recv();
|
alert_recv();
|
||||||
}
|
}
|
||||||
|
@ -92,14 +92,14 @@ static void thread_alert(void)
|
||||||
handler_executed = 0;
|
handler_executed = 0;
|
||||||
/**TESTPOINT: thread-thread sync via alert*/
|
/**TESTPOINT: thread-thread sync via alert*/
|
||||||
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
|
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
|
||||||
tThread_entry, NULL, NULL, NULL,
|
thread_entry, NULL, NULL, NULL,
|
||||||
K_PRIO_PREEMPT(0), 0, 0);
|
K_PRIO_PREEMPT(0), 0, 0);
|
||||||
alert_send();
|
alert_send();
|
||||||
k_sleep(TIMEOUT);
|
k_sleep(TIMEOUT);
|
||||||
k_thread_abort(tid);
|
k_thread_abort(tid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tIsr_entry(void *p)
|
static void tisr_entry(void *p)
|
||||||
{
|
{
|
||||||
alert_send();
|
alert_send();
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ static void isr_alert(void)
|
||||||
{
|
{
|
||||||
handler_executed = 0;
|
handler_executed = 0;
|
||||||
/**TESTPOINT: thread-isr sync via alert*/
|
/**TESTPOINT: thread-isr sync via alert*/
|
||||||
irq_offload(tIsr_entry, NULL);
|
irq_offload(tisr_entry, NULL);
|
||||||
k_sleep(TIMEOUT);
|
k_sleep(TIMEOUT);
|
||||||
alert_recv();
|
alert_recv();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
#define NUM_MILLISECONDS 5000
|
#define NUM_MILLISECONDS 5000
|
||||||
#define TEST_TIMEOUT 20000
|
#define TEST_TIMEOUT 20000
|
||||||
|
|
||||||
static u32_t criticalVar;
|
static u32_t critical_var;
|
||||||
static u32_t altTaskIterations;
|
static u32_t alt_task_iterations;
|
||||||
|
|
||||||
static struct k_work_q offload_work_q;
|
static struct k_work_q offload_work_q;
|
||||||
static K_THREAD_STACK_DEFINE(offload_work_q_stack,
|
static K_THREAD_STACK_DEFINE(offload_work_q_stack,
|
||||||
|
@ -40,19 +40,19 @@ K_SEM_DEFINE(TEST_SEM, 0, UINT_MAX);
|
||||||
*
|
*
|
||||||
* @brief Routine to be called from a workqueue
|
* @brief Routine to be called from a workqueue
|
||||||
*
|
*
|
||||||
* This routine increments the global variable <criticalVar>.
|
* This routine increments the global variable <critical_var>.
|
||||||
*
|
*
|
||||||
* @return 0
|
* @return 0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void criticalRtn(struct k_work *unused)
|
void critical_rtn(struct k_work *unused)
|
||||||
{
|
{
|
||||||
volatile u32_t x;
|
volatile u32_t x;
|
||||||
|
|
||||||
ARG_UNUSED(unused);
|
ARG_UNUSED(unused);
|
||||||
|
|
||||||
x = criticalVar;
|
x = critical_var;
|
||||||
criticalVar = x + 1;
|
critical_var = x + 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ void criticalRtn(struct k_work *unused)
|
||||||
* @return number of critical section calls made by task
|
* @return number of critical section calls made by task
|
||||||
*/
|
*/
|
||||||
|
|
||||||
u32_t criticalLoop(u32_t count)
|
u32_t critical_loop(u32_t count)
|
||||||
{
|
{
|
||||||
s64_t mseconds;
|
s64_t mseconds;
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ u32_t criticalLoop(u32_t count)
|
||||||
while (k_uptime_get() < mseconds + NUM_MILLISECONDS) {
|
while (k_uptime_get() < mseconds + NUM_MILLISECONDS) {
|
||||||
struct k_work work_item;
|
struct k_work work_item;
|
||||||
|
|
||||||
k_work_init(&work_item, criticalRtn);
|
k_work_init(&work_item, critical_rtn);
|
||||||
k_work_submit_to_queue(&offload_work_q, &work_item);
|
k_work_submit_to_queue(&offload_work_q, &work_item);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ u32_t criticalLoop(u32_t count)
|
||||||
* @return N/A
|
* @return N/A
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void AlternateTask(void *arg1, void *arg2, void *arg3)
|
void alternate_task(void *arg1, void *arg2, void *arg3)
|
||||||
{
|
{
|
||||||
ARG_UNUSED(arg1);
|
ARG_UNUSED(arg1);
|
||||||
ARG_UNUSED(arg2);
|
ARG_UNUSED(arg2);
|
||||||
|
@ -98,13 +98,13 @@ void AlternateTask(void *arg1, void *arg2, void *arg3)
|
||||||
|
|
||||||
k_sem_take(&ALT_SEM, K_FOREVER); /* Wait to be activated */
|
k_sem_take(&ALT_SEM, K_FOREVER); /* Wait to be activated */
|
||||||
|
|
||||||
altTaskIterations = criticalLoop(altTaskIterations);
|
alt_task_iterations = critical_loop(alt_task_iterations);
|
||||||
|
|
||||||
k_sem_give(®RESS_SEM);
|
k_sem_give(®RESS_SEM);
|
||||||
|
|
||||||
k_sem_take(&ALT_SEM, K_FOREVER); /* Wait to be re-activated */
|
k_sem_take(&ALT_SEM, K_FOREVER); /* Wait to be re-activated */
|
||||||
|
|
||||||
altTaskIterations = criticalLoop(altTaskIterations);
|
alt_task_iterations = critical_loop(alt_task_iterations);
|
||||||
|
|
||||||
k_sem_give(®RESS_SEM);
|
k_sem_give(®RESS_SEM);
|
||||||
}
|
}
|
||||||
|
@ -120,9 +120,9 @@ void AlternateTask(void *arg1, void *arg2, void *arg3)
|
||||||
* @return N/A
|
* @return N/A
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void RegressionTask(void *arg1, void *arg2, void *arg3)
|
void regression_task(void *arg1, void *arg2, void *arg3)
|
||||||
{
|
{
|
||||||
u32_t nCalls = 0;
|
u32_t ncalls = 0;
|
||||||
|
|
||||||
ARG_UNUSED(arg1);
|
ARG_UNUSED(arg1);
|
||||||
ARG_UNUSED(arg2);
|
ARG_UNUSED(arg2);
|
||||||
|
@ -130,26 +130,26 @@ void RegressionTask(void *arg1, void *arg2, void *arg3)
|
||||||
|
|
||||||
k_sem_give(&ALT_SEM); /* Activate AlternateTask() */
|
k_sem_give(&ALT_SEM); /* Activate AlternateTask() */
|
||||||
|
|
||||||
nCalls = criticalLoop(nCalls);
|
ncalls = critical_loop(ncalls);
|
||||||
|
|
||||||
/* Wait for AlternateTask() to complete */
|
/* Wait for AlternateTask() to complete */
|
||||||
zassert_true(k_sem_take(®RESS_SEM, TEST_TIMEOUT) == 0,
|
zassert_true(k_sem_take(®RESS_SEM, TEST_TIMEOUT) == 0,
|
||||||
"Timed out waiting for REGRESS_SEM");
|
"Timed out waiting for REGRESS_SEM");
|
||||||
|
|
||||||
zassert_equal(criticalVar, nCalls + altTaskIterations,
|
zassert_equal(critical_var, ncalls + alt_task_iterations,
|
||||||
"Unexpected value for <criticalVar>");
|
"Unexpected value for <criticalVar>");
|
||||||
|
|
||||||
k_sched_time_slice_set(10, 10);
|
k_sched_time_slice_set(10, 10);
|
||||||
|
|
||||||
k_sem_give(&ALT_SEM); /* Re-activate AlternateTask() */
|
k_sem_give(&ALT_SEM); /* Re-activate AlternateTask() */
|
||||||
|
|
||||||
nCalls = criticalLoop(nCalls);
|
ncalls = critical_loop(ncalls);
|
||||||
|
|
||||||
/* Wait for AlternateTask() to finish */
|
/* Wait for AlternateTask() to finish */
|
||||||
zassert_true(k_sem_take(®RESS_SEM, TEST_TIMEOUT) == 0,
|
zassert_true(k_sem_take(®RESS_SEM, TEST_TIMEOUT) == 0,
|
||||||
"Timed out waiting for REGRESS_SEM");
|
"Timed out waiting for REGRESS_SEM");
|
||||||
|
|
||||||
zassert_equal(criticalVar, nCalls + altTaskIterations,
|
zassert_equal(critical_var, ncalls + alt_task_iterations,
|
||||||
"Unexpected value for <criticalVar>");
|
"Unexpected value for <criticalVar>");
|
||||||
|
|
||||||
k_sem_give(&TEST_SEM);
|
k_sem_give(&TEST_SEM);
|
||||||
|
@ -158,8 +158,8 @@ void RegressionTask(void *arg1, void *arg2, void *arg3)
|
||||||
|
|
||||||
static void init_objects(void)
|
static void init_objects(void)
|
||||||
{
|
{
|
||||||
criticalVar = 0;
|
critical_var = 0;
|
||||||
altTaskIterations = 0;
|
alt_task_iterations = 0;
|
||||||
k_work_q_start(&offload_work_q,
|
k_work_q_start(&offload_work_q,
|
||||||
offload_work_q_stack,
|
offload_work_q_stack,
|
||||||
K_THREAD_STACK_SIZEOF(offload_work_q_stack),
|
K_THREAD_STACK_SIZEOF(offload_work_q_stack),
|
||||||
|
@ -169,11 +169,11 @@ static void init_objects(void)
|
||||||
static void start_threads(void)
|
static void start_threads(void)
|
||||||
{
|
{
|
||||||
k_thread_create(&thread1, stack1, STACK_SIZE,
|
k_thread_create(&thread1, stack1, STACK_SIZE,
|
||||||
AlternateTask, NULL, NULL, NULL,
|
alternate_task, NULL, NULL, NULL,
|
||||||
K_PRIO_PREEMPT(12), 0, 0);
|
K_PRIO_PREEMPT(12), 0, 0);
|
||||||
|
|
||||||
k_thread_create(&thread2, stack2, STACK_SIZE,
|
k_thread_create(&thread2, stack2, STACK_SIZE,
|
||||||
RegressionTask, NULL, NULL, NULL,
|
regression_task, NULL, NULL, NULL,
|
||||||
K_PRIO_PREEMPT(12), 0, 0);
|
K_PRIO_PREEMPT(12), 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,23 +27,23 @@
|
||||||
#include <zephyr.h>
|
#include <zephyr.h>
|
||||||
|
|
||||||
/* size of stack area used by each thread */
|
/* size of stack area used by each thread */
|
||||||
#define STACKSIZE 1024 + CONFIG_TEST_EXTRA_STACKSIZE
|
#define STACKSIZE (1024 + CONFIG_TEST_EXTRA_STACKSIZE)
|
||||||
|
|
||||||
/* Number of memory blocks. The minimum number of blocks needed to run the
|
/* Number of memory blocks. The minimum number of blocks needed to run the
|
||||||
* test is 2
|
* test is 2
|
||||||
*/
|
*/
|
||||||
#define NUMBLOCKS 2
|
#define NUMBLOCKS 2
|
||||||
|
|
||||||
static int tcRC = TC_PASS; /* test case return code */
|
static int tc_rc = TC_PASS; /* test case return code */
|
||||||
|
|
||||||
int testSlabGetAllBlocks(void **P);
|
int test_slab_get_all_blocks(void **P);
|
||||||
int testSlabFreeAllBlocks(void **P);
|
int test_slab_free_all_blocks(void **P);
|
||||||
|
|
||||||
|
|
||||||
K_SEM_DEFINE(SEM_HELPERDONE, 0, 1);
|
K_SEM_DEFINE(SEM_HELPERDONE, 0, 1);
|
||||||
K_SEM_DEFINE(SEM_REGRESSDONE, 0, 1);
|
K_SEM_DEFINE(SEM_REGRESSDONE, 0, 1);
|
||||||
|
|
||||||
K_MEM_SLAB_DEFINE(MAP_LgBlks, 1024, NUMBLOCKS, 4);
|
K_MEM_SLAB_DEFINE(map_lgblks, 1024, NUMBLOCKS, 4);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,17 +53,17 @@ K_MEM_SLAB_DEFINE(MAP_LgBlks, 1024, NUMBLOCKS, 4);
|
||||||
* This routine verifies current value against expected value
|
* This routine verifies current value against expected value
|
||||||
* and returns true if they are the same.
|
* and returns true if they are the same.
|
||||||
*
|
*
|
||||||
* @param expectRetValue expect value
|
* @param expect_ret_value expect value
|
||||||
* @param currentRetValue current value
|
* @param current_ret_current current value
|
||||||
*
|
*
|
||||||
* @return true, false
|
* @return true, false
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool verifyRetValue(int expectRetValue, int currentRetValue)
|
bool verify_ret_value(int expect_ret_value, int current_ret_current)
|
||||||
{
|
{
|
||||||
return (expectRetValue == currentRetValue);
|
return (expect_ret_value == current_ret_current);
|
||||||
|
|
||||||
} /* verifyRetValue */
|
} /* verify_ret_value */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -76,7 +76,7 @@ bool verifyRetValue(int expectRetValue, int currentRetValue)
|
||||||
* @return N/A
|
* @return N/A
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void HelperTask(void)
|
void helper_task(void)
|
||||||
{
|
{
|
||||||
void *ptr[NUMBLOCKS]; /* Pointer to memory block */
|
void *ptr[NUMBLOCKS]; /* Pointer to memory block */
|
||||||
|
|
||||||
|
@ -92,10 +92,10 @@ void HelperTask(void)
|
||||||
PRINT_LINE;
|
PRINT_LINE;
|
||||||
|
|
||||||
/* Test k_mem_slab_alloc */
|
/* Test k_mem_slab_alloc */
|
||||||
tcRC = testSlabGetAllBlocks(ptr);
|
tc_rc = test_slab_get_all_blocks(ptr);
|
||||||
if (tcRC == TC_FAIL) {
|
if (tc_rc == TC_FAIL) {
|
||||||
TC_ERROR("Failed testSlabGetAllBlocks function\n");
|
TC_ERROR("Failed test_slab_get_all_blocks function\n");
|
||||||
goto exitTest1; /* terminate test */
|
goto exittest1; /* terminate test */
|
||||||
}
|
}
|
||||||
|
|
||||||
k_sem_give(&SEM_HELPERDONE); /* Indicate part 2 is complete */
|
k_sem_give(&SEM_HELPERDONE); /* Indicate part 2 is complete */
|
||||||
|
@ -114,7 +114,7 @@ void HelperTask(void)
|
||||||
PRINT_LINE;
|
PRINT_LINE;
|
||||||
|
|
||||||
TC_PRINT("%s: About to free a memory block\n", __func__);
|
TC_PRINT("%s: About to free a memory block\n", __func__);
|
||||||
k_mem_slab_free(&MAP_LgBlks, &ptr[0]);
|
k_mem_slab_free(&map_lgblks, &ptr[0]);
|
||||||
k_sem_give(&SEM_HELPERDONE);
|
k_sem_give(&SEM_HELPERDONE);
|
||||||
|
|
||||||
/* Part 5 of test */
|
/* Part 5 of test */
|
||||||
|
@ -123,19 +123,19 @@ void HelperTask(void)
|
||||||
TC_PRINT("(5) <%s> freeing the next block\n", __func__);
|
TC_PRINT("(5) <%s> freeing the next block\n", __func__);
|
||||||
PRINT_LINE;
|
PRINT_LINE;
|
||||||
TC_PRINT("%s: About to free another memory block\n", __func__);
|
TC_PRINT("%s: About to free another memory block\n", __func__);
|
||||||
k_mem_slab_free(&MAP_LgBlks, &ptr[1]);
|
k_mem_slab_free(&map_lgblks, &ptr[1]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Free all the other blocks. The first 2 blocks are freed by this task
|
* Free all the other blocks. The first 2 blocks are freed by this task
|
||||||
*/
|
*/
|
||||||
for (int i = 2; i < NUMBLOCKS; i++) {
|
for (int i = 2; i < NUMBLOCKS; i++) {
|
||||||
k_mem_slab_free(&MAP_LgBlks, &ptr[i]);
|
k_mem_slab_free(&map_lgblks, &ptr[i]);
|
||||||
}
|
}
|
||||||
TC_PRINT("%s: freed all blocks allocated by this task\n", __func__);
|
TC_PRINT("%s: freed all blocks allocated by this task\n", __func__);
|
||||||
|
|
||||||
exitTest1:
|
exittest1:
|
||||||
|
|
||||||
TC_END_RESULT(tcRC);
|
TC_END_RESULT(tc_rc);
|
||||||
k_sem_give(&SEM_HELPERDONE);
|
k_sem_give(&SEM_HELPERDONE);
|
||||||
} /* HelperTask */
|
} /* HelperTask */
|
||||||
|
|
||||||
|
@ -156,33 +156,33 @@ exitTest1:
|
||||||
* @return TC_PASS, TC_FAIL
|
* @return TC_PASS, TC_FAIL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int testSlabGetAllBlocks(void **p)
|
int test_slab_get_all_blocks(void **p)
|
||||||
{
|
{
|
||||||
int retValue; /* task_mem_map_xxx interface return value */
|
int ret_value; /* task_mem_map_xxx interface return value */
|
||||||
void *errPtr; /* Pointer to block */
|
void *errptr; /* Pointer to block */
|
||||||
|
|
||||||
TC_PRINT("Function %s\n", __func__);
|
TC_PRINT("Function %s\n", __func__);
|
||||||
|
|
||||||
for (int i = 0; i < NUMBLOCKS; i++) {
|
for (int i = 0; i < NUMBLOCKS; i++) {
|
||||||
/* Verify number of used blocks in the map */
|
/* Verify number of used blocks in the map */
|
||||||
retValue = k_mem_slab_num_used_get(&MAP_LgBlks);
|
ret_value = k_mem_slab_num_used_get(&map_lgblks);
|
||||||
if (verifyRetValue(i, retValue)) {
|
if (verify_ret_value(i, ret_value)) {
|
||||||
TC_PRINT("MAP_LgBlks used %d blocks\n", retValue);
|
TC_PRINT("MAP_LgBlks used %d blocks\n", ret_value);
|
||||||
} else {
|
} else {
|
||||||
TC_ERROR("Failed task_mem_map_used_get for "
|
TC_ERROR("Failed task_mem_map_used_get for "
|
||||||
"MAP_LgBlks, i=%d, retValue=%d\n",
|
"MAP_LgBlks, i=%d, retValue=%d\n",
|
||||||
i, retValue);
|
i, ret_value);
|
||||||
return TC_FAIL;
|
return TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get memory block */
|
/* Get memory block */
|
||||||
retValue = k_mem_slab_alloc(&MAP_LgBlks, &p[i], K_NO_WAIT);
|
ret_value = k_mem_slab_alloc(&map_lgblks, &p[i], K_NO_WAIT);
|
||||||
if (verifyRetValue(0, retValue)) {
|
if (verify_ret_value(0, ret_value)) {
|
||||||
TC_PRINT(" k_mem_slab_alloc OK, p[%d] = %p\n",
|
TC_PRINT(" k_mem_slab_alloc OK, p[%d] = %p\n",
|
||||||
i, p[i]);
|
i, p[i]);
|
||||||
} else {
|
} else {
|
||||||
TC_ERROR("Failed k_mem_slab_alloc, i=%d, "
|
TC_ERROR("Failed k_mem_slab_alloc, i=%d, "
|
||||||
"retValue %d\n", i, retValue);
|
"ret_value %d\n", i, ret_value);
|
||||||
return TC_FAIL;
|
return TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,30 +191,30 @@ int testSlabGetAllBlocks(void **p)
|
||||||
/* Verify number of used blocks in the map - expect all blocks are
|
/* Verify number of used blocks in the map - expect all blocks are
|
||||||
* used
|
* used
|
||||||
*/
|
*/
|
||||||
retValue = k_mem_slab_num_used_get(&MAP_LgBlks);
|
ret_value = k_mem_slab_num_used_get(&map_lgblks);
|
||||||
if (verifyRetValue(NUMBLOCKS, retValue)) {
|
if (verify_ret_value(NUMBLOCKS, ret_value)) {
|
||||||
TC_PRINT("MAP_LgBlks used %d blocks\n", retValue);
|
TC_PRINT("MAP_LgBlks used %d blocks\n", ret_value);
|
||||||
} else {
|
} else {
|
||||||
TC_ERROR("Failed task_mem_map_used_get for MAP_LgBlks, "
|
TC_ERROR("Failed task_mem_map_used_get for MAP_LgBlks, "
|
||||||
"retValue %d\n", retValue);
|
"retValue %d\n", ret_value);
|
||||||
return TC_FAIL;
|
return TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to get one more block and it should fail */
|
/* Try to get one more block and it should fail */
|
||||||
retValue = k_mem_slab_alloc(&MAP_LgBlks, &errPtr, K_NO_WAIT);
|
ret_value = k_mem_slab_alloc(&map_lgblks, &errptr, K_NO_WAIT);
|
||||||
if (verifyRetValue(-ENOMEM, retValue)) {
|
if (verify_ret_value(-ENOMEM, ret_value)) {
|
||||||
TC_PRINT(" k_mem_slab_alloc RC_FAIL expected as all (%d) "
|
TC_PRINT(" k_mem_slab_alloc RC_FAIL expected as all (%d) "
|
||||||
"blocks are used.\n", NUMBLOCKS);
|
"blocks are used.\n", NUMBLOCKS);
|
||||||
} else {
|
} else {
|
||||||
TC_ERROR("Failed k_mem_slab_alloc, expect RC_FAIL, got %d\n",
|
TC_ERROR("Failed k_mem_slab_alloc, expect RC_FAIL, got %d\n",
|
||||||
retValue);
|
ret_value);
|
||||||
return TC_FAIL;
|
return TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRINT_LINE;
|
PRINT_LINE;
|
||||||
|
|
||||||
return TC_PASS;
|
return TC_PASS;
|
||||||
} /* testSlabGetAllBlocks */
|
} /* test_slab_get_all_blocks */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -232,27 +232,27 @@ int testSlabGetAllBlocks(void **p)
|
||||||
* @return TC_PASS, TC_FAIL
|
* @return TC_PASS, TC_FAIL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int testSlabFreeAllBlocks(void **p)
|
int test_slab_free_all_blocks(void **p)
|
||||||
{
|
{
|
||||||
int retValue; /* task_mem_map_xxx interface return value */
|
int ret_value; /* task_mem_map_xxx interface return value */
|
||||||
|
|
||||||
TC_PRINT("Function %s\n", __func__);
|
TC_PRINT("Function %s\n", __func__);
|
||||||
|
|
||||||
for (int i = 0; i < NUMBLOCKS; i++) {
|
for (int i = 0; i < NUMBLOCKS; i++) {
|
||||||
/* Verify number of used blocks in the map */
|
/* Verify number of used blocks in the map */
|
||||||
retValue = k_mem_slab_num_used_get(&MAP_LgBlks);
|
ret_value = k_mem_slab_num_used_get(&map_lgblks);
|
||||||
if (verifyRetValue(NUMBLOCKS - i, retValue)) {
|
if (verify_ret_value(NUMBLOCKS - i, ret_value)) {
|
||||||
TC_PRINT("MAP_LgBlks used %d blocks\n", retValue);
|
TC_PRINT("MAP_LgBlks used %d blocks\n", ret_value);
|
||||||
} else {
|
} else {
|
||||||
TC_ERROR("Failed task_mem_map_used_get for "
|
TC_ERROR("Failed task_mem_map_used_get for "
|
||||||
"MAP_LgBlks, expect %d, got %d\n",
|
"MAP_LgBlks, expect %d, got %d\n",
|
||||||
NUMBLOCKS - i, retValue);
|
NUMBLOCKS - i, ret_value);
|
||||||
return TC_FAIL;
|
return TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
TC_PRINT(" block ptr to free p[%d] = %p\n", i, p[i]);
|
TC_PRINT(" block ptr to free p[%d] = %p\n", i, p[i]);
|
||||||
/* Free memory block */
|
/* Free memory block */
|
||||||
k_mem_slab_free(&MAP_LgBlks, &p[i]);
|
k_mem_slab_free(&map_lgblks, &p[i]);
|
||||||
|
|
||||||
TC_PRINT("MAP_LgBlks freed %d block\n", i + 1);
|
TC_PRINT("MAP_LgBlks freed %d block\n", i + 1);
|
||||||
|
|
||||||
|
@ -263,12 +263,12 @@ int testSlabFreeAllBlocks(void **p)
|
||||||
* - should be 0 as no blocks are used
|
* - should be 0 as no blocks are used
|
||||||
*/
|
*/
|
||||||
|
|
||||||
retValue = k_mem_slab_num_used_get(&MAP_LgBlks);
|
ret_value = k_mem_slab_num_used_get(&map_lgblks);
|
||||||
if (verifyRetValue(0, retValue)) {
|
if (verify_ret_value(0, ret_value)) {
|
||||||
TC_PRINT("MAP_LgBlks used %d blocks\n", retValue);
|
TC_PRINT("MAP_LgBlks used %d blocks\n", ret_value);
|
||||||
} else {
|
} else {
|
||||||
TC_ERROR("Failed task_mem_map_used_get for MAP_LgBlks, "
|
TC_ERROR("Failed task_mem_map_used_get for MAP_LgBlks, "
|
||||||
"retValue %d\n", retValue);
|
"retValue %d\n", ret_value);
|
||||||
return TC_FAIL;
|
return TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,7 +286,7 @@ int testSlabFreeAllBlocks(void **p)
|
||||||
*
|
*
|
||||||
* @return N/A
|
* @return N/A
|
||||||
*/
|
*/
|
||||||
void printPointers(void **pointer)
|
void print_pointers(void **pointer)
|
||||||
{
|
{
|
||||||
TC_PRINT("%s: ", __func__);
|
TC_PRINT("%s: ", __func__);
|
||||||
for (int i = 0; i < NUMBLOCKS; i++) {
|
for (int i = 0; i < NUMBLOCKS; i++) {
|
||||||
|
@ -296,15 +296,15 @@ void printPointers(void **pointer)
|
||||||
TC_PRINT("\n");
|
TC_PRINT("\n");
|
||||||
PRINT_LINE;
|
PRINT_LINE;
|
||||||
|
|
||||||
} /* printPointers */
|
} /* print_pointers */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @brief Main task to test task_mem_map_xxx interfaces
|
* @brief Main task to test task_mem_map_xxx interfaces
|
||||||
*
|
*
|
||||||
* This routine calls testSlabGetAllBlocks() to get all memory blocks from the
|
* This routine calls test_slab_get_all_blocks() to get all memory blocks from
|
||||||
* map and calls testSlabFreeAllBlocks() to free all memory blocks. It also
|
* the map and calls test_slab_free_all_blocks() to free all memory blocks.
|
||||||
* tries to wait (with and without timeout) for a memory block.
|
* It also tries to wait (with and without timeout) for a memory block.
|
||||||
*
|
*
|
||||||
* This routine tests the following:
|
* This routine tests the following:
|
||||||
*
|
*
|
||||||
|
@ -313,9 +313,9 @@ void printPointers(void **pointer)
|
||||||
* @return N/A
|
* @return N/A
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void RegressionTask(void)
|
void regression_task(void)
|
||||||
{
|
{
|
||||||
int retValue; /* task_mem_map_xxx interface return value */
|
int ret_value; /* task_mem_map_xxx interface return value */
|
||||||
void *b; /* Pointer to memory block */
|
void *b; /* Pointer to memory block */
|
||||||
void *ptr[NUMBLOCKS]; /* Pointer to memory block */
|
void *ptr[NUMBLOCKS]; /* Pointer to memory block */
|
||||||
|
|
||||||
|
@ -332,18 +332,18 @@ void RegressionTask(void)
|
||||||
PRINT_LINE;
|
PRINT_LINE;
|
||||||
|
|
||||||
/* Test k_mem_slab_alloc */
|
/* Test k_mem_slab_alloc */
|
||||||
tcRC = testSlabGetAllBlocks(ptr);
|
tc_rc = test_slab_get_all_blocks(ptr);
|
||||||
if (tcRC == TC_FAIL) {
|
if (tc_rc == TC_FAIL) {
|
||||||
TC_ERROR("Failed testSlabGetAllBlocks function\n");
|
TC_ERROR("Failed test_slab_get_all_blocks function\n");
|
||||||
goto exitTest; /* terminate test */
|
goto exittest; /* terminate test */
|
||||||
}
|
}
|
||||||
|
|
||||||
printPointers(ptr);
|
print_pointers(ptr);
|
||||||
/* Test task_mem_map_free */
|
/* Test task_mem_map_free */
|
||||||
tcRC = testSlabFreeAllBlocks(ptr);
|
tc_rc = test_slab_free_all_blocks(ptr);
|
||||||
if (tcRC == TC_FAIL) {
|
if (tc_rc == TC_FAIL) {
|
||||||
TC_ERROR("Failed testSlabFreeAllBlocks function\n");
|
TC_ERROR("Failed testalab_freeall_blocks function\n");
|
||||||
goto exitTest; /* terminate test */
|
goto exittest; /* terminate test */
|
||||||
}
|
}
|
||||||
|
|
||||||
k_sem_give(&SEM_REGRESSDONE); /* Allow HelperTask to run */
|
k_sem_give(&SEM_REGRESSDONE); /* Allow HelperTask to run */
|
||||||
|
@ -363,26 +363,26 @@ void RegressionTask(void)
|
||||||
"in <%s>\n", __func__);
|
"in <%s>\n", __func__);
|
||||||
PRINT_LINE;
|
PRINT_LINE;
|
||||||
|
|
||||||
retValue = k_mem_slab_alloc(&MAP_LgBlks, &b, 20);
|
ret_value = k_mem_slab_alloc(&map_lgblks, &b, 20);
|
||||||
if (verifyRetValue(-EAGAIN, retValue)) {
|
if (verify_ret_value(-EAGAIN, ret_value)) {
|
||||||
TC_PRINT("%s: k_mem_slab_alloc times out which is "
|
TC_PRINT("%s: k_mem_slab_alloc times out which is "
|
||||||
"expected\n", __func__);
|
"expected\n", __func__);
|
||||||
} else {
|
} else {
|
||||||
TC_ERROR("Failed k_mem_slab_alloc, retValue %d\n", retValue);
|
TC_ERROR("Failed k_mem_slab_alloc, retValue %d\n", ret_value);
|
||||||
tcRC = TC_FAIL;
|
tc_rc = TC_FAIL;
|
||||||
goto exitTest; /* terminate test */
|
goto exittest; /* terminate test */
|
||||||
}
|
}
|
||||||
|
|
||||||
TC_PRINT("%s: start to wait for block\n", __func__);
|
TC_PRINT("%s: start to wait for block\n", __func__);
|
||||||
k_sem_give(&SEM_REGRESSDONE); /* Allow HelperTask to run part 4 */
|
k_sem_give(&SEM_REGRESSDONE); /* Allow HelperTask to run part 4 */
|
||||||
retValue = k_mem_slab_alloc(&MAP_LgBlks, &b, 50);
|
ret_value = k_mem_slab_alloc(&map_lgblks, &b, 50);
|
||||||
if (verifyRetValue(0, retValue)) {
|
if (verify_ret_value(0, ret_value)) {
|
||||||
TC_PRINT("%s: k_mem_slab_alloc OK, block allocated at %p\n",
|
TC_PRINT("%s: k_mem_slab_alloc OK, block allocated at %p\n",
|
||||||
__func__, b);
|
__func__, b);
|
||||||
} else {
|
} else {
|
||||||
TC_ERROR("Failed k_mem_slab_alloc, retValue %d\n", retValue);
|
TC_ERROR("Failed k_mem_slab_alloc, ret_value %d\n", ret_value);
|
||||||
tcRC = TC_FAIL;
|
tc_rc = TC_FAIL;
|
||||||
goto exitTest; /* terminate test */
|
goto exittest; /* terminate test */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait for HelperTask to complete */
|
/* Wait for HelperTask to complete */
|
||||||
|
@ -390,14 +390,14 @@ void RegressionTask(void)
|
||||||
|
|
||||||
TC_PRINT("%s: start to wait for block\n", __func__);
|
TC_PRINT("%s: start to wait for block\n", __func__);
|
||||||
k_sem_give(&SEM_REGRESSDONE); /* Allow HelperTask to run part 5 */
|
k_sem_give(&SEM_REGRESSDONE); /* Allow HelperTask to run part 5 */
|
||||||
retValue = k_mem_slab_alloc(&MAP_LgBlks, &b, K_FOREVER);
|
ret_value = k_mem_slab_alloc(&map_lgblks, &b, K_FOREVER);
|
||||||
if (verifyRetValue(0, retValue)) {
|
if (verify_ret_value(0, ret_value)) {
|
||||||
TC_PRINT("%s: k_mem_slab_alloc OK, block allocated at %p\n",
|
TC_PRINT("%s: k_mem_slab_alloc OK, block allocated at %p\n",
|
||||||
__func__, b);
|
__func__, b);
|
||||||
} else {
|
} else {
|
||||||
TC_ERROR("Failed k_mem_slab_alloc, retValue %d\n", retValue);
|
TC_ERROR("Failed k_mem_slab_alloc, ret_value %d\n", ret_value);
|
||||||
tcRC = TC_FAIL;
|
tc_rc = TC_FAIL;
|
||||||
goto exitTest; /* terminate test */
|
goto exittest; /* terminate test */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait for HelperTask to complete */
|
/* Wait for HelperTask to complete */
|
||||||
|
@ -406,19 +406,19 @@ void RegressionTask(void)
|
||||||
|
|
||||||
/* Free memory block */
|
/* Free memory block */
|
||||||
TC_PRINT("%s: Used %d block\n", __func__,
|
TC_PRINT("%s: Used %d block\n", __func__,
|
||||||
k_mem_slab_num_used_get(&MAP_LgBlks));
|
k_mem_slab_num_used_get(&map_lgblks));
|
||||||
k_mem_slab_free(&MAP_LgBlks, &b);
|
k_mem_slab_free(&map_lgblks, &b);
|
||||||
TC_PRINT("%s: 1 block freed, used %d block\n",
|
TC_PRINT("%s: 1 block freed, used %d block\n",
|
||||||
__func__, k_mem_slab_num_used_get(&MAP_LgBlks));
|
__func__, k_mem_slab_num_used_get(&map_lgblks));
|
||||||
|
|
||||||
exitTest:
|
exittest:
|
||||||
|
|
||||||
TC_END_RESULT(tcRC);
|
TC_END_RESULT(tc_rc);
|
||||||
TC_END_REPORT(tcRC);
|
TC_END_REPORT(tc_rc);
|
||||||
} /* RegressionTask */
|
} /* regression_task */
|
||||||
|
|
||||||
K_THREAD_DEFINE(HELPERTASK, STACKSIZE, HelperTask, NULL, NULL, NULL,
|
K_THREAD_DEFINE(HELPERTASK, STACKSIZE, helper_task, NULL, NULL, NULL,
|
||||||
7, 0, K_NO_WAIT);
|
7, 0, K_NO_WAIT);
|
||||||
|
|
||||||
K_THREAD_DEFINE(REGRESSTASK, STACKSIZE, RegressionTask, NULL, NULL, NULL,
|
K_THREAD_DEFINE(REGRESSTASK, STACKSIZE, regression_task, NULL, NULL, NULL,
|
||||||
5, 0, K_NO_WAIT);
|
5, 0, K_NO_WAIT);
|
||||||
|
|
|
@ -31,7 +31,8 @@ static void put_msgq(struct k_msgq *pmsgq)
|
||||||
ret = k_msgq_put(pmsgq, (void *)&data[i], K_NO_WAIT);
|
ret = k_msgq_put(pmsgq, (void *)&data[i], K_NO_WAIT);
|
||||||
zassert_false(ret, NULL);
|
zassert_false(ret, NULL);
|
||||||
/**TESTPOINT: msgq free get*/
|
/**TESTPOINT: msgq free get*/
|
||||||
zassert_equal(k_msgq_num_free_get(pmsgq), MSGQ_LEN - 1 - i, NULL);
|
zassert_equal(k_msgq_num_free_get(pmsgq),
|
||||||
|
MSGQ_LEN - 1 - i, NULL);
|
||||||
/**TESTPOINT: msgq used get*/
|
/**TESTPOINT: msgq used get*/
|
||||||
zassert_equal(k_msgq_num_used_get(pmsgq), i + 1, NULL);
|
zassert_equal(k_msgq_num_used_get(pmsgq), i + 1, NULL);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +50,8 @@ static void get_msgq(struct k_msgq *pmsgq)
|
||||||
/**TESTPOINT: msgq free get*/
|
/**TESTPOINT: msgq free get*/
|
||||||
zassert_equal(k_msgq_num_free_get(pmsgq), i + 1, NULL);
|
zassert_equal(k_msgq_num_free_get(pmsgq), i + 1, NULL);
|
||||||
/**TESTPOINT: msgq used get*/
|
/**TESTPOINT: msgq used get*/
|
||||||
zassert_equal(k_msgq_num_used_get(pmsgq), MSGQ_LEN - 1 - i, NULL);
|
zassert_equal(k_msgq_num_used_get(pmsgq),
|
||||||
|
MSGQ_LEN - 1 - i, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,12 +62,12 @@ static void purge_msgq(struct k_msgq *pmsgq)
|
||||||
zassert_equal(k_msgq_num_used_get(pmsgq), 0, NULL);
|
zassert_equal(k_msgq_num_used_get(pmsgq), 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tIsr_entry(void *p)
|
static void tisr_entry(void *p)
|
||||||
{
|
{
|
||||||
put_msgq((struct k_msgq *)p);
|
put_msgq((struct k_msgq *)p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tThread_entry(void *p1, void *p2, void *p3)
|
static void thread_entry(void *p1, void *p2, void *p3)
|
||||||
{
|
{
|
||||||
get_msgq((struct k_msgq *)p1);
|
get_msgq((struct k_msgq *)p1);
|
||||||
k_sem_give(&end_sema);
|
k_sem_give(&end_sema);
|
||||||
|
@ -76,7 +78,7 @@ static void msgq_thread(struct k_msgq *pmsgq)
|
||||||
k_sem_init(&end_sema, 0, 1);
|
k_sem_init(&end_sema, 0, 1);
|
||||||
/**TESTPOINT: thread-thread data passing via message queue*/
|
/**TESTPOINT: thread-thread data passing via message queue*/
|
||||||
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
|
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
|
||||||
tThread_entry, pmsgq, NULL, NULL,
|
thread_entry, pmsgq, NULL, NULL,
|
||||||
K_PRIO_PREEMPT(0), 0, 0);
|
K_PRIO_PREEMPT(0), 0, 0);
|
||||||
put_msgq(pmsgq);
|
put_msgq(pmsgq);
|
||||||
k_sem_take(&end_sema, K_FOREVER);
|
k_sem_take(&end_sema, K_FOREVER);
|
||||||
|
@ -89,7 +91,7 @@ static void msgq_thread(struct k_msgq *pmsgq)
|
||||||
static void msgq_isr(struct k_msgq *pmsgq)
|
static void msgq_isr(struct k_msgq *pmsgq)
|
||||||
{
|
{
|
||||||
/**TESTPOINT: thread-isr data passing via message queue*/
|
/**TESTPOINT: thread-isr data passing via message queue*/
|
||||||
irq_offload(tIsr_entry, pmsgq);
|
irq_offload(tisr_entry, pmsgq);
|
||||||
get_msgq(pmsgq);
|
get_msgq(pmsgq);
|
||||||
|
|
||||||
/**TESTPOINT: msgq purge*/
|
/**TESTPOINT: msgq purge*/
|
||||||
|
|
|
@ -51,35 +51,35 @@
|
||||||
|
|
||||||
#define STACKSIZE 512
|
#define STACKSIZE 512
|
||||||
|
|
||||||
static int tcRC = TC_PASS; /* test case return code */
|
static int tc_rc = TC_PASS; /* test case return code */
|
||||||
|
|
||||||
K_MUTEX_DEFINE(private_mutex);
|
K_MUTEX_DEFINE(private_mutex);
|
||||||
|
|
||||||
|
|
||||||
K_MUTEX_DEFINE(Mutex1);
|
K_MUTEX_DEFINE(mutex1);
|
||||||
K_MUTEX_DEFINE(Mutex2);
|
K_MUTEX_DEFINE(mutex2);
|
||||||
K_MUTEX_DEFINE(Mutex3);
|
K_MUTEX_DEFINE(mutex3);
|
||||||
K_MUTEX_DEFINE(Mutex4);
|
K_MUTEX_DEFINE(mutex4);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Task05 -
|
* task05 -
|
||||||
*
|
*
|
||||||
* @return N/A
|
* @return N/A
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void Task05(void)
|
void task05(void)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
k_sleep(K_MSEC(3500));
|
k_sleep(K_MSEC(3500));
|
||||||
|
|
||||||
/* Wait and boost owner priority to 5 */
|
/* Wait and boost owner priority to 5 */
|
||||||
rv = k_mutex_lock(&Mutex4, K_SECONDS(1));
|
rv = k_mutex_lock(&mutex4, K_SECONDS(1));
|
||||||
if (rv != -EAGAIN) {
|
if (rv != -EAGAIN) {
|
||||||
tcRC = TC_FAIL;
|
tc_rc = TC_FAIL;
|
||||||
TC_ERROR("Failed to timeout on mutex 0x%x\n",
|
TC_ERROR("Failed to timeout on mutex 0x%x\n",
|
||||||
(u32_t)&Mutex4);
|
(u32_t)&mutex4);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,12 +87,12 @@ void Task05(void)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Task06 -
|
* task06 -
|
||||||
*
|
*
|
||||||
* @return N/A
|
* @return N/A
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void Task06(void)
|
void task06(void)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
|
@ -107,24 +107,24 @@ void Task06(void)
|
||||||
* to 7, but will instead drop to 6.
|
* to 7, but will instead drop to 6.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
rv = k_mutex_lock(&Mutex4, K_SECONDS(2));
|
rv = k_mutex_lock(&mutex4, K_SECONDS(2));
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
tcRC = TC_FAIL;
|
tc_rc = TC_FAIL;
|
||||||
TC_ERROR("Failed to take mutex 0x%x\n", (u32_t)&Mutex4);
|
TC_ERROR("Failed to take mutex 0x%x\n", (u32_t)&mutex4);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
k_mutex_unlock(&Mutex4);
|
k_mutex_unlock(&mutex4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Task07 -
|
* task07 -
|
||||||
*
|
*
|
||||||
* @return N/A
|
* @return N/A
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void Task07(void)
|
void task07(void)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
|
@ -138,11 +138,11 @@ void Task07(void)
|
||||||
* priority of the owning task RegressionTask will drop to 8.
|
* priority of the owning task RegressionTask will drop to 8.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
rv = k_mutex_lock(&Mutex3, K_SECONDS(3));
|
rv = k_mutex_lock(&mutex3, K_SECONDS(3));
|
||||||
if (rv != -EAGAIN) {
|
if (rv != -EAGAIN) {
|
||||||
tcRC = TC_FAIL;
|
tc_rc = TC_FAIL;
|
||||||
TC_ERROR("Failed to timeout on mutex 0x%x\n",
|
TC_ERROR("Failed to timeout on mutex 0x%x\n",
|
||||||
(u32_t)&Mutex3);
|
(u32_t)&mutex3);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,85 +150,85 @@ void Task07(void)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Task08 -
|
* task08 -
|
||||||
*
|
*
|
||||||
* @return N/A
|
* @return N/A
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void Task08(void)
|
void task08(void)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
k_sleep(K_MSEC(1500));
|
k_sleep(K_MSEC(1500));
|
||||||
|
|
||||||
/* Wait and boost owner priority to 8 */
|
/* Wait and boost owner priority to 8 */
|
||||||
rv = k_mutex_lock(&Mutex2, K_FOREVER);
|
rv = k_mutex_lock(&mutex2, K_FOREVER);
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
tcRC = TC_FAIL;
|
tc_rc = TC_FAIL;
|
||||||
TC_ERROR("Failed to take mutex 0x%x\n", (u32_t)&Mutex2);
|
TC_ERROR("Failed to take mutex 0x%x\n", (u32_t)&mutex2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
k_mutex_unlock(&Mutex2);
|
k_mutex_unlock(&mutex2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Task09 -
|
* task09 -
|
||||||
*
|
*
|
||||||
* @return N/A
|
* @return N/A
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void Task09(void)
|
void task09(void)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
k_sleep(K_MSEC(500)); /* Allow lower priority task to run */
|
k_sleep(K_MSEC(500)); /* Allow lower priority task to run */
|
||||||
|
|
||||||
rv = k_mutex_lock(&Mutex1, K_NO_WAIT); /*<Mutex1> is already locked. */
|
rv = k_mutex_lock(&mutex1, K_NO_WAIT); /*<Mutex1> is already locked. */
|
||||||
if (rv != -EBUSY) { /* This attempt to lock the mutex */
|
if (rv != -EBUSY) { /* This attempt to lock the mutex */
|
||||||
/* should not succeed. */
|
/* should not succeed. */
|
||||||
tcRC = TC_FAIL;
|
tc_rc = TC_FAIL;
|
||||||
TC_ERROR("Failed to NOT take locked mutex 0x%x\n",
|
TC_ERROR("Failed to NOT take locked mutex 0x%x\n",
|
||||||
(u32_t)&Mutex1);
|
(u32_t)&mutex1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait and boost owner priority to 9 */
|
/* Wait and boost owner priority to 9 */
|
||||||
rv = k_mutex_lock(&Mutex1, K_FOREVER);
|
rv = k_mutex_lock(&mutex1, K_FOREVER);
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
tcRC = TC_FAIL;
|
tc_rc = TC_FAIL;
|
||||||
TC_ERROR("Failed to take mutex 0x%x\n", (u32_t)&Mutex1);
|
TC_ERROR("Failed to take mutex 0x%x\n", (u32_t)&mutex1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
k_mutex_unlock(&Mutex1);
|
k_mutex_unlock(&mutex1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Task11 -
|
* task11 -
|
||||||
*
|
*
|
||||||
* @return N/A
|
* @return N/A
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void Task11(void)
|
void task11(void)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
k_sleep(K_MSEC(3500));
|
k_sleep(K_MSEC(3500));
|
||||||
rv = k_mutex_lock(&Mutex3, K_FOREVER);
|
rv = k_mutex_lock(&mutex3, K_FOREVER);
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
tcRC = TC_FAIL;
|
tc_rc = TC_FAIL;
|
||||||
TC_ERROR("Failed to take mutex 0x%x\n", (u32_t)&Mutex2);
|
TC_ERROR("Failed to take mutex 0x%x\n", (u32_t)&mutex2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
k_mutex_unlock(&Mutex3);
|
k_mutex_unlock(&mutex3);
|
||||||
}
|
}
|
||||||
|
|
||||||
K_THREAD_STACK_DEFINE(task12_stack_area, STACKSIZE);
|
K_THREAD_STACK_DEFINE(task12_stack_area, STACKSIZE);
|
||||||
struct k_thread task12_thread_data;
|
struct k_thread task12_thread_data;
|
||||||
extern void Task12(void);
|
extern void task12(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -240,14 +240,14 @@ extern void Task12(void);
|
||||||
* @return N/A
|
* @return N/A
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void RegressionTask(void)
|
void regression_task(void)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
int i;
|
int i;
|
||||||
struct k_mutex *mutexes[4] = { &Mutex1, &Mutex2, &Mutex3, &Mutex4 };
|
struct k_mutex *mutexes[4] = { &mutex1, &mutex2, &mutex3, &mutex4 };
|
||||||
struct k_mutex *giveMutex[3] = { &Mutex3, &Mutex2, &Mutex1 };
|
struct k_mutex *givemutex[3] = { &mutex3, &mutex2, &mutex1 };
|
||||||
int priority[4] = { 9, 8, 7, 5 };
|
int priority[4] = { 9, 8, 7, 5 };
|
||||||
int dropPri[3] = { 8, 8, 9 };
|
int droppri[3] = { 8, 8, 9 };
|
||||||
|
|
||||||
TC_START("Test kernel Mutex API");
|
TC_START("Test kernel Mutex API");
|
||||||
|
|
||||||
|
@ -265,8 +265,8 @@ void RegressionTask(void)
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
TC_ERROR("Failed to lock mutex 0x%x\n",
|
TC_ERROR("Failed to lock mutex 0x%x\n",
|
||||||
(u32_t)mutexes[i]);
|
(u32_t)mutexes[i]);
|
||||||
tcRC = TC_FAIL;
|
tc_rc = TC_FAIL;
|
||||||
goto errorReturn;
|
goto error_return;
|
||||||
}
|
}
|
||||||
k_sleep(K_SECONDS(1));
|
k_sleep(K_SECONDS(1));
|
||||||
|
|
||||||
|
@ -274,12 +274,12 @@ void RegressionTask(void)
|
||||||
if (rv != priority[i]) {
|
if (rv != priority[i]) {
|
||||||
TC_ERROR("Expected priority %d, not %d\n",
|
TC_ERROR("Expected priority %d, not %d\n",
|
||||||
priority[i], rv);
|
priority[i], rv);
|
||||||
tcRC = TC_FAIL;
|
tc_rc = TC_FAIL;
|
||||||
goto errorReturn;
|
goto error_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tcRC != TC_PASS) { /* Catch any errors from other tasks */
|
if (tc_rc != TC_PASS) { /* Catch any errors from other tasks */
|
||||||
goto errorReturn;
|
goto error_return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,49 +297,49 @@ void RegressionTask(void)
|
||||||
TC_ERROR("%s timed out and out priority should drop.\n",
|
TC_ERROR("%s timed out and out priority should drop.\n",
|
||||||
"Task05");
|
"Task05");
|
||||||
TC_ERROR("Expected priority %d, not %d\n", 6, rv);
|
TC_ERROR("Expected priority %d, not %d\n", 6, rv);
|
||||||
tcRC = TC_FAIL;
|
tc_rc = TC_FAIL;
|
||||||
goto errorReturn;
|
goto error_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
k_mutex_unlock(&Mutex4);
|
k_mutex_unlock(&mutex4);
|
||||||
rv = k_thread_priority_get(k_current_get());
|
rv = k_thread_priority_get(k_current_get());
|
||||||
if (rv != 7) {
|
if (rv != 7) {
|
||||||
TC_ERROR("Gave %s and priority should drop.\n", "Mutex4");
|
TC_ERROR("Gave %s and priority should drop.\n", "Mutex4");
|
||||||
TC_ERROR("Expected priority %d, not %d\n", 7, rv);
|
TC_ERROR("Expected priority %d, not %d\n", 7, rv);
|
||||||
tcRC = TC_FAIL;
|
tc_rc = TC_FAIL;
|
||||||
goto errorReturn;
|
goto error_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
k_sleep(K_SECONDS(1)); /* Task07 should time out */
|
k_sleep(K_SECONDS(1)); /* task07 should time out */
|
||||||
|
|
||||||
/* ~ 6 seconds have passed */
|
/* ~ 6 seconds have passed */
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
rv = k_thread_priority_get(k_current_get());
|
rv = k_thread_priority_get(k_current_get());
|
||||||
if (rv != dropPri[i]) {
|
if (rv != droppri[i]) {
|
||||||
TC_ERROR("Expected priority %d, not %d\n",
|
TC_ERROR("Expected priority %d, not %d\n",
|
||||||
dropPri[i], rv);
|
droppri[i], rv);
|
||||||
tcRC = TC_FAIL;
|
tc_rc = TC_FAIL;
|
||||||
goto errorReturn;
|
goto error_return;
|
||||||
}
|
}
|
||||||
k_mutex_unlock(giveMutex[i]);
|
k_mutex_unlock(givemutex[i]);
|
||||||
|
|
||||||
if (tcRC != TC_PASS) {
|
if (tc_rc != TC_PASS) {
|
||||||
goto errorReturn;
|
goto error_return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = k_thread_priority_get(k_current_get());
|
rv = k_thread_priority_get(k_current_get());
|
||||||
if (rv != 10) {
|
if (rv != 10) {
|
||||||
TC_ERROR("Expected priority %d, not %d\n", 10, rv);
|
TC_ERROR("Expected priority %d, not %d\n", 10, rv);
|
||||||
tcRC = TC_FAIL;
|
tc_rc = TC_FAIL;
|
||||||
goto errorReturn;
|
goto error_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
k_sleep(K_SECONDS(1)); /* Give Task11 time to run */
|
k_sleep(K_SECONDS(1)); /* Give task11 time to run */
|
||||||
|
|
||||||
if (tcRC != TC_PASS) {
|
if (tc_rc != TC_PASS) {
|
||||||
goto errorReturn;
|
goto error_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* test recursive locking using a private mutex */
|
/* test recursive locking using a private mutex */
|
||||||
|
@ -349,20 +349,20 @@ void RegressionTask(void)
|
||||||
rv = k_mutex_lock(&private_mutex, K_NO_WAIT);
|
rv = k_mutex_lock(&private_mutex, K_NO_WAIT);
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
TC_ERROR("Failed to lock private mutex\n");
|
TC_ERROR("Failed to lock private mutex\n");
|
||||||
tcRC = TC_FAIL;
|
tc_rc = TC_FAIL;
|
||||||
goto errorReturn;
|
goto error_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = k_mutex_lock(&private_mutex, K_NO_WAIT);
|
rv = k_mutex_lock(&private_mutex, K_NO_WAIT);
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
TC_ERROR("Failed to recursively lock private mutex\n");
|
TC_ERROR("Failed to recursively lock private mutex\n");
|
||||||
tcRC = TC_FAIL;
|
tc_rc = TC_FAIL;
|
||||||
goto errorReturn;
|
goto error_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Start thread */
|
/* Start thread */
|
||||||
k_thread_create(&task12_thread_data, task12_stack_area, STACKSIZE,
|
k_thread_create(&task12_thread_data, task12_stack_area, STACKSIZE,
|
||||||
(k_thread_entry_t)Task12, NULL, NULL, NULL,
|
(k_thread_entry_t)task12, NULL, NULL, NULL,
|
||||||
K_PRIO_PREEMPT(12), 0, K_NO_WAIT);
|
K_PRIO_PREEMPT(12), 0, K_NO_WAIT);
|
||||||
k_sleep(1); /* Give Task12 a chance to block on the mutex */
|
k_sleep(1); /* Give Task12 a chance to block on the mutex */
|
||||||
|
|
||||||
|
@ -372,44 +372,44 @@ void RegressionTask(void)
|
||||||
rv = k_mutex_lock(&private_mutex, K_NO_WAIT);
|
rv = k_mutex_lock(&private_mutex, K_NO_WAIT);
|
||||||
if (rv != -EBUSY) {
|
if (rv != -EBUSY) {
|
||||||
TC_ERROR("Unexpectedly got lock on private mutex\n");
|
TC_ERROR("Unexpectedly got lock on private mutex\n");
|
||||||
tcRC = TC_FAIL;
|
tc_rc = TC_FAIL;
|
||||||
goto errorReturn;
|
goto error_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = k_mutex_lock(&private_mutex, K_SECONDS(1));
|
rv = k_mutex_lock(&private_mutex, K_SECONDS(1));
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
TC_ERROR("Failed to re-obtain lock on private mutex\n");
|
TC_ERROR("Failed to re-obtain lock on private mutex\n");
|
||||||
tcRC = TC_FAIL;
|
tc_rc = TC_FAIL;
|
||||||
goto errorReturn;
|
goto error_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
k_mutex_unlock(&private_mutex);
|
k_mutex_unlock(&private_mutex);
|
||||||
|
|
||||||
TC_PRINT("Recursive locking tests successful\n");
|
TC_PRINT("Recursive locking tests successful\n");
|
||||||
|
|
||||||
errorReturn:
|
error_return:
|
||||||
TC_END_RESULT(tcRC);
|
TC_END_RESULT(tc_rc);
|
||||||
TC_END_REPORT(tcRC);
|
TC_END_REPORT(tc_rc);
|
||||||
} /* RegressionTask */
|
} /* RegressionTask */
|
||||||
|
|
||||||
|
|
||||||
K_THREAD_DEFINE(TASK05, STACKSIZE, Task05, NULL, NULL, NULL,
|
K_THREAD_DEFINE(TASK05, STACKSIZE, task05, NULL, NULL, NULL,
|
||||||
5, 0, K_NO_WAIT);
|
5, 0, K_NO_WAIT);
|
||||||
|
|
||||||
K_THREAD_DEFINE(TASK06, STACKSIZE, Task06, NULL, NULL, NULL,
|
K_THREAD_DEFINE(TASK06, STACKSIZE, task06, NULL, NULL, NULL,
|
||||||
6, 0, K_NO_WAIT);
|
6, 0, K_NO_WAIT);
|
||||||
|
|
||||||
K_THREAD_DEFINE(TASK07, STACKSIZE, Task07, NULL, NULL, NULL,
|
K_THREAD_DEFINE(TASK07, STACKSIZE, task07, NULL, NULL, NULL,
|
||||||
7, 0, K_NO_WAIT);
|
7, 0, K_NO_WAIT);
|
||||||
|
|
||||||
K_THREAD_DEFINE(TASK08, STACKSIZE, Task08, NULL, NULL, NULL,
|
K_THREAD_DEFINE(TASK08, STACKSIZE, task08, NULL, NULL, NULL,
|
||||||
8, 0, K_NO_WAIT);
|
8, 0, K_NO_WAIT);
|
||||||
|
|
||||||
K_THREAD_DEFINE(TASK09, STACKSIZE, Task09, NULL, NULL, NULL,
|
K_THREAD_DEFINE(TASK09, STACKSIZE, task09, NULL, NULL, NULL,
|
||||||
9, 0, K_NO_WAIT);
|
9, 0, K_NO_WAIT);
|
||||||
|
|
||||||
K_THREAD_DEFINE(TASK11, STACKSIZE, Task11, NULL, NULL, NULL,
|
K_THREAD_DEFINE(TASK11, STACKSIZE, task11, NULL, NULL, NULL,
|
||||||
11, 0, K_NO_WAIT);
|
11, 0, K_NO_WAIT);
|
||||||
|
|
||||||
K_THREAD_DEFINE(REGRESSTASK, STACKSIZE, RegressionTask, NULL, NULL, NULL,
|
K_THREAD_DEFINE(REGRESSTASK, STACKSIZE, regression_task, NULL, NULL, NULL,
|
||||||
10, 0, K_NO_WAIT);
|
10, 0, K_NO_WAIT);
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include <zephyr.h>
|
#include <zephyr.h>
|
||||||
|
|
||||||
|
|
||||||
static int tcRC = TC_PASS; /* test case return code */
|
static int tc_rc = TC_PASS; /* test case return code */
|
||||||
|
|
||||||
extern struct k_mutex private_mutex;
|
extern struct k_mutex private_mutex;
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ extern struct k_mutex private_mutex;
|
||||||
* @return N/A
|
* @return N/A
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void Task12(void)
|
void task12(void)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ void Task12(void)
|
||||||
|
|
||||||
rv = k_mutex_lock(&private_mutex, K_FOREVER);
|
rv = k_mutex_lock(&private_mutex, K_FOREVER);
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
tcRC = TC_FAIL;
|
tc_rc = TC_FAIL;
|
||||||
TC_ERROR("Failed to obtain private mutex\n");
|
TC_ERROR("Failed to obtain private mutex\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,12 +30,12 @@ static K_THREAD_STACK_DEFINE(tstack, STACK_SIZE);
|
||||||
static struct k_thread tdata;
|
static struct k_thread tdata;
|
||||||
|
|
||||||
/*entry of contexts*/
|
/*entry of contexts*/
|
||||||
static void tIsr_entry(void *p)
|
static void tisr_entry(void *p)
|
||||||
{
|
{
|
||||||
k_sem_give((struct k_sem *)p);
|
k_sem_give((struct k_sem *)p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tThread_entry(void *p1, void *p2, void *p3)
|
static void thread_entry(void *p1, void *p2, void *p3)
|
||||||
{
|
{
|
||||||
k_sem_give((struct k_sem *)p1);
|
k_sem_give((struct k_sem *)p1);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ static void tsema_thread_thread(struct k_sem *psem)
|
||||||
{
|
{
|
||||||
/**TESTPOINT: thread-thread sync via sema*/
|
/**TESTPOINT: thread-thread sync via sema*/
|
||||||
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
|
k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
|
||||||
tThread_entry, psem, NULL, NULL,
|
thread_entry, psem, NULL, NULL,
|
||||||
K_PRIO_PREEMPT(0), 0, 0);
|
K_PRIO_PREEMPT(0), 0, 0);
|
||||||
|
|
||||||
zassert_false(k_sem_take(psem, K_FOREVER), NULL);
|
zassert_false(k_sem_take(psem, K_FOREVER), NULL);
|
||||||
|
@ -55,7 +55,7 @@ static void tsema_thread_thread(struct k_sem *psem)
|
||||||
static void tsema_thread_isr(struct k_sem *psem)
|
static void tsema_thread_isr(struct k_sem *psem)
|
||||||
{
|
{
|
||||||
/**TESTPOINT: thread-isr sync via sema*/
|
/**TESTPOINT: thread-isr sync via sema*/
|
||||||
irq_offload(tIsr_entry, psem);
|
irq_offload(tisr_entry, psem);
|
||||||
zassert_false(k_sem_take(psem, K_FOREVER), NULL);
|
zassert_false(k_sem_take(psem, K_FOREVER), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
DESCRIPTION
|
* DESCRIPTION
|
||||||
This module contains the code for testing sprintf() functionality.
|
* This module contains the code for testing sprintf() functionality.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <tc_util.h>
|
#include <tc_util.h>
|
||||||
|
@ -32,22 +32,28 @@ This module contains the code for testing sprintf() functionality.
|
||||||
* The underlying sprintf() architecture will truncate it.
|
* The underlying sprintf() architecture will truncate it.
|
||||||
*/
|
*/
|
||||||
#define REALLY_LONG_STRING \
|
#define REALLY_LONG_STRING \
|
||||||
"11111111111111111111111111111111111111111111111111111111111111111" \
|
"1111111111111111111111111111111111" \
|
||||||
"22222222222222222222222222222222222222222222222222222222222222222" \
|
"1111111111111111111111111111111" \
|
||||||
"33333333333333333333333333333333333333333333333333333333333333333" \
|
"22222222222222222222222222222222" \
|
||||||
"44444444444444444444444444444444444444444444444444444444444444444" \
|
"222222222222222222222222222222222" \
|
||||||
"55555555555555555555555555555555555555555555555555555555555555555" \
|
"333333333333333333333333333333333" \
|
||||||
"66666666666666666666666666666666666666666666666666666666666666666"
|
"33333333333333333333333333333333" \
|
||||||
|
"44444444444444444444444444444444" \
|
||||||
|
"444444444444444444444444444444444" \
|
||||||
|
"555555555555555555555555555555555" \
|
||||||
|
"55555555555555555555555555555555" \
|
||||||
|
"66666666666666666666666666666666" \
|
||||||
|
"666666666666666666666666666666666"
|
||||||
|
|
||||||
#define PRINTF_MAX_STRING_LENGTH 200
|
#define PRINTF_MAX_STRING_LENGTH 200
|
||||||
|
|
||||||
typedef union {
|
union raw_double_u {
|
||||||
double d;
|
double d;
|
||||||
struct {
|
struct {
|
||||||
u32_t u1; /* This part contains the exponent */
|
u32_t u1; /* This part contains the exponent */
|
||||||
u32_t u2; /* This part contains the fraction */
|
u32_t u2; /* This part contains the fraction */
|
||||||
};
|
};
|
||||||
} raw_double_u;
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_FLOAT
|
#ifdef CONFIG_FLOAT
|
||||||
/**
|
/**
|
||||||
|
@ -57,10 +63,10 @@ typedef union {
|
||||||
* @return TC_PASS on success, TC_FAIL otherwise
|
* @return TC_PASS on success, TC_FAIL otherwise
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int sprintfDoubleTest(void)
|
int sprintf_double_test(void)
|
||||||
{
|
{
|
||||||
char buffer[100];
|
char buffer[100];
|
||||||
raw_double_u var;
|
union raw_double_u var;
|
||||||
int status = TC_PASS;
|
int status = TC_PASS;
|
||||||
|
|
||||||
var.u1 = 0x00000000;
|
var.u1 = 0x00000000;
|
||||||
|
@ -108,25 +114,29 @@ int sprintfDoubleTest(void)
|
||||||
|
|
||||||
sprintf(buffer, "%.*f", 11, var.d);
|
sprintf(buffer, "%.*f", 11, var.d);
|
||||||
if (strcmp(buffer, "1.00000000000") != 0) {
|
if (strcmp(buffer, "1.00000000000") != 0) {
|
||||||
TC_ERROR("sprintf(1.00000000000) - incorrect output '%s'\n", buffer);
|
TC_ERROR("sprintf(1.00000000000) - incorrect "
|
||||||
|
"output '%s'\n", buffer);
|
||||||
status = TC_FAIL;
|
status = TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(buffer, "%12f", var.d);
|
sprintf(buffer, "%12f", var.d);
|
||||||
if (strcmp(buffer, " 1.000000") != 0) {
|
if (strcmp(buffer, " 1.000000") != 0) {
|
||||||
TC_ERROR("sprintf( 1.000000) - incorrect output '%s'\n", buffer);
|
TC_ERROR("sprintf( 1.000000) - incorrect "
|
||||||
|
"output '%s'\n", buffer);
|
||||||
status = TC_FAIL;
|
status = TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(buffer, "%-12f", var.d);
|
sprintf(buffer, "%-12f", var.d);
|
||||||
if (strcmp(buffer, "1.000000 ") != 0) {
|
if (strcmp(buffer, "1.000000 ") != 0) {
|
||||||
TC_ERROR("sprintf(1.000000 ) - incorrect output '%s'\n", buffer);
|
TC_ERROR("sprintf(1.000000 ) - incorrect "
|
||||||
|
"output '%s'\n", buffer);
|
||||||
status = TC_FAIL;
|
status = TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(buffer, "%012f", var.d);
|
sprintf(buffer, "%012f", var.d);
|
||||||
if (strcmp(buffer, "00001.000000") != 0) {
|
if (strcmp(buffer, "00001.000000") != 0) {
|
||||||
TC_ERROR("sprintf(00001.000000) - incorrect output '%s'\n", buffer);
|
TC_ERROR("sprintf(00001.000000) - incorrect "
|
||||||
|
"output '%s'\n", buffer);
|
||||||
status = TC_FAIL;
|
status = TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,13 +158,15 @@ int sprintfDoubleTest(void)
|
||||||
var.d = 1234.0;
|
var.d = 1234.0;
|
||||||
sprintf(buffer, "%e", var.d);
|
sprintf(buffer, "%e", var.d);
|
||||||
if (strcmp(buffer, "1.234000e+003") != 0) {
|
if (strcmp(buffer, "1.234000e+003") != 0) {
|
||||||
TC_ERROR("sprintf(1.234000e+003) - incorrect output '%s'\n", buffer);
|
TC_ERROR("sprintf(1.234000e+003) - incorrect "
|
||||||
|
"output '%s'\n", buffer);
|
||||||
status = TC_FAIL;
|
status = TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(buffer, "%E", var.d);
|
sprintf(buffer, "%E", var.d);
|
||||||
if (strcmp(buffer, "1.234000E+003") != 0) {
|
if (strcmp(buffer, "1.234000E+003") != 0) {
|
||||||
TC_ERROR("sprintf(1.234000E+003) - incorrect output '%s'\n", buffer);
|
TC_ERROR("sprintf(1.234000E+003) - incorrect "
|
||||||
|
"output '%s'\n", buffer);
|
||||||
status = TC_FAIL;
|
status = TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,13 +174,15 @@ int sprintfDoubleTest(void)
|
||||||
var.d = 0.1234;
|
var.d = 0.1234;
|
||||||
sprintf(buffer, "%e", var.d);
|
sprintf(buffer, "%e", var.d);
|
||||||
if (strcmp(buffer, "1.234000e-001") != 0) {
|
if (strcmp(buffer, "1.234000e-001") != 0) {
|
||||||
TC_ERROR("sprintf(1.234000e-001) - incorrect output '%s'\n", buffer);
|
TC_ERROR("sprintf(1.234000e-001) - incorrect "
|
||||||
|
"output '%s'\n", buffer);
|
||||||
status = TC_FAIL;
|
status = TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(buffer, "%E", var.d);
|
sprintf(buffer, "%E", var.d);
|
||||||
if (strcmp(buffer, "1.234000E-001") != 0) {
|
if (strcmp(buffer, "1.234000E-001") != 0) {
|
||||||
TC_ERROR("sprintf(1.234000E-001) - incorrect output '%s'\n", buffer);
|
TC_ERROR("sprintf(1.234000E-001) - incorrect "
|
||||||
|
"output '%s'\n", buffer);
|
||||||
status = TC_FAIL;
|
status = TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,13 +190,15 @@ int sprintfDoubleTest(void)
|
||||||
var.d = 1234000000.0;
|
var.d = 1234000000.0;
|
||||||
sprintf(buffer, "%g", var.d);
|
sprintf(buffer, "%g", var.d);
|
||||||
if (strcmp(buffer, "1.234e+009") != 0) {
|
if (strcmp(buffer, "1.234e+009") != 0) {
|
||||||
TC_ERROR("sprintf(1.234e+009) - incorrect output '%s'\n", buffer);
|
TC_ERROR("sprintf(1.234e+009) - incorrect "
|
||||||
|
"output '%s'\n", buffer);
|
||||||
status = TC_FAIL;
|
status = TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(buffer, "%G", var.d);
|
sprintf(buffer, "%G", var.d);
|
||||||
if (strcmp(buffer, "1.234E+009") != 0) {
|
if (strcmp(buffer, "1.234E+009") != 0) {
|
||||||
TC_ERROR("sprintf(1.234E+009) - incorrect output '%s'\n", buffer);
|
TC_ERROR("sprintf(1.234E+009) - incorrect "
|
||||||
|
"output '%s'\n", buffer);
|
||||||
status = TC_FAIL;
|
status = TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +236,7 @@ int tvsnprintf(char *s, size_t len, const char *format, ...)
|
||||||
* @return TC_PASS on success, TC_FAIL otherwise
|
* @return TC_PASS on success, TC_FAIL otherwise
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int vsnprintfTest(void)
|
int vsnprintf_test(void)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
int status = TC_PASS;
|
int status = TC_PASS;
|
||||||
|
@ -286,7 +302,7 @@ int tvsprintf(char *s, const char *format, ...)
|
||||||
* @return TC_PASS on success, TC_FAIL otherwise
|
* @return TC_PASS on success, TC_FAIL otherwise
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int vsprintfTest(void)
|
int vsprintf_test(void)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
int status = TC_PASS;
|
int status = TC_PASS;
|
||||||
|
@ -320,7 +336,7 @@ int vsprintfTest(void)
|
||||||
* @return TC_PASS on success, TC_FAIL otherwise
|
* @return TC_PASS on success, TC_FAIL otherwise
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int snprintfTest(void)
|
int snprintf_test(void)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
int status = TC_PASS;
|
int status = TC_PASS;
|
||||||
|
@ -366,7 +382,7 @@ int snprintfTest(void)
|
||||||
* @return TC_PASS on success, TC_FAIL otherwise
|
* @return TC_PASS on success, TC_FAIL otherwise
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int sprintfMiscTest(void)
|
int sprintf_misc_test(void)
|
||||||
{
|
{
|
||||||
int status = TC_PASS;
|
int status = TC_PASS;
|
||||||
int count;
|
int count;
|
||||||
|
@ -442,7 +458,7 @@ int sprintfMiscTest(void)
|
||||||
* @return TC_PASS on success, TC_FAIL otherwise
|
* @return TC_PASS on success, TC_FAIL otherwise
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int sprintfIntegerTest(void)
|
int sprintf_integer_test(void)
|
||||||
{
|
{
|
||||||
int status = TC_PASS;
|
int status = TC_PASS;
|
||||||
int len;
|
int len;
|
||||||
|
@ -453,12 +469,14 @@ int sprintfIntegerTest(void)
|
||||||
/* Note: prints hex numbers in 8 characters */
|
/* Note: prints hex numbers in 8 characters */
|
||||||
len = sprintf(buffer, "%x", 0x11);
|
len = sprintf(buffer, "%x", 0x11);
|
||||||
if (len != 2) {
|
if (len != 2) {
|
||||||
TC_ERROR("sprintf(%%x). Expected 2 bytes written, not %d\n", len);
|
TC_ERROR("sprintf(%%x). "
|
||||||
|
"Expected 2 bytes written, not %d\n", len);
|
||||||
status = TC_FAIL;
|
status = TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(buffer, "11") != 0) {
|
if (strcmp(buffer, "11") != 0) {
|
||||||
TC_ERROR("sprintf(%%x). Expected '%s', got '%s'\n", "11", buffer);
|
TC_ERROR("sprintf(%%x). "
|
||||||
|
"Expected '%s', got '%s'\n", "11", buffer);
|
||||||
status = TC_FAIL;
|
status = TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -595,7 +613,7 @@ int sprintfIntegerTest(void)
|
||||||
* @return TC_PASS on success, TC_FAIL otherwise
|
* @return TC_PASS on success, TC_FAIL otherwise
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int sprintfStringTest(void)
|
int sprintf_stringtest(void)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
int status = TC_PASS;
|
int status = TC_PASS;
|
||||||
|
@ -615,20 +633,24 @@ int sprintfStringTest(void)
|
||||||
|
|
||||||
sprintf(buffer, "%s", "short string");
|
sprintf(buffer, "%s", "short string");
|
||||||
if (strcmp(buffer, "short string") != 0) {
|
if (strcmp(buffer, "short string") != 0) {
|
||||||
TC_ERROR("sprintf(%%s). Expected 'short string', got '%s'\n", buffer);
|
TC_ERROR("sprintf(%%s). "
|
||||||
|
"Expected 'short string', got '%s'\n", buffer);
|
||||||
status = TC_FAIL;
|
status = TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = sprintf(buffer, "%s", REALLY_LONG_STRING);
|
len = sprintf(buffer, "%s", REALLY_LONG_STRING);
|
||||||
#ifndef CONFIG_NEWLIB_LIBC
|
#ifndef CONFIG_NEWLIB_LIBC
|
||||||
if (len != PRINTF_MAX_STRING_LENGTH) {
|
if (len != PRINTF_MAX_STRING_LENGTH) {
|
||||||
TC_ERROR("Internals changed. Max string length no longer %d got %d\n",
|
TC_ERROR("Internals changed. "
|
||||||
|
"Max string length no longer %d got %d\n",
|
||||||
PRINTF_MAX_STRING_LENGTH, len);
|
PRINTF_MAX_STRING_LENGTH, len);
|
||||||
status = TC_FAIL;
|
status = TC_FAIL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (strncmp(buffer, REALLY_LONG_STRING, PRINTF_MAX_STRING_LENGTH) != 0) {
|
if (strncmp(buffer, REALLY_LONG_STRING,
|
||||||
TC_ERROR("First %d characters of REALLY_LONG_STRING not printed!\n",
|
PRINTF_MAX_STRING_LENGTH) != 0) {
|
||||||
|
TC_ERROR("First %d characters of REALLY_LONG_STRING "
|
||||||
|
"not printed!\n",
|
||||||
PRINTF_MAX_STRING_LENGTH);
|
PRINTF_MAX_STRING_LENGTH);
|
||||||
status = TC_FAIL;
|
status = TC_FAIL;
|
||||||
}
|
}
|
||||||
|
@ -652,38 +674,38 @@ void main(void)
|
||||||
PRINT_LINE;
|
PRINT_LINE;
|
||||||
|
|
||||||
TC_PRINT("Testing sprintf() with integers ....\n");
|
TC_PRINT("Testing sprintf() with integers ....\n");
|
||||||
if (sprintfIntegerTest() != TC_PASS) {
|
if (sprintf_integer_test() != TC_PASS) {
|
||||||
status = TC_FAIL;
|
status = TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
TC_PRINT("Testing snprintf() ....\n");
|
TC_PRINT("Testing snprintf() ....\n");
|
||||||
if (snprintfTest() != TC_PASS) {
|
if (snprintf_test() != TC_PASS) {
|
||||||
status = TC_FAIL;
|
status = TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
TC_PRINT("Testing vsprintf() ....\n");
|
TC_PRINT("Testing vsprintf() ....\n");
|
||||||
if (vsprintfTest() != TC_PASS) {
|
if (vsprintf_test() != TC_PASS) {
|
||||||
status = TC_FAIL;
|
status = TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
TC_PRINT("Testing vsnprintf() ....\n");
|
TC_PRINT("Testing vsnprintf() ....\n");
|
||||||
if (vsnprintfTest() != TC_PASS) {
|
if (vsnprintf_test() != TC_PASS) {
|
||||||
status = TC_FAIL;
|
status = TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
TC_PRINT("Testing sprintf() with strings ....\n");
|
TC_PRINT("Testing sprintf() with strings ....\n");
|
||||||
if (sprintfStringTest() != TC_PASS) {
|
if (sprintf_stringtest() != TC_PASS) {
|
||||||
status = TC_FAIL;
|
status = TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
TC_PRINT("Testing sprintf() with misc options ....\n");
|
TC_PRINT("Testing sprintf() with misc options ....\n");
|
||||||
if (sprintfMiscTest() != TC_PASS) {
|
if (sprintf_misc_test() != TC_PASS) {
|
||||||
status = TC_FAIL;
|
status = TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_FLOAT
|
#ifdef CONFIG_FLOAT
|
||||||
TC_PRINT("Testing sprintf() with doubles ....\n");
|
TC_PRINT("Testing sprintf() with doubles ....\n");
|
||||||
if (sprintfDoubleTest() != TC_PASS) {
|
if (sprintf_double_test() != TC_PASS) {
|
||||||
status = TC_FAIL;
|
status = TC_FAIL;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_FLOAT */
|
#endif /* CONFIG_FLOAT */
|
||||||
|
|
|
@ -23,21 +23,21 @@
|
||||||
|
|
||||||
#define _TIMESTAMP_NUM 0 /* set to timer # for use by timestamp (0-3) */
|
#define _TIMESTAMP_NUM 0 /* set to timer # for use by timestamp (0-3) */
|
||||||
|
|
||||||
#define _CLKGATECTRL *((volatile u32_t *)0x400FE104)
|
#define _CLKGATECTRL (*((volatile u32_t *)0x400FE104))
|
||||||
#define _CLKGATECTRL_TIMESTAMP_EN (1 << (16 + _TIMESTAMP_NUM))
|
#define _CLKGATECTRL_TIMESTAMP_EN (1 << (16 + _TIMESTAMP_NUM))
|
||||||
|
|
||||||
#define _TIMESTAMP_BASE 0x40030000
|
#define _TIMESTAMP_BASE 0x40030000
|
||||||
#define _TIMESTAMP_OFFSET (0x1000 * _TIMESTAMP_NUM)
|
#define _TIMESTAMP_OFFSET (0x1000 * _TIMESTAMP_NUM)
|
||||||
#define _TIMESTAMP_ADDR (_TIMESTAMP_BASE + _TIMESTAMP_OFFSET)
|
#define _TIMESTAMP_ADDR (_TIMESTAMP_BASE + _TIMESTAMP_OFFSET)
|
||||||
|
|
||||||
#define _TIMESTAMP_CFG *((volatile u32_t *)(_TIMESTAMP_ADDR + 0))
|
#define _TIMESTAMP_CFG (*((volatile u32_t *)(_TIMESTAMP_ADDR + 0)))
|
||||||
#define _TIMESTAMP_CTRL *((volatile u32_t *)(_TIMESTAMP_ADDR + 0xC))
|
#define _TIMESTAMP_CTRL (*((volatile u32_t *)(_TIMESTAMP_ADDR + 0xC)))
|
||||||
#define _TIMESTAMP_MODE *((volatile u32_t *)(_TIMESTAMP_ADDR + 0x4))
|
#define _TIMESTAMP_MODE (*((volatile u32_t *)(_TIMESTAMP_ADDR + 0x4)))
|
||||||
#define _TIMESTAMP_LOAD *((volatile u32_t *)(_TIMESTAMP_ADDR + 0x28))
|
#define _TIMESTAMP_LOAD (*((volatile u32_t *)(_TIMESTAMP_ADDR + 0x28)))
|
||||||
#define _TIMESTAMP_IMASK *((volatile u32_t *)(_TIMESTAMP_ADDR + 0x18))
|
#define _TIMESTAMP_IMASK (*((volatile u32_t *)(_TIMESTAMP_ADDR + 0x18)))
|
||||||
#define _TIMESTAMP_ISTATUS *((volatile u32_t *)(_TIMESTAMP_ADDR + 0x1C))
|
#define _TIMESTAMP_ISTATUS (*((volatile u32_t *)(_TIMESTAMP_ADDR + 0x1C)))
|
||||||
#define _TIMESTAMP_ICLEAR *((volatile u32_t *)(_TIMESTAMP_ADDR + 0x24))
|
#define _TIMESTAMP_ICLEAR (*((volatile u32_t *)(_TIMESTAMP_ADDR + 0x24)))
|
||||||
#define _TIMESTAMP_VAL *((volatile u32_t *)(_TIMESTAMP_ADDR + 0x48))
|
#define _TIMESTAMP_VAL (*((volatile u32_t *)(_TIMESTAMP_ADDR + 0x48)))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the rollover value such that it leaves the most significant bit of
|
* Set the rollover value such that it leaves the most significant bit of
|
||||||
|
@ -57,7 +57,7 @@
|
||||||
*
|
*
|
||||||
* @return N/A
|
* @return N/A
|
||||||
*/
|
*/
|
||||||
void _TimestampOpen(void)
|
void _timestamp_open(void)
|
||||||
{
|
{
|
||||||
/* QEMU does not currently support the 32-bit timer modes of the GPTM */
|
/* QEMU does not currently support the 32-bit timer modes of the GPTM */
|
||||||
printk("WARNING! Timestamp is not supported for this target!\n");
|
printk("WARNING! Timestamp is not supported for this target!\n");
|
||||||
|
@ -71,7 +71,9 @@ void _TimestampOpen(void)
|
||||||
_TIMESTAMP_CTRL = 0x0; /* disable/reset timer */
|
_TIMESTAMP_CTRL = 0x0; /* disable/reset timer */
|
||||||
_TIMESTAMP_CFG = 0x0; /* 32-bit timer */
|
_TIMESTAMP_CFG = 0x0; /* 32-bit timer */
|
||||||
_TIMESTAMP_MODE = 0x2; /* periodic mode */
|
_TIMESTAMP_MODE = 0x2; /* periodic mode */
|
||||||
_TIMESTAMP_LOAD = _TIMESTAMP_MAX; /* maximum interval to reduce rollovers */
|
_TIMESTAMP_LOAD = _TIMESTAMP_MAX; /* maximum interval
|
||||||
|
* to reduce rollovers
|
||||||
|
*/
|
||||||
_TIMESTAMP_IMASK = 0x70F; /* mask all timer interrupts */
|
_TIMESTAMP_IMASK = 0x70F; /* mask all timer interrupts */
|
||||||
_TIMESTAMP_ICLEAR = 0x70F; /* clear all interrupt status */
|
_TIMESTAMP_ICLEAR = 0x70F; /* clear all interrupt status */
|
||||||
|
|
||||||
|
@ -86,29 +88,29 @@ void _TimestampOpen(void)
|
||||||
*
|
*
|
||||||
* @return timestamp value
|
* @return timestamp value
|
||||||
*/
|
*/
|
||||||
u32_t _TimestampRead(void)
|
u32_t _timestamp_read(void)
|
||||||
{
|
{
|
||||||
static u32_t lastTimerVal;
|
static u32_t last_timer_val;
|
||||||
static u32_t cnt;
|
static u32_t cnt;
|
||||||
u32_t timerVal = _TIMESTAMP_VAL;
|
u32_t timer_val = _TIMESTAMP_VAL;
|
||||||
|
|
||||||
/* handle rollover for every other read (end of sleep) */
|
/* handle rollover for every other read (end of sleep) */
|
||||||
|
|
||||||
if ((cnt % 2) && (timerVal > lastTimerVal)) {
|
if ((cnt % 2) && (timer_val > last_timer_val)) {
|
||||||
lastTimerVal = timerVal;
|
last_timer_val = timer_val;
|
||||||
|
|
||||||
/* convert to extended up-counter value */
|
/* convert to extended up-counter value */
|
||||||
timerVal = _TIMESTAMP_EXT + (_TIMESTAMP_MAX - timerVal);
|
timer_val = _TIMESTAMP_EXT + (_TIMESTAMP_MAX - timer_val);
|
||||||
} else {
|
} else {
|
||||||
lastTimerVal = timerVal;
|
last_timer_val = timer_val;
|
||||||
|
|
||||||
/* convert to up-counter value */
|
/* convert to up-counter value */
|
||||||
timerVal = _TIMESTAMP_MAX - timerVal;
|
timer_val = _TIMESTAMP_MAX - timer_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
cnt++;
|
cnt++;
|
||||||
|
|
||||||
return timerVal;
|
return timer_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -119,7 +121,7 @@ u32_t _TimestampRead(void)
|
||||||
*
|
*
|
||||||
* @return N/A
|
* @return N/A
|
||||||
*/
|
*/
|
||||||
void _TimestampClose(void)
|
void _timestamp_close(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* disable/reset timer */
|
/* disable/reset timer */
|
||||||
|
@ -135,25 +137,25 @@ void _TimestampClose(void)
|
||||||
|
|
||||||
#define _COUNTDOWN_TIMER false
|
#define _COUNTDOWN_TIMER false
|
||||||
|
|
||||||
#define _CLKGATECTRL *((volatile u32_t *)0x4004803C)
|
#define _CLKGATECTRL (*((volatile u32_t *)0x4004803C))
|
||||||
#define _CLKGATECTRL_TIMESTAMP_EN (1 << 29)
|
#define _CLKGATECTRL_TIMESTAMP_EN (1 << 29)
|
||||||
|
|
||||||
#define _SYSOPTCTRL2 *((volatile u32_t *)0x40048004)
|
#define _SYSOPTCTRL2 (*((volatile u32_t *)0x40048004))
|
||||||
#define _SYSOPTCTRL2_32KHZRTCCLK (1 << 4)
|
#define _SYSOPTCTRL2_32KHZRTCCLK (1 << 4)
|
||||||
|
|
||||||
#define _TIMESTAMP_ADDR (0x4003D000)
|
#define _TIMESTAMP_ADDR (0x4003D000)
|
||||||
|
|
||||||
#define _TIMESTAMP_ICLEAR *((volatile u32_t *)(_TIMESTAMP_ADDR + 0x24))
|
#define _TIMESTAMP_ICLEAR (*((volatile u32_t *)(_TIMESTAMP_ADDR + 0x24)))
|
||||||
|
|
||||||
#define _TIMESTAMP_VAL *((volatile u32_t *)(_TIMESTAMP_ADDR + 0))
|
#define _TIMESTAMP_VAL (*((volatile u32_t *)(_TIMESTAMP_ADDR + 0)))
|
||||||
#define _TIMESTAMP_PRESCALE *((volatile u32_t *)(_TIMESTAMP_ADDR + 0x4))
|
#define _TIMESTAMP_PRESCALE (*((volatile u32_t *)(_TIMESTAMP_ADDR + 0x4)))
|
||||||
#define _TIMESTAMP_COMP *((volatile u32_t *)(_TIMESTAMP_ADDR + 0xC))
|
#define _TIMESTAMP_COMP (*((volatile u32_t *)(_TIMESTAMP_ADDR + 0xC)))
|
||||||
#define _TIMESTAMP_CTRL *((volatile u32_t *)(_TIMESTAMP_ADDR + 0x10))
|
#define _TIMESTAMP_CTRL (*((volatile u32_t *)(_TIMESTAMP_ADDR + 0x10)))
|
||||||
#define _TIMESTAMP_STATUS *((volatile u32_t *)(_TIMESTAMP_ADDR + 0x14))
|
#define _TIMESTAMP_STATUS (*((volatile u32_t *)(_TIMESTAMP_ADDR + 0x14)))
|
||||||
#define _TIMESTAMP_LOCK *((volatile u32_t *)(_TIMESTAMP_ADDR + 0x18))
|
#define _TIMESTAMP_LOCK (*((volatile u32_t *)(_TIMESTAMP_ADDR + 0x18)))
|
||||||
#define _TIMESTAMP_IMASK *((volatile u32_t *)(_TIMESTAMP_ADDR + 0x1C))
|
#define _TIMESTAMP_IMASK (*((volatile u32_t *)(_TIMESTAMP_ADDR + 0x1C)))
|
||||||
#define _TIMESTAMP_RACCESS *((volatile u32_t *)(_TIMESTAMP_ADDR + 0x800))
|
#define _TIMESTAMP_RACCESS (*((volatile u32_t *)(_TIMESTAMP_ADDR + 0x800)))
|
||||||
#define _TIMESTAMP_WACCESS *((volatile u32_t *)(_TIMESTAMP_ADDR + 0x804))
|
#define _TIMESTAMP_WACCESS (*((volatile u32_t *)(_TIMESTAMP_ADDR + 0x804)))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -163,7 +165,7 @@ void _TimestampClose(void)
|
||||||
*
|
*
|
||||||
* @return N/A
|
* @return N/A
|
||||||
*/
|
*/
|
||||||
void _TimestampOpen(void)
|
void _timestamp_open(void)
|
||||||
{
|
{
|
||||||
/* enable timer access */
|
/* enable timer access */
|
||||||
_CLKGATECTRL |= _CLKGATECTRL_TIMESTAMP_EN;
|
_CLKGATECTRL |= _CLKGATECTRL_TIMESTAMP_EN;
|
||||||
|
@ -197,9 +199,9 @@ void _TimestampOpen(void)
|
||||||
*
|
*
|
||||||
* @return timestamp value
|
* @return timestamp value
|
||||||
*/
|
*/
|
||||||
u32_t _TimestampRead(void)
|
u32_t _timestamp_read(void)
|
||||||
{
|
{
|
||||||
static u32_t lastPrescale;
|
static u32_t last_prescale;
|
||||||
static u32_t cnt;
|
static u32_t cnt;
|
||||||
u32_t prescale1 = _TIMESTAMP_PRESCALE;
|
u32_t prescale1 = _TIMESTAMP_PRESCALE;
|
||||||
u32_t prescale2 = _TIMESTAMP_PRESCALE;
|
u32_t prescale2 = _TIMESTAMP_PRESCALE;
|
||||||
|
@ -211,13 +213,15 @@ u32_t _TimestampRead(void)
|
||||||
prescale2 = _TIMESTAMP_PRESCALE;
|
prescale2 = _TIMESTAMP_PRESCALE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* handle prescale rollover @ 0x8000 for every other read (end of sleep) */
|
/* handle prescale rollover @ 0x8000
|
||||||
|
* for every other read (end of sleep)
|
||||||
|
*/
|
||||||
|
|
||||||
if ((cnt % 2) && (prescale1 < lastPrescale)) {
|
if ((cnt % 2) && (prescale1 < last_prescale)) {
|
||||||
prescale1 += 0x8000;
|
prescale1 += 0x8000;
|
||||||
}
|
}
|
||||||
|
|
||||||
lastPrescale = prescale2;
|
last_prescale = prescale2;
|
||||||
cnt++;
|
cnt++;
|
||||||
|
|
||||||
return prescale1;
|
return prescale1;
|
||||||
|
@ -231,7 +235,7 @@ u32_t _TimestampRead(void)
|
||||||
*
|
*
|
||||||
* @return N/A
|
* @return N/A
|
||||||
*/
|
*/
|
||||||
void _TimestampClose(void)
|
void _timestamp_close(void)
|
||||||
{
|
{
|
||||||
_TIMESTAMP_STATUS = 0x0; /* disable counter */
|
_TIMESTAMP_STATUS = 0x0; /* disable counter */
|
||||||
_TIMESTAMP_CTRL = 0x0; /* disable oscillator */
|
_TIMESTAMP_CTRL = 0x0; /* disable oscillator */
|
||||||
|
@ -255,7 +259,7 @@ void _TimestampClose(void)
|
||||||
*
|
*
|
||||||
* @return N/A
|
* @return N/A
|
||||||
*/
|
*/
|
||||||
void _TimestampOpen(void)
|
void _timestamp_open(void)
|
||||||
{
|
{
|
||||||
/* enable RTT clock from PMC */
|
/* enable RTT clock from PMC */
|
||||||
soc_pmc_peripheral_enable(ID_RTT);
|
soc_pmc_peripheral_enable(ID_RTT);
|
||||||
|
@ -272,7 +276,7 @@ void _TimestampOpen(void)
|
||||||
*
|
*
|
||||||
* @return timestamp value
|
* @return timestamp value
|
||||||
*/
|
*/
|
||||||
u32_t _TimestampRead(void)
|
u32_t _timestamp_read(void)
|
||||||
{
|
{
|
||||||
static u32_t last_val;
|
static u32_t last_val;
|
||||||
u32_t tmr_val = _TIMESTAMP_VAL;
|
u32_t tmr_val = _TIMESTAMP_VAL;
|
||||||
|
@ -298,7 +302,7 @@ u32_t _TimestampRead(void)
|
||||||
*
|
*
|
||||||
* @return N/A
|
* @return N/A
|
||||||
*/
|
*/
|
||||||
void _TimestampClose(void)
|
void _timestamp_close(void)
|
||||||
{
|
{
|
||||||
/* disable RTT clock from PMC */
|
/* disable RTT clock from PMC */
|
||||||
soc_pmc_peripheral_disable(ID_RTT);
|
soc_pmc_peripheral_disable(ID_RTT);
|
||||||
|
|
|
@ -282,31 +282,31 @@ static const char test_data[] = { '0', '1', '2', '3', '4',
|
||||||
'5', '6', '7' };
|
'5', '6', '7' };
|
||||||
|
|
||||||
static const char sample_data[] =
|
static const char sample_data[] =
|
||||||
"abcdefghijklmnopqrstuvxyz"
|
"abcdefghijklmnopqrstuvxyz "
|
||||||
"abcdefghijklmnopqrstuvxyz"
|
"abcdefghijklmnopqrstuvxyz "
|
||||||
"abcdefghijklmnopqrstuvxyz"
|
"abcdefghijklmnopqrstuvxyz "
|
||||||
"abcdefghijklmnopqrstuvxyz"
|
"abcdefghijklmnopqrstuvxyz "
|
||||||
"abcdefghijklmnopqrstuvxyz"
|
"abcdefghijklmnopqrstuvxyz "
|
||||||
"abcdefghijklmnopqrstuvxyz"
|
"abcdefghijklmnopqrstuvxyz "
|
||||||
"abcdefghijklmnopqrstuvxyz"
|
"abcdefghijklmnopqrstuvxyz "
|
||||||
"abcdefghijklmnopqrstuvxyz"
|
"abcdefghijklmnopqrstuvxyz "
|
||||||
"abcdefghijklmnopqrstuvxyz"
|
"abcdefghijklmnopqrstuvxyz "
|
||||||
"abcdefghijklmnopqrstuvxyz"
|
"abcdefghijklmnopqrstuvxyz "
|
||||||
"abcdefghijklmnopqrstuvxyz"
|
"abcdefghijklmnopqrstuvxyz "
|
||||||
"abcdefghijklmnopqrstuvxyz"
|
"abcdefghijklmnopqrstuvxyz "
|
||||||
"abcdefghijklmnopqrstuvxyz";
|
"abcdefghijklmnopqrstuvxyz";
|
||||||
|
|
||||||
static char test_rw_short[] =
|
static char test_rw_short[] =
|
||||||
"abcdefghijklmnopqrstuvwxyz";
|
"abcdefghijklmnopqrstuvwxyz";
|
||||||
|
|
||||||
static char test_rw_long[] =
|
static char test_rw_long[] =
|
||||||
"abcdefghijklmnopqrstuvwxyz"
|
"abcdefghijklmnopqrstuvwxyz "
|
||||||
"abcdefghijklmnopqrstuvwxyz"
|
"abcdefghijklmnopqrstuvwxyz "
|
||||||
"abcdefghijklmnopqrstuvwxyz"
|
"abcdefghijklmnopqrstuvwxyz "
|
||||||
"abcdefghijklmnopqrstuvwxyz"
|
"abcdefghijklmnopqrstuvwxyz "
|
||||||
"abcdefghijklmnopqrstuvwxyz"
|
"abcdefghijklmnopqrstuvwxyz "
|
||||||
"abcdefghijklmnopqrstuvwxyz"
|
"abcdefghijklmnopqrstuvwxyz "
|
||||||
"abcdefghijklmnopqrstuvwxyz";
|
"abcdefghijklmnopqrstuvwxyz ";
|
||||||
|
|
||||||
static void test_pkt_read_append(void)
|
static void test_pkt_read_append(void)
|
||||||
{
|
{
|
||||||
|
@ -440,7 +440,7 @@ static void test_pkt_read_append(void)
|
||||||
tfrag = net_frag_read(tfrag, off + 10, &tpos, 10, data);
|
tfrag = net_frag_read(tfrag, off + 10, &tpos, 10, data);
|
||||||
if (!tfrag ||
|
if (!tfrag ||
|
||||||
memcmp(sample_data + off + 10, data, 10)) {
|
memcmp(sample_data + off + 10, data, 10)) {
|
||||||
printk("Failed to read from offset %d, frag length %d"
|
printk("Failed to read from offset %d, frag length %d "
|
||||||
"read length %d\n",
|
"read length %d\n",
|
||||||
tfrag->len + 10, tfrag->len, 10);
|
tfrag->len + 10, tfrag->len, 10);
|
||||||
zassert_true(false, "Fail offset read");
|
zassert_true(false, "Fail offset read");
|
||||||
|
@ -995,8 +995,8 @@ static void test_fragment_split(void)
|
||||||
#define FRAGA (FRAG_COUNT - 2)
|
#define FRAGA (FRAG_COUNT - 2)
|
||||||
#define FRAGB (FRAG_COUNT - 1)
|
#define FRAGB (FRAG_COUNT - 1)
|
||||||
struct net_pkt *pkt;
|
struct net_pkt *pkt;
|
||||||
struct net_buf *frags[FRAG_COUNT], *frag, *fragA, *fragB;
|
struct net_buf *frags[FRAG_COUNT], *frag, *frag_a, *frag_b;
|
||||||
int i, total, splitA, splitB;
|
int i, total, split_a, split_b;
|
||||||
int ret, frag_size;
|
int ret, frag_size;
|
||||||
|
|
||||||
memset(frags, 0, FRAG_COUNT * sizeof(void *));
|
memset(frags, 0, FRAG_COUNT * sizeof(void *));
|
||||||
|
@ -1031,45 +1031,45 @@ static void test_fragment_split(void)
|
||||||
|
|
||||||
net_pkt_frag_add(pkt, frags[0]);
|
net_pkt_frag_add(pkt, frags[0]);
|
||||||
|
|
||||||
fragA = frags[FRAGA];
|
frag_a = frags[FRAGA];
|
||||||
fragB = frags[FRAGB];
|
frag_b = frags[FRAGB];
|
||||||
|
|
||||||
zassert_is_null(fragA, "fragA is not NULL");
|
zassert_is_null(frag_a, "frag_a is not NULL");
|
||||||
zassert_is_null(fragB, "fragB is not NULL");
|
zassert_is_null(frag_b, "frag_b is not NULL");
|
||||||
|
|
||||||
splitA = frag_size * 2 / 3;
|
split_a = frag_size * 2 / 3;
|
||||||
splitB = frag_size - splitA;
|
split_b = frag_size - split_a;
|
||||||
|
|
||||||
zassert_true(splitA > 0, "A size is 0");
|
zassert_true(split_a > 0, "A size is 0");
|
||||||
zassert_true(splitA > splitB, "A is smaller than B");
|
zassert_true(split_a > split_b, "A is smaller than B");
|
||||||
|
|
||||||
/* Test some error cases first */
|
/* Test some error cases first */
|
||||||
ret = net_pkt_split(NULL, NULL, 1024, &fragA, &fragB, K_NO_WAIT);
|
ret = net_pkt_split(NULL, NULL, 1024, &frag_a, &frag_b, K_NO_WAIT);
|
||||||
zassert_equal(ret, -EINVAL, "Invalid buf pointers");
|
zassert_equal(ret, -EINVAL, "Invalid buf pointers");
|
||||||
|
|
||||||
ret = net_pkt_split(pkt, pkt->frags, CONFIG_NET_BUF_DATA_SIZE + 1,
|
ret = net_pkt_split(pkt, pkt->frags, CONFIG_NET_BUF_DATA_SIZE + 1,
|
||||||
&fragA, &fragB, K_NO_WAIT);
|
&frag_a, &frag_b, K_NO_WAIT);
|
||||||
zassert_equal(ret, 0, "Split failed");
|
zassert_equal(ret, 0, "Split failed");
|
||||||
|
|
||||||
ret = net_pkt_split(pkt, pkt->frags, splitA,
|
ret = net_pkt_split(pkt, pkt->frags, split_a,
|
||||||
&fragA, &fragB, K_NO_WAIT);
|
&frag_a, &frag_b, K_NO_WAIT);
|
||||||
zassert_equal(ret, 0, "Cannot split frag");
|
zassert_equal(ret, 0, "Cannot split frag");
|
||||||
|
|
||||||
if (fragA->len != splitA) {
|
if (frag_a->len != split_a) {
|
||||||
printk("Frag A len %d not %d\n", fragA->len, splitA);
|
printk("Frag_a len %d not %d\n", frag_a->len, split_a);
|
||||||
zassert_equal(fragA->len, splitA, "FragA len wrong");
|
zassert_equal(frag_a->len, split_a, "Frag_a len wrong");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fragB->len != splitB) {
|
if (frag_b->len != split_b) {
|
||||||
printk("Frag B len %d not %d\n", fragB->len, splitB);
|
printk("Frag_b len %d not %d\n", frag_b->len, split_b);
|
||||||
zassert_true(false, "FragB len wrong");
|
zassert_true(false, "Frag_b len wrong");
|
||||||
}
|
}
|
||||||
|
|
||||||
zassert_false(memcmp(pkt->frags->data, fragA->data, splitA),
|
zassert_false(memcmp(pkt->frags->data, frag_a->data, split_a),
|
||||||
"Frag A data mismatch");
|
"Frag_a data mismatch");
|
||||||
|
|
||||||
zassert_false(memcmp(pkt->frags->data + splitA, fragB->data, splitB),
|
zassert_false(memcmp(pkt->frags->data + split_a, frag_b->data, split_b),
|
||||||
"Frag B data mismatch");
|
"Frag_b data mismatch");
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_main(void)
|
void test_main(void)
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
* @param my_sem thread's own semaphore
|
* @param my_sem thread's own semaphore
|
||||||
* @param other_sem other thread's semaphore
|
* @param other_sem other thread's semaphore
|
||||||
*/
|
*/
|
||||||
void helloLoop(const char *my_name,
|
void hello_loop(const char *my_name,
|
||||||
struct k_sem *my_sem, struct k_sem *other_sem)
|
struct k_sem *my_sem, struct k_sem *other_sem)
|
||||||
{
|
{
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -50,32 +50,32 @@ void helloLoop(const char *my_name,
|
||||||
|
|
||||||
/* define semaphores */
|
/* define semaphores */
|
||||||
|
|
||||||
K_SEM_DEFINE(threadA_sem, 1, 1); /* starts off "available" */
|
K_SEM_DEFINE(threada_sem, 1, 1); /* starts off "available" */
|
||||||
K_SEM_DEFINE(threadB_sem, 0, 1); /* starts off "not available" */
|
K_SEM_DEFINE(threadb_sem, 0, 1); /* starts off "not available" */
|
||||||
|
|
||||||
|
|
||||||
/* threadB is a dynamic thread that is spawned by threadA */
|
/* threadb is a dynamic thread that is spawned by threadA */
|
||||||
|
|
||||||
void threadB(void *dummy1, void *dummy2, void *dummy3)
|
void threadb(void *dummy1, void *dummy2, void *dummy3)
|
||||||
{
|
{
|
||||||
/* invoke routine to ping-pong hello messages with threadA */
|
/* invoke routine to ping-pong hello messages with threadA */
|
||||||
helloLoop(__func__, &threadB_sem, &threadA_sem);
|
hello_loop(__func__, &threadb_sem, &threada_sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
K_THREAD_STACK_DEFINE(threadB_stack_area, STACKSIZE);
|
K_THREAD_STACK_DEFINE(threadb_stack_area, STACKSIZE);
|
||||||
static struct k_thread threadB_data;
|
static struct k_thread threadb_data;
|
||||||
|
|
||||||
/* threadA is a static thread that is spawned automatically */
|
/* threada is a static thread that is spawned automatically */
|
||||||
|
|
||||||
void threadA(void *dummy1, void *dummy2, void *dummy3)
|
void threada(void *dummy1, void *dummy2, void *dummy3)
|
||||||
{
|
{
|
||||||
/* spawn threadB */
|
/* spawn threadB */
|
||||||
k_thread_create(&threadB_data, threadB_stack_area, STACKSIZE, threadB,
|
k_thread_create(&threadb_data, threadb_stack_area, STACKSIZE, threadb,
|
||||||
NULL, NULL, NULL, PRIORITY, 0, K_NO_WAIT);
|
NULL, NULL, NULL, PRIORITY, 0, K_NO_WAIT);
|
||||||
|
|
||||||
/* invoke routine to ping-pong hello messages with threadB */
|
/* invoke routine to ping-pong hello messages with threadB */
|
||||||
helloLoop(__func__, &threadA_sem, &threadB_sem);
|
hello_loop(__func__, &threada_sem, &threadb_sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
K_THREAD_DEFINE(threadA_id, STACKSIZE, threadA, NULL, NULL, NULL,
|
K_THREAD_DEFINE(threada_id, STACKSIZE, threada, NULL, NULL, NULL,
|
||||||
PRIORITY, 0, K_NO_WAIT);
|
PRIORITY, 0, K_NO_WAIT);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue