Add a new crate for testing `no-std`

* This needs to be enabled `.travis.yml` but I won´t dare changing it
becomes this will fail on `stable` compiler
* Run the test by `cargo test -p no-std-tests`
This commit is contained in:
Niklas Adofsson 2018-06-15 17:49:48 +02:00 committed by niklasad1
parent 05da6f2d0f
commit 2a311fbe11
3 changed files with 40 additions and 1 deletions

View File

@ -1,2 +1,2 @@
[workspace]
members = ["uint", "fixed-hash", "ethereum-types", "tests", "ethbloom"]
members = ["uint", "fixed-hash", "ethereum-types", "tests", "ethbloom", "no-std-tests"]

12
no-std-tests/Cargo.toml Normal file
View File

@ -0,0 +1,12 @@
[package]
name = "no-std-tests"
version = "0.0.1"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Tests for no-std environments"
license = "MIT"
[dependencies]
libc = { version = "0.2", default-features = false }
ethereum-types = { git = "https://github.com/niklasad1/primitives", default-features = false, branch = "ethereum-types/no-std" }
ethbloom = { git = "https://github.com/niklasad1/primitives", default-features = false, branch = "ethereum-types/no-std" }
fixed-hash = { git = "https://github.com/niklasad1/primitives", default-features = false, branch = "ethereum-types/no-std" }

27
no-std-tests/src/main.rs Normal file
View File

@ -0,0 +1,27 @@
#![feature(lang_items, start, panic_implementation)]
#![no_std]
extern crate libc;
extern crate ethereum_types;
extern crate ethbloom;
extern crate fixed_hash;
use ethereum_types::{Address, Public, Secret, Signature};
#[start]
fn start(_argc: isize, _argv: *const *const u8) -> isize {
0
}
#[cfg(not(test))]
#[lang = "eh_personality"]
#[no_mangle]
pub extern "C" fn rust_eh_personality() {}
#[cfg(not(test))]
#[panic_implementation]
fn panic(_info: &core::panic::PanicInfo) -> ! {
unsafe {
libc::abort();
}
}