Line |
Branch |
Exec |
Source |
1 |
|
|
/* |
2 |
|
|
** EPITECH PROJECT, 2024 |
3 |
|
|
** 42sh |
4 |
|
|
** File description: |
5 |
|
|
** The cd.ini |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
#include "criterion/criterion.h" |
9 |
|
|
#include "criterion/redirect.h" |
10 |
|
|
#include "../include/myshell.h" |
11 |
|
|
|
12 |
|
4 |
Test(cd1, 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, "cd include\n"); |
18 |
|
2 |
fprintf(file, "pwd\n"); |
19 |
|
2 |
fprintf(file, "exit\n"); |
20 |
|
2 |
fclose(file); |
21 |
|
2 |
freopen("test_input.txt", "r", stdin); |
22 |
|
2 |
shell(env); |
23 |
|
✗ |
} |
24 |
|
|
|
25 |
|
4 |
Test(cd2, full_gcorv) |
26 |
|
|
{ |
27 |
|
2 |
char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;"); |
28 |
|
2 |
FILE *file = fopen("test_input.txt", "w"); |
29 |
|
|
|
30 |
|
2 |
fprintf(file, "cd ..\n"); |
31 |
|
2 |
fprintf(file, "pwd\n"); |
32 |
|
2 |
fprintf(file, "exit\n"); |
33 |
|
2 |
fclose(file); |
34 |
|
2 |
freopen("test_input.txt", "r", stdin); |
35 |
|
2 |
shell(env); |
36 |
|
✗ |
} |
37 |
|
|
|
38 |
|
4 |
Test(cd3, full_gcorv) |
39 |
|
|
{ |
40 |
|
2 |
char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;"); |
41 |
|
2 |
FILE *file = fopen("test_input.txt", "w"); |
42 |
|
|
|
43 |
|
2 |
fprintf(file, "cd\n"); |
44 |
|
2 |
fprintf(file, "pwd\n"); |
45 |
|
2 |
fprintf(file, "cd ..\n"); |
46 |
|
2 |
fprintf(file, "pwd\n"); |
47 |
|
2 |
fprintf(file, "cd ~\n"); |
48 |
|
2 |
fprintf(file, "pwd\n"); |
49 |
|
2 |
fprintf(file, "exit\n"); |
50 |
|
2 |
fclose(file); |
51 |
|
2 |
freopen("test_input.txt", "r", stdin); |
52 |
|
2 |
shell(env); |
53 |
|
✗ |
} |
54 |
|
|
|
55 |
|
4 |
Test(cd4, full_gcorv) |
56 |
|
|
{ |
57 |
|
2 |
char **env = my_str_to_word_array_select("", " ;"); |
58 |
|
2 |
FILE *file = fopen("test_input.txt", "w"); |
59 |
|
|
|
60 |
|
2 |
fprintf(file, "cd ..\n"); |
61 |
|
2 |
fprintf(file, "pwd\n"); |
62 |
|
2 |
fprintf(file, "cd -\n"); |
63 |
|
2 |
fprintf(file, "pwd\n"); |
64 |
|
2 |
fprintf(file, "exit\n"); |
65 |
|
2 |
fclose(file); |
66 |
|
2 |
freopen("test_input.txt", "r", stdin); |
67 |
|
2 |
shell(env); |
68 |
|
✗ |
} |
69 |
|
|
|
70 |
|
4 |
Test(cd5, full_gcorv) |
71 |
|
|
{ |
72 |
|
2 |
char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;"); |
73 |
|
2 |
FILE *file = fopen("test_input.txt", "w"); |
74 |
|
|
|
75 |
|
2 |
fprintf(file, "cd 42sh 42sh 42sh\n"); |
76 |
|
2 |
fprintf(file, "exit\n"); |
77 |
|
2 |
fclose(file); |
78 |
|
2 |
freopen("test_input.txt", "r", stdin); |
79 |
|
2 |
shell(env); |
80 |
|
✗ |
} |
81 |
|
|
|
82 |
|
4 |
Test(cd6, full_gcorv) |
83 |
|
|
{ |
84 |
|
2 |
char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;"); |
85 |
|
2 |
FILE *file = fopen("test_input.txt", "w"); |
86 |
|
|
|
87 |
|
2 |
fprintf(file, "cd /root\n"); |
88 |
|
2 |
fprintf(file, "exit\n"); |
89 |
|
2 |
fclose(file); |
90 |
|
2 |
freopen("test_input.txt", "r", stdin); |
91 |
|
2 |
shell(env); |
92 |
|
✗ |
} |
93 |
|
|
|
94 |
|
|
/* |
95 |
|
|
Test(cd7, full_gcorv) |
96 |
|
|
{ |
97 |
|
|
char **env = my_str_to_word_array_select("", " ;"); |
98 |
|
|
FILE *file = fopen("test_input.txt", "w"); |
99 |
|
|
|
100 |
|
|
fprintf(file, "cd\n"); |
101 |
|
|
fprintf(file, "exit\n"); |
102 |
|
|
fclose(file); |
103 |
|
|
freopen("test_input.txt", "r", stdin); |
104 |
|
|
shell(env); |
105 |
|
|
} |
106 |
|
|
|
107 |
|
|
Test(cd8, full_gcorv) |
108 |
|
|
{ |
109 |
|
|
char **env = my_str_to_word_array_select("", " ;"); |
110 |
|
|
FILE *file = fopen("test_input.txt", "w"); |
111 |
|
|
|
112 |
|
|
fprintf(file, "cd ~\n"); |
113 |
|
|
fprintf(file, "exit\n"); |
114 |
|
|
fclose(file); |
115 |
|
|
freopen("test_input.txt", "r", stdin); |
116 |
|
|
shell(env); |
117 |
|
|
}*/ |
118 |
|
|
|
119 |
|
4 |
Test(cd9, full_gcorv) |
120 |
|
|
{ |
121 |
|
2 |
char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;"); |
122 |
|
2 |
FILE *file = fopen("test_input.txt", "w"); |
123 |
|
|
|
124 |
|
2 |
fprintf(file, "setenv HOME /home\n"); |
125 |
|
2 |
fprintf(file, "cd\n"); |
126 |
|
2 |
fprintf(file, "pwd\n"); |
127 |
|
2 |
fprintf(file, "cd ..\n"); |
128 |
|
2 |
fprintf(file, "unsetenv HOME\n"); |
129 |
|
2 |
fprintf(file, "cd\n"); |
130 |
|
2 |
fprintf(file, "exit\n"); |
131 |
|
2 |
fclose(file); |
132 |
|
2 |
freopen("test_input.txt", "r", stdin); |
133 |
|
2 |
shell(env); |
134 |
|
✗ |
} |
135 |
|
|
|
136 |
|
4 |
Test(cd10, full_gcorv) |
137 |
|
|
{ |
138 |
|
2 |
char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;"); |
139 |
|
2 |
FILE *file = fopen("test_input.txt", "w"); |
140 |
|
|
|
141 |
|
2 |
fprintf(file, "unsetenv OLDPWD\n"); |
142 |
|
2 |
fprintf(file, "cd -\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(cd11, 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, "cd *\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 |
|
|
|