summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cesar/mac/common/src/store.c1
-rw-r--r--cesar/mac/common/test/sta/Makefile7
-rw-r--r--cesar/mac/common/test/sta/src/test_sta.c44
3 files changed, 52 insertions, 0 deletions
diff --git a/cesar/mac/common/src/store.c b/cesar/mac/common/src/store.c
index 9ed93a6157..f74cfaef83 100644
--- a/cesar/mac/common/src/store.c
+++ b/cesar/mac/common/src/store.c
@@ -471,6 +471,7 @@ mac_store_sta_add_ (mac_store_t *ctx, uint tei __FL)
arch_dsr_lock ();
if (!ctx->sta[tei])
{
+ dbg_assert (sizeof (sta_t) <= BLK_SIZE);
sta = blk_new_ ((blk_destructor_t) sta_uninit __fl);
sta_init (&sta->sta, tei);
/* Clear the new STA tables. */
diff --git a/cesar/mac/common/test/sta/Makefile b/cesar/mac/common/test/sta/Makefile
new file mode 100644
index 0000000000..5900f171ab
--- /dev/null
+++ b/cesar/mac/common/test/sta/Makefile
@@ -0,0 +1,7 @@
+BASE = ../../../..
+
+HOST_PROGRAMS = test_sta
+test_sta_SOURCES = test_sta.c
+test_sta_MODULES = lib mac/common
+
+include $(BASE)/common/make/top.mk
diff --git a/cesar/mac/common/test/sta/src/test_sta.c b/cesar/mac/common/test/sta/src/test_sta.c
new file mode 100644
index 0000000000..509f05d773
--- /dev/null
+++ b/cesar/mac/common/test/sta/src/test_sta.c
@@ -0,0 +1,44 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2011 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/test_sta.c
+ * \brief Test for mac/common/sta
+ * \ingroup test
+ *
+ */
+#include "common/std.h"
+#include "lib/blk.h"
+#include "lib/test.h"
+#include "mac/common/store.h"
+
+void
+sta_test_suite (test_t t)
+{
+ test_suite_begin (t, "Sta");
+ test_begin (t, "sta_t structure size test")
+ {
+ mac_store_t *ctx = mac_store_init ();
+ mac_store_sta_add (ctx, 42);
+ test_fail_unless (mac_store_sta_remove (ctx, 42));
+ mac_store_uninit (ctx);
+ } test_end;
+}
+
+int
+main (int argc, char **argv)
+{
+ test_t t;
+ test_init (t, argc, argv);
+ sta_test_suite (t);
+ test_result (t);
+ test_begin (t, "Memory check")
+ {
+ test_fail_unless (blk_check_memory ());
+ } test_end;
+ return test_nb_failed (t) == 0 ? 0 : 1;
+}