mirror of
https://github.com/yuzu-emu/unicorn
synced 2024-11-24 18:58:31 +00:00
Merge pull request #241 from practicalswift/testcases
Add test cases for issues #236 (potential memory leak) and #237 (OS X crash)
This commit is contained in:
commit
01671683be
2 changed files with 49 additions and 0 deletions
20
tests/regress/osx_qemu_thread_create_crash.py
Executable file
20
tests/regress/osx_qemu_thread_create_crash.py
Executable file
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import platform
|
||||
import resource
|
||||
|
||||
from unicorn import *
|
||||
|
||||
import regress
|
||||
|
||||
# OS X: OK with 2047 iterations.
|
||||
# OS X: Crashes at 2048:th iteration ("qemu: qemu_thread_create: Resource temporarily unavailable").
|
||||
# Linux: No crashes observed.
|
||||
class ThreadCreateCrash(regress.RegressTest):
|
||||
def test(self):
|
||||
for i in xrange(2048):
|
||||
Uc(UC_ARCH_X86, UC_MODE_64)
|
||||
self.assertTrue(True, "If not reached, then we have a crashing bug.")
|
||||
|
||||
if __name__ == '__main__':
|
||||
regress.main()
|
29
tests/regress/potential_memory_leak.py
Executable file
29
tests/regress/potential_memory_leak.py
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import platform
|
||||
import resource
|
||||
|
||||
from unicorn import *
|
||||
|
||||
import regress
|
||||
|
||||
class MemoryLeak(regress.RegressTest):
|
||||
def test(self):
|
||||
if platform.system() == "Darwin":
|
||||
rusage_multiplier = 1
|
||||
elif platform.system() == "Linux":
|
||||
rusage_multiplier = 1024
|
||||
else:
|
||||
# resource.getrusage(...) is platform dependent. Only tested under OS X and Linux.
|
||||
return
|
||||
max_rss_before = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss * rusage_multiplier
|
||||
for i in xrange(10000):
|
||||
mu = Uc(UC_ARCH_X86, UC_MODE_64)
|
||||
mu.mem_map(0, 4096)
|
||||
mu.emu_start(0, 0)
|
||||
max_rss_after = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss * rusage_multiplier
|
||||
rss_increase_per_iteration = (max_rss_after - max_rss_before) / i
|
||||
self.assertLess(rss_increase_per_iteration, 8000)
|
||||
|
||||
if __name__ == '__main__':
|
||||
regress.main()
|
Loading…
Reference in a new issue