bastienkody / pipex_tester

Ecole 42 tests
9 stars 0 forks source link

Test 2 : valgrind ./pipex Makefile yes head outf #1

Closed cdrik6 closed 6 months ago

cdrik6 commented 6 months ago

Dear Bastien, i would like to check something, in your script for this test you do : first_proc=$(cat vlg.txt | grep -m1 -A 1 "HEAP SUMMARY" | ... second_proc=$(cat vlg.txt | grep -m2 -A 1 "HEAP SUMMARY" | .. main_proc=$(cat vlg.txt | grep -m3 -A 1 "HEAP SUMMARY" | .. Are you sure of the order?

When i run valgrind on my side, the report does not follow that order, and would have scripted sthg like that second_proc=$(cat vlg.txt | grep -m1 -A 1 "HEAP SUMMARY" | .. first_proc=$(cat vlg.txt | grep -m2 -A 1 "HEAP SUMMARY" | ... main_proc=$(cat vlg.txt | grep -m3 -A 1 "HEAP SUMMARY" | .. But i am really not sure such i am so lost in that project, and by the way your tester is a GREAT source of thoughts to work on pipex - thank you very much !

bastienkody commented 6 months ago

Hi! Thanks for the kind words! This tester sum up all problems I went through during pipex implementation. I hope it can help you getting around all the tricky part of the project, which is a good basis for the bigger one Minishell. Humm I am not sure about your concern on valgrind tests. It seems logic that the first command should be the first launched by your program and so the first analyzed by valgrind, however I don't always perfectly understand how valgrind works. Do you find issues on all valgrind tests, or just on a specific one? In the case of "yes | head" I think yes must be terminated first by a sigpipe sent from head when it has read 10 lines ; let me check again tomorrow at 42. Good luck on implementing pipex !

cdrik6 commented 6 months ago

Only for this Test2 as this is the only one with a non-avoid leak due to 'yes'. Actually the order of "HEAP SUMMARY" is different each time, i just got now second main first

so i think it is not sufficient to search "HEAP SUMMARY", but the number before "HEAP SUMMARY" and check if that is the process number of the main / first or second. Example: At start we have ==2767465== Command: ./pipex Makefile yes head outf ==2767468== Command: /usr/bin/yes ==2767469== Command: /usr/bin/head ... ==2767469== HEAP SUMMARY: --> so I guess HEAP for the head cmd ==2767465== HEAP SUMMARY: --> so I guess HEAP for the main ==2767468== HEAP SUMMARY: --> so I guess HEAP for the yes cmd

It is what i understand, it is not the true :) And i do not really know how to script that...

cdrik6 commented 6 months ago

You can find me on discord with the pseudo and so on at school to talk IRL.

bastienkody commented 6 months ago

I just tested it several times with my own pipex. I always have from valgrind: yes, head and main process in that specific order. However if the leaks are ONLY generated by yes command, whatever the order of valgrind, I guess its okay !

cdrik6 commented 6 months ago

Ok thanks, so it must be due to a problem in my messy code, and I guess it may come from the waitpid function.