extern crate valgrind;
use std::fs::{File};
use std::io::{BufReader};
use valgrind::*;
macro_rules! t {
($e:expr) => (match $e {
Err(e) => panic!("`{}' returned {}", stringify!($e), e),
Ok(v) => v,
})
}
#[test]
fn parse_default_supp() {
let f = t!(File::open("tests/default.supp"));
let mut reader = BufReader::new(f);
let suppressions = t!(Suppressions::parse(&mut reader));
assert_eq!(suppressions.count(), 161);
let mut iter = suppressions.iter();
let suppression = iter.next().unwrap();
assert_eq!(suppression, &Suppression {
name: "ld-2.X possibly applying relocations".to_string(),
type_: SuppressionType::OtherType {
tool_name: "exp-sgcheck".to_string(),
suppression_type: "SorG".to_string(),
},
opt_extra_info: None,
frames: vec![
Frame::ObjFrame { glob: "*/*lib*/ld-2.*so*".to_string() },
Frame::ObjFrame { glob: "*/*lib*/ld-2.*so*".to_string() },
]
});
let suppression = iter.nth(3).unwrap();
assert_eq!(suppression, &Suppression {
name: "X11-Cond-1".to_string(),
type_: SuppressionType::MemcheckCond,
opt_extra_info: None,
frames: vec![
Frame::FunFrame { glob: "__rawmemchr".to_string() },
Frame::ObjFrame { glob: "*libXt.so.6.0".to_string() },
Frame::ObjFrame { glob: "*libXt.so.6.0".to_string() },
]
});
let suppression = iter.next().unwrap();
assert_eq!(suppression, &Suppression {
name: "X11-Addr4-1".to_string(),
type_: SuppressionType::MemcheckAddr(4),
opt_extra_info: None,
frames: vec![
Frame::ObjFrame { glob: "/usr/X11R6/lib/libX11.so.6.1".to_string() },
Frame::ObjFrame { glob: "/usr/X11R6/lib/libX11.so.6.1".to_string() },
Frame::ObjFrame { glob: "/usr/X11R6/lib/libX11.so.6.1".to_string() },
]
});
let suppression = iter.nth(6).unwrap();
assert_eq!(suppression, &Suppression {
name: "X11-Param-1".to_string(),
type_: SuppressionType::MemcheckParam,
opt_extra_info: Some(vec!["write(buf)".to_string()]),
frames: vec![
Frame::FunFrame { glob: "__libc_write".to_string() },
Frame::ObjFrame { glob: "/usr/X11R6/lib/libX11.so.6.1".to_string() },
Frame::ObjFrame { glob: "/usr/X11R6/lib/libX11.so.6.1".to_string() },
]
});
let suppression = iter.nth(30).unwrap();
assert_eq!(suppression, &Suppression {
name: "XftFontOpenInfo-umod-127-strangeness".to_string(),
type_: SuppressionType::MemcheckValue(8),
opt_extra_info: None,
frames: vec![
Frame::ObjFrame { glob: "/usr/X11*/lib*/libXft.so*".to_string() },
Frame::ObjFrame { glob: "/usr/X11*/lib*/libXft.so*".to_string() },
]
});
let suppression = iter.nth(4).unwrap();
assert_eq!(suppression, &Suppression {
name: "ifort-9.X-on-amd64-1".to_string(),
type_: SuppressionType::MemcheckAddr(8),
opt_extra_info: None,
frames: vec![
Frame::FunFrame { glob: "unaligned_bigint".to_string() },
Frame::FunFrame { glob: "hash".to_string() },
Frame::FunFrame { glob: "for__add_to_lf_table".to_string() },
]
});
let suppression = iter.next().unwrap();
assert_eq!(suppression, &Suppression {
name: "zlib-1.2.x trickyness (1a): See http://www.zlib.net/zlib_faq.html#faq36".to_string(),
type_: SuppressionType::MemcheckCond,
opt_extra_info: None,
frames: vec![
Frame::ObjFrame { glob: "/*lib*/libz.so.1.2.*".to_string() },
Frame::FrameWildcard,
Frame::ObjFrame { glob: "/*lib*/libz.so.1.2.*".to_string() },
Frame::FunFrame { glob: "deflate".to_string() },
]
});
let suppression = iter.nth(3).unwrap();
assert_eq!(suppression, &Suppression {
name: "zlib-1.2.x trickyness (3a): See http://www.zlib.net/zlib_faq.html#faq36".to_string(),
type_: SuppressionType::MemcheckValue(4),
opt_extra_info: None,
frames: vec![
Frame::ObjFrame { glob: "/*lib*/libz.so.1.2.*".to_string() },
Frame::FrameWildcard,
Frame::ObjFrame { glob: "/*lib*/libz.so.1.2.*".to_string() },
Frame::FunFrame { glob: "deflate".to_string() },
]
});
let suppression = iter.nth(3).unwrap();
assert_eq!(suppression, &Suppression {
name: "Ubuntu804-hack-1".to_string(),
type_: SuppressionType::MemcheckOverlap,
opt_extra_info: None,
frames: vec![
Frame::FunFrame { glob: "mempcpy".to_string() },
Frame::FunFrame { glob: "_IO_default_xsputn".to_string() },
Frame::ObjFrame { glob: "/lib*/libc-2.*so*".to_string() },
]
});
let suppression = iter.nth(2).unwrap();
assert_eq!(suppression, &Suppression {
name: "dyld_stub_binder".to_string(),
type_: SuppressionType::OtherType {
tool_name: "drd".to_string(),
suppression_type: "ConflictingAccess".to_string(),
},
opt_extra_info: None,
frames: vec![
Frame::FrameWildcard,
Frame::FunFrame { glob: "_ZN4dyld18fastBindLazySymbolEPP11ImageLoaderm".to_string() },
Frame::FunFrame { glob: "dyld_stub_binder".to_string() },
]
});
let suppression = iter.nth(23).unwrap();
assert_eq!(suppression, &Suppression {
name: "OSX1011:1-Leak".to_string(),
type_: SuppressionType::MemcheckLeak,
opt_extra_info: Some(vec!["match-leak-kinds: possible".to_string()]),
frames: vec![
Frame::FunFrame { glob: "malloc_zone_?alloc".to_string() },
Frame::FrameWildcard,
Frame::FunFrame { glob: "_read_images".to_string() },
]
});
let suppression = iter.nth(62).unwrap();
assert_eq!(suppression, &Suppression {
name: "OSX1011:AppleIntelHD4000GraphicsGLDriver-2-Addr2".to_string(),
type_: SuppressionType::MemcheckAddr(2),
opt_extra_info: None,
frames: vec![
Frame::FunFrame { glob: "*platform_memmove*".to_string() },
Frame::ObjFrame { glob: "*AppleIntelHD4000GraphicsGLDriver.bundle*AppleIntelHD4000GraphicsGLDriver*".to_string() },
Frame::ObjFrame { glob: "*AppleIntelHD4000GraphicsGLDriver.bundle*AppleIntelHD4000GraphicsGLDriver*".to_string() },
]
});
let suppression = iter.nth(2).unwrap();
assert_eq!(suppression, &Suppression {
name: "OSX1011:AppleIntelHD4000GraphicsGLDriver-3-Addr1".to_string(),
type_: SuppressionType::MemcheckAddr(1),
opt_extra_info: None,
frames: vec![
Frame::FunFrame { glob: "*platform_memmove*".to_string() },
Frame::ObjFrame { glob: "*AppleIntelHD4000GraphicsGLDriver.bundle*AppleIntelHD4000GraphicsGLDriver*".to_string() },
Frame::ObjFrame { glob: "*GLEngine.bundle*GLEngine*".to_string() },
]
});
let suppression = iter.nth(6).unwrap();
assert_eq!(suppression, &Suppression {
name: "OSX1011:mach_msg_trap-1".to_string(),
type_: SuppressionType::MemcheckParam,
opt_extra_info: Some(vec!["msg->desc.port.name".to_string()]),
frames: vec![
Frame::FunFrame { glob: "mach_msg_trap".to_string() },
Frame::ObjFrame { glob: "*libsystem_kernel.dylib*".to_string() },
Frame::ObjFrame { glob: "*SystemConfiguration.framework*SystemConfiguration*".to_string() },
]
});
let suppression = iter.nth(2).unwrap();
assert_eq!(suppression, &Suppression {
name: "macos-__pthread_rwlock_init-see-our-bug-196528".to_string(),
type_: SuppressionType::MemcheckCond,
opt_extra_info: None,
frames: vec![
Frame::FunFrame { glob: "pthread_rwlock_init".to_string() },
]
});
assert!(iter.next().is_none());
}