summaryrefslogtreecommitdiff
path: root/cesar/cl/test/src/cl_mactotei_find.c
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/cl/test/src/cl_mactotei_find.c')
-rw-r--r--cesar/cl/test/src/cl_mactotei_find.c96
1 files changed, 96 insertions, 0 deletions
diff --git a/cesar/cl/test/src/cl_mactotei_find.c b/cesar/cl/test/src/cl_mactotei_find.c
new file mode 100644
index 0000000000..7f6c0467e5
--- /dev/null
+++ b/cesar/cl/test/src/cl_mactotei_find.c
@@ -0,0 +1,96 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cl/test/src/cl_mactotei_find.c
+ * \brief test of the cl mac to tei function find.
+ * \ingroup cl/test/src
+ *
+ */
+
+#include "common/std.h"
+#include "lib/test.h"
+#include "lib/rnd.h"
+#include "lib/trace.h"
+
+#include "cl/cl_mactotei.h"
+#include "cl/cl.h"
+
+#include "cl/inc/cl_mactotei.h"
+#include "cl/inc/cl.h"
+#include "cl/inc/context.h"
+#include "cl/inc/trace.h"
+
+#include "mac/common/ntb.h"
+#include "hal/phy/phy.h"
+
+#include <stdio.h>
+
+int main (void)
+{
+ test_t test;
+ cl_t *cl;
+ cl_mactotei_blk_t *table;
+ uint count;
+ sar_t *sar;
+ pbproc_t *pbproc;
+ mac_config_t *mac_config;
+ mac_store_t *mac_store;
+ phy_t *phy;
+
+ trace_init ();
+ test_init (test, 0, NULL);
+ mac_store = mac_store_init ();
+ mac_config = blk_alloc ();
+ phy = blk_alloc ();
+ mac_ntb_init(phy, mac_config);
+ pbproc = pbproc_init (mac_config, mac_store);
+ sar = sar_init (mac_store, pbproc, NULL);
+ mac_config->tei = 10;
+ cl = cl_init (mac_store, sar, mac_config);
+ table = cl_mactotei_new ();
+
+ for (count = 0; count < 120; count ++)
+ {
+ cl_mactotei_addr_add (table, count * 2, count, count);
+ }
+
+ cl_mactotei_use_table (cl, table);
+
+ test_begin (test, "Search for tei with the mac @ == tei")
+ {
+ for (count = 0; count < 120; count ++)
+ {
+ test_fail_if (cl_mactotei_table_find_tei_from_mac(cl, count * 2) != count, "Wrong tei for mac @ : %d", count);
+ }
+ }
+ test_end;
+ cl_mactotei_table_find_tei_from_mac (cl, count * 2);
+
+ test_begin (test, "Search for a mac @ which does not exists")
+ {
+ test_fail_if (cl_mactotei_table_find_tei_from_mac(cl, 121) != 0x0, "Wrong tei for mac @ 121");
+ }
+ test_end;
+
+ cl_trace_print (cl);
+ cl_uninit (cl);
+ mac_store_uninit (mac_store);
+ blk_release (mac_config);
+ blk_release (phy);
+ pbproc_uninit (pbproc);
+ sar_uninit (sar);
+
+ test_begin (test, "Memory test")
+ {
+ test_fail_if (blk_check_memory() == false, "Memory not freed");
+ }
+ test_end;
+
+ test_result (test);
+ return test_nb_failed (test) == 0 ? 0 : 1;
+}