Commit bb7fe069 authored by RILLING Louis's avatar RILLING Louis
Browse files

fake-vm: Separate out a common tansiv-client crate to easily build several flavors

parent e251b60b
......@@ -105,30 +105,18 @@ dependencies = [
name = "fake_vm"
version = "0.1.0"
dependencies = [
"binser",
"binser_derive",
"chrono",
"crossbeam-queue",
"lazy_static 1.4.0",
"libc",
"libc_timer",
"log",
"nix",
"seq_lock",
"static_assertions",
"stderrlog",
"structopt",
"tansiv-client",
]
[[package]]
name = "fake_vm_capi"
version = "0.1.0"
dependencies = [
"fake_vm",
"libc",
"log",
"static_assertions",
"stderrlog",
"tansiv-client",
]
[[package]]
......@@ -314,6 +302,25 @@ dependencies = [
"unicode-xid",
]
[[package]]
name = "tansiv-client"
version = "0.1.0"
dependencies = [
"binser",
"binser_derive",
"chrono",
"crossbeam-queue",
"lazy_static 1.4.0",
"libc",
"libc_timer",
"log",
"nix",
"seq_lock",
"static_assertions",
"stderrlog",
"structopt",
]
[[package]]
name = "termcolor"
version = "1.1.0"
......
[workspace]
members = ["fake_vm", "capi"]
members = ["tansiv-client", "fake_vm", "capi"]
default-members = ["fake_vm", "capi"]
......@@ -27,7 +27,7 @@ test: cargo-tests other-tests
.PHONY: cargo-tests
cargo-tests:
$(CARGO) test $(CARGO_FLAGS) -- --test-threads 1 $(TEST_FLAGS)
$(CARGO) test --workspace $(CARGO_FLAGS) -- --test-threads 1 $(TEST_FLAGS)
.PHONY: other-tests $(TEST_DIRS)
other-tests: $(TEST_DIRS)
......
......@@ -5,13 +5,13 @@ authors = ["Louis Rilling <louis.rilling@irisa.fr>"]
edition = "2018"
[dependencies]
fake_vm = {version = "0.1.0", path = "../fake_vm"}
tansiv-client = {version = "0.1.0", path = "../tansiv-client", features = ["process"]}
libc = "0.2"
log = "0.4"
static_assertions = "0.3.1"
[dev-dependencies]
fake_vm = {version = "0.1.0", path = "../fake_vm", features = ["test-helpers"]}
tansiv-client = {version = "0.1.0", path = "../tansiv-client", features = ["process", "test-helpers"]}
stderrlog = "0.4"
[lib]
......
#[cfg(test)]
#[macro_use(local_vsg_address_str, local_vsg_address, remote_vsg_address)]
extern crate fake_vm;
extern crate tansiv_client;
use fake_vm::{Context, Error, Result};
use tansiv_client::{Context, Error, Result};
use libc::{self, uintptr_t};
#[allow(unused_imports)]
use log::{debug, error};
......@@ -43,9 +43,9 @@ type CRecvCallback = unsafe extern "C" fn(uintptr_t);
#[no_mangle]
pub unsafe extern fn vsg_init(argc: c_int, argv: *const *const c_char, next_arg_p: *mut c_int, recv_callback: CRecvCallback, recv_callback_arg: uintptr_t) -> *mut Context {
let callback: fake_vm::RecvCallback = Box::new(move || recv_callback(recv_callback_arg));
let callback: tansiv_client::RecvCallback = Box::new(move || recv_callback(recv_callback_arg));
match parse_os_args(argc, argv, |args| fake_vm::init(args, callback)) {
match parse_os_args(argc, argv, |args| tansiv_client::init(args, callback)) {
Ok((context, next_arg)) => {
if let Some(next_arg_p) = next_arg_p.as_mut() {
*next_arg_p = next_arg;
......@@ -176,7 +176,7 @@ pub unsafe extern fn vsg_send(context: *const Context, dst: libc::in_addr_t, msg
/// the provided buffer. The message is lost.
#[no_mangle]
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);
const_assert!(tansiv_client::MAX_PACKET_SIZE <= std::u32::MAX as usize);
if let Some(context) = context.as_ref() {
let len = if msglen.is_null() {
......@@ -247,7 +247,7 @@ pub unsafe extern fn vsg_poll(context: *const Context) -> c_int {
#[cfg(test)]
mod test {
use fake_vm::test_helpers::*;
use tansiv_client::test_helpers::*;
use libc::timeval;
#[allow(unused_imports)]
use log::{error, info};
......@@ -396,7 +396,7 @@ mod test {
extern "C" fn dummy_recv_callback(_arg: uintptr_t) -> () {
}
// C-style version of fake_vm::test_helpers::RecvNotifier
// C-style version of tansiv_client::test_helpers::RecvNotifier
// Ugly
struct RecvNotifier(AtomicBool);
......@@ -619,7 +619,7 @@ mod test {
let res: c_int = unsafe { vsg_start(context) };
assert_eq!(0, res);
let buffer = [0u8; fake_vm::MAX_PACKET_SIZE + 1];
let buffer = [0u8; tansiv_client::MAX_PACKET_SIZE + 1];
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);
......
......@@ -4,25 +4,5 @@ version = "0.1.0"
authors = ["Louis Rilling <louis.rilling@irisa.fr>"]
edition = "2018"
[features]
default = []
test-helpers = ["stderrlog"]
[dependencies]
binser = {version = "0.1.0", path = "../../binser"}
binser_derive = {version = "0.1.0", path = "../../binser/binser_derive"}
chrono = "0.4"
crossbeam-queue = {path = "../../crossbeam/crossbeam-queue", features = ["spsc-waitfree"]}
lazy_static = "1.3.0"
libc = "0.2"
libc_timer = {version = "0.1.0", path = "../../libc_timer"}
log = "0.4"
nix = "0.11"
seq_lock = {version = "0.1.0", path = "../../seq_lock"}
static_assertions = "0.3.1"
structopt = "0.2"
stderrlog = {version = "0.4", optional = true}
[dev-dependencies]
stderrlog = "0.4"
tansiv-client = {version = "0.1.0", path = "../tansiv-client", features = ["process"]}
This diff is collapsed.
[package]
name = "tansiv-client"
version = "0.1.0"
authors = ["Louis Rilling <louis.rilling@irisa.fr>"]
edition = "2018"
[features]
default = []
process = []
test-helpers = ["stderrlog"]
[dependencies]
binser = {version = "0.1.0", path = "../../binser"}
binser_derive = {version = "0.1.0", path = "../../binser/binser_derive"}
chrono = "0.4"
crossbeam-queue = {path = "../../crossbeam/crossbeam-queue", features = ["spsc-waitfree"]}
lazy_static = "1.3.0"
libc = "0.2"
libc_timer = {version = "0.1.0", path = "../../libc_timer"}
log = "0.4"
nix = "0.11"
seq_lock = {version = "0.1.0", path = "../../seq_lock"}
static_assertions = "0.3.1"
structopt = "0.2"
stderrlog = {version = "0.4", optional = true}
[dev-dependencies]
stderrlog = "0.4"
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment