#!/bin/bash
# SyncDirs10.0-Test: Provide a test function to show that SyncDirs is operating correctly.
# Version 1.0
# Copyright (C) 2006 Free Software Foundation, Inc.
# Author: Geoff Farrell
# This file is part of SyncDirs10.0.
# SyncDirs10.0 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.
# SyncDirs10.0 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 SyncDirs10.0; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
# Required files:
# SyncDirs10.0
# ExportRpms
# CreateLocalFilesUpdated (for testing only)
# SyncDirs10.0-Test (for testing only)
# For SyncDirs10.0 testing, examine the files produced by that script, and produce a comparative output to
# illustrate the changes that would have been made, based on the contents of the various directories (ftp, local, and backup).
# (Testing is performed with all 'write' functions to the actual directories disabled. The only 'write' functions enabled are
# those involved in writing temp files to the working directory)
#
# This output can then be examined to confirm correct operation; ie, determine if any errors would have been produced.
#
# This script uses the set of files local.files4.
created by CreateLocalFilesUpdated (a copy of local.files.
# as they would appear after updates have been applied, and obsolete files have been deleted)
#** User customisation:
#** Note: the declarations up to 'WK_DIR' need user customisation to suit individual environments.
#** The declarations following those should not need changing.
# Define the cpu architecture. This must agree with the corresponding definition in SyncDirs10.0
ARCH=i586 # i586 cpu
# Note: for other architectures, use:
# ARCH=ppc # ppc cpu
# ARCH=ppc64 # ppc64 cpu
# ARCH=x86_64 # x86_64 cpu
# Define the working directory. This must agree with the corresponding definition for Testing mode in SyncDirs10.0
WK_DIR=/tmp/SyncDirs # Working directory - where Lots of temp files get stored
#----------------------------------------------------------------------------------------------------------------------
# The following declarations should not need changing
DATE_TIME=$(date +%y%m%d%H%M) # Create a date/time stamp
LOG_FILE=$WK_DIR/syncdirs_test_$DATE_TIME.log # Log file, to include a date/time stamp
FTP_FILES_NAME=ftp.files # Contains a list of files available for download from the ftp site
LOCAL_FILES_NAME=local.files # Contains a list of files in the local updates directory
FTP_ADD_NAME=ftp.add # Contains a list of new updates to be added from the ftp site (to the local updates directory)
FTP_FIL_NAME=ftp.fil # Ditto to FTP_ADD, but after filtering out unwanted files
LOCAL_FILES_UPD_NAME=local.files4 # Contains a list of files of the local updates directory, after the updates
# have been applied, and the obsolete files have been deleted
#** Note the mapping to the specially prepared 'local.files4' files
LOCAL_REMOVE_NAME=local.remove # Contains a list of files to be removed from the local updates directory
BACKUP_FILES_NAME=backup.files # Contains a list of files in the local backup directory
BACKUP_ADD_NAME=backup.add # Contains a list of files to be added to the local backup directory (from the local updates directory)
BACKUP_REMOVE_NAME=backup.remove # Contains a list of files to be deleted from the local backup directory
LOCAL_NOCHANGE_NAME=local.files.nochange # Contains a list of files in LOCAL_FILES_UPD, but excluding those in LOCAL_REMOVE
BACKUP_NOCHANGE_NAME=backup.files.nochange # Contains a list of files in BACKUP_FILES, but excluding those in BACKUP_REMOVE
LOCAL_FILES_TMP_NAME=local.files.tmp # Temp file used in constructing LOCAL_NOCHANGE
BACKUP_FILES_TMP_NAME=backup.files.tmp # Temp file used in constructing BACKUP_NOCHANGE
FTP_FILES=$WK_DIR/$FTP_FILES_NAME # Contains a list of files available for download from the ftp site
LOCAL_FILES=$WK_DIR/$LOCAL_FILES_NAME # Contains a list of files in the local updates directory
FTP_ADD=$WK_DIR/$FTP_ADD_NAME # Contains a list of new updates to be added from the ftp site (to the local updates directory)
FTP_FIL=$WK_DIR/$FTP_FIL_NAME # Ditto to FTP_ADD, but after filtering out unwanted files
LOCAL_FILES_UPD=$WK_DIR/$LOCAL_FILES_UPD_NAME # Contains a list of files of the local updates directory, after the updates
# have been applied, and the obsolete files have been deleted
#** Note the mapping to the specially prepared 'local.files4. files
LOCAL_REMOVE=$WK_DIR/$LOCAL_REMOVE_NAME # Contains a list of files to be removed from the local updates directory
BACKUP_FILES=$WK_DIR/$BACKUP_FILES_NAME # Contains a list of files in the local backup directory
BACKUP_ADD=$WK_DIR/$BACKUP_ADD_NAME # Contains a list of files to be added to the local backup directory (from the local updates directory)
BACKUP_REMOVE=$WK_DIR/$BACKUP_REMOVE_NAME # Contains a list of files to be deleted from the local backup directory
LOCAL_NOCHANGE=$WK_DIR/$LOCAL_NOCHANGE_NAME # Contains a list of files in LOCAL_FILES_UPD, but excluding those in LOCAL_REMOVE
BACKUP_NOCHANGE=$WK_DIR/$BACKUP_NOCHANGE_NAME # Contains a list of files in BACKUP_FILES, but excluding those in BACKUP_REMOVE
LOCAL_FILES_TMP=$WK_DIR/$LOCAL_FILES_TMP_NAME # Temp file used in constructing LOCAL_NOCHANGE
BACKUP_FILES_TMP=$WK_DIR/$BACKUP_FILES_TMP_NAME # Temp file used in constructing BACKUP_NOCHANGE
IDX_DELTAS=deltas # Name used for the 'deltas' directory
IDX_PATCHES=patches # Name used for the 'patches' directory
IDX_PATCHES_OBS=patches.obs # Name used for 'patches.obsolete' directory
# $ARCH is defined earlier in user customisation section. Default setting is 'i586' cpu
IDX_ARCH=$ARCH # Name used for '$ARCH' directory
IDX_NOARCH=noarch # Name used for 'noarch' directory
IDX_SCRIPTS=scripts # Name used for 'scripts' directory
# Declare an array to hold these directory names
declare -a IdxDir
# Load the directory names into the array
IdxDir[0]=$IDX_DELTAS
IdxDir[1]=$IDX_PATCHES
IdxDir[2]=$IDX_PATCHES_OBS
IdxDir[3]=$IDX_ARCH
IdxDir[4]=$IDX_NOARCH
IdxDir[5]=$IDX_SCRIPTS
# Declare arrays to hold error results
declare -a ErrDeltas
declare -a ErrPatches
declare -a ErrPatchesObs
declare -a ErrArch
declare -a ErrNoarch
declare -a ErrScripts
#**-----------------------------------------------------------------------------------------------------
#** Test method: local updates compared to ftp files:
#** 1. any file in LOCAL_REMOVE should exist in LOCAL_FILES
#** 2. any file in LOCAL_REMOVE should not exist in FTP_FILES
#** 3. any file in FTP_FIL should exist in FTP_FILES
#** 4. any file in FTP_FIL should not exist in LOCAL_FILES
#** 5. all files in LOCAL_FILES other than LOCAL_REMOVE should exist in FTP_FILES (Generate a LOCAL_NOCHANGE file to test this)
#**
#** Test method: local updates compared to local backups:
#** 6. any file in BACKUP_REMOVE should exist in BACKUP_FILES
#** 7. any file in BACKUP_REMOVE should not exist in LOCAL_FILES_UPD
#** 8. any file in BACKUP_ADD should exist in LOCAL_FILES_UPD
#** 9. any file in BACKUP_ADD should not exist in BACKUP_FILES
#** 10. all files in BACKUP_FILES other than BACKUP_REMOVE should exist in LOCAL_FILES_UPD (Generate a BACKUP_NOCHANGE file to test this)
#**
#** Test criteria: satisfaction of the above conditions should confirm proper operation
#**-----------------------------------------------------------------------------------------------------
for Dir in "${IdxDir[@]}"; do # for all the directories
# Generate pointers to filenames representing those directories
LocalFilesDir=$LOCAL_FILES.$Dir # $WK_DIR/local.files.
FtpFilesDir=$FTP_FILES.$Dir # $WK_DIR/ftp.files.
FtpFilDir=$FTP_FIL.$Dir # $WK_DIR/ftp.fil.
LocalUpdDir=$LOCAL_FILES_UPD.$Dir # $WK_DIR/local.files4.
LocalRemoveDir=$LOCAL_REMOVE.$Dir # $WK_DIR/local.remove.
BackupFilesDir=$BACKUP_FILES.$Dir # $WK_DIR/backup.files.
BackupAddDir=$BACKUP_ADD.$Dir # $WK_DIR/backup.add.
BackupRemoveDir=$BACKUP_REMOVE.$Dir # $WK_DIR/backup.remove.
LocalNochangeDir=$LOCAL_NOCHANGE.$Dir # $WK_DIR/local.files.nochange.
BackupNochangeDir=$BACKUP_NOCHANGE.$Dir # $WK_DIR/backup.files.nochange.
LocalFilesTmpDir=$LOCAL_FILES_TMP.$Dir # $WK_DIR/local.files.tmp.
BackupFilesTmpDir=$BACKUP_FILES_TMP.$Dir # $WK_DIR/backup.files.tmp.
# Using '_NAME' construct in 'echo' commands for shorter messages (doesn't have $WK_DIR pre-pended)
LocalFilesName=$LOCAL_FILES_NAME.$Dir # local.files.
FtpFilesName=$FTP_FILES_NAME.$Dir # ftp.files.
FtpAddName=$FTP_ADD_NAME.$Dir # ftp.add.
FtpFilName=$FTP_FIL_NAME.$Dir # ftp.fil.
LocalUpdName=$LOCAL_FILES_UPD_NAME.$Dir # local.files4.
LocalRemoveName=$LOCAL_REMOVE_NAME.$Dir # local.remove.
BackupFilesName=$BACKUP_FILES_NAME.$Dir # backup.files.
BackupAddName=$BACKUP_ADD_NAME.$Dir # backup.add.
BackupRemoveName=$BACKUP_REMOVE_NAME.$Dir # backup.remove.
LocalNochangeName=$LOCAL_NOCHANGE_NAME.$Dir # local.files.nochange.
BackupNochangeName=$BACKUP_NOCHANGE_NAME.$Dir # backup.files.nochange.
echo "**********************************" | tee -a $LOG_FILE
echo "LocalFilesDir =$LocalFilesDir" | tee -a $LOG_FILE
echo "FtpFilesDir =$FtpFilesDir" | tee -a $LOG_FILE
echo "FtpFilDir =$FtpFilDir" | tee -a $LOG_FILE
echo "LocalUpdDir =$LocalUpdDir" | tee -a $LOG_FILE
echo "LocalRemoveDir =$LocalRemoveDir" | tee -a $LOG_FILE
echo "BackupFilesDir =$BackupFilesDir" | tee -a $LOG_FILE
echo "BackupAddDir =$BackupAddDir" | tee -a $LOG_FILE
echo "BackupRemoveDir =$BackupRemoveDir" | tee -a $LOG_FILE
echo "LocalNochangeDir =$LocalNochangeDir" | tee -a $LOG_FILE
echo "BackupNochangeDir =$BackupNochangeDir" | tee -a $LOG_FILE
echo "LocalFilesTmpDir =$LocalFilesTmpDir" | tee -a $LOG_FILE
echo "BackupFilesTmpDir =$BackupFilesTmpDir" | tee -a $LOG_FILE
echo "LocalFilesName =$LocalFilesName" | tee -a $LOG_FILE
echo "FtpFilesName =$FtpFilesName" | tee -a $LOG_FILE
echo "FtpAddName =$FtpAddName" | tee -a $LOG_FILE
echo "FtpFilName =$FtpFilName" | tee -a $LOG_FILE
echo "LocalUpdName =$LocalUpdName" | tee -a $LOG_FILE
echo "LocalRemoveName =$LocalRemoveName" | tee -a $LOG_FILE
echo "BackupFilesName =$BackupFilesName" | tee -a $LOG_FILE
echo "BackupAddName =$BackupAddName" | tee -a $LOG_FILE
echo "BackupRemoveName =$BackupRemoveName" | tee -a $LOG_FILE
echo "LocalNochangeName =$LocalNochangeName" | tee -a $LOG_FILE
echo "BackupNochangeName =$BackupNochangeName" | tee -a $LOG_FILE
echo "Initialising File Count variables..." | tee -a $LOG_FILE
# Initialise counters: these are used to record errors in the above test conditions
NumLocRem_in_LocFiles=0 # Number of errors for $LocalRemoveDir files in $LocalFilesDir (Test 1)
echo "NumLocRem_in_LocFiles =$NumLocRem_in_LocFiles" | tee -a $LOG_FILE
NumLocRem_in_FtpFiles=0 # Number of errors for $LocalRemoveDir files in $FtpFilesDir (Test 2)
echo "NumLocRem_in_FtpFiles =$NumLocRem_in_FtpFiles" | tee -a $LOG_FILE
NumFtpFil_in_FtpFiles=0 # Number of errors for $FtpFilDir files in $FtpFilesDir (Test 3)
echo "NumFtpFil_in_FtpFiles =$NumFtpFil_in_FtpFiles" | tee -a $LOG_FILE
NumFtpFil_in_LocFiles=0 # Number of errors for $FtpFilDir files in $LocalFilesDir (Test 4)
echo "NumFtpFil_in_LocFiles =$NumFtpFil_in_LocFiles" | tee -a $LOG_FILE
NumLocNoChgFiles_in_FtpFiles=0 # Number of errors for $LocalNochangeDir files in $FtpFilesDir (Test 5)
echo "NumLocNoChgFiles_in_FtpFiles =$NumLocNoChgFiles_in_FtpFiles" | tee -a $LOG_FILE
NumBackupRem_in_BackupFiles=0 # Number of errors for $BackupRemoveDir files in $BackupFilesDir (Test 6)
echo "NumBackupRem_in_BackupFiles =$NumBackupRem_in_BackupFiles" | tee -a $LOG_FILE
NumBackupRem_in_LocalUpd=0 # Number of errors for $BackupRemoveDir files in $LocalUpdDir (Test 7)
echo "NumBackupRem_in_LocalUpd =$NumBackupRem_in_LocalUpd" | tee -a $LOG_FILE
NumBackupAdd_in_LocalUpd=0 # Number of errors for $BackupAddDir files in $LocalUpdDir (Test 8)
echo "NumBackupAdd_in_LocalUpd =$NumBackupAdd_in_LocalUpd" | tee -a $LOG_FILE
NumBackupAdd_in_BackupFiles=0 # Number of errors for $BackupAddDir files in $BackupFilesDir (Test 9)
echo "NumBackupAdd_in_BackupFiles =$NumBackupAdd_in_BackupFiles" | tee -a $LOG_FILE
NumBackupNoChgFiles_in_LocalUpd=0 # Number of errors for $BackupNochangeDir files in $LocalUpdDir (Test 10)
echo "NumBackupNoChgFiles_in_LocalUpd =$NumBackupNoChgFiles_in_LocalUpd" | tee -a $LOG_FILE
echo "**********************************" | tee -a $LOG_FILE
# Prepare for generating LocalNochangeDir
echo "Copying from $LocalFilesDir to $LocalNochangeDir" | tee -a $LOG_FILE
cp $LocalFilesDir $LocalNochangeDir
echo "Testing '$Dir' directory:" | tee -a $LOG_FILE
echo "Files in $LocalFilesName ="$(cat $LocalFilesDir | wc -l) | tee -a $LOG_FILE
echo "Files in $FtpFilName ="$(cat $FtpFilDir | wc -l) | tee -a $LOG_FILE
num=$(cat $LocalRemoveDir | wc -l) # Get the number of files in $LocalRemoveDir
echo "**********************************" | tee -a $LOG_FILE
echo "Files in $LocalRemoveName =$num" | tee -a $LOG_FILE # Print the number
i=0 # Reset files counter
if [ $(($num)) -gt 0 ]; then # If files exist in $LocalRemoveDir, analyse them
# Prepare to read from the $LocalRemoveDir file
exec 7<&0
exec < $LocalRemoveDir
echo "Examining files listed in $LocalRemoveName now..." | tee -a $LOG_FILE
while [ $(($i)) -lt $(($num)) ]; do # Generate LOCAL_NOCHANGE during this
let i+=1 # Increment file counter
read LocalRemove_tmp
echo "$LocalRemoveName:$i Examining "$LocalRemove_tmp | tee -a $LOG_FILE
# Check for $LocalRemove_tmp file in $LocalFilesDir (should exist); 'sed' argument provides exact match
FileInLocFiles=$(cat $LocalFilesDir | sed -ne '/^'$LocalRemove_tmp'$/p')
echo "$LocalRemoveName:$i Test 1: This file should exist in $LocalFilesName >" $FileInLocFiles | tee -a $LOG_FILE
if [ -z "$FileInLocFiles" ]; then # If this file is missing from $LocalFilesDir
let NumLocRem_in_LocFiles+=1 # Increment the error count
echo "NumLocRem_in_LocFiles incremented to: $NumLocRem_in_LocFiles" | tee -a $LOG_FILE
# Register the failure
echo "$LocalRemoveName:$i ** Test Condition 1 failed: file $LocalRemove_tmp missing from $LocalFilesName" | tee -a $LOG_FILE
fi
# Generate $LocalNochangeDir file
# Set an argument for sed, to remove $LocalRemove_tmp from $LocalNochangeDir
MATCHTEXT='/'$LocalRemove_tmp'/!p'
# Remove $LocalRemove_tmp file from $LocalNochangeDir file.
# Eventually, after scanning all $LocalRemoveDir files, $LocalNochangeDir will represent
# $LocalFilesDir, minus all $LocalRemoveDir files
cat $LocalNochangeDir | sed -ne $MATCHTEXT | cat > $LocalFilesTmpDir
# Move tmp file to $LocalNochangeDir for the next iteration
mv $LocalFilesTmpDir $LocalNochangeDir
# Check for $LocalRemove_tmp file in $FtpFilesDir (should not exist); 'sed' argument provides exact match
FileInFtpFiles=$(cat $FtpFilesDir | sed -ne '/^'$LocalRemove_tmp'$/p')
echo "$LocalRemoveName:$i Test 2: This file should NOT exist in $FtpFilesName >" $FileInFtpFiles | tee -a $LOG_FILE
if [ -n "$FileInFtpFiles" ]; then # If this file exists in $FtpFilesDir
let NumLocRem_in_FtpFiles+=1 # Increment the error count
echo "NumLocRem_in_FtpFiles incremented to: $NumLocRem_in_FtpFiles" | tee -a $LOG_FILE
# Register the failure
echo "$LocalRemoveName:$i ** Test Condition 2 failed: file $LocalRemove_tmp exists in $FtpFilesName" | tee -a $LOG_FILE
fi
done
exec 0<&- # Close $LocalRemoveDir
exec 0<&7 7<&- # Restore stdin from fd #7 & close fd #7
else
echo "$LocalRemoveName:$i Test Conditions 1 & 2 skipped: no files in $LocalRemoveName" | tee -a $LOG_FILE
fi
echo "***************************************" | tee -a $LOG_FILE
num=$(cat $FtpFilDir | wc -l) # Get the number of files in $FtpFilDir
echo "files in $FtpFilName =$num" | tee -a $LOG_FILE # Print the number
i=0 # Reset files counter
if [ $(($num)) -gt 0 ]; then # If files exist in $FtpFilDir, analyse them
# Prepare to read from the $FtpFilDir file
exec 7<&0
exec < $FtpFilDir
echo "Examining files listed in $FtpFilName now..." | tee -a $LOG_FILE
while [ $(($i)) -lt $(($num)) ]; do # Generate $LocalNochangeDir during this
let i+=1 # Increment file counter
read FtpFil_tmp
echo "$FtpFilName:$i Examining "$FtpFil_tmp | tee -a $LOG_FILE
# Check for $FtpFil_tmp file in $FtpFilesDir (should exist); 'sed' argument provides exact match
FileInFtpFil=$(cat $FtpFilesDir | sed -ne '/^'$FtpFil_tmp'$/p')
echo "$FtpFilName:$i Test 3: This file should exist in $FtpFilesName >" $FileInFtpFil | tee -a $LOG_FILE
if [ -z "$FileInFtpFil" ]; then # If this file is missing from $FtpFilesDir
let NumFtpFil_in_FtpFiles+=1 # Increment the error count
echo "NumFtpFil_in_FtpFiles incremented to: $NumFtpFil_in_FtpFiles" | tee -a $LOG_FILE
# Register the failure
echo "$FtpFilName:$i ** Test Condition 3 failed: file $FtpFil_tmp missing from $FtpFilesName" | tee -a $LOG_FILE
fi
# Check for $FtpFil_tmp file in $LocalFilesDir (should not exist); 'sed' argument provides exact match
FileInLocalFiles=$(cat $LocalFilesDir | sed -ne '/^'$FtpFil_tmp'$/p')
echo "$FtpFilName:$i Test 4: This file should NOT exist in $LocalFilesName >" $FileInLocalFiles | tee -a $LOG_FILE
if [ -n "$FileInLocalFiles" ]; then # If this file exists in $LocalFilesDir
let NumFtpFil_in_LocFiles+=1 # Increment the error count
echo "NumFtpFil_in_LocFiles incremented to: $NumFtpFil_in_LocFiles" | tee -a $LOG_FILE
# Register the failure
echo "$FtpFilName:$i ** Test Condition 4 failed: file $FtpFil_tmp exists in $LocalFilesName" | tee -a $LOG_FILE
fi
done
exec 0<&- # Close $FtpFilDir
exec 0<&7 7<&- # Restore stdin from fd #7 & close fd #7
else
echo "$FtpFilName:$i Test Conditions 3 & 4 skipped: no files in $FtpFilName" | tee -a $LOG_FILE
fi
echo "***************************************" | tee -a $LOG_FILE
echo "Checking unchanged local files now..." | tee -a $LOG_FILE
num=$(cat $LocalNochangeDir | wc -l) # Get the number of files in $LocalNochangeDir
echo "files in $LocalNochangeName =$num" | tee -a $LOG_FILE # Print the number
i=0 # Reset files counter
if [ $(($num)) -gt 0 ]; then # If files exist in $LocalNochangeDir, analyse them
# Prepare to read from the $LocalNochangeDir file
exec 7<&0
exec < $LocalNochangeDir
echo "Examining files listed in $LocalNochangeName now..." | tee -a $LOG_FILE
while [ $(($i)) -lt $(($num)) ]; do # Do all $LocalNochangeDir files
let i+=1 # Increment file counter
read LocalNoChg_tmp
echo "$LocalNochangeName:$i Examining "$LocalNoChg_tmp | tee -a $LOG_FILE
# Check for $LocalNoChg_tmp file in $FtpFilesDir (should exist); 'sed' argument provides exact match
FileInLocalNoChg=$(cat $FtpFilesDir | sed -ne '/^'$LocalNoChg_tmp'$/p')
echo "$LocalNochangeName:$i Test 5: This file should exist in $FtpFilesName >" $FileInLocalNoChg | tee -a $LOG_FILE
if [ -z "$FileInLocalNoChg" ]; then # If this file is missing from $FtpFilesDir
let NumLocNoChgFiles_in_FtpFiles+=1 # Increment the error count
echo "NumLocNoChgFiles_in_FtpFiles incremented to: $NumLocNoChgFiles_in_FtpFiles" | tee -a $LOG_FILE
# Register the failure
echo "$LocalNochangeName:$i ** Test Condition 5 failed: file $LocalNoChg_tmp missing from $FtpFilesName" | tee -a $LOG_FILE
fi
done
exec 0<&- # Close $LocalNochangeDir
exec 0<&7 7<&- # Restore stdin from fd #7 & close fd #7
else
echo "$LocalNochangeName:$i Test Condition 5 skipped: no files in $LocalNochangeName" | tee -a $LOG_FILE
fi
echo "***************************************" | tee -a $LOG_FILE
#**------------------------------------------
#** Starting Backups
#**------------------------------------------
# Prepare for generating BackupNochangeDir
cp $BackupFilesDir $BackupNochangeDir
echo "Files in $BackupFilesName ="$(cat $BackupFilesDir | wc -l) | tee -a $LOG_FILE
echo "Files in $BackupAddName ="$(cat $BackupAddDir | wc -l) | tee -a $LOG_FILE
num=$(cat $BackupRemoveDir | wc -l) # Get the number of files in $BackupRemoveDir
echo "Files in $BackupRemoveName =$num" | tee -a $LOG_FILE # Print the number
i=0 # Reset files counter
if [ $(($num)) -gt 0 ]; then # If files exist in $BackupRemoveDir, analyse them
# Prepare to read from the $BackupRemoveDir file
exec 7<&0
exec < $BackupRemoveDir
echo "Examining files listed in $BackupRemoveName now..." | tee -a $LOG_FILE
while [ $(($i)) -lt $(($num)) ]; do # Examine all $BackupRemoveDir files
# Generate $BackupNochangeDir during this
let i+=1 # Increment file counter
read BackupRemove_tmp
echo "$BackupRemoveName:$i Examining "$BackupRemove_tmp | tee -a $LOG_FILE
# Check for $BackupRemove_tmp file in $BackupFilesDir (should exist); 'sed' argument provides exact match
FileInBackupFiles=$(cat $BackupFilesDir | sed -ne '/^'$BackupRemove_tmp'$/p')
echo "$BackupRemoveName:$i Test 6: This file should exist in $BackupFilesName >" $FileInBackupFiles | tee -a $LOG_FILE
if [ -z "$FileInBackupFiles" ]; then # If this file is missing from $BackupFilesDir
let NumBackupRem_in_BackupFiles+=1 # Increment the error count
echo "NumBackupRem_in_BackupFiles incremented to: $NumBackupRem_in_BackupFiles" | tee -a $LOG_FILE
# Register the failure
echo "$BackupRemoveName:$i ** Test Condition 6 failed: file $BackupRemove_tmp missing from $BackupFilesName" | tee -a $LOG_FILE
fi
# Generate $BackupNochangeDir file
# Set an argument for sed, to remove $BackupRemove_tmp from $BackupNochangeDir
MATCHTEXT='/'$BackupRemove_tmp'/!p'
# Remove $BackupRemove_tmp file from $BackupNochangeDir file
# Eventually, after processing all $BackupRemoveDir files, $BackupNochangeDir will represent
# $BackupFilesDir, minus all $BackupRemoveDir files
cat $BackupNochangeDir | sed -ne $MATCHTEXT | cat > $BackupFilesTmpDir
# Move tmp file to $BackupNochangeDir for the next iteration
mv $BackupFilesTmpDir $BackupNochangeDir
# Check for $BackupRemove_tmp file in $LocalUpdDir (should not exist); 'sed' argument provides exact match
File_in_LocalUpd=$(cat $LocalUpdDir | sed -ne '/^'$BackupRemove_tmp'$/p')
echo "$BackupRemoveName:$i Test 7: This file should NOT exist in $LocalUpdName >" $File_in_LocalUpd | tee -a $LOG_FILE
if [ -n "$File_in_LocalUpd" ]; then # If this file exists in $LocalUpdDir
let NumBackupRem_in_LocalUpd+=1 # Increment the error count
echo "NumBackupRem_in_LocalUpd incremented to: $NumBackupRem_in_LocalUpd" | tee -a $LOG_FILE
# Register the failure
echo "$BackupRemoveName:$i ** Test Condition 7 failed: file $BackupRemove_tmp exists in $LocalUpdName" | tee -a $LOG_FILE
fi
done
exec 0<&- # Close $BackupRemoveDir
exec 0<&7 7<&- # Restore stdin from fd #7 & close fd #7
else
echo "$BackupRemoveName:$i Test Conditions 6 & 7 skipped: no files in $BackupRemoveName" | tee -a $LOG_FILE
fi
echo "***************************************" | tee -a $LOG_FILE
num=$(cat $BackupAddDir | wc -l) # Get the number of files in $BackupAddDir
echo "files in $BackupAddName =$num" | tee -a $LOG_FILE # Print the number
i=0 # Reset files counter
if [ $(($num)) -gt 0 ]; then # If files exist in $BackupAddDir, analyse them
# Prepare to read from the $BackupAddDir file
exec 7<&0
exec < $BackupAddDir
echo "Examining files listed in $BackupAddName now..." | tee -a $LOG_FILE
while [ $(($i)) -lt $(($num)) ]; do # Examine all $BackupAddDir files
# Generate $BackupNochangeDir during this
let i+=1 # Increment file counter
read BackupAdd_tmp
echo "$BackupAddName:$i Examining "$BackupAdd_tmp | tee -a $LOG_FILE
# Check for $FtpFil_tmp file in $LocalUpdDir (should exist); 'sed' argument provides exact match
FileInLocalUpd=$(cat $LocalUpdDir | sed -ne '/^'$BackupAdd_tmp'$/p')
echo "$BackupAddName:$i Test 8: This file should exist in $LocalUpdName >" $FileInLocalUpd | tee -a $LOG_FILE
if [ -z "$FileInLocalUpd" ]; then # If this file is missing from $LocalUpdDir
let NumBackupAdd_in_LocalUpd+=1 # Increment the error count
echo "NumBackupAdd_in_LocalUpd incremented to: $NumBackupAdd_in_LocalUpd" | tee -a $LOG_FILE
echo "** Test Condition 8 failed: file $BackupAdd_tmp missing from $LocalUpdName" | tee -a $LOG_FILE # Register the failure
fi
# Check for $FtpFil_tmp file in $BackupFilesDir (should not exist); 'sed' argument provides exact match
FileInBackupFiles=$(cat $BackupFilesDir | sed -ne '/^'$BackupAdd_tmp'$/p')
echo "$BackupAddName:$i Test 9: This file should NOT exist in $BackupFilesName >" $FileInBackupFiles | tee -a $LOG_FILE
if [ -n "$FileInBackupFiles" ]; then # If this file exists in $BackupFilesDir
let NumBackupAdd_in_BackupFiles+=1 # Increment the error count
echo "NumBackupAdd_in_BackupFiles incremented to: $NumBackupAdd_in_BackupFiles" | tee -a $LOG_FILE
echo "FileInBackupFiles =$FileInBackupFiles" | tee -a $LOG_FILE
# Register the failure
echo "$BackupAddName:$i ** Test Condition 9 failed: file $BackupAdd_tmp exists in $BackupFilesName" | tee -a $LOG_FILE
fi
done
exec 0<&- # Close $BackupAddDir
exec 0<&7 7<&- # Restore stdin from fd #7 & close fd #7
else
echo "$BackupAddName:$i Test Conditions 8 & 9 skipped: no files in $BackupAddName" | tee -a $LOG_FILE
fi
echo "***************************************" | tee -a $LOG_FILE
echo "Checking unchanged backup files now..." | tee -a $LOG_FILE
num=$(cat $BackupNochangeDir | wc -l) # Get the number of files in $BackupNochangeDir
echo "Files in $BackupNochangeName =$num" | tee -a $LOG_FILE # Print the number
i=0 # Reset files counter
if [ $(($num)) -gt 0 ]; then # If files exist in $BackupNochangeDir, analyse them
# Prepare to read from the $BackupNochangeDir file
exec 7<&0
exec < $BackupNochangeDir
echo "Examining files listed in $BackupNochangeName now..." | tee -a $LOG_FILE
while [ $(($i)) -lt $(($num)) ]; do # Examine all $BackupNochangeDir files
let i+=1 # Increment file counter
read BackupNoChg_tmp
echo "$BackupNochangeName:$i Examining "$BackupNoChg_tmp | tee -a $LOG_FILE
# Check for $BackupNoChg_tmp file in $LocalUpdDir (should exist); 'sed' argument provides exact match
FileInLocalUpd=$(cat $LocalUpdDir | sed -ne '/^'$BackupNoChg_tmp'$/p')
echo "$BackupNochangeName:$i Test 10: This file should exist in $LocalUpdName >" $FileInLocalUpd | tee -a $LOG_FILE
if [ -z "$FileInLocalUpd" ]; then # If this file is missing from $LocalUpdDir
let NumBackupNoChgFiles_in_LocalUpd+=1 # Increment the error count
echo "NumBackupNoChgFiles_in_LocalUpd incremented to: $NumBackupNoChgFiles_in_LocalUpd" | tee -a $LOG_FILE
# Register the failure
echo "$BackupNochangeName:$i ** Test Condition 10 failed: file $BackupNoChg_tmp missing from $LocalUpdName" | tee -a $LOG_FILE
fi
done
exec 0<&- # Close $BackupNochangeDir
exec 0<&7 7<&- # Restore stdin from fd #7 & close fd #7
else
echo "$BackupNochangeName:$i Test Condition 10 skipped: no files in $BackupNochangeName" | tee -a $LOG_FILE
fi
echo "**********************************************************" | tee -a $LOG_FILE
echo "SUMMARY for '$Dir' directory:" | tee -a $LOG_FILE
echo "Test Condition 1: $NumLocRem_in_LocFiles errors" | tee -a $LOG_FILE
echo "Test Condition 2: $NumLocRem_in_FtpFiles errors" | tee -a $LOG_FILE
echo "Test Condition 3: $NumFtpFil_in_FtpFiles errors" | tee -a $LOG_FILE
echo "Test Condition 4: $NumFtpFil_in_LocFiles errors" | tee -a $LOG_FILE
echo "Test Condition 5: $NumLocNoChgFiles_in_FtpFiles errors" | tee -a $LOG_FILE
echo "Test Condition 6: $NumBackupRem_in_BackupFiles errors" | tee -a $LOG_FILE
echo "Test Condition 7: $NumBackupRem_in_LocalUpd errors" | tee -a $LOG_FILE
echo "Test Condition 8: $NumBackupAdd_in_LocalUpd errors" | tee -a $LOG_FILE
echo "Test Condition 9: $NumBackupAdd_in_BackupFiles errors" | tee -a $LOG_FILE
echo "Test Condition 10: $NumBackupNoChgFiles_in_LocalUpd errors" | tee -a $LOG_FILE
# Save Error Conditions for later report
case $Dir in
deltas)
ErrDeltas[0]=$NumLocRem_in_LocFiles
ErrDeltas[1]=$NumLocRem_in_FtpFiles
ErrDeltas[2]=$NumFtpFil_in_FtpFiles
ErrDeltas[3]=$NumFtpFil_in_LocFiles
ErrDeltas[4]=$NumLocNoChgFiles_in_FtpFiles
ErrDeltas[5]=$NumBackupRem_in_BackupFiles
ErrDeltas[6]=$NumBackupRem_in_LocalUpd
ErrDeltas[7]=$NumBackupAdd_in_LocalUpd
ErrDeltas[8]=$NumBackupAdd_in_BackupFiles
ErrDeltas[9]=$NumBackupNoChgFiles_in_LocalUpd
;;
patches)
ErrPatches[0]=$NumLocRem_in_LocFiles
ErrPatches[1]=$NumLocRem_in_FtpFiles
ErrPatches[2]=$NumFtpFil_in_FtpFiles
ErrPatches[3]=$NumFtpFil_in_LocFiles
ErrPatches[4]=$NumLocNoChgFiles_in_FtpFiles
ErrPatches[5]=$NumBackupRem_in_BackupFiles
ErrPatches[6]=$NumBackupRem_in_LocalUpd
ErrPatches[7]=$NumBackupAdd_in_LocalUpd
ErrPatches[8]=$NumBackupAdd_in_BackupFiles
ErrPatches[9]=$NumBackupNoChgFiles_in_LocalUpd
;;
patches.obs)
ErrPatchesObs[0]=$NumLocRem_in_LocFiles
ErrPatchesObs[1]=$NumLocRem_in_FtpFiles
ErrPatchesObs[2]=$NumFtpFil_in_FtpFiles
ErrPatchesObs[3]=$NumFtpFil_in_LocFiles
ErrPatchesObs[4]=$NumLocNoChgFiles_in_FtpFiles
ErrPatchesObs[5]=$NumBackupRem_in_BackupFiles
ErrPatchesObs[6]=$NumBackupRem_in_LocalUpd
ErrPatchesObs[7]=$NumBackupAdd_in_LocalUpd
ErrPatchesObs[8]=$NumBackupAdd_in_BackupFiles
ErrPatchesObs[9]=$NumBackupNoChgFiles_in_LocalUpd
;;
"$ARCH")
ErrArch[0]=$NumLocRem_in_LocFiles
ErrArch[1]=$NumLocRem_in_FtpFiles
ErrArch[2]=$NumFtpFil_in_FtpFiles
ErrArch[3]=$NumFtpFil_in_LocFiles
ErrArch[4]=$NumLocNoChgFiles_in_FtpFiles
ErrArch[5]=$NumBackupRem_in_BackupFiles
ErrArch[6]=$NumBackupRem_in_LocalUpd
ErrArch[7]=$NumBackupAdd_in_LocalUpd
ErrArch[8]=$NumBackupAdd_in_BackupFiles
ErrArch[9]=$NumBackupNoChgFiles_in_LocalUpd
;;
noarch)
ErrNoarch[0]=$NumLocRem_in_LocFiles
ErrNoarch[1]=$NumLocRem_in_FtpFiles
ErrNoarch[2]=$NumFtpFil_in_FtpFiles
ErrNoarch[3]=$NumFtpFil_in_LocFiles
ErrNoarch[4]=$NumLocNoChgFiles_in_FtpFiles
ErrNoarch[5]=$NumBackupRem_in_BackupFiles
ErrNoarch[6]=$NumBackupRem_in_LocalUpd
ErrNoarch[7]=$NumBackupAdd_in_LocalUpd
ErrNoarch[8]=$NumBackupAdd_in_BackupFiles
ErrNoarch[9]=$NumBackupNoChgFiles_in_LocalUpd
;;
scripts)
ErrScripts[0]=$NumLocRem_in_LocFiles
ErrScripts[1]=$NumLocRem_in_FtpFiles
ErrScripts[2]=$NumFtpFil_in_FtpFiles
ErrScripts[3]=$NumFtpFil_in_LocFiles
ErrScripts[4]=$NumLocNoChgFiles_in_FtpFiles
ErrScripts[5]=$NumBackupRem_in_BackupFiles
ErrScripts[6]=$NumBackupRem_in_LocalUpd
ErrScripts[7]=$NumBackupAdd_in_LocalUpd
ErrScripts[8]=$NumBackupAdd_in_BackupFiles
ErrScripts[9]=$NumBackupNoChgFiles_in_LocalUpd
;;
esac
Err=0 # Reset Err flag
if [ $(($NumLocRem_in_LocFiles)) -gt 0 ]; then let Err+=1; fi
if [ $(($NumLocRem_in_FtpFiles)) -gt 0 ]; then let Err+=1; fi
if [ $(($NumFtpFil_in_FtpFiles)) -gt 0 ]; then let Err+=1; fi
if [ $(($NumFtpFil_in_LocFiles)) -gt 0 ]; then let Err+=1; fi
if [ $(($NumLocNoChgFiles_in_FtpFiles)) -gt 0 ]; then let Err+=1; fi
if [ $(($NumBackupRem_in_BackupFiles)) -gt 0 ]; then let Err+=1; fi
if [ $(($NumBackupRem_in_LocalUpd)) -gt 0 ]; then let Err+=1; fi
if [ $(($NumBackupAdd_in_LocalUpd)) -gt 0 ]; then let Err+=1; fi
if [ $(($NumBackupAdd_in_BackupFiles)) -gt 0 ]; then let Err+=1; fi
if [ $(($NumBackupNoChgFiles_in_LocalUpd)) -gt 0 ]; then let Err+=1; fi
# Check for overall errors
if [ $(($Err)) -gt 0 ]; then
if [ $(($Err)) -eq 1 ]; then
Conditions="Condition"
else
Conditions="Conditions"
fi
echo "$Err Test $Conditions failed in \'$Dir\' directory. Check Log file" | tee -a $LOG_FILE
else
echo "All Test Conditions passed in \'$Dir\' directory." | tee -a $LOG_FILE
fi
echo "**********************************************************" | tee -a $LOG_FILE
done
echo | tee -a $LOG_FILE
echo "End of detailed tests." | tee -a $LOG_FILE
echo "Start of Summaries..." | tee -a $LOG_FILE
echo | tee -a $LOG_FILE
# Print Overall Summary of Test Results
ErrAll=0 # Reset Overall error flag
for Dir in "${IdxDir[@]}"; do # for all the directories
case $Dir in
deltas)
ErrDel=0 # Reset Deltas error flag
if [ $((${ErrDeltas[0]})) -gt 0 ]; then let ErrDel+=1; let ErrAll+=1; fi
if [ $((${ErrDeltas[1]})) -gt 0 ]; then let ErrDel+=1; let ErrAll+=1; fi
if [ $((${ErrDeltas[2]})) -gt 0 ]; then let ErrDel+=1; let ErrAll+=1; fi
if [ $((${ErrDeltas[3]})) -gt 0 ]; then let ErrDel+=1; let ErrAll+=1; fi
if [ $((${ErrDeltas[4]})) -gt 0 ]; then let ErrDel+=1; let ErrAll+=1; fi
if [ $((${ErrDeltas[5]})) -gt 0 ]; then let ErrDel+=1; let ErrAll+=1; fi
if [ $((${ErrDeltas[6]})) -gt 0 ]; then let ErrDel+=1; let ErrAll+=1; fi
if [ $((${ErrDeltas[7]})) -gt 0 ]; then let ErrDel+=1; let ErrAll+=1; fi
if [ $((${ErrDeltas[8]})) -gt 0 ]; then let ErrDel+=1; let ErrAll+=1; fi
if [ $((${ErrDeltas[9]})) -gt 0 ]; then let ErrDel+=1; let ErrAll+=1; fi
echo "**********************************************************" | tee -a $LOG_FILE
echo "SUMMARY for 'deltas' directory:" | tee -a $LOG_FILE
echo "Test Condition 1: ${ErrDeltas[0]} errors" | tee -a $LOG_FILE
echo "Test Condition 2: ${ErrDeltas[1]} errors" | tee -a $LOG_FILE
echo "Test Condition 3: ${ErrDeltas[2]} errors" | tee -a $LOG_FILE
echo "Test Condition 4: ${ErrDeltas[3]} errors" | tee -a $LOG_FILE
echo "Test Condition 5: ${ErrDeltas[4]} errors" | tee -a $LOG_FILE
echo "Test Condition 6: ${ErrDeltas[5]} errors" | tee -a $LOG_FILE
echo "Test Condition 7: ${ErrDeltas[6]} errors" | tee -a $LOG_FILE
echo "Test Condition 8: ${ErrDeltas[7]} errors" | tee -a $LOG_FILE
echo "Test Condition 9: ${ErrDeltas[8]} errors" | tee -a $LOG_FILE
echo "Test Condition 10: ${ErrDeltas[9]} errors" | tee -a $LOG_FILE
if [ $(($ErrDel)) -gt 0 ]; then
if [ $(($ErrDel)) -eq 1 ]; then
Conditions="Condition"
else
Conditions="Conditions"
fi
echo "$ErrDel Test $Conditions FAILED in 'deltas' directory. Check Log file" | tee -a $LOG_FILE
else
echo "All Test Conditions PASSED in 'deltas' directory." | tee -a $LOG_FILE
fi
echo "**********************************************************" | tee -a $LOG_FILE
;;
patches)
ErrPat=0 # Reset Patches error flag
if [ $((${ErrPatches[0]})) -gt 0 ]; then let ErrPat+=1; let ErrAll+=1; fi
if [ $((${ErrPatches[1]})) -gt 0 ]; then let ErrPat+=1; let ErrAll+=1; fi
if [ $((${ErrPatches[2]})) -gt 0 ]; then let ErrPat+=1; let ErrAll+=1; fi
if [ $((${ErrPatches[3]})) -gt 0 ]; then let ErrPat+=1; let ErrAll+=1; fi
if [ $((${ErrPatches[4]})) -gt 0 ]; then let ErrPat+=1; let ErrAll+=1; fi
if [ $((${ErrPatches[5]})) -gt 0 ]; then let ErrPat+=1; let ErrAll+=1; fi
if [ $((${ErrPatches[6]})) -gt 0 ]; then let ErrPat+=1; let ErrAll+=1; fi
if [ $((${ErrPatches[7]})) -gt 0 ]; then let ErrPat+=1; let ErrAll+=1; fi
if [ $((${ErrPatches[8]})) -gt 0 ]; then let ErrPat+=1; let ErrAll+=1; fi
if [ $((${ErrPatches[9]})) -gt 0 ]; then let ErrPat+=1; let ErrAll+=1; fi
echo "**********************************************************" | tee -a $LOG_FILE
echo "SUMMARY for 'patches' directory:" | tee -a $LOG_FILE
echo "Test Condition 1: ${ErrPatches[0]} errors" | tee -a $LOG_FILE
echo "Test Condition 2: ${ErrPatches[1]} errors" | tee -a $LOG_FILE
echo "Test Condition 3: ${ErrPatches[2]} errors" | tee -a $LOG_FILE
echo "Test Condition 4: ${ErrPatches[3]} errors" | tee -a $LOG_FILE
echo "Test Condition 5: ${ErrPatches[4]} errors" | tee -a $LOG_FILE
echo "Test Condition 6: ${ErrPatches[5]} errors" | tee -a $LOG_FILE
echo "Test Condition 7: ${ErrPatches[6]} errors" | tee -a $LOG_FILE
echo "Test Condition 8: ${ErrPatches[7]} errors" | tee -a $LOG_FILE
echo "Test Condition 9: ${ErrPatches[8]} errors" | tee -a $LOG_FILE
echo "Test Condition 10: ${ErrPatches[9]} errors" | tee -a $LOG_FILE
if [ $(($ErrPat)) -gt 0 ]; then
if [ $(($ErrPat)) -eq 1 ]; then
Conditions="Condition"
else
Conditions="Conditions"
fi
echo "$ErrPat Test $Conditions FAILED in 'patches' directory. Check Log file" | tee -a $LOG_FILE
else
echo "All Test Conditions PASSED in 'patches' directory." | tee -a $LOG_FILE
fi
echo "**********************************************************" | tee -a $LOG_FILE
;;
patches.obs)
ErrPatObs=0 # Reset PatchesObs error flag
if [ $((${ErrPatchesObs[0]})) -gt 0 ]; then let ErrPatObs+=1; let ErrAll+=1; fi
if [ $((${ErrPatchesObs[1]})) -gt 0 ]; then let ErrPatObs+=1; let ErrAll+=1; fi
if [ $((${ErrPatchesObs[2]})) -gt 0 ]; then let ErrPatObs+=1; let ErrAll+=1; fi
if [ $((${ErrPatchesObs[3]})) -gt 0 ]; then let ErrPatObs+=1; let ErrAll+=1; fi
if [ $((${ErrPatchesObs[4]})) -gt 0 ]; then let ErrPatObs+=1; let ErrAll+=1; fi
if [ $((${ErrPatchesObs[5]})) -gt 0 ]; then let ErrPatObs+=1; let ErrAll+=1; fi
if [ $((${ErrPatchesObs[6]})) -gt 0 ]; then let ErrPatObs+=1; let ErrAll+=1; fi
if [ $((${ErrPatchesObs[7]})) -gt 0 ]; then let ErrPatObs+=1; let ErrAll+=1; fi
if [ $((${ErrPatchesObs[8]})) -gt 0 ]; then let ErrPatObs+=1; let ErrAll+=1; fi
if [ $((${ErrPatchesObs[9]})) -gt 0 ]; then let ErrPatObs+=1; let ErrAll+=1; fi
echo "**********************************************************" | tee -a $LOG_FILE
echo "SUMMARY for 'patches.obsolete' directory:" | tee -a $LOG_FILE
echo "Test Condition 1: ${ErrPatchesObs[0]} errors" | tee -a $LOG_FILE
echo "Test Condition 2: ${ErrPatchesObs[1]} errors" | tee -a $LOG_FILE
echo "Test Condition 3: ${ErrPatchesObs[2]} errors" | tee -a $LOG_FILE
echo "Test Condition 4: ${ErrPatchesObs[3]} errors" | tee -a $LOG_FILE
echo "Test Condition 5: ${ErrPatchesObs[4]} errors" | tee -a $LOG_FILE
echo "Test Condition 6: ${ErrPatchesObs[5]} errors" | tee -a $LOG_FILE
echo "Test Condition 7: ${ErrPatchesObs[6]} errors" | tee -a $LOG_FILE
echo "Test Condition 8: ${ErrPatchesObs[7]} errors" | tee -a $LOG_FILE
echo "Test Condition 9: ${ErrPatchesObs[8]} errors" | tee -a $LOG_FILE
echo "Test Condition 10: ${ErrPatchesObs[9]} errors" | tee -a $LOG_FILE
if [ $(($ErrPatObs)) -gt 0 ]; then
if [ $(($ErrPatObs)) -eq 1 ]; then
Conditions="Condition"
else
Conditions="Conditions"
fi
echo "$ErrPatObs Test $Conditions FAILED in 'patches.obsolete' directory. Check Log file" | tee -a $LOG_FILE
else
echo "All Test Conditions PASSED in 'patches.obsolete' directory." | tee -a $LOG_FILE
fi
echo "**********************************************************" | tee -a $LOG_FILE
;;
"$ARCH")
Err_Arch=0 # Reset Arch error flag
if [ $((${ErrArch[0]})) -gt 0 ]; then let Err_Arch+=1; let ErrAll+=1; fi
if [ $((${ErrArch[1]})) -gt 0 ]; then let Err_Arch+=1; let ErrAll+=1; fi
if [ $((${ErrArch[2]})) -gt 0 ]; then let Err_Arch+=1; let ErrAll+=1; fi
if [ $((${ErrArch[3]})) -gt 0 ]; then let Err_Arch+=1; let ErrAll+=1; fi
if [ $((${ErrArch[4]})) -gt 0 ]; then let Err_Arch+=1; let ErrAll+=1; fi
if [ $((${ErrArch[5]})) -gt 0 ]; then let Err_Arch+=1; let ErrAll+=1; fi
if [ $((${ErrArch[6]})) -gt 0 ]; then let Err_Arch+=1; let ErrAll+=1; fi
if [ $((${ErrArch[7]})) -gt 0 ]; then let Err_Arch+=1; let ErrAll+=1; fi
if [ $((${ErrArch[8]})) -gt 0 ]; then let Err_Arch+=1; let ErrAll+=1; fi
if [ $((${ErrArch[9]})) -gt 0 ]; then let Err_Arch+=1; let ErrAll+=1; fi
echo "**********************************************************" | tee -a $LOG_FILE
echo "SUMMARY for '$ARCH' directory:" | tee -a $LOG_FILE
echo "Test Condition 1: ${ErrArch[0]} errors" | tee -a $LOG_FILE
echo "Test Condition 2: ${ErrArch[1]} errors" | tee -a $LOG_FILE
echo "Test Condition 3: ${ErrArch[2]} errors" | tee -a $LOG_FILE
echo "Test Condition 4: ${ErrArch[3]} errors" | tee -a $LOG_FILE
echo "Test Condition 5: ${ErrArch[4]} errors" | tee -a $LOG_FILE
echo "Test Condition 6: ${ErrArch[5]} errors" | tee -a $LOG_FILE
echo "Test Condition 7: ${ErrArch[6]} errors" | tee -a $LOG_FILE
echo "Test Condition 8: ${ErrArch[7]} errors" | tee -a $LOG_FILE
echo "Test Condition 9: ${ErrArch[8]} errors" | tee -a $LOG_FILE
echo "Test Condition 10: ${ErrArch[9]} errors" | tee -a $LOG_FILE
if [ $(($Err_Arch)) -gt 0 ]; then
if [ $(($Err_Arch)) -eq 1 ]; then
Conditions="Condition"
else
Conditions="Conditions"
fi
echo "$Err_Arch Test $Conditions FAILED in '$ARCH' directory. Check Log file" | tee -a $LOG_FILE
else
echo "All Test Conditions PASSED in '$ARCH' directory." | tee -a $LOG_FILE
fi
echo "**********************************************************" | tee -a $LOG_FILE
;;
noarch)
Err_Noarch=0 # Reset Noarch error flag
if [ $((${ErrNoarch[0]})) -gt 0 ]; then let Err_Noarch+=1; let ErrAll+=1; fi
if [ $((${ErrNoarch[1]})) -gt 0 ]; then let Err_Noarch+=1; let ErrAll+=1; fi
if [ $((${ErrNoarch[2]})) -gt 0 ]; then let Err_Noarch+=1; let ErrAll+=1; fi
if [ $((${ErrNoarch[3]})) -gt 0 ]; then let Err_Noarch+=1; let ErrAll+=1; fi
if [ $((${ErrNoarch[4]})) -gt 0 ]; then let Err_Noarch+=1; let ErrAll+=1; fi
if [ $((${ErrNoarch[5]})) -gt 0 ]; then let Err_Noarch+=1; let ErrAll+=1; fi
if [ $((${ErrNoarch[6]})) -gt 0 ]; then let Err_Noarch+=1; let ErrAll+=1; fi
if [ $((${ErrNoarch[7]})) -gt 0 ]; then let Err_Noarch+=1; let ErrAll+=1; fi
if [ $((${ErrNoarch[8]})) -gt 0 ]; then let Err_Noarch+=1; let ErrAll+=1; fi
if [ $((${ErrNoarch[9]})) -gt 0 ]; then let Err_Noarch+=1; let ErrAll+=1; fi
echo "**********************************************************" | tee -a $LOG_FILE
echo "SUMMARY for 'noarch' directory:" | tee -a $LOG_FILE
echo "Test Condition 1: ${ErrNoarch[0]} errors" | tee -a $LOG_FILE
echo "Test Condition 2: ${ErrNoarch[1]} errors" | tee -a $LOG_FILE
echo "Test Condition 3: ${ErrNoarch[2]} errors" | tee -a $LOG_FILE
echo "Test Condition 4: ${ErrNoarch[3]} errors" | tee -a $LOG_FILE
echo "Test Condition 5: ${ErrNoarch[4]} errors" | tee -a $LOG_FILE
echo "Test Condition 6: ${ErrNoarch[5]} errors" | tee -a $LOG_FILE
echo "Test Condition 7: ${ErrNoarch[6]} errors" | tee -a $LOG_FILE
echo "Test Condition 8: ${ErrNoarch[7]} errors" | tee -a $LOG_FILE
echo "Test Condition 9: ${ErrNoarch[8]} errors" | tee -a $LOG_FILE
echo "Test Condition 10: ${ErrNoarch[9]} errors" | tee -a $LOG_FILE
if [ $(($Err_Noarch)) -gt 0 ]; then
if [ $(($Err_Noarch)) -eq 1 ]; then
Conditions="Condition"
else
Conditions="Conditions"
fi
echo "$Err_Noarch Test $Conditions FAILED in 'noarch' directory. Check Log file" | tee -a $LOG_FILE
else
echo "All Test Conditions PASSED in 'noarch' directory." | tee -a $LOG_FILE
fi
echo "**********************************************************" | tee -a $LOG_FILE
;;
scripts)
ErrScr=0 # Reset Scripts error flag
if [ $((${ErrScripts[0]})) -gt 0 ]; then let ErrScr+=1; let ErrAll+=1; fi
if [ $((${ErrScripts[1]})) -gt 0 ]; then let ErrScr+=1; let ErrAll+=1; fi
if [ $((${ErrScripts[2]})) -gt 0 ]; then let ErrScr+=1; let ErrAll+=1; fi
if [ $((${ErrScripts[3]})) -gt 0 ]; then let ErrScr+=1; let ErrAll+=1; fi
if [ $((${ErrScripts[4]})) -gt 0 ]; then let ErrScr+=1; let ErrAll+=1; fi
if [ $((${ErrScripts[5]})) -gt 0 ]; then let ErrScr+=1; let ErrAll+=1; fi
if [ $((${ErrScripts[6]})) -gt 0 ]; then let ErrScr+=1; let ErrAll+=1; fi
if [ $((${ErrScripts[7]})) -gt 0 ]; then let ErrScr+=1; let ErrAll+=1; fi
if [ $((${ErrScripts[8]})) -gt 0 ]; then let ErrScr+=1; let ErrAll+=1; fi
if [ $((${ErrScripts[9]})) -gt 0 ]; then let ErrScr+=1; let ErrAll+=1; fi
echo "**********************************************************" | tee -a $LOG_FILE
echo "SUMMARY for 'scripts' directory:" | tee -a $LOG_FILE
echo "Test Condition 1: ${ErrScripts[0]} errors" | tee -a $LOG_FILE
echo "Test Condition 2: ${ErrScripts[1]} errors" | tee -a $LOG_FILE
echo "Test Condition 3: ${ErrScripts[2]} errors" | tee -a $LOG_FILE
echo "Test Condition 4: ${ErrScripts[3]} errors" | tee -a $LOG_FILE
echo "Test Condition 5: ${ErrScripts[4]} errors" | tee -a $LOG_FILE
echo "Test Condition 6: ${ErrScripts[5]} errors" | tee -a $LOG_FILE
echo "Test Condition 7: ${ErrScripts[6]} errors" | tee -a $LOG_FILE
echo "Test Condition 8: ${ErrScripts[7]} errors" | tee -a $LOG_FILE
echo "Test Condition 9: ${ErrScripts[8]} errors" | tee -a $LOG_FILE
echo "Test Condition 10: ${ErrScripts[9]} errors" | tee -a $LOG_FILE
if [ $(($ErrScr)) -gt 0 ]; then
if [ $(($ErrScr)) -eq 1 ]; then
Conditions="Condition"
else
Conditions="Conditions"
fi
echo "$ErrScr Test $Conditions FAILED in 'scripts' directory. Check Log file" | tee -a $LOG_FILE
else
echo "All Test Conditions PASSED in 'scripts' directory." | tee -a $LOG_FILE
fi
echo "**********************************************************" | tee -a $LOG_FILE
;;
esac
done
DirErr=0 # Initialise variable for number of directories with errors
echo "Overall SUMMARY for the entire test:" | tee -a $LOG_FILE
if [ $(($ErrDel)) -gt 0 ]; then
if [ $(($ErrDel)) -eq 1 ]; then
Conditions="Condition"
else
Conditions="Conditions"
fi
echo "$ErrDel Test $Conditions FAILED in 'deltas' directory. Check Log file" | tee -a $LOG_FILE
let DirErr+=1
else
echo "All Test Conditions PASSED in 'deltas' directory." | tee -a $LOG_FILE
fi
if [ $(($ErrPat)) -gt 0 ]; then
if [ $(($ErrPat)) -eq 1 ]; then
Conditions="Condition"
else
Conditions="Conditions"
fi
echo "$ErrPat Test $Conditions FAILED in 'patches' directory. Check Log file" | tee -a $LOG_FILE
let DirErr+=1
else
echo "All Test Conditions PASSED in 'patches' directory." | tee -a $LOG_FILE
fi
if [ $(($ErrPatObs)) -gt 0 ]; then
if [ $(($ErrPatObs)) -eq 1 ]; then
Conditions="Condition"
else
Conditions="Conditions"
fi
echo "$ErrPatObs Test $Conditions FAILED in 'patches.obsolete' directory. Check Log file" | tee -a $LOG_FILE
let DirErr+=1
else
echo "All Test Conditions PASSED in 'patches.obsolete' directory." | tee -a $LOG_FILE
fi
if [ $(($Err_Arch)) -gt 0 ]; then
if [ $(($Err_Arch)) -eq 1 ]; then
Conditions="Condition"
else
Conditions="Conditions"
fi
echo "$Err_Arch Test $Conditions FAILED in '$ARCH' directory. Check Log file" | tee -a $LOG_FILE
let DirErr+=1
else
echo "All Test Conditions PASSED in '$ARCH' directory." | tee -a $LOG_FILE
fi
if [ $(($Err_Noarch)) -gt 0 ]; then
if [ $(($Err_Noarch)) -eq 1 ]; then
Conditions="Condition"
else
Conditions="Conditions"
fi
echo "$Err_Noarch Test $Conditions FAILED in 'noarch' directory. Check Log file" | tee -a $LOG_FILE
let DirErr+=1
else
echo "All Test Conditions PASSED in 'noarch' directory." | tee -a $LOG_FILE
fi
if [ $(($ErrScr)) -gt 0 ]; then
if [ $(($ErrScr)) -eq 1 ]; then
Conditions="Condition"
else
Conditions="Conditions"
fi
echo "$ErrScr Test $Conditions FAILED in 'scripts' directory. Check Log file" | tee -a $LOG_FILE
let DirErr+=1
else
echo "All Test Conditions PASSED in 'scripts' directory." | tee -a $LOG_FILE
fi
if [ $(($ErrAll)) -gt 0 ]; then
if [ $(($DirErr)) -eq 1 ]; then
Directories="directory"
else
Directories="directories"
fi
if [ $(($ErrAll)) -eq 1 ]; then
Conditions="Condition"
else
Conditions="Conditions"
fi
echo "$ErrAll Test $Conditions FAILED in $DirErr $Directories. Check Log file." | tee -a $LOG_FILE
else
echo "All Test Conditions PASSED in all directories" | tee -a $LOG_FILE
echo "**********************************************************" | tee -a $LOG_FILE
fi