Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Per Cederqvist
lyskom-server-ceder-1616-generations-topgit
Commits
7253c54c
Commit
7253c54c
authored
Aug 25, 1996
by
Per Cederqvist
Browse files
Initial checkin.
parent
ae80520c
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/server/testsuite/.cvsignore
0 → 100644
View file @
7253c54c
l2g.log
l2g.sum
site.exp
test-l2g
src/server/testsuite/config/unix.exp
0 → 100644
View file @
7253c54c
set nl "\r?\n"
set any "\[ -\]"
set deep_any "\\\[ -\\\]"
set stty_init "-echo -onlcr -ocrnl -istrip"
proc l2g_start {} {
global spawn_id
global l2g
spawn $l2g
}
proc l2g_stop {} {
global spawn_id
close
}
proc l2g_send {str} {
unanchored_expect "^l2g> " "prompt before $str"
send "$str\n"
}
proc simple_expect {regex {testname ""}} {
global test
global any
global nl
set test $testname
if {$test == ""} {
set test "looking for $regex"
}
expect {
-re "^$regex$nl" {pass "$test"}
timeout {fail "$test (timeout)"}
eof {fail "$test (eof)"; wait}
buffer_full {fail "$test (buffer_full)"}
-re "($any*)$nl" {
fail "$test (unexpected line '$expect_out(1,string)' waiting for '$regex')"
}
-re "($any*)l2g>" {
fail "$test (unexpected incomplete line '$expect_out(1,string)' waiting for '$regex')"
}
}
unset test
}
proc unanchored_expect {regex testname} {
global test
global any
global nl
set test $testname
expect {
-re "$regex" {pass "$test"}
timeout {fail "$test (timeout)"}
buffer_full {fail "$test (buffer_full)"}
eof {fail "$test (eof)"; wait}
-re "($any*)$nl" {
fail "$test (unexpected line '$expect_out(1,string)' waiting for '$regex')"
}
-re "($any*)l2g>" {
fail "$test (unexpected incomplete line '$expect_out(1,string)' waiting for '$regex')"
}
}
unset test
}
src/server/testsuite/l2g.0/00.exp
0 → 100644
View file @
7253c54c
l2g_start
l2g_send "I0"
l2g_send "I1"
l2g_send "D0"
l2g_send "I0"
l2g_send "C0 1"
l2g_send "C0 1"
l2g_send "C0 1"
l2g_send "l 0 0"
simple_expect "0"
l2g_send "l 0 1"
simple_expect "0"
l2g_send "l 0 2"
simple_expect "0"
l2g_send "l 0 3"
simple_expect "0"
l2g_send "l 0 4"
simple_expect "0"
l2g_send "l 0 5"
simple_expect "0"
l2g_send "a 0 3 103"
l2g_send "l 0 1"
simple_expect "0"
l2g_send "l 0 2"
simple_expect "0"
l2g_send "l 0 3"
simple_expect "103"
l2g_send "l 0 4"
simple_expect "0"
l2g_send "l 0 5"
simple_expect "0"
l2g_send "a 0 4 104"
l2g_send "l 0 1"
simple_expect "0"
l2g_send "l 0 2"
simple_expect "0"
l2g_send "l 0 3"
simple_expect "103"
l2g_send "l 0 4"
simple_expect "104"
l2g_send "l 0 5"
simple_expect "0"
l2g_send "a 0 5 105"
l2g_send "a 0 6 106"
l2g_send "a 0 7 107"
l2g_send "a 0 8 108"
l2g_send "a 0 9 109"
l2g_send "a 0 10 1010"
l2g_send "a 0 11 1011"
l2g_send "a 0 12 1012"
l2g_send "u 0"
simple_expect "Number of blocks: 1"
simple_expect "0: 10 0 3 .dense. .103 104 105 106 107 108 109 1010 1011 1012 ."
#
l2g_send "a 0 13 1013"
l2g_send "a 0 14 1014"
l2g_send "a 0 15 1015"
l2g_send "a 0 16 1016"
l2g_send "a 0 17 1017"
l2g_send "a 0 18 1018"
l2g_send "a 0 19 1019"
l2g_send "a 0 20 1020"
l2g_send "a 0 21 1021"
l2g_send "a 0 22 1022"
l2g_send "a 0 23 1023"
l2g_send "l 0 1"
simple_expect "0" "test 1"
l2g_send "l 0 2"
simple_expect "0" "test 2"
l2g_send "l 0 3"
simple_expect "103"
l2g_send "l 0 4"
simple_expect "104"
l2g_send "l 0 5"
simple_expect "105"
l2g_send "l 0 24"
simple_expect "0"
l2g_send "l 0 23"
simple_expect "1023"
l2g_send "l 0 22"
simple_expect "1022"
l2g_send "l 0 20"
simple_expect "1020"
l2g_send "d 0 20"
l2g_send "l 0 20"
simple_expect "0" "deletion works"
l2g_send "l 0 1"
simple_expect "0"
l2g_send "l 0 2"
simple_expect "0"
l2g_send "l 0 3"
simple_expect "103"
l2g_send "l 0 4"
simple_expect "104"
l2g_send "l 0 5"
simple_expect "105"
l2g_send "l 0 24"
simple_expect "0"
l2g_send "l 0 23"
simple_expect "1023"
l2g_send "l 0 22"
simple_expect "1022"
l2g_send "l 0 20"
simple_expect "0"
l2g_send "l 0 21"
simple_expect "1021"
l2g_send "l 0 19"
simple_expect "1019"
l2g_send "d 0 19"
l2g_send "l 0 18"
simple_expect "1018"
l2g_send "l 0 19"
simple_expect "0"
l2g_send "l 0 20"
simple_expect "0"
l2g_send "l 0 21"
simple_expect "1021"
proc check_state {map} {
l2g_send "n $map 0"
setup_xfail "*"
simple_expect "3" "checking index 0 in $map"
foreach n {3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 20 21 22} {
l2g_send "n $map $n"
setup_xfail "*"
simple_expect "[expr {$n + 1}]" "checking $n in $map"
}
l2g_send "n $map 18"
setup_xfail "*"
simple_expect "21" "checking 18 in $map"
l2g_send "n $map 19"
setup_xfail "*"
simple_expect "21" "checking 19 in $map"
l2g_send "n $map 23"
simple_expect "0" "checking 23 in $map"
l2g_send "n $map 24"
simple_expect "0" "checking 24 in $map"
}
check_state 0
l2g_send "n 1 0"
simple_expect "0"
l2g_send "C0 1"
check_state 1
l2g_send "d 0 14"
check_state 1
l2g_send "d 1 13"
l2g_send "l 0 14"
simple_expect "0"
l2g_send "l 1 13"
simple_expect "0"
l2g_send "I2"
l2g_send "u 2"
simple_expect "Number of blocks: 1"
simple_expect "0: 0 10 0 \\(dense\\) \\\[\\\]"
l2g_send "a2 10 139"
l2g_send "u 2"
simple_expect "Number of blocks: 1"
simple_expect "0: 1 9 10 \\(dense\\) \\\[139 \\\]"
l2g_send "a2 12 141"
l2g_send "u 2"
simple_expect "Number of blocks: 1"
simple_expect "0: 3 8 10 \\(dense\\) \\\[139 0 141 \\\]"
l2g_send "a2 14 147"
l2g_send "u 2"
simple_expect "Number of blocks: 1"
simple_expect "0: 5 7 10 \\(dense\\) \\\[139 0 141 0 147 \\\]"
l2g_send "a2 16 153"
l2g_send "u 2"
simple_expect "Number of blocks: 1"
simple_expect "0: 7 6 10 \\(dense\\) \\\[139 0 141 0 147 0 153 \\\]"
l2g_send "a2 18 157"
l2g_send "u 2"
simple_expect "Number of blocks: 1"
simple_expect "0: 9 5 10 \\(dense\\) \\\[139 0 141 0 147 0 153 0 157 \\\]"
l2g_send "a2 21 167"
l2g_send "u 2"
simple_expect "Number of blocks: 1"
simple_expect "0: 6 4 10 \\(sparse\\) \\\[10:139 12:141 14:147 16:153 18:157 21:167 \\\]"
l2g_stop
src/server/testsuite/test-l2g.c
0 → 100644
View file @
7253c54c
#include
<assert.h>
#include
<stdio.h>
#include
<string.h>
#include
<sys/types.h>
#include
<time.h>
#include
<ctype.h>
#include
"s-string.h"
#include
"/users/inge/src/server/local_to_global.h"
const
int
MAXMAPS
=
10
;
const
int
LINSIZE
=
1024
;
const
int
ARGS
=
3
;
/*
D m destruct
I m init
C m clear
C m m copy
a m l g append
d m l delete
l m l lookup
n m l next-key
c m compact
u m dump
r m read
p m print
*/
int
main
()
{
Local_to_global
maps
[
MAXMAPS
];
char
input
[
LINSIZE
];
int
num
[
ARGS
];
int
n
;
int
got
;
int
ok
;
char
*
s
;
printf
(
"l2g> "
);
fflush
(
stdout
);
while
(
fgets
(
input
,
LINSIZE
,
stdin
)
!=
NULL
)
{
s
=
strchr
(
input
,
'\n'
);
assert
(
s
);
*
s
=
'\0'
;
if
(
*
input
==
'\0'
)
{
printf
(
"EMPTY LINE
\n
l2g> "
);
fflush
(
stdout
);
continue
;
}
for
(
n
=
0
;
n
<
ARGS
;
n
++
)
num
[
n
]
=
0
;
n
=
0
;
got
=
0
;
for
(
s
=
input
+
1
;
*
s
&&
*
s
!=
'\n'
;
++
s
)
{
if
(
isdigit
(
*
s
))
{
if
(
n
<
ARGS
)
{
got
=
1
;
num
[
n
]
=
10
*
num
[
n
]
+
*
s
-
'0'
;
}
else
{
printf
(
"BAD INPUT (too many numbers)
\n
l2g> "
);
fflush
(
stdout
);
continue
;
}
}
else
if
(
*
s
==
' '
)
{
if
(
got
)
n
++
;
got
=
0
;
}
else
{
printf
(
"BAD INPUT (bad character)
\n
l2g> "
);
fflush
(
stdout
);
continue
;
}
}
if
(
got
)
n
++
;
ok
=
0
;
switch
(
*
input
)
{
case
'D'
:
if
(
n
==
1
&&
num
[
0
]
<
MAXMAPS
)
{
l2g_destruct
(
&
maps
[
num
[
0
]]);
ok
=
1
;
}
break
;
case
'I'
:
if
(
n
==
1
&&
num
[
0
]
<
MAXMAPS
)
{
l2g_init
(
&
maps
[
num
[
0
]]);
ok
=
1
;
}
break
;
case
'C'
:
if
(
n
==
1
&&
num
[
0
]
<
MAXMAPS
)
{
l2g_clear
(
&
maps
[
num
[
0
]]);
ok
=
1
;
}
else
if
(
n
==
2
&&
num
[
0
]
<
MAXMAPS
&&
num
[
1
]
<
MAXMAPS
)
{
l2g_copy
(
&
maps
[
num
[
0
]],
&
maps
[
num
[
1
]]);
ok
=
1
;
}
break
;
case
'a'
:
if
(
n
==
3
&&
num
[
0
]
<
MAXMAPS
)
{
l2g_append
(
&
maps
[
num
[
0
]],
num
[
1
],
num
[
2
]);
ok
=
1
;
}
break
;
case
'd'
:
if
(
n
==
2
&&
num
[
0
]
<
MAXMAPS
)
{
l2g_delete
(
&
maps
[
num
[
0
]],
num
[
1
]);
ok
=
1
;
}
break
;
case
'l'
:
if
(
n
==
2
&&
num
[
0
]
<
MAXMAPS
)
{
printf
(
"%lu
\n
"
,
(
unsigned
long
)
l2g_lookup
(
&
maps
[
num
[
0
]],
num
[
1
]));
ok
=
1
;
}
break
;
case
'n'
:
if
(
n
==
2
&&
num
[
0
]
<
MAXMAPS
)
{
printf
(
"%lu
\n
"
,
(
unsigned
long
)
l2g_next_key
(
&
maps
[
num
[
0
]],
num
[
1
]));
ok
=
1
;
}
break
;
case
'c'
:
if
(
n
==
1
&&
num
[
0
]
<
MAXMAPS
)
{
l2g_compact
(
&
maps
[
num
[
0
]]);
ok
=
1
;
}
break
;
case
'u'
:
if
(
n
==
1
&&
num
[
0
]
<
MAXMAPS
)
{
l2g_dump
(
&
maps
[
num
[
0
]],
stdout
);
ok
=
1
;
}
break
;
case
'r'
:
if
(
n
==
1
&&
num
[
0
]
<
MAXMAPS
)
{
l2g_read
(
&
maps
[
num
[
0
]],
stdin
);
ok
=
1
;
}
break
;
case
'p'
:
if
(
n
==
1
&&
num
[
0
]
<
MAXMAPS
)
{
l2g_print
(
&
maps
[
num
[
0
]],
stdout
);
ok
=
1
;
}
break
;
}
if
(
ok
==
0
)
{
printf
(
"BAD LINE (bad params)
\n
l2g> "
);
fflush
(
stdout
);
continue
;
}
printf
(
"l2g> "
);
fflush
(
stdout
);
}
return
0
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment