Line |
Branch |
Exec |
Source |
1 |
|
|
/* |
2 |
|
|
** EPITECH PROJECT, 2024 |
3 |
|
|
** 42sh |
4 |
|
|
** File description: |
5 |
|
|
** The other.ini |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
#include "criterion/criterion.h" |
9 |
|
|
#include "criterion/redirect.h" |
10 |
|
|
#include "../include/myshell.h" |
11 |
|
|
|
12 |
|
4 |
Test(other1, full_gcorv) |
13 |
|
|
{ |
14 |
|
2 |
char **env = my_str_to_word_array_select("", " ;"); |
15 |
|
2 |
FILE *file = fopen("test_input.txt", "w"); |
16 |
|
|
|
17 |
|
2 |
fprintf(file, "exit\n"); |
18 |
|
2 |
fclose(file); |
19 |
|
2 |
freopen("test_input.txt", "r", stdin); |
20 |
|
2 |
shell(env); |
21 |
|
✗ |
} |
22 |
|
|
|
23 |
|
4 |
Test(other2, full_gcorv) |
24 |
|
|
{ |
25 |
|
2 |
char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;"); |
26 |
|
2 |
FILE *file = fopen("test_input.txt", "w"); |
27 |
|
|
|
28 |
|
2 |
fprintf(file, "echo \"ls\" > source_me\n"); |
29 |
|
2 |
fprintf(file, "source source_me\n"); |
30 |
|
2 |
fprintf(file, "rm source_me\n"); |
31 |
|
2 |
fprintf(file, "exit\n"); |
32 |
|
2 |
fclose(file); |
33 |
|
2 |
freopen("test_input.txt", "r", stdin); |
34 |
|
2 |
shell(env); |
35 |
|
✗ |
} |
36 |
|
|
|
37 |
|
4 |
Test(other3, full_gcorv) |
38 |
|
|
{ |
39 |
|
2 |
char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;"); |
40 |
|
2 |
FILE *file = fopen("test_input.txt", "w"); |
41 |
|
|
|
42 |
|
2 |
fprintf(file, "source\n"); |
43 |
|
2 |
fprintf(file, "exit\n"); |
44 |
|
2 |
fclose(file); |
45 |
|
2 |
freopen("test_input.txt", "r", stdin); |
46 |
|
2 |
shell(env); |
47 |
|
✗ |
} |
48 |
|
|
|
49 |
|
4 |
Test(other4, full_gcorv) |
50 |
|
|
{ |
51 |
|
2 |
char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;"); |
52 |
|
2 |
FILE *file = fopen("test_input.txt", "w"); |
53 |
|
|
|
54 |
|
2 |
fprintf(file, "echo Hello World\n"); |
55 |
|
2 |
fprintf(file, "echo $?\n"); |
56 |
|
2 |
fprintf(file, "echo *\n"); |
57 |
|
2 |
fprintf(file, "exit\n"); |
58 |
|
2 |
fclose(file); |
59 |
|
2 |
freopen("test_input.txt", "r", stdin); |
60 |
|
2 |
shell(env); |
61 |
|
✗ |
} |
62 |
|
|
|
63 |
|
4 |
Test(other5, full_gcorv) |
64 |
|
|
{ |
65 |
|
2 |
char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;"); |
66 |
|
2 |
FILE *file = fopen("test_input.txt", "w"); |
67 |
|
|
|
68 |
|
2 |
fprintf(file, "echo test && (env | grep PATH)\n"); |
69 |
|
2 |
fprintf(file, "(env | grep HOME) && echo 42sh\n"); |
70 |
|
2 |
fprintf(file, "cd /etc; (cd / && ls); ls\n"); |
71 |
|
2 |
fprintf(file, "(ls && cd /random) || pwd\n"); |
72 |
|
2 |
fprintf(file, "(ls ; pwd) > test\n"); |
73 |
|
2 |
fprintf(file, "cat test\n"); |
74 |
|
2 |
fprintf(file, "exit\n"); |
75 |
|
2 |
fclose(file); |
76 |
|
2 |
freopen("test_input.txt", "r", stdin); |
77 |
|
2 |
shell(env); |
78 |
|
✗ |
} |
79 |
|
|
|
80 |
|
4 |
Test(other6, full_gcorv) |
81 |
|
|
{ |
82 |
|
2 |
char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;"); |
83 |
|
2 |
FILE *file = fopen("test_input.txt", "w"); |
84 |
|
|
|
85 |
|
2 |
fprintf(file, "set TEST1=42sh; set TEST2=mysh; set | grep TEST; unset TEST1; set | grep TEST\n"); |
86 |
|
2 |
fprintf(file, "set TEST21=42sh; set | grep TEST; set TEST21=mysh; set | grep TEST\n"); |
87 |
|
2 |
fprintf(file, "set TEST31=42sh; set TEST32=mysh; set TEST31=mysh; set | grep TEST; unset TEST32\n"); |
88 |
|
2 |
fprintf(file, "exit\n"); |
89 |
|
2 |
fclose(file); |
90 |
|
2 |
freopen("test_input.txt", "r", stdin); |
91 |
|
2 |
shell(env); |
92 |
|
✗ |
} |
93 |
|
|
|
94 |
|
4 |
Test(other7, full_gcorv) |
95 |
|
|
{ |
96 |
|
2 |
char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;"); |
97 |
|
2 |
FILE *file = fopen("test_input.txt", "w"); |
98 |
|
|
|
99 |
|
2 |
fprintf(file, "echo \"echo Hello World\" > script\n"); |
100 |
|
2 |
fprintf(file, "echo \"ls ; pwd\" >> script\n"); |
101 |
|
2 |
fprintf(file, "./script\n"); |
102 |
|
2 |
fprintf(file, "exit\n"); |
103 |
|
2 |
fclose(file); |
104 |
|
2 |
freopen("test_input.txt", "r", stdin); |
105 |
|
2 |
shell(env); |
106 |
|
✗ |
} |
107 |
|
|
|