Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
3055a942
Commit
3055a942
authored
Dec 30, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
15d9be2f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
34 deletions
+32
-34
go/internal/xtracing/tracetest/tracetest.go
go/internal/xtracing/tracetest/tracetest.go
+29
-31
go/neo/neo_test.go
go/neo/neo_test.go
+3
-3
No files found.
go/internal/xtracing/tracetest/tracetest.go
View file @
3055a942
...
...
@@ -99,46 +99,44 @@ var (
deadTime
=
flag
.
Duration
(
"tracetest.deadtime"
,
3
*
time
.
Second
,
"time after which no events activity is considered to be a deadlock"
)
)
// XXX hide Chan from public API
// Chan provides synchronous channel with additional property that send
// _Chan provides synchronous channel with additional property that send
// blocks until receiving side explicitly acknowledges message was received and
// processed.
//
// New channels must be created via NewChan.
// New channels must be created via
_
NewChan.
//
// It is safe to use Chan from multiple goroutines simultaneously.
type
Chan
interface
{
ChanTx
ChanRx
// It is safe to use
_
Chan from multiple goroutines simultaneously.
type
_
Chan
interface
{
_
ChanTx
_
ChanRx
name
()
string
// name of the channel
}
//
ChanTx represents "send-only" half of
Chan.
//
_ChanTx represents "send-only" half of _
Chan.
// It is similar to chan<- .
type
ChanTx
interface
{
type
_
ChanTx
interface
{
// Send sends event to a consumer and waits for ack.
// if main testing goroutine detects any problem Send panics.
XXX
// if main testing goroutine detects any problem Send panics.
Send
(
event
interface
{})
// Close closes the sending side of the channel.
Close
()
}
//
ChanRx represents "receive-only" half of
Chan.
//
_ChanRx represents "receive-only" half of _
Chan.
// It is similar to <-chan .
type
ChanRx
interface
{
type
_
ChanRx
interface
{
// Recv receives message from a producer.
//
// The consumer, after dealing with the message, must send back an ack.
Recv
()
*
Msg
// _rxq returns raw channel that is serving ChanRx.
// it is used internally to use ChanRx in select.
// _rxq returns raw channel that is serving
_
ChanRx.
// it is used internally to use
_
ChanRx in select.
_rxq
()
<-
chan
*
Msg
}
// Msg represents message with 1 event sent over Chan.
// Msg represents message with 1 event sent over
_
Chan.
//
// The goroutine which sent the message will wait for Ack before continue.
type
Msg
struct
{
...
...
@@ -148,7 +146,7 @@ type Msg struct {
// _chan implements Chan.
// _chan implements
_
Chan.
type
_chan
struct
{
t
*
T
msgq
chan
*
Msg
...
...
@@ -156,12 +154,12 @@ type _chan struct {
_name
string
}
// name implements Chan.
// name implements
_
Chan.
func
(
ch
*
_chan
)
name
()
string
{
return
ch
.
_name
}
// Send implements ChanTx.
// Send implements
_
ChanTx.
func
(
ch
*
_chan
)
Send
(
event
interface
{})
{
if
*
chatty
{
fmt
.
Printf
(
"%s <- %T %v
\n
"
,
ch
.
name
(),
event
,
event
)
...
...
@@ -179,18 +177,18 @@ func (ch *_chan) Send(event interface{}) {
}
}
// Close implements ChanTx.
// Close implements
_
ChanTx.
func
(
ch
*
_chan
)
Close
()
{
close
(
ch
.
down
)
// note - not .msgq
}
// Recv implements ChanRx.
// Recv implements
_
ChanRx.
func
(
ch
*
_chan
)
Recv
()
*
Msg
{
msg
:=
<-
ch
.
msgq
return
msg
}
// _rxq implements ChanRx.
// _rxq implements
_
ChanRx.
func
(
ch
*
_chan
)
_rxq
()
<-
chan
*
Msg
{
return
ch
.
msgq
}
...
...
@@ -206,8 +204,8 @@ func (m *Msg) nak(why string) {
m
.
ack
<-
errors
.
New
(
why
)
}
//
NewChan creates new
Chan channel.
func
NewChan
(
name
string
)
Chan
{
//
_NewChan creates new _
Chan channel.
func
_NewChan
(
name
string
)
_
Chan
{
// XXX somehow avoid channels with duplicate names
// (only allow to create named channels from under dispatcher?)
return
&
_chan
{
msgq
:
make
(
chan
*
Msg
),
down
:
make
(
chan
struct
{}),
_name
:
name
}
...
...
@@ -496,7 +494,7 @@ type T struct {
_testing_TB
mu
sync
.
Mutex
streamTab
map
[
/*stream*/
string
]
Chan
// set to nil on test shutdown
streamTab
map
[
/*stream*/
string
]
_
Chan
// set to nil on test shutdown
routeEvent
func
(
event
interface
{})
(
stream
string
)
tracev
[]
eventTrace
// record of events as they happen
delayInjectTab
map
[
/*stream*/
string
]
*
delayInjectState
...
...
@@ -608,15 +606,15 @@ func (t *T) RxEvent(event interface{}) {
// chanForStream returns channel corresponding to stream.
// must be called under mu.
func
(
t
*
T
)
chanForStream
(
stream
string
)
Chan
{
func
(
t
*
T
)
chanForStream
(
stream
string
)
_
Chan
{
if
t
.
streamTab
==
nil
{
return
nil
// t is no longer operational after e.g. deadlock
}
ch
,
ok
:=
t
.
streamTab
[
stream
]
if
!
ok
{
ch
=
NewChan
(
stream
)
ch
.
(
*
_chan
)
.
t
=
t
// XXX move into NewChan
ch
=
_
NewChan
(
stream
)
ch
.
(
*
_chan
)
.
t
=
t
// XXX move into
_
NewChan
t
.
streamTab
[
stream
]
=
ch
}
return
ch
...
...
@@ -746,9 +744,9 @@ func (t *T) closeStreamTab() (nnak int) {
}
// print details about pending events and all streams
type
sendInfo
struct
{
ch
Chan
;
msg
*
Msg
}
type
sendInfo
struct
{
ch
_
Chan
;
msg
*
Msg
}
var
sendv
[]
sendInfo
// sends are pending here
var
quietv
[]
Chan
// this channels are quiet
var
quietv
[]
_Chan
// this channels are quiet
// order channels by name
var
streams
[]
string
...
...
@@ -817,7 +815,7 @@ func Verify(t *testing.T, f func(t *T)) {
testf
:=
func
(
t
testing
.
TB
,
delayInjectTab
map
[
string
]
*
delayInjectState
)
*
T
{
tT
:=
&
T
{
_testing_TB
:
t
,
streamTab
:
make
(
map
[
string
]
Chan
),
streamTab
:
make
(
map
[
string
]
_
Chan
),
delayInjectTab
:
delayInjectTab
,
}
...
...
go/neo/neo_test.go
View file @
3055a942
...
...
@@ -428,7 +428,7 @@ func benchmarkGetObject(b *testing.B, Mnet, Snet, Cnet xnet.Networker, benchit f
obj1
,
err
:=
zback
.
Load
(
ctx
,
xid1
)
if
err
!=
nil
{
b
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
buf1
,
serial1
:=
obj1
.
Data
,
obj1
.
Serial
...
...
@@ -436,11 +436,11 @@ func benchmarkGetObject(b *testing.B, Mnet, Snet, Cnet xnet.Networker, benchit f
xcload1
:=
func
()
{
cbuf1
,
cserial1
,
err
:=
C
.
Load
(
ctx
,
xid1
)
if
err
!=
nil
{
b
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
if
!
(
bytes
.
Equal
(
cbuf1
.
Data
,
buf1
.
Data
)
&&
cserial1
==
serial1
)
{
b
.
Fatalf
(
"C.Load first -> %q %v ; want %q %v"
,
cbuf1
.
Data
,
cserial1
,
buf1
.
Data
,
serial1
)
t
.
Fatalf
(
"C.Load first -> %q %v ; want %q %v"
,
cbuf1
.
Data
,
cserial1
,
buf1
.
Data
,
serial1
)
}
cbuf1
.
Release
()
...
...
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