enable memgrind

This commit is contained in:
Jan Mercl
2021-02-17 18:42:44 +01:00
parent 612508d1d3
commit 5ab7e771a8
5 changed files with 10 additions and 74 deletions

View File

@@ -110,8 +110,8 @@ var (
func TestMain(m *testing.M) {
fmt.Printf("test binary compiled for %s/%s\n", runtime.GOOS, runtime.GOARCH)
flag.Parse()
libc.MemAuditStart()
os.Exit(m.Run())
}
@@ -131,16 +131,11 @@ func tempDB(t testing.TB) (string, *sql.DB) {
}
func TestScalar(t *testing.T) {
libc.MemAuditStart()
dir, db := tempDB(t)
defer func() {
db.Close()
os.RemoveAll(dir)
if err := libc.MemAuditReport(); err != nil {
t.Error(err)
}
}()
t1 := time.Date(2017, 4, 20, 1, 2, 3, 56789, time.UTC)
@@ -204,15 +199,11 @@ func TestScalar(t *testing.T) {
}
func TestBlob(t *testing.T) {
libc.MemAuditStart()
dir, db := tempDB(t)
defer func() {
db.Close()
os.RemoveAll(dir)
if err := libc.MemAuditReport(); err != nil {
t.Error(err)
}
}()
b1 := []byte(time.Now().String())
@@ -260,7 +251,6 @@ func TestBlob(t *testing.T) {
}
func benchmarkInsertMemory(b *testing.B, n int) {
libc.MemAuditStart()
db, err := sql.Open(driverName, "file::memory:")
if err != nil {
b.Fatal(err)
@@ -268,9 +258,6 @@ func benchmarkInsertMemory(b *testing.B, n int) {
defer func() {
db.Close()
if err := libc.MemAuditReport(); err != nil {
b.Error(err)
}
}()
b.ReportAllocs()
@@ -315,7 +302,6 @@ func BenchmarkInsertMemory(b *testing.B) {
var staticInt int
func benchmarkNextMemory(b *testing.B, n int) {
libc.MemAuditStart()
db, err := sql.Open(driverName, "file::memory:")
if err != nil {
b.Fatal(err)
@@ -323,9 +309,6 @@ func benchmarkNextMemory(b *testing.B, n int) {
defer func() {
db.Close()
if err := libc.MemAuditReport(); err != nil {
b.Error(err)
}
}()
if _, err := db.Exec(`
@@ -387,16 +370,12 @@ func BenchmarkNextMemory(b *testing.B) {
// https://gitlab.com/cznic/sqlite/issues/11
func TestIssue11(t *testing.T) {
libc.MemAuditStart()
const N = 6570
dir, db := tempDB(t)
defer func() {
db.Close()
os.RemoveAll(dir)
if err := libc.MemAuditReport(); err != nil {
t.Error(err)
}
}()
if _, err := db.Exec(`
@@ -419,7 +398,6 @@ func TestIssue11(t *testing.T) {
// https://gitlab.com/cznic/sqlite/issues/12
func TestMemDB(t *testing.T) {
libc.MemAuditStart()
// Verify we can create out-of-the heap memory DB instance.
db, err := sql.Open(driverName, "file::memory:")
if err != nil {
@@ -428,9 +406,6 @@ func TestMemDB(t *testing.T) {
defer func() {
db.Close()
if err := libc.MemAuditReport(); err != nil {
t.Error(err)
}
}()
v := strings.Repeat("a", 1024)
@@ -458,7 +433,6 @@ func TestMemDB(t *testing.T) {
}
func TestConcurrentGoroutines(t *testing.T) {
libc.MemAuditStart()
const (
ngoroutines = 8
nrows = 5000
@@ -471,9 +445,6 @@ func TestConcurrentGoroutines(t *testing.T) {
defer func() {
os.RemoveAll(dir)
if err := libc.MemAuditReport(); err != nil {
t.Error(err)
}
}()
db, err := sql.Open(driverName, filepath.Join(dir, "test.db"))
@@ -570,7 +541,6 @@ func TestConcurrentGoroutines(t *testing.T) {
}
func TestConcurrentProcesses(t *testing.T) {
libc.MemAuditStart()
dir, err := ioutil.TempDir("", "sqlite-test-")
if err != nil {
t.Fatal(err)
@@ -578,9 +548,6 @@ func TestConcurrentProcesses(t *testing.T) {
defer func() {
os.RemoveAll(dir)
if err := libc.MemAuditReport(); err != nil {
t.Error(err)
}
}()
m, err := filepath.Glob(filepath.FromSlash("internal/mptest/*"))
@@ -668,7 +635,6 @@ outer:
// https://gitlab.com/cznic/sqlite/issues/19
func TestIssue19(t *testing.T) {
libc.MemAuditStart()
const (
drop = `
drop table if exists products;
@@ -702,9 +668,6 @@ INSERT INTO "products" ("id", "user_id", "name", "description", "created_at", "c
defer func() {
os.RemoveAll(dir)
if err := libc.MemAuditReport(); err != nil {
t.Error(err)
}
}()
wd, err := os.Getwd()
@@ -794,7 +757,6 @@ func mustExec(t *testing.T, db *sql.DB, sql string, args ...interface{}) sql.Res
// https://gitlab.com/cznic/sqlite/issues/20
func TestIssue20(t *testing.T) {
libc.MemAuditStart()
const TablePrefix = "gosqltest_"
tempDir, err := ioutil.TempDir("", "")
@@ -804,9 +766,6 @@ func TestIssue20(t *testing.T) {
defer func() {
os.RemoveAll(tempDir)
if err := libc.MemAuditReport(); err != nil {
t.Error(err)
}
}()
db, err := sql.Open("sqlite", filepath.Join(tempDir, "foo.db"))
@@ -860,7 +819,6 @@ func TestIssue20(t *testing.T) {
}
func TestNoRows(t *testing.T) {
libc.MemAuditStart()
tempDir, err := ioutil.TempDir("", "")
if err != nil {
t.Fatal(err)
@@ -877,9 +835,6 @@ func TestNoRows(t *testing.T) {
defer func() {
db.Close()
if err := libc.MemAuditReport(); err != nil {
t.Error(err)
}
}()
stmt, err := db.Prepare("create table t(i);")
@@ -896,7 +851,6 @@ func TestNoRows(t *testing.T) {
// https://gitlab.com/cznic/sqlite/-/issues/28
func TestIssue28(t *testing.T) {
libc.MemAuditStart()
tempDir, err := ioutil.TempDir("", "")
if err != nil {
t.Fatal(err)
@@ -904,9 +858,6 @@ func TestIssue28(t *testing.T) {
defer func() {
os.RemoveAll(tempDir)
if err := libc.MemAuditReport(); err != nil {
t.Error(err)
}
}()
db, err := sql.Open("sqlite", filepath.Join(tempDir, "test.db"))
@@ -929,7 +880,6 @@ func TestIssue28(t *testing.T) {
// https://gitlab.com/cznic/sqlite/-/issues/30
func TestIssue30(t *testing.T) {
libc.MemAuditStart()
tempDir, err := ioutil.TempDir("", "")
if err != nil {
t.Fatal(err)
@@ -937,9 +887,6 @@ func TestIssue30(t *testing.T) {
defer func() {
os.RemoveAll(tempDir)
if err := libc.MemAuditReport(); err != nil {
t.Error(err)
}
}()
db, err := sql.Open("sqlite", filepath.Join(tempDir, "test.db"))
@@ -999,7 +946,6 @@ Col 3: DatabaseTypeName "DATE", DecimalSize 0 0 false, Length 922337203685477580
// https://gitlab.com/cznic/sqlite/-/issues/35
func TestTime(t *testing.T) {
libc.MemAuditStart()
types := []string{
"DATE",
"DATETIME",
@@ -1018,9 +964,6 @@ func TestTime(t *testing.T) {
defer func() {
db.Close()
if err := libc.MemAuditReport(); err != nil {
t.Error(err)
}
}()
for _, typ := range types {