From 0ed360b5e5c02cecf71fe89b8e26bdeafd5ae852 Mon Sep 17 00:00:00 2001 From: Jack May Date: Mon, 31 Aug 2020 21:48:16 -0700 Subject: [PATCH] fix program test stubs (#11956) * fix program tset stubs * nudge --- ci/nits.sh | 1 + sdk/src/program_stubs.rs | 20 +++----------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/ci/nits.sh b/ci/nits.sh index 02225184d..9ec46e91e 100755 --- a/ci/nits.sh +++ b/ci/nits.sh @@ -26,6 +26,7 @@ declare print_free_tree=( ':runtime/src/**.rs' ':sdk/bpf/rust/rust-utils/**.rs' ':sdk/**.rs' + ':^sdk/src/program_stubs.rs' ':programs/**.rs' ':^**bin**.rs' ':^**bench**.rs' diff --git a/sdk/src/program_stubs.rs b/sdk/src/program_stubs.rs index f713001ba..9228f5a76 100644 --- a/sdk/src/program_stubs.rs +++ b/sdk/src/program_stubs.rs @@ -1,38 +1,24 @@ //! @brief Syscall stubs when building for non-BPF targets -#![cfg(feature = "program")] - -#[cfg(not(target_arch = "bpf"))] -fn print_line_to_stdout(_message: &str) { - #[cfg(not(feature = "program"))] - { - use std::io::{self, Write}; - io::stdout() - .write_all(format!("{}\n", _message).as_bytes()) - .unwrap(); - io::stdout().flush().unwrap(); - } -} - #[cfg(not(target_arch = "bpf"))] #[no_mangle] /// # Safety 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(); - print_line_to_stdout(string); + println!("{}", string); } #[cfg(not(target_arch = "bpf"))] #[no_mangle] pub fn sol_log_64_(arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u64) { - print_line_to_stdout(&format!("{} {} {} {} {}", arg1, arg2, arg3, arg4, arg5)); + println!("{} {} {} {} {}", arg1, arg2, arg3, arg4, arg5); } #[cfg(not(target_arch = "bpf"))] #[no_mangle] pub fn sol_invoke_signed_rust() { - print_line_to_stdout("sol_invoke_signed_rust()"); + println!("sol_invoke_signed_rust()"); } #[macro_export]