#!/bin/sh 

echo '---setup principals'
env keystore=`pwd` ./setup.py 1>/dev/null 2>& 1

echo '---setup attributes'
env keystore=`pwd` ./attr.py 1>rocket.log 2>& 1

echo '---run queries'
g_cmd_sha=`grep "cmd1:" query.py |sed "s/cmd1://g" `
g_cmd_cn=`grep "cmd2:" query.py |sed "s/cmd2://g" `

echo '...with sha'
eval $g_cmd_sha 2>/dev/null 1 > rocket.sha

echo '...with cn'
eval $g_cmd_cn 1>rocket.cn 2>&1

result=`diff -I "Restoring file" rocket.cn rocket.save 2>/dev/null`
if [ $? -eq 0 ]; then
    if [ "$result" = "" ]; then
       echo "   PASSED"
       env keystore=`pwd` ABAC_CN=1 ./dump_db.py 1 > rockets.pl 2>/dev/null
    else
       echo "   ERROR:partial_proof_rt1 test result differs!!!"
    fi
else
    echo "   ERROR:partial_proof_rt1 test result differs!!!"
fi

