#!/bin/bash

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

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

