Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
quininer committed May 16, 2019
1 parent f763a8b commit e3cdb01
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ os:
- osx

install:
- wget https://github.com/jedisct1/libsodium/releases/download/1.0.16/libsodium-1.0.16.tar.gz
- tar xvfz libsodium-1.0.16.tar.gz
- cd libsodium-1.0.16 && ./configure --prefix=$HOME/installed_libsodium && make && make install &&
- wget https://github.com/jedisct1/libsodium/releases/download/1.0.17/libsodium-1.0.17.tar.gz
- tar xvfz libsodium-1.0.17.tar.gz
- cd libsodium-1.0.17 && ./configure --prefix=$HOME/installed_libsodium && make && make install &&
cd ..
- export PKG_CONFIG_PATH=$HOME/installed_libsodium/lib/pkgconfig:$PKG_CONFIG_PATH
- export LD_LIBRARY_PATH=$HOME/installed_libsodium/lib:$LD_LIBRARY_PATH
Expand Down
6 changes: 3 additions & 3 deletions memsec-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ default-features = false

[dev-dependencies]
libc = "0.2"
quickcheck = "0.7"
quickcheck = "0.8"

[target.'cfg(unix)'.dev-dependencies]
libsodium-sys = "0.1.0"
nix = "0.11"
libsodium-sys = { version = "0.2", features = [ "use-pkg-config" ] }
nix = "0.13"

[features]
default = [ "alloc", "use_os" ]
Expand Down
17 changes: 5 additions & 12 deletions memsec-test/benches/memcmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extern crate memsec;

use test::Bencher;
use std::mem::size_of_val;
use libc::{ c_void, c_int, size_t };
use libc::c_void;


#[bench]
Expand Down Expand Up @@ -57,7 +57,7 @@ fn libsodium_memcmp_eq_bench(b: &mut Bencher) {
let y: [u8; 1025] = [9; 1025];

b.iter(|| unsafe {
libsodium_sys::sodium_memcmp(x.as_ptr(), y.as_ptr(), size_of_val(&y))
libsodium_sys::sodium_memcmp(x.as_ptr() as *const _, y.as_ptr() as *const _, size_of_val(&y))
});
}

Expand All @@ -68,7 +68,7 @@ fn libsodium_memcmp_nq_bench(b: &mut Bencher) {
let z: [u8; 1025] = [3; 1025];

b.iter(|| unsafe {
libsodium_sys::sodium_memcmp(x.as_ptr(), z.as_ptr(), size_of_val(&z))
libsodium_sys::sodium_memcmp(x.as_ptr() as *const _, z.as_ptr() as *const _, size_of_val(&z))
});
}

Expand All @@ -79,7 +79,7 @@ fn libsodium_compare_nq_bench(b: &mut Bencher) {
let z: [u8; 1025] = [3; 1025];

b.iter(|| unsafe {
sodium_compare(x.as_ptr(), z.as_ptr(), size_of_val(&z))
libsodium_sys::sodium_compare(x.as_ptr() as *const _, z.as_ptr() as *const _, size_of_val(&z))
});
}

Expand All @@ -90,7 +90,7 @@ fn libsodium_compare_eq_bench(b: &mut Bencher) {
let y: [u8; 1025] = [9; 1025];

b.iter(|| unsafe {
sodium_compare(x.as_ptr(), y.as_ptr(), size_of_val(&y))
libsodium_sys::sodium_compare(x.as_ptr() as *const _, y.as_ptr() as *const _, size_of_val(&y))
});
}

Expand All @@ -113,10 +113,3 @@ fn libc_memcmp_nq_bench(b: &mut Bencher) {
libc::memcmp(x.as_ptr() as *const c_void, z.as_ptr() as *const c_void, size_of_val(&z))
});
}


#[cfg(unix)]
#[link = "libsodium"]
extern "C" {
fn sodium_compare(b1_: *const u8, b2_: *const u8, len: size_t) -> c_int;
}
2 changes: 1 addition & 1 deletion memsec-test/benches/memzero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ fn libsodium_memzero_bench(b: &mut Bencher) {
let mut x: [u8; 1025] = [0; 1025];

b.iter(|| unsafe {
libsodium_sys::sodium_memzero(x.as_mut_ptr(), size_of_val(&x))
libsodium_sys::sodium_memzero(x.as_mut_ptr() as *mut _, size_of_val(&x))
});
}

0 comments on commit e3cdb01

Please sign in to comment.