#ifndef bsu_test_utest_tests_h #define bsu_test_utest_tests_h /* Cesar project {{{ * * Copyright (C) 2010 Spidcom * * <<>> * * }}} */ /** * \file bsu/test/utest/tests.h * \brief Test environment. * \ingroup bsu */ #include "lib/test.h" #include "bsu/bsu.h" #include "lib/test.h" #include "mac/common/store.h" #include "mac/common/config.h" #include "mac/pbproc/pbproc.h" #include "mac/sar/sar.h" #include "bsu/beacon/beacon.h" struct bsu_aclf_test_phy_t { /** Frequency simulation. */ float frequency_hz; /** Phy date. */ u32 phy_date; /** Zero crossing. */ u32 zero_crossing_date; /** False to use phy clock function to make time goes on, * or false to increase time by 1000 ticks on phy_date function call. */ bool use_phy_clock; }; typedef struct bsu_aclf_test_phy_t bsu_aclf_test_phy_t; struct bsu_test_ca_t { /* Beacon periods computed for the CA. */ ca_beacon_period_t beacon_periods[CA_BEACON_PERIOD_NB]; /* Number of beacon periods. */ uint nb_beacon_periods; }; typedef struct bsu_test_ca_t bsu_test_ca_t; struct bsu_test_sar_t { /** Beacon sent. */ pb_beacon_t *beacon; /** MFS used. */ mfs_tx_t *mfs; /** BTO and BPSTO address. */ void *bto_bpsto; }; typedef struct bsu_test_sar_t bsu_test_sar_t; struct bsu_test_ul_t { /** Beacon sent. */ bsu_beacon_t *beacon; }; typedef struct bsu_test_ul_t bsu_test_ul_t; struct bsu_test_t { /** Mac config. */ mac_config_t mac_config; /** Mac store. */ mac_store_t *mac_store; /** Channel Access context. */ bsu_test_ca_t ca; /** Phy simulated context. */ bsu_aclf_test_phy_t *phy; /** Sar context. */ bsu_test_sar_t sar; /** Upper layer context. */ bsu_test_ul_t ul; /** BSU. */ bsu_t *bsu; /** Hal timer. */ hal_timer_t *timer; }; typedef struct bsu_test_t bsu_test_t; BEGIN_DECLS /** * Initialise the upper layer stub to INVALID_PTR. * \param ctx the test module context. */ void bsu_test_upper_layer_beacon_received_init (bsu_test_t *ctx); /** * Initialise the test unit. * \param ctx the tests context. */ void bsu_test_init (bsu_test_t *ctx); /** * Uninitialise the test unit. * \param ctx the tests context. */ void bsu_test_uninit (bsu_test_t *ctx); /** * Create a beacon. * \param beacon structure to fill. * * Creates a beacon with 2 regions, 2 non persistent allocations, 2 Persistent * allocations. */ void bsu_test_create_beacon (bsu_test_t *ctx, bsu_beacon_t *beacon); /** * Verify the data present in the generated beacon are equal to the one in the * bsu beacon. * \param t test context. * \param ctx the bsu_test context. * \param beacon the bsu data beacon. * \param phy_beacon the beacon generated by the bsu. * \param type the beacon type. * * \Warn the TEI in the phy_beacon is compared with the TEI in the mac * config. */ void bsu_test_beacon_check_generation (test_t t, bsu_test_t *ctx, bsu_beacon_t *beacon, pb_beacon_t *phy_beacon, bsu_beacon_type_t type); /** * Verify the read data corresponds to the one provided to generate the * beacon. * \param t test context. * \param ctx the bsu_test context. * \param beacon the bsu data beacon. * \param sched the schedules filled with the data in the real beacon. */ void bsu_test_beacon_check_read (test_t t, bsu_test_t *ctx, bsu_beacon_t *beacon, bsu_avln_t *sched); /** * Fill the station AVLN object with test values. * \param ctx the bsu_test context. * \param avln the AVLN object to fill. */ void bsu_test_avln_create (bsu_test_t *ctx, bsu_avln_t *avln); void phy_clock (bsu_aclf_test_phy_t *ctx, u32 ticks); void bsu_test_reset_phy (bsu_aclf_test_phy_t *ctx); bsu_avln_t* bsu_avln_get (bsu_t *ctx, u64 nid, u8 snid, mac_t mac); END_DECLS #endif /* bsu_test_utest_tests_h */