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

Merge branch 'dev/tanqemu'

parents fb805b5a 8f47fc69
Pipeline #175639 failed with stages
in 4 minutes and 9 seconds
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "aho-corasick"
version = "0.7.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86"
dependencies = [
"memchr",
]
[[package]]
name = "ansi_term"
version = "0.11.0"
......@@ -26,6 +35,30 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
[[package]]
name = "bindgen"
version = "0.55.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75b13ce559e6433d360c26305643803cb52cfbabbc2b9c47ce04a58493dfb443"
dependencies = [
"bitflags",
"cexpr",
"cfg-if",
"clang-sys",
"clap",
"env_logger",
"lazy_static 1.4.0",
"lazycell",
"log",
"peeking_take_while",
"proc-macro2 1.0.23",
"quote 1.0.7",
"regex",
"rustc-hash",
"shlex",
"which",
]
[[package]]
name = "binser"
version = "0.1.0"
......@@ -34,8 +67,8 @@ version = "0.1.0"
name = "binser_derive"
version = "0.1.0"
dependencies = [
"proc-macro2",
"quote",
"proc-macro2 0.4.30",
"quote 0.6.13",
"syn",
]
......@@ -45,12 +78,32 @@ version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "capi"
version = "0.1.0"
dependencies = [
"libc",
"log",
"static_assertions",
"stderrlog",
"tansiv-client",
]
[[package]]
name = "cc"
version = "1.0.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd"
[[package]]
name = "cexpr"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27"
dependencies = [
"nom",
]
[[package]]
name = "cfg-if"
version = "0.1.10"
......@@ -68,6 +121,17 @@ dependencies = [
"time",
]
[[package]]
name = "clang-sys"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9da1484c6a890e374ca5086062d4847e0a2c1e5eba9afa5d48c09e8eb39b2519"
dependencies = [
"glob",
"libc",
"libloading",
]
[[package]]
name = "clap"
version = "2.33.0"
......@@ -101,36 +165,39 @@ dependencies = [
"lazy_static 1.4.0",
]
[[package]]
name = "env_logger"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
dependencies = [
"atty",
"humantime",
"log",
"regex",
"termcolor",
]
[[package]]
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",
"capi",
]
[[package]]
name = "glob"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
[[package]]
name = "heck"
version = "0.3.1"
......@@ -140,6 +207,15 @@ dependencies = [
"unicode-segmentation",
]
[[package]]
name = "humantime"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
dependencies = [
"quick-error",
]
[[package]]
name = "lazy_static"
version = "0.2.11"
......@@ -152,6 +228,12 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "lazycell"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libc"
version = "0.2.68"
......@@ -166,6 +248,16 @@ dependencies = [
"nix",
]
[[package]]
name = "libloading"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2443d8f0478b16759158b2f66d525991a05491138bc05814ef52a250148ef4f9"
dependencies = [
"cfg-if",
"winapi",
]
[[package]]
name = "log"
version = "0.4.8"
......@@ -181,6 +273,12 @@ version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
[[package]]
name = "memchr"
version = "2.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
[[package]]
name = "nix"
version = "0.11.1"
......@@ -194,6 +292,16 @@ dependencies = [
"void",
]
[[package]]
name = "nom"
version = "5.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af"
dependencies = [
"memchr",
"version_check",
]
[[package]]
name = "num-integer"
version = "0.1.42"
......@@ -219,22 +327,52 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef"
[[package]]
name = "peeking_take_while"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
[[package]]
name = "proc-macro2"
version = "0.4.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
dependencies = [
"unicode-xid",
"unicode-xid 0.1.0",
]
[[package]]
name = "proc-macro2"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51ef7cd2518ead700af67bf9d1a658d90b6037d77110fd9c0445429d0ba1c6c9"
dependencies = [
"unicode-xid 0.2.1",
]
[[package]]
name = "quick-error"
version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
[[package]]
name = "quote"
version = "0.6.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
dependencies = [
"proc-macro2",
"proc-macro2 0.4.30",
]
[[package]]
name = "quote"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
dependencies = [
"proc-macro2 1.0.23",
]
[[package]]
......@@ -252,10 +390,40 @@ dependencies = [
"redox_syscall",
]
[[package]]
name = "regex"
version = "1.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
"thread_local 1.0.1",
]
[[package]]
name = "regex-syntax"
version = "0.6.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8"
[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "seq_lock"
version = "0.1.0"
[[package]]
name = "shlex"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
[[package]]
name = "static_assertions"
version = "0.3.4"
......@@ -272,7 +440,7 @@ dependencies = [
"chrono",
"log",
"termcolor",
"thread_local",
"thread_local 0.3.4",
]
[[package]]
......@@ -298,8 +466,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53010261a84b37689f9ed7d395165029f9cc7abb9f56bbfe86bee2597ed25107"
dependencies = [
"heck",
"proc-macro2",
"quote",
"proc-macro2 0.4.30",
"quote 0.6.13",
"syn",
]
......@@ -309,9 +477,43 @@ version = "0.15.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5"
dependencies = [
"proc-macro2",
"quote",
"unicode-xid",
"proc-macro2 0.4.30",
"quote 0.6.13",
"unicode-xid 0.1.0",
]
[[package]]
name = "tanqemu"
version = "0.1.0"
dependencies = [
"tansiv-client",
]
[[package]]
name = "tanqemu_capi"
version = "0.1.0"
dependencies = [
"capi",
]
[[package]]
name = "tansiv-client"
version = "0.1.0"
dependencies = [
"bindgen",
"binser",
"binser_derive",
"chrono",
"crossbeam-queue",
"lazy_static 1.4.0",
"libc",
"libc_timer",
"log",
"nix",
"seq_lock",
"static_assertions",
"stderrlog",
"structopt",
]
[[package]]
......@@ -354,6 +556,15 @@ dependencies = [
"unreachable",
]
[[package]]
name = "thread_local"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
dependencies = [
"lazy_static 1.4.0",
]
[[package]]
name = "time"
version = "0.1.42"
......@@ -383,6 +594,12 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
[[package]]
name = "unicode-xid"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
[[package]]
name = "unreachable"
version = "1.0.0"
......@@ -398,12 +615,27 @@ version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
[[package]]
name = "version_check"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
[[package]]
name = "void"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
[[package]]
name = "which"
version = "3.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724"
dependencies = [
"libc",
]
[[package]]
name = "winapi"
version = "0.3.8"
......
[workspace]
members = ["fake_vm", "capi"]
members = ["tansiv-client", "capi", "fake_vm", "fake_vm_capi", "tanqemu", "tanqemu_capi"]
default-members = ["fake_vm_capi", "tanqemu_capi"]
LIB_CRATES := fake_vm_capi tanqemu_capi
CARGO := cargo
CARGO_ENV ?=
CARGO_FLAGS ?=
TEST_FLAGS ?=
PREFIX ?= /usr/local
TOP_DIR := $(shell pwd)
QEMU_SRC ?= $(TOP_DIR)/../qemu
QEMU_BUILD ?= $(TOP_DIR)/../qemu
CARGO_ENV += QEMU_SRC=$(QEMU_SRC) QEMU_BUILD=$(QEMU_BUILD)
ifeq ($(RELEASE),)
PROFILE := debug
else
......@@ -13,21 +21,24 @@ else
endif
OUT_DIR := $(TOP_DIR)/target/$(PROFILE)
TEST_DIRS := $(TOP_DIR)/capi/tests
TEST_DIRS := $(TOP_DIR)/fake_vm_capi/tests
DEST_LIB_DIR := $(PREFIX)/lib
DEST_INC_DIR := $(PREFIX)/include
.PHONY: build
build:
$(CARGO) build $(CARGO_FLAGS)
build: $(LIB_CRATES)
.PHONY: $(LIB_CRATES)
$(LIB_CRATES):
$(CARGO_ENV) $(CARGO) build -p $@ $(CARGO_FLAGS)
.PHONY: test
test: cargo-tests other-tests
.PHONY: cargo-tests
cargo-tests:
$(CARGO) test $(CARGO_FLAGS) -- --test-threads 1 $(TEST_FLAGS)
$(CARGO_ENV) $(CARGO) test --workspace $(CARGO_FLAGS) -- --test-threads 1 $(TEST_FLAGS)
.PHONY: other-tests $(TEST_DIRS)
other-tests: $(TEST_DIRS)
......
[package]
name = "fake_vm_capi"
name = "capi"
version = "0.1.0"
authors = ["Louis Rilling <l.rilling@av7.net>"]
authors = ["Louis Rilling <louis.rilling@irisa.fr>"]
edition = "2018"
[features]
default = []
process = ["tansiv-client/process"]
qemu = ["tansiv-client/qemu"]
[dependencies]
fake_vm = {version = "0.1.0", path = "../fake_vm"}
tansiv-client = {version = "0.1.0", path = "../tansiv-client"}
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 = ["test-helpers"]}
stderrlog = "0.4"
[lib]
name = "fake_vm"
crate-type = ["staticlib"]
#[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};
use static_assertions::const_assert;
use std::os::raw::{c_char, c_int};
use std::sync::Arc;
unsafe fn parse_os_args<F, T>(argc: c_int, argv: *const *const c_char, parse: F) -> Result<(T, c_int)>
where F: FnOnce(&mut dyn Iterator<Item = std::borrow::Cow<'static, std::ffi::OsStr>>) -> Result<T>
......@@ -42,15 +43,15 @@ unsafe fn parse_os_args<F, T>(argc: c_int, argv: *const *const c_char, parse: F)
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));
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) -> *const Context {
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;
}
Box::into_raw(context)
Arc::into_raw(context)
},
Err(e) => {
error!("vsg_init failed: {}", e);
......@@ -60,9 +61,9 @@ pub unsafe extern fn vsg_init(argc: c_int, argv: *const *const c_char, next_arg_
}
#[no_mangle]
pub unsafe extern fn vsg_cleanup(context: *mut Context) {
if let Some(context) = context.as_mut() {
drop(Box::from_raw(context));
pub unsafe extern fn vsg_cleanup(context: *const Context) {
if !context.is_null() {
drop(Arc::from_raw(context));
}
}
......@@ -176,7 +177,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 +248,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 +397,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 +620,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);
......
[package]
name = "fake_vm"
version = "0.1.0"
authors = ["Louis Rilling <l.rilling@av7.net>"]
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"
<