From: Christian Grothoff Date: Mon, 18 Feb 2019 09:17:45 +0000 (+0100) Subject: rexxnor fix for string to digit X-Git-Tag: v0.11.0~63^2~32^2~33 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=0ca5d7e2a0d80732fcab9422281da7b80964da6b;p=oweals%2Fgnunet.git rexxnor fix for string to digit --- diff --git a/src/integration-tests/gnunet_testing.py.in b/src/integration-tests/gnunet_testing.py.in index dcfc99e8d..5767a455a 100644 --- a/src/integration-tests/gnunet_testing.py.in +++ b/src/integration-tests/gnunet_testing.py.in @@ -176,7 +176,7 @@ class StatisticsCondition(Condition): def check(self): if (self.fulfilled == False): self.result = self.peer.get_statistics_value(self.subsystem, self.name) - if (str(self.result) == str(self.value)): + if (self.result == str(self.value)): self.fulfilled = True return True else: @@ -185,10 +185,6 @@ class StatisticsCondition(Condition): return True def evaluate(self, failed_only): - if (self.result == -1): - res = b'NaN' - else: - res = str(self.result).encode('utf-8') if (self.fulfilled == False): fail = b" FAIL!" op = b" != " @@ -210,7 +206,7 @@ class StatisticsCondition(Condition): # op + # res + # fail) - logger.debug('%s %s %s condition in subsystem %s : %s : (expected/real value) %s %s %s %s', self.peer.id[:4], self.peer.cfg.encode('utf-8'), str(self.type).encode('utf-8'), self.subsystem.encode('utf-8').ljust(12), self.name.encode('utf-8').ljust(30), str(self.value).encode('utf-8'), op, res, fail) + logger.debug('%s %s %s condition in subsystem %s : %s : (expected/real value) %s %s %s %s', self.peer.id[:4], self.peer.cfg.encode('utf-8'), str(self.type).encode('utf-8'), self.subsystem.encode('utf-8').ljust(12), self.name.encode('utf-8').ljust(30), str(self.value).encode('utf-8'), op, self.result, fail) return self.fulfilled @@ -232,7 +228,7 @@ class EqualStatisticsCondition(Condition): if (self.fulfilled == False): self.result = self.peer.get_statistics_value(self.subsystem, self.name) self.result2 = self.peer2.get_statistics_value(self.subsystem2, self.name2) - if (str(self.result) == str(self.result2)): + if (self.result == self.result2): self.fulfilled = True return True else: @@ -244,11 +240,11 @@ class EqualStatisticsCondition(Condition): if (self.result == -1): res = b'NaN' else: - res = str(self.result).encode('utf-8') + res = self.result if (self.result2 == -1): res2 = b'NaN' else: - res2 = str(self.result2).encode('utf-8') + res2 = self.result2 if (self.fulfilled == False): fail = b" FAIL!" op = b" != " @@ -262,7 +258,7 @@ class EqualStatisticsCondition(Condition): # b'" "' + # self.name.encode('utf-8').ljust(30) + # b'" == ' + - # str(self.result).encode('utf-8') + + # self.result + # b" " + # self.peer2.id[:4] + # b' "' + @@ -270,8 +266,8 @@ class EqualStatisticsCondition(Condition): # b'" ' + # self.name2.encode('utf-8').ljust(30) + # b'" ' + - # str(self.result2).encode('utf-8')) - logger.debug('%s %s %s == %s %s %s %s %s', self.peer.id[:4], self.subsystem.encode('utf-8').ljust(12), self.name.encode('utf-8').ljust(30), str(self.result).encode('utf-8'), self.peer2.id[:4], self.subsystem2.encode('uft-8').ljust(12), self.name2.encode('utf-8').ljust(30), str(self.result2).encode('utf-8')) + # self.result2) + logger.debug('%s %s %s == %s %s %s %s %s', self.peer.id[:4], self.subsystem.encode('utf-8').ljust(12), self.name.encode('utf-8').ljust(30), self.result, self.peer2.id[:4], self.subsystem2.encode('uft-8').ljust(12), self.name2.encode('utf-8').ljust(30), self.result2) return self.fulfilled @@ -380,10 +376,11 @@ class Peer(object): tests = (tests[0][:-1], tests[1], tests[2]) tests = tests[0] # print("running gnunet-statistics " + self.cfg + " for " + name + "/" + subsystem + " yields " + tests.decode("utf-8")) - logger.debug('running gnunet-statistics %s for %s "/" %s yields %s', self.cfg, name, subsystem, test.decode("utf-8")) - if (tests.isdigit() == True): - return tests + logger.debug('running gnunet-statistics %s for %s "/" %s yields %s', self.cfg, name, subsystem, test.decode("utf-8")) + result = tests.decode("utf-8").strip() + if (result.isdigit() == True): + return result else: # print("Invalid statistics value: " + str(tests) + " is not a number!") - logger.debug('Invalid statistics value: %s is not a number!', str(tests)) + logger.debug('Invalid statistics value: %s is not a number!', result) return -1