summaryrefslogtreecommitdiff
path: root/hal/phy/maximus/test/src/test_phy_access.c
diff options
context:
space:
mode:
Diffstat (limited to 'hal/phy/maximus/test/src/test_phy_access.c')
-rw-r--r--hal/phy/maximus/test/src/test_phy_access.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/hal/phy/maximus/test/src/test_phy_access.c b/hal/phy/maximus/test/src/test_phy_access.c
index b46f05798b..c0688c84ca 100644
--- a/hal/phy/maximus/test/src/test_phy_access.c
+++ b/hal/phy/maximus/test/src/test_phy_access.c
@@ -18,6 +18,8 @@
#include "hal/phy/maximus/test/inc/test_phy_maximus.h"
#include "host/station.h"
#include "host/sci.h"
+#include "maximus/common/types/phy_types.h"
+#include "host/fwd.h" // for 'phy_msg_hdr_t'
#include <stdio.h> // for 'printf'
#include <string.h> // for 'memset'
#include <netinet/in.h> // for 'ntohl' and 'ntohs' functions
@@ -26,7 +28,6 @@
#include <errno.h>
uint32_t maximus_pending_isrs; // used in 'station.c'
-extern station_ctx_t my_station;
phy_t *ctx;
int netclock_id = 0;
@@ -49,7 +50,7 @@ void phy_access_backoff_start_test_case(test_t t)
int fd_in = -1;
// open pipe
- fd_in = open(my_station.pipe_out_name, O_RDONLY);
+ fd_in = open(ctx->control.station->pipe_out_name, O_RDONLY);
// read sci header and netclock header
memset(data, '\0', 256);
@@ -88,7 +89,7 @@ void phy_access_backoff_start_test_case(test_t t)
int fd_in = -1;
// open pipe
- fd_in = open(my_station.pipe_out_name, O_RDONLY);
+ fd_in = open(ctx->control.station->pipe_out_name, O_RDONLY);
// read sci header
test_fail_unless ((-1 != fd_in)
@@ -113,7 +114,7 @@ void phy_access_backoff_start_test_case(test_t t)
| (unsigned long long)(ntohl(sci_hdr.netclock_low));
// update current tick value
- my_station.current_tick_tck = msg_tick_tck;
+ ctx->control.station->current_tick_tck = msg_tick_tck;
// close pipe
close(fd_in);
@@ -159,13 +160,9 @@ void phy_access_backoff_slot_count_test_case(test_t t)
test_begin(t, "backoff slot count")
{
- if (NULL != ctx)
- {
- ctx->access.slot_count = 5;
- }
- test_fail_unless ((EINVAL != errno)
- && (NULL != ctx)
- && (ctx->access.slot_count == phy_access_backoff_slot_count(ctx)));
+ test_fail_unless ((NULL != ctx)
+ && (ctx->access.slot_count == phy_access_backoff_slot_count(ctx))
+ && (EINVAL != errno));
} test_end;
return;
@@ -181,9 +178,9 @@ void phy_access_backoff_prp_won_test_case(test_t t)
{
ctx->access.prp_result = 1;
}
- test_fail_unless ((EINVAL != errno)
- && (NULL != ctx)
- && (ctx->access.prp_result == phy_access_backoff_prp_won(ctx)));
+ test_fail_unless ((NULL != ctx)
+ && (ctx->access.prp_result == phy_access_backoff_prp_won(ctx))
+ && (EINVAL != errno));
} test_end;
return;
@@ -205,7 +202,7 @@ void phy_access_timer_program_test_case(test_t t)
int fd_in = -1;
// open pipe
- fd_in = open(my_station.pipe_out_name, O_RDONLY);
+ fd_in = open(ctx->control.station->pipe_out_name, O_RDONLY);
// read sci header and netclock header
memset(data, '\0', 256);
@@ -237,7 +234,8 @@ void phy_access_timer_program_test_case(test_t t)
test_begin(t, "access cb")
{
- test_fail_unless ((*ctx->control.access_cb)(ctx->control.user_data));
+ test_fail_unless ((NULL != ctx->control.access_cb)
+ && ((*ctx->control.access_cb)(ctx->control.user_data)));
} test_end;
return;
@@ -257,7 +255,7 @@ void phy_access_timer_cancel_test_case(test_t t)
int fd_in = -1;
// open pipe
- fd_in = open(my_station.pipe_out_name, O_RDONLY);
+ fd_in = open(ctx->control.station->pipe_out_name, O_RDONLY);
// read sci header and netclock header
memset(data, '\0', 256);
@@ -282,6 +280,7 @@ void phy_access_test_suite(test_t t)
int user_data = 1234567890;
unsigned char buffer[1024];
int fd_out = -1;
+ station_ctx_t station;
ctx = phy_init ((void*)&user_data,
&phy_rx_fc_cb,
@@ -289,11 +288,12 @@ void phy_access_test_suite(test_t t)
&phy_access_conf_cb,
&phy_pbdma_cb,
&phy_deferred_cb);
- station_init(&my_station);
+ station_init (&station);
+ sci_init(station.sci, &station);
// TO REMOVE
memset(buffer, 'a', 1024);
- fd_out = open(my_station.pipe_out_name, O_WRONLY);
+ fd_out = open(station.pipe_out_name, O_WRONLY);
write(fd_out, buffer, 1024);
close(fd_out);
@@ -305,5 +305,6 @@ void phy_access_test_suite(test_t t)
phy_access_timer_program_test_case(t);
phy_access_timer_cancel_test_case(t);
- station_down (&my_station);
+ phy_uninit (ctx);
+ station_down (&station);
}