rexxnor fix for string to digit
authorChristian Grothoff <christian@grothoff.org>
Mon, 18 Feb 2019 09:17:45 +0000 (10:17 +0100)
committerChristian Grothoff <christian@grothoff.org>
Mon, 18 Feb 2019 09:17:45 +0000 (10:17 +0100)
src/integration-tests/gnunet_testing.py.in

index dcfc99e8d7ce6d66005610fc05ac4f97dd76e49d..5767a455ad0b780d1caeeae6b026a57d98825aae 100644 (file)
@@ -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