#!/bin/bash

# DO NOT RUN THIS, SOURCE IT FROM YOUR TERMINAL (idk why it needs this)

for ((i=0; i < 1000; ++i)); do
   if timeout -s INT 0.8 ./mutex.out > /dev/null
      # if grep -q 'Post: count: 99'; then
      #    : # good result
      # else
      #    e='NOT 99!'
      # fi
   then
      : # did not timeout
   else
      e='TIMEOUT!'
   fi

   if [ "$e" = "" ]; then
      if ((i % 100 == 99)); then
         echo -n .
      fi
   else
      echo -n "-ERROR on take ${i}: $e-"
      e=
   fi
done

echo # final newline