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
bba3b56d
Commit
bba3b56d
authored
Jan 03, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
a9f156f4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
27 deletions
+36
-27
go/internal/xtracing/tracetest/tracetest.go
go/internal/xtracing/tracetest/tracetest.go
+36
-27
No files found.
go/internal/xtracing/tracetest/tracetest.go
View file @
bba3b56d
...
...
@@ -268,6 +268,13 @@ func (t *T) SetEventRouter(routeEvent func(event interface{}) (stream string)) {
t
.
routeEvent
=
routeEvent
}
// t.RxEvent should be synchronously called from test system when an event
// occurs.
//
// The sequential process of the test system where event originated should be
// paused until RxEvent returns. This requirement can be easily met via ... XXX
//
//
// XXX doc; naming
// XXX NewEvent? IncomingEvent? OnEvent?
// XXX pass events in not via t (via something dedicated)?
...
...
@@ -299,32 +306,6 @@ func (t *T) RxEvent(event interface{}) {
t
.
fatalfInNonMain
(
"%s: (pre)send: canceled (test failed)"
,
stream
)
}
// TODO it is possible to empirically detect here if a test incorrectly
// decomposed its system into serial streams: consider unrelated to each
// other events A and B are incorrectly routed to the same channel. It
// could be so happening that the order of checks on the test side is
// almost always correct and so the error is not visible. However
//
// if we add delays to delivery of either A or B
// and test both combinations
//
// we will for sure detect the error as, if A and B are indeed
// unrelated, one of the delay combination will result in events
// delivered to test in different to what it expects order.
//
// the time for delay could be taken as follows:
//
// - run the test without delay; collect δt between events on particular stream
// - take delay = max(δt)·10
//
// to make sure there is indeed no different orderings possible on the
// stream, rerun the test N(event-on-stream) times, and during i'th run
// delay i'th event.
//
// TODO See also on this topic:
// http://www.1024cores.net/home/relacy-race-detector
// http://www.1024cores.net/home/relacy-race-detector/rrd-introduction
if
delay
!=
0
{
time
.
Sleep
(
delay
)
}
...
...
@@ -564,10 +545,38 @@ func run(t testing.TB, f func(t *T), delayInjectTab map[string]*delayInjectState
// unexpected events. f is rerun several times and should not alter its
// behaviour from run to run.
func
Verify
(
t
*
testing
.
T
,
f
func
(
t
*
T
))
{
// run f once. This produces initial trace of events.
tT0
:=
run
(
t
,
f
,
nil
)
// now, if f succeeds, verify f with injected delays.
// XXX explain with more text
//
// We inject delays to empirically detect race conditions and if a test
// incorrectly decomposed its system into serial streams: consider
// unrelated to each other events A and B are incorrectly routed to the
// same channel. It could be so happening that the order of checks on
// the test side is almost always correct and so the error is not
// visible. However
//
// if we add delays to delivery of either A or B
// and test both combinations
//
// we will for sure detect the error as, if A and B are indeed
// unrelated, one of the delay combination will result in events
// delivered to test in different to what it expects order.
//
// the time for delay could be taken as follows:
//
// - run the test without delay; collect δt between events on particular stream
// - take delay = max(δt)·10
//
// to make sure there is indeed no different orderings possible on the
// stream, rerun the test N(event-on-stream) times, and during i'th run
// delay i'th event.
//
// See also on this topic:
// http://www.1024cores.net/home/relacy-race-detector
// http://www.1024cores.net/home/relacy-race-detector/rrd-introduction
if
tT0
.
Failed
()
{
return
}
...
...
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