summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschodet2008-07-11 14:07:26 +0000
committerschodet2008-07-11 14:07:26 +0000
commit9b7b18b31c2a73dbf1309ec81512331517c811ff (patch)
treed6662a47e966e07e874291c7fc67444596667e15
parent1fd023261360d27d9e03ea726855fde166337be4 (diff)
* cp2/sta/action/test/utest:
- added test context. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@2602 017c9cb6-072f-447c-8318-d5b54f68fe89
-rw-r--r--cesar/cp2/sta/action/test/utest/inc/test_sta_action.h39
-rw-r--r--cesar/cp2/sta/action/test/utest/override/cp2/inc/context.h1
-rw-r--r--cesar/cp2/sta/action/test/utest/src/assoc.c23
-rw-r--r--cesar/cp2/sta/action/test/utest/src/drv.c28
-rw-r--r--cesar/cp2/sta/action/test/utest/src/info.c46
-rw-r--r--cesar/cp2/sta/action/test/utest/src/test_sta_action.c16
6 files changed, 103 insertions, 50 deletions
diff --git a/cesar/cp2/sta/action/test/utest/inc/test_sta_action.h b/cesar/cp2/sta/action/test/utest/inc/test_sta_action.h
new file mode 100644
index 0000000000..e67c36ed7e
--- /dev/null
+++ b/cesar/cp2/sta/action/test/utest/inc/test_sta_action.h
@@ -0,0 +1,39 @@
+#ifndef inc_test_sta_action_h
+#define inc_test_sta_action_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file inc/test_sta_action.h
+ * \brief Test sta/action.
+ * \ingroup test
+ */
+#include "cp2/inc/context.h"
+
+/** Contexts used in tests. */
+struct test_sta_action_t
+{
+ cp_t cp;
+ mac_config_t mac_config;
+};
+typedef struct test_sta_action_t test_sta_action_t;
+
+/**
+ * Initialise test contexts.
+ * \param ctx test context
+ */
+void
+test_sta_action_init (test_sta_action_t *ctx);
+
+/**
+ * Uninitialise test contexts.
+ * \param ctx test context
+ */
+void
+test_sta_action_uninit (test_sta_action_t *ctx);
+
+#endif /* inc_test_sta_action_h */
diff --git a/cesar/cp2/sta/action/test/utest/override/cp2/inc/context.h b/cesar/cp2/sta/action/test/utest/override/cp2/inc/context.h
index 3c1a4764cd..ce288a9c8f 100644
--- a/cesar/cp2/sta/action/test/utest/override/cp2/inc/context.h
+++ b/cesar/cp2/sta/action/test/utest/override/cp2/inc/context.h
@@ -12,6 +12,7 @@
* \brief Control plane context override.
* \ingroup test
*/
+#include "cp2/types.h"
#include "cp2/sta/action/inc/context.h"
#include "cp2/sta/mgr/sta_mgr.h"
#include "cp2/sta/mgr/inc/sta_mgr.h"
diff --git a/cesar/cp2/sta/action/test/utest/src/assoc.c b/cesar/cp2/sta/action/test/utest/src/assoc.c
index 6c6785ad9d..7d4d5953da 100644
--- a/cesar/cp2/sta/action/test/utest/src/assoc.c
+++ b/cesar/cp2/sta/action/test/utest/src/assoc.c
@@ -14,26 +14,25 @@
#include "lib/scenario/scenario.h"
-#include "cp2/inc/context.h"
+#include "inc/test_sta_action.h"
void
assoc_basic_test_case (test_t t)
{
- cp_t cp;
+ test_sta_action_t ctx;
+ test_sta_action_init (&ctx);
scenario_globals_t globals = {
- .cp = &cp,
+ .cp = &ctx.cp,
};
- lib_rnd_init (&cp.rnd, 1234);
- cp_sta_mgr_init (&cp);
test_case_begin (t, "basic");
/* Create a CCo to associate with. */
const cp_snid_t snid = 2;
const cp_nid_t nid = 0xf11111111111ull;
- cp_net_t *cco_net = cp_sta_mgr_add_avln (&cp, snid, nid);
+ cp_net_t *cco_net = cp_sta_mgr_add_avln (&ctx.cp, snid, nid);
dbg_assert (cco_net);
const cp_tei_t cco_tei = 1, sta_tei = 2;
const mac_t cco_mac = 0x111111111111ull;
- cp_sta_t *cco = cp_net_sta_add (&cp, cco_net, cco_tei, cco_mac);
+ cp_sta_t *cco = cp_net_sta_add (&ctx.cp, cco_net, cco_tei, cco_mac);
cp_mme_peer_t cco_peer = CP_MME_PEER (cco_mac, cco_tei);
/* Association test. */
test_begin (t, "assoc")
@@ -64,13 +63,13 @@ assoc_basic_test_case (test_t t)
SCENARIO_END
};
scenario_run (t, entries, &globals);
- cp_net_t *our_net = cp_sta_mgr_get_our_avln (&cp);
- test_fail_unless (cp_net_get_nid (&cp, our_net) == nid);
- test_fail_unless (cp_net_get_snid (&cp, our_net) == snid);
- test_fail_unless (cp_sta_own_data_get_tei (&cp) == sta_tei);
+ cp_net_t *our_net = cp_sta_mgr_get_our_avln (&ctx.cp);
+ test_fail_unless (cp_net_get_nid (&ctx.cp, our_net) == nid);
+ test_fail_unless (cp_net_get_snid (&ctx.cp, our_net) == snid);
+ test_fail_unless (cp_sta_own_data_get_tei (&ctx.cp) == sta_tei);
} test_end;
slab_release (cco);
- cp_sta_mgr_uninit (&cp);
+ test_sta_action_uninit (&ctx);
}
void
diff --git a/cesar/cp2/sta/action/test/utest/src/drv.c b/cesar/cp2/sta/action/test/utest/src/drv.c
index 40518f310d..d87b39d221 100644
--- a/cesar/cp2/sta/action/test/utest/src/drv.c
+++ b/cesar/cp2/sta/action/test/utest/src/drv.c
@@ -14,7 +14,7 @@
#include "lib/scenario/scenario.h"
-#include "cp2/inc/context.h"
+#include "inc/test_sta_action.h"
#include <string.h>
@@ -80,15 +80,13 @@ drv_check_params (cp_t *ctx,
static void
drv_basic_test_case (test_t t)
{
- cp_t cp;
- mac_config_t mac_config;
- cp.mac_config = &mac_config;
+ test_sta_action_t ctx;
+ test_sta_action_init (&ctx);
cp_mme_peer_t peer = CP_MME_PEER (0xaabbccddeeffull);
- cp_sta_mgr_init (&cp);
test_case_begin (t, "basic");
test_begin (t, "set")
{
- drv_set_params (&cp, MAC_BROADCAST, false, false, "", "",
+ drv_set_params (&ctx.cp, MAC_BROADCAST, false, false, "", "",
CP_SECURITY_LEVEL_SC, 1, "", "", "", NULL);
u32 tonemask[PHY_TONEMASK_WORDS];
uint i;
@@ -208,17 +206,17 @@ drv_basic_test_case (test_t t)
SCENARIO_END
};
scenario_globals_t globals = {
- .cp = &cp,
+ .cp = &ctx.cp,
};
scenario_run (t, entries, &globals);
- drv_check_params (&cp, t, 0x112233445566ull, true, true, "p4ssw0rd",
- "s3cr3t", CP_SECURITY_LEVEL_HS, 0x002233445566ull,
- "the M STA HFID", "the U STA HFID", "the AVLN HFID",
- NULL);
+ drv_check_params (&ctx.cp, t, 0x112233445566ull, true, true,
+ "p4ssw0rd", "s3cr3t", CP_SECURITY_LEVEL_HS,
+ 0x002233445566ull, "the M STA HFID",
+ "the U STA HFID", "the AVLN HFID", NULL);
} test_end;
test_begin (t, "set error")
{
- drv_set_params (&cp, MAC_BROADCAST, false, false, "", "",
+ drv_set_params (&ctx.cp, MAC_BROADCAST, false, false, "", "",
CP_SECURITY_LEVEL_SC, 1, "", "", "", NULL);
scenario_entry_t entries[] = {
/* Set MAC address. */
@@ -323,13 +321,13 @@ drv_basic_test_case (test_t t)
SCENARIO_END
};
scenario_globals_t globals = {
- .cp = &cp,
+ .cp = &ctx.cp,
};
scenario_run (t, entries, &globals);
- drv_check_params (&cp, t, MAC_BROADCAST, false, false, "", "",
+ drv_check_params (&ctx.cp, t, MAC_BROADCAST, false, false, "", "",
CP_SECURITY_LEVEL_SC, 1, "", "", "", NULL);
} test_end;
- cp_sta_mgr_uninit (&cp);
+ test_sta_action_uninit (&ctx);
}
void
diff --git a/cesar/cp2/sta/action/test/utest/src/info.c b/cesar/cp2/sta/action/test/utest/src/info.c
index 5cada74e21..658920baf0 100644
--- a/cesar/cp2/sta/action/test/utest/src/info.c
+++ b/cesar/cp2/sta/action/test/utest/src/info.c
@@ -14,7 +14,7 @@
#include "lib/scenario/scenario.h"
-#include "cp2/inc/context.h"
+#include "inc/test_sta_action.h"
#include "lib/slab.h"
@@ -68,12 +68,12 @@ info_set_tei_map_check (test_t t, cp_t *cp, info_set_tei_map_check_t *check)
static void
info_set_tei_map_test_cases (test_t t)
{
- cp_t cp;
+ test_sta_action_t ctx;
+ test_sta_action_init (&ctx);
scenario_globals_t globals = {
- .cp = &cp,
+ .cp = &ctx.cp,
};
cp_mme_peer_t peer = CP_MME_PEER (0xaabbccddeeffull);
- cp_sta_mgr_init (&cp);
test_case_begin (t, "set_tei_map");
test_begin (t, "add first")
{
@@ -97,7 +97,7 @@ info_set_tei_map_test_cases (test_t t)
{ 1, 0x111111111111ull, true },
INFO_SET_TEI_MAP_CHECK_END
};
- info_set_tei_map_check (t, &cp, stmc);
+ info_set_tei_map_check (t, &ctx.cp, stmc);
} test_end;
test_begin (t, "add second and third")
{
@@ -127,7 +127,7 @@ info_set_tei_map_test_cases (test_t t)
{ 3, 0x333333333333ull, true },
INFO_SET_TEI_MAP_CHECK_END
};
- info_set_tei_map_check (t, &cp, stmc);
+ info_set_tei_map_check (t, &ctx.cp, stmc);
} test_end;
test_begin (t, "delete")
{
@@ -152,7 +152,7 @@ info_set_tei_map_test_cases (test_t t)
{ 3, 0x333333333333ull, true },
INFO_SET_TEI_MAP_CHECK_END
};
- info_set_tei_map_check (t, &cp, stmc);
+ info_set_tei_map_check (t, &ctx.cp, stmc);
} test_end;
test_begin (t, "update")
{
@@ -181,7 +181,7 @@ info_set_tei_map_test_cases (test_t t)
{ 4, 0x444444444444ull, false },
INFO_SET_TEI_MAP_CHECK_END
};
- info_set_tei_map_check (t, &cp, stmc);
+ info_set_tei_map_check (t, &ctx.cp, stmc);
} test_end;
test_begin (t, "update add specials")
{
@@ -240,7 +240,7 @@ info_set_tei_map_test_cases (test_t t)
{ 0xfe, 0xfefefefefefeull, false },
INFO_SET_TEI_MAP_CHECK_END
};
- info_set_tei_map_check (t, &cp, stmc);
+ info_set_tei_map_check (t, &ctx.cp, stmc);
} test_end;
test_begin (t, "update remove specials")
{
@@ -269,7 +269,7 @@ info_set_tei_map_test_cases (test_t t)
{ 4, 0x444444444444ull, false },
INFO_SET_TEI_MAP_CHECK_END
};
- info_set_tei_map_check (t, &cp, stmc);
+ info_set_tei_map_check (t, &ctx.cp, stmc);
} test_end;
test_case_begin (t, "set_tei_map errors");
test_begin (t, "initial error")
@@ -288,7 +288,7 @@ info_set_tei_map_test_cases (test_t t)
{ 4, 0x444444444444ull, false },
INFO_SET_TEI_MAP_CHECK_END
};
- info_set_tei_map_check (t, &cp, stmc);
+ info_set_tei_map_check (t, &ctx.cp, stmc);
} test_end;
test_begin (t, "add error")
{
@@ -316,7 +316,7 @@ info_set_tei_map_test_cases (test_t t)
{ 5, 0x555555555555ull, false },
INFO_SET_TEI_MAP_CHECK_END
};
- info_set_tei_map_check (t, &cp, stmc);
+ info_set_tei_map_check (t, &ctx.cp, stmc);
} test_end;
test_begin (t, "update error")
{
@@ -344,9 +344,9 @@ info_set_tei_map_test_cases (test_t t)
{ 5, 0x555555555555ull, true },
INFO_SET_TEI_MAP_CHECK_END
};
- info_set_tei_map_check (t, &cp, stmc);
+ info_set_tei_map_check (t, &ctx.cp, stmc);
} test_end;
- cp_sta_mgr_uninit (&cp);
+ test_sta_action_uninit (&ctx);
}
struct info_unassociated_sta_check_t
@@ -385,11 +385,11 @@ info_unassociated_sta_check (test_t t, cp_t *cp,
static void
info_unassociated_sta_test_cases (test_t t)
{
- cp_t cp;
+ test_sta_action_t ctx;
+ test_sta_action_init (&ctx);
scenario_globals_t globals = {
- .cp = &cp,
+ .cp = &ctx.cp,
};
- cp_sta_mgr_init (&cp);
test_case_begin (t, "unassociated_sta");
test_begin (t, "add one")
{
@@ -406,7 +406,7 @@ info_unassociated_sta_test_cases (test_t t)
{ 0x111111111111ull, 0xf11111111111ull, 0, true },
INFO_UNASSOCIATED_STA_CHECK_END
};
- info_unassociated_sta_check (t, &cp, usc);
+ info_unassociated_sta_check (t, &ctx.cp, usc);
} test_end;
test_begin (t, "add more")
{
@@ -450,7 +450,7 @@ info_unassociated_sta_test_cases (test_t t)
{ 0xbbbbbbbbbbbbull, 0xf22222222222ull, 2, true },
INFO_UNASSOCIATED_STA_CHECK_END
};
- info_unassociated_sta_check (t, &cp, usc);
+ info_unassociated_sta_check (t, &ctx.cp, usc);
} test_end;
test_begin (t, "updates")
{
@@ -479,7 +479,7 @@ info_unassociated_sta_test_cases (test_t t)
{ 0xbbbbbbbbbbbbull, 0xf22222222222ull, 2, true },
INFO_UNASSOCIATED_STA_CHECK_END
};
- info_unassociated_sta_check (t, &cp, usc);
+ info_unassociated_sta_check (t, &ctx.cp, usc);
} test_end;
/* TODO: NID change? */
test_case_begin (t, "unassociated_sta errors");
@@ -504,7 +504,7 @@ info_unassociated_sta_test_cases (test_t t)
{ 0x888888888888ull, 0xf88888888888ull, 0, false },
INFO_UNASSOCIATED_STA_CHECK_END
};
- info_unassociated_sta_check (t, &cp, usc);
+ info_unassociated_sta_check (t, &ctx.cp, usc);
} test_end;
test_begin (t, "no room error")
{
@@ -546,9 +546,9 @@ info_unassociated_sta_test_cases (test_t t)
{ 0x888888888888ull, 0xf88888888888ull, 0, false },
INFO_UNASSOCIATED_STA_CHECK_END
};
- info_unassociated_sta_check (t, &cp, usc);
+ info_unassociated_sta_check (t, &ctx.cp, usc);
} test_end;
- cp_sta_mgr_uninit (&cp);
+ test_sta_action_uninit (&ctx);
}
void
diff --git a/cesar/cp2/sta/action/test/utest/src/test_sta_action.c b/cesar/cp2/sta/action/test/utest/src/test_sta_action.c
index a60c237f41..0a8c957742 100644
--- a/cesar/cp2/sta/action/test/utest/src/test_sta_action.c
+++ b/cesar/cp2/sta/action/test/utest/src/test_sta_action.c
@@ -12,6 +12,8 @@
*/
#include "common/std.h"
+#include "inc/test_sta_action.h"
+
#include "lib/test.h"
void
@@ -23,6 +25,20 @@ drv_test_suite (test_t t);
void
info_test_suite (test_t t);
+void
+test_sta_action_init (test_sta_action_t *ctx)
+{
+ ctx->cp.mac_config = &ctx->mac_config;
+ cp_sta_mgr_init (&ctx->cp);
+ lib_rnd_init (&ctx->cp.rnd, 1234);
+}
+
+void
+test_sta_action_uninit (test_sta_action_t *ctx)
+{
+ cp_sta_mgr_uninit (&ctx->cp);
+}
+
int
main (int argc, char **argv)
{