This commit is contained in:
Frans Kaashoek 2025-02-02 10:50:29 -05:00
parent 6e5dbc5a47
commit 25a43f7a5e
4 changed files with 28 additions and 8 deletions

View File

@ -99,7 +99,7 @@ func (ts *Test) GenericTest() {
// requests and had time to checkpoint.
sz := ts.Config.Group(Gid).LogSize()
if sz > 8*ts.maxraftstate {
ts.Fatalf("logs were not trimmed (%v > 8*%v)", sz, ts.maxraftstate)
ts.t.Fatalf("logs were not trimmed (%v > 8*%v)", sz, ts.maxraftstate)
}
}
if ts.maxraftstate < 0 {

View File

@ -14,7 +14,7 @@ func TestBasic(t *testing.T) {
for i := 0; i < 10; i++ {
r := ts.one()
if r.N != i+1 {
ts.Fatalf("expected %d instead of %d", i, r.N)
ts.t.Fatalf("expected %d instead of %d", i, r.N)
}
ts.checkCounter(r.N, NSRV)
}

View File

@ -33,10 +33,10 @@ func TestStaticOneShardGroup5A(t *testing.T) {
// Read the initial configuration and check it
cfg, v, err := sck.Query()
if err != rpc.OK {
ts.Fatalf("Query failed %v", err)
ts.t.Fatalf("Query failed %v", err)
}
if v != 1 || cfg.Num != 1 || cfg.Shards[0] != shardcfg.Gid1 {
ts.Fatalf("Static wrong %v %v", cfg, v)
ts.t.Fatalf("Static wrong %v %v", cfg, v)
}
cfg.CheckConfig(t, []tester.Tgid{shardcfg.Gid1})

View File

@ -4,11 +4,12 @@ import (
crand "crypto/rand"
"encoding/base64"
"fmt"
// "log"
//"log"
"math/big"
"math/rand"
"runtime"
"runtime/debug"
// "runtime/debug"
"strings"
"sync"
"sync/atomic"
"testing"
@ -137,8 +138,27 @@ func (cfg *Config) End() {
}
func (cfg *Config) Fatalf(format string, args ...any) {
debug.PrintStack()
cfg.t.Fatalf(format, args...)
const maxStackLen = 50
fmt.Printf("Fatal: ")
fmt.Printf(format, args...)
fmt.Println("")
var pc [maxStackLen]uintptr
// Skip two extra frames to account for this function
// and runtime.Callers itself.
n := runtime.Callers(2, pc[:])
if n == 0 {
panic("testing: zero callers found")
}
frames := runtime.CallersFrames(pc[:n])
var frame runtime.Frame
for more := true; more; {
frame, more = frames.Next()
// Print only frames in our test files
if strings.Contains(frame.File, "test.go") {
fmt.Printf(" %v:%d\n", frame.File, frame.Line)
}
}
cfg.t.FailNow()
}
func Randstring(n int) string {