summaryrefslogtreecommitdiff
path: root/cp/beacon/test
diff options
context:
space:
mode:
authorlaranjeiro2008-01-10 14:57:27 +0000
committerlaranjeiro2008-01-10 14:57:27 +0000
commit973292d95ba088a132ac38487dbe2b47347181f5 (patch)
tree4450d5d3630061bd52f35134be7939fc967912e0 /cp/beacon/test
parent36706aac4af72cd7730b6518d3dd3efe6429eedc (diff)
Implemented and tested the genration of a central beacon and discover beacon generated by the sta in respsonse of a
discover bentry. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1254 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cp/beacon/test')
-rw-r--r--cp/beacon/test/central_beacon/Makefile4
-rw-r--r--cp/beacon/test/central_beacon/overide/cp/station/inc/context.h1
-rw-r--r--cp/beacon/test/central_beacon/src/ac_line_test.c15
-rw-r--r--cp/beacon/test/central_beacon/src/bts_bto_bp.c23
-rw-r--r--cp/beacon/test/central_beacon/src/central_beacon.c137
5 files changed, 151 insertions, 29 deletions
diff --git a/cp/beacon/test/central_beacon/Makefile b/cp/beacon/test/central_beacon/Makefile
index e8e7cde17b..a9aa6381f4 100644
--- a/cp/beacon/test/central_beacon/Makefile
+++ b/cp/beacon/test/central_beacon/Makefile
@@ -6,12 +6,12 @@ INCLUDES = cp/beacon/test/central_beacon/overide
TARGET_PROGRAMS = ac_line estimation central_beacon
-ac_line_SOURCES = ac_line_test.c phy_stub.c
+ac_line_SOURCES = ac_line_test.c phy_stub.c pbproc_stub.c
ac_line_MODULES = lib mac/common cp/beacon \
cp/beacon/test/central_beacon/overide/cp/station \
cp/beacon/test/central_beacon/overide/cp/secu
-estimation_SOURCES = bts_bto_bp.c phy_stub.c
+estimation_SOURCES = bts_bto_bp.c phy_stub.c pbproc_stub.c
estimation_MODULES = lib mac/common cp/beacon \
cp/beacon/test/central_beacon/overide/cp/station \
cp/beacon/test/central_beacon/overide/cp/secu
diff --git a/cp/beacon/test/central_beacon/overide/cp/station/inc/context.h b/cp/beacon/test/central_beacon/overide/cp/station/inc/context.h
index cf2cfcc277..16bc9e2f61 100644
--- a/cp/beacon/test/central_beacon/overide/cp/station/inc/context.h
+++ b/cp/beacon/test/central_beacon/overide/cp/station/inc/context.h
@@ -35,7 +35,6 @@ struct cp_sta_t
uint nid;
uint hm;
- uint tei;
uint ncnr;
uint numslots;
uint slotusage;
diff --git a/cp/beacon/test/central_beacon/src/ac_line_test.c b/cp/beacon/test/central_beacon/src/ac_line_test.c
index e4772cfcfc..62cca9aa6e 100644
--- a/cp/beacon/test/central_beacon/src/ac_line_test.c
+++ b/cp/beacon/test/central_beacon/src/ac_line_test.c
@@ -43,15 +43,23 @@ int main (void)
cp_sta_t *sta;
cp_secu_t *secu;
cp_beacon_t *cp_beacon;
+ ca_t *ca;
+ pbproc_t *pbproc;
+ mac_store_t *mac_store;
uint per_ntb;
trace_init();
test_init(test,0,NULL);
sta = blk_alloc();
- secu = blk_alloc();
+ secu = blk_alloc();
+ pbproc = blk_alloc();
+ ca = blk_alloc();
+ mac_store = blk_alloc();
+
mac_ntb_init((phy_t *) &phy, &mac_config);
- cp_beacon = cp_beacon_init((phy_t *) &phy, sta, secu);
+ cp_beacon = cp_beacon_init((phy_t *) &phy, sta, secu, ca, pbproc,
+ mac_store);
test_case_begin (test, "Frequency detection");
@@ -115,6 +123,9 @@ int main (void)
trace_uninit();
blk_release (sta);
blk_release (secu);
+ blk_release (ca);
+ blk_release (pbproc);
+ blk_release (mac_store);
test_begin(test, "memory test")
{
diff --git a/cp/beacon/test/central_beacon/src/bts_bto_bp.c b/cp/beacon/test/central_beacon/src/bts_bto_bp.c
index 502f008d8c..e1dad7e0ad 100644
--- a/cp/beacon/test/central_beacon/src/bts_bto_bp.c
+++ b/cp/beacon/test/central_beacon/src/bts_bto_bp.c
@@ -70,6 +70,10 @@ test_estimation (test_t test)
cp_secu_t *secu;
mac_config_t mac_config;
cp_beacon_t *cp_beacon;
+
+ ca_t *ca;
+ pbproc_t *pbproc;
+ mac_store_t *mac_store;
uint i;
// Configuring the phy test for this test.
@@ -81,24 +85,33 @@ test_estimation (test_t test)
sta = blk_alloc();
secu = blk_alloc();
+ ca = blk_alloc();
+ mac_store = blk_alloc ();
+ pbproc = blk_alloc ();
+
mac_ntb_init((phy_t *) &phy, &mac_config);
- cp_beacon = cp_beacon_init((phy_t *) &phy, sta, secu);
+ cp_beacon = cp_beacon_init((phy_t *) &phy, sta, secu, ca, pbproc,
+ mac_store);
printf ("Result\n");
for (i = 0; i < 100; i++)
{
- cp_beacon_central_beacon_estimate_bts_bto_bp (cp_beacon);
+ cp_beacon_central_beacon_estimate_bts_bto_bp (cp_beacon,
+ &cp_beacon->cbeacon);
printf ("btse : %d \t bto 0 : %d\t bto 1 : %d \t bto 2 : %d\t bto 3 : %d\n",
- cp_beacon->cbeacon.bts_bto.btse_ntb[0], cp_beacon->cbeacon.bts_bto.bto_ntb[0],
- cp_beacon->cbeacon.bts_bto.bto_ntb[1],cp_beacon->cbeacon.bts_bto.bto_ntb[2],
- cp_beacon->cbeacon.bts_bto.bto_ntb[3]);
+ cp_beacon->cbeacon.btse_ntb[0], (s16) cp_beacon->cbeacon.bto_bpsto.bto[0],
+ (s16) cp_beacon->cbeacon.bto_bpsto.bto[1], (s16) cp_beacon->cbeacon.bto_bpsto.bto[2],
+ (s16) cp_beacon->cbeacon.bto_bpsto.bto[3]);
}
cp_beacon_trace_print(cp_beacon);
cp_beacon_uninit(cp_beacon);
mac_ntb_uninit();
blk_release (sta);
+ blk_release (pbproc);
+ blk_release (ca);
+ blk_release (mac_store);
blk_release (secu);
}
diff --git a/cp/beacon/test/central_beacon/src/central_beacon.c b/cp/beacon/test/central_beacon/src/central_beacon.c
index 31c291a614..fc354ccdfd 100644
--- a/cp/beacon/test/central_beacon/src/central_beacon.c
+++ b/cp/beacon/test/central_beacon/src/central_beacon.c
@@ -41,21 +41,22 @@
#define WORD sizeof(u32)
void
-test_bentries_generation (test_t test);
+test_bentries_generation (void);
void
-test_beacon_process (test_t test);
+test_beacon_process (void);
+
+test_t test;
+cp_beacon_desc_t *beacon;
int
main (void)
{
- test_t test;
-
test_init (test, 0, NULL);
trace_init ();
- test_bentries_generation(test);
- test_beacon_process (test);
+ test_bentries_generation();
+ test_beacon_process ();
trace_uninit();
@@ -71,7 +72,7 @@ main (void)
}
void
-test_bentries_generation (test_t test)
+test_bentries_generation (void)
{
cp_beacon_t *cp_beacon;
u8 cbeacon[512];
@@ -79,6 +80,10 @@ test_bentries_generation (test_t test)
mac_t mac_addr;
mac_config_t mac_config;
+ pbproc_t *pbproc;
+ ca_t *ca;
+ mac_store_t *mac_store;
+
phy_t *phy;
cp_sta_t *sta;
cp_secu_t *secu;
@@ -86,10 +91,16 @@ test_bentries_generation (test_t test)
phy = blk_alloc();
sta = blk_alloc();
secu = blk_alloc();
+
+ pbproc = blk_alloc();
+ ca = blk_alloc();
+ mac_store = blk_alloc();
+
mac_ntb_init ((phy_t *)phy, &mac_config);
- cp_beacon = cp_beacon_init ((phy_t *)phy, sta, secu);
- cp_beacon_central_beacon_estimate_bts_bto_bp (cp_beacon);
+ cp_beacon = cp_beacon_init ((phy_t *)phy, sta, secu, ca, pbproc, mac_store);
+ cp_beacon_central_beacon_estimate_bts_bto_bp (cp_beacon,
+ &cp_beacon->cbeacon);
cp_beacon->bentries_data.cscd = 0x7;
beacon = cbeacon + 1;
@@ -182,7 +193,7 @@ test_bentries_generation (test_t test)
// Create the bpsto
// The test will only verify the bentry header because the bpsto is
// stamped by the pbproc on the send.
- beacon = cp_bentry_bpsto (cp_beacon, cbeacon + 1);
+ beacon = cp_bentry_bpsto (cp_beacon, &cp_beacon->cbeacon, cbeacon + 1);
test_begin (test, "BPSTO")
{
test_fail_if (*(u8*) (cbeacon + 1) != 0x6, "Wrong bentry type");
@@ -252,33 +263,47 @@ test_bentries_generation (test_t test)
blk_release (sta);
blk_release (secu);
+ blk_release (pbproc);
+ blk_release (ca);
+ blk_release (mac_store);
+
cp_beacon_uninit(cp_beacon);
mac_ntb_uninit();
}
void
-test_beacon_process (test_t test)
+test_beacon_process (void)
{
cp_beacon_t *cp_beacon;
cp_sta_t *sta;
cp_secu_t *secu;
mac_config_t *mac_config;
phy_t *phy;
+ ca_t *ca;
+ pbproc_t *pbproc;
+ mac_store_t *mac_store;
- cp_beacon_desc_t *beacon;
u8 *bentries;
u8 *bentry_tmp;
uint bpsto;
// Allocate the data
- sta = blk_alloc();
secu = blk_alloc();
mac_config = blk_alloc();
phy = blk_alloc();
+ ca = blk_alloc();
+ mac_store = blk_alloc ();
+ pbproc = blk_alloc ();
+
+ sta = cp_station_init (mac_store, (cl_t *) mac_config, pbproc, mac_config);
mac_ntb_init (phy, mac_config);
- cp_beacon = cp_beacon_init ((phy_t *)phy, sta, secu);
- cp_beacon_central_beacon_estimate_bts_bto_bp (cp_beacon);
+ cp_beacon = cp_beacon_init ((phy_t *)phy, sta, secu, ca, pbproc, mac_store);
+ cp_beacon_central_beacon_estimate_bts_bto_bp (cp_beacon,
+ &cp_beacon->cbeacon);
+ cp_beacon_central_beacon_estimate_bts_bto_bp (cp_beacon,
+ &cp_beacon->dbeacon);
+
sta->mac_addr = 0x123456789ABC;
@@ -299,14 +324,14 @@ test_beacon_process (test_t test)
beacon->payload->rtsbf = 0x0;
beacon->payload->nm = 0x2;
beacon->payload->cco_cap = 0x0;
- beacon->payload->bmi_nbe = 0x3;
+ beacon->payload->bmi_nbe = 0x4;
bentries = &beacon->payload->bmis;
test_case_begin (test, "Bentries generation test");
bentry_tmp = bentries;
- bentries = cp_bentry_bpsto (cp_beacon, bentries);
+ bentries = cp_bentry_bpsto (cp_beacon, &cp_beacon->cbeacon, bentries);
test_begin(test, "BPSTO")
{
@@ -351,6 +376,20 @@ test_beacon_process (test_t test)
}
test_end;
+
+ bentry_tmp = bentries;
+ bentries = cp_bentry_discover (cp_beacon, bentries, 0xA);
+
+ test_begin (test, "Discover bentry")
+ {
+ test_fail_if (*bentry_tmp != 0x4, "Wrong bentry type, shall be 0x4 \
+ instead of %x\n", *bentry_tmp);
+ test_fail_if (*(bentry_tmp + 1) != 1, "Wrong bentry length, shall be \
+ 0x1 instead of %x\n", *(bentry_tmp + 1));
+ test_fail_if (*(bentry_tmp + 2) != 0xA, "Wrong tei");
+ }
+ test_end;
+
// Read the beacon.
cp_beacon_process (cp_beacon, beacon);
@@ -364,14 +403,27 @@ test_beacon_process (test_t test)
}
test_end;
+ // Launch the same beacon but simulating that the sta which receives it
+ // has been designated by the CCo to send a discover beacon.
+ cp_beacon->last_central_beacon = NULL;
+ sta->mac_config->tei = 0xA;
+ cp_beacon_process (cp_beacon, beacon);
+
+ /*
+ * Warn : Do not release the beacon because the cp_beacon_uninit already
+ * do it if the beacon as been processed.
+ */
+
cp_beacon_uninit (cp_beacon);
mac_ntb_uninit ();
+ cp_sta_uninit (sta);
// Uninit the data
- blk_release (sta);
blk_release (phy);
blk_release (secu);
blk_release (mac_config);
- blk_release_desc ((blk_t *) beacon);
+ blk_release (ca);
+ blk_release (mac_store);
+ blk_release (pbproc);
}
/**
@@ -414,3 +466,50 @@ phy_clock_get_zero_cross_captured_date (phy_t *ctx)
return phy->ntb;
}
+void
+pbproc_mfs_beacon_prepare (pbproc_t *ctx, mfs_tx_t *mfs,
+ u32 beacon_period_start_date, pb_beacon_t *pb,
+ const pbproc_tx_beacon_params_t *params)
+{
+ cp_beacon_desc_t *dbeacon;
+ uint c_payload;
+ uint d_payload;
+ uint i;
+
+ dbg_assert (pb);
+ dbg_assert (beacon);
+
+ test_case_begin (test, "Discover beacon verifycation");
+ dbeacon = (cp_beacon_desc_t *) pb;
+
+ test_begin (test, "Verify NID")
+ {
+ test_fail_if (beacon->nid_msb != dbeacon->nid_msb, "Wrong nid MSB");
+ test_fail_if (beacon->payload->nid_lsb != dbeacon->payload->nid_lsb,
+ "Wrong nid lsb");
+ }
+ test_end;
+
+ test_begin (test, "Paylaod")
+ {
+ memcpy (&c_payload, beacon->payload + 8, 4);
+ memcpy (&d_payload, dbeacon->payload + 8, 4);
+
+ test_fail_if ((c_payload & 0x1FFFFFF0) != (d_payload & 0x1FFFFFF0), "Wrong \
+ payload copy from the central beacon");
+ test_fail_if (dbeacon->payload->bmi_nbe != beacon->payload->bmi_nbe + 1,
+ "Wrong quantity of bentries");
+ test_fail_if (*(&dbeacon->payload->bmis) != CP_BENTRY_DISCOVER_INFO,
+ "Wrong bentruy header for the discover info");
+
+ for (i = 0; i < 122; i++)
+ {
+ test_fail_if (*(&dbeacon->payload->bmis + 6 + i) != *(&beacon->payload->bmis + i),
+ "First Bentry copied from central beacon is false");
+ }
+ }
+ test_end;
+
+ blk_release_desc ((blk_t *) pb);
+}
+