mirror of
https://github.com/golang/go
synced 2024-11-22 00:54:43 -07:00
testing: shorten some tests.
These are the top runners. More to come. Also print two digits of timing info under -test.v. R=rsc CC=golang-dev https://golang.org/cl/4317044
This commit is contained in:
parent
4cb660aad8
commit
f0cf7d296c
@ -178,7 +178,11 @@ func TestBasicOperations(t *testing.T) {
|
||||
|
||||
func TestLargeStringWrites(t *testing.T) {
|
||||
var buf Buffer
|
||||
for i := 3; i < 30; i += 3 {
|
||||
limit := 30
|
||||
if testing.Short() {
|
||||
limit = 9
|
||||
}
|
||||
for i := 3; i < limit; i += 3 {
|
||||
s := fillString(t, "TestLargeWrites (1)", &buf, "", 5, data)
|
||||
empty(t, "TestLargeStringWrites (2)", &buf, s, make([]byte, len(data)/i))
|
||||
}
|
||||
@ -188,7 +192,11 @@ func TestLargeStringWrites(t *testing.T) {
|
||||
|
||||
func TestLargeByteWrites(t *testing.T) {
|
||||
var buf Buffer
|
||||
for i := 3; i < 30; i += 3 {
|
||||
limit := 30
|
||||
if testing.Short() {
|
||||
limit = 9
|
||||
}
|
||||
for i := 3; i < limit; i += 3 {
|
||||
s := fillBytes(t, "TestLargeWrites (1)", &buf, "", 5, bytes)
|
||||
empty(t, "TestLargeByteWrites (2)", &buf, s, make([]byte, len(data)/i))
|
||||
}
|
||||
|
@ -201,7 +201,10 @@ func TestIndexByte(t *testing.T) {
|
||||
|
||||
// test a larger buffer with different sizes and alignments
|
||||
func TestIndexByteBig(t *testing.T) {
|
||||
const n = 1024
|
||||
var n = 1024
|
||||
if testing.Short() {
|
||||
n = 128
|
||||
}
|
||||
b := make([]byte, n)
|
||||
for i := 0; i < n; i++ {
|
||||
// different start alignments
|
||||
|
@ -90,5 +90,8 @@ func TestParse(t *testing.T) {
|
||||
if !bytes.Equal(out, expected) {
|
||||
t.Errorf("%d: output got: %x want: %x", i, out, expected)
|
||||
}
|
||||
if testing.Short() {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,11 @@ import (
|
||||
)
|
||||
|
||||
func TestRead(t *testing.T) {
|
||||
b := make([]byte, 4e6)
|
||||
var n int = 4e6
|
||||
if testing.Short() {
|
||||
n = 1e5
|
||||
}
|
||||
b := make([]byte, n)
|
||||
n, err := Read(b)
|
||||
if n != len(b) || err != nil {
|
||||
t.Fatalf("Read(buf) = %d, %s", n, err)
|
||||
|
@ -97,7 +97,11 @@ func TestEncryptPKCS1v15(t *testing.T) {
|
||||
return true
|
||||
}
|
||||
|
||||
quick.Check(tryEncryptDecrypt, nil)
|
||||
config := new(quick.Config)
|
||||
if testing.Short() {
|
||||
config.MaxCount = 10
|
||||
}
|
||||
quick.Check(tryEncryptDecrypt, config)
|
||||
}
|
||||
|
||||
// These test vectors were generated with `openssl rsautl -pkcs -encrypt`
|
||||
|
@ -15,7 +15,11 @@ import (
|
||||
func TestKeyGeneration(t *testing.T) {
|
||||
random := rand.Reader
|
||||
|
||||
priv, err := GenerateKey(random, 1024)
|
||||
size := 1024
|
||||
if testing.Short() {
|
||||
size = 128
|
||||
}
|
||||
priv, err := GenerateKey(random, size)
|
||||
if err != nil {
|
||||
t.Errorf("failed to generate key")
|
||||
}
|
||||
@ -99,6 +103,9 @@ func TestDecryptOAEP(t *testing.T) {
|
||||
t.Errorf("#%d,%d (blind) bad result: %#v (want %#v)", i, j, out, message.in)
|
||||
}
|
||||
}
|
||||
if testing.Short() {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,11 @@ func TestSortStrings(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSortLarge_Random(t *testing.T) {
|
||||
data := make([]int, 1000000)
|
||||
n := 1000000
|
||||
if testing.Short() {
|
||||
n /= 100
|
||||
}
|
||||
data := make([]int, n)
|
||||
for i := 0; i < len(data); i++ {
|
||||
data[i] = rand.Intn(100)
|
||||
}
|
||||
@ -174,6 +178,9 @@ func lg(n int) int {
|
||||
|
||||
func TestBentleyMcIlroy(t *testing.T) {
|
||||
sizes := []int{100, 1023, 1024, 1025}
|
||||
if testing.Short() {
|
||||
sizes = []int{100, 127, 128, 129}
|
||||
}
|
||||
dists := []string{"sawtooth", "rand", "stagger", "plateau", "shuffle"}
|
||||
modes := []string{"copy", "reverse", "reverse1", "reverse2", "sort", "dither"}
|
||||
var tmp1, tmp2 [1025]int
|
||||
|
@ -617,7 +617,11 @@ func equal(m string, s1, s2 string, t *testing.T) bool {
|
||||
|
||||
func TestCaseConsistency(t *testing.T) {
|
||||
// Make a string of all the runes.
|
||||
a := make([]int, unicode.MaxRune+1)
|
||||
numRunes := unicode.MaxRune + 1
|
||||
if testing.Short() {
|
||||
numRunes = 1000
|
||||
}
|
||||
a := make([]int, numRunes)
|
||||
for i := range a {
|
||||
a[i] = i
|
||||
}
|
||||
@ -627,10 +631,10 @@ func TestCaseConsistency(t *testing.T) {
|
||||
lower := ToLower(s)
|
||||
|
||||
// Consistency checks
|
||||
if n := utf8.RuneCountInString(upper); n != unicode.MaxRune+1 {
|
||||
if n := utf8.RuneCountInString(upper); n != numRunes {
|
||||
t.Error("rune count wrong in upper:", n)
|
||||
}
|
||||
if n := utf8.RuneCountInString(lower); n != unicode.MaxRune+1 {
|
||||
if n := utf8.RuneCountInString(lower); n != numRunes {
|
||||
t.Error("rune count wrong in lower:", n)
|
||||
}
|
||||
if !equal("ToUpper(upper)", ToUpper(upper), upper, t) {
|
||||
|
@ -370,10 +370,11 @@ func hammerCompareAndSwapUintptr32(uval *uint32, count int) {
|
||||
}
|
||||
|
||||
func TestHammer32(t *testing.T) {
|
||||
const (
|
||||
n = 100000
|
||||
p = 4
|
||||
)
|
||||
const p = 4
|
||||
n := 100000
|
||||
if testing.Short() {
|
||||
n = 1000
|
||||
}
|
||||
defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(p))
|
||||
|
||||
for _, tt := range hammer32 {
|
||||
@ -391,7 +392,7 @@ func TestHammer32(t *testing.T) {
|
||||
for i := 0; i < p; i++ {
|
||||
<-c
|
||||
}
|
||||
if val != n*p {
|
||||
if val != uint32(n)*p {
|
||||
t.Errorf("%s: val=%d want %d", tt.name, val, n*p)
|
||||
}
|
||||
}
|
||||
@ -478,10 +479,11 @@ func hammerCompareAndSwapUintptr64(uval *uint64, count int) {
|
||||
}
|
||||
|
||||
func TestHammer64(t *testing.T) {
|
||||
const (
|
||||
n = 100000
|
||||
p = 4
|
||||
)
|
||||
const p = 4
|
||||
n := 100000
|
||||
if testing.Short() {
|
||||
n = 1000
|
||||
}
|
||||
defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(p))
|
||||
|
||||
for _, tt := range hammer64 {
|
||||
@ -499,7 +501,7 @@ func TestHammer64(t *testing.T) {
|
||||
for i := 0; i < p; i++ {
|
||||
<-c
|
||||
}
|
||||
if val != n*p {
|
||||
if val != uint64(n)*p {
|
||||
t.Errorf("%s: val=%d want %d", tt.name, val, n*p)
|
||||
}
|
||||
}
|
||||
|
@ -102,16 +102,20 @@ func HammerRWMutex(gomaxprocs, numReaders, num_iterations int) {
|
||||
}
|
||||
|
||||
func TestRWMutex(t *testing.T) {
|
||||
HammerRWMutex(1, 1, 1000)
|
||||
HammerRWMutex(1, 3, 1000)
|
||||
HammerRWMutex(1, 10, 1000)
|
||||
HammerRWMutex(4, 1, 1000)
|
||||
HammerRWMutex(4, 3, 1000)
|
||||
HammerRWMutex(4, 10, 1000)
|
||||
HammerRWMutex(10, 1, 1000)
|
||||
HammerRWMutex(10, 3, 1000)
|
||||
HammerRWMutex(10, 10, 1000)
|
||||
HammerRWMutex(10, 5, 10000)
|
||||
n := 1000
|
||||
if testing.Short() {
|
||||
n = 5
|
||||
}
|
||||
HammerRWMutex(1, 1, n)
|
||||
HammerRWMutex(1, 3, n)
|
||||
HammerRWMutex(1, 10, n)
|
||||
HammerRWMutex(4, 1, n)
|
||||
HammerRWMutex(4, 3, n)
|
||||
HammerRWMutex(4, 10, n)
|
||||
HammerRWMutex(10, 1, n)
|
||||
HammerRWMutex(10, 3, n)
|
||||
HammerRWMutex(10, 10, n)
|
||||
HammerRWMutex(10, 5, n)
|
||||
}
|
||||
|
||||
func TestRLocker(t *testing.T) {
|
||||
|
@ -186,7 +186,7 @@ func RunTests(matchString func(pat, str string) (bool, os.Error), tests []Intern
|
||||
go tRunner(t, &tests[i])
|
||||
<-t.ch
|
||||
ns += time.Nanoseconds()
|
||||
tstr := fmt.Sprintf("(%.1f seconds)", float64(ns)/1e9)
|
||||
tstr := fmt.Sprintf("(%.2f seconds)", float64(ns)/1e9)
|
||||
if t.failed {
|
||||
println("--- FAIL:", tests[i].Name, tstr)
|
||||
print(t.errors)
|
||||
|
Loading…
Reference in New Issue
Block a user