Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
68cf67fd
Commit
68cf67fd
authored
Jul 13, 2023
by
inphi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cannon: MIPS test vectors for syscalls
parent
129c22c8
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
144 additions
and
10 deletions
+144
-10
evm_test.go
cannon/mipsevm/evm_test.go
+16
-5
brk.bin
cannon/mipsevm/open_mips_tests/test/bin/brk.bin
+0
-0
exit_group.bin
cannon/mipsevm/open_mips_tests/test/bin/exit_group.bin
+0
-0
fcntl.bin
cannon/mipsevm/open_mips_tests/test/bin/fcntl.bin
+0
-0
mmap.bin
cannon/mipsevm/open_mips_tests/test/bin/mmap.bin
+0
-0
brk.asm
cannon/mipsevm/open_mips_tests/test/brk.asm
+26
-0
exit_group.asm
cannon/mipsevm/open_mips_tests/test/exit_group.asm
+29
-0
fcntl.asm
cannon/mipsevm/open_mips_tests/test/fcntl.asm
+27
-0
mmap.asm
cannon/mipsevm/open_mips_tests/test/mmap.asm
+28
-0
state_test.go
cannon/mipsevm/state_test.go
+18
-5
No files found.
cannon/mipsevm/evm_test.go
View file @
68cf67fd
...
...
@@ -63,6 +63,8 @@ func TestEVM(t *testing.T) {
if
strings
.
HasPrefix
(
f
.
Name
(),
"oracle"
)
{
oracle
=
staticOracle
(
t
,
[]
byte
(
"hello world"
))
}
// Short-circuit early for exit_group.bin
exitGroup
:=
f
.
Name
()
==
"exit_group.bin"
env
,
evmState
:=
NewEVMEnv
(
contracts
,
addrs
)
env
.
Config
.
Tracer
=
tracer
...
...
@@ -83,6 +85,9 @@ func TestEVM(t *testing.T) {
if
us
.
state
.
PC
==
endAddr
{
break
}
if
exitGroup
&&
us
.
state
.
Exited
{
break
}
insn
:=
state
.
Memory
.
GetMemory
(
state
.
PC
)
t
.
Logf
(
"step: %4d pc: 0x%08x insn: 0x%08x"
,
state
.
Step
,
state
.
PC
,
insn
)
...
...
@@ -122,11 +127,17 @@ func TestEVM(t *testing.T) {
require
.
Equal
(
t
,
hexutil
.
Bytes
(
uniPost
)
.
String
(),
hexutil
.
Bytes
(
evmPost
)
.
String
(),
"mipsevm produced different state than EVM"
)
}
require
.
Equal
(
t
,
uint32
(
endAddr
),
state
.
PC
,
"must reach end"
)
// inspect test result
done
,
result
:=
state
.
Memory
.
GetMemory
(
baseAddrEnd
+
4
),
state
.
Memory
.
GetMemory
(
baseAddrEnd
+
8
)
require
.
Equal
(
t
,
done
,
uint32
(
1
),
"must be done"
)
require
.
Equal
(
t
,
result
,
uint32
(
1
),
"must have success result"
)
if
exitGroup
{
require
.
NotEqual
(
t
,
uint32
(
endAddr
),
us
.
state
.
PC
,
"must not reach end"
)
require
.
True
(
t
,
us
.
state
.
Exited
,
"must set exited state"
)
require
.
Equal
(
t
,
uint8
(
1
),
us
.
state
.
ExitCode
,
"must exit with 1"
)
}
else
{
require
.
Equal
(
t
,
uint32
(
endAddr
),
state
.
PC
,
"must reach end"
)
// inspect test result
done
,
result
:=
state
.
Memory
.
GetMemory
(
baseAddrEnd
+
4
),
state
.
Memory
.
GetMemory
(
baseAddrEnd
+
8
)
require
.
Equal
(
t
,
done
,
uint32
(
1
),
"must be done"
)
require
.
Equal
(
t
,
result
,
uint32
(
1
),
"must have success result"
)
}
})
}
}
...
...
cannon/mipsevm/open_mips_tests/test/bin/brk.bin
0 → 100644
View file @
68cf67fd
File added
cannon/mipsevm/open_mips_tests/test/bin/exit_group.bin
0 → 100644
View file @
68cf67fd
File added
cannon/mipsevm/open_mips_tests/test/bin/fcntl.bin
0 → 100644
View file @
68cf67fd
File added
cannon/mipsevm/open_mips_tests/test/bin/mmap.bin
0 → 100644
View file @
68cf67fd
File added
cannon/mipsevm/open_mips_tests/test/brk.asm
0 → 100644
View file @
68cf67fd
.
section
.
test
,
"x"
.
balign
4
.
set
noreorder
.
global
test
.
ent
test
test
:
li
$
v0
,
4045
syscall
lui
$
t0
,
0x4000
subu
$
v0
,
$
v0
,
$
t0
sltiu
$
v0
,
$
v0
,
1
#
save
results
lui
$
s0
,
0xbfff
#
Load
the
base
address
0xbffffff0
ori
$
s0
,
0xfff0
ori
$
s1
,
$
0
,
1
#
Prepare
the
'
done
'
status
sw
$
v0
,
8
(
$
s0
)
#
Set
the
test
result
sw
$
s1
,
4
(
$
s0
)
#
Set
'
done
'
$
done
:
jr
$
ra
nop
.
end
test
cannon/mipsevm/open_mips_tests/test/exit_group.asm
0 → 100644
View file @
68cf67fd
.
section
.
test
,
"x"
.
balign
4
.
set
noreorder
.
global
test
.
ent
test
test
:
li
$
a0
,
1
li
$
v0
,
4246
syscall
#
Unreachable
....
#
set
test
result
to
fail
.
#
Test
runner
should
short
-
circuit
before
reaching
this
point
.
li
$
v0
,
0
#
save
results
lui
$
s0
,
0xbfff
#
Load
the
base
address
0xbffffff0
ori
$
s0
,
0xfff0
ori
$
s1
,
$
0
,
1
#
Prepare
the
'
done
'
status
sw
$
v0
,
8
(
$
s0
)
#
Set
the
test
result
sw
$
s1
,
4
(
$
s0
)
#
Set
'
done
'
$
done
:
jr
$
ra
nop
.
end
test
cannon/mipsevm/open_mips_tests/test/fcntl.asm
0 → 100644
View file @
68cf67fd
.
section
.
test
,
"x"
.
balign
4
.
set
noreorder
.
global
test
.
ent
test
test
:
#
fnctl
(
0
,
3
)
li
$
v0
,
4055
li
$
a0
,
0x0
li
$
a1
,
0x3
syscall
sltiu
$
v0
,
$
v0
,
1
#
save
results
lui
$
s0
,
0xbfff
#
Load
the
base
address
0xbffffff0
ori
$
s0
,
0xfff0
ori
$
s1
,
$
0
,
1
#
Prepare
the
'
done
'
status
sw
$
v0
,
8
(
$
s0
)
#
Set
the
test
result
sw
$
s1
,
4
(
$
s0
)
#
Set
'
done
'
$
done
:
jr
$
ra
nop
.
end
test
cannon/mipsevm/open_mips_tests/test/mmap.asm
0 → 100644
View file @
68cf67fd
.
section
.
test
,
"x"
.
balign
4
.
set
noreorder
.
global
test
.
ent
test
test
:
li
$
v0
,
4090
lui
$
a0
,
0x3000
li
$
a1
,
4096
syscall
lui
$
t0
,
0x3000
subu
$
v0
,
$
v0
,
$
t0
sltiu
$
v0
,
$
v0
,
1
#
save
results
lui
$
s0
,
0xbfff
#
Load
the
base
address
0xbffffff0
ori
$
s0
,
0xfff0
ori
$
s1
,
$
0
,
1
#
Prepare
the
'
done
'
status
sw
$
v0
,
8
(
$
s0
)
#
Set
the
test
result
sw
$
s1
,
4
(
$
s0
)
#
Set
'
done
'
$
done
:
jr
$
ra
nop
.
end
test
cannon/mipsevm/state_test.go
View file @
68cf67fd
...
...
@@ -35,6 +35,9 @@ func TestState(t *testing.T) {
if
strings
.
HasPrefix
(
f
.
Name
(),
"oracle"
)
{
oracle
=
staticOracle
(
t
,
[]
byte
(
"hello world"
))
}
// Short-circuit early for exit_group.bin
exitGroup
:=
f
.
Name
()
==
"exit_group.bin"
// TODO: currently tests are compiled as flat binary objects
// We can use more standard tooling to compile them to ELF files and get remove maketests.py
fn
:=
path
.
Join
(
"open_mips_tests/test/bin"
,
f
.
Name
())
...
...
@@ -57,14 +60,24 @@ func TestState(t *testing.T) {
if
us
.
state
.
PC
==
endAddr
{
break
}
if
exitGroup
&&
us
.
state
.
Exited
{
break
}
_
,
err
:=
us
.
Step
(
false
)
require
.
NoError
(
t
,
err
)
}
require
.
Equal
(
t
,
uint32
(
endAddr
),
us
.
state
.
PC
,
"must reach end"
)
// inspect test result
done
,
result
:=
state
.
Memory
.
GetMemory
(
baseAddrEnd
+
4
),
state
.
Memory
.
GetMemory
(
baseAddrEnd
+
8
)
require
.
Equal
(
t
,
done
,
uint32
(
1
),
"must be done"
)
require
.
Equal
(
t
,
result
,
uint32
(
1
),
"must have success result"
)
if
exitGroup
{
require
.
NotEqual
(
t
,
uint32
(
endAddr
),
us
.
state
.
PC
,
"must not reach end"
)
require
.
True
(
t
,
us
.
state
.
Exited
,
"must set exited state"
)
require
.
Equal
(
t
,
uint8
(
1
),
us
.
state
.
ExitCode
,
"must exit with 1"
)
}
else
{
require
.
Equal
(
t
,
uint32
(
endAddr
),
us
.
state
.
PC
,
"must reach end"
)
done
,
result
:=
state
.
Memory
.
GetMemory
(
baseAddrEnd
+
4
),
state
.
Memory
.
GetMemory
(
baseAddrEnd
+
8
)
// inspect test result
require
.
Equal
(
t
,
done
,
uint32
(
1
),
"must be done"
)
require
.
Equal
(
t
,
result
,
uint32
(
1
),
"must have success result"
)
}
})
}
}
...
...
Write
Preview
Markdown
is supported
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