#!/bin/csh

# This gets run from runtests

set passcode = 13 # EACCES

set arglist =
set optlist =

while ($#argv > 0)
  switch ($1)
  case "-e":
    shift
    set passcode = $1
    breaksw
  case "-u":
    shift
    set optlist = ($optlist "-u" $1)
    breaksw
  case "-*":
    set optlist = ($optlist $1)
    breaksw
  default:
    set arglist = ($arglist $1)
    breaksw
  endsw
  shift
end

if ($#arglist != 5) then
  echo "usage: run_one_test progdir testname acl aclfile testfile"
  exit 1
endif

set prog = $arglist[1]
set testname = $arglist[2]
set acl = $arglist[3]
set aclfile = $arglist[4]
set testfile = $arglist[5]

echo "test $testname $acl $aclfile $testfile"

echo "  nfs4_setfacl -s $acl $aclfile"
nfs4_setfacl -s $acl $aclfile
#setfacl -m $acl $aclfile
set st = $status
if ($st != 0) then
  echo "  error setfacl status $st"
  exit 3
endif

$prog/can_$testname $optlist -q $testfile
set st = $status

if ($st == 0) then
  echo "  *** FAIL ***"
else if ($st == $passcode) then
  echo "  PASS"
else
  echo "  errno $st"
endif

exit $st
