aboutsummaryrefslogtreecommitdiff
path: root/suites
diff options
context:
space:
mode:
Diffstat (limited to 'suites')
-rw-r--r--suites/builtin.py118
-rw-r--r--suites/cmd.py93
-rw-r--r--suites/operation.py16
-rw-r--r--suites/parenthesis.py27
-rw-r--r--suites/preprocess.py (renamed from suites/suites.py)85
-rw-r--r--suites/status.py18
6 files changed, 261 insertions, 96 deletions
diff --git a/suites/builtin.py b/suites/builtin.py
index 93e9db7..aba70a1 100644
--- a/suites/builtin.py
+++ b/suites/builtin.py
@@ -3,18 +3,26 @@ from suite import suite
@suite
def suite_echo(test):
+ test("echo")
test("echo bonjour")
test("echo lalalala lalalalal alalalalal alalalala")
test("echo lalalala lalalalal alalalalal alalalala")
test("echo " + config.LOREM)
+ test("echo -n")
test("echo -n bonjour")
test("echo -n lalalala lalalalal alalalalal alalalala")
test("echo -n lalalala lalalalal alalalalal alalalala")
test("echo -n " + config.LOREM)
+ test("echo bonjour -n")
+ test("echo -n bonjour -n")
+ test(" echo bonjour je")
+ test(" echo -n bonjour je")
+
@suite
def suite_export(test):
+ test("export")
test("export A=a; echo $A")
test("export A=a B=b C=c; echo $A$B$C")
test("export A=a B=b C=c D=d E=e F=f G=g H=h I=i J=j K=k L=l" +
@@ -56,21 +64,35 @@ def suite_export(test):
@suite
def suite_cd(test):
- test("cd .; pwd");
- test("cd ..; pwd");
- test("cd ../..; pwd");
- test("cd ../../..; pwd");
- test("cd ../../../..; pwd");
- test("cd ../../../../..; pwd");
- test("cd ../../../../../..; pwd");
- test("cd /; pwd");
- test("cd /etc; pwd");
- test("cd $HOME; pwd");
- test("cd ~; pwd");
+ test("cd .; pwd; echo $PWD");
+ test("cd ..; pwd; echo $PWD");
+ test("cd ../..; pwd; echo $PWD");
+ test("cd ../../..; pwd; echo $PWD");
+ test("cd ../../../..; pwd; echo $PWD");
+ test("cd ../../../../..; pwd; echo $PWD");
+ test("cd ../../../../../..; pwd; echo $PWD");
+ test("cd /; pwd; echo $PWD");
+ test("cd /etc; pwd; echo $PWD");
+ test("cd $HOME; pwd; echo $PWD");
+ test("cd ~; pwd; echo $PWD");
+ test("cd ~/..; pwd; echo $PWD");
+ test("cd ~/../..; pwd; echo $PWD");
+ test("cd /; pwd; echo $PWD");
+ test("cd /.; pwd; echo $PWD");
+ test("cd /./; pwd; echo $PWD");
+ test("cd /././././; pwd; echo $PWD");
+ test("cd //; pwd; echo $PWD");
+ test("cd")
@suite
def suite_unset(test):
+ test("unset")
test("unset A; echo $A", setup="export A=a")
+ test("unset 'A '; echo $A", setup="export A=a")
+ test("unset 'A='; echo $A", setup="export A=a")
+ test("unset A B C; echo $A$B$C", setup="export A=a B=b C=c")
+ test("unset A; echo $A$B$C", setup="export A=a B=b C=c")
+ test("unset C; echo $A$B$C", setup="export A=a B=b C=c")
@suite
def suite_pwd(test):
@@ -80,12 +102,14 @@ def suite_pwd(test):
test("pwd", setup="cd ../../..")
test("pwd", setup="cd /")
test("pwd", setup="cd $HOME")
+ test("pwd | cat -e")
@suite
def suite_env(test):
test("env")
test("env", setup="export A=a")
test("env", setup="export A=a B=b C=c")
+ test("env | cat -e", setup="export A=a B=b C=c")
@suite
def suite_exit(test):
@@ -93,3 +117,75 @@ def suite_exit(test):
test("exit 1")
test("exit 2")
test("exit 3")
+ test("exit 0")
+ test("exit -0")
+ test("exit -1")
+ test("exit 255")
+ test("exit 256")
+ test("exit 2000000")
+ test("exit -2000000")
+ test("exit 2147483647")
+ test("exit -2147483648")
+ test("exit 2147483648")
+ test("exit -2147483649")
+ test("exit 3147483648")
+ test("exit -3147483649")
+ test("exit 4294967295")
+ test("exit 4294967296")
+ test("exit -9223372036854775808")
+ test("exit 9223372036854775807")
+ test("exit -9223372036854775809")
+ test("exit 9223372036854775808")
+ test("exit 18446744073709551615")
+ test("exit 18446744073709551616")
+
+ test("exit +1")
+ test("exit +2")
+ test("exit +3")
+ test("exit +0")
+ test("exit +255")
+ test("exit +256")
+ test("exit +2000000")
+ test("exit +2147483647")
+
+ test("exit ++1")
+ test("exit ++2")
+ test("exit ++3")
+ test("exit ++0")
+ test("exit ++255")
+ test("exit ++256")
+ test("exit ++2000000")
+ test("exit ++2147483647")
+
+ test("exit --1")
+ test("exit --2")
+ test("exit --3")
+ test("exit --0")
+ test("exit --255")
+ test("exit --256")
+ test("exit --2000000")
+ test("exit --2147483647")
+
+ test("exit bonjour")
+ test("exit 0_")
+ test("exit _0")
+ test("exit 0123456789")
+ test("exit -0123456789")
+ test("exit 00000000000000000000000000000000000000000000001")
+ test("exit 00000000000000000000000000000000000000000000000" +
+ "00000000000000000000000000000000000000000000001")
+ test("exit 00000000000000000000000000000000000000000000000" +
+ "00000000000000000000000000000000000000000000000")
+ test("exit -00000000000000000000000000000000000000000000000" +
+ "00000000000000000000000000000000000000000000001")
+ test("exit -99999999999999999999999999999999999999999999" +
+ "99999999999999999999999999999999999999999999")
+ test("exit 99999999999999999999999999999999999999999999" +
+ "99999999999999999999999999999999999999999999")
+
+ test("exit 0 bonjour")
+ test("exit bonjour 0")
+ test("exit 0 1")
+ test("exit 0 1 2 3 4 5 6 7 8 9")
+
+ test("exit " + config.LOREM)
diff --git a/suites/cmd.py b/suites/cmd.py
new file mode 100644
index 0000000..018bd1a
--- /dev/null
+++ b/suites/cmd.py
@@ -0,0 +1,93 @@
+import config
+from suite import suite
+
+@suite
+def suite_redirection(test):
+ test("echo bonjour > test", setup="", files=["test"])
+ test("echo > test bonjour", setup="", files=["test"])
+ test("> test echo bonjour", setup="", files=["test"])
+ test("echo bonjour >> test", setup="", files=["test"])
+ test("echo >> test bonjour", setup="", files=["test"])
+ test(">> test echo bonjour", setup="", files=["test"])
+ test("cat < test", setup="echo bonjour > test")
+ test("echo bonjour > test", setup="", files=["test"])
+
+ test("echo > test'sticked' bonjour", setup="", files=["teststicked"])
+ test("> test'sticked' echo bonjour", setup="", files=["teststicked"])
+ test("echo bonjour >> test'sticked'", setup="", files=["teststicked"])
+ test("echo >> test'sticked' bonjour", setup="", files=["teststicked"])
+ test(">> test'sticked' echo bonjour", setup="", files=["teststicked"])
+ test("cat < test'sticked'", setup="echo bonjour > test'sticked'")
+ test("< test'sticked' cat", setup="echo bonjour > test'sticked'")
+
+ test("echo > test\"sticked\" bonjour", setup="", files=["teststicked"])
+ test("> test\"sticked\" echo bonjour", setup="", files=["teststicked"])
+ test("echo bonjour >> test\"sticked\"", setup="", files=["teststicked"])
+ test("echo >> test\"sticked\" bonjour", setup="", files=["teststicked"])
+ test(">> test\"sticked\" echo bonjour", setup="", files=["teststicked"])
+ test("cat < test\"sticked\"", setup="echo bonjour > test\"sticked\"")
+ test("< test\"sticked\" cat", setup="echo bonjour > test\"sticked\"")
+
+ test("echo > test'yo'\"sticked\" bonjour", setup="", files=["testyosticked"])
+ test("> test'yo'\"sticked\" echo bonjour", setup="", files=["testyosticked"])
+ test("echo bonjour >> test'yo'\"sticked\"", setup="", files=["testyosticked"])
+ test("echo >> test'yo'\"sticked\" bonjour", setup="", files=["testyosticked"])
+ test(">> test'yo'\"sticked\" echo bonjour", setup="", files=["testyosticked"])
+ test("cat < test'yo'\"sticked\"", setup="echo bonjour > test'yo'\"sticked\"")
+ test("< test'yo'\"sticked\" cat", setup="echo bonjour > test'yo'\"sticked\"")
+
+ test("echo bonjour > test > je > suis", setup="", files=["test", "je", "suis"])
+ test("echo > test > je bonjour > suis", setup="", files=["test", "je", "suis"])
+ test("> test echo bonjour > je > suis", setup="", files=["test", "je", "suis"])
+ test("echo bonjour >> test > je >> suis", setup="", files=["test", "je", "suis"])
+ test("echo >> test bonjour > je > suis", setup="", files=["test", "je", "suis"])
+ test(">> test echo > je bonjour > suis", setup="", files=["test", "je", "suis"])
+ test("cat < test < je", setup="echo bonjour > test; echo salut > je")
+
+ test("echo bonjour>test>je>suis", setup="", files=["test", "je", "suis"])
+ test(">test echo bonjour>je>suis", setup="", files=["test", "je", "suis"])
+ test("echo bonjour>>test>je>>suis", setup="", files=["test", "je", "suis"])
+ test("cat<test<je", setup="echo bonjour > test; echo salut > je")
+
+ test("echo bonjour > a'b'c'd'e'f'g'h'i'j'k'l'm'n'o'p'q'r's't'u'v'w'x'y'z'",
+ files=["abcdefghijklmnopqrstuvwxyz"])
+ test('echo bonjour > a"b"c"d"e"f"g"h"i"j"k"l"m"n"o"p"q"r"s"t"u"v"w"x"y"z"',
+ files=["abcdefghijklmnopqrstuvwxyz"])
+ test('echo bonjour > a\'b\'c"d"e\'f\'g"h"i\'j\'k"l"m\'n\'o"p\'q\'r"s\'t\'u"v"w"x"y\'z\'',
+ files=["abcdefghijklmnopqrstuvwxyz"])
+
+ test("> file", files=["file"])
+ test("< file", setup="echo bonjour > file")
+
+@suite
+def suite_edgecases(test):
+ test('echo "\\"" >>a"b""c" ', files=["abc"])
+ test("echo " + ''.join([chr(i) for i in range(1, 127) if chr(i) not in '\n`"\'()|&><']))
+ test("echo foo>bar", files=["bar"])
+ test("echo foo >bar", files=["bar"])
+ test("echo foo> bar", files=["bar"])
+ test("echo foo > bar", files=["bar"])
+
+@suite
+def suite_cmd_error(test):
+ test(">")
+ test(">>")
+ test("<")
+ test("echo >")
+ test("echo >>")
+ test("echo <")
+
+ test("> test", files=["test"])
+ test(">> test", files=["test"])
+ test("< test", setup="touch test")
+
+ test("echo foo >>> bar")
+ test("echo foo >>>> bar")
+ test("echo foo >>>>> bar")
+
+ test("cat <<< bar", setup="echo bonjour > bar")
+ test("cat <<<< bar", setup="echo bonjour > bar")
+ test("cat <<<<< bar", setup="echo bonjour > bar")
+
+ test("notfound")
+ test("notfound a b c")
diff --git a/suites/operation.py b/suites/operation.py
index 7bed096..8d912d3 100644
--- a/suites/operation.py
+++ b/suites/operation.py
@@ -9,6 +9,9 @@ def suite_end(test):
test("echo; ")
test("echo ; ")
test("echo ;")
+ test("; echo")
+ test(" ;echo")
+ test(" ; echo")
test("echo a; echo b; echo c; echo d; echo e; echo f; echo g; echo h; echo i;" +
"echo j; echo k; echo l; echo m; echo c; echo c; echo c; echo c; echo c;" +
"echo c; echo c; echo c; echo v; echo w; echo x; echo y; echo z")
@@ -29,6 +32,9 @@ def suite_and(test):
test("echo&& ")
test("echo && ")
test("echo &&")
+ test("&&echo")
+ test("&& echo")
+ test(" && echo")
test("echo a&& echo b&& echo c&& echo d&& echo e&& echo f&& echo g&& echo h&& echo i&&" +
"echo j&& echo k&& echo l&& echo m&& echo c&& echo c&& echo c&& echo c&& echo c&&" +
"echo c&& echo c&& echo c&& echo v&& echo w&& echo x&& echo y&& echo z")
@@ -49,6 +55,9 @@ def suite_or(test):
test("echo|| ")
test("echo || ")
test("echo ||")
+ test("||echo")
+ test("|| echo")
+ test(" || echo")
test("echo a|| echo b|| echo c|| echo d|| echo e|| echo f|| echo g|| echo h|| echo i||" +
"echo j|| echo k|| echo l|| echo m|| echo c|| echo c|| echo c|| echo c|| echo c||" +
"echo c|| echo c|| echo c|| echo v|| echo w|| echo x|| echo y|| echo z")
@@ -69,3 +78,10 @@ def suite_pipe(test):
test("ls -l | cat -e | cat | cat | cat", setup="touch a b c d; mkdir m1 m2 m3")
test("ls -l | cat -e | cat -e | cat -e | cat -e", setup="touch a b c d; mkdir m1 m2 m3")
test("ls -l | cat -e < a", setup="touch a b c d; mkdir m1 m2 m3; echo bonjour > a")
+
+ test("echo|")
+ test("echo |")
+ test("echo | ")
+ test("|cat")
+ test("| cat")
+ test(" | cat")
diff --git a/suites/parenthesis.py b/suites/parenthesis.py
index c1df83b..30f1cce 100644
--- a/suites/parenthesis.py
+++ b/suites/parenthesis.py
@@ -14,5 +14,32 @@ def suite_parenthesis(test):
test("ls doesnotexist || (echo b && echo c)")
test("(echo bonjour > f1)", files=["f1"])
+ test("(echo bonjour > f1 > f2 > f3)", files=["f1", "f2", "f3"])
+ test("(echo bonjour > f1 > f2 > f3 > f4 > f5 > f6 > f7 > f8 > f9)",
+ files=["f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9"])
+
+ test("(echo bonjour) > f1", files=["f1"])
+ test("(echo bonjour) > f1 > f2 > f3", files=["f1", "f2", "f3"])
+ test("(echo bonjour) > f1 > f2 > f3 > f4 > f5 > f6 > f7 > f8 > f9",
+ files=["f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9"])
+
+ test("(cat -e < f1)", setup="echo bonjour > f1")
+ test("(cat -e < f1 < f2 < f3)", setup="touch f1 f2 f3 f4; echo bonjour > f3")
+ test("(cat -e < f1 < f2 < f3 < f4 < f5 < f6 < f7 < f8 < f9)",
+ setup="touch f1 f2 f3 f4 f5 f6 f7 f8 f9; echo bonjour > f9")
+
+ test("(cat -e) < f1", setup="echo bonjour > f1")
+ test("(cat -e) < f1 < f2 < f3", setup="touch f1 f2 f3 f4; echo bonjour > f3")
+ test("(cat -e) < f1 < f2 < f3 < f4 < f5 < f6 < f7 < f8 < f9",
+ setup="touch f1 f2 f3 f4 f5 f6 f7 f8 f9; echo bonjour > f9")
+
+ test("(echo bonjour > f1 > f2 > f3 > f4) > f5 > f6 > f7 > f8 > f9",
+ files=["f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9"])
+ test("(cat -e < f1 < f2 < f3 < f4) < f5 < f6 < f7 < f8 < f9",
+ setup="touch f1 f2 f3 f4 f5 f6 f7 f8 f9; echo bonjour > f4")
+
test("(echo bonjour > f1) > f2", files=["f1", "f2"])
test("(cat -e > f1) < f2", setup="ls -l / > f2", files=["f1"])
+
+ test("(exit); echo bonjour")
+ test("(echo bonjour; exit; echo aurevoir)")
diff --git a/suites/suites.py b/suites/preprocess.py
index 9f6ce86..62588b7 100644
--- a/suites/suites.py
+++ b/suites/preprocess.py
@@ -18,91 +18,6 @@ def suite_quote(test):
test('echo "\\\\"')
@suite
-def suite_redirection(test):
- test("echo bonjour > test", setup="", files=["test"])
- test("echo > test bonjour", setup="", files=["test"])
- test("> test echo bonjour", setup="", files=["test"])
- test("echo bonjour >> test", setup="", files=["test"])
- test("echo >> test bonjour", setup="", files=["test"])
- test(">> test echo bonjour", setup="", files=["test"])
- test("cat < test", setup="echo bonjour > test")
- test("echo bonjour > test", setup="", files=["test"])
-
- test("echo > test'sticked' bonjour", setup="", files=["teststicked"])
- test("> test'sticked' echo bonjour", setup="", files=["teststicked"])
- test("echo bonjour >> test'sticked'", setup="", files=["teststicked"])
- test("echo >> test'sticked' bonjour", setup="", files=["teststicked"])
- test(">> test'sticked' echo bonjour", setup="", files=["teststicked"])
- test("cat < test'sticked'", setup="echo bonjour > test'sticked'")
- test("< test'sticked' cat", setup="echo bonjour > test'sticked'")
-
- test("echo > test\"sticked\" bonjour", setup="", files=["teststicked"])
- test("> test\"sticked\" echo bonjour", setup="", files=["teststicked"])
- test("echo bonjour >> test\"sticked\"", setup="", files=["teststicked"])
- test("echo >> test\"sticked\" bonjour", setup="", files=["teststicked"])
- test(">> test\"sticked\" echo bonjour", setup="", files=["teststicked"])
- test("cat < test\"sticked\"", setup="echo bonjour > test\"sticked\"")
- test("< test\"sticked\" cat", setup="echo bonjour > test\"sticked\"")
-
- test("echo > test'yo'\"sticked\" bonjour", setup="", files=["testyosticked"])
- test("> test'yo'\"sticked\" echo bonjour", setup="", files=["testyosticked"])
- test("echo bonjour >> test'yo'\"sticked\"", setup="", files=["testyosticked"])
- test("echo >> test'yo'\"sticked\" bonjour", setup="", files=["testyosticked"])
- test(">> test'yo'\"sticked\" echo bonjour", setup="", files=["testyosticked"])
- test("cat < test'yo'\"sticked\"", setup="echo bonjour > test'yo'\"sticked\"")
- test("< test'yo'\"sticked\" cat", setup="echo bonjour > test'yo'\"sticked\"")
-
- test("echo bonjour > test > je > suis", setup="", files=["test", "je", "suis"])
- test("echo > test > je bonjour > suis", setup="", files=["test", "je", "suis"])
- test("> test echo bonjour > je > suis", setup="", files=["test", "je", "suis"])
- test("echo bonjour >> test > je >> suis", setup="", files=["test", "je", "suis"])
- test("echo >> test bonjour > je > suis", setup="", files=["test", "je", "suis"])
- test(">> test echo > je bonjour > suis", setup="", files=["test", "je", "suis"])
- test("cat < test < je", setup="echo bonjour > test; echo salut > je")
-
- test("echo bonjour>test>je>suis", setup="", files=["test", "je", "suis"])
- test(">test echo bonjour>je>suis", setup="", files=["test", "je", "suis"])
- test("echo bonjour>>test>je>>suis", setup="", files=["test", "je", "suis"])
- test("cat<test<je", setup="echo bonjour > test; echo salut > je")
-
- test("echo bonjour > a'b'c'd'e'f'g'h'i'j'k'l'm'n'o'p'q'r's't'u'v'w'x'y'z'",
- files=["abcdefghijklmnopqrstuvwxyz"])
- test('echo bonjour > a"b"c"d"e"f"g"h"i"j"k"l"m"n"o"p"q"r"s"t"u"v"w"x"y"z"',
- files=["abcdefghijklmnopqrstuvwxyz"])
- test('echo bonjour > a\'b\'c"d"e\'f\'g"h"i\'j\'k"l"m\'n\'o"p\'q\'r"s\'t\'u"v"w"x"y\'z\'',
- files=["abcdefghijklmnopqrstuvwxyz"])
-
-@suite
-def suite_edgecases(test):
- test('echo "\\"" >>a"b""c" ', files=["abc"])
- test("echo " + ''.join([chr(i) for i in range(1, 127) if chr(i) not in '\n`"\'()|&><']))
- test("echo foo>bar", files=["bar"])
- test("echo foo >bar", files=["bar"])
- test("echo foo> bar", files=["bar"])
- test("echo foo > bar", files=["bar"])
-
-@suite
-def suite_cmd_error(test):
- test(">")
- test(">>")
- test("<")
- test("echo >")
- test("echo >>")
- test("echo <")
-
- test("> test", files=["test"])
- test(">> test", files=["test"])
- test("< test", setup="touch test")
-
- test("echo foo >>> bar")
- test("echo foo >>>> bar")
- test("echo foo >>>>> bar")
-
- test("cat <<< bar", setup="echo bonjour > bar")
- test("cat <<<< bar", setup="echo bonjour > bar")
- test("cat <<<<< bar", setup="echo bonjour > bar")
-
-@suite
def suite_interpolation(test):
test("echo $TEST", exports={"TEST": "bonjour"})
test("echo $TES", exports={"TEST": "bonjour"})
diff --git a/suites/status.py b/suites/status.py
new file mode 100644
index 0000000..f116ec1
--- /dev/null
+++ b/suites/status.py
@@ -0,0 +1,18 @@
+from suite import suite
+
+@suite
+def suite_status(test):
+ test("echo $?")
+ test("echo; echo $?")
+ test("notfound; echo $?")
+ test("cat < doesntexist; echo $?")
+ test("cat < noperm; echo $?", setup="echo bonjour > noperm; chmod 000 noperm")
+ test("(ls && ls) && echo $?")
+
+ test("echo")
+ test("notfound")
+ test("cat < doesntexist")
+ test("cat < noperm", setup="echo bonjour > noperm; chmod 000 noperm")
+ test("(ls && ls)")
+ test("(ls doesntexist || ls)")
+ test("(ls doesntexist && ls)")