#!/bin/sh
# $Id: rmdir.sh,v 1.1 2001/10/05 19:01:51 cubbi Exp $
TESTPROG=`pwd`/../bin/rmdir

# Test 0: check if it exists
if test -f $TESTPROG; then

 rm -rf test_dir
# Test 1: check if rmdir can delete a directory
 mkdir test_dir
 $TESTPROG test_dir || (
  echo "FAIL: $TESTPROG failed to delete a directory"
  exit
 )
 if test -d test_dir; then
  echo "FAIL: $TESTPROG failed to delete a directory"
  exit
 fi
# Test 2: check if rmdir can delete several directories
 mkdir test_dir0 test_dir1 test_dir2
 $TESTPROG test_dir0 test_dir1 test_dir2 || (
  echo "FAIL: $TESTPROG failed to delete several directories at once"
  exit
 )
 if test -d test_dir2; then
  echo "FAIL: $TESTPROG failed to delete several directories at once"
  exit
 fi
# Test 3: check if rmdir -p works
 mkdir -p test_dir0/test_dir1/test_dir2
 $TESTPROG -p test_dir0/test_dir1/test_dir2 || (
  echo "FAIL: $TESTPROG failed at the option '-p' test"
  exit
 )
 if test -d test_dir0; then
  echo "FAIL: $TESTPROG failed at the option '-p' test"
  exit
 fi
# Test 4: check the support of -- option - deleting a directory called "-p"
 mkdir -- -p
 $TESTPROG -- -p || (
  echo "FAIL: $TESTPROG failed at the option '--' test"
  exit
 )
 if test -d test_dir0; then
  echo "FAIL: $TESTPROG failed at the option '--' test"
  exit
 fi

 echo "PASS: rmdir"
else
 echo "SKIP: $TESTPROG doesn't exist"
fi
