-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e390586
commit 4637fd1
Showing
53 changed files
with
301 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,95 @@ | ||
#! /bin/bash | ||
|
||
make_diff () | ||
prepare_function() | ||
{ | ||
diff "$2" "$3" > diffs/ft_"$FUNCT"."$1".txt | ||
DIFF=$(diff a b) | ||
if [ "$DIFF" != "" ] | ||
if [ "$FUNCT" = "read" ] | ||
then | ||
echo -e "\033[0;31m[KO]\033[0m" | ||
else | ||
echo -e "\033[0;32m[OK]\033[0m" | ||
rm -f diffs/ft_"$FUNCT"."$1".txt | ||
echo "testing read function" > read.txt | ||
echo "testing read function" > ft_read.txt | ||
fi | ||
} | ||
|
||
test_std() | ||
check_error() | ||
{ | ||
if [ "$FUNCT" == "read" ] | ||
if [ "$FUNCT" = "read" ] && [ $1 = $STD ] | ||
then | ||
echo -e "\e[2mtesting stdin\e[0m" | ||
else | ||
ERROR_STD=$( ./"$FUNCT"_std $IMPLEM 2>&1 >/dev/null ) | ||
ERROR_FD=$( ./"$FUNCT" "$1" $IMPLEM ft_"$FUNCT".txt 2>&1 >/dev/null ) | ||
fi | ||
if [ $? = 0 ] | ||
} | ||
|
||
make_diff () | ||
{ | ||
DIFF=$(diff "$2" "$3") | ||
if [ "$DIFF" != "" ] | ||
then | ||
./"$FUNCT"_std $ORIG > a | ||
./"$FUNCT"_std $IMPLEM > b | ||
make_diff "$1" a b | ||
rm -f a b | ||
echo -e "\033[0;31m[KO]\033[0m" | ||
|
||
echo "--- EXPECTED RESULT ---" >> diffs/ft_"$FUNCT"."$1".txt | ||
cat a >> diffs/ft_"$FUNCT"."$1".txt | ||
echo "--- ACTUAL RESULT ---" >> diffs/ft_"$FUNCT"."$1".txt | ||
cat b >> diffs/ft_"$FUNCT"."$1".txt | ||
|
||
else | ||
echo -e "\033[0;31m[ERROR]\033[0m" | ||
echo -e "\033[0;32m[OK]\033[0m" | ||
rm -f diffs/ft_"$FUNCT"."$1".txt | ||
fi | ||
} | ||
|
||
test_fd() | ||
run_compare() | ||
{ | ||
if [ "$FUNCT" == "read" ] | ||
then | ||
echo "testing read function" > read.txt | ||
echo "testing read function" > ft_read.txt | ||
fi | ||
ERROR_FD=$( ./"$FUNCT"_fd "$2" $IMPLEM ft_"$FUNCT".txt 2>&1 >/dev/null ) | ||
if [ $? = 0 ] | ||
then | ||
./"$FUNCT"_fd "$2" $ORIG "$FUNCT".txt > a | ||
./"$FUNCT"_fd "$2" $IMPLEM ft_"$FUNCT".txt > b | ||
make_diff "$1" "$FUNCT".txt ft_"$FUNCT".txt | ||
make_diff "$1" a b | ||
./"$FUNCT" "$1" "$ORIG" "$FUNCT".txt > a | ||
./"$FUNCT" "$1" "$IMPLEM" ft_"$FUNCT".txt > b | ||
DIFF=$(diff a b) | ||
if [ "$DIFF" != "" ] | ||
then | ||
echo -e "\033[0;31m[KO]\033[0m" | ||
echo "--- EXPECTED RESULT ---" >> diffs/ft_"$FUNCT"."$1".txt | ||
cat "$FUNCT".txt >> diffs/ft_"$FUNCT"."$1".txt | ||
echo "" >> diffs/ft_"$FUNCT"."$1".txt | ||
cat a >> diffs/ft_"$FUNCT"."$1".txt | ||
echo "--- ACTUAL RESULT ---" >> diffs/ft_"$FUNCT"."$1".txt | ||
cat ft_"$FUNCT".txt >> diffs/ft_"$FUNCT"."$1".txt | ||
echo "" >> diffs/ft_"$FUNCT"."$1".txt | ||
cat b >> diffs/ft_"$FUNCT"."$1".txt | ||
else | ||
echo -e "\033[0;32m[OK]\033[0m" | ||
fi | ||
rm -rf a b | ||
rm -rf "$FUNCT".txt ft_"$FUNCT".txt | ||
else | ||
echo -e "\033[0;31m[ERROR]\033[0m" | ||
fi | ||
[ -f read.txt ] && rm read.txt | ||
[ -f ft_read.txt ] && rm ft_read.txt | ||
} | ||
|
||
FD_OPEN=0 | ||
FD_WRONG=1 | ||
test_input() | ||
{ | ||
prepare_function | ||
check_error "$1" | ||
run_compare "$1" | ||
} | ||
|
||
STD=0 | ||
FD_OPEN=1 | ||
FD_WRONG=2 | ||
|
||
FUNCT=$1 | ||
echo -e "" | ||
echo -e "\033[0;1m> ft_"$FUNCT"\033[0m" | ||
COMP=$( clang testers/test_"$FUNCT"_fd.c -L. -lasm -o "$FUNCT"_fd 2>&1 >/dev/null ) | ||
|
||
COMP=$( clang testers/test_"$FUNCT".c -L. -lasm -o "$FUNCT" 2>&1 >/dev/null ) | ||
if [ $? = 0 ] | ||
then | ||
clang -Wall -Werror -Wextra testers/test_"$FUNCT"_std.c -L. -lasm -o "$FUNCT"_std | ||
clang -Wall -Werror -Wextra testers/test_"$FUNCT"_fd.c -L. -lasm -o "$FUNCT"_fd | ||
test_std 1 | ||
test_fd 2 $FD_OPEN | ||
test_fd 3 $FD_WRONG | ||
rm -f "$FUNCT"_std "$FUNCT"_fd | ||
clang -Wall -Werror -Wextra testers/test_"$FUNCT".c -L. -lasm -o "$FUNCT" | ||
test_input $STD | ||
test_input $FD_OPEN | ||
test_input $FD_WRONG | ||
rm -f "$FUNCT" | ||
else | ||
echo -e "\033[0;31m[DONT COMPILE]\033[0m" | ||
fi | ||
|
||
rm -f "$FUNCT".txt | ||
rm -f ft_"$FUNCT".txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.