summaryrefslogtreecommitdiff
path: root/hal/phy/maximus/test/src/test_phy_ctrl.c
diff options
context:
space:
mode:
authorlefranc2008-01-04 09:55:19 +0000
committerlefranc2008-01-04 09:55:19 +0000
commita42c5d2e7f1fda6539122928ab42ba4690af86df (patch)
tree492f4577e083a57de9de87d16cf6eced1255c467 /hal/phy/maximus/test/src/test_phy_ctrl.c
parent20c8ffeb7a0607c6edd9305b67367f1665673898 (diff)
- added socket implementation for maximus to station communication
- you need to define "STATION_SOCK" into host/config.h to enable socket communication git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1211 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'hal/phy/maximus/test/src/test_phy_ctrl.c')
-rw-r--r--hal/phy/maximus/test/src/test_phy_ctrl.c161
1 files changed, 156 insertions, 5 deletions
diff --git a/hal/phy/maximus/test/src/test_phy_ctrl.c b/hal/phy/maximus/test/src/test_phy_ctrl.c
index e9238bc1c0..0b63b69595 100644
--- a/hal/phy/maximus/test/src/test_phy_ctrl.c
+++ b/hal/phy/maximus/test/src/test_phy_ctrl.c
@@ -888,8 +888,12 @@ void phy_uninit_test_case(test_t t)
int fd_in = -1;
// open pipe
+#ifdef STATION_SOCK
+ fd_in = my_station.sock_pair_fd;
+#else /* STATION_SOCK */
fd_in = open(my_station.pipe_out_name, O_RDONLY);
-
+#endif /* STATION_SOCK */
+
// read sci and netclock headers
memset(data, '\0', 256);
test_fail_unless ((-1 != fd_in)
@@ -906,7 +910,9 @@ void phy_uninit_test_case(test_t t)
test_fail_unless (ntohs(netclock_hdr->id) == ctx->control.extra_timer_program_netclock_id);
// close pipe
+#ifndef STATION_SOCK
close(fd_in);
+#endif /* !STATION_SOCK */
} test_end;
id = ctx->control.extra_timer_program_netclock_id;
@@ -930,7 +936,11 @@ void phy_uninit_test_case(test_t t)
int fd_in = -1;
// open pipe
+#ifdef STATION_SOCK
+ fd_in = my_station.sock_pair_fd;
+#else /* STATION_SOCK */
fd_in = open(my_station.pipe_out_name, O_RDONLY);
+#endif /* STATION_SOCK */
// read sci and netclock headers
memset(data, '\0', 256);
@@ -945,7 +955,9 @@ void phy_uninit_test_case(test_t t)
test_fail_unless (ntohs(netclock_hdr->id) == id);
// close pipe
+#ifndef STATION_SOCK
close(fd_in);
+#endif /* !STATION_SOCK */
} test_end;
maximus_pending_isrs = 0;
@@ -1158,7 +1170,11 @@ void phy_tx_frame_test_case(test_t t)
set_node_t *found_node;
// open pipe
+#ifdef STATION_SOCK
+ fd_in = my_station.sock_pair_fd;
+#else /* STATION_SOCK */
fd_in = open(my_station.pipe_out_name, O_RDONLY);
+#endif /* STATION_SOCK */
// read sci header
test_fail_unless ((-1 != fd_in)
@@ -1178,7 +1194,9 @@ void phy_tx_frame_test_case(test_t t)
my_station.current_tick_tck = msg_tick_tck;
// close pipe
+#ifndef STATION_SOCK
close(fd_in);
+#endif /* !STATION_SOCK */
/* Remove netclock callback. */
@@ -1242,7 +1260,11 @@ void phy_tx_frame_test_case(test_t t)
date += duration_in_ticks;
// open pipe
+#ifdef STATION_SOCK
+ fd_in = my_station.sock_pair_fd;
+#else /* STATION_SOCK */
fd_in = open(my_station.pipe_out_name, O_RDONLY);
+#endif /* STATION_SOCK */
// read sci header
test_fail_unless ((-1 != fd_in)
@@ -1262,7 +1284,9 @@ void phy_tx_frame_test_case(test_t t)
my_station.current_tick_tck = msg_tick_tck;
// close pipe
+#ifndef STATION_SOCK
close(fd_in);
+#endif /* !STATION_SOCK */
/* Remove netclock callback. */
@@ -1294,7 +1318,11 @@ void phy_tx_frame_test_case(test_t t)
int fd_in = -1;
// open pipe
+#ifdef STATION_SOCK
+ fd_in = my_station.sock_pair_fd;
+#else /* STATION_SOCK */
fd_in = open(my_station.pipe_out_name, O_RDONLY);
+#endif /* STATION_SOCK */
// read sci header
test_fail_unless ((-1 != fd_in)
@@ -1307,7 +1335,9 @@ void phy_tx_frame_test_case(test_t t)
test_fail_unless (date2 == ntohl(netclock_hdr.tick_low));
// close pipe
+#ifndef STATION_SOCK
close(fd_in);
+#endif /* !STATION_SOCK */
} test_end;
// test the second callback
@@ -1326,7 +1356,11 @@ void phy_tx_frame_test_case(test_t t)
int fd_in = -1;
// open pipe
+#ifdef STATION_SOCK
+ fd_in = my_station.sock_pair_fd;
+#else /* STATION_SOCK */
fd_in = open(my_station.pipe_out_name, O_RDONLY);
+#endif /* STATION_SOCK */
// read sci and phy headers
memset(data, '\0', SCI_MSG_MAX_SIZE);
@@ -1342,7 +1376,9 @@ void phy_tx_frame_test_case(test_t t)
test_fail_unless (PHY_TYPE_PREAMBLE == phy_hdr->type);
// close pipe
+#ifndef STATION_SOCK
close(fd_in);
+#endif /* !STATION_SOCK */
} test_end;
// check that the correct netclock message has been sent to Maximus
@@ -1376,7 +1412,11 @@ void phy_tx_frame_test_case(test_t t)
date += duration_in_ticks;
// open pipe
+#ifdef STATION_SOCK
+ fd_in = my_station.sock_pair_fd;
+#else /* STATION_SOCK */
fd_in = open(my_station.pipe_out_name, O_RDONLY);
+#endif /* STATION_SOCK */
// read sci header
test_fail_unless ((-1 != fd_in)
@@ -1396,7 +1436,9 @@ void phy_tx_frame_test_case(test_t t)
my_station.current_tick_tck = msg_tick_tck;
// close pipe
+#ifndef STATION_SOCK
close(fd_in);
+#endif /* !STATION_SOCK */
/* Remove netclock callback. */
@@ -1428,7 +1470,11 @@ void phy_tx_frame_test_case(test_t t)
int fd_in = -1;
// open pipe
+#ifdef STATION_SOCK
+ fd_in = my_station.sock_pair_fd;
+#else /* STATION_SOCK */
fd_in = open(my_station.pipe_out_name, O_RDONLY);
+#endif /* STATION_SOCK */
// read sci and phy headers
memset(data, '\0', SCI_MSG_MAX_SIZE);
@@ -1451,7 +1497,9 @@ void phy_tx_frame_test_case(test_t t)
test_fail_unless (0 == memcmp(&ctx->control.current_tx_param.fc_av, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+sizeof(u32), 4*sizeof(u32)));
// close pipe
+#ifndef STATION_SOCK
close(fd_in);
+#endif /* !STATION_SOCK */
} test_end;
// check that the correct netclock message has been sent to Maximus
@@ -1482,7 +1530,11 @@ void phy_tx_frame_test_case(test_t t)
date += duration_in_ticks;
// open pipe
+#ifdef STATION_SOCK
+ fd_in = my_station.sock_pair_fd;
+#else /* STATION_SOCK */
fd_in = open(my_station.pipe_out_name, O_RDONLY);
+#endif /* STATION_SOCK */
// read sci header
test_fail_unless ((-1 != fd_in)
@@ -1502,7 +1554,9 @@ void phy_tx_frame_test_case(test_t t)
my_station.current_tick_tck = msg_tick_tck;
// close pipe
+#ifndef STATION_SOCK
close(fd_in);
+#endif /* !STATION_SOCK */
/* Remove netclock callback. */
@@ -1570,7 +1624,11 @@ void phy_tx_frame_test_case(test_t t)
phy_pb_tx_t *current_pb = &ctx->pbdma.first_pb->pb_tx;
// open pipe
+#ifdef STATION_SOCK
+ fd_in = my_station.sock_pair_fd;
+#else /* STATION_SOCK */
fd_in = open(my_station.pipe_out_name, O_RDONLY);
+#endif /* STATION_SOCK */
// read sci and phy headers
memset(data, '\0', SCI_MSG_MAX_SIZE);
@@ -1606,7 +1664,9 @@ void phy_tx_frame_test_case(test_t t)
my_station.current_tick_tck = msg_tick_tck;
// close pipe
+#ifndef STATION_SOCK
close(fd_in);
+#endif /* !STATION_SOCK */
} test_end;
test_begin(t, "short ppdu")
@@ -1626,7 +1686,11 @@ void phy_tx_frame_test_case(test_t t)
// check that the correct phy message has been sent to Maximus
// open pipe
+#ifdef STATION_SOCK
+ fd_in = my_station.sock_pair_fd;
+#else /* STATION_SOCK */
fd_in = open(my_station.pipe_out_name, O_RDONLY);
+#endif /* STATION_SOCK */
// read sci and phy headers
memset(data, '\0', SCI_MSG_MAX_SIZE);
@@ -1649,7 +1713,9 @@ void phy_tx_frame_test_case(test_t t)
test_fail_unless (0 == memcmp(&ctx->control.current_tx_param.fc_av, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+sizeof(u32), 4*sizeof(u32)));
// close pipe
+#ifndef STATION_SOCK
close(fd_in);
+#endif /* !STATION_SOCK */
} test_end;
id = ctx->control.next_tx_param.tx_frame_netclock_id;
@@ -1670,7 +1736,11 @@ void phy_tx_frame_test_case(test_t t)
int fd_in = -1;
// open pipe
+#ifdef STATION_SOCK
+ fd_in = my_station.sock_pair_fd;
+#else /* STATION_SOCK */
fd_in = open(my_station.pipe_out_name, O_RDONLY);
+#endif /* STATION_SOCK */
// read sci and netclock headers
memset(data, '\0', 256);
@@ -1685,7 +1755,9 @@ void phy_tx_frame_test_case(test_t t)
test_fail_unless (ntohs(netclock_hdr->id) == id);
// close pipe
+#ifndef STATION_SOCK
close(fd_in);
+#endif /* !STATION_SOCK */
} test_end;
// check that the correct netclock message has been sent to Maximus
@@ -1699,7 +1771,11 @@ void phy_tx_frame_test_case(test_t t)
set_node_t *found_node;
// open pipe
+#ifdef STATION_SOCK
+ fd_in = my_station.sock_pair_fd;
+#else /* STATION_SOCK */
fd_in = open(my_station.pipe_out_name, O_RDONLY);
+#endif /* STATION_SOCK */
// read sci header
test_fail_unless ((-1 != fd_in)
@@ -1712,7 +1788,9 @@ void phy_tx_frame_test_case(test_t t)
test_fail_unless (date3 == ntohl(netclock_hdr.tick_low));
// close pipe
+#ifndef STATION_SOCK
close(fd_in);
+#endif /* !STATION_SOCK */
/* Remove netclock callback. */
@@ -1833,7 +1911,11 @@ void maximus_phy_send_test_case(test_t t)
}
// open pipe
- fd_in = open(my_station.pipe_out_name, O_RDONLY);
+#ifdef STATION_SOCK
+ fd_in = my_station.sock_pair_fd;
+#else /* STATION_SOCK */
+ fd_in = open(my_station.pipe_out_name, O_RDONLY);
+#endif /* STATION_SOCK */
// read sci and phy headers
memset(data, '\0', SCI_MSG_MAX_SIZE);
@@ -1861,7 +1943,9 @@ void maximus_phy_send_test_case(test_t t)
}
// close pipe
- close(fd_in);
+#ifndef STATION_SOCK
+ close(fd_in);
+#endif /* !STATION_SOCK */
}
} test_end;
@@ -1885,7 +1969,11 @@ void maximus_phy_send_test_case(test_t t)
int fd_in = -1;
// open pipe
+#ifdef STATION_SOCK
+ fd_in = my_station.sock_pair_fd;
+#else /* STATION_SOCK */
fd_in = open(my_station.pipe_out_name, O_RDONLY);
+#endif /* STATION_SOCK */
// read sci and phy headers
memset(data, '\0', SCI_MSG_MAX_SIZE);
@@ -1909,7 +1997,9 @@ void maximus_phy_send_test_case(test_t t)
test_fail_unless (0 == memcmp(tonemap1_data, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+(PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES, MAC_PB520_BYTES));
// close pipe
+#ifndef STATION_SOCK
close(fd_in);
+#endif /* !STATION_SOCK */
} test_end;
// test send RX
@@ -1929,7 +2019,11 @@ void maximus_phy_send_test_case(test_t t)
int fd_in = -1;
// open pipe
+#ifdef STATION_SOCK
+ fd_in = my_station.sock_pair_fd;
+#else /* STATION_SOCK */
fd_in = open(my_station.pipe_out_name, O_RDONLY);
+#endif /* STATION_SOCK */
// read sci and phy headers
memset(data, '\0', SCI_MSG_MAX_SIZE);
@@ -1952,7 +2046,9 @@ void maximus_phy_send_test_case(test_t t)
test_fail_unless (0 == memcmp(data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), &ctx->control.rx_param.src_station_id, sizeof(uint16_t)));
// close pipe
+#ifndef STATION_SOCK
close(fd_in);
+#endif /* !STATION_SOCK */
} test_end;
}
@@ -2013,7 +2109,11 @@ void phy_rx_activate_test_case(test_t t)
int fd_in = -1;
// open pipe
+#ifdef STATION_SOCK
+ fd_in = my_station.sock_pair_fd;
+#else /* STATION_SOCK */
fd_in = open(my_station.pipe_out_name, O_RDONLY);
+#endif /* STATION_SOCK */
// read sci header and netclock header
memset(data, '\0', 256);
@@ -2031,7 +2131,9 @@ void phy_rx_activate_test_case(test_t t)
test_fail_unless (ntohs(netclock_hdr->id) == ctx->control.rx_param.rx_activate_netclock_id);
// close pipe
+#ifndef STATION_SOCK
close(fd_in);
+#endif /* !STATION_SOCK */
} test_end;
phy_access_backoff_start (ctx, date+10, cap);
@@ -2044,7 +2146,11 @@ void phy_rx_activate_test_case(test_t t)
int fd_in = -1;
// open pipe
+#ifdef STATION_SOCK
+ fd_in = my_station.sock_pair_fd;
+#else /* STATION_SOCK */
fd_in = open(my_station.pipe_out_name, O_RDONLY);
+#endif /* STATION_SOCK */
// read sci and netclock headers
memset(data, '\0', 256);
@@ -2062,7 +2168,9 @@ void phy_rx_activate_test_case(test_t t)
test_fail_unless (ntohs(netclock_hdr->id) == ctx->access.backoff_start_netclock_id);
// close pipe
+#ifndef STATION_SOCK
close(fd_in);
+#endif /* !STATION_SOCK */
} test_end;
pre_detection = false;
@@ -2083,7 +2191,11 @@ void phy_rx_activate_test_case(test_t t)
int fd_in = -1;
// open pipe
+#ifdef STATION_SOCK
+ fd_in = my_station.sock_pair_fd;
+#else /* STATION_SOCK */
fd_in = open(my_station.pipe_out_name, O_RDONLY);
+#endif /* STATION_SOCK */
// read sci and netclock headers
memset(data, '\0', 256);
@@ -2098,7 +2210,9 @@ void phy_rx_activate_test_case(test_t t)
test_fail_unless (ntohs(netclock_hdr->id) == id1);
// close pipe
+#ifndef STATION_SOCK
close(fd_in);
+#endif /* !STATION_SOCK */
} test_end;
// check that the correct netclock message has been sent to Maximus
@@ -2109,7 +2223,11 @@ void phy_rx_activate_test_case(test_t t)
int fd_in = -1;
// open pipe
+#ifdef STATION_SOCK
+ fd_in = my_station.sock_pair_fd;
+#else /* STATION_SOCK */
fd_in = open(my_station.pipe_out_name, O_RDONLY);
+#endif /* STATION_SOCK */
// read sci and netclock headers
memset(data, '\0', 256);
@@ -2124,7 +2242,9 @@ void phy_rx_activate_test_case(test_t t)
test_fail_unless (ntohs(netclock_hdr->id) == id2);
// close pipe
+#ifndef STATION_SOCK
close(fd_in);
+#endif /* !STATION_SOCK */
} test_end;
// check that the correct netclock message has been sent to Maximus
@@ -2135,7 +2255,11 @@ void phy_rx_activate_test_case(test_t t)
int fd_in = -1;
// open pipe
+#ifdef STATION_SOCK
+ fd_in = my_station.sock_pair_fd;
+#else /* STATION_SOCK */
fd_in = open(my_station.pipe_out_name, O_RDONLY);
+#endif /* STATION_SOCK */
// read sci and netclock headers
memset(data, '\0', 256);
@@ -2153,7 +2277,9 @@ void phy_rx_activate_test_case(test_t t)
test_fail_unless (ntohs(netclock_hdr->id) == ctx->control.rx_param.rx_activate_netclock_id);
// close pipe
+#ifndef STATION_SOCK
close(fd_in);
+#endif /* !STATION_SOCK */
} test_end;
// test the callback
@@ -2247,8 +2373,8 @@ void phy_rx_prepare_test_case(test_t t)
// check phy data
test_fail_unless (0 == memcmp(data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), &ctx->control.rx_param.src_station_id, sizeof(uint16_t)));
- // close pipe
- close(fd_in);
+ // close pipe
+ close(fd_in);
} test_end;
test_begin(t, "rx prepare with ROBO modulation")
@@ -2424,7 +2550,12 @@ void phy_extra_timer_program_test_case(test_t t)
int fd_in = -1;
// open pipe
+#ifdef STATION_SOCK
+ fd_in = my_station.sock_pair_fd;
+#else /* STATION_SOCK */
fd_in = open(my_station.pipe_out_name, O_RDONLY);
+#endif /* STATION_SOCK */
+
// read sci and netclock headers
memset(data, '\0', 256);
@@ -2442,7 +2573,9 @@ void phy_extra_timer_program_test_case(test_t t)
test_fail_unless (ntohs(netclock_hdr->id) == ctx->control.extra_timer_program_netclock_id);
// close pipe
+#ifndef STATION_SOCK
close(fd_in);
+#endif /* !STATION_SOCK */
} test_end;
// test the callback
@@ -2472,7 +2605,11 @@ void phy_extra_timer_program_test_case(test_t t)
int fd_in = -1;
// open pipe
+#ifdef STATION_SOCK
+ fd_in = my_station.sock_pair_fd;
+#else /* STATION_SOCK */
fd_in = open(my_station.pipe_out_name, O_RDONLY);
+#endif /* STATION_SOCK */
// read sci and netclock headers
memset(data, '\0', 256);
@@ -2487,7 +2624,9 @@ void phy_extra_timer_program_test_case(test_t t)
test_fail_unless (ntohs(netclock_hdr->id) == id);
// close pipe
+#ifndef STATION_SOCK
close(fd_in);
+#endif /* !STATION_SOCK */
} test_end;
// check that the correct netclock message has been sent to Maximus
@@ -2498,7 +2637,11 @@ void phy_extra_timer_program_test_case(test_t t)
int fd_in = -1;
// open pipe
+#ifdef STATION_SOCK
+ fd_in = my_station.sock_pair_fd;
+#else /* STATION_SOCK */
fd_in = open(my_station.pipe_out_name, O_RDONLY);
+#endif /* STATION_SOCK */
// read sci and netclock headers
memset(data, '\0', 256);
@@ -2516,7 +2659,9 @@ void phy_extra_timer_program_test_case(test_t t)
test_fail_unless (ntohs(netclock_hdr->id) == ctx->control.extra_timer_program_netclock_id);
// close pipe
+#ifndef STATION_SOCK
close(fd_in);
+#endif /* !STATION_SOCK */
} test_end;
return;
@@ -2545,7 +2690,11 @@ void phy_extra_timer_cancel_test_case(test_t t)
int fd_in = -1;
// open pipe
+#ifdef STATION_SOCK
+ fd_in = my_station.sock_pair_fd;
+#else /* STATION_SOCK */
fd_in = open(my_station.pipe_out_name, O_RDONLY);
+#endif /* STATION_SOCK */
// read sci and netclock headers
memset(data, '\0', 256);
@@ -2560,7 +2709,9 @@ void phy_extra_timer_cancel_test_case(test_t t)
test_fail_unless (ntohs(netclock_hdr->id) == id);
// close pipe
+#ifndef STATION_SOCK
close(fd_in);
+#endif /* !STATION_SOCK */
} test_end;
return;