-
Notifications
You must be signed in to change notification settings - Fork 0
/
buffer_t_array_test.go
577 lines (496 loc) · 17.6 KB
/
buffer_t_array_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
//////////////////////////////////////////////////////////////////
// //
// Copyright (c) 2018-2022 YottaDB LLC and/or its subsidiaries. //
// All rights reserved. //
// //
// This source code contains the intellectual property //
// of its copyright holder(s), and is made available //
// under a license. If you do not know the terms of //
// the license, please stop and do not read further. //
// //
//////////////////////////////////////////////////////////////////
package yottadb_test
import (
"bytes"
"fmt"
"github.com/stretchr/testify/assert"
"lang.yottadb.com/go/yottadb"
. "lang.yottadb.com/go/yottadb/internal/test_helpers"
"os"
"runtime"
"testing"
"time"
)
// TestBufTAryDeleteExclST tests the DeleteExclST() method.
func TestBufTAryDeleteExclST(t *testing.T) {
var namelst yottadb.BufferTArray
var tptoken uint64 = yottadb.NOTTP
var err error
var errcode int
namelst.Alloc(2, 10) // Need an array of two names not more than 10 bytes
defer namelst.Free()
// We need to create 4 local variables to test this so do that first (thus also testing KeyT.SetValE()
err = yottadb.SetValE(tptoken, nil, "I have a value", "var1", []string{"sub1", "sub2"})
Assertnoerr(err, t)
err = yottadb.SetValE(tptoken, nil, "I wish I was a value", "var2", []string{})
Assertnoerr(err, t)
err = yottadb.SetValE(tptoken, nil, "I was a value", "var3", []string{"sub1"})
Assertnoerr(err, t)
err = yottadb.SetValE(tptoken, nil, "I AM A VALUE", "var4", []string{})
Assertnoerr(err, t)
// Now delete var1 and var3 by exclusively keeping var2 and var 4
err = namelst.SetValStr(tptoken, nil, 0, "var2")
Assertnoerr(err, t)
err = namelst.SetValStr(tptoken, nil, 1, "var4")
Assertnoerr(err, t)
err = namelst.SetElemUsed(tptoken, nil, 2)
Assertnoerr(err, t)
err = namelst.DeleteExclST(tptoken, nil)
Assertnoerr(err, t)
// OK, delete done, see which vars exist
_, err = yottadb.ValE(tptoken, nil, "var1", []string{"sub1", "sub2"}) // Expect this var to be gone
if nil == err {
t.Errorf("var1 found when it should have been deleted (no error occurred when fetched")
}
errcode = yottadb.ErrorCode(err)
if yottadb.YDB_ERR_LVUNDEF != errcode {
t.Error("The ValE() errorcode for val3(\"sub1\",\"sub2\") expected to be", yottadb.YDB_ERR_LVUNDEF, "but was", errcode)
}
_, err = yottadb.ValE(tptoken, nil, "var2", []string{})
if nil != err {
t.Errorf("var2 not found when it should still exist (if ever existed)")
}
_, err = yottadb.ValE(tptoken, nil, "var3", []string{"sub1"})
if nil == err {
t.Errorf("var3 found when it should have been deleted (no error occurred when fetched")
}
errcode = yottadb.ErrorCode(err)
if yottadb.YDB_ERR_LVUNDEF != errcode {
t.Error("The ValE() errorcode for val3(\"sub1\") expected to be", yottadb.YDB_ERR_LVUNDEF, "but was", errcode)
}
_, err = yottadb.ValE(tptoken, nil, "var4", []string{})
if nil != err {
t.Errorf("var4 not found when it should still exist (if ever existed)")
}
// Delete with an empty list which should clear var2 and var4
namelst.SetElemUsed(tptoken, nil, 0)
Assertnoerr(err, t)
err = namelst.DeleteExclST(tptoken, nil)
Assertnoerr(err, t)
_, err = yottadb.ValE(tptoken, nil, "var2", []string{})
errcode = yottadb.ErrorCode(err)
if nil == err {
t.Errorf("var2 found when it should have been deleted (no error occurred when fetched")
}
errcode = yottadb.ErrorCode(err)
if yottadb.YDB_ERR_LVUNDEF != errcode {
t.Error("The ValE() errorcode for val2 expected to be", yottadb.YDB_ERR_LVUNDEF, "but was", errcode)
}
_, err = yottadb.ValE(tptoken, nil, "var4", []string{})
if nil == err {
t.Errorf("var4 found when it should have been deleted (no error occurred when fetched")
}
errcode = yottadb.ErrorCode(err)
if yottadb.YDB_ERR_LVUNDEF != errcode {
t.Error("The ValE() errorcode for val4 expected to be", yottadb.YDB_ERR_LVUNDEF, "but was", errcode)
}
}
func TestBufTAryDeleteExclSTErrors(t *testing.T) {
var namelst yottadb.BufferTArray
var tptoken uint64 = yottadb.NOTTP
var err error
var errcode int
defer namelst.Free()
namelst.Alloc(yottadb.YDB_MAX_NAMES+1, 64)
err = namelst.SetElemUsed(tptoken, nil, 1)
Assertnoerr(err, t)
// YDB_ERR_INVVARNAME - from passing a bad M name
err = namelst.SetValStr(tptoken, nil, 0, "1")
Assertnoerr(err, t)
err = namelst.DeleteExclST(tptoken, nil)
errcode = yottadb.ErrorCode(err)
if yottadb.YDB_ERR_INVVARNAME != errcode {
t.Error("The DeleteExclST() errorcode for 1 expected to be", yottadb.YDB_ERR_INVVARNAME, "but was", errcode)
}
// YDB_ERR_ISVUNSUPPORTED - from special variable
err = namelst.SetValStr(tptoken, nil, 0, "$ZCHSET")
Assertnoerr(err, t)
err = namelst.DeleteExclST(tptoken, nil)
errcode = yottadb.ErrorCode(err)
if yottadb.YDB_ERR_ISVUNSUPPORTED != errcode {
t.Error("The DeleteExclST() errorcode for $ZCHSET expected to be", yottadb.YDB_ERR_ISVUNSUPPORTED, "but was", errcode)
}
// YDB_ERR_GVNUNSUPPORTED - from passing a global
err = namelst.SetValStr(tptoken, nil, 0, "^a")
Assertnoerr(err, t)
err = namelst.DeleteExclST(tptoken, nil)
errcode = yottadb.ErrorCode(err)
if yottadb.YDB_ERR_GVNUNSUPPORTED != errcode {
t.Error("The DeleteExclST() errorcode for ^a expected to be", yottadb.YDB_ERR_GVNUNSUPPORTED, "but was", errcode)
}
// YDB_ERR_VARNAME2LONG
err = namelst.SetValStr(tptoken, nil, 0, "a1a2a3a4a5a6a7a8a9a0b1b2b3b4b5b6b7b8b9b0")
Assertnoerr(err, t)
err = namelst.DeleteExclST(tptoken, nil)
errcode = yottadb.ErrorCode(err)
if yottadb.YDB_ERR_VARNAME2LONG != errcode {
t.Error("The DeleteExclST() errorcode for a too long VarName expected to be", yottadb.YDB_ERR_VARNAME2LONG, "but was", errcode)
}
// YDB_ERR_NAMECOUNT2HI
for i := 0; i < yottadb.YDB_MAX_NAMES+1; i++ {
err = namelst.SetValStr(tptoken, nil, uint32(i), fmt.Sprintf("a%d", i))
Assertnoerr(err, t)
}
err = namelst.SetElemUsed(tptoken, nil, yottadb.YDB_MAX_NAMES+1)
Assertnoerr(err, t)
err = namelst.DeleteExclST(tptoken, nil)
errcode = yottadb.ErrorCode(err)
if yottadb.YDB_ERR_NAMECOUNT2HI != errcode {
t.Error("The DeleteExclST() errorcode for node with 32 subscripts expected to be", yottadb.YDB_ERR_NAMECOUNT2HI, "but was", errcode)
}
}
func TestBufTAryDump(t *testing.T) {
var value, noalloc_value yottadb.BufferTArray
var tp = yottadb.NOTTP
var buf1 bytes.Buffer
// Dump from a nil buffer
noalloc_value.DumpToWriter(&buf1)
defer value.Free()
value.Alloc(10, 64)
value.SetValStr(tp, nil, 0, "Hello")
value.SetElemUsed(tp, nil, 1)
value.DumpToWriter(&buf1)
// BufferTArray dump does not show any info about included buffers, so no asserts for
// that; it really only mentions used/available buffers
assert.Contains(t, buf1.String(), "10")
assert.Contains(t, buf1.String(), "Hello")
// Dump from a nil BufferTArray with an INVSTRLEN error
value.Alloc(1, 0)
value.SetValStr(tp, nil, 0, "Hello") // this should return an INVSTRLEN error
value.DumpToWriter(&buf1)
}
func TestBufTAryAlloc(t *testing.T) {
var value, noalloc_value yottadb.BufferTArray
// Try freeing a never Alloc'd buffer
value.Free()
// Try allocating a buffer then freeing it many times
value.Alloc(10, 64)
value.Free()
value.Free()
// Try allocing a size of
value.Alloc(0, 64)
// Try allocating a buffer multiple times without freeing
value.Alloc(10, 64)
value.Alloc(10, 64)
// Verify allocated size
r := value.ElemAlloc()
assert.Equal(t, r, uint32(10))
// Try getting ElemAlloc on non-alloced value
r = noalloc_value.ElemAlloc()
assert.Equal(t, r, uint32(0))
}
func TestBufTAryLenAlloc(t *testing.T) {
var value, noalloc_value yottadb.BufferTArray
// Try getting length of non-alloc'd array
r := value.ElemLenAlloc()
assert.Equal(t, r, uint32(0))
r = noalloc_value.ElemLenAlloc()
assert.Equal(t, r, uint32(0))
value.Alloc(10, 64)
r = value.ElemLenAlloc()
assert.Equal(t, r, uint32(64))
// Alloc a length of 0 and try to get it
value.Alloc(0, 64)
r = value.ElemLenAlloc()
assert.Equal(t, r, uint32(0))
}
func TestBufTAryBAry(t *testing.T) {
var value yottadb.BufferTArray
var tp = yottadb.NOTTP
var errcode int
v := []byte("Hello")
toolong := []byte("This byte array is too long")
// Get value from non-allocd value
r, err := value.ValBAry(tp, nil, 0)
errcode = yottadb.ErrorCode(err)
assert.Equal(t, yottadb.YDB_ERR_INSUFFSUBS, errcode)
assert.Nil(t, r)
// Alloc, but get value past the end
value.Alloc(10, 16)
r, err = value.ValBAry(tp, nil, 11)
errcode = yottadb.ErrorCode(err)
assert.Equal(t, yottadb.YDB_ERR_INSUFFSUBS, errcode)
assert.Nil(t, r)
// Get a valid value with no content
r, err = value.ValBAry(tp, nil, 0)
// Get a value with some value
err = value.SetValBAry(tp, nil, 1, v)
assert.Nil(t, err)
r, err = value.ValBAry(tp, nil, 1)
assert.Nil(t, err)
assert.Equal(t, r, v)
// Try set a value on out of bounds element
err = value.SetValBAry(tp, nil, 11, v)
errcode = yottadb.ErrorCode(err)
assert.Equal(t, yottadb.YDB_ERR_INSUFFSUBS, errcode)
// Try set a value longer than the buffer
err = value.SetValBAry(tp, nil, 2, toolong)
errcode = yottadb.ErrorCode(err)
assert.Equal(t, yottadb.YDB_ERR_INVSTRLEN, errcode)
l, err := value.ElemLenUsed(tp, nil, 2)
assert.Nil(t, err)
assert.Equal(t, l, uint32(0))
// Try to set a value on a freed structure
value.Free()
err = value.SetValBAry(tp, nil, 0, v)
errcode = yottadb.ErrorCode(err)
assert.Equal(t, yottadb.YDB_ERR_INSUFFSUBS, errcode)
}
func TestBufTAryElemLenUsed(t *testing.T) {
var value yottadb.BufferTArray
var tp = yottadb.NOTTP
var errcode int
// Test non alloc'd structure
err := value.SetElemLenUsed(tp, nil, 0, 0)
errcode = yottadb.ErrorCode(err)
assert.Equal(t, yottadb.YDB_ERR_INSUFFSUBS, errcode)
r, err := value.ElemLenUsed(tp, nil, 0)
errcode = yottadb.ErrorCode(err)
assert.Equal(t, yottadb.YDB_ERR_STRUCTUNALLOCD, errcode)
assert.Equal(t, r, uint32(0))
// Allocate, then test with an element past the end
value.Alloc(10, 64)
err = value.SetElemLenUsed(tp, nil, 11, 5)
errcode = yottadb.ErrorCode(err)
assert.Equal(t, yottadb.YDB_ERR_INSUFFSUBS, errcode)
r, err = value.ElemLenUsed(tp, nil, 11)
errcode = yottadb.ErrorCode(err)
assert.Equal(t, yottadb.YDB_ERR_INSUFFSUBS, errcode)
assert.Equal(t, r, uint32(0))
// Set a valid subscript to an invalid length
err = value.SetElemLenUsed(tp, nil, 0, 100)
errcode = yottadb.ErrorCode(err)
assert.Equal(t, yottadb.YDB_ERR_INVSTRLEN, errcode)
r, err = value.ElemLenUsed(tp, nil, 0)
assert.Nil(t, err)
assert.Equal(t, r, uint32(0))
// Get a valid length
err = value.SetElemLenUsed(tp, nil, 0, 50)
assert.Nil(t, err)
r, err = value.ElemLenUsed(tp, nil, 0)
assert.Nil(t, err)
assert.Equal(t, r, uint32(50))
}
func TestBufTAryValStr(t *testing.T) {
var value yottadb.BufferTArray
var tp = yottadb.NOTTP
var errcode int
// Test before Alloc
r, err := value.ValStr(tp, nil, 0)
errcode = yottadb.ErrorCode(err)
assert.Equal(t, yottadb.YDB_ERR_INSUFFSUBS, errcode)
assert.Equal(t, r, "")
value.Alloc(10, 16)
// Test after alloc, before setting value outside of range
r, err = value.ValStr(tp, nil, 11)
errcode = yottadb.ErrorCode(err)
assert.Equal(t, yottadb.YDB_ERR_INSUFFSUBS, errcode)
assert.Equal(t, r, "")
// Test after alloc, valid except not defined
r, err = value.ValStr(tp, nil, 0)
assert.Nil(t, err)
assert.NotNil(t, r)
assert.Equal(t, r, "")
// Set a value and check that it is defined
err = value.SetValStr(tp, nil, 1, "Hello")
assert.Nil(t, err)
r, err = value.ValStr(tp, nil, 1)
assert.Nil(t, err)
assert.Equal(t, r, "Hello")
// Try set a value on out of bounds element
err = value.SetValStr(tp, nil, 11, "Out of Bounds")
errcode = yottadb.ErrorCode(err)
assert.Equal(t, yottadb.YDB_ERR_INSUFFSUBS, errcode)
// Try set a value longer than the buffer
err = value.SetValStr(tp, nil, 2, "This string is too long")
errcode = yottadb.ErrorCode(err)
assert.Equal(t, yottadb.YDB_ERR_INVSTRLEN, errcode)
l, err := value.ElemLenUsed(tp, nil, 2)
assert.Nil(t, err)
assert.Equal(t, l, uint32(0))
// Try to set a value on a freed structure
value.Free()
err = value.SetValStr(tp, nil, 0, "Hello")
errcode = yottadb.ErrorCode(err)
assert.Equal(t, yottadb.YDB_ERR_INSUFFSUBS, errcode)
}
func TestBufTAryElemUsed(t *testing.T) {
var value yottadb.BufferTArray
var tp = yottadb.NOTTP
var errcode int
// Test before Alloc
r := value.ElemUsed()
assert.Equal(t, uint32(0), r)
// Test set
err := value.SetElemUsed(tp, nil, 0)
assert.Nil(t, err)
// Alloc, and test
value.Alloc(10, 50)
// Test that ElemUsed() is 0 after alloc
r = value.ElemUsed()
assert.Equal(t, uint32(0), r)
// Test that setting ElemUsed > Alloc'ed returns error
err = value.SetElemUsed(tp, nil, 100)
errcode = yottadb.ErrorCode(err)
assert.Equal(t, yottadb.YDB_ERR_INSUFFSUBS, errcode)
// Test that setting ElemUsed < Alloc'ed returns nil
err = value.SetElemUsed(tp, nil, 5)
assert.Nil(t, err)
// Test that ElemUsed is correct after set
r = value.ElemUsed()
assert.Equal(t, uint32(5), r)
// Ensure that we can set the elems used back to 0 after
// they had been set to a different value
err = value.SetElemUsed(tp, nil, 0)
assert.Nil(t, err)
r = value.ElemUsed()
assert.Equal(t, uint32(0), r)
}
func TestBufferTAryNilRecievers(t *testing.T) {
var value *yottadb.BufferTArray
var tp = yottadb.NOTTP
var safe = func() {
r := recover()
assert.NotNil(t, r)
}
var test_wrapper = func(f func()) {
defer safe()
f()
assert.Fail(t, "panic expected, but did not occur")
}
test_wrapper(func() { value.Alloc(10, 10) })
test_wrapper(func() { value.Dump() })
test_wrapper(func() { value.DumpToWriter(nil) })
//test_wrapper(func() { value.Free() }) // Free doesn't panic as a nil rec.
test_wrapper(func() { value.ElemAlloc() })
test_wrapper(func() { value.ElemLenAlloc() })
test_wrapper(func() { value.ElemLenUsed(tp, nil, 0) })
test_wrapper(func() { value.ElemUsed() })
test_wrapper(func() { value.ValBAry(tp, nil, 0) })
test_wrapper(func() { value.ValStr(tp, nil, 0) })
test_wrapper(func() { value.SetElemLenUsed(tp, nil, 0, 10) })
test_wrapper(func() { value.SetElemUsed(tp, nil, 32) })
test_wrapper(func() { value.SetValBAry(tp, nil, 0, nil) })
test_wrapper(func() { value.SetValStr(tp, nil, 0, "") })
test_wrapper(func() { value.SetValStr(tp, nil, 0, "ok") })
test_wrapper(func() { value.DeleteExclST(tp, nil) })
test_wrapper(func() { value.TpST(tp, nil, nil, "OK") })
}
func TestBufTAryTpSt(t *testing.T) {
var novars yottadb.BufferTArray
var namelst yottadb.BufferTArray
var tptoken uint64 = yottadb.NOTTP
var err error
var errors int
namelst.Alloc(2, 10) // Need an array of two names not more than 10 bytes
// Start with clean slate then drive TP transaction
Dbdeleteall(tptoken, nil, &errors, t)
err = novars.TpST(tptoken, nil, func(tp uint64, errstr *yottadb.BufferT) int32 {
return int32(TestTpRtn(tp, nil, nil))
}, "BATCH")
Assertnoerr(err, t)
// Fetch the two nodes to make sure they are there and have correct values
val1, err := yottadb.ValE(tptoken, nil, "^Variable1A", []string{"Index0", "Index1", "Index2"})
Assertnoerr(err, t)
if "The value of Variable1A" != val1 {
t.Logf("FAIL - The fetched value of ^Variable1A(\"Index0\",\"Index1\",\"Index2\") was not correct\n")
t.Logf(" Expected: 'The value of Variable1A', Received: '%s'\n", val1)
t.Fail()
}
val2, err := yottadb.ValE(tptoken, nil, "^Variable2B", []string{"Idx0", "Idx1"})
Assertnoerr(err, t)
if "The value of Variable2B" != val2 {
t.Logf("FAIL - The fetched value of ^Variable2B(\"Idx0\",\"Idx1\") was not correct\n")
t.Logf(" Expected: 'The value of Variable2B', Received: '%s'\n", val2)
t.Fail()
}
}
func TestBufTAryTpNest(t *testing.T) {
var tproutine func(uint64, *yottadb.BufferT) int32
nest_limit := 130
if os.Getenv("real_mach_type") == "armv7l" {
nest_limit = 20
}
nest := 0
tproutine = func(tptoken uint64, errstr *yottadb.BufferT) int32 {
if nest < nest_limit {
nest++
e := yottadb.TpE(tptoken, nil, tproutine, "BATCH", []string{})
if nil == e {
return 0
}
return int32(yottadb.ErrorCode(e))
}
return 0
}
e := tproutine(yottadb.NOTTP, nil)
// Only expect the ERR_TPTOODEEP if we went all the way down, which we don't on armv7l
if os.Getenv("real_mach_type") != "armv7l" {
assert.Equal(t, int32(yottadb.YDB_ERR_TPTOODEEP), e)
}
}
func TestBufferTArrayFree(t *testing.T) {
SkipTimedTests(t)
SkipMemIntensiveTests(t)
func() {
var mem_before, mem_after int
var allocation_size uint32 = 1024 * 1024 * 512
var buffer [1024 * 1024 * 512]byte
for i := uint32(0); i < allocation_size; i++ {
buffer[uint(i)] = byte(i)
}
// Note starting memory
mem_before = GetHeapUsage(t)
func() {
var buft yottadb.BufferTArray
defer buft.Free()
buft.Alloc(1, allocation_size)
tt := buffer[:]
err := buft.SetValBAry(yottadb.NOTTP, nil, 0, tt)
Assertnoerr(err, t)
}()
// Trigger a garbage collection
runtime.GC()
// Verify that the difference between start and end is much less than 500MB
mem_after = GetHeapUsage(t)
assert.InEpsilon(t, mem_before, mem_after, .2)
}()
}
func TestBufferTArrayFinalizerCleansCAlloc(t *testing.T) {
SkipTimedTests(t)
SkipMemIntensiveTests(t)
func() {
var mem_before, mem_after int
var allocation_size uint32 = 1024 * 1024 * 512
var buffer [1024 * 1024 * 512]byte
for i := uint32(0); i < allocation_size; i++ {
buffer[uint(i)] = byte(i)
}
// Note starting memory
mem_before = GetHeapUsage(t)
func() {
var buft yottadb.BufferTArray
buft.Alloc(1, allocation_size)
tt := buffer[:]
err := buft.SetValBAry(yottadb.NOTTP, nil, 0, tt)
Assertnoerr(err, t)
}()
// Trigger a garbage collection
runtime.GC()
// It may take a moment for the finalizer to run; sleep for a smidgen
time.Sleep(time.Millisecond * 100)
// Verify that the difference between start and end is much less than 500MB
mem_after = GetHeapUsage(t)
assert.InEpsilon(t, mem_before, mem_after, .2)
}()
}