Ver Fonte

tests: factor out tcp_sack data into a common file

Rich Lane há 8 anos atrás
pai
commit
5a0f2ef657
3 ficheiros alterados com 152 adições e 152 exclusões
  1. 131 0
      tests/common.rs
  2. 11 76
      tests/ubpf_jit_x86_64.rs
  3. 10 76
      tests/ubpf_vm.rs

+ 131 - 0
tests/common.rs

@@ -0,0 +1,131 @@
+// Converted from the tests for uBPF <https://github.com/iovisor/ubpf>
+// Copyright 2015 Big Switch Networks, Inc
+// Copyright 2016 6WIND S.A. <quentin.monnet@6wind.com>
+//
+// Licensed under the Apache License, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0> or
+// the MIT license <http://opensource.org/licenses/MIT>, at your option. This file may not be
+// copied, modified, or distributed except according to those terms.
+
+// Assembly code and data for tcp_sack testcases.
+
+#[allow(dead_code)]
+pub const TCP_SACK_ASM: &'static str = "
+    ldxb r2, [r1+12]
+    ldxb r3, [r1+13]
+    lsh r3, 0x8
+    or r3, r2
+    mov r0, 0x0
+    jne r3, 0x8, +37
+    ldxb r2, [r1+23]
+    jne r2, 0x6, +35
+    ldxb r2, [r1+14]
+    add r1, 0xe
+    and r2, 0xf
+    lsh r2, 0x2
+    add r1, r2
+    mov r0, 0x0
+    ldxh r4, [r1+12]
+    add r1, 0x14
+    rsh r4, 0x2
+    and r4, 0x3c
+    mov r2, r4
+    add r2, 0xffffffec
+    mov r5, 0x15
+    mov r3, 0x0
+    jgt r5, r4, +20
+    mov r5, r3
+    lsh r5, 0x20
+    arsh r5, 0x20
+    mov r4, r1
+    add r4, r5
+    ldxb r5, [r4]
+    jeq r5, 0x1, +4
+    jeq r5, 0x0, +12
+    mov r6, r3
+    jeq r5, 0x5, +9
+    ja +2
+    add r3, 0x1
+    mov r6, r3
+    ldxb r3, [r4+1]
+    add r3, r6
+    lsh r3, 0x20
+    arsh r3, 0x20
+    jsgt r2, r3, -18
+    ja +1
+    mov r0, 0x1
+    exit";
+
+#[allow(dead_code)]
+pub const TCP_SACK_BIN: [u8;352] = [
+    0x71, 0x12, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x71, 0x13, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x67, 0x03, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+    0x4f, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0xb7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x55, 0x03, 0x25, 0x00, 0x08, 0x00, 0x00, 0x00,
+    0x71, 0x12, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x55, 0x02, 0x23, 0x00, 0x06, 0x00, 0x00, 0x00,
+    0x71, 0x12, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x07, 0x01, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
+    0x57, 0x02, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
+    0x67, 0x02, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+    0x0f, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0xb7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x69, 0x14, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x07, 0x01, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
+    0x77, 0x04, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+    0x57, 0x04, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
+    0xbf, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x07, 0x02, 0x00, 0x00, 0xec, 0xff, 0xff, 0xff,
+    0xb7, 0x05, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00,
+    0xb7, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x2d, 0x45, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0xbf, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x67, 0x05, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
+    0xc7, 0x05, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
+    0xbf, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x0f, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x71, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x15, 0x05, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00,
+    0x15, 0x05, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0xbf, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x15, 0x05, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00,
+    0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x07, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+    0xbf, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x71, 0x43, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x0f, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x67, 0x03, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
+    0xc7, 0x03, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
+    0x6d, 0x32, 0xee, 0xff, 0x00, 0x00, 0x00, 0x00,
+    0x05, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0xb7, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+    0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+];
+
+#[allow(dead_code)]
+pub const TCP_SACK_MATCH: [u8;78] = [
+    0x00, 0x26, 0x62, 0x2f, 0x47, 0x87, 0x00, 0x1d,
+    0x60, 0xb3, 0x01, 0x84, 0x08, 0x00, 0x45, 0x00,
+    0x00, 0x40, 0xa8, 0xde, 0x40, 0x00, 0x40, 0x06,
+    0x9d, 0x58, 0xc0, 0xa8, 0x01, 0x03, 0x3f, 0x74,
+    0xf3, 0x61, 0xe5, 0xc0, 0x00, 0x50, 0xe5, 0x94,
+    0x3f, 0x77, 0xa3, 0xc4, 0xc4, 0x80, 0xb0, 0x10,
+    0x01, 0x3e, 0x34, 0xb6, 0x00, 0x00, 0x01, 0x01,
+    0x08, 0x0a, 0x00, 0x17, 0x95, 0x6f, 0x8d, 0x9d,
+    0x9e, 0x27, 0x01, 0x01, 0x05, 0x0a, 0xa3, 0xc4,
+    0xca, 0x28, 0xa3, 0xc4, 0xcf, 0xd0
+];
+
+#[allow(dead_code)]
+pub const TCP_SACK_NOMATCH: [u8;66] = [
+    0x00, 0x26, 0x62, 0x2f, 0x47, 0x87, 0x00, 0x1d,
+    0x60, 0xb3, 0x01, 0x84, 0x08, 0x00, 0x45, 0x00,
+    0x00, 0x40, 0xa8, 0xde, 0x40, 0x00, 0x40, 0x06,
+    0x9d, 0x58, 0xc0, 0xa8, 0x01, 0x03, 0x3f, 0x74,
+    0xf3, 0x61, 0xe5, 0xc0, 0x00, 0x50, 0xe5, 0x94,
+    0x3f, 0x77, 0xa3, 0xc4, 0xc4, 0x80, 0x80, 0x10,
+    0x01, 0x3e, 0x34, 0xb6, 0x00, 0x00, 0x01, 0x01,
+    0x08, 0x0a, 0x00, 0x17, 0x95, 0x6f, 0x8d, 0x9d,
+    0x9e, 0x27
+];

+ 11 - 76
tests/ubpf_jit_x86_64.rs

@@ -22,8 +22,11 @@
 
 
 extern crate rbpf;
+mod common;
 
 use rbpf::helpers;
+use rbpf::assembler::assemble;
+use common::{TCP_SACK_ASM, TCP_SACK_MATCH, TCP_SACK_NOMATCH};
 
 #[test]
 fn test_jit_add() {
@@ -1785,88 +1788,20 @@ fn test_jit_tcp_port80_nomatch_proto() {
     unsafe { assert_eq!(vm.prog_exec_jit(mem), 0x0); }
 }
 
-const PROG_TCP_SACK: [u8;352] = [
-    0x71, 0x12, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x71, 0x13, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x67, 0x03, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
-    0x4f, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0xb7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x55, 0x03, 0x25, 0x00, 0x08, 0x00, 0x00, 0x00,
-    0x71, 0x12, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x55, 0x02, 0x23, 0x00, 0x06, 0x00, 0x00, 0x00,
-    0x71, 0x12, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x07, 0x01, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
-    0x57, 0x02, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
-    0x67, 0x02, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
-    0x0f, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0xb7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x69, 0x14, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x07, 0x01, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
-    0x77, 0x04, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
-    0x57, 0x04, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
-    0xbf, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x07, 0x02, 0x00, 0x00, 0xec, 0xff, 0xff, 0xff,
-    0xb7, 0x05, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00,
-    0xb7, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x2d, 0x45, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0xbf, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x67, 0x05, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
-    0xc7, 0x05, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
-    0xbf, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x0f, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x71, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x15, 0x05, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00,
-    0x15, 0x05, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0xbf, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x15, 0x05, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00,
-    0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x07, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-    0xbf, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x71, 0x43, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x0f, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x67, 0x03, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
-    0xc7, 0x03, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
-    0x6d, 0x32, 0xee, 0xff, 0x00, 0x00, 0x00, 0x00,
-    0x05, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0xb7, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-    0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-];
-
 #[test]
 fn test_jit_tcp_sack_match() {
-    let mem = &mut [
-        0x00, 0x26, 0x62, 0x2f, 0x47, 0x87, 0x00, 0x1d,
-        0x60, 0xb3, 0x01, 0x84, 0x08, 0x00, 0x45, 0x00,
-        0x00, 0x40, 0xa8, 0xde, 0x40, 0x00, 0x40, 0x06,
-        0x9d, 0x58, 0xc0, 0xa8, 0x01, 0x03, 0x3f, 0x74,
-        0xf3, 0x61, 0xe5, 0xc0, 0x00, 0x50, 0xe5, 0x94,
-        0x3f, 0x77, 0xa3, 0xc4, 0xc4, 0x80, 0xb0, 0x10,
-        0x01, 0x3e, 0x34, 0xb6, 0x00, 0x00, 0x01, 0x01,
-        0x08, 0x0a, 0x00, 0x17, 0x95, 0x6f, 0x8d, 0x9d,
-        0x9e, 0x27, 0x01, 0x01, 0x05, 0x0a, 0xa3, 0xc4,
-        0xca, 0x28, 0xa3, 0xc4, 0xcf, 0xd0
-    ];
-    let prog = &PROG_TCP_SACK;
-    let mut vm = rbpf::EbpfVmRaw::new(prog);
+    let mut mem = TCP_SACK_MATCH.to_vec();
+    let prog = assemble(TCP_SACK_ASM).unwrap();
+    let mut vm = rbpf::EbpfVmRaw::new(&prog);
     vm.jit_compile();
-    unsafe { assert_eq!(vm.prog_exec_jit(mem), 0x1); }
+    unsafe { assert_eq!(vm.prog_exec_jit(mem.as_mut_slice()), 0x1); }
 }
 
 #[test]
 fn test_jit_tcp_sack_nomatch() {
-    let mem = &mut [
-        0x00, 0x26, 0x62, 0x2f, 0x47, 0x87, 0x00, 0x1d,
-        0x60, 0xb3, 0x01, 0x84, 0x08, 0x00, 0x45, 0x00,
-        0x00, 0x40, 0xa8, 0xde, 0x40, 0x00, 0x40, 0x06,
-        0x9d, 0x58, 0xc0, 0xa8, 0x01, 0x03, 0x3f, 0x74,
-        0xf3, 0x61, 0xe5, 0xc0, 0x00, 0x50, 0xe5, 0x94,
-        0x3f, 0x77, 0xa3, 0xc4, 0xc4, 0x80, 0x80, 0x10,
-        0x01, 0x3e, 0x34, 0xb6, 0x00, 0x00, 0x01, 0x01,
-        0x08, 0x0a, 0x00, 0x17, 0x95, 0x6f, 0x8d, 0x9d,
-        0x9e, 0x27
-    ];
-    let prog = &PROG_TCP_SACK;
-    let mut vm = rbpf::EbpfVmRaw::new(prog);
+    let mut mem = TCP_SACK_NOMATCH.to_vec();
+    let prog = assemble(TCP_SACK_ASM).unwrap();
+    let mut vm = rbpf::EbpfVmRaw::new(&prog);
     vm.jit_compile();
-    unsafe { assert_eq!(vm.prog_exec_jit(mem), 0x0); }
+    unsafe { assert_eq!(vm.prog_exec_jit(mem.as_mut_slice()), 0x0); }
 }

+ 10 - 76
tests/ubpf_vm.rs

@@ -22,9 +22,11 @@
 
 
 extern crate rbpf;
+mod common;
 
 use rbpf::helpers;
 use rbpf::assembler::assemble;
+use common::{TCP_SACK_ASM, TCP_SACK_MATCH, TCP_SACK_NOMATCH};
 
 #[test]
 fn test_vm_add() {
@@ -1684,86 +1686,18 @@ fn test_vm_tcp_port80_nomatch_proto() {
     assert_eq!(vm.prog_exec(mem), 0x0);
 }
 
-const PROG_TCP_SACK: [u8;352] = [
-    0x71, 0x12, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x71, 0x13, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x67, 0x03, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
-    0x4f, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0xb7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x55, 0x03, 0x25, 0x00, 0x08, 0x00, 0x00, 0x00,
-    0x71, 0x12, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x55, 0x02, 0x23, 0x00, 0x06, 0x00, 0x00, 0x00,
-    0x71, 0x12, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x07, 0x01, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
-    0x57, 0x02, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
-    0x67, 0x02, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
-    0x0f, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0xb7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x69, 0x14, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x07, 0x01, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
-    0x77, 0x04, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
-    0x57, 0x04, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
-    0xbf, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x07, 0x02, 0x00, 0x00, 0xec, 0xff, 0xff, 0xff,
-    0xb7, 0x05, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00,
-    0xb7, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x2d, 0x45, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0xbf, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x67, 0x05, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
-    0xc7, 0x05, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
-    0xbf, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x0f, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x71, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x15, 0x05, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00,
-    0x15, 0x05, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0xbf, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x15, 0x05, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00,
-    0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x07, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-    0xbf, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x71, 0x43, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x0f, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x67, 0x03, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
-    0xc7, 0x03, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
-    0x6d, 0x32, 0xee, 0xff, 0x00, 0x00, 0x00, 0x00,
-    0x05, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0xb7, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-    0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-];
-
 #[test]
 fn test_vm_tcp_sack_match() {
-    let mem = &mut [
-        0x00, 0x26, 0x62, 0x2f, 0x47, 0x87, 0x00, 0x1d,
-        0x60, 0xb3, 0x01, 0x84, 0x08, 0x00, 0x45, 0x00,
-        0x00, 0x40, 0xa8, 0xde, 0x40, 0x00, 0x40, 0x06,
-        0x9d, 0x58, 0xc0, 0xa8, 0x01, 0x03, 0x3f, 0x74,
-        0xf3, 0x61, 0xe5, 0xc0, 0x00, 0x50, 0xe5, 0x94,
-        0x3f, 0x77, 0xa3, 0xc4, 0xc4, 0x80, 0xb0, 0x10,
-        0x01, 0x3e, 0x34, 0xb6, 0x00, 0x00, 0x01, 0x01,
-        0x08, 0x0a, 0x00, 0x17, 0x95, 0x6f, 0x8d, 0x9d,
-        0x9e, 0x27, 0x01, 0x01, 0x05, 0x0a, 0xa3, 0xc4,
-        0xca, 0x28, 0xa3, 0xc4, 0xcf, 0xd0
-    ];
-    let prog = &PROG_TCP_SACK;
-    let vm = rbpf::EbpfVmRaw::new(prog);
-    assert_eq!(vm.prog_exec(mem), 0x1);
+    let mut mem = TCP_SACK_MATCH.to_vec();
+    let prog = assemble(TCP_SACK_ASM).unwrap();
+    let vm = rbpf::EbpfVmRaw::new(&prog);
+    assert_eq!(vm.prog_exec(mem.as_mut_slice()), 0x1);
 }
 
 #[test]
 fn test_vm_tcp_sack_nomatch() {
-    let mem = &mut [
-        0x00, 0x26, 0x62, 0x2f, 0x47, 0x87, 0x00, 0x1d,
-        0x60, 0xb3, 0x01, 0x84, 0x08, 0x00, 0x45, 0x00,
-        0x00, 0x40, 0xa8, 0xde, 0x40, 0x00, 0x40, 0x06,
-        0x9d, 0x58, 0xc0, 0xa8, 0x01, 0x03, 0x3f, 0x74,
-        0xf3, 0x61, 0xe5, 0xc0, 0x00, 0x50, 0xe5, 0x94,
-        0x3f, 0x77, 0xa3, 0xc4, 0xc4, 0x80, 0x80, 0x10,
-        0x01, 0x3e, 0x34, 0xb6, 0x00, 0x00, 0x01, 0x01,
-        0x08, 0x0a, 0x00, 0x17, 0x95, 0x6f, 0x8d, 0x9d,
-        0x9e, 0x27
-    ];
-    let prog = &PROG_TCP_SACK;
-    let vm = rbpf::EbpfVmRaw::new(prog);
-    assert_eq!(vm.prog_exec(mem), 0x0);
+    let mut mem = TCP_SACK_NOMATCH.to_vec();
+    let prog = assemble(TCP_SACK_ASM).unwrap();
+    let vm = rbpf::EbpfVmRaw::new(&prog);
+    assert_eq!(vm.prog_exec(mem.as_mut_slice()), 0x0);
 }