Line |
Branch |
Exec |
Source |
1 |
|
|
/* |
2 |
|
|
** EPITECH PROJECT, 2024 |
3 |
|
|
** 42sh |
4 |
|
|
** File description: |
5 |
|
|
** The operators.ini |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
#include "criterion/criterion.h" |
9 |
|
|
#include "criterion/redirect.h" |
10 |
|
|
#include "../include/myshell.h" |
11 |
|
|
|
12 |
|
4 |
Test(operators1, 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 -l && pwd && ls -l && ls -l\n"); |
18 |
|
2 |
fprintf(file, "ls && setenv TEST test\n"); |
19 |
|
2 |
fprintf(file, "cd / && ls\n"); |
20 |
|
2 |
fprintf(file, "pwd && echo Current path\n"); |
21 |
|
2 |
fprintf(file, "echo test && pwd\n"); |
22 |
|
2 |
fprintf(file, "cat test && pwd\n"); |
23 |
|
2 |
fprintf(file, "exit\n"); |
24 |
|
2 |
fclose(file); |
25 |
|
2 |
freopen("test_input.txt", "r", stdin); |
26 |
|
2 |
shell(env); |
27 |
|
✗ |
} |
28 |
|
|
|
29 |
|
4 |
Test(operators2, full_gcorv) |
30 |
|
|
{ |
31 |
|
2 |
char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;"); |
32 |
|
2 |
FILE *file = fopen("test_input.txt", "w"); |
33 |
|
|
|
34 |
|
2 |
fprintf(file, "ls -l || pwd || ls -l || ls -l\n"); |
35 |
|
2 |
fprintf(file, "ls || /usr/bin/ls\n"); |
36 |
|
2 |
fprintf(file, "cd / || pwd\n"); |
37 |
|
2 |
fprintf(file, "echo OK || echo Hello World\n"); |
38 |
|
2 |
fprintf(file, "cat test || echo File not found\n"); |
39 |
|
2 |
fprintf(file, "exit\n"); |
40 |
|
2 |
fclose(file); |
41 |
|
2 |
freopen("test_input.txt", "r", stdin); |
42 |
|
2 |
shell(env); |
43 |
|
✗ |
} |
44 |
|
|
|
45 |
|
4 |
Test(operators3, full_gcorv) |
46 |
|
|
{ |
47 |
|
2 |
char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;"); |
48 |
|
2 |
FILE *file = fopen("test_input.txt", "w"); |
49 |
|
|
|
50 |
|
2 |
fprintf(file, "ls -l && pwd || ls -l && ls -l\n"); |
51 |
|
2 |
fprintf(file, "ls -l || pwd && ls -l || ls -l\n"); |
52 |
|
2 |
fprintf(file, "ls -l && pwd || ls -l && ls -l && pwd\n"); |
53 |
|
2 |
fprintf(file, "42sh && pwd || ls\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(operators4, 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, "&& ls\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(operators5, 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, "ls &&\n"); |
78 |
|
2 |
fprintf(file, "exit\n"); |
79 |
|
2 |
fclose(file); |
80 |
|
2 |
freopen("test_input.txt", "r", stdin); |
81 |
|
2 |
shell(env); |
82 |
|
✗ |
} |
83 |
|
|
|
84 |
|
4 |
Test(operators6, full_gcorv) |
85 |
|
|
{ |
86 |
|
2 |
char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;"); |
87 |
|
2 |
FILE *file = fopen("test_input.txt", "w"); |
88 |
|
|
|
89 |
|
2 |
fprintf(file, "|| ls\n"); |
90 |
|
2 |
fprintf(file, "exit\n"); |
91 |
|
2 |
fclose(file); |
92 |
|
2 |
freopen("test_input.txt", "r", stdin); |
93 |
|
2 |
shell(env); |
94 |
|
✗ |
} |
95 |
|
|
|
96 |
|
4 |
Test(operators7, full_gcorv) |
97 |
|
|
{ |
98 |
|
2 |
char **env = my_str_to_word_array_select("TERM=xterm ; PATH=/bin:/usr/bin", " ;"); |
99 |
|
2 |
FILE *file = fopen("test_input.txt", "w"); |
100 |
|
|
|
101 |
|
2 |
fprintf(file, "ls ||\n"); |
102 |
|
2 |
fprintf(file, "exit\n"); |
103 |
|
2 |
fclose(file); |
104 |
|
2 |
freopen("test_input.txt", "r", stdin); |
105 |
|
2 |
shell(env); |
106 |
|
✗ |
} |
107 |
|
|
|