diff --git a/src/test/log_analyzer/log_analyzer.py b/src/test/log_analyzer/log_analyzer.py index 20bfdd2f74d8254435c2c7f405c7facca04a95d0..7cccf41b15f61b52d8192a025366a1dde71da548 100755 --- a/src/test/log_analyzer/log_analyzer.py +++ b/src/test/log_analyzer/log_analyzer.py @@ -69,48 +69,81 @@ def check_logfile_for_collision(logfile): :param logfile: :return: True if collision was found """ - with FileReadBackwards(logfile) as file: for line in file: if ("Collision!") in line: return True +def check_bot_stop(logfile): + + """ + Reads logfile from end to start and checks if last line contains the roboter stopping + :param logfile: + :return: True if roboter did stop was found + """ + with FileReadBackwards(logfile) as file: + for line in file: + if ("Bot did not move for 5 seconds!") in line: + return True + +def check_timestop(logfile): + + """ + Reads logfile from end to start and checks if last line contains the roboter stopping + :param logfile: + :return: True if roboter did stop was found + """ + with FileReadBackwards(logfile) as file: + for line in file: + if ("Simulation Timeout!") in line: + return True def get_log(log_dir, logname, config): """ Currently does conclusiveness checks - ToDo: Move these checks to separate function - ToDo: Distanz checken :param log_dir: location of log files :param logname: corresponds to the name of the testcase file :param config: config object where safety_distances are stored :return: currently nothing. """ - + logfiles = [f for f in glob.glob(log_dir + logname + "lm.log")] for l in logfiles: logging.debug("Matching logs %s", l) - location = l.find("ACT") - - if check_logfile_for_collision(l): - logging.info("Testcase %s: red", l[location: location + 5]) - logging.warning("Found collision for testcase %s", l[location:location + 5]) - break + locationanfang = l.find("log/")+4 + locationende = l.find(".uml") safety_distance = get_safety_distance(l) if not check_safety_distance(safety_distance, config): - logging.info("Testcase %s yellow", l[location:location + 5]) + logging.info("Testcase %s yellow", l[locationanfang:locationende]) + logging.warning("Wrong safety distance for testcase %s",l[locationanfang:locationende]) + break + + if check_logfile_for_collision(l): + logging.info("Testcase %s: red", l[locationanfang: locationende]) + logging.warning("Found collision for testcase %s", l[locationanfang:locationende]) + break + if not check_bot_stop(l) and not check_timestop(l): + logging.info("Testcase %s: yellow", l[locationanfang:locationende]) + logging.warning("Error Gazebo %s", l[locationanfang:locationende]) + else: # if we are here, we did there was no collision and safety_distance is within limits - if not check_distance(config,l): - logging.info("Testcase %s: red", l[location: location + 5]) - logging.warning("Found distance does not match! %s", l[location:location + 5]) - else: - logging.info("testcase %s: green", l[location: location + 5]) - + if check_timestop(l): + if not check_distance_timeout(config,l): + logging.info("Testcase %s: red", l[locationanfang:locationende]) + logging.warning("Roboter too close %s", l[locationanfang:locationende]) + else: + logging.info("testcase %s: green", l[locationanfang:locationende]) + else: + if not check_distance(config,l): + logging.info("Testcase %s: red", l[locationanfang:locationende]) + logging.warning("Distance does not match! %s", l[locationanfang:locationende]) + else: + logging.info("testcase %s: green", l[locationanfang:locationende]) def get_safety_distance(logfile): """ @@ -125,6 +158,17 @@ def get_safety_distance(logfile): if counter == 3: return line[29:] +def check_distance_timeout(config, logfile): + counter = 0 + with FileReadBackwards(logfile) as file: + for line in file: + counter += 1 + if counter == 2: + distance = line[67:] + if Decimal(distance)<=Decimal(config['rangeLeftBorder']): + return False + else: + return True def check_distance(config, logfile): counter = 0 @@ -132,7 +176,7 @@ def check_distance(config, logfile): for line in file: counter += 1 if counter == 2: - distance = line[50:] + distance = line[67:] if Decimal(distance)<=Decimal(config['rangeLeftBorder']) or Decimal(distance)>=Decimal(config['rangeRightBorder']): return False else: @@ -163,8 +207,9 @@ def main(): for testcase in testcases: config = get_config(testcase) - location = testcase.find("ACT") - get_log(args.l, testcase[location:location + 8] + "0_", config) + locationanfang = testcase.find("faelle")+7 + locationende = testcase.find(".uml")+4 + get_log(args.l, testcase[locationanfang:locationende] + "0_", config) logging.debug("got config for %s", testcase)