Sfoglia il codice sorgente

tests/assembler.rs: add tcp_sack test

Rich Lane 8 anni fa
parent
commit
a6b0d4b4ff
1 ha cambiato i file con 7 aggiunte e 0 eliminazioni
  1. 7 0
      tests/assembler.rs

+ 7 - 0
tests/assembler.rs

@@ -4,7 +4,9 @@
 // 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.
 extern crate rbpf;
+mod common;
 
+use common::{TCP_SACK_ASM, TCP_SACK_BIN};
 use rbpf::assembler::assemble;
 use rbpf::ebpf;
 
@@ -393,6 +395,11 @@ fn test_large_immediate() {
                Ok(vec![insn(ebpf::ADD64_IMM, 1, 0, 0, -2147483648)]));
 }
 
+#[test]
+fn test_tcp_sack() {
+    assert_eq!(assemble(&TCP_SACK_ASM), Ok(TCP_SACK_BIN.to_vec()));
+}
+
 #[test]
 fn test_error_invalid_instruction() {
     assert_eq!(asm("abcd"), Err("Invalid instruction \"abcd\"".to_string()));