make system tests run properly
This commit is contained in:
jcosborn 2018-08-01 03:57:35 -05:00 • committed by Andreas Rumpf
commit 8f4c5a8955
7 changed files with 62 additions and 31 deletions

View file

@ -436,8 +436,9 @@ proc requestOsChunks(a: var MemRegion, size: int): PBigChunk =
a.nextChunkSize = PageSize*4 a.nextChunkSize = PageSize*4
else: else:
a.nextChunkSize = min(roundup(usedMem shr 2, PageSize), a.nextChunkSize * 2) a.nextChunkSize = min(roundup(usedMem shr 2, PageSize), a.nextChunkSize * 2)
var size = size a.nextChunkSize = min(a.nextChunkSize, MaxBigChunkSize)
var size = size
if size > a.nextChunkSize: if size > a.nextChunkSize:
result = cast[PBigChunk](osAllocPages(size)) result = cast[PBigChunk](osAllocPages(size))
else: else:

18
tests/system/t7894.nim Normal file
View file

@ -0,0 +1,18 @@
discard """
"""
import os
const size = 250000000
var saved = newSeq[seq[int8]]()
for i in 0..22:
# one of these is 0.25GB.
#echo i
var x = newSeq[int8](size)
sleep(10)
saved.add(x)
for x in saved:
#echo x.len
doAssert x.len == size

View file

@ -1,54 +1,57 @@
discard """
"""
var x: ptr int var x: ptr int
x = cast[ptr int](alloc(7)) x = cast[ptr int](alloc(7))
assert x != nil doAssert x != nil
x = cast[ptr int](x.realloc(2)) x = cast[ptr int](x.realloc(2))
assert x != nil doAssert x != nil
x.dealloc() x.dealloc()
x = createU(int, 3) x = createU(int, 3)
assert x != nil doAssert x != nil
x.dealloc() x.dealloc()
x = create(int, 4) x = create(int, 4)
assert cast[ptr array[4, int]](x)[0] == 0 doAssert cast[ptr array[4, int]](x)[0] == 0
assert cast[ptr array[4, int]](x)[1] == 0 doAssert cast[ptr array[4, int]](x)[1] == 0
assert cast[ptr array[4, int]](x)[2] == 0 doAssert cast[ptr array[4, int]](x)[2] == 0
assert cast[ptr array[4, int]](x)[3] == 0 doAssert cast[ptr array[4, int]](x)[3] == 0
x = x.resize(4) x = x.resize(4)
assert x != nil doAssert x != nil
x.dealloc() x.dealloc()
x = cast[ptr int](allocShared(100)) x = cast[ptr int](allocShared(100))
assert x != nil doAssert x != nil
deallocShared(x) deallocShared(x)
x = createSharedU(int, 3) x = createSharedU(int, 3)
assert x != nil doAssert x != nil
x.deallocShared() x.deallocShared()
x = createShared(int, 3) x = createShared(int, 3)
assert x != nil doAssert x != nil
assert cast[ptr array[3, int]](x)[0] == 0 doAssert cast[ptr array[3, int]](x)[0] == 0
assert cast[ptr array[3, int]](x)[1] == 0 doAssert cast[ptr array[3, int]](x)[1] == 0
assert cast[ptr array[3, int]](x)[2] == 0 doAssert cast[ptr array[3, int]](x)[2] == 0
assert x != nil doAssert x != nil
x = cast[ptr int](x.resizeShared(2)) x = cast[ptr int](x.resizeShared(2))
assert x != nil doAssert x != nil
x.deallocShared() x.deallocShared()
x = create(int, 10) x = create(int, 10)
assert x != nil doAssert x != nil
x = x.resize(12) x = x.resize(12)
assert x != nil doAssert x != nil
x.dealloc() x.dealloc()
x = createShared(int, 1) x = createShared(int, 1)
assert x != nil doAssert x != nil
x = x.resizeShared(1) x = x.resizeShared(1)
assert x != nil doAssert x != nil
x.deallocShared() x.deallocShared()
x = cast[ptr int](alloc0(125 shl 23)) x = cast[ptr int](alloc0(125 shl 23))

View file

@ -1,3 +1,6 @@
discard """
"""
const const
nmax = 2*1024*1024*1024 nmax = 2*1024*1024*1024

View file

@ -65,7 +65,7 @@ proc main() =
for val in table.values(): for val in table.values():
if myObj2.isNil: if myObj2.isNil:
myObj2 = val myObj2 = val
assert(myObj == myObj2) # passes doAssert(myObj == myObj2) # passes
var tableCopy: ListTableRef[int, SomeObj] var tableCopy: ListTableRef[int, SomeObj]
deepCopy(tableCopy, table) deepCopy(tableCopy, table)
@ -80,7 +80,7 @@ proc main() =
#echo cast[int](myObjCopy) #echo cast[int](myObjCopy)
#echo cast[int](myObjCopy2) #echo cast[int](myObjCopy2)
assert(myObjCopy == myObjCopy2) # fails doAssert(myObjCopy == myObjCopy2) # fails
type type
@ -88,7 +88,7 @@ type
counter, max: int counter, max: int
data: array[0..99, (pointer, pointer)] data: array[0..99, (pointer, pointer)]
assert(sizeof(PtrTable) == 2*sizeof(int)+sizeof(pointer)*2*100) doAssert(sizeof(PtrTable) == 2*sizeof(int)+sizeof(pointer)*2*100)
main() main()
echo "ok" echo "ok"

View file

@ -1,3 +1,6 @@
discard """
"""
import import
unittest, osproc, streams, os, strformat unittest, osproc, streams, os, strformat
const STRING_DATA = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." const STRING_DATA = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."

View file

@ -1,3 +1,6 @@
discard """
"""
import os import os
import osproc import osproc
import parseopt2 import parseopt2
@ -7,12 +10,12 @@ let argv = commandLineParams()
if argv == @[]: if argv == @[]:
# this won't work with spaces # this won't work with spaces
assert execShellCmd(getAppFilename() & " \"foo bar\" --aa:bar=a --a=c:d --ab -c --a[baz]:doo") == 0 doAssert execShellCmd(getAppFilename() & " \"foo bar\" --aa:bar=a --a=c:d --ab -c --a[baz]:doo") == 0
else: else:
let f = toSeq(getopt()) let f = toSeq(getopt())
echo f.repr echo f.repr
assert f[0].kind == cmdArgument and f[0].key == "foo bar" and f[0].val == "" doAssert f[0].kind == cmdArgument and f[0].key == "foo bar" and f[0].val == ""
assert f[1].kind == cmdLongOption and f[1].key == "aa" and f[1].val == "bar=a" doAssert f[1].kind == cmdLongOption and f[1].key == "aa" and f[1].val == "bar=a"
assert f[2].kind == cmdLongOption and f[2].key == "a=c" and f[2].val == "d" doAssert f[2].kind == cmdLongOption and f[2].key == "a=c" and f[2].val == "d"
assert f[3].kind == cmdLongOption and f[3].key == "ab" and f[3].val == "" doAssert f[3].kind == cmdLongOption and f[3].key == "ab" and f[3].val == ""
assert f[4].kind == cmdShortOption and f[4].key == "c" and f[4].val == "" doAssert f[4].kind == cmdShortOption and f[4].key == "c" and f[4].val == ""