#!/bin/bash

i=0
while [ -e shard_primary_relinquish_migrate-${i}.log ]; do
        i=$(($i + 1))
done

echo
echo compiling
#rm site_scons/site_tools/unittest.pyc
if ! scons -j2 mongod mongos mongo > shard_primary_relinquish_migrate-${i}.log 2>&1; then
        echo "build failed"
        exit 254
fi
echo testing
rm -rf /data/db
mkdir /data/db
./mongo --nodb shard_primary_relinquish_migrate.js >> shard_primary_relinquish_migrate-${i}.log 2>&1
rc=$?
echo "rc=$rc"
if [ $rc = 253 ]; then
        echo "  bug is present, hence \"good\""
        exit 0
else
        echo "  bug is NOT present, hence \"bad\""
        exit 1
fi

