use std::io::stdout;
use std::path::Path;
use indoc::indoc;
use bpflint::Lint;
use bpflint::lint_custom;
use bpflint::terminal::Opts;
use bpflint::terminal::report_opts;
fn main() {
let lint = Lint {
name: "bpf-stackid-usage".to_string(),
code: indoc! { r#"
(call_expression
function: (identifier) @function (#eq? @function "bpf_get_stackid")
)
"# }
.to_string(),
message: "Please don't use bpf_get_stackid() in this example.".to_string(),
};
let code = include_bytes!("task_longrun.bpf.c");
let matches = lint_custom(code, &[lint]).expect("failed to lint");
assert_eq!(matches.len(), 1);
let opts = Opts {
color: true,
extra_lines: (2, 2),
..Default::default()
};
report_opts(
&matches[0],
code,
Path::new("task_longrun.bpf.c"),
&opts,
&mut stdout().lock(),
)
.expect("failed to report matches");
}