Commit 4329a93d authored by SIMONIN Matthieu's avatar SIMONIN Matthieu
Browse files

Merge branch 'dev/capi_recv' into 'master'

Dev/capi recv

See merge request quinson/2018-vsg!2
parents d29d6880 2d770910
Pipeline #147058 passed with stages
in 3 minutes and 26 seconds
......@@ -41,6 +41,19 @@ configure_file(examples/send/deployment.xml examples/send/deployment.xml)
configure_file(examples/send/nova_cluster.xml examples/send/nova_cluster.xml)
add_dependencies(send fake-vm)
# Benchs
add_executable(gettimeofday examples/benchs/gettimeofday.cpp)
set_target_properties(gettimeofday PROPERTIES RUNTIME_OUTPUT_DIRECTORY examples/benchs)
target_link_libraries(gettimeofday PUBLIC ${FAKEVM_LIBS} vsg)
configure_file(examples/benchs/deployment.xml examples/benchs/deployment.xml)
configure_file(examples/benchs/nova_cluster.xml examples/benchs/nova_cluster.xml)
add_dependencies(gettimeofday fake-vm)
# Qemus
configure_file(examples/qemus/boot_and_log.sh examples/qemus/boot_and_log.sh COPYONLY)
configure_file(examples/qemus/deployment.xml examples/qemus/deployment.xml COPYONLY)
configure_file(examples/qemus/nova_cluster.xml examples/qemus/nova_cluster.xml COPYONLY)
# Unit tests
add_executable(tests src/tests/tests.cpp)
target_link_libraries(tests PUBLIC ${FAKEVM_LIBS} vsg ${SimGrid_LIBRARY})
......@@ -49,4 +62,7 @@ target_compile_options(tests PUBLIC -fexceptions)
add_dependencies(tests fake-vm)
install(TARGETS tansiv DESTINATION bin)
install(TARGETS vsg DESTINATION lib)
install(FILES src/vsg/vsg.h DESTINATION include)
install(CODE "MESSAGE(\"-- Installing libfake_vm\")")
install(CODE "execute_process(COMMAND make install WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/fake-vm )")
\ No newline at end of file
<?xml version='1.0'?>
<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
<platform version="4.1">
<actor host="nova-1.lyon.grid5000.fr" function="vsg_vm">
<argument value="10.0.0.1"/> <!-- whoam i from the protocol perspective; must be consistent with send.cpp:make_addr() -->
<argument value="./examples/benchs/gettimeofday"/>
</actor>
</platform>
#include <atomic>
#include <cstring>
#include <limits>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <sys/time.h>
extern "C" {
#include <fake_vm.h>
#include <vsg.h>
}
using namespace std;
// Addresses used in this program
#define ADDR_FMT "10.0.%d.1"
void die(const char* msg, int error)
{
fprintf(stderr, "%s", msg);
if (error)
fprintf(stderr, "\t%s\n", std::strerror(error));
exit(1);
}
// addr must point at at least INET_ADDRSTRLEN chars.
void make_addr(char* addr, int id)
{
if (snprintf(addr, INET_ADDRSTRLEN, ADDR_FMT, id) >= INET_ADDRSTRLEN) {
die("Invalid address template or id", 0);
}
}
void recv_cb(uintptr_t arg)
{
std::atomic<bool>* callback_called = (std::atomic<bool>*)arg;
*callback_called = true;
};
vsg_context* init_vsg(int argc, char* argv[])
{
std::string src_str = "10.0.0.1";
uint32_t src = inet_addr(src_str.c_str());
int vsg_argc = 6;
const char* const vsg_argv[] = {"-a", CONNECTION_SOCKET_NAME, "-n", src_str.c_str(), "-t", "1970-01-01T00:00:00"};
std::atomic<bool> callback_called(false);
vsg_context* context = vsg_init(vsg_argc, vsg_argv, NULL, recv_cb, (uintptr_t)&callback_called);
if (!context) {
die("Unable to initialize the context", 0);
}
int ret = vsg_start(context);
if (ret) {
die("Unable to start the vsg client", ret);
}
return context;
}
#define LIMIT 5
int bench_vsg_gettimeofday(int argc, char* argv[])
{
vsg_context* context = init_vsg(argc, argv);
timeval limit = {.tv_sec = LIMIT, .tv_usec = 0};
int loop_count;
timeval start;
vsg_gettimeofday(context, &start, NULL);
timeval current;
timeval diff;
for (loop_count = 0; loop_count < std::numeric_limits<int>::max(); loop_count++) {
vsg_gettimeofday(context, &current, NULL);
timersub(&current, &start, &diff);
if (timercmp(&diff, &limit, >=)) {
break;
}
}
printf("I'm done with bench_vsg_gettimeofday\n");
return loop_count;
}
int bench_gettimeofday(int argc, char* argv[])
{
timeval limit = {.tv_sec = LIMIT, .tv_usec = 0};
int loop_count;
timeval start;
gettimeofday(&start, NULL);
timeval current;
timeval diff;
for (loop_count = 0; loop_count < std::numeric_limits<int>::max(); loop_count++) {
// TODO(msimonin): faire un truc genre une addition
// à nombre d'itérations fixé
// compilé en mode release (make RELEASE=0)
// make install avec prefix connu
gettimeofday(&current, NULL);
timersub(&current, &start, &diff);
if (timercmp(&diff, &limit, >=)) {
break;
}
}
printf("I'm done with bench_gettimeofday\n");
return loop_count;
}
/*
*
* Run a simple benchmark to see the effect of gettimeofday implementation
*/
int main(int argc, char* argv[])
{
int count1 = bench_gettimeofday(argc, argv);
int count2 = bench_vsg_gettimeofday(argc, argv);
double rate1 = (double)count1 / LIMIT;
double rate2 = (double)count2 / LIMIT;
printf("\n");
printf("|%-20s|%16.2f /s|\n", "gettimeofday", rate1);
printf("|%-20s|%16.2f /s|\n", "vsg_gettimeofday", rate2);
printf("\n");
exit(0);
}
<?xml version='1.0'?>
<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
<platform version="4.1">
<zone id="AS0" routing="Full">
<cluster id="nova" prefix="nova-" suffix=".lyon.grid5000.fr" radical="0-200" speed="16120000000.0f,0.0f,0.0f" core="16" bw="10Gbps" lat="1.0E-4s" router_id="router1">
<prop id="watt_per_state" value="75.83:81.97:174.04, 123.86:123.86:123.86, 66:66:66" />
<prop id="watt_off" value="8.81" />
</cluster>
</zone>
</platform>
......@@ -9,14 +9,12 @@ Start an UDP listener and an UDP client inside the VM.
Use $(tmux a) inside the vm to start using.
USAGE:
./boot_and_log.sh LISTEN_PORT CONNECT_HOST CONNECT_PORT
./boot_and_log.sh IP MAC
Positional Arguments:
IP: the ip to use (this is likely to be correlated to the MAC but it's good enough for now)
MAC: the mac address to use
LISTEN_HOST: start an UDP server that will listen on this address in the VM
LISTEN_PORT: start an UDP server that will listen on this port in the VM
CONNECT_HOST: The UDP client will use this a foreign address
CONNECT_PORT: The UDP client will use this as foreign port
Environment Variables:
owned:
......@@ -24,7 +22,6 @@ Environment Variables:
from third party (examples)
SLIRP_DEBUG="all": activate all debug message from slirp
G_MESSAGES_DEBUG="Slirp": glib debug filter
HOSTFWD=hostfwd=tcp::10022-:22: add a redirection
EOF
}
......@@ -34,24 +31,16 @@ then
exit 1
fi
if (( "$#" != "4" ))
if (( "$#" != "2" ))
then
usage
exit 1
fi
LISTEN_HOST=$1
shift
LISTEN_PORT=$1
shift
IP=$1
MAC=$2
CONNECT_HOST=$1
shift
CONNECT_PORT=$1
shift
VM_NAME="vm-$LISTEN_PORT"
VM_NAME="vm-${MAC//:/-}"
# A decent key to use
cloud_init_key=$(cat ~/.ssh/id_rsa.pub)
......@@ -74,10 +63,6 @@ local-hostname: $VM_NAME
disable_root: false
bootcmd:
- echo "-----> START of MY CLOUD INIT <---------- \n"
- apt update && apt install -y tmux netcat-openbsd
- tmux new-session -s tansiv -d "echo -e 'listener $LISTEN_HOST->localhost:$LISTEN_PORT\n'; nc -u -l 0.0.0.0 $LISTEN_PORT"
- tmux new-session -s tansiv2 -d "echo -e 'client $CONNECT_HOST:$CONNECT_PORT\n'; nc -u $CONNECT_HOST $CONNECT_PORT"
- tmux move-pane -s tansiv2 -t tansiv
- echo "-----> END of MY CLOUD INIT <---------- \n"
EOF
......@@ -93,19 +78,10 @@ VM_IMAGE=$VM_NAME.qcow2
# start on the base one
# VM_IMAGE=debian10-x64-min.qcow2
# redir one udp port passed in parameter:;
UDP_REDIR="hostfwd=udp:$LISTEN_HOST:$LISTEN_PORT-:$LISTEN_PORT"
TCP_REDIR="hostfwd=tcp::1$LISTEN_PORT-:22"
if [ -z "$HOSTFWD"]
then
HOSTFWD=$TCP_REDIR,$UDP_REDIR
else
HOSTFWD="$HOSTFWD,$TCP_REDIR,$UDP_REDIR"
fi
TAP_NAME=tap${MAC:(-2)}
$QEMU \
-m 1g \
-drive file=$VM_IMAGE \
-cdrom $CLOUD_INIT_ISO \
-netdev user,id=network0,$HOSTFWD \
-device e1000,netdev=network0
-netdev tantap,src=$IP,id=mynet0,ifname=$TAP_NAME,script=no,downscript=no \
-device e1000,netdev=mynet0,mac=$MAC
\ No newline at end of file
......@@ -3,21 +3,17 @@
<platform version="4.1">
<actor host="nova-1.lyon.grid5000.fr" function="vsg_vm">
<argument value="192.168.0.53"/> <!-- how simgrid knows me-->
<argument value="192.168.0.10"/> <!-- how simgrid knows me-->
<argument value="./examples/qemus/boot_and_log.sh"/>
<argument value="192.168.0.53"/> <!-- listen to this -->
<argument value="1234"/> <!-- listen to this -->
<argument value="192.168.0.54"/> <!-- connect to this -->
<argument value="1235"/> <!-- connect to this -->
<argument value="192.168.0.10"/> <!-- how vsg knows me-->
<argument value="52:54:00:00:00:10"/> <!-- my mac address so that the dhcp give the above IP -->
</actor>
<actor host="nova-2.lyon.grid5000.fr" function="vsg_vm">
<argument value="192.168.0.54"/> <!-- how simgrid knows me-->
<argument value="192.168.0.11"/> <!-- how simgrid knows me-->
<argument value="./examples/qemus/boot_and_log.sh"/>
<argument value="192.168.0.54"/> <!-- listen to this -->
<argument value="1235"/> <!-- listen to this -->
<argument value="192.168.0.53"/> <!-- connect to this -->
<argument value="1234"/> <!-- connect to this -->
<argument value="192.168.0.11"/> <!-- how vsg knows me-->
<argument value="52:54:00:00:00:11"/> <!-- my mac address so that the dhcp give the above IP -->
</actor>
</platform>
\ No newline at end of file
<?xml version='1.0'?>
<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
<platform version="4.1">
<zone id="AS0" routing="Full">
<cluster id="nova" prefix="nova-" suffix=".lyon.grid5000.fr" radical="0-200" speed="16120000000.0f,0.0f,0.0f" core="16" bw="10Gbps" lat="1.0E-1s" router_id="router1">
<prop id="watt_per_state" value="75.83:81.97:174.04, 123.86:123.86:123.86, 66:66:66" />
<prop id="watt_off" value="8.81" />
</cluster>
</zone>
</platform>
......@@ -31,15 +31,15 @@ void make_addr(char* addr, int id)
void recv_cb(uintptr_t arg)
{
std::atomic<bool>* callback_called = (std::atomic<bool>*)arg;
*callback_called = true;
std::atomic<bool>* callback_called = (std::atomic<bool>*)arg;
*callback_called = true;
};
int main(int argc, char* argv[])
{
// initialization phase
int dest_id = std::atoi(argv[1]);
int src_id = 1 - dest_id;
int dest_id = std::atoi(argv[1]);
int src_id = 1 - dest_id;
char dest_str[INET_ADDRSTRLEN];
make_addr(dest_str, dest_id);
char src_str[INET_ADDRSTRLEN];
......@@ -49,7 +49,7 @@ int main(int argc, char* argv[])
int vsg_argc = 6;
const char* const vsg_argv[] = {"-a", CONNECTION_SOCKET_NAME, "-n", src_str, "-t", "1970-01-01T00:00:00"};
std::atomic<bool> callback_called(false);
vsg_context* context = vsg_init(vsg_argc, vsg_argv, NULL, recv_cb, (uintptr_t)&callback_called);
vsg_context* context = vsg_init(vsg_argc, vsg_argv, NULL, recv_cb, (uintptr_t)&callback_called);
if (!context) {
die("Unable to initialize the context", 0);
......@@ -61,7 +61,7 @@ int main(int argc, char* argv[])
}
std::string msg = "plop";
ret = vsg_send(context, src, dest, msg.length() + 1, (uint8_t*)msg.c_str());
ret = vsg_send(context, dest, msg.length() + 1, (uint8_t*)msg.c_str());
if (ret) {
die("vsg_send() failed", ret);
}
......@@ -74,7 +74,7 @@ int main(int argc, char* argv[])
uint32_t recv_dest;
uint32_t buffer_len = msg.length() + 1;
char buffer[buffer_len];
ret = vsg_recv(context, &src, &dest, &buffer_len, (uint8_t*)buffer);
ret = vsg_recv(context, &src, &dest, &buffer_len, (uint8_t*)buffer);
if (ret) {
die("vsg_recv() failed", ret);
}
......
......@@ -15,7 +15,7 @@ int vsg_start(const struct vsg_context* context);
int vsg_stop(const struct vsg_context* context);
int vsg_gettimeofday(const struct vsg_context* context, struct timeval* timeval, void* timezone);
int vsg_send(const struct vsg_context* context, uint32_t src, uint32_t dest, uint32_t msglen, const uint8_t* msg);
int vsg_send(const struct vsg_context* context, uint32_t dest, uint32_t msglen, const uint8_t* msg);
int vsg_recv(const struct vsg_context* context, uint32_t* src, uint32_t* dest, uint32_t* msglen, uint8_t* msg);
int vsg_poll(const struct vsg_context* context);
......
......@@ -2,7 +2,7 @@
#[macro_use(local_vsg_address_str, local_vsg_address, remote_vsg_address)]
extern crate fake_vm;
use fake_vm::{Context, VsgAddress, Error, Result};
use fake_vm::{Context, Error, Result};
use libc::{self, uintptr_t};
#[allow(unused_imports)]
use log::{debug, error};
......@@ -107,7 +107,7 @@ pub unsafe extern fn vsg_gettimeofday(context: *const Context, timeval: *mut lib
}
}
/// Sends a message having source address `src`, destination address `dest` and a payload stored in
/// Sends a message having source address `src`, destination address `dst` and a payload stored in
/// `msg[0..msglen]`.
///
/// # Safety
......@@ -125,7 +125,7 @@ pub unsafe extern fn vsg_gettimeofday(context: *const Context, timeval: *mut lib
///
/// * Fails with `libc::ENOMEM` whenever there is no more buffers to hold the message to send.
#[no_mangle]
pub unsafe extern fn vsg_send(context: *const Context, src: VsgAddress, dest: VsgAddress, msglen: u32, msg: *const u8) -> c_int {
pub unsafe extern fn vsg_send(context: *const Context, dst: libc::in_addr_t, msglen: u32, msg: *const u8) -> c_int {
if let Some(context) = context.as_ref() {
// We can tolerate msg.is_null() if msglen == 0 but std::slice::from_raw_parts() requires
// non null pointers.
......@@ -139,7 +139,7 @@ pub unsafe extern fn vsg_send(context: *const Context, src: VsgAddress, dest: Vs
};
let payload = std::slice::from_raw_parts(ptr, msglen as usize);
match (*context).send(src, dest, payload) {
match (*context).send(dst, payload) {
Ok(_) => 0,
Err(e) => match e {
Error::NoMemoryAvailable => libc::ENOMEM,
......@@ -154,14 +154,14 @@ pub unsafe extern fn vsg_send(context: *const Context, src: VsgAddress, dest: Vs
}
/// Picks the next message in the receive queue, stores its payload in `msg[0..*msglen]` and
/// optionnally returns sender and destination addresses in `*psrc` and `*pdest` respectively. The
/// optionnally returns sender and destination addresses in `*psrc` and `*pdst` respectively. The
/// actual length of the received payload is stored in `*msglen`.
///
/// # Safety
///
/// * `context` should point to a valid context, as previously returned by [`vsg_init`].
///
/// * `psrc` and `pdest` can be `NULL`, in which case the correponding addresses will not be returned.
/// * `psrc` and `pdst` can be `NULL`, in which case the correponding addresses will not be returned.
///
/// * If `msglen` is `NULL` or `*msglen` is `0`, only 0-length messages can be received. Note that
/// in that case it is allowed that `msg` is `NULL` too.
......@@ -175,7 +175,7 @@ pub unsafe extern fn vsg_send(context: *const Context, src: VsgAddress, dest: Vs
/// * Fails with `libc::EMSGSIZE` whenever the next message in the queue has a payload bigger than
/// the provided buffer. The message is lost.
#[no_mangle]
pub unsafe extern fn vsg_recv(context: *const Context, psrc: *mut VsgAddress, pdest: *mut VsgAddress, msglen: *mut u32, msg: *mut u8) -> c_int {
pub unsafe extern fn vsg_recv(context: *const Context, psrc: *mut libc::in_addr_t, pdst: *mut libc::in_addr_t, msglen: *mut u32, msg: *mut u8) -> c_int {
const_assert!(fake_vm::MAX_PACKET_SIZE <= std::u32::MAX as usize);
if let Some(context) = context.as_ref() {
......@@ -197,12 +197,12 @@ pub unsafe extern fn vsg_recv(context: *const Context, psrc: *mut VsgAddress, pd
let payload = std::slice::from_raw_parts_mut(ptr, len as usize);
match (*context).recv(payload) {
Ok((src, dest, payload)) => {
Ok((src, dst, payload)) => {
if !psrc.is_null() {
*psrc = src;
}
if !pdest.is_null() {
*pdest = dest;
if !pdst.is_null() {
*pdst = dst;
}
if !msglen.is_null() {
*msglen = payload.len() as u32;
......@@ -545,9 +545,8 @@ mod test {
assert_eq!(0, res);
let buffer = b"Foo msg";
let src = local_vsg_address!();
let dest = remote_vsg_address!();
let res: c_int = unsafe { vsg_send(context, src, dest, buffer.len() as u32, buffer.as_ref().as_ptr()) };
let dst = remote_vsg_address!();
let res: c_int = unsafe { vsg_send(context, dst, buffer.len() as u32, buffer.as_ref().as_ptr()) };
assert_eq!(0, res);
let res: c_int = unsafe { vsg_stop(context) };
......@@ -569,9 +568,8 @@ mod test {
let res: c_int = unsafe { vsg_start(context) };
assert_eq!(0, res);
let src = local_vsg_address!();
let dest = remote_vsg_address!();
let res: c_int = unsafe { vsg_send(context, src, dest, 0, std::ptr::null()) };
let dst = remote_vsg_address!();
let res: c_int = unsafe { vsg_send(context, dst, 0, std::ptr::null()) };
assert_eq!(0, res);
let res: c_int = unsafe { vsg_stop(context) };
......@@ -593,14 +591,13 @@ mod test {
let res: c_int = unsafe { vsg_start(context) };
assert_eq!(0, res);
let src = local_vsg_address!();
let dest = remote_vsg_address!();
let res: c_int = unsafe { vsg_send(context, src, dest, 1, std::ptr::null()) };
let dst = remote_vsg_address!();
let res: c_int = unsafe { vsg_send(context, dst, 1, std::ptr::null()) };
assert_eq!(libc::EINVAL, res);
// Terminate gracefully
let buffer = b"Foo msg";
let res: c_int = unsafe { vsg_send(context, src, dest, buffer.len() as u32, buffer.as_ref().as_ptr()) };
let res: c_int = unsafe { vsg_send(context, dst, buffer.len() as u32, buffer.as_ref().as_ptr()) };
assert_eq!(0, res);
let res: c_int = unsafe { vsg_stop(context) };
......@@ -623,14 +620,13 @@ mod test {
assert_eq!(0, res);
let buffer = [0u8; fake_vm::MAX_PACKET_SIZE + 1];
let src = local_vsg_address!();
let dest = remote_vsg_address!();
let res: c_int = unsafe { vsg_send(context, src, dest, buffer.len() as u32, (&buffer).as_ptr()) };
let dst = remote_vsg_address!();
let res: c_int = unsafe { vsg_send(context, dst, buffer.len() as u32, (&buffer).as_ptr()) };
assert_eq!(libc::EMSGSIZE, res);
// Terminate gracefully
let buffer = b"Foo msg";
let res: c_int = unsafe { vsg_send(context, src, dest, buffer.len() as u32, buffer.as_ref().as_ptr()) };
let res: c_int = unsafe { vsg_send(context, dst, buffer.len() as u32, buffer.as_ref().as_ptr()) };
assert_eq!(0, res);
let res: c_int = unsafe { vsg_stop(context) };
......@@ -645,9 +641,8 @@ mod test {
init();
let buffer = b"Foo msg";
let src = local_vsg_address!();
let dest = remote_vsg_address!();
let res: c_int = unsafe { vsg_send(std::ptr::null(), src, dest, buffer.len() as u32, buffer.as_ref().as_ptr()) };
let dst = remote_vsg_address!();
let res: c_int = unsafe { vsg_send(std::ptr::null(), dst, buffer.len() as u32, buffer.as_ref().as_ptr()) };
assert_eq!(libc::EINVAL, res);
}
......@@ -677,9 +672,8 @@ mod test {
let res: c_int = unsafe { vsg_recv(context, &mut src, &mut dst, &mut buffer_len, buffer.as_mut().as_mut_ptr()) };
assert_eq!(0, res);
// FIXME: Use the remote address when available in the protocol
assert_eq!(src, local_vsg_address!());
assert_eq!(dst, local_vsg_address!());
assert_eq!(dst, remote_vsg_address!());
assert_eq!(buffer_len, EXPECTED_MSG.len() as u32);
assert_eq!(buffer, EXPECTED_MSG);
......@@ -715,7 +709,7 @@ mod test {
let res: c_int = unsafe { vsg_recv(context, std::ptr::null_mut(), &mut dst, &mut buffer_len, buffer.as_mut().as_mut_ptr()) };
assert_eq!(0, res);
assert_eq!(dst, local_vsg_address!());
assert_eq!(dst, remote_vsg_address!());
assert_eq!(buffer_len, EXPECTED_MSG.len() as u32);
assert_eq!(buffer, EXPECTED_MSG);
......@@ -787,9 +781,8 @@ mod test {
let res: c_int = unsafe { vsg_recv(context, &mut src, &mut dst, std::ptr::null_mut(), std::ptr::null_mut()) };
assert_eq!(0, res);
// FIXME: Use the remote address when available in the protocol
assert_eq!(src, local_vsg_address!());
assert_eq!(dst, local_vsg_address!());
assert_eq!(dst, remote_vsg_address!());
let res: c_int = unsafe { vsg_stop(context) };
assert_eq!(0, res);
......@@ -823,9 +816,8 @@ mod test {
let res: c_int = unsafe { vsg_recv(context, &mut src, &mut dst, &mut buffer_len, std::ptr::null_mut()) };
assert_eq!(0, res);
// FIXME: Use the remote address when available in the protocol
assert_eq!(src, local_vsg_address!());
assert_eq!(dst, local_vsg_address!());
assert_eq!(dst, remote_vsg_address!());
assert_eq!(buffer_len, 0);
let res: c_int = unsafe { vsg_stop(context) };
......@@ -860,9 +852,8 @@ mod test {
let res: c_int = unsafe { vsg_recv(context, &mut src, &mut dst, std::ptr::null_mut(), buffer.as_mut().as_mut_ptr()) };
assert_eq!(0, res);
// FIXME: Use the remote address when available in the protocol
assert_eq!(src, local_vsg_address!());
assert_eq!(dst, local_vsg_address!());
assert_eq!(dst, remote_vsg_address!());
assert_eq!(buffer, EXPECTED_MSG);
let res: c_int = unsafe { vsg_stop(context) };
......@@ -1038,9 +1029,8 @@ mod test {
let res: c_int = unsafe { vsg_recv(context, &mut src, &mut dst, &mut buffer_len, buffer.as_mut().as_mut_ptr()) };
assert_eq!(0, res);
// FIXME: Use the remote address when available in the protocol
assert_eq!(src, local_vsg_address!());
assert_eq!(dst, local_vsg_address!());
assert_eq!(dst, remote_vsg_address!());
assert_eq!(buffer_len, EXPECTED_MSG.len() as u32);
assert_eq!(buffer, EXPECTED_MSG);
......@@ -1070,9 +1060,8 @@ mod test {
assert_ne!(TIMEVAL_POISON.tv_usec, tv.tv_usec);
let buffer = b"This is the end";
let src = local_vsg_address!();
let dest = remote_vsg_address!();
let res: c_int = unsafe { vsg_send(context, src, dest, buffer.len() as u32, buffer.as_ref().as_ptr()) };
let dst = remote_vsg_address!();
let res: c_int = unsafe { vsg_send(context, dst, buffer.len() as u32, buffer.as_ref().as_ptr()) };
assert_eq!(0, res);
let res: c_int = unsafe { vsg_stop(context) };
......@@ -1098,9 +1087,8 @@ mod test {
assert_eq!(0, res);
let buffer = b"This is the end";
let src = local_vsg_address!();
let dest = remote_vsg_address!();
let res: c_int = unsafe { vsg_send(context, src, dest, buffer.len() as u32, buffer.as_ref().as_ptr()) };
let dst = remote_vsg_address!();
let res: c_int = unsafe { vsg_send(context, dst, buffer.len() as u32, buffer.as_ref().as_ptr()) };
assert_eq!(0, res);
let res: c_int = unsafe { vsg_stop(context) };
......
......@@ -39,9 +39,8 @@ int main(int argc, const char* argv[])
if (res)
die("vsg_gettimeofday() failed", res);
uint32_t src = 0;
uint32_t dest = 1;
res = vsg_send(context, src, dest, sizeof(msg), msg);
res = vsg_send(context, dest, sizeof(msg), msg);
if (res)
die("vsg_send() failed", res);
......@@ -49,6 +48,7 @@ int main(int argc, const char* argv[])