Skip to content

Commit 99e78ac

Browse files
authored
Merge pull request #353 from LeaYeh/doc-valgrind
[DOC] Add shell commands how to test with valgrind
2 parents 790bee8 + 9efd48d commit 99e78ac

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ https://starchart.cc/LeaYeh/minishell
5656
* [Signal Handling](#signal-handling)
5757
* [Exception Handling](#exception-handling)
5858
* [Known Issue](#known-issue)
59+
* [How to test with Valgrind](#how-to-test-with-valgrind)
5960

6061
# Support Features
6162

@@ -602,6 +603,31 @@ Reference:
602603
- Our question in Stackoverflow
603604
- https://stackoverflow.com/questions/78140706/exception-handling-through-signal-communication-in-multiprocess-programs-in-c
604605

606+
# How to test with Valgrind
607+
608+
To test your minishell extensively with Valgrind, but without any reports from external commands, you can follow these steps:
609+
610+
1. Start bash
611+
```bash
612+
bash
613+
```
614+
2. If you have one, input the name of your suppression file to suppress leaks coming from readline
615+
```bash
616+
export SUPPRESSION_FILE=/path/to/your/suppression_file
617+
```
618+
3. Set up environment variables
619+
```bash
620+
export VALGRIND=$(which valgrind)
621+
export VALGRINDFLAGS="--errors-for-leak-kinds=all --leak-check=full --read-var-info=yes --show-error-list=yes --show-leak-kinds=all --suppressions=$SUPPRESSION_FILE --trace-children=yes --track-origins=yes"
622+
export VALGRINDFDFLAGS="--track-fds=all"
623+
export IGNORED_PATHS="/bin/* /usr/bin/* /usr/sbin/* $(which -a norminette)"
624+
export VALGRINDFLAGS+=" --trace-children-skip=$(echo $IGNORED_PATHS | sed 's/ /,/g')"
625+
```
626+
4. Run your minishell with valgrind
627+
```bash
628+
$VALGRIND $VALGRINDFLAGS $VALGRINDFDFLAGS ./minishell
629+
```
630+
605631
# Liked it?
606632

607633
Hope you liked this project, don't forget to give it a star ⭐.

0 commit comments

Comments
 (0)