make system tests run properly
This commit is contained in:
jcosborn
2018-08-01 03:57:35 -05:00
committed by Andreas Rumpf
parent 9e37e3e5e8
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
else:
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:
result = cast[PBigChunk](osAllocPages(size))
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
x = cast[ptr int](alloc(7))
assert x != nil
doAssert x != nil
x = cast[ptr int](x.realloc(2))
assert x != nil
doAssert x != nil
x.dealloc()
x = createU(int, 3)
assert x != nil
doAssert x != nil
x.dealloc()
x = create(int, 4)
assert cast[ptr array[4, int]](x)[0] == 0
assert cast[ptr array[4, int]](x)[1] == 0
assert cast[ptr array[4, int]](x)[2] == 0
assert cast[ptr array[4, int]](x)[3] == 0
doAssert cast[ptr array[4, int]](x)[0] == 0
doAssert cast[ptr array[4, int]](x)[1] == 0
doAssert cast[ptr array[4, int]](x)[2] == 0
doAssert cast[ptr array[4, int]](x)[3] == 0
x = x.resize(4)
assert x != nil
doAssert x != nil
x.dealloc()
x = cast[ptr int](allocShared(100))
assert x != nil
doAssert x != nil
deallocShared(x)
x = createSharedU(int, 3)
assert x != nil
doAssert x != nil
x.deallocShared()
x = createShared(int, 3)
assert x != nil
assert cast[ptr array[3, int]](x)[0] == 0
assert cast[ptr array[3, int]](x)[1] == 0
assert cast[ptr array[3, int]](x)[2] == 0
doAssert x != nil
doAssert cast[ptr array[3, int]](x)[0] == 0
doAssert cast[ptr array[3, int]](x)[1] == 0
doAssert cast[ptr array[3, int]](x)[2] == 0
assert x != nil
doAssert x != nil
x = cast[ptr int](x.resizeShared(2))
assert x != nil
doAssert x != nil
x.deallocShared()
x = create(int, 10)
assert x != nil
doAssert x != nil
x = x.resize(12)
assert x != nil
doAssert x != nil
x.dealloc()
x = createShared(int, 1)
assert x != nil
doAssert x != nil
x = x.resizeShared(1)
assert x != nil
doAssert x != nil
x.deallocShared()
x = cast[ptr int](alloc0(125 shl 23))

View File

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

View File

@@ -65,7 +65,7 @@ proc main() =
for val in table.values():
if myObj2.isNil:
myObj2 = val
assert(myObj == myObj2) # passes
doAssert(myObj == myObj2) # passes
var tableCopy: ListTableRef[int, SomeObj]
deepCopy(tableCopy, table)
@@ -80,7 +80,7 @@ proc main() =
#echo cast[int](myObjCopy)
#echo cast[int](myObjCopy2)
assert(myObjCopy == myObjCopy2) # fails
doAssert(myObjCopy == myObjCopy2) # fails
type
@@ -88,7 +88,7 @@ type
counter, max: int
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()
echo "ok"

View File

@@ -1,3 +1,6 @@
discard """
"""
import
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."
@@ -36,7 +39,7 @@ proc verifyFileSize(sz: int64) =
discard execProcess(&"dd if=/dev/zero of={fn} bs=1000000 count={size_in_mb}")
doAssert os.getFileSize(fn) == sz # Verify OS filesize by string
var f = open(fn)
doAssert f.getFileSize() == sz # Verify file handle filesize
f.close()

View File

@@ -1,3 +1,6 @@
discard """
"""
import os
import osproc
import parseopt2
@@ -7,12 +10,12 @@ let argv = commandLineParams()
if argv == @[]:
# 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:
let f = toSeq(getopt())
echo f.repr
assert 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"
assert 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 == ""
assert f[4].kind == cmdShortOption and f[4].key == "c" and f[4].val == ""
doAssert f[0].kind == cmdArgument and f[0].key == "foo bar" and f[0].val == ""
doAssert f[1].kind == cmdLongOption and f[1].key == "aa" and f[1].val == "bar=a"
doAssert f[2].kind == cmdLongOption and f[2].key == "a=c" and f[2].val == "d"
doAssert f[3].kind == cmdLongOption and f[3].key == "ab" and f[3].val == ""
doAssert f[4].kind == cmdShortOption and f[4].key == "c" and f[4].val == ""