summaryrefslogtreecommitdiff
path: root/cesar/host
diff options
context:
space:
mode:
authorIPMbox Team2012-02-03 14:32:28 +0100
committerNicolas Schodet2012-02-20 10:08:46 +0100
commit3ed571f9d933e5c5dadef650c07e20e8aad06213 (patch)
tree761bfe80d4660605e00f52afb8532d9a2ef847b6 /cesar/host
parent89328e8cc096f8c9f340a3eb8910d06748a3e572 (diff)
cesar, cleopatre, common: new ipmbox design, closes #848
Diffstat (limited to 'cesar/host')
-rw-r--r--cesar/host/test/src/test_netclock.c95
-rw-r--r--cesar/host/test/src/test_sci.c5
2 files changed, 15 insertions, 85 deletions
diff --git a/cesar/host/test/src/test_netclock.c b/cesar/host/test/src/test_netclock.c
index 4ccabcccb8..b892f40ae2 100644
--- a/cesar/host/test/src/test_netclock.c
+++ b/cesar/host/test/src/test_netclock.c
@@ -22,40 +22,6 @@
#include <stdio.h>
extern char dump_buffer[];
-//void netclock_new_test_case(test_t t)
-//{
-// netclock_ctx_t *netclock;
-// station_ctx_t *station;
-//
-// test_case_begin(t, "new");
-// station = station_new();
-//
-// test_begin(t, "station = NULL")
-// {
-// test_fail_unless(
-// (netclock_new(NULL) == NULL)
-// && (errno == EINVAL)
-// );
-// } test_end;
-//
-// test_begin(t, "check new")
-// {
-// test_fail_unless(
-// ((netclock = netclock_new(station)) != NULL)
-// && (netclock->station == station)
-// );
-// } test_end;
-//
-// netclock_free(netclock);
-// station_free(station);
-// return;
-//}
-//
-//void netclock_free_test_case(test_t t)
-//{
-// return
-//}
-
void netclock_init_test_case(test_t t)
{
netclock_ctx_t netclock;
@@ -95,7 +61,6 @@ void netclock_init_test_case(test_t t)
&& (netclock.current_id == 1)
&& (netclock.sci->msg_callback[SCI_MSG_TYPE_NETWORK_CLOCK].function == netclock_recv)
&& (netclock.sci->msg_callback[SCI_MSG_TYPE_NETWORK_CLOCK].data == &netclock)
-// && (set_empty(&netclock.callback_set))
);
} test_end;
@@ -324,37 +289,6 @@ void netclock_schedule_test_case(test_t t)
);
} test_end;
-// test_begin(t, "full registring table")
-// {
-// int i;
-// netclock.callback_nb = NETCLOCK_CALLBACK_MAX_NB;
-// test_fail_unless(
-// (netclock_schedule(&netclock, NETWORK_CLOCK_TYPE_PHY, 0x1234567890abcdefULL, _test_schedule, data) < 0)
-// && (errno == ENOSPC)
-// );
-// netclock.callback_nb = 1;
-//
-// for(i = 0; i < NETCLOCK_CALLBACK_TABLE_SIZE; i++)
-// {
-// netclock.callback_table[i].function = _fake_schedule;
-// }
-// test_fail_unless(
-// (netclock_schedule(&netclock, NETWORK_CLOCK_TYPE_PHY, 0x1234567890abcdefULL, _test_schedule, data) < 0)
-// && (errno == ENOSPC)
-// );
-// } test_end;
-//
-// test_begin(t, "one free slot")
-// {
-// netclock.callback_table[NETCLOCK_CALLBACK_TABLE_SIZE / 2].function = NULL;
-// netclock.callback_nb = NETCLOCK_CALLBACK_TABLE_SIZE - 1;
-// test_fail_unless(
-// (netclock_schedule(&netclock, NETWORK_CLOCK_TYPE_PHY, 0x1234567890abcdefULL, _test_schedule, data) > 0)
-// && (netclock.callback_table[NETCLOCK_CALLBACK_TABLE_SIZE / 2].function == _test_schedule)
-// && (netclock.callback_nb == NETCLOCK_CALLBACK_TABLE_SIZE)
-// );
-// } test_end;
-
station_down(&station);
#ifndef STATION_SOCK
close(fd_in);
@@ -372,7 +306,9 @@ void netclock_unschedule_test_case(test_t t)
int fd_in;
int len;
unsigned char buffer[1024];
-
+ netclock_id_t id1 = 0x1233;
+ netclock_id_t id2 = 0x1234;
+
test_case_begin(t, "unschedule");
station_init(&station);
@@ -388,24 +324,23 @@ void netclock_unschedule_test_case(test_t t)
// reset errno
errno = 0;
} test_end
-
+
test_begin(t, "check unschedule")
{
netclock_callback_t callback1, callback2, cb_ref;
- callback1.id = 0x1233;
- callback1.function = _fake_schedule;
+ callback1.id = id1;
+ callback1.function = &_fake_schedule;
set_node_init(&callback1.node);
- set_insert(&netclock.callback_set, &callback1.node);
- callback2.id = 0x1234;
- callback2.function = _test_schedule;
+ set_insert (&netclock.callback_set, &callback1.node);
+ callback2.id = id2;
+ callback2.function = &_test_schedule;
set_node_init(&callback2.node);
- set_insert(&netclock.callback_set, &callback2.node);
+ set_insert (&netclock.callback_set, &callback2.node);
netclock.callback_nb = 2;
+ cb_ref.id = id1;
set_node_init(&cb_ref.node);
- cb_ref.id = callback2.id;
-
test_fail_unless(
- (netclock_unschedule(&netclock, 0x1234) >= 0)
+ (netclock_unschedule (&netclock, id1) >= 0)
&& (set_find(&netclock.callback_set, &cb_ref.node) == NULL)
&& (netclock.callback_nb == 1)
);
@@ -426,7 +361,7 @@ void netclock_unschedule_test_case(test_t t)
nclock_hdr = (netclock_msg_hdr_t *)(buffer + sizeof(sci_msg_hdr_t));
test_fail_unless(
(nclock_hdr->type == NETWORK_CLOCK_TYPE_REMOVE)
- && (ntohs(nclock_hdr->id) == 0x1234)
+ && (ntohs (nclock_hdr->id) == id1)
);
} test_end;
@@ -434,7 +369,7 @@ void netclock_unschedule_test_case(test_t t)
test_begin(t, "id not exist")
{
test_fail_unless(
- (netclock_unschedule(&netclock, 0x1234) < 0)
+ (netclock_unschedule (&netclock, id1) < 0)
&& (errno == ENOENT)
&& (netclock.callback_nb == 1)
);
@@ -550,8 +485,6 @@ void netclock_recv_test_case(test_t t)
void netclock_test_suite(test_t t)
{
test_suite_begin(t, "netclock");
- //netclock_new_test_case(t);
- //netclock_free_test_case(t);
netclock_init_test_case(t);
netclock_fill_hdr_test_case(t);
netclock_schedule_test_case(t);
diff --git a/cesar/host/test/src/test_sci.c b/cesar/host/test/src/test_sci.c
index 8ffc1d06a3..833f710f6c 100644
--- a/cesar/host/test/src/test_sci.c
+++ b/cesar/host/test/src/test_sci.c
@@ -130,9 +130,7 @@ void sci_fill_hdr_test_case(test_t t)
sci_ctx_t sci;
sci_msg_t msg;
unsigned char buffer[128];
- unsigned short previous_msg_id;
-
-
+
test_case_begin(t, "fill_hdr");
test_begin(t, "init msg")
@@ -193,7 +191,6 @@ void sci_fill_hdr_test_case(test_t t)
&& (EINVAL != errno)
&& (ENOSPC != errno)
);
- previous_msg_id = sci.current_msg_id;
test_fail_unless(
(sci_fill_hdr(&sci, &msg, SCI_MSG_TYPE_SYSTEM, 0xaa55) >= 0)
&& ((unsigned char *)msg.sci_hdr == msg.data_begin)