. "$BST_LIB"
require ls coreutils/present

tmp=${TMPDIR:-/tmp}/bst-coreutils.$$
printf 'gamma\nalpha\nbeta\n' > "$tmp"

check_out coreutils/cat        "alpha"    cat "$tmp"
check_out coreutils/sort-first "alpha"    sh -c "sort '$tmp' | head -1"
check_out coreutils/wc-lines   "3"        sh -c "wc -l < '$tmp' | tr -d ' '"
check_out coreutils/ls-root    "bin"      ls /

# checksum determinism: same input hashes identically across two runs
if command -v sha256sum >/dev/null 2>&1; then
  d1=$(sha256sum "$tmp" | cut -d' ' -f1)
  d2=$(sha256sum "$tmp" | cut -d' ' -f1)
  check_eq coreutils/sha256-deterministic "$d1" "$d2"
else
  bst_skip coreutils/sha256 "sha256sum not installed on this image"
fi

rm -f "$tmp"
