GCC Code Coverage Report


Directory: ./
File: tests/functional_test_commands.c
Date: 2024-06-05 00:36:48
Exec Total Coverage
Lines: 88 98 89.8%
Functions: 20 20 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2024
3 ** 42sh
4 ** File description:
5 ** The commands.ini
6 */
7
8 #include "criterion/criterion.h"
9 #include "criterion/redirect.h"
10 #include "../include/myshell.h"
11
12 4 Test(commands1, 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, "cat /etc/resolv.conf\n");
18 2 fprintf(file, "ls -l /bin\n");
19 2 fprintf(file, "pwd\n");
20 2 fprintf(file, "exit\n");
21 2 fclose(file);
22 2 freopen("test_input.txt", "r", stdin);
23 2 shell(env);
24 }
25
26 4 Test(commands2, full_gcorv)
27 {
28 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
29 2 FILE *file = fopen("test_input.txt", "w");
30
31 2 fprintf(file, "ls\n");
32 2 fprintf(file, "pwd\n");
33 2 fprintf(file, "ls -l\n");
34 2 fprintf(file, "exit\n");
35 2 fclose(file);
36 2 freopen("test_input.txt", "r", stdin);
37 2 shell(env);
38 }
39
40 4 Test(commands3, full_gcorv)
41 {
42 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
43 2 FILE *file = fopen("test_input.txt", "w");
44
45 2 fprintf(file, "/usr/bin/ls\n");
46 2 fprintf(file, "exit\n");
47 2 fclose(file);
48 2 freopen("test_input.txt", "r", stdin);
49 2 shell(env);
50 }
51
52 4 Test(commands4, full_gcorv)
53 {
54 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
55 2 FILE *file = fopen("test_input.txt", "w");
56
57 2 fprintf(file, "\"ls\"\n");
58 2 fprintf(file, "\'ls\'\n");
59 2 fprintf(file, "ls\n");
60 2 fprintf(file, "exit\n");
61 2 fclose(file);
62 2 freopen("test_input.txt", "r", stdin);
63 2 shell(env);
64 }
65
66 4 Test(commands5, full_gcorv)
67 {
68 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
69 2 FILE *file = fopen("test_input.txt", "w");
70
71 2 fprintf(file, "./42sh\n");
72 2 fprintf(file, "ls\n");
73 2 fprintf(file, "ls\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(commands6, 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, "42sh\n");
86 2 fprintf(file, "exit\n");
87 2 fclose(file);
88 2 freopen("test_input.txt", "r", stdin);
89 2 shell(env);
90 }
91
92 4 Test(commands7, full_gcorv)
93 {
94 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
95 2 FILE *file = fopen("test_input.txt", "w");
96
97 2 fprintf(file, "/ls\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(commands8, 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, "./Makefile\n");
110 2 fprintf(file, "exit\n");
111 2 fclose(file);
112 2 freopen("test_input.txt", "r", stdin);
113 2 shell(env);
114 }
115
116 4 Test(commands9, full_gcorv)
117 {
118 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
119 2 FILE *file = fopen("test_input.txt", "w");
120
121 2 fprintf(file, "./include\n");
122 2 fprintf(file, "exit\n");
123 2 fclose(file);
124 2 freopen("test_input.txt", "r", stdin);
125 2 shell(env);
126 }
127
128 4 Test(commands10, full_gcorv)
129 {
130 2 char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;");
131 2 FILE *file = fopen("test_input.txt", "w");
132
133 2 fprintf(file, "cdenv\n");
134 2 fprintf(file, "exit\n");
135 2 fclose(file);
136 2 freopen("test_input.txt", "r", stdin);
137 2 shell(env);
138 }
139