Commit ae125f96 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 99931c46
......@@ -530,7 +530,7 @@ func (t *T) RxEvent(event interface{}) {
t.streamTabMu.Unlock()
if ch == nil {
t.fatalfInNonMain("%s: send: canceled (test failed)", stream)
t.fatalfInNonMain("%s: (pre)send: canceled (test failed)", stream)
}
// TODO it is possible to empirically detect here if a test incorrectly
......@@ -652,68 +652,6 @@ func (t *T) xget1(stream string, eventp interface{}) *Msg {
return msg
}
/*
// deadlock reports diagnostic when retrieving event from stream times out.
//
// Timing out on recv means there is a deadlock either if no event was sent at
// all, or some other event was sent to another channel/checker.
//
// Report the full picture - what was expected and what was sent where.
func (t *T) deadlock(stream string, eventp interface{}) {
t.Helper()
// mark streamTab no longer operational XXX ok?
t.streamTabMu.Lock()
streamTab := t.streamTab
t.streamTab = nil
t.streamTabMu.Unlock()
bad := fmt.Sprintf("%s: deadlock waiting for %T\n", stream, eventp)
type sendInfo struct{ch Chan; msg *Msg}
var sendv []sendInfo
for _, ch := range streamTab {
// check whether someone is sending on a dst without blocking.
// if yes - report to sender there is a problem - so it can cancel its task.
select {
case msg := <-ch._rxq():
sendv = append(sendv, sendInfo{ch, msg})
default:
}
// XXX panic triggering disabled because if sender panics we have no chance to continue
// TODO retest this
// in any case close channel where future Sends may arrive so that will panic too.
//close(dst.msgq)
}
// order channels by name
sort.Slice(sendv, func(i, j int) bool {
return strings.Compare(sendv[i].ch.name(), sendv[j].ch.name()) < 0
})
if len(sendv) == 0 {
bad += fmt.Sprintf("noone is sending\n")
} else {
bad += fmt.Sprintf("there are %d pending sender(s) on other channel(s):\n", len(sendv))
for _, __ := range sendv {
bad += fmt.Sprintf("%s:\t%T %v\n", __.ch.name(), __.msg.Event, __.msg.Event)
}
}
// log the deadlock details and nak all senders.
// nak them only after deadlock printout, so that the deadlock text
// comes first, and their "panics" don't get intermixed with it.
t.Log(bad)
for _, __ := range sendv {
__.msg.nak("deadlock")
}
t.FailNow()
}
*/
// fatalfInNonMain should be called for fatal cases in non-main goroutines instead of panic.
//
// we don't panic because it will stop the process and prevent the main
......@@ -815,9 +753,9 @@ func (t *T) Fatalf(format string, argv ...interface{}) {
// - main func to run the system
// - testf (serial) func to verify events that comes from channels
// Verify verifies a system.
// Verify verifies a test system.
// XXX
func Verify(t testing.TB, testf func(t *T)) {
func Verify(t testing.TB, f func(t *T)) {
tT := &T{TB: t, streamTab: make(map[string]Chan)}
// XXX
......@@ -829,7 +767,7 @@ func Verify(t testing.TB, testf func(t *T)) {
}()
*/
testf(tT)
f(tT)
// XXX in the end: verify that streams are the same from run to run (if completed successfully).
......
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