From: Wook Song Date: Wed, 13 Mar 2019 06:33:29 +0000 (+0900) Subject: [Test/Transform/Arithmetic] Update checkResult script to support integer X-Git-Tag: v0.1.2~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=30f764ab2ccf228316db4ac72fe9d59a63ca0689;p=platform%2Fupstream%2Fnnstreamer.git [Test/Transform/Arithmetic] Update checkResult script to support integer Since the python script for checking unit test results has only supported values of floating-point type until now, this patch updates the script to support integer so that more test cases using integer values could be added. Signed-off-by: Wook Song --- diff --git a/tests/transform_arithmetic/checkResult.py b/tests/transform_arithmetic/checkResult.py index d381e4f..cab20a0 100644 --- a/tests/transform_arithmetic/checkResult.py +++ b/tests/transform_arithmetic/checkResult.py @@ -14,6 +14,17 @@ import sys import struct ## +# @brief Get value of proper type corresponding to the unpack format string +# +def getValue (val, unpack_format): + if unpack_format in ['b', 'B', 'h', 'H', 'i', 'I', 'q', 'Q']: + return int(val) + elif unpack_format in ['f', 'd']: + return float(val) + else: + return None + +## # @brief Check typecast from typea to typeb with file fna/fnb # def testArithmetic (fna, fnb, typeasize, typebsize,typeapack, typebpack, mode, value1, value2): @@ -27,23 +38,28 @@ def testArithmetic (fna, fnb, typeasize, typebsize,typeapack, typebpack, mode, v return 11 limitb = 2 ** (8 * typebsize) maskb = limitb - 1 + value1 = getValue(value1, typeapack) + value2 = getValue(value2, typebpack) + if value1 is None or value2 is None: + return 12 + for x in range(0, num): vala = struct.unpack(typeapack, fna[x * typeasize: x * typeasize + typeasize])[0] valb = struct.unpack(typebpack, fnb[x * typebsize: x * typebsize + typebsize])[0] if (mode == 'add'): - diff = vala + float(value1) - valb + diff = vala + value1 - valb if diff > 0.01 or diff < -0.01: return 20 elif (mode == 'mul'): - diff = vala * float(value1) - valb + diff = vala * value1 - valb if diff > 0.01 or diff < -0.01: return 20 elif (mode == 'add-mul'): - diff = (vala + float(value1)) * float(value2) - valb + diff = (vala + value1) * value2 - valb if diff > 0.01 or diff < -0.01: return 20 elif (mode == 'mul-add'): - diff = (vala * float(value1)) + float(value2) - valb + diff = (vala * value1) + value2 - valb if diff > 0.01 or diff < -0.01: return 20 else: