GCC Code Coverage Report


Directory: ./
File: tests/functional_test_pipes.c
Date: 2024-06-05 00:36:48
Exec Total Coverage
Lines: 162 182 89.0%
Functions: 40 40 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2024
3 ** 42sh
4 ** File description:
5 ** The pipes.ini
6 */
7
8 #include "criterion/criterion.h"
9 #include "criterion/redirect.h"
10 #include "../include/myshell.h"
11
12 4 Test(pipes1, full_gcorv)
13 {
14 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
15 2 FILE *file = fopen("test_input.txt", "w");
16
17 2 fprintf(file, "ls | grep sh\n");
18 2 fprintf(file, "exit\n");
19 2 fclose(file);
20 2 freopen("test_input.txt", "r", stdin);
21 2 shell(env);
22 }
23
24 4 Test(pipes2, full_gcorv)
25 {
26 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
27 2 FILE *file = fopen("test_input.txt", "w");
28
29 2 fprintf(file, "env | grep PATH\n");
30 2 fprintf(file, "exit 45|cat /etc/resolv.conf\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(pipes3, 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, "cat -e < Makefile | grep sh\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(pipes4, 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, "ls | grep sh > pipe\n");
55 2 fprintf(file, "rm -rf pipe\n");
56 2 fprintf(file, "exit\n");
57 2 fclose(file);
58 2 freopen("test_input.txt", "r", stdin);
59 2 shell(env);
60 }
61
62 4 Test(pipes5, full_gcorv)
63 {
64 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
65 2 FILE *file = fopen("test_input.txt", "w");
66
67 2 fprintf(file, "cat -e < Makefile | grep sh > pipe\n");
68 2 fprintf(file, "rm -rf pipe\n");
69 2 fprintf(file, "exit\n");
70 2 fclose(file);
71 2 freopen("test_input.txt", "r", stdin);
72 2 shell(env);
73 }
74
75 4 Test(pipes6, full_gcorv)
76 {
77 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
78 2 FILE *file = fopen("test_input.txt", "w");
79
80 2 fprintf(file, "cat -e > pipe | grep sh < Makefile\n");
81 2 fprintf(file, "exit\n");
82 2 fclose(file);
83 2 freopen("test_input.txt", "r", stdin);
84 2 shell(env);
85 }
86
87 4 Test(pipes7, full_gcorv)
88 {
89 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
90 2 FILE *file = fopen("test_input.txt", "w");
91
92 2 fprintf(file, "ls | cat -e < Makefile\n");
93 2 fprintf(file, "exit\n");
94 2 fclose(file);
95 2 freopen("test_input.txt", "r", stdin);
96 2 shell(env);
97 }
98
99 4 Test(pipes8, full_gcorv)
100 {
101 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
102 2 FILE *file = fopen("test_input.txt", "w");
103
104 2 fprintf(file, "ls > pipe | cat -e\n");
105 2 fprintf(file, "exit\n");
106 2 fclose(file);
107 2 freopen("test_input.txt", "r", stdin);
108 2 shell(env);
109 }
110
111 4 Test(pipes9, full_gcorv)
112 {
113 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
114 2 FILE *file = fopen("test_input.txt", "w");
115
116 2 fprintf(file, "ls > pipe | cat -e\n");
117 2 fprintf(file, "exit\n");
118 2 fclose(file);
119 2 freopen("test_input.txt", "r", stdin);
120 2 shell(env);
121 }
122
123 4 Test(pipes10, full_gcorv)
124 {
125 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
126 2 FILE *file = fopen("test_input.txt", "w");
127
128 2 fprintf(file, "|\n");
129 2 fprintf(file, "exit\n");
130 2 fclose(file);
131 2 freopen("test_input.txt", "r", stdin);
132 2 shell(env);
133 }
134
135 4 Test(pipes11, full_gcorv)
136 {
137 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
138 2 FILE *file = fopen("test_input.txt", "w");
139
140 2 fprintf(file, "||||\n");
141 2 fprintf(file, "exit\n");
142 2 fclose(file);
143 2 freopen("test_input.txt", "r", stdin);
144 2 shell(env);
145 }
146
147 4 Test(pipes12, full_gcorv)
148 {
149 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
150 2 FILE *file = fopen("test_input.txt", "w");
151
152 2 fprintf(file, " | | | | \n");
153 2 fprintf(file, "exit\n");
154 2 fclose(file);
155 2 freopen("test_input.txt", "r", stdin);
156 2 shell(env);
157 }
158
159 4 Test(pipes13, full_gcorv)
160 {
161 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
162 2 FILE *file = fopen("test_input.txt", "w");
163
164 2 fprintf(file, "exit\n");
165 2 fclose(file);
166 2 freopen("test_input.txt", "r", stdin);
167 2 shell(env);
168 }
169
170 4 Test(pipes14, full_gcorv)
171 {
172 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
173 2 FILE *file = fopen("test_input.txt", "w");
174
175 2 fprintf(file, "ls |\n");
176 2 fprintf(file, "exit\n");
177 2 fclose(file);
178 2 freopen("test_input.txt", "r", stdin);
179 2 shell(env);
180 }
181
182 4 Test(pipes15, full_gcorv)
183 {
184 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
185 2 FILE *file = fopen("test_input.txt", "w");
186
187 2 fprintf(file, "ls ||||| cat\n");
188 2 fprintf(file, "exit\n");
189 2 fclose(file);
190 2 freopen("test_input.txt", "r", stdin);
191 2 shell(env);
192 }
193
194 4 Test(pipes16, full_gcorv)
195 {
196 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
197 2 FILE *file = fopen("test_input.txt", "w");
198
199 2 fprintf(file, "42sh | grep sh\n");
200 2 fprintf(file, "exit\n");
201 2 fclose(file);
202 2 freopen("test_input.txt", "r", stdin);
203 2 shell(env);
204 }
205
206 4 Test(pipes17, full_gcorv)
207 {
208 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
209 2 FILE *file = fopen("test_input.txt", "w");
210
211 2 fprintf(file, "42sh | 42sh | 42sh\n");
212 2 fprintf(file, "exit\n");
213 2 fclose(file);
214 2 freopen("test_input.txt", "r", stdin);
215 2 shell(env);
216 }
217
218 4 Test(pipes18, full_gcorv)
219 {
220 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
221 2 FILE *file = fopen("test_input.txt", "w");
222
223 2 fprintf(file, "ls | grep sh | 42sh\n");
224 2 fprintf(file, "exit\n");
225 2 fclose(file);
226 2 freopen("test_input.txt", "r", stdin);
227 2 shell(env);
228 }
229
230 4 Test(pipes19, full_gcorv)
231 {
232 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
233 2 FILE *file = fopen("test_input.txt", "w");
234
235 2 fprintf(file, "ls | grep sh | 42sh | grep sh\n");
236 2 fprintf(file, "exit\n");
237 2 fclose(file);
238 2 freopen("test_input.txt", "r", stdin);
239 2 shell(env);
240 }
241
242 4 Test(pipes20, full_gcorv)
243 {
244 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
245 2 FILE *file = fopen("test_input.txt", "w");
246
247 2 fprintf(file, "mysh | 42sh\n");
248 2 fprintf(file, "exit\n");
249 2 fclose(file);
250 2 freopen("test_input.txt", "r", stdin);
251 2 shell(env);
252 }
253