nesvoboda / socrates

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

ValueError: invalid literal for int() with base 10 #1

Closed Shankhara closed 4 years ago

Shankhara commented 4 years ago

Hi, First, thanks for your work it's great help. My only concern is when socrates.py tests death timing. Do you know how to correct this line in socrates.py ? death_time = int(last_line[: last_line.find(" ")])

See here the last line :

 DEATH TIMING

Running ../..//philo_one/philo_one 3 310 200 100
ran ../..//philo_one/philo_one 3 310 200 100
Traceback (most recent call last):
  File "socrates.py", line 217, in <module>
    exit(socrates(bin_path))
  File "socrates.py", line 198, in socrates
    test_program(f"{bin_path}/philo_one/philo_one")
  File "socrates.py", line 140, in test_program
    if run_starvation_measures(binary) is False:
  File "socrates.py", line 119, in run_starvation_measures
    measure_starvation_timing(binary, results)
  File "socrates.py", line 95, in measure_starvation_timing
    death_time = int(last_line[: last_line.find(" ")])
ValueError: invalid literal for int() with base 10: '311\t1' 

Thx

nesvoboda commented 4 years ago

Dear @Shankhara,

Thank you for opening up an issue for this! Could you please send me the binary that has the problem, or its output for the test 4 310 200 100? You can produce one by doing something like this: ./philo_one 4 310 200 100 > out.txt

I hope that'll help us to fix the issue.

The meaning of the line in question is roughly this:

"Pick the last line from the beginning until the first space (' '), and run atoi on it"

This normally works if your last line is something like this:

00000313 3 died

Here, 00000310 will be cast to integer and then compared with 310 to see if the death timing was right.

nesvoboda commented 4 years ago

Fixed in 3405edf