#!/bin/sh 


noise=$1

if [ -z "$noise" ]; then
    exit
fi 

echo "---running haystack fruit_python $noise scaling"

rm -rf fruit_$noise
mkdir fruit_$noise
sed "s/#VAL#/$noise/" base/SETUP.py > fruit_$noise/setup.py
sed "s/#VAL#/$noise/" base/QUERY.py > fruit_$noise/query.py
sed "s/#VAL#/$noise/" base/ATTR.py > fruit_$noise/attr.py
cp base/RESULT fruit_$noise/fruit.save

cd fruit_$noise
chmod +x setup.py attr.py query.py
./setup.py 1>/dev/null 2>& 1
env keystore=`pwd` ./attr.py 1>/dev/null 2>& 1
env keystore=`pwd` ABAC_CN=1 ./query.py 1>fruit.tmp 2> fruit.time
result=`diff fruit.tmp fruit.save 2>/dev/null`
if [ "$result" = "" ]; then
   echo "   PASSED"
else   
   echo "   ERROR"
fi


