Split out Rust BPF no-std stuff (#4968)

This commit is contained in:
Jack May
2019-07-08 20:28:05 -08:00
committed by GitHub
parent 49250f62aa
commit f9a2254688
35 changed files with 164 additions and 217 deletions

View File

@ -14,6 +14,8 @@ edition = "2018"
[dependencies]
solana-sdk-bpf-utils = { path = "../../../../sdk/bpf/rust/rust-utils", version = "0.17.0" }
[workspace]
members = []
[dev_dependencies]
solana-sdk-bpf-test = { path = "../../../../sdk/bpf/rust/rust-test", version = "0.17.0" }
[workspace]
members = []

View File

@ -22,3 +22,27 @@ pub fn many_args(
info!(arg6, arg7, arg8, arg9, 0);
arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9
}
#[cfg(test)]
mod test {
extern crate solana_sdk_bpf_test;
extern crate std;
use super::*;
#[no_mangle]
pub unsafe fn sol_log_(message: *const u8, length: u64) {
let slice = std::slice::from_raw_parts(message, length as usize);
let string = std::str::from_utf8(&slice).unwrap();
std::println!("{}", string);
}
#[no_mangle]
pub fn sol_log_64_(arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u64) {
std::println!("{} {} {} {} {}", arg1, arg2, arg3, arg4, arg5);
}
#[test]
fn test_many_args() {
assert_eq!(45, many_args(1, 2, 3, 4, 5, 6, 7, 8, 9));
}
}