GCC Code Coverage Report


Directory: ./
File: tests/functional_test_parentheses.c
Date: 2024-06-05 00:36:48
Exec Total Coverage
Lines: 101 113 89.4%
Functions: 24 24 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2024
3 ** 42sh
4 ** File description:
5 ** The parentheses.ini
6 */
7
8 #include "criterion/criterion.h"
9 #include "criterion/redirect.h"
10 #include "../include/myshell.h"
11
12 4 Test(parentheses1, 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)\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(parentheses2, 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, "((((((((ls))))))))\n");
30 2 fprintf(file, "exit\n");
31 2 fclose(file);
32 2 freopen("test_input.txt", "r", stdin);
33 2 shell(env);
34 }
35
36 4 Test(parentheses3, full_gcorv)
37 {
38 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
39 2 FILE *file = fopen("test_input.txt", "w");
40
41 2 fprintf(file, "(ls test || ls && pwd) > parentheses\n");
42 2 fprintf(file, "exit\n");
43 2 fclose(file);
44 2 freopen("test_input.txt", "r", stdin);
45 2 shell(env);
46 }
47
48 4 Test(parentheses4, full_gcorv)
49 {
50 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
51 2 FILE *file = fopen("test_input.txt", "w");
52
53 2 fprintf(file, "echo test ; (ls ; pwd) ; echo 42sh\n");
54 2 fprintf(file, "exit\n");
55 2 fclose(file);
56 2 freopen("test_input.txt", "r", stdin);
57 2 shell(env);
58 }
59
60 4 Test(parentheses5, full_gcorv)
61 {
62 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
63 2 FILE *file = fopen("test_input.txt", "w");
64
65 2 fprintf(file, "(cat -e | grep \"c\") < Makefile > parentheses\n");
66 2 fprintf(file, "exit\n");
67 2 fclose(file);
68 2 freopen("test_input.txt", "r", stdin);
69 2 shell(env);
70 }
71
72 4 Test(parentheses6, full_gcorv)
73 {
74 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
75 2 FILE *file = fopen("test_input.txt", "w");
76
77 2 fprintf(file, "echo test && (env | grep PATH)\n");
78 2 fprintf(file, "(env | grep HOME) && echo 42sh\n");
79 2 fprintf(file, "cd /etc; (cd / && ls); ls\n");
80 2 fprintf(file, "(ls && cd /random) || pwd\n");
81 2 fprintf(file, "(ls ; pwd) > test\n");
82 2 fprintf(file, "cat test\n");
83 2 fprintf(file, "exit\n");
84 2 fclose(file);
85 2 freopen("test_input.txt", "r", stdin);
86 2 shell(env);
87 }
88
89 4 Test(parentheses7, full_gcorv)
90 {
91 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
92 2 FILE *file = fopen("test_input.txt", "w");
93
94 2 fprintf(file, "(()\n");
95 2 fprintf(file, "exit\n");
96 2 fclose(file);
97 2 freopen("test_input.txt", "r", stdin);
98 2 shell(env);
99 }
100
101 4 Test(parentheses8, full_gcorv)
102 {
103 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
104 2 FILE *file = fopen("test_input.txt", "w");
105
106 2 fprintf(file, "())\n");
107 2 fprintf(file, "exit\n");
108 2 fclose(file);
109 2 freopen("test_input.txt", "r", stdin);
110 2 shell(env);
111 }
112
113 4 Test(parentheses9, full_gcorv)
114 {
115 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
116 2 FILE *file = fopen("test_input.txt", "w");
117
118 2 fprintf(file, "( () () )\n");
119 2 fprintf(file, "exit\n");
120 2 fclose(file);
121 2 freopen("test_input.txt", "r", stdin);
122 2 shell(env);
123 }
124
125 4 Test(parentheses10, full_gcorv)
126 {
127 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
128 2 FILE *file = fopen("test_input.txt", "w");
129
130 2 fprintf(file, "ls (42sh)\n");
131 2 fprintf(file, "exit\n");
132 2 fclose(file);
133 2 freopen("test_input.txt", "r", stdin);
134 2 shell(env);
135 }
136
137 4 Test(parentheses11, full_gcorv)
138 {
139 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
140 2 FILE *file = fopen("test_input.txt", "w");
141
142 2 fprintf(file, "(ls) 42sh\n");
143 2 fprintf(file, "exit\n");
144 2 fclose(file);
145 2 freopen("test_input.txt", "r", stdin);
146 2 shell(env);
147 }
148
149 4 Test(parentheses12, full_gcorv)
150 {
151 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
152 2 FILE *file = fopen("test_input.txt", "w");
153
154 2 fprintf(file, "()\n");
155 2 fprintf(file, "exit\n");
156 2 fclose(file);
157 2 freopen("test_input.txt", "r", stdin);
158 2 shell(env);
159 }
160