#!/bin/bash

# Test the copying of a large directory hierarchy...while deleting it.

# Copyright (C) 2003-2006 IBM
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.

TREE_DEST="$POUNDER_TMPDIR/copytree/"

# Set up the erase
trap 'echo Cleaning up...; rm -rf "$TREE_DEST"; echo Clean.; exit 0'  1 2 15

# Copy the data
mkdir -p "$TREE_DEST"
cp -pRdu /usr "$TREE_DEST"

# Compare the data
diff -Naur /usr "$TREE_DEST/usr/" | tee "$POUNDER_TMPDIR/copytree.diff"

# Clean up
rm -rf "$TREE_DEST"

# Anything in the diff?
DIFF_ERRORS=`wc -l < $POUNDER_TMPDIR/copytree.diff`
if [ $DIFF_ERRORS -gt 0 ]; then
        exit $DIFF_ERRORS
fi

exit 0