#!/bin/sh
# Run the upstream command-line fixtures (tests/clo.rs) against the
# installed binary.
set -eu

sample=tests/evtx/security_sample.evtx

echo "search -q"
chainsaw search 4624 "$sample" -q | diff -u tests/evtx/clo_search_q_simple_string.txt -

echo "search -q --jsonl"
chainsaw search 4624 "$sample" -q --jsonl | diff -u tests/evtx/clo_search_q_jsonl_simple_string.txt -

echo "search -jq"
chainsaw search 4624 "$sample" -jq | diff -u tests/evtx/clo_search_qj_simple_string.txt -

echo "hunt -r"
chainsaw hunt "$sample" -r tests/evtx/rule-any-logon.yml | diff -u tests/evtx/clo_hunt_r_any_logon.txt -

echo "analyse gaps"
out=$(chainsaw --no-banner analyse gaps "$sample")
echo "$out"
echo "$out" | grep -q "Security: 10 records"
echo "$out" | grep -q "No RecordID gaps detected"
