Commit b74bca96 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 7405215b
...@@ -100,35 +100,34 @@ func setupTraceEvents(t *tracetest.T) { ...@@ -100,35 +100,34 @@ func setupTraceEvents(t *tracetest.T) {
// TestExample demonstrates how to use tracetest to verify concurrent system with 2 threads. // TestExample demonstrates how to use tracetest to verify concurrent system with 2 threads.
func TestExample(t *testing.T) { func TestExample(t *testing.T) {
tracetest.Verify(t, tracetestExample) tracetest.Verify(t, func(t *tracetest.T) {
} // setup tracing to deliver trace events to t and route them appropriately.
func tracetestExample(t *tracetest.T) { setupTraceEvents(t)
// setup tracing to deliver trace events to t and route them appropriately.
setupTraceEvents(t) // run the workload
var wg sync.WaitGroup
// run the workload defer wg.Wait()
var wg sync.WaitGroup wg.Add(2)
defer wg.Wait()
wg.Add(2) go func() { // thread1
defer wg.Done()
go func() { // thread1 hi("T1·A")
defer wg.Done() hello("T1·B")
hi("T1·A") }()
hello("T1·B")
}() go func() { // thread2
defer wg.Done()
go func() { // thread2 hi("T2·C")
defer wg.Done() }()
hi("T2·C")
}() // assert that events come as expected
t.Expect("t2", eventHi("T2·C"))
// assert that events come as expected t.Expect("t1", eventHi("T1·A"))
t.Expect("t2", eventHi("T2·C")) t.Expect("t1", eventHello("T1·B"))
t.Expect("t1", eventHi("T1·A"))
t.Expect("t1", eventHello("T1·B")) // XXX also t.Recv, t.ExpectNoAck ?
// XXX also t.Recv, t.ExpectNoAck ? //t1 := t.OnStream("t1")
//t1.Expect(eventHi("X·A"))
//t1 := t.OnStream("t1") })
//t1.Expect(eventHi("X·A"))
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment