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
7405215b
Commit
7405215b
authored
Dec 24, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
0255bff1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
+13
-6
go/internal/xtracing/tracetest/example_test.go
go/internal/xtracing/tracetest/example_test.go
+13
-6
No files found.
go/internal/xtracing/tracetest/example_test.go
View file @
7405215b
...
...
@@ -61,6 +61,7 @@ func setupTracing(t *tracetest.T) *tracing.ProbeGroup {
t
.
RxEvent
(
eventHello
(
who
))
})
tracing
.
Unlock
()
// NOTE pg.Done must be invoked by caller when setup tracing is no longer needed.
return
pg
}
...
...
@@ -86,18 +87,24 @@ func routeEvent(event interface{}) (stream string) {
return
strings
.
ToLower
(
who
[
:
i
])
}
// setupTraceEvents sets up tracing and routing.
// it is used in the prologue of tests.
func
setupTraceEvents
(
t
*
tracetest
.
T
)
{
// setup tracing to deliver trace events to t.
pg
:=
setupTracing
(
t
)
t
.
Cleanup
(
pg
.
Done
)
// tell t to which stream an event should go.
t
.
SetEventRouter
(
routeEvent
)
}
// TestExample demonstrates how to use tracetest to verify concurrent system with 2 threads.
func
TestExample
(
t
*
testing
.
T
)
{
tracetest
.
Verify
(
t
,
tracetestExample
)
}
func
tracetestExample
(
t
*
tracetest
.
T
)
{
// setup tracing to deliver trace events to t.
pg
:=
setupTracing
(
t
)
defer
pg
.
Done
()
// tell tracetest to which stream an event should go.
t
.
SetEventRouter
(
routeEvent
)
// setup tracing to deliver trace events to t and route them appropriately.
setupTraceEvents
(
t
)
// run the workload
var
wg
sync
.
WaitGroup
...
...
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