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
ecfe1afe
Unverified
Commit
ecfe1afe
authored
Apr 19, 2023
by
protolambda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mipsevm: fix go mips test running
parent
1ff08514
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
8 deletions
+16
-8
state_test.go
mipsevm/state_test.go
+16
-8
No files found.
mipsevm/state_test.go
View file @
ecfe1afe
...
@@ -12,8 +12,9 @@ import (
...
@@ -12,8 +12,9 @@ import (
uc
"github.com/unicorn-engine/unicorn/bindings/go/unicorn"
uc
"github.com/unicorn-engine/unicorn/bindings/go/unicorn"
)
)
// baseAddr is used in tests to write the results to
// baseAddrStart - baseAddrEnd is used in tests to write the results to
const
baseAddr
=
0xbffffff0
const
baseAddrEnd
=
0xbf
_ff_ff_f0
const
baseAddrStart
=
0xbf
_c0_00_00
// endAddr is used as return-address for tests
// endAddr is used as return-address for tests
const
endAddr
=
0xa7ef00d0
const
endAddr
=
0xa7ef00d0
...
@@ -24,6 +25,9 @@ func TestState(t *testing.T) {
...
@@ -24,6 +25,9 @@ func TestState(t *testing.T) {
for
_
,
f
:=
range
testFiles
{
for
_
,
f
:=
range
testFiles
{
t
.
Run
(
f
.
Name
(),
func
(
t
*
testing
.
T
)
{
t
.
Run
(
f
.
Name
(),
func
(
t
*
testing
.
T
)
{
if
f
.
Name
()
==
"oracle.bin"
{
t
.
Skip
(
"oracle test needs to be updated to use syscall pre-image oracle"
)
}
// TODO: currently tests are compiled as flat binary objects
// 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
// We can use more standard tooling to compile them to ELF files and get remove maketests.py
fn
:=
path
.
Join
(
"test/bin"
,
f
.
Name
())
fn
:=
path
.
Join
(
"test/bin"
,
f
.
Name
())
...
@@ -39,15 +43,19 @@ func TestState(t *testing.T) {
...
@@ -39,15 +43,19 @@ func TestState(t *testing.T) {
// set the return address ($ra) to jump into when test completes
// set the return address ($ra) to jump into when test completes
state
.
Registers
[
31
]
=
endAddr
state
.
Registers
[
31
]
=
endAddr
err
=
state
.
SetMemoryRange
(
baseAddr
&^
pageAddrMask
,
bytes
.
NewReader
(
make
([]
byte
,
pageSize
)))
//
err = state.SetMemoryRange(baseAddr&^pageAddrMask, bytes.NewReader(make([]byte, pageSize)))
require
.
NoError
(
t
,
err
,
"must allocate page for the result data"
)
//
require.NoError(t, err, "must allocate page for the result data")
//
err
=
state
.
SetMemoryRange
(
endAddr
&^
pageAddrMask
,
bytes
.
NewReader
(
make
([]
byte
,
pageSize
)))
//
err = state.SetMemoryRange(endAddr&^pageAddrMask, bytes.NewReader(make([]byte, pageSize)))
require
.
NoError
(
t
,
err
,
"must allocate page to return to"
)
//
require.NoError(t, err, "must allocate page to return to")
mu
,
err
:=
NewUnicorn
()
mu
,
err
:=
NewUnicorn
()
require
.
NoError
(
t
,
err
,
"load unicorn"
)
require
.
NoError
(
t
,
err
,
"load unicorn"
)
defer
mu
.
Close
()
defer
mu
.
Close
()
require
.
NoError
(
t
,
mu
.
MemMap
(
baseAddrStart
,
((
baseAddrEnd
-
baseAddrStart
)
&^
pageAddrMask
)
+
pageSize
))
require
.
NoError
(
t
,
mu
.
MemMap
(
endAddr
&^
pageAddrMask
,
pageSize
))
err
=
LoadUnicorn
(
state
,
mu
)
err
=
LoadUnicorn
(
state
,
mu
)
require
.
NoError
(
t
,
err
,
"load state into unicorn"
)
require
.
NoError
(
t
,
err
,
"load state into unicorn"
)
err
=
HookUnicorn
(
state
,
mu
,
os
.
Stdout
,
os
.
Stderr
)
err
=
HookUnicorn
(
state
,
mu
,
os
.
Stdout
,
os
.
Stderr
)
...
@@ -64,7 +72,7 @@ func TestState(t *testing.T) {
...
@@ -64,7 +72,7 @@ func TestState(t *testing.T) {
err
=
RunUnicorn
(
mu
,
state
.
PC
,
1000
)
err
=
RunUnicorn
(
mu
,
state
.
PC
,
1000
)
require
.
NoError
(
t
,
err
,
"must run steps without error"
)
require
.
NoError
(
t
,
err
,
"must run steps without error"
)
// inspect test result
// inspect test result
done
,
result
:=
state
.
GetMemory
(
baseAddr
+
4
),
state
.
GetMemory
(
baseAddr
+
8
)
done
,
result
:=
state
.
GetMemory
(
baseAddr
End
+
4
),
state
.
GetMemory
(
baseAddrEnd
+
8
)
require
.
Equal
(
t
,
done
,
uint32
(
1
),
"must be done"
)
require
.
Equal
(
t
,
done
,
uint32
(
1
),
"must be done"
)
require
.
Equal
(
t
,
result
,
uint32
(
1
),
"must have success result"
)
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