nesvoboda / socrates

A small testing framework for 42's philosophers
67 stars 3 forks source link

Potential death time parsing bug #9

Open cacharle opened 3 years ago

cacharle commented 3 years ago

I had this error once with philo_one:

DEATH TIMING

[2 MS] [3 MS] [2 MS] [2 MS] Traceback (most recent call last):
  File "./socrates.py", line 281, in <module>
    exit(socrates(args.path, args.philo))
  File "./socrates.py", line 242, in socrates
    test_program(f"{bin_path}/philo_one/philo_one")
  File "./socrates.py", line 157, in test_program
    if run_starvation_measures(binary) is False:
  File "./socrates.py", line 131, in run_starvation_measures
    measure_starvation_timing(binary, results)
  File "./socrates.py", line 108, in measure_starvation_timing
    death_time = int(last_line[:separator_index].strip("\0"))
ValueError: invalid literal for int() with base 10: 'dyld:'

When I run the test on my own I have the following output:

❯ ./philo_one 3 310 200 100 | cat -e
0 2 has taken fork$
0 2 has taken fork$
0 2 is eating$
2 3 has taken fork$
200 2 is sleeping$
200 3 has taken fork$
200 3 is eating$
200 1 has taken fork$
300 2 is thinking$
311 2 died$

I never had this error before.

nesvoboda commented 3 years ago

Thanks for the report! I Your program clearly works, as you've shown in the example. It has also worked the first 4 times in the error output. But it looks to me as if it probably ended with an error of some kind, hence the dyld: part.

What we can possibly do from our side to mitigate that is to check if the program has returned gracefully before parsing the output, what do you think?

cacharle commented 3 years ago

I think the non parsable output should be printed (or at least the few last lines) and have a clear message that it couldn't be parsed. Then continue the other tests.

nesvoboda commented 3 years ago

That makes a lot of sense!