Commit 7d46732f authored by Alexandru Dura's avatar Alexandru Dura
Browse files

Tests for cd

parent 07735963
......@@ -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);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment