#!/bin/bash

# atop reports number of CPU and two extra lines
ATOPSOPINION="$(atop -P cpu 5 1 | grep -vE '^(RESET|SEP)' | wc -l)"
TRUTH="$(lscpu -p | grep -vE '^#' | wc -l)"

if [ "${TRUTH}" -ne "${ATOPSOPINION}" ]; then
  printf >&2 "autopkgtest 01-numcpus failed"
  printf >&2 "atop thinks %s CPUs, truth is %s CPUs\n" "${ATOPSOPINION}" "${TRUTH}"
  atop -P cpu 5 1 >&2
  lscpu -p >&2
  exit 1 
else
  exit 0
fi

