summaryrefslogtreecommitdiff
path: root/cesar/cp2/sta
diff options
context:
space:
mode:
authorchertier2008-06-13 15:07:03 +0000
committerchertier2008-06-13 15:07:03 +0000
commitc9bfae38de975b6cdb6f58b4b16d0e6722da7b65 (patch)
tree21563766acafbd638d21678cce1a49ef7b8630b3 /cesar/cp2/sta
parentc77e49520703503332bff94939087d832cb616b9 (diff)
updated sta core test and sta core accordingly (improving / adding new tests),
and managing/verifying test counters appropriately git-svn-id: svn+ssh://pessac/svn/cesar/trunk@2336 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/cp2/sta')
-rw-r--r--cesar/cp2/sta/core/src/core.c18
-rw-r--r--cesar/cp2/sta/core/test/src/core_test.c122
2 files changed, 110 insertions, 30 deletions
diff --git a/cesar/cp2/sta/core/src/core.c b/cesar/cp2/sta/core/src/core.c
index 9c106dcd66..9d578e76bd 100644
--- a/cesar/cp2/sta/core/src/core.c
+++ b/cesar/cp2/sta/core/src/core.c
@@ -310,7 +310,7 @@ cp_sta_core_gen_core_alarm(cp_t *cp_ctx, cp_sta_core_alarm_def_t *sta_core_alarm
{
cyg_alarm_initialize(sta_core_alarm->alarm_handle, trigger_time, cp_sta_core_ms_to_cyg_tick(event_period_or_delay_ms));
#ifdef DEBUG
- diag_printf("%u %s() : create a %u ms cyclic alarm at eCos time = %u\n",
+ diag_printf("%u %s() : create a %u ms cyclic alarm at eCos time = %u ticks\n",
cyg_hal_sys_getpid(),__FUNCTION__,event_period_or_delay_ms,(int)cyg_current_time());
#endif
}
@@ -318,7 +318,7 @@ cp_sta_core_gen_core_alarm(cp_t *cp_ctx, cp_sta_core_alarm_def_t *sta_core_alarm
{
cyg_alarm_initialize(sta_core_alarm->alarm_handle, trigger_time, 0);
#ifdef DEBUG
- diag_printf("%u %s() : create a %u ms one-shot alarm at eCos time = %u (end of alarm at eCos time = %u)\n",
+ diag_printf("%u %s() : create a %u ms one-shot alarm at eCos time = %u ticks (end of alarm will be at eCos time = %u ticks)\n",
cyg_hal_sys_getpid(),__FUNCTION__,event_period_or_delay_ms,(int)cyg_current_time(),trigger_time);
#endif
}
@@ -343,7 +343,7 @@ void
cp_sta_core_gen_core_cyclic_event(cp_t *cp_ctx, cp_sta_core_alarm_def_t *sta_core_alarm, cp_sta_core_event_flag_t event_flag, cp_fsm_event_t *fsm_event, uint event_period_ms)
{
#ifdef DEBUG
- diag_printf("%u %s() : create a %u ms cyclic alarm at eCos time = %u...\n",
+ diag_printf("%u %s() : create a %u ms cyclic alarm at eCos time = %u ticks...\n",
cyg_hal_sys_getpid(),__FUNCTION__,event_period_ms,(int)cyg_current_time());
#endif
cp_sta_core_gen_core_alarm( cp_ctx,
@@ -375,7 +375,7 @@ void
cp_sta_core_gen_core_timed_event(cp_t *cp_ctx, cp_sta_core_alarm_def_t *sta_core_alarm, cp_sta_core_event_flag_t event_flag, cp_fsm_event_t *fsm_event, uint event_delay_ms)
{
#ifdef DEBUG
- diag_printf("%u %s() : create a %u ms one-shot alarm at eCos time = %u...\n",
+ diag_printf("%u %s() : create a %u ms one-shot alarm at eCos time = %u ticks...\n",
cyg_hal_sys_getpid(),__FUNCTION__,event_delay_ms,(int)cyg_current_time());
#endif
cp_sta_core_gen_core_alarm( cp_ctx,
@@ -407,7 +407,7 @@ cp_sta_core_gen_cyclic_event(cp_t *cp_ctx, cp_sta_core_timed_event_def_t *sta_co
dbg_assert(sta_core_cyclic_event);
dbg_assert(fsm_event);
#ifdef DEBUG
- diag_printf("%u %s() : creating a %u ms cyclic event at eCos time = %u\n",
+ diag_printf("%u %s() : creating a %u ms cyclic event at eCos time = %u ticks\n",
cyg_hal_sys_getpid(),__FUNCTION__,event_period_ms,(int)cyg_current_time());
#endif
cp_sta_core_gen_core_cyclic_event(cp_ctx, sta_core_cyclic_event, CP_STA_CORE_EVENT_FLAG_FSM, fsm_event, event_period_ms);
@@ -433,7 +433,7 @@ cp_sta_core_gen_timed_event(cp_t *cp_ctx, cp_sta_core_timed_event_def_t *sta_cor
dbg_assert(sta_core_timed_event);
dbg_assert(fsm_event);
#ifdef DEBUG
- diag_printf("%u %s() : creating a %u ms timed event at eCos time = %u\n",cyg_hal_sys_getpid(),__FUNCTION__,event_delay_ms,(int)cyg_current_time());
+ diag_printf("%u %s() : creating a %u ms timed event at eCos time = %u ticks\n",cyg_hal_sys_getpid(),__FUNCTION__,event_delay_ms,(int)cyg_current_time());
#endif
cp_sta_core_gen_core_timed_event(cp_ctx, sta_core_timed_event, CP_STA_CORE_EVENT_FLAG_FSM, fsm_event, event_delay_ms);
}
@@ -712,7 +712,7 @@ cp_sta_core_wait_event_loop(cp_t *cp_ctx)
while (!cp_ctx->sta_core.terminate_flag)
{
#if DEBUG
- diag_printf("%u %s() : station ready and waiting for event (@core_event_flag=0x%08lx ; flag_mask=0x%08lx)...\n",
+ diag_printf("%u %s() : cp sta core thread ready and waiting for events (@core_event_flag=0x%08lx ; flag_mask=0x%08lx)...\n",
cyg_hal_sys_getpid(),__FUNCTION__,(unsigned long)&cp_ctx->sta_core.wait_event_core_flag,(unsigned long)flag_mask);
#endif
// wait for a cp sta core event
@@ -733,13 +733,13 @@ cp_sta_core_wait_event_loop(cp_t *cp_ctx)
{
// we find an event, so we clear it
#if DEBUG
- diag_printf("%u %s() : we find a %s event (flag_value=0x%08lx ; flag_mask=0x%08lx)...\n",
+ diag_printf("%u %s() : cp sta core thread find a %s event (flag_value=0x%08lx ; flag_mask=0x%08lx)...\n",
cyg_hal_sys_getpid(),__FUNCTION__,cst_str_cp_sta_core_event[i],(unsigned long)flag_value,(unsigned long)flag_mask);
#endif
//cyg_flag_maskbits (&cp_ctx->sta_core.wait_event_core_flag, ~cp_sta_core_event_action[i].event_flag);
flag_value &= ~cp_sta_core_event_action[i].event_flag;
#if DEBUG
- diag_printf("%u %s() : ... so, we clear it before we treat it (station_flag=0x%08lx ; flag_mask=0x%08lx)...\n",
+ diag_printf("%u %s() : ... so, clear this event before treating it (event_core_flag=0x%08lx ; flag_mask=0x%08lx)...\n",
cyg_hal_sys_getpid(),__FUNCTION__,(unsigned long)*((u32*)&cp_ctx->sta_core.wait_event_core_flag),(unsigned long)flag_mask);
#endif
// and then we process it
diff --git a/cesar/cp2/sta/core/test/src/core_test.c b/cesar/cp2/sta/core/test/src/core_test.c
index f344bf9110..78b0459f8a 100644
--- a/cesar/cp2/sta/core/test/src/core_test.c
+++ b/cesar/cp2/sta/core/test/src/core_test.c
@@ -23,13 +23,18 @@
#include "cp2/cp.h"
#include "cp2/cl_interf/cl_interf.h"
+#include "cp2/fsm/fsm.h"
+
#include "cp2/inc/context.h"
-#define CORE_TEST_NS_TO_MS 1000000 // 1 millisecond = 1000000 nanoseconds
-#define CORE_TEST_50HZ_PWL_BEACON_PERIOD_MS 40 // by default, ACL frequency assumed to be 50 Hz (=> beacon period = 40 ms)
-#define CORE_TEST_MAXCOUNT_OF_GARBAGE_OCCURENCE 5 // test will stop after N occurences of garbage collector
-#define CORE_TEST_BEACON_TO_MME_RATE_DIVISOR 5 // 1 x MME for N x beacons
-#define CORE_TEST_BEGIN_SENDING_MME_BEFORE_END 4 // begin to simulate MMEs events N x garbage collector events before end of test
+#define CORE_TEST_NS_TO_MS 1000000 // 1 millisecond = 1000000 nanoseconds
+#define CORE_TEST_50HZ_PWL_BEACON_PERIOD_MS 40 // by default, ACL frequency assumed to be 50 Hz (=> beacon period = 40 ms)
+#define CORE_TEST_MAXCOUNT_OF_GARBAGE_OCCURENCE 5 // test will stop after N occurences of garbage collector
+#define CORE_TEST_BEACON_TO_MME_RATE_DIVISOR 5 // 1 x MME for N x beacons
+#define CORE_TEST_BEGIN_SENDING_MME_BEFORE_END 4 // begin to simulate MMEs events N x garbage collector events before end of test
+
+#define CORE_TEST_ONE_SHOT_TIMEOUT_MS 2500 // arbitrary one-shot timeout
+#define CORE_TEST_ONE_SHOT_FSM_EVENT_PTR 0xBABABABA // dummy FSM event descriptor
#define CORE_TEST_COUNT_OF_RECV_BEACON_EVENTS ((CORE_TEST_MAXCOUNT_OF_GARBAGE_OCCURENCE * CP_STA_CORE_GARBAGE_COLLECTOR_PERIOD_MS) / CORE_TEST_50HZ_PWL_BEACON_PERIOD_MS)
#define CORE_TEST_COUNT_OF_BEACON_PROCESSING CORE_TEST_COUNT_OF_RECV_BEACON_EVENTS
@@ -37,6 +42,9 @@
#define CORE_TEST_COUNT_OF_RECV_MME_EVENTS (((CORE_TEST_BEGIN_SENDING_MME_BEFORE_END * CP_STA_CORE_GARBAGE_COLLECTOR_PERIOD_MS) / CORE_TEST_50HZ_PWL_BEACON_PERIOD_MS) / CORE_TEST_BEACON_TO_MME_RATE_DIVISOR)
#define CORE_TEST_COUNT_OF_MME_PROCESSING CORE_TEST_COUNT_OF_RECV_MME_EVENTS
+#define CORE_TEST_COUNT_OF_ONE_SHOT_TIMEOUT_EVENTS 1
+#define CORE_TEST_COUNT_OF_ONE_SHOT_TIMEOUT_PROCESSING CORE_TEST_COUNT_OF_ONE_SHOT_TIMEOUT_EVENTS
+
#define CORE_TEST_COUNT_OF_CP_THREAD_TERMINATE_EVENTS 1
static const char *cst_str_result[] = {"failed ! ","succeeded"};
@@ -48,6 +56,7 @@ static const char *cst_str_comment_status_of_counters[] = {"some events/processi
int count_of_recv_beacon_events = 0;
int count_of_recv_mme_events = 0;
int count_of_cp_fsm_events = 0;
+int count_of_one_shot_timeout_events = 0;
int count_of_garbage_collector_events = 0;
int count_of_cp_thread_terminate_events = 0;
@@ -61,9 +70,11 @@ int count_of_sta_mgr_garbage_calls = 0;
int count_of_beacon_processing = 0;
int count_of_mme_processing = 0;
int count_of_cp_fsm_processing = 0;
+int count_of_one_shot_timeout_processing = 0;
int count_of_garbage_collector_processing = 0;
int count_of_cp_thread_terminate_processing = 0;
+// test counters for sub-garbage collector functions being called
int count_of_cl_interf_garbage_processing = 0;
int count_of_sta_action_garbage_processing = 0;
int count_of_cco_action_garbage_processing = 0;
@@ -73,12 +84,16 @@ int count_of_sta_mgr_garbage_processing = 0;
bool beacon_events_test_result = false;
bool mme_events_test_result = false;
bool cp_fsm_events_test_result = false;
+bool one_shot_timeout_events_test_result = false;
bool garbage_collector_events_test_result = false;
bool cp_thread_terminate_events_test_result = false;
//flag to force/signal end of test
bool end_of_test = false;
+//eCos tick resolution in millisecond
+unsigned int sysclock_resolution;
+
/**
* phy_clock_get_zero_cross_captured_date() stub.
*
@@ -182,6 +197,22 @@ test_case_sta_core_verify_results (test_t test, cp_t *cp)
diag_printf("\ncp_fsm_events_test_result = %s : %s\n\n",
cst_str_result[cp_fsm_events_test_result],cst_str_comment1_events_processing[cp_fsm_events_test_result]);
+ // display and verify one-shot timed events test results
+ diag_printf(" count_of_one_shot_timeout_events = %u (%u expected)\n",
+ count_of_one_shot_timeout_events, CORE_TEST_COUNT_OF_ONE_SHOT_TIMEOUT_EVENTS);
+ diag_printf(" count_of_one_shot_timeout_processing = %u (%u expected)\n",
+ count_of_one_shot_timeout_processing, CORE_TEST_COUNT_OF_ONE_SHOT_TIMEOUT_PROCESSING);
+ one_shot_timeout_events_test_result = (count_of_one_shot_timeout_events == CORE_TEST_COUNT_OF_ONE_SHOT_TIMEOUT_EVENTS)
+ &&
+ (count_of_one_shot_timeout_processing == CORE_TEST_COUNT_OF_ONE_SHOT_TIMEOUT_PROCESSING);
+ diag_printf(" count_of_one_shot_timeout_events = %u (%u expected)\n",
+ count_of_one_shot_timeout_events, CORE_TEST_COUNT_OF_ONE_SHOT_TIMEOUT_EVENTS);
+ diag_printf(" count_of_one_shot_timeout_processing = %u (%u expected)\n",
+ count_of_one_shot_timeout_processing, CORE_TEST_COUNT_OF_ONE_SHOT_TIMEOUT_PROCESSING);
+
+ diag_printf("\none_shot_timeout_events_test_result = %s : %s\n\n",
+ cst_str_result[one_shot_timeout_events_test_result],cst_str_comment2_events_processing[one_shot_timeout_events_test_result]);
+
// display and verify garbage collector events test results
diag_printf(" count_of_garbage_collector_events = %u (%u expected)\n",
count_of_garbage_collector_events, CORE_TEST_MAXCOUNT_OF_GARBAGE_OCCURENCE);
@@ -233,10 +264,11 @@ test_case_sta_core_verify_results (test_t test, cp_t *cp)
cst_str_result[cp_thread_terminate_events_test_result],cst_str_comment2_events_processing[cp_thread_terminate_events_test_result]);
// report and verify whole test results
- test_counters_ok = (beacon_events_test_result == true)
- && (mme_events_test_result == true)
- && (cp_fsm_events_test_result == true)
- && (garbage_collector_events_test_result == true)
+ test_counters_ok = (beacon_events_test_result == true)
+ && (mme_events_test_result == true)
+ && (cp_fsm_events_test_result == true)
+ && (one_shot_timeout_events_test_result == true)
+ && (garbage_collector_events_test_result == true)
&& (cp_thread_terminate_events_test_result == true);
diag_printf(" beacon_events_test_result = %s : %s\n",
@@ -245,6 +277,8 @@ test_case_sta_core_verify_results (test_t test, cp_t *cp)
cst_str_result[mme_events_test_result],cst_str_comment1_events_processing[mme_events_test_result]);
diag_printf(" cp_fsm_events_test_result = %s : %s\n",
cst_str_result[cp_fsm_events_test_result],cst_str_comment1_events_processing[cp_fsm_events_test_result]);
+ diag_printf(" one_shot_timeout_events_test_result = %s : %s\n",
+ cst_str_result[one_shot_timeout_events_test_result],cst_str_comment1_events_processing[one_shot_timeout_events_test_result]);
diag_printf(" garbage_collector_events_test_result = %s : %s\n",
cst_str_result[garbage_collector_events_test_result],cst_str_comment2_events_processing[garbage_collector_events_test_result]);
diag_printf(" cp_thread_terminate_events_test_result = %s : %s\n",
@@ -303,13 +337,16 @@ test_case_sta_core_init (test_t test)
void
test_case_sta_core_test_1 (test_t test)
{
- cp_t cp_ctx;
+ cp_t cp_ctx;
cp_sta_core_timed_event_def_t cyclic_recv_central_beacon_event;
- int previous_count_of_beacon_processing = 0;
- int prev_bis_count_of_beacon_processing = 0;
- int my_count_of_garbage_collector_processing = 0;
- int my_previous_count_of_beacon_processing = 0;
- int my_count_of_beacon_processing = 0;
+ cp_sta_core_timed_event_def_t one_shot_timeout_core_event;
+ cp_fsm_event_t *one_shot_timeout_fsm_event = (void *) CORE_TEST_ONE_SHOT_FSM_EVENT_PTR;
+ int previous_count_of_beacon_processing = 0;
+ int prev_bis_count_of_beacon_processing = 0;
+ int my_count_of_garbage_collector_processing = 0;
+ int my_previous_count_of_beacon_processing = 0;
+ int my_count_of_beacon_processing = 0;
+ unsigned int tmp_date;
test_case_begin (test, "sta core test_1");
@@ -323,10 +360,18 @@ test_case_sta_core_test_1 (test_t test)
//(calling this cp sta core API function is for test purpose only beacause it is not really a "public" function)
//count_of_recv_beacon_events++;
//cp_sta_core_signal_recv_beacon_event(&cp_ctx);
- //cp_sta_core_gen_core_cyclic_event(&cp_ctx, &cyclic_recv_central_beacon_event, CP_STA_CORE_EVENT_FLAG_RECV_BEACON, 0, CORE_TEST_50HZ_PWL_BEACON_PERIOD_MS);
- cp_sta_core_gen_core_cyclic_event(&cp_ctx, &cyclic_recv_central_beacon_event, CP_STA_CORE_EVENT_FLAG_RECV_BEACON, 0, cp_ctx.pwl.bp_ntb/25000);
+ //cp_sta_core_gen_core_cyclic_event(&cp_ctx, &cyclic_recv_central_beacon_event, CP_STA_CORE_EVENT_FLAG_RECV_BEACON, NULL, CORE_TEST_50HZ_PWL_BEACON_PERIOD_MS);
+ cp_sta_core_gen_core_cyclic_event(&cp_ctx, &cyclic_recv_central_beacon_event, CP_STA_CORE_EVENT_FLAG_RECV_BEACON, NULL, cp_ctx.pwl.bp_ntb/25000);
+
+ //arm a one-shot timeout that will end-up at half the total running time of the loop test...
+ cp_sta_core_gen_timed_event(&cp_ctx, &one_shot_timeout_core_event, one_shot_timeout_fsm_event, CORE_TEST_ONE_SHOT_TIMEOUT_MS);//CORE_TEST_MAXCOUNT_OF_GARBAGE_OCCURENCE
- //test loop that will stop after N occurrences of calling the garbage collector...
+ //display eCos system date in millisecond just before entering test loop
+ tmp_date = cp_sta_core_get_date_ms(&cp_ctx);
+ diag_printf("%u %s() : entering test loop at eCos system date = %u ms (%u ticks)\n",
+ cyg_hal_sys_getpid(), __FUNCTION__, tmp_date, cp_sta_core_ms_to_cyg_tick(tmp_date));
+
+ //test loop that will stop after N occurrences (CORE_TEST_MAXCOUNT_OF_GARBAGE_OCCURENCE) of calling the garbage collector...
while (!end_of_test)
{
my_count_of_garbage_collector_processing = count_of_garbage_collector_processing;
@@ -416,6 +461,23 @@ cp_fsm_post (cp_t *ctx, cp_fsm_event_t *event)
{
dbg_assert (ctx);
dbg_assert (event);
+ //diag_printf("%u %s() : event reference pointer = 0x%08lX\n",
+ // cyg_hal_sys_getpid(),__FUNCTION__,(unsigned long)event);
+ switch ((unsigned long)event)
+ {
+ case CORE_TEST_ONE_SHOT_FSM_EVENT_PTR :
+ // ok, update counters...
+ diag_printf("%u %s() : event reference pointer 0x%08lX ok (CORE_TEST_ONE_SHOT_FSM_EVENT_PTR)\n",
+ cyg_hal_sys_getpid(),__FUNCTION__,(unsigned long)event);
+ count_of_one_shot_timeout_events++;
+ count_of_one_shot_timeout_processing++;
+ break;
+ default :
+ // ko, so don't update counters !
+ diag_printf("%u %s() : unexpected/unknown event reference pointer 0x%08lX !? (internal error)\n",
+ cyg_hal_sys_getpid(),__FUNCTION__,(unsigned long)event);
+ break;
+ }
}
/** Test main.
@@ -426,18 +488,34 @@ cp_fsm_post (cp_t *ctx, cp_fsm_event_t *event)
int
main (void)
{
+ char strtmp[128];
test_t test;
+
test_init (test, 0, NULL);
+ sysclock_resolution = (cyg_clock_get_resolution(cyg_real_time_clock()).dividend / cyg_clock_get_resolution(cyg_real_time_clock()).divisor) / CORE_TEST_NS_TO_MS;
+#if 1
+ //ceci marche (affichage correct, pas d'erreur contexte phy après...)
+ sprintf(strtmp, "eCos system real-time clock resolution = %u ms (1 tick = %u ms)", sysclock_resolution, sysclock_resolution);
+ diag_printf("%u %s() : %s\n",
+ cyg_hal_sys_getpid(), __FUNCTION__, strtmp);
+#else
+# if 0
+ //ceci "ne marche pas" (affichage correct, mais provoque erreur d'assert contexte phy un peu plus loin !?)
+ diag_printf("%u %s() : eCos system real-time clock resolution = %u ms (1 tick = %u ms)\n",
+ cyg_hal_sys_getpid(), __FUNCTION__, sysclock_resolution, sysclock_resolution);
+# else
+ //ceci marche (affichage correct, pas d'erreur contexte phy après...)
diag_printf("%u %s() : eCos system real-time clock resolution = %u ms\n",
- cyg_hal_sys_getpid(),
- __FUNCTION__,
- (cyg_clock_get_resolution(cyg_real_time_clock()).dividend / cyg_clock_get_resolution(cyg_real_time_clock()).divisor) / CORE_TEST_NS_TO_MS);
+ cyg_hal_sys_getpid(), __FUNCTION__, sysclock_resolution);
+# endif
+#endif
//reset counters used to report test results
count_of_recv_beacon_events = 0;
count_of_recv_mme_events = 0;
count_of_cp_fsm_events = 0;
+ count_of_one_shot_timeout_events = 0;
count_of_garbage_collector_events = 0;
count_of_cl_interf_garbage_calls = 0;
count_of_cp_thread_terminate_events = 0;
@@ -445,6 +523,7 @@ main (void)
count_of_beacon_processing = 0;
count_of_mme_processing = 0;
count_of_cp_fsm_processing = 0;
+ count_of_one_shot_timeout_processing = 0;
count_of_garbage_collector_processing = 0;
count_of_cl_interf_garbage_processing = 0;
count_of_cp_thread_terminate_processing = 0;
@@ -452,6 +531,7 @@ main (void)
beacon_events_test_result = false;
mme_events_test_result = false;
cp_fsm_events_test_result = false;
+ one_shot_timeout_events_test_result = false;
garbage_collector_events_test_result = false;
cp_thread_terminate_events_test_result = false;