Skip to content

Commit

Permalink
added new memtest script
Browse files Browse the repository at this point in the history
script for detecting memory issues as each of the regression tests are
run; requires the valgrind program, which is only available on Linux,
so this script is not configured on Windows systems
  • Loading branch information
thunder422 committed Oct 26, 2012
1 parent 1d427d7 commit da0014b
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Expand Up @@ -40,6 +40,7 @@
# is not available use the three RELEASE variables
# 2012-10-24 detect the CMAKE_BUILD_TYPE environment variable and set the
# cmake variable if not already set, then report the build type
# 2012-10-25 added configuration of new memtest script on non-Windows builds

cmake_minimum_required(VERSION 2.8)

Expand Down Expand Up @@ -104,6 +105,14 @@ configure_file(
"${PROJECT_BINARY_DIR}/regtest" @ONLY
)

# configure a memtest script to pass source directory to the script
if (NOT WIN32)
configure_file(
"${PROJECT_SOURCE_DIR}/memtest.in"
"${PROJECT_BINARY_DIR}/memtest" @ONLY
)
endif (NOT WIN32)

# add the binary tree to the search path for include files
# so that ibcp_config.h, autoenums.h, test_names.h can be found
# which is not necessary for in source build
Expand Down
66 changes: 66 additions & 0 deletions memtest.in
@@ -0,0 +1,66 @@
# vim:ts=4:sw=4:filetype=sh:
#
# Interactive BASIC Compiler Project
# File: memtest - script to run all tests and check for memory issues
# Copyright (C) 2010-2012 Thunder422
#
# 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 3 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.
#
# For a copy of the GNU General Public License,
# see <http://www.gnu.org/licenses/>.
#
#
# Change History:
#
# 2012-10-25 initial release (started from regtest)
#
#
# Usage:
# memtest
#
# Details:
# output files are directed to current (IBCP) directory, and then
# comparing to the established output files in the test directory
# reporting any changes as FAIL; also checks for memory issues
# (including memory leaks) and reports a failure if any
#
# Notes:
# memory checking requires the valgrind utility, which is only
# available on Linux
#

rm -f parser*.txt expression*.txt translator*.txt
dir=@ibcp_SOURCE_DIR@/test/
for input in ${dir}parser*.dat ${dir}expression*.dat ${dir}translator*.dat
do
base=${input##*/}
output=${base%.dat}.txt
memout=${base%.dat}.mem
valgrind --leak-check=full ./ibcp -t $input >$output 2>$memout
result=""
cmp -s $dir$output $output
if [ $? -ne 0 ]
then
result=" Results"
fi
errsum=(`grep "ERROR SUMMARY" $memout`)
if [ ${errsum[3]} -ne 0 ]
then
result="$result Memory(${errsum[3]})"
fi
if [ "X$result" == "X" ]
then
result="OK"
else
result="FAIL: $result"
fi
echo Test File $base... $result
done

0 comments on commit da0014b

Please sign in to comment.