# Test suite for lyskomd. # Copyright (C) 1998-2001, 2003 Lysator Academic Computer Association. # # This file is part of the LysKOM server. # # LysKOM 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 1, or (at your option) # any later version. # # LysKOM 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 LysKOM; see the file COPYING. If not, write to # Lysator, c/o ISY, Linkoping University, S-581 83 Linkoping, SWEDEN, # or the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, # MA 02139, USA. # # Please report bugs at http://bugzilla.lysator.liu.se/. # Common code for leaks checking source "$srcdir/config/prot-a.exp" set blocks_base 0 set strings_base 0 set blocks_usage 0 set strings_usage 0 proc startup_leaks {{aux "def_val"} { config "" }} { global srcdir if {"$aux" == "def_val"} { set aux $srcdir/lyskomd.0/aux-items.conf } lyskomd_start "$aux" "$config" client_start 0 talk_to client 0 send "A[holl "DejaGnu Leaks Test"]\n" simple_expect "LysKOM" kom_accept_async "0 { }" kom_login 5 "gazonk" 0 } proc shutdown_leaks {} { kom_logout kom_login 5 "gazonk" 0 kom_enable 255 send "9999 44 0\n" simple_expect "=9999" client_death 0 lyskomd_death } proc read_memory_file {} { set allocated_strings 0 set allocated_blocks 0 set f [ open "etc/memory-usage" ] while { [ gets $f line] >= 0 } { if { [regexp "Allocated blocks .grand total." $line] } { set allocated_blocks [lindex "$line" [expr [llength "$line"] - 1]] } elseif { [regexp "Allocated strings" $line] } { set allocated_strings [lindex "$line" [expr [llength "$line"] - 1]] } } close $f return "$allocated_blocks $allocated_strings" } proc read_usage_base {} { global blocks_base global strings_base set val [read_memory_file] set blocks_base [lindex $val 0] set strings_base [lindex $val 1] save_memory_file "usage-base.tmp" } proc check_usage {test id} { global blocks_usage global strings_usage global blocks_base global strings_base set val [read_memory_file] set blocks_usage [lindex $val 0] set strings_usage [lindex $val 1] set succeed 1 if { [expr $strings_usage != $strings_base] } { fail "$test (strings) See lyskomd.$id.\{usage,base\}" set succeed 0 } if { [expr $blocks_usage != $blocks_base] } { fail "$test (blocks) See lyskomd.$id.\{base,usage\}" set succeed 0 } if { $succeed } { pass "$test" } else { save_memory_file "lyskomd.$id.usage" system "cp usage-base.tmp lyskomd.$id.base" } } proc save_memory_file {target} { system "cp etc/memory-usage $target" }