From 459d39cb741eed29d665ac3fa80372b01fbbab95 Mon Sep 17 00:00:00 2001 From: Afonso Bordado Date: Sat, 29 Jul 2023 12:54:51 +0100 Subject: [PATCH] Use EbpfVmFixedMbuff in cranelift tests Signed-off-by: Afonso Bordado --- tests/cranelift.rs | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/tests/cranelift.rs b/tests/cranelift.rs index da1d4ff9a..d3203aec5 100644 --- a/tests/cranelift.rs +++ b/tests/cranelift.rs @@ -2118,8 +2118,7 @@ fn test_cranelift_ldabsb() { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, ]; - let mut vm = rbpf::EbpfVmRaw::new(Some(prog)).unwrap(); - assert_eq!(vm.execute_program(mem).unwrap(), 0x33); + let mut vm = rbpf::EbpfVmFixedMbuff::new(Some(prog), 0x00, 0x08).unwrap(); vm.cranelift_compile().unwrap(); assert_eq!(vm.execute_program_cranelift(mem).unwrap(), 0x33); @@ -2135,8 +2134,7 @@ fn test_cranelift_ldabsh() { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, ]; - let mut vm = rbpf::EbpfVmRaw::new(Some(prog)).unwrap(); - assert_eq!(vm.execute_program(mem).unwrap(), 0x4433); + let mut vm = rbpf::EbpfVmFixedMbuff::new(Some(prog), 0x00, 0x08).unwrap(); vm.cranelift_compile().unwrap(); assert_eq!(vm.execute_program_cranelift(mem).unwrap(), 0x4433); @@ -2152,10 +2150,9 @@ fn test_cranelift_ldabsw() { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, ]; - let mut vm = rbpf::EbpfVmRaw::new(Some(prog)).unwrap(); - assert_eq!(vm.execute_program(mem).unwrap(), 0x66554433); - vm.cranelift_compile().unwrap(); + let mut vm = rbpf::EbpfVmFixedMbuff::new(Some(prog), 0x00, 0x08).unwrap(); + vm.cranelift_compile().unwrap(); assert_eq!(vm.execute_program_cranelift(mem).unwrap(), 0x66554433); } @@ -2169,10 +2166,9 @@ fn test_cranelift_ldabsdw() { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, ]; - let mut vm = rbpf::EbpfVmRaw::new(Some(prog)).unwrap(); - assert_eq!(vm.execute_program(mem).unwrap(), 0xaa99887766554433); - vm.cranelift_compile().unwrap(); + let mut vm = rbpf::EbpfVmFixedMbuff::new(Some(prog), 0x00, 0x08).unwrap(); + vm.cranelift_compile().unwrap(); assert_eq!(vm.execute_program_cranelift(mem).unwrap(), 0xaa99887766554433); } @@ -2187,11 +2183,10 @@ fn test_cranelift_ldindb() { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, ]; - let mut vm = rbpf::EbpfVmRaw::new(Some(prog)).unwrap(); - assert_eq!(vm.execute_program(mem).unwrap(), 0x88); + let mut vm = rbpf::EbpfVmFixedMbuff::new(Some(prog), 0x00, 0x08).unwrap(); vm.cranelift_compile().unwrap(); - assert_eq!(vm.execute_program_cranelift(mem).unwrap(), 0x88); + assert_eq!(vm.execute_program_cranelift(mem).unwrap(), 0x88); } #[test] @@ -2205,11 +2200,10 @@ fn test_cranelift_ldindh() { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, ]; - let mut vm = rbpf::EbpfVmRaw::new(Some(prog)).unwrap(); - assert_eq!(vm.execute_program(mem).unwrap(), 0x9988); + let mut vm = rbpf::EbpfVmFixedMbuff::new(Some(prog), 0x00, 0x08).unwrap(); vm.cranelift_compile().unwrap(); - assert_eq!(vm.execute_program_cranelift(mem).unwrap(), 0x9988); + assert_eq!(vm.execute_program_cranelift(mem).unwrap(), 0x9988); } #[test] @@ -2223,10 +2217,9 @@ fn test_cranelift_ldindw() { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, ]; - let mut vm = rbpf::EbpfVmRaw::new(Some(prog)).unwrap(); - assert_eq!(vm.execute_program(mem).unwrap(), 0x88776655); - vm.cranelift_compile().unwrap(); + let mut vm = rbpf::EbpfVmFixedMbuff::new(Some(prog), 0x00, 0x08).unwrap(); + vm.cranelift_compile().unwrap(); assert_eq!(vm.execute_program_cranelift(mem).unwrap(), 0x88776655); } @@ -2241,9 +2234,8 @@ fn test_cranelift_ldinddw() { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, ]; - let mut vm = rbpf::EbpfVmRaw::new(Some(prog)).unwrap(); - assert_eq!(vm.execute_program(mem).unwrap(), 0xccbbaa9988776655); - vm.cranelift_compile().unwrap(); + let mut vm = rbpf::EbpfVmFixedMbuff::new(Some(prog), 0x00, 0x08).unwrap(); + vm.cranelift_compile().unwrap(); assert_eq!(vm.execute_program_cranelift(mem).unwrap(), 0xccbbaa9988776655); }