GCC Code Coverage Report


Directory: ./
File: tests/functional_test_where.c
Date: 2024-05-07 14:54:03
Exec Total Coverage
Lines: 24 93 25.8%
Functions: 6 20 30.0%
Branches: 0 0 -%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2024
3 ** 42sh
4 ** File description:
5 ** The where.ini
6 */
7
8 #include "criterion/criterion.h"
9 #include "criterion/redirect.h"
10 #include "../include/myshell.h"
11
12 4 Test(where1, 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, "where 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 Test(where2, full_gcorv)
25 {
26 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
27 FILE *file = fopen("test_input.txt", "w");
28
29 fprintf(file, "where ls grep pwd\n");
30 fprintf(file, "exit\n");
31 fclose(file);
32 freopen("test_input.txt", "r", stdin);
33 shell(env);
34 }
35
36 Test(where3, full_gcorv)
37 {
38 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
39 FILE *file = fopen("test_input.txt", "w");
40
41 fprintf(file, "where cd\n");
42 fprintf(file, "exit\n");
43 fclose(file);
44 freopen("test_input.txt", "r", stdin);
45 shell(env);
46 }
47
48 Test(where4, full_gcorv)
49 {
50 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
51 FILE *file = fopen("test_input.txt", "w");
52
53 fprintf(file, "where /usr/bin/ls\n");
54 fprintf(file, "exit\n");
55 fclose(file);
56 freopen("test_input.txt", "r", stdin);
57 shell(env);
58 }
59
60 Test(where5, full_gcorv)
61 {
62 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
63 FILE *file = fopen("test_input.txt", "w");
64
65 fprintf(file, "alias l ls -l\n");
66 fprintf(file, "where l\n");
67 fprintf(file, "exit\n");
68 fclose(file);
69 freopen("test_input.txt", "r", stdin);
70 shell(env);
71 }
72
73 Test(where6, full_gcorv)
74 {
75 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
76 FILE *file = fopen("test_input.txt", "w");
77
78 fprintf(file, "alias ls ls -l\n");
79 fprintf(file, "where ls\n");
80 fprintf(file, "exit\n");
81 fclose(file);
82 freopen("test_input.txt", "r", stdin);
83 shell(env);
84 }
85
86 Test(where7, full_gcorv)
87 {
88 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
89 FILE *file = fopen("test_input.txt", "w");
90
91 fprintf(file, "unsetenv PATH\n");
92 fprintf(file, "where ls\n");
93 fprintf(file, "exit\n");
94 fclose(file);
95 freopen("test_input.txt", "r", stdin);
96 shell(env);
97 }
98
99 4 Test(where8, full_gcorv)
100 {
101 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=", " ;");
102 2 FILE *file = fopen("test_input.txt", "w");
103
104 2 fprintf(file, "where ls\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(where9, 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, "where\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 Test(where10, full_gcorv)
124 {
125 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
126 FILE *file = fopen("test_input.txt", "w");
127
128 fprintf(file, "where 42sh\n");
129 fprintf(file, "exit\n");
130 fclose(file);
131 freopen("test_input.txt", "r", stdin);
132 shell(env);
133 }
134