A shell that runs x86_64 assembly
c
x86-64
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tests_completion.c 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "config.h"
  2. #include <check.h>
  3. #include <errno.h>
  4. #include <stdio.h>
  5. #include <unistd.h>
  6. #include "asmsh_check.h"
  7. #include "completion.h"
  8. const char *icompl_a[] = {"a", "aaa", "aad", "aam", "aas", "adc", "add", "and", "andn", NULL};
  9. const char *icompl_x[] = {"x", "xadd", "xchg", "xlat", "xor", NULL};
  10. const char *icompl_j[] = {"j", "jo", "jno", "jb", "jc", "jnae", "jae", "jnb", "jnc", "je", "jz", "jne", "jnz", "jbe", "jna", "ja", "jnbe", "js", "jns", "jp", "jpe", "jnp", "jpo", "jl", "jnge", "jge", "jnl", "jle", "jng", "jg", "jnle", "jmp", NULL};
  11. const char *icompl_xa[] = {"xr", NULL};
  12. const char *icompl_ro[] = {"ro", "rol", "ror", NULL};
  13. const char *icompl_movs[] = {"movs", "movs", "movsb", "movsw", "movsd", "movsq", "movsx", NULL};
  14. const char *icompl_movb[] = {"movb", "movb", "movbe", NULL};
  15. const char **icompl[] = {icompl_a, icompl_x, icompl_j, icompl_xa, icompl_ro, icompl_movs, icompl_movb};
  16. int icompl_sz = sizeof(icompl)/sizeof(*icompl);
  17. START_TEST(test_instr_completions)
  18. {
  19. const char **curcomp = icompl[_i];
  20. char **ret;
  21. int i;
  22. ret = asmsh_compl_instr(curcomp[0]);
  23. ck_assert_ptr_nonnull(ret);
  24. i=0;
  25. while(1)
  26. {
  27. if(!ret[i] || !curcomp[i+1])
  28. {
  29. ck_assert_ptr_null(ret[i]);
  30. ck_assert_ptr_null(curcomp[i+1]);
  31. break;
  32. }
  33. ck_assert_str_eq(ret[i], curcomp[i+1]);
  34. free(ret[i]);
  35. i++;
  36. }
  37. free(ret);
  38. }
  39. END_TEST
  40. ASMSH_CHECK_START("testing completion", "Testing completion features")
  41. ASMSH_ADD_LOOP_TEST(test_instr_completions, 0, icompl_sz);
  42. ASMSH_CHECK_END