|
@@ -110,6 +110,7 @@ fn test_vm_block_port() {
|
|
|
// let prog = &text_scn.data;
|
|
|
// ---
|
|
|
|
|
|
+ #[rustfmt::skip]
|
|
|
let prog = &[
|
|
|
0xb7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
0x79, 0x12, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x79 instead of 0x61
|
|
@@ -138,6 +139,7 @@ fn test_vm_block_port() {
|
|
|
0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
|
];
|
|
|
|
|
|
+ #[rustfmt::skip]
|
|
|
let packet = &mut [
|
|
|
0x01, 0x23, 0x45, 0x67, 0x89, 0xab,
|
|
|
0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54,
|
|
@@ -192,6 +194,7 @@ fn test_jit_block_port() {
|
|
|
// let prog = &text_scn.data;
|
|
|
// ---
|
|
|
|
|
|
+ #[rustfmt::skip]
|
|
|
let prog = &[
|
|
|
0xb7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
0x79, 0x12, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x79 instead of 0x61
|
|
@@ -220,6 +223,7 @@ fn test_jit_block_port() {
|
|
|
0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
|
];
|
|
|
|
|
|
+ #[rustfmt::skip]
|
|
|
let packet = &mut [
|
|
|
0x01, 0x23, 0x45, 0x67, 0x89, 0xab,
|
|
|
0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54,
|
|
@@ -256,6 +260,7 @@ fn test_jit_block_port() {
|
|
|
// Program and memory come from uBPF test ldxh.
|
|
|
#[test]
|
|
|
fn test_vm_mbuff() {
|
|
|
+ #[rustfmt::skip]
|
|
|
let prog = &[
|
|
|
// Load mem from mbuff into R1
|
|
|
0x79, 0x11, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
@@ -310,6 +315,7 @@ fn test_vm_mbuff_with_rust_api() {
|
|
|
#[test]
|
|
|
#[cfg(all(not(windows), feature = "std"))]
|
|
|
fn test_jit_mbuff() {
|
|
|
+ #[rustfmt::skip]
|
|
|
let prog = &[
|
|
|
// Load mem from mbuff into R1
|
|
|
0x79, 0x11, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
@@ -339,10 +345,12 @@ fn test_jit_mbuff() {
|
|
|
#[cfg(all(not(windows), feature = "std"))]
|
|
|
#[test]
|
|
|
fn test_vm_jit_ldabsb() {
|
|
|
+ #[rustfmt::skip]
|
|
|
let prog = &[
|
|
|
0x30, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
|
|
0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
|
];
|
|
|
+ #[rustfmt::skip]
|
|
|
let mem = &mut [
|
|
|
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
|
|
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
|
|
@@ -359,10 +367,12 @@ fn test_vm_jit_ldabsb() {
|
|
|
#[cfg(all(not(windows), feature = "std"))]
|
|
|
#[test]
|
|
|
fn test_vm_jit_ldabsh() {
|
|
|
+ #[rustfmt::skip]
|
|
|
let prog = &[
|
|
|
0x28, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
|
|
0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
|
];
|
|
|
+ #[rustfmt::skip]
|
|
|
let mem = &mut [
|
|
|
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
|
|
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
|
|
@@ -379,10 +389,12 @@ fn test_vm_jit_ldabsh() {
|
|
|
#[cfg(all(not(windows), feature = "std"))]
|
|
|
#[test]
|
|
|
fn test_vm_jit_ldabsw() {
|
|
|
+ #[rustfmt::skip]
|
|
|
let prog = &[
|
|
|
0x20, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
|
|
0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
|
];
|
|
|
+ #[rustfmt::skip]
|
|
|
let mem = &mut [
|
|
|
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
|
|
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
|
|
@@ -399,10 +411,12 @@ fn test_vm_jit_ldabsw() {
|
|
|
#[cfg(all(not(windows), feature = "std"))]
|
|
|
#[test]
|
|
|
fn test_vm_jit_ldabsdw() {
|
|
|
+ #[rustfmt::skip]
|
|
|
let prog = &[
|
|
|
0x38, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
|
|
0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
|
];
|
|
|
+ #[rustfmt::skip]
|
|
|
let mem = &mut [
|
|
|
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
|
|
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
|
|
@@ -419,10 +433,12 @@ fn test_vm_jit_ldabsdw() {
|
|
|
#[test]
|
|
|
#[should_panic(expected = "Error: out of bounds memory load (insn #1),")]
|
|
|
fn test_vm_err_ldabsb_oob() {
|
|
|
+ #[rustfmt::skip]
|
|
|
let prog = &[
|
|
|
0x38, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00,
|
|
|
0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
|
];
|
|
|
+ #[rustfmt::skip]
|
|
|
let mem = &mut [
|
|
|
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
|
|
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
|
|
@@ -436,6 +452,7 @@ fn test_vm_err_ldabsb_oob() {
|
|
|
#[test]
|
|
|
#[should_panic(expected = "Error: out of bounds memory load (insn #1),")]
|
|
|
fn test_vm_err_ldabsb_nomem() {
|
|
|
+ #[rustfmt::skip]
|
|
|
let prog = &[
|
|
|
0x38, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
|
|
0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
@@ -449,11 +466,13 @@ fn test_vm_err_ldabsb_nomem() {
|
|
|
#[cfg(all(not(windows), feature = "std"))]
|
|
|
#[test]
|
|
|
fn test_vm_jit_ldindb() {
|
|
|
+ #[rustfmt::skip]
|
|
|
let prog = &[
|
|
|
0xb7, 0x01, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
|
|
|
0x50, 0x10, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
|
|
0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
|
];
|
|
|
+ #[rustfmt::skip]
|
|
|
let mem = &mut [
|
|
|
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
|
|
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
|
|
@@ -470,11 +489,13 @@ fn test_vm_jit_ldindb() {
|
|
|
#[cfg(all(not(windows), feature = "std"))]
|
|
|
#[test]
|
|
|
fn test_vm_jit_ldindh() {
|
|
|
+ #[rustfmt::skip]
|
|
|
let prog = &[
|
|
|
0xb7, 0x01, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
|
|
|
0x48, 0x10, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
|
|
0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
|
];
|
|
|
+ #[rustfmt::skip]
|
|
|
let mem = &mut [
|
|
|
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
|
|
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
|
|
@@ -491,11 +512,13 @@ fn test_vm_jit_ldindh() {
|
|
|
#[cfg(all(not(windows), feature = "std"))]
|
|
|
#[test]
|
|
|
fn test_vm_jit_ldindw() {
|
|
|
+ #[rustfmt::skip]
|
|
|
let prog = &[
|
|
|
0xb7, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
|
|
0x40, 0x10, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
|
|
0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
|
];
|
|
|
+ #[rustfmt::skip]
|
|
|
let mem = &mut [
|
|
|
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
|
|
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
|
|
@@ -512,11 +535,13 @@ fn test_vm_jit_ldindw() {
|
|
|
#[cfg(all(not(windows), feature = "std"))]
|
|
|
#[test]
|
|
|
fn test_vm_jit_ldinddw() {
|
|
|
+ #[rustfmt::skip]
|
|
|
let prog = &[
|
|
|
0xb7, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
|
|
0x58, 0x10, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
|
|
0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
|
];
|
|
|
+ #[rustfmt::skip]
|
|
|
let mem = &mut [
|
|
|
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
|
|
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
|
|
@@ -533,11 +558,13 @@ fn test_vm_jit_ldinddw() {
|
|
|
#[test]
|
|
|
#[should_panic(expected = "Error: out of bounds memory load (insn #2),")]
|
|
|
fn test_vm_err_ldindb_oob() {
|
|
|
+ #[rustfmt::skip]
|
|
|
let prog = &[
|
|
|
0xb7, 0x01, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
|
|
|
0x38, 0x10, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00,
|
|
|
0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
|
];
|
|
|
+ #[rustfmt::skip]
|
|
|
let mem = &mut [
|
|
|
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
|
|
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
|
|
@@ -551,6 +578,7 @@ fn test_vm_err_ldindb_oob() {
|
|
|
#[test]
|
|
|
#[should_panic(expected = "Error: out of bounds memory load (insn #2),")]
|
|
|
fn test_vm_err_ldindb_nomem() {
|
|
|
+ #[rustfmt::skip]
|
|
|
let prog = &[
|
|
|
0xb7, 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
|
|
0x38, 0x10, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
|
@@ -643,7 +671,8 @@ fn test_vm_jit_bpf_to_bpf_call(){
|
|
|
exit
|
|
|
mov64 r0, r2
|
|
|
add64 r0, r1
|
|
|
- exit").unwrap();
|
|
|
+ exit
|
|
|
+ ").unwrap();
|
|
|
let mut vm = rbpf::EbpfVmNoData::new(Some(&test_code)).unwrap();
|
|
|
vm.jit_compile().unwrap();
|
|
|
let vm_res= unsafe { vm.execute_program_jit().unwrap() };
|
|
@@ -653,6 +682,7 @@ fn test_vm_jit_bpf_to_bpf_call(){
|
|
|
#[test]
|
|
|
#[should_panic(expected = "[Verifier] Error: unsupported call type #2 (insn #0)")]
|
|
|
fn test_verifier_err_other_type_call(){
|
|
|
+ #[rustfmt::skip]
|
|
|
let prog = &[
|
|
|
0x85, 0x20, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
|
|
0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
@@ -664,6 +694,7 @@ fn test_verifier_err_other_type_call(){
|
|
|
#[test]
|
|
|
#[should_panic(expected = "Error: unsupported call type #2 (insn #0)")]
|
|
|
fn test_vm_other_type_call(){
|
|
|
+ #[rustfmt::skip]
|
|
|
let prog = &[
|
|
|
0x85, 0x20, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
|
|
0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
@@ -680,6 +711,7 @@ fn test_vm_other_type_call(){
|
|
|
#[test]
|
|
|
#[should_panic(expected = "[JIT] Error: unexpected call type #2 (insn #0)")]
|
|
|
fn test_vm_jit_other_type_call(){
|
|
|
+ #[rustfmt::skip]
|
|
|
let prog = &[
|
|
|
0x85, 0x20, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
|
|
0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
@@ -712,7 +744,8 @@ fn test_stack_overflow(){
|
|
|
exit
|
|
|
mov64 r0, r2
|
|
|
add64 r0, r1
|
|
|
- exit").unwrap();
|
|
|
+ exit
|
|
|
+ ").unwrap();
|
|
|
let mut vm = rbpf::EbpfVmNoData::new(Some(&test_code)).unwrap();
|
|
|
vm.set_stack_usage_calculator(|_,_,_| 512, Box::new(())).unwrap();
|
|
|
vm.execute_program().unwrap();
|