GCC Code Coverage Report


Directory: ./
File: tests/functional_test_environnement.c
Date: 2024-06-05 00:36:48
Exec Total Coverage
Lines: 149 160 93.1%
Functions: 22 22 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2024
3 ** 42sh
4 ** File description:
5 ** The environnement.ini
6 */
7
8 #include "criterion/criterion.h"
9 #include "criterion/redirect.h"
10 #include "../include/myshell.h"
11
12 4 Test(environnement1, full_gcorv)
13 {
14 2 char **env = my_str_to_word_array_select("PATH=/bin:/usr/bin ; export _=ls ; export LS_COLORS=RID ; export MYBG=4 ; export LVL=4 ; export NOTE=2", " ;");
15 2 FILE *file = fopen("test_input.txt", "w");
16
17 2 fprintf(file, "unsetenv _\n");
18 2 fprintf(file, "unsetenv MYSH\n");
19 2 fprintf(file, "unsetenv HOSTTYPE\n");
20 2 fprintf(file, "unsetenv VENDOR\n");
21 2 fprintf(file, "unsetenv OSTYPE\n");
22 2 fprintf(file, "unsetenv MACHTYPE\n");
23 2 fprintf(file, "unsetenv SHLVL\n");
24 2 fprintf(file, "unsetenv PWD\n");
25 2 fprintf(file, "unsetenv LOGNAME\n");
26 2 fprintf(file, "unsetenv USER\n");
27 2 fprintf(file, "unsetenv GROUP\n");
28 2 fprintf(file, "unsetenv HOST\n");
29 2 fprintf(file, "unsetenv REMOTEHOST\n");
30 2 fprintf(file, "unsetenv LS_COLORS\n");
31 2 fprintf(file, "unsetenv NOTE\n");
32 2 fprintf(file, "setenv titi\n");
33 2 fprintf(file, "setenv tata coucou\n");
34 2 fprintf(file, "env\n");
35 2 fprintf(file, "/usr/bin/env\n");
36 2 fprintf(file, "unsetenv titi\n");
37 2 fprintf(file, "env\n");
38 2 fprintf(file, "/usr/bin/env\n");
39 2 fprintf(file, "unsetenv tata\n");
40 2 fprintf(file, "env\n");
41 2 fprintf(file, "/usr/bin/env\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(environnement2, 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, "unsetenv _\n");
54 2 fprintf(file, "unsetenv MYSH\n");
55 2 fprintf(file, "unsetenv HOSTTYPE\n");
56 2 fprintf(file, "unsetenv VENDOR\n");
57 2 fprintf(file, "unsetenv OSTYPE\n");
58 2 fprintf(file, "unsetenv MACHTYPE\n");
59 2 fprintf(file, "unsetenv SHLVL\n");
60 2 fprintf(file, "unsetenv PWD\n");
61 2 fprintf(file, "unsetenv LOGNAME\n");
62 2 fprintf(file, "unsetenv USER\n");
63 2 fprintf(file, "unsetenv GROUP\n");
64 2 fprintf(file, "unsetenv HOST\n");
65 2 fprintf(file, "unsetenv REMOTEHOST\n");
66 2 fprintf(file, "unsetenv LS_COLORS\n");
67 2 fprintf(file, "unsetenv NOTE\n");
68 2 fprintf(file, "env > my_env\n");
69 2 fprintf(file, "cat my_env\n");
70 2 fprintf(file, "rm my_env\n");
71 2 fprintf(file, "exit\n");
72 2 fclose(file);
73 2 freopen("test_input.txt", "r", stdin);
74 2 shell(env);
75 }
76
77 4 Test(environnement3, full_gcorv)
78 {
79 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
80 2 FILE *file = fopen("test_input.txt", "w");
81
82 2 fprintf(file, "unsetenv _\n");
83 2 fprintf(file, "unsetenv MYSH\n");
84 2 fprintf(file, "unsetenv HOSTTYPE\n");
85 2 fprintf(file, "unsetenv VENDOR\n");
86 2 fprintf(file, "unsetenv OSTYPE\n");
87 2 fprintf(file, "unsetenv MACHTYPE\n");
88 2 fprintf(file, "unsetenv SHLVL\n");
89 2 fprintf(file, "unsetenv PWD\n");
90 2 fprintf(file, "unsetenv LOGNAME\n");
91 2 fprintf(file, "unsetenv USER\n");
92 2 fprintf(file, "unsetenv GROUP\n");
93 2 fprintf(file, "unsetenv HOST\n");
94 2 fprintf(file, "unsetenv REMOTEHOST\n");
95 2 fprintf(file, "unsetenv LS_COLORS\n");
96 2 fprintf(file, "unsetenv NOTE\n");
97 2 fprintf(file, "setenv\n");
98 2 fprintf(file, "exit\n");
99 2 fclose(file);
100 2 freopen("test_input.txt", "r", stdin);
101 2 shell(env);
102 }
103
104 4 Test(environnement4, full_gcorv)
105 {
106 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
107 2 FILE *file = fopen("test_input.txt", "w");
108
109 2 fprintf(file, "setenv PATH /\n");
110 2 fprintf(file, "ls\n");
111 2 fprintf(file, "exit\n");
112 2 fclose(file);
113 2 freopen("test_input.txt", "r", stdin);
114 2 shell(env);
115 }
116
117 4 Test(environnement5, full_gcorv)
118 {
119 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
120 2 FILE *file = fopen("test_input.txt", "w");
121
122 2 fprintf(file, "unsetenv _ HOSTTYPE VENDOR OSTYPE MACHTYPE SHLVL PWD LOGNAME USER GROUP HOST REMOTEHOST LS_COLORS NOTE MYSH\n");
123 2 fprintf(file, "env\n");
124 2 fprintf(file, "exit\n");
125 2 fclose(file);
126 2 freopen("test_input.txt", "r", stdin);
127 2 shell(env);
128 }
129
130 4 Test(environnement6, full_gcorv)
131 {
132 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
133 2 FILE *file = fopen("test_input.txt", "w");
134
135 2 fprintf(file, "env | grep PATH\n");
136 2 fprintf(file, "exit\n");
137 2 fclose(file);
138 2 freopen("test_input.txt", "r", stdin);
139 2 shell(env);
140 }
141
142 4 Test(environnement7, full_gcorv)
143 {
144 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
145 2 FILE *file = fopen("test_input.txt", "w");
146
147 2 fprintf(file, "unsetenv *_*\n");
148 2 fprintf(file, "env\n");
149 2 fprintf(file, "unsetenv *\n");
150 2 fprintf(file, "env\n");
151 2 fprintf(file, "exit\n");
152 2 fclose(file);
153 2 freopen("test_input.txt", "r", stdin);
154 2 shell(env);
155 }
156
157 4 Test(environnement8, full_gcorv)
158 {
159 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
160 2 FILE *file = fopen("test_input.txt", "w");
161
162 2 fprintf(file, "setenv 42sh 42sh 42sh\n");
163 2 fprintf(file, "exit\n");
164 2 fclose(file);
165 2 freopen("test_input.txt", "r", stdin);
166 2 shell(env);
167 }
168
169 4 Test(environnement9, full_gcorv)
170 {
171 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
172 2 FILE *file = fopen("test_input.txt", "w");
173
174 2 fprintf(file, "unsetenv\n");
175 2 fprintf(file, "exit\n");
176 2 fclose(file);
177 2 freopen("test_input.txt", "r", stdin);
178 2 shell(env);
179 }
180
181 4 Test(environnement10, full_gcorv)
182 {
183 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
184 2 FILE *file = fopen("test_input.txt", "w");
185
186 2 fprintf(file, "setenv 42sh 42sh\n");
187 2 fprintf(file, "exit\n");
188 2 fclose(file);
189 2 freopen("test_input.txt", "r", stdin);
190 2 shell(env);
191 }
192
193 4 Test(environnement11, full_gcorv)
194 {
195 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
196 2 FILE *file = fopen("test_input.txt", "w");
197
198 2 fprintf(file, "setenv sh:42 42\n");
199 2 fprintf(file, "exit\n");
200 2 fclose(file);
201 2 freopen("test_input.txt", "r", stdin);
202 2 shell(env);
203 }
204