Work around missing lib on linux (Issue #4972) (#4975)

This commit is contained in:
Jack May
2019-07-08 22:24:57 -08:00
committed by GitHub
parent f9a2254688
commit 50c6b5d62d
6 changed files with 32 additions and 15 deletions

View File

@@ -17,7 +17,7 @@ pub fn many_args(
arg8: u64,
arg9: u64,
) -> u64 {
info!("another package");
info!("Another package");
info!(arg1, arg2, arg3, arg4, arg5);
info!(arg6, arg7, arg8, arg9, 0);
arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9
@@ -25,20 +25,19 @@ pub fn many_args(
#[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 pull_in_externs() {
// Rust on Linux excludes the solana_sdk_bpf_test library unless there is a
// direct dependency, use this test to force the pull in of the library.
// This is not necessary on macos and unfortunate on Linux
// Issue #4972
extern crate solana_sdk_bpf_test;
use solana_sdk_bpf_test::*;
unsafe { sol_log_("X".as_ptr(), 1) };
sol_log_64_(1, 2, 3, 4, 5);
}
#[test]