Skip to content

Commit

Permalink
Merge pull request #8 from polachok/ctest
Browse files Browse the repository at this point in the history
Add ctest tests
  • Loading branch information
mrmonday committed Apr 13, 2016
2 parents 4646e04 + b712ce8 commit 46d7f2b
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
15 changes: 15 additions & 0 deletions netmap_test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "netmap_test"
version = "0.1.0"
authors = ["Alexander Polyakov <[email protected]>"]
build = "build.rs"

[dependencies.netmap_sys]
path = "../../netmap_sys"
features = [ "netmap_with_libs" ]

[dependencies]
libc = "0.2"

[build-dependencies]
ctest = { git = "https://github.com/libpnet/ctest", branch = "nowerror" }
24 changes: 24 additions & 0 deletions netmap_test/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
extern crate ctest;

fn main() {
let mut cfg = ctest::TestGenerator::new();

cfg.header("sys/time.h")
.header("sys/ioctl.h")
.header("net/if.h")
.header("net/netmap.h")
.header("net/netmap_user.h");

cfg.type_name(|ty, is_struct| {
if is_struct || ty == "timeval" {
format!("struct {}", ty)
} else {
ty.to_string()
}
});

cfg.include("netmap/sys");
cfg.include("/usr/include");

cfg.generate("../src/lib.rs", "all.rs");
}
11 changes: 11 additions & 0 deletions netmap_test/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#![allow(bad_style)]

extern crate netmap_sys;
extern crate libc;

//use netmap_sys::*;
use netmap_sys::netmap::*;
use netmap_sys::netmap_user::*;
use libc::*;

include!(concat!(env!("OUT_DIR"), "/all.rs"));

0 comments on commit 46d7f2b

Please sign in to comment.