Skip to content

Commit

Permalink
Fix: Memory API test to induce error through yaml
Browse files Browse the repository at this point in the history
Patch fixes memory API test to induce error through yaml and
handle the same in test

Signed-off-by: Harish <[email protected]>
  • Loading branch information
harish-24 committed Jan 22, 2020
1 parent d419044 commit 0b69f82
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
11 changes: 3 additions & 8 deletions memory/memory_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def copyutil(self, file_name):
def setUp(self):
smm = SoftwareManager()
self.memsize = int(self.params.get(
'memory_size', default=memory.meminfo.MemFree.m) * 1048576 * 0.5)
'memory_size', default=(memory.meminfo.MemFree.m * 0.5)) * 1048576)
self.induce_err = self.params.get('induce_err', default=0)

for package in ['gcc', 'make']:
Expand All @@ -54,20 +54,15 @@ def setUp(self):

build.make(self.teststmpdir)

def test(self):
def test_memapi(self):
os.chdir(self.teststmpdir)
proc = process.SubProcess('./memory_api %s %s' % (self.memsize, self.induce_err),
shell=True, allow_output_check='both')
proc.start()
while proc.poll() is None:
pass

ret = process.system('./memory_api %s 1' % self.memsize,
shell=True, ignore_status=True)
if ret == 255:
self.log.info("Error obtained as expected")

if proc.poll() != 0:
if proc.poll() not in [0, 255]:
self.fail("Unexpected application abort, check for possible issues")

def test_mremap(self):
Expand Down
8 changes: 6 additions & 2 deletions memory/memory_api.py.data/memory_api.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
setup:
memory_size: 10 # in MB
induce_err: 1
memory_size: 100 # in MB
error: !mux
wo_err:
induce_err: 0
with_err:
induce_err: 1

0 comments on commit 0b69f82

Please sign in to comment.