#!/usr/bin/env bash

tests(){
  MY_ID="${RANDOM}-$$"
  MINIMAL_SIZE=1048576 # 1MiB
  yes "$MY_ID" | sosreport 
 
  SOS_SIZE=$(stat -c "%s" $1/sosreport*${MY_ID}*tar.xz)
  echo "Checking for proper minimal size of generated sosreport"
  [ "$SOS_SIZE" -gt "$MINIMAL_SIZE" ] || exit 1
  
  echo "CLEANING ..."
  rm -v $1/sosreport*${MY_ID}*tar* 
}

if [ $sys_ver -gt 6 ]; then 
  tests /var/tmp
else 
  tests /tmp
fi

