123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #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
-
- START_TEST(test_embed)
- {
- asmsh_t sh;
- ck_assert_int_eq(asmsh_init(&sh, NULL), 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);
-
-
- }
- 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_ADD_TEST(test_embed);
- ASMSH_CHECK_END
|