Add test to exercise more args then registers (#4661)

This commit is contained in:
Jack May 2019-06-12 13:04:53 -07:00 committed by GitHub
parent b78a13d42c
commit bc44516eb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 125 additions and 1 deletions

View File

@ -67,7 +67,7 @@ fn main() {
.expect("Unable to create BPF install directory")
.success());
let rust_programs = ["alloc", "dep_crate", "iter", "noop", "panic"];
let rust_programs = ["alloc", "dep_crate", "iter", "many_args", "noop", "panic"];
for program in rust_programs.iter() {
println!(
"cargo:warning=(not a warning) Building Rust-based BPF programs: solana_bpf_rust_{}",

View File

@ -0,0 +1,3 @@
/target/
Cargo.lock

View File

@ -0,0 +1,23 @@
# Note: This crate must be built using build.sh
[package]
name = "solana-bpf-rust-many-args"
version = "0.16.0"
description = "Solana BPF many-args program written in Rust"
authors = ["Solana Maintainers <maintainers@solana.com>"]
repository = "https://github.com/solana-labs/solana"
license = "Apache-2.0"
homepage = "https://solana.com/"
edition = "2018"
[dependencies]
solana-sdk-bpf-utils = { path = "../../../../sdk/bpf/rust-utils", version = "0.16.0" }
solana-bpf-rust-many-args-dep = { path = "../many_args_dep", version = "0.16.0" }
[workspace]
members = []
[lib]
crate-type = ["cdylib"]
name = "solana_bpf_rust_many_args"

View File

@ -0,0 +1,6 @@
[dependencies.compiler_builtins]
path = "../../../../sdk/bpf/rust-bpf-sysroot/src/compiler-builtins"
features = ["c", "mem"]
[target.bpfel-unknown-unknown.dependencies]
alloc = { path = "../../../../sdk/bpf/rust-bpf-sysroot/src/liballoc" }

View File

@ -0,0 +1,22 @@
//! @brief Example Rust-based BPF program tests loop iteration
extern crate solana_sdk_bpf_utils;
use solana_sdk_bpf_utils::log::*;
pub fn many_args(
arg1: u64,
arg2: u64,
arg3: u64,
arg4: u64,
arg5: u64,
arg6: u64,
arg7: u64,
arg8: u64,
arg9: u64,
) -> u64 {
sol_log("same package");
sol_log_64(arg1, arg2, arg3, arg4, arg5);
sol_log_64(arg6, arg7, arg8, arg9, 0);
arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9
}

View File

@ -0,0 +1,23 @@
//! @brief Example Rust-based BPF program tests loop iteration
#![no_std]
mod helper;
extern crate solana_sdk_bpf_utils;
use solana_sdk_bpf_utils::log::*;
#[no_mangle]
pub extern "C" fn entrypoint(_input: *mut u8) -> bool {
sol_log("call same package");
assert_eq!(crate::helper::many_args(1, 2, 3, 4, 5, 6, 7, 8, 9), 45);
sol_log("call another package");
assert_eq!(
solana_bpf_rust_many_args_dep::many_args(1, 2, 3, 4, 5, 6, 7, 8, 9),
45
);
sol_log("Success");
true
}

View File

@ -0,0 +1,3 @@
/target/
Cargo.lock

View File

@ -0,0 +1,19 @@
# Note: This crate must be built using build.sh
[package]
name = "solana-bpf-rust-many-args-dep"
version = "0.16.0"
description = "Solana BPF many-args-dep program written in Rust"
authors = ["Solana Maintainers <maintainers@solana.com>"]
repository = "https://github.com/solana-labs/solana"
license = "Apache-2.0"
homepage = "https://solana.com/"
edition = "2018"
[dependencies]
solana-sdk-bpf-utils = { path = "../../../../sdk/bpf/rust-utils", version = "0.16.0" }
[workspace]
members = []

View File

@ -0,0 +1,24 @@
//! @brief Solana Rust-based BPF program utility functions and types
#![no_std]
extern crate solana_sdk_bpf_utils;
use solana_sdk_bpf_utils::log::*;
pub fn many_args(
arg1: u64,
arg2: u64,
arg3: u64,
arg4: u64,
arg5: u64,
arg6: u64,
arg7: u64,
arg8: u64,
arg9: u64,
) -> u64 {
sol_log("another package");
sol_log_64(arg1, arg2, arg3, arg4, arg5);
sol_log_64(arg6, arg7, arg8, arg9, 0);
arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9
}

View File

@ -86,6 +86,7 @@ mod bpf {
let programs = [
("solana_bpf_rust_alloc", true),
("solana_bpf_rust_iter", true),
// ("solana_bpf_rust_many_args", true), // Issue #3099
("solana_bpf_rust_noop", true),
("solana_bpf_rust_dep_crate", true),
("solana_bpf_rust_panic", false),