add tests

pull/608/head
Andrés Medina
parent 08e993dde3
commit f58f02bcc1

@ -1082,6 +1082,21 @@ mod tests {
}
}
#[test]
fn parsing_older_ext_data() {
let btf_data = [
159, 235, 1, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
];
let btf_ext_data = [
159, 235, 1, 0, 24, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 8, 0, 0,
0, 16, 0, 0, 0,
];
let btf = Btf::parse(&btf_data, Endianness::default()).unwrap();
let btf_ext = BtfExt::parse(&btf_ext_data, Endianness::default(), &btf).unwrap();
assert_eq!(btf_ext.func_info_rec_size(), 8);
assert_eq!(btf_ext.line_info_rec_size(), 16);
}
#[test]
fn test_write_btf() {
let mut btf = Btf::new();

@ -1634,6 +1634,31 @@ mod tests {
)
}
#[test]
fn sanitizes_empty_btf_files_to_none() {
let mut obj = fake_obj();
obj.parse_section(fake_section(
BpfSectionKind::Btf,
".BTF",
&[
159, 235, 1, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
],
))
.unwrap();
obj.parse_section(fake_section(
BpfSectionKind::BtfExt,
".BTF.ext",
&[
159, 235, 1, 0, 24, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 8, 0,
0, 0, 16, 0, 0, 0,
],
))
.unwrap();
let btf = obj.fixup_and_sanitize_btf(&BtfFeatures::default()).unwrap();
assert!(btf.is_none());
}
#[test]
fn test_parse_program_error() {
let obj = fake_obj();

Loading…
Cancel
Save