bug-1121.exp 3.49 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# Test suite for lyskomd.
# Copyright (C) 1999, 2002-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/. 

# Test for bug 1121: mark-as-read mishandles read texts in some
# circumstances.  Also test that lyskomd can repair the problems
# introduced by this bug.

lyskomd_start

client_start 0

talk_to client 0
send "A3Hfoo\n"
simple_expect "LysKOM" "connected"

# Log in as administrator.
send "1000 80 0 { }\n"
simple_expect "=1000"

send "1001 62 5 [holl "gazonk"] 1\n"
simple_expect "=1001"

# Create a few texts.
send "1002 86 [holl "Text"] 1 { 0 5 } 0 { }\n"
simple_expect "=1002 1"
send "1003 86 [holl "Text"] 1 { 0 5 } 0 { }\n"
simple_expect "=1003 2"
send "1004 86 [holl "Text"] 1 { 0 5 } 0 { }\n"
simple_expect "=1004 3"
send "1005 86 [holl "Text"] 1 { 0 5 } 0 { }\n"
simple_expect "=1005 4"
send "1006 86 [holl "Text"] 1 { 0 5 } 0 { }\n"
simple_expect "=1006 5"
send "1007 86 [holl "Text"] 1 { 0 5 } 0 { }\n"
simple_expect "=1007 6"
send "1008 86 [holl "Text"] 1 { 0 5 } 0 { }\n"
simple_expect "=1008 7"
send "1009 86 [holl "Text"] 1 { 0 5 } 0 { }\n"
simple_expect "=1009 8"

# Check what is read.
send "1010 107 5 5 1 0\n"
simple_expect "=1010 0 $any_time 5 255 0 \\* 5 $any_time 00000000"

# Mark texts.
send "1011 27 5 4 { 1 3 4 8 }\n"
simple_expect "=1011"
send "1012 107 5 5 1 0\n"
simple_expect "=1012 0 $any_time 5 255 3 { 1 1 3 4 8 8 } 5 $any_time 00000000"

# Mark texts again.  This triggers the bug.
send "1013 27 5 4 { 5 6 7 8 }\n"
simple_expect "=1013"
send "1014 107 5 5 1 0\n"
simple_expect "=1014 0 $any_time 5 255 2 { 1 1 3 8 } 5 $any_time 00000000"

# Save the database.
send "1015 42 255\n"
simple_expect "=1015"

# Shut down.
send "1016 42 255\n"
simple_expect "=1016"

send "1017 44 0\n"
simple_expect "=1017"

client_death 0

lyskomd_death

# Make sure we can read a broken database with no problem.
unpack_db bug-1121

dbck_run {
    "fparse_read_range_0: discarded out-of-order local number 8 probably introduced by bug 1121"
}

lyskomd_start "" "" "" "" "" [list \
	"WARN: [pwd]/db/number.txt: No such file" \
        ] 0 0 6 9 0 {
    "fparse_read_range_0: discarded out-of-order local number 8 probably introduced by bug 1121"
}

# Log in as person 5.  This reads the broken data into the core
# memory, and marks it as read, so that it is saved back once lyskomd
# terminates.  The dbck that is run from lyskomd_death won't find any
# problems.
client_start 1
talk_to client 1
send "A3Hfoo\n"
simple_expect "LysKOM"
send "1018 80 0 { }\n"
simple_expect "=1018"
send "1019 0 5 [holl "gazonk"]\n"
lyskomd_expect "fparse_read_range_0: discarded out-of-order local number 8 probably introduced by bug 1121"
simple_expect "=1019"

system "kill -TERM $lyskomd_pid"
lyskomd_death "" signal