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
decaff6f
Commit
decaff6f
authored
Dec 23, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
f4d307b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
12 deletions
+22
-12
go/internal/xtracing/tracetest/tracetest.go
go/internal/xtracing/tracetest/tracetest.go
+22
-12
No files found.
go/internal/xtracing/tracetest/tracetest.go
View file @
decaff6f
...
...
@@ -490,13 +490,21 @@ type Streams interface {
type
T
struct
{
testing
.
TB
streamTabMu
sync
.
Mutex
streamTab
map
[
/*stream*/
string
]
Chan
// set to nil on test shutdown
routeEvent
func
(
event
interface
{})
(
stream
string
)
mu
sync
.
Mutex
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
nakq
[]
nak
// naks queued to be sent after Fatal
}
// eventTrace keeps information about one event T received via RxEvent.
type
eventTrace
struct
{
t
time
.
Time
// monotonic
stream
string
event
interface
{}
}
type
nak
struct
{
msg
*
Msg
why
string
...
...
@@ -510,8 +518,8 @@ func (t *T) queuenak(msg *Msg, why string) {
// XXX doc; naming
func
(
t
*
T
)
SetEventRouter
(
routeEvent
func
(
event
interface
{})
(
stream
string
))
{
t
.
streamTabM
u
.
Lock
()
defer
t
.
streamTabM
u
.
Unlock
()
t
.
m
u
.
Lock
()
defer
t
.
m
u
.
Unlock
()
if
t
.
routeEvent
!=
nil
{
panic
(
"double call to SetEventRouter"
)
...
...
@@ -521,13 +529,15 @@ func (t *T) SetEventRouter(routeEvent func(event interface{}) (stream string)) {
// XXX doc; naming
func
(
t
*
T
)
RxEvent
(
event
interface
{})
{
t0
:=
time
.
Now
()
stream
:=
"default"
t
.
streamTabM
u
.
Lock
()
t
.
m
u
.
Lock
()
if
t
.
routeEvent
!=
nil
{
stream
=
t
.
routeEvent
(
event
)
}
t
.
tracev
=
append
(
t
.
tracev
,
eventTrace
{
t0
,
stream
,
event
})
ch
:=
t
.
chanForStream
(
stream
)
t
.
streamTabM
u
.
Unlock
()
t
.
m
u
.
Unlock
()
if
ch
==
nil
{
t
.
fatalfInNonMain
(
"%s: (pre)send: canceled (test failed)"
,
stream
)
...
...
@@ -566,7 +576,7 @@ func (t *T) RxEvent(event interface{}) {
}
// chanForStream returns channel corresponding to stream.
// must be called under
streamTabM
u.
// must be called under
m
u.
func
(
t
*
T
)
chanForStream
(
stream
string
)
Chan
{
if
t
.
streamTab
==
nil
{
return
nil
// t is no longer operational after e.g. deadlock
...
...
@@ -623,9 +633,9 @@ func (t *T) expect1(stream string, eventExpect interface{}) *Msg {
func
(
t
*
T
)
xget1
(
stream
string
,
eventp
interface
{})
*
Msg
{
t
.
Helper
()
t
.
streamTabM
u
.
Lock
()
t
.
m
u
.
Lock
()
ch
:=
t
.
chanForStream
(
stream
)
t
.
streamTabM
u
.
Unlock
()
t
.
m
u
.
Unlock
()
// XXX ch == nil -> no longer operational
...
...
@@ -694,10 +704,10 @@ func (t *T) closeStreamTab() (nnak int) {
t
.
Helper
()
// mark streamTab no longer operational
t
.
streamTabM
u
.
Lock
()
t
.
m
u
.
Lock
()
streamTab
:=
t
.
streamTab
t
.
streamTab
=
nil
t
.
streamTabM
u
.
Unlock
()
t
.
m
u
.
Unlock
()
if
streamTab
==
nil
{
return
// already closed
...
...
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