12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #include "config.h"
- #include <check.h>
- #include <errno.h>
- #include <stdio.h>
- #include <string.h>
- #include <unistd.h>
-
- #include "asmsh_check.h"
- #include "shell.h"
-
- START_TEST(test_init)
- {
- asmsh_t sh;
- ck_assert_int_eq(asmsh_init(&sh, CHILD_PATH), 0);
- asmsh_cleanup(&sh);
- }
- END_TEST
-
- START_TEST(test_exit)
- {
- asmsh_t sh;
- ck_assert_int_eq(asmsh_init(&sh, CHILD_PATH), 0);
- ck_assert_int_eq(asmsh_exec(&sh, "mov $60, %rax"), 0);
- ck_assert_int_eq(asmsh_exec(&sh, "xor %rdi, %rdi"), 0);
- ck_assert_int_eq(asmsh_exec(&sh, "syscall"), 1);
- asmsh_cleanup(&sh);
-
- ck_assert_int_eq(asmsh_init(&sh, CHILD_PATH), 0);
- ck_assert_int_eq(asmsh_exec(&sh, "mov $60, %rax"), 0);
- ck_assert_int_eq(asmsh_exec(&sh, "mov $0x29, %rdi"), 0);
- ck_assert_int_eq(asmsh_exec(&sh, "syscall"), 42);
- asmsh_cleanup(&sh);
- }
- END_TEST
-
- START_TEST(test_cmd)
- {
- asmsh_t sh;
- ck_assert_int_eq(asmsh_init(&sh, CHILD_PATH), 0);
- ck_assert_int_eq(asmsh_exec(&sh, ".reg"), 0);
- ck_assert_int_eq(asmsh_exec(&sh, ".q"), 1);
- asmsh_cleanup(&sh);
-
- }
- END_TEST
-
- ASMSH_CHECK_START("Testing shell", "testing shell init/exec functions")
- ASMSH_ADD_TEST(test_init);
- ASMSH_ADD_TEST(test_exit);
- ASMSH_ADD_TEST(test_cmd);
- ASMSH_CHECK_END
|