summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
authorThierry Carré2013-02-14 18:24:15 +0100
committerThierry Carré2013-02-22 16:43:25 +0100
commit168549f4c09c40e2b1841b1c7570899e259b1b6d (patch)
treede94e11e5a0d94791eabf64bfc31db4179f60993 /cesar
parent534f7b98f1f654644224b8e57c7de1bd1088c5a4 (diff)
cesar/{host, hal}: erase dead code linked to STATION_SOCK, refs #2979
Diffstat (limited to 'cesar')
-rw-r--r--cesar/hal/ipmbox/maximus/test/src/test_maximus_hal.c6
-rw-r--r--cesar/hal/leon/maximus/test/src/test_maximus_timer.c10
-rw-r--r--cesar/hal/phy/maximus/test/src/test_phy_maximus.c10
-rw-r--r--cesar/host/sci/maximus/inc/socket.h2
-rw-r--r--cesar/host/sci/maximus/src/sci.c8
-rw-r--r--cesar/host/station/src/station.c92
-rw-r--r--cesar/host/station/station.h10
-rw-r--r--cesar/host/test/src/test_fcall.c12
-rw-r--r--cesar/host/test/src/test_netclock.c18
-rw-r--r--cesar/host/test/src/test_sci.c8
-rw-r--r--cesar/host/test/src/test_station.c36
-rw-r--r--cesar/host/test/src/test_system.c6
12 files changed, 4 insertions, 214 deletions
diff --git a/cesar/hal/ipmbox/maximus/test/src/test_maximus_hal.c b/cesar/hal/ipmbox/maximus/test/src/test_maximus_hal.c
index 2a30eb074b..302c61be9d 100644
--- a/cesar/hal/ipmbox/maximus/test/src/test_maximus_hal.c
+++ b/cesar/hal/ipmbox/maximus/test/src/test_maximus_hal.c
@@ -54,11 +54,7 @@ maximus_ether_open (station_ctx_t *station)
{
int fd;
-#ifdef STATION_SOCK
- fd = station->sock_pair_fd;
-#else /* STATION_SOCK */
fd = open (station->pipe_out_name, O_RDONLY);
-#endif /* STATION_SOCK */
return fd;
}
@@ -66,9 +62,7 @@ maximus_ether_open (station_ctx_t *station)
void
maximus_ether_close (int fd)
{
-#ifndef STATION_SOCK
close (fd);
-#endif /* !STATION_SOCK */
}
int
diff --git a/cesar/hal/leon/maximus/test/src/test_maximus_timer.c b/cesar/hal/leon/maximus/test/src/test_maximus_timer.c
index 36607c4275..07971ccc90 100644
--- a/cesar/hal/leon/maximus/test/src/test_maximus_timer.c
+++ b/cesar/hal/leon/maximus/test/src/test_maximus_timer.c
@@ -45,11 +45,7 @@ maximus_timer_open (station_ctx_t *station)
{
int fd;
- #ifdef STATION_SOCK
- fd = station->sock_pair_fd;
- #else /* STATION_SOCK */
- fd = open(station->pipe_out_name, O_RDONLY);
- #endif /* STATION_SOCK */
+ fd = open(station->pipe_out_name, O_RDONLY);
return fd;
}
@@ -57,9 +53,7 @@ maximus_timer_open (station_ctx_t *station)
void
maximus_timer_close (int fd)
{
- #ifndef STATION_SOCK
- close(fd);
- #endif /* !STATION_SOCK */
+ close(fd);
}
void
diff --git a/cesar/hal/phy/maximus/test/src/test_phy_maximus.c b/cesar/hal/phy/maximus/test/src/test_phy_maximus.c
index c898ecd70e..44ee024083 100644
--- a/cesar/hal/phy/maximus/test/src/test_phy_maximus.c
+++ b/cesar/hal/phy/maximus/test/src/test_phy_maximus.c
@@ -72,11 +72,7 @@ maximus_phy_open (station_ctx_t *station)
{
int fd;
- #ifdef STATION_SOCK
- fd = station->sock_pair_fd;
- #else /* STATION_SOCK */
- fd = open(station->pipe_out_name, O_RDONLY);
- #endif /* STATION_SOCK */
+ fd = open(station->pipe_out_name, O_RDONLY);
return fd;
}
@@ -84,9 +80,7 @@ maximus_phy_open (station_ctx_t *station)
void
maximus_phy_close (int fd)
{
- #ifndef STATION_SOCK
- close(fd);
- #endif /* !STATION_SOCK */
+ close(fd);
}
int
diff --git a/cesar/host/sci/maximus/inc/socket.h b/cesar/host/sci/maximus/inc/socket.h
index 414aad9c36..d73a0d5afc 100644
--- a/cesar/host/sci/maximus/inc/socket.h
+++ b/cesar/host/sci/maximus/inc/socket.h
@@ -21,8 +21,6 @@
#include <sys/types.h>
-#undef STATION_SOCK /** enable socket communication */
-
#define HOST_PF_UNIX 1
#define HOST_AF_UNIX HOST_PF_UNIX
diff --git a/cesar/host/sci/maximus/src/sci.c b/cesar/host/sci/maximus/src/sci.c
index bb1eb7e55e..0980d9fdb2 100644
--- a/cesar/host/sci/maximus/src/sci.c
+++ b/cesar/host/sci/maximus/src/sci.c
@@ -151,11 +151,7 @@ sci_send (sci_ctx_t *sci, sci_msg_t *msg)
return -1;
}
-#ifdef STATION_SOCK
- output = sci->station->sock_fd;
-#else
output = sci->station->pipe_out_fd;
-#endif
len = write (output, msg->data_begin, msg->length);
@@ -193,11 +189,7 @@ sci_recv (sci_ctx_t *sci)
return -1;
}
-#ifdef STATION_SOCK
- input = sci->station->sock_fd;
-#else
input = sci->station->pipe_in_fd;
-#endif
if (sci_msg_init (&msg, sci_buffer, SCI_MSG_MAX_SIZE) < 0)
return -1;
diff --git a/cesar/host/station/src/station.c b/cesar/host/station/src/station.c
index d895af7143..363b53b436 100644
--- a/cesar/host/station/src/station.c
+++ b/cesar/host/station/src/station.c
@@ -62,10 +62,6 @@ static netclock_callback_t _ecos_tick_cb;
*/
int station_init(station_ctx_t *station)
{
-#ifdef STATION_SOCK
- int sock_server_fd;
-#endif /* STATION_SOCK */
-
DBG_ASSERT(station);
if(station == NULL)
{
@@ -74,14 +70,8 @@ int station_init(station_ctx_t *station)
}
memset(station, '\0', sizeof(station_ctx_t));
-#ifdef STATION_SOCK
- station->sock_fd = -1;
- station->sock_pair_fd = -1;
- sock_server_fd = -1;
-#else /* STATION_SOCK */
station->pipe_in_fd = -1;
station->pipe_out_fd = -1;
-#endif
station->pipe_log_fd = -1;
/* get station id */
@@ -93,12 +83,10 @@ int station_init(station_ctx_t *station)
/* build pipe names */
sprintf(station->pipe_log_name, "%s/%s_log_%d", STATION_PIPE_PATH, STATION_PIPE_PREFIX, station->id);
unlink(station->pipe_log_name); // in case of an error occurs after, unlink now
-#ifndef STATION_SOCK
sprintf(station->pipe_in_name, "%s/%s_in_%d", STATION_PIPE_PATH, STATION_PIPE_PREFIX, station->id);
unlink(station->pipe_in_name); // in case of an error occurs after, unlink now
sprintf(station->pipe_out_name, "%s/%s_out_%d", STATION_PIPE_PATH, STATION_PIPE_PREFIX, station->id);
unlink(station->pipe_out_name); // in case of an error occurs after, unlink now
-#endif
// reset errno generated by the 'unlink() function'
errno = 0;
@@ -108,46 +96,6 @@ int station_init(station_ctx_t *station)
if((station->pipe_log_fd = open(station->pipe_log_name, O_RDWR | O_NONBLOCK, S_IRWXU | S_IRWXG)) < 0)
goto failed;
-#ifdef STATION_SOCK
- /* build sock name */
- sprintf(station->sock_name, "%s/%s_sock_%d", STATION_SOCK_PATH, STATION_SOCK_PREFIX, station->id);
- unlink(station->sock_name);
-
- /* create socket */
- if((sock_server_fd = socket (PF_UNIX, SOCK_STREAM, 0)) < 0)
- {
- station_log(station, STATION_LOG_WARNING, STATION_LOGTYPE_STATION,
- "%s: failed to create socket (errno=%d)",
- __FUNCTION__, errno);
- goto failed;
- }
-
- /* extend send buffer size */
- {
- int bufsize = STATION_MAX_SOCK_BUFFER_SIZE;
- if(setsockopt (sock_server_fd, SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof(bufsize)) < 0)
- {
- station_log(station, STATION_LOG_WARNING, STATION_LOGTYPE_STATION,
- "%s: failed to set buffer size to %d bytes (errno=%d)",
- __FUNCTION__, bufsize, errno);
- goto failed;
- }
- }
-
- /* bind the socket */
- {
- struct sockaddr_un sockaddr;
- sockaddr.sun_family = AF_UNIX;
- strcpy (sockaddr.sun_path, station->sock_name);
- if((bind (sock_server_fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr))) < 0)
- {
- station_log(station, STATION_LOG_WARNING, STATION_LOGTYPE_STATION,
- "%s: bind to '%s' failed (errno=%d)",
- __FUNCTION__, station->sock_name, errno);
- goto failed;
- }
- }
-#else /* STATION_SOCK */
/* open in pipe */
if(mknod(station->pipe_in_name, 0770 | S_IFIFO, 0) < 0)
{
@@ -180,7 +128,6 @@ int station_init(station_ctx_t *station)
goto failed;
}
-#endif /* STATION_SOCK */
/* init all contexts */
station->sci = &_my_sci;
@@ -199,19 +146,6 @@ int station_init(station_ctx_t *station)
/* init the random generator */
srand(station->id);
-#if (defined STATION_SOCK) && !defined(UNIT_TEST)
- /* listen and accept connection */
- listen(sock_server_fd, 1);
- if((station->sock_fd = accept(sock_server_fd, NULL, NULL)) < 0)
- {
- station_log(station, STATION_LOG_WARNING, STATION_LOGTYPE_STATION,
- "%s: accept failed (errno=%d)",
- __FUNCTION__, errno);
- goto failed;
- }
- close(sock_server_fd);
-#endif /* STATION_SOCK && !UNIT_TEST */
-
return 0;
failed:
@@ -219,17 +153,6 @@ failed:
close(station->pipe_log_fd);
unlink(station->pipe_log_name);
station->pipe_log_fd = -1;
-#ifdef STATION_SOCK
- if(station->sock_fd >= 0)
- close(station->sock_fd);
- if(station->sock_pair_fd >= 0)
- close(station->sock_pair_fd);
- if(sock_server_fd >= 0)
- close(sock_server_fd);
- unlink(station->sock_name);
- station->sock_fd = -1;
- station->sock_pair_fd = -1;
-#else /* STATION_SOCK */
if(station->pipe_out_fd >= 0)
close(station->pipe_out_fd);
if(station->pipe_in_fd >= 0)
@@ -238,7 +161,6 @@ failed:
unlink(station->pipe_in_name);
station->pipe_out_fd = -1;
station->pipe_in_fd = -1;
-#endif /* STATION_SOCK */
station->status = STATION_STATUS_ERROR;
return -1;
}
@@ -253,15 +175,6 @@ void station_down(station_ctx_t *station)
|| (station->status == STATION_STATUS_INIT))
return;
-#ifdef STATION_SOCK
- if(station->sock_fd >= 0)
- close(station->sock_fd);
- if(station->sock_pair_fd >= 0)
- close(station->sock_pair_fd);
- unlink(station->sock_name);
- station->sock_fd = -1;
- station->sock_pair_fd = -1;
-#else /* STATION_SOCK */
if(station->pipe_out_fd >= 0)
close(station->pipe_out_fd);
if(station->pipe_in_fd >= 0)
@@ -270,7 +183,6 @@ void station_down(station_ctx_t *station)
unlink(station->pipe_in_name);
station->pipe_out_fd = -1;
station->pipe_in_fd = -1;
-#endif /* STATION_SOCK */
if(station->pipe_log_fd >= 0)
close(station->pipe_log_fd);
unlink(station->pipe_log_name);
@@ -331,11 +243,7 @@ int station_idle(station_ctx_t *station)
/* wait for next message with 1 second timeout */
FD_ZERO(&read_fds);
-#ifdef STATION_SOCK
- FD_SET(station->sock_fd, &read_fds);
-#else /* STATION_SOCK */
FD_SET(station->pipe_in_fd, &read_fds);
-#endif /* STATION_SOCK */
timeout.tv_sec = 1;
timeout.tv_usec = 0;
sel = select(STATION_MAX_FD + 1, &read_fds, NULL, NULL, &timeout);
diff --git a/cesar/host/station/station.h b/cesar/host/station/station.h
index 8c6fd11c3e..751179a427 100644
--- a/cesar/host/station/station.h
+++ b/cesar/host/station/station.h
@@ -93,16 +93,10 @@ struct station_ctx
struct system_ctx *system;
tick_t current_tick_tck; /** current global clock tick got from sci msg */
u32 seed; /** station seed (may be needed for cesar initialization) */
-#ifdef STATION_SOCK
- int sock_fd; /** file descriptor for messaging input/output */
- int sock_pair_fd; /** file descriptor for socket pair, used by unit test */
- char sock_name[MAXPATHLEN]; /** filename of messaging input/output */
-#else /* STATION_SOCK */
int pipe_in_fd; /** file descriptor for messaging input pipe */
char pipe_in_name[MAXPATHLEN]; /** filename of messaging input file */
int pipe_out_fd; /** file descriptor for messaging output pipe */
char pipe_out_name[MAXPATHLEN]; /** filename of messaging output pipe */
-#endif /* STATION_SOCK */
int pipe_log_fd; /** output pipe file desc to send debug data */
char pipe_log_name[MAXPATHLEN]; /** output pipe filename to send debug data */
station_log_level_t log_level;
@@ -163,11 +157,7 @@ int station_ecos_set_itimer(station_ctx_t *station, tick_t tick);
static inline int station_is_initialized(station_ctx_t *station)
{
-#ifdef STATION_SOCK
- return (station->sock_fd >= 0);
-#else /* STATION_SOCK */
return ((station->pipe_in_fd >= 0) && (station->pipe_out_fd >= 0));
-#endif /* STATION_SOCK */
}
/**
diff --git a/cesar/host/test/src/test_fcall.c b/cesar/host/test/src/test_fcall.c
index 83121754eb..15459fe36f 100644
--- a/cesar/host/test/src/test_fcall.c
+++ b/cesar/host/test/src/test_fcall.c
@@ -369,11 +369,7 @@ void fcall_return_test_case(test_t t)
errno = 0;
} test_end;
-#ifdef STATION_SOCK
- fd_in = station.sock_pair_fd;
-#else /* STATION_SOCK */
fd_in = open(station.pipe_out_name, O_RDONLY);
-#endif /* STATION_SOCK */
test_begin(t, "fcall_return")
{
@@ -423,9 +419,7 @@ void fcall_return_test_case(test_t t)
} test_end;
station_down(&station);
-#ifndef STATION_SOCK
close(fd_in);
-#endif
}
int _test_recv_result;
@@ -501,11 +495,7 @@ void fcall_recv_test_case(test_t t)
errno = 0;
} test_end;
-#ifdef STATION_SOCK
- fd_in = station.sock_pair_fd;
-#else /* STATION_SOCK */
fd_in = open(station.pipe_out_name, O_RDONLY);
-#endif /* STATION_SOCK */
test_begin(t, "check recv")
{
@@ -615,9 +605,7 @@ void fcall_recv_test_case(test_t t)
} test_end;
station_down(&station);
-#ifndef STATION_SOCK
close(fd_in);
-#endif /* STATION_SOCK */
return;
}
diff --git a/cesar/host/test/src/test_netclock.c b/cesar/host/test/src/test_netclock.c
index 858e13d8a7..d74056ef4d 100644
--- a/cesar/host/test/src/test_netclock.c
+++ b/cesar/host/test/src/test_netclock.c
@@ -250,11 +250,7 @@ void netclock_schedule_test_case(test_t t)
errno = 0;
} test_end
-#ifdef STATION_SOCK
- fd_in = station.sock_pair_fd;
-#else /* STATION_SOCK */
fd_in = open(station.pipe_out_name, O_RDONLY);
-#endif /* STATION_SOCK */
test_begin(t, "recv netclock msg")
{
@@ -290,9 +286,7 @@ void netclock_schedule_test_case(test_t t)
} test_end;
station_down(&station);
-#ifndef STATION_SOCK
close(fd_in);
-#endif /* STATION_SOCK */
return;
}
@@ -345,11 +339,7 @@ void netclock_unschedule_test_case(test_t t)
&& (netclock.callback_nb == 1)
);
-#ifdef STATION_SOCK
- fd_in = station.sock_pair_fd;
-#else /* STATION_SOCK */
fd_in = open(station.pipe_out_name, O_RDONLY);
-#endif /* STATION_SOCK */
test_fail_if((len = read(fd_in, buffer, sizeof(sci_msg_hdr_t))) != sizeof(sci_msg_hdr_t));
hdr = (sci_msg_hdr_t *)buffer;
@@ -378,9 +368,7 @@ void netclock_unschedule_test_case(test_t t)
} test_end;
station_down(&station);
-#ifndef STATION_SOCK
close(fd_in);
-#endif /* STATION_SOCK */
return;
}
@@ -442,11 +430,7 @@ void netclock_recv_test_case(test_t t)
errno = 0;
} test_end;
-#ifdef STATION_SOCK
- fd_in = station.sock_pair_fd;
-#else /* STATION_SOCK */
fd_in = open(station.pipe_out_name, O_RDONLY);
-#endif /* STATION_SOCK */
memset(data_buffer, '\0', 32);
@@ -480,9 +464,7 @@ void netclock_recv_test_case(test_t t)
);
} test_end;
-#ifndef STATION_SOCK
close(fd_in);
-#endif /* STATION_SOCK */
station_down(&station);
return;
diff --git a/cesar/host/test/src/test_sci.c b/cesar/host/test/src/test_sci.c
index f8231f99c5..1a8556997d 100644
--- a/cesar/host/test/src/test_sci.c
+++ b/cesar/host/test/src/test_sci.c
@@ -276,11 +276,7 @@ void sci_send_test_case(test_t t)
test_begin(t, "check send")
{
int r;
-#ifdef STATION_SOCK
- fd_out = station.sock_pair_fd;
-#else
fd_out = open(station.pipe_out_name, O_RDONLY);
-#endif
test_fail_unless(
0 <= sci_msg_push (&msg, strlen (TEST_DATA_STR))
&& (EINVAL != errno)
@@ -384,11 +380,7 @@ void sci_recv_test_case(test_t t)
sci_fill_hdr(&sci, &msg, SCI_MSG_TYPE_SYSTEM, 0) >= 0
);
} test_end;
-#ifdef STATION_SOCK
- fd_in = station.sock_pair_fd;
-#else
fd_in = open(station.pipe_in_name, O_WRONLY);
-#endif
test_begin(t, "bad magic")
{
int r;
diff --git a/cesar/host/test/src/test_station.c b/cesar/host/test/src/test_station.c
index 8e83d70392..6991f237f2 100644
--- a/cesar/host/test/src/test_station.c
+++ b/cesar/host/test/src/test_station.c
@@ -66,9 +66,7 @@ void station_init_test_case(test_t t)
{
station_ctx_t station;
char buffer[256];
-#ifndef STATION_SOCK
struct stat my_stat;
-#endif
test_case_begin(t, "init");
station_init(&station);
@@ -77,13 +75,8 @@ void station_init_test_case(test_t t)
{
test_fail_unless(
(station.id == getpid())
-#ifdef STATION_SOCK
- && (station.sock_fd >= 0)
- && (station.sock_pair_fd >= 0)
-#else
&& (station.pipe_in_fd >= 0)
&& (station.pipe_out_fd >= 0)
-#endif
&& (station.pipe_log_fd >= 0)
&& (station.sci != NULL)
&& (station.log_level == STATION_LOG_WARNING)
@@ -98,20 +91,14 @@ void station_init_test_case(test_t t)
test_begin(t, "check pipe names")
{
/* check pipe names */
-#ifdef STATION_SOCK
- sprintf(buffer, "%s/%s_sock_%d", STATION_SOCK_PATH, STATION_SOCK_PREFIX, getpid());
- test_fail_if(strcmp(buffer, station.sock_name));
-#else
sprintf(buffer, "%s/%s_in_%d", STATION_PIPE_PATH, STATION_PIPE_PREFIX, getpid());
test_fail_if(strcmp(buffer, station.pipe_in_name));
sprintf(buffer, "%s/%s_out_%d", STATION_PIPE_PATH, STATION_PIPE_PREFIX, getpid());
test_fail_if(strcmp(buffer, station.pipe_out_name));
-#endif
/*sprintf(buffer, "%s/%s_debug_%d", STATION_PIPE_PATH, STATION_PIPE_PREFIX, getpid());
test_fail_if(strcmp(buffer, station->debug_out_name));*/
} test_end;
-#ifndef STATION_SOCK
test_begin(t, "check if pipes are created and open")
{
test_fail_unless(
@@ -124,7 +111,6 @@ void station_init_test_case(test_t t)
&& (fstat(station.pipe_out_fd, &my_stat) >= 0)
&& S_ISFIFO(my_stat.st_mode));
} test_end;
-#endif
station_down(&station);
}
@@ -133,9 +119,7 @@ void station_down_test_case(test_t t)
{
station_ctx_t station;
int fd_in, fd_out;
-#ifndef STATION_SOCK
char name_in[256], name_out[256];
-#endif
struct stat my_stat;
test_case_begin(t, "down");
@@ -147,25 +131,12 @@ void station_down_test_case(test_t t)
} test_end;
station_init(&station);
-#ifdef STATION_SOCK
- fd_in = station.sock_fd;
- fd_out = station.sock_pair_fd;
-#else
fd_in = station.pipe_in_fd;
fd_out = station.pipe_out_fd;
strcpy(name_in, station.pipe_in_name);
strcpy(name_out, station.pipe_out_name);
-#endif
station_down(&station);
-#ifdef STATION_SOCK
- test_begin(t, "socket is closed")
- {
- test_fail_unless(
- (fstat(fd_in, &my_stat) < 0)
- && (fstat(fd_out, &my_stat) < 0));
- } test_end;
-#else
test_begin(t, "pipes are closed")
{
test_fail_unless(
@@ -179,7 +150,6 @@ void station_down_test_case(test_t t)
(stat(name_in, &my_stat) < 0)
&& (stat(name_out, &my_stat) < 0));
} test_end;
-#endif
}
void station_idle_test_case(test_t t)
@@ -206,15 +176,9 @@ void station_idle_test_case(test_t t)
test_begin(t, "recv idle msg")
{
-#ifdef STATION_SOCK
- test_fail_unless(
- ((fd_in = station.sock_pair_fd) >= 0)
- );
-#else
test_fail_if(
((fd_in = open(station.pipe_out_name, O_RDONLY)) < 0)
);
-#endif
test_fail_unless(
(station_idle(&station) >= 0)
&& ((len = read(fd_in, buffer, sizeof(sci_msg_hdr_t))) == sizeof(sci_msg_hdr_t))
diff --git a/cesar/host/test/src/test_system.c b/cesar/host/test/src/test_system.c
index 58666363e5..db3f860d47 100644
--- a/cesar/host/test/src/test_system.c
+++ b/cesar/host/test/src/test_system.c
@@ -108,11 +108,7 @@ void system_recv_test_case(test_t t)
errno = 0;
} test_end;
-#ifdef STATION_SOCK
- fd_in = station.sock_pair_fd;
-#else /* STATION_SOCK */
fd_in = open(station.pipe_out_name, O_RDONLY);
-#endif /* STATION_SOCK */
test_begin(t, "recv")
{
@@ -145,9 +141,7 @@ void system_recv_test_case(test_t t)
);
} test_end;
-#ifndef STATION_SOCK
close(fd_in);
-#endif /* STATION_SOCK */
station_down(&station);
return;