tests_pass_without_features.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #include <tools/ccanlint/ccanlint.h>
  2. #include <tools/tools.h>
  3. #include <ccan/str/str.h>
  4. #include <ccan/foreach/foreach.h>
  5. #include <sys/types.h>
  6. #include <sys/stat.h>
  7. #include <fcntl.h>
  8. #include <unistd.h>
  9. #include <limits.h>
  10. #include <errno.h>
  11. #include <stdlib.h>
  12. #include <stdio.h>
  13. #include <err.h>
  14. #include <string.h>
  15. #include <ctype.h>
  16. /* We don't do these under valgrind: too slow! */
  17. static void do_run_tests_no_features(struct manifest *m,
  18. unsigned int *timeleft,
  19. struct score *score)
  20. {
  21. struct list_head *list;
  22. struct ccan_file *i;
  23. char *cmdout;
  24. score->total = 0;
  25. foreach_ptr(list, &m->run_tests, &m->api_tests) {
  26. list_for_each(list, i, list) {
  27. score->total++;
  28. if (verbose >= 2)
  29. printf(" %s\n", i->name);
  30. if (run_command(m, timeleft, &cmdout, "%s",
  31. i->compiled[COMPILE_NOFEAT]))
  32. score->score++;
  33. else
  34. score_file_error(score, i, 0, "%s", cmdout);
  35. }
  36. }
  37. if (score->score == score->total)
  38. score->pass = true;
  39. }
  40. /* Gcc's warn_unused_result is fascist bullshit. */
  41. #define doesnt_matter()
  42. static void run_under_debugger(struct manifest *m, struct score *score)
  43. {
  44. char *command;
  45. struct file_error *first;
  46. first = list_top(&score->per_file_errors, struct file_error, list);
  47. if (!ask("Should I run the first failing test under the debugger?"))
  48. return;
  49. command = tal_fmt(m, "gdb -ex 'break tap.c:139' -ex 'run' %s",
  50. first->file->compiled[COMPILE_NOFEAT]);
  51. if (system(command))
  52. doesnt_matter();
  53. }
  54. struct ccanlint tests_pass_without_features = {
  55. .key = "tests_pass_without_features",
  56. .name = "Module's run and api tests pass (without features)",
  57. .check = do_run_tests_no_features,
  58. .handle = run_under_debugger,
  59. .needs = "tests_compile_without_features"
  60. };
  61. REGISTER_TEST(tests_pass_without_features);