-
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.
Merge pull request #36 from ErwannLesech/funct_test
test<funct_test>: Adding new tests on echo
- Loading branch information
Showing
9 changed files
with
59 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
echo titi ; echo -la else fi if |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
echo ' ' ; echo else titi ls -n |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
echo tata echo # fi if ' -la -n |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
echo fi -e ls tata ls -E |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
echo if elif toto -E tata fi |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
echo | ||
echo elif -la # -la # ' |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
echo | ||
echo titi -n ls -n toto |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import subprocess | ||
|
||
executable_path = '/home/ugopc/ING1/42sh/42-Sh/src/42sh' | ||
|
||
l = [ "if", "else", "elif", "fi", ";", "'", "echo", "ls", "-n", "-e" ,"-E", "-la", "#", "titi", "tata", "toto", "\n", " ", "\t" ] | ||
import random | ||
error = 0 | ||
number_of_test = 1000 | ||
for i in range(number_of_test): | ||
str = "" | ||
for j in range(10): | ||
str += l[random.randint(0, len(l) - 1)] + " " | ||
ref_res = subprocess.run("echo " + '"' + str + '"' + " | bash --posix", shell=True, capture_output=True, text=True) | ||
res = subprocess.run(executable_path + " -c " + '"' +str + '"', shell=True, capture_output=True, text=True) | ||
|
||
if ref_res.stdout != res.stdout and res.returncode == 0 and ref_res.returncode == 0: | ||
error += 1 | ||
# print("=== Error match stdout ===") | ||
# print("Input: " + str) | ||
f = open("test.txt", "a") | ||
f.write('"' + str + '"\n') | ||
# print("res: " + res.stdout) | ||
# print("ref_res: " + ref_res.stdout) | ||
f.close() | ||
|
||
if ref_res.returncode != res.returncode: | ||
error += 1 | ||
# print("=== Error return code ===") | ||
# print("Input: " + str) | ||
# print("") | ||
# print("result of 42sh: " + res.stdout) | ||
# print("") | ||
# print("result of bash --posix: " + ref_res.stdout) | ||
# print("") | ||
# print("return code of 42sh: ", end="") | ||
# print(res.returncode) | ||
# print("return code of bash --posix: ", end="") | ||
# print(ref_res.returncode) | ||
# print("") | ||
print("Accuracy: ", end="") | ||
print((number_of_test - error) / number_of_test * 100, end="") | ||
print("%") |