Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Alexandru Dura
pintos-public
Commits
7d46732f
Commit
7d46732f
authored
Mar 27, 2021
by
Alexandru Dura
Browse files
Tests for cd
parent
07735963
Changes
1
Hide whitespace changes
Inline
Side-by-side
shell/shell-test.c
View file @
7d46732f
...
...
@@ -77,6 +77,10 @@ int send_command(const char *cmd, char *result, size_t result_size, int sleep_se
if (t < 0) { \
printf("Error while sending commands to the shell."); \
} \
char *n = strchr(result_buf, '\n'); \
if (n) {\
*n = 0; \
}\
if (strcmp(result_buf, expected)) {\
++n_fail;\
printf("[FAIL] Expected '%s', but got '%s'.\n", expected, result_buf); \
...
...
@@ -123,9 +127,16 @@ int main(int argc, char **argv) {
TEST
(
"cat < file1.txt
\n
"
,
"line1"
);
TEST
(
"cat file1.txt | wc -l
\n
"
,
"1"
);
TEST
(
"cat file1.txt | cat | cat | cat | cat | wc -l
\n
"
,
"1"
);
TEST
(
"mkdir dir1
\n
"
,
""
);
TEST
(
"cd dir1
\n
"
,
""
);
TEST
(
"ls
\n
"
,
""
);
TEST
(
"cd -
\n
"
,
cwd
);
TEST
(
"pwd
\n
"
,
cwd
);
close
(
in
);
int
wstatus
;
waitpid
(
shell_pid
,
&
wstatus
,
0
);
printf
(
"================================================================================
\n
"
);
printf
(
"%d tests PASSED, %d tests FAILED.
\n
"
,
n_pass
,
n_fail
);
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment