#include "config.h" #include #include #include #include #include #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