# Test suite for lyskomd. # Copyright (C) 1999 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 mail bug reports to bug-lyskom@lysator.liu.se. # Test the lock file of lyskomd and dbck. # Start a server that locks the database. lyskomd_start # Start dbck in read-only mode. No lock is required. spawn ../dbck -d config/lyskomd-config set test "dbck started in read-only mode" expect { -re "^MSG: init_cache: using datafile\.$nl" { pass "$test" } } set test "read-only dbck sent second line" expect { -re "^Read $any_num confs/persons and $any_num texts, eof at $any_num$nl" { pass "$test" } } set test "read-only dbck sent final line" expect { -re "^Press enter to terminate dbck$nl" { pass "$test" } } send "\n" set test "read-only dbck died" expect { eof { pass "$test"; wait } } unset test # Attempt to start dbck in read-write mode. spawn ../dbck -d -i config/lyskomd-config set test "dbck finds a lock" expect { -re "^Database already locked by $any*\.$nl" { pass "$test" } } set test "read-write dbck sent final line" expect { -re "^Press enter to terminate dbck$nl" { pass "$test" } } send "\n" set test "read-write dbck died" expect { eof { pass "$test"; wait } } unset test # Attempt to start a second lyskomd. spawn ../lyskomd -d config/lyskomd-config set test "lyskomd finds a lock" expect { -re "Database already locked by $any*:$lyskomd_pid$nl" { pass "$test" } } set test "lyskomd writes an exiting message." expect { -re "Cannot obtain database lock\. Exiting\.$nl" { pass "$test" } } set test "read-write lyskomd sent final line" expect { -re "^\[0-9 :\]* Press enter to terminate lyskomd$nl" { pass "$test" } } send "\n" set test "read-write lyskomd died" expect { eof { pass "$test"; wait } } unset test # Shut down lyskomd. system "kill -HUP $lyskomd_pid" lyskomd_death # Start a new lyskomd. lyskomd_start # Kill it so that it cannot remove the lock file. system "kill -KILL $lyskomd_pid" set test "lyskomd was killed" expect { eof { pass "$test"; wait } } # Start a new lyskomd. Check that it removes the stale lock file. set new_pid [spawn ../lyskomd -d config/lyskomd-config] set test "stale lock file removed" expect { -re " $new_pid Removed stale lock file left by $any*:$lyskomd_pid\.$nl" { pass "$test" } } system "kill -HUP $new_pid" set test "non-stale lyskomd sent final line" expect { -re "^\[0-9 :\]* $new_pid Press enter to terminate lyskomd$nl" { pass "$test" } } send "\n" set test "non-stale lyskomd died" expect { eof { pass "$test"; wait } } unset test # Start a new lyskomd while a lock file for a remote system exists. system "ln -s inet.lysator.liu.se:4711 db/lyskomd-lock" spawn ../lyskomd -d config/lyskomd-config set test "remote lock file found" expect { -re "Database already locked by inet\.lysator\.liu\.se:4711$nl" { pass "$test" } } set test "local lyskomd sent final line" expect { -re "^\[0-9 :\]* Press enter to terminate lyskomd$nl" { pass "$test" } } send "\n" set test "local lyskomd died" expect { eof { pass "$test"; wait } } unset test