dependency_on_destroyed_task.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #include <signal.h>
  2. #include <stdlib.h>
  3. #include "../helper.h"
  4. /*
  5. * It is possible to depend on a task that is over, but not on a task that has
  6. * already been destroyed. In this test, we make sure things go wrong if taskB
  7. * depends upon the destroyed taskA. It should trigger STARPU_ASSERT or
  8. * STARPU_ABORT somewhere in StarPU, so we can try and cath SIGABRT. Note that
  9. * the error might be weirder, leading this test to fail. In this case, it is
  10. * probably OK to disable it for a while :-) Maybe we could also detect
  11. * destroyed tasks in starpu_task_declare_deps_array.
  12. */
  13. static void abort_catcher(int sig)
  14. {
  15. (void) sig;
  16. starpu_shutdown();
  17. /* Here, failure is success. */
  18. exit(EXIT_SUCCESS);
  19. }
  20. int
  21. main(void)
  22. {
  23. #ifdef STARPU_HAVE_VALGRIND_H
  24. if (RUNNING_ON_VALGRIND)
  25. return STARPU_TEST_SKIPPED;
  26. #endif
  27. int ret;
  28. struct starpu_task *taskA, *taskB;
  29. ret = starpu_init(NULL);
  30. if (ret == -ENODEV)
  31. {
  32. return STARPU_TEST_SKIPPED;
  33. }
  34. taskA = starpu_task_create();
  35. taskA->cl = NULL;
  36. taskA->detach = 0;
  37. taskB = starpu_task_create();
  38. taskB->cl = NULL;
  39. ret = starpu_task_submit(taskA);
  40. if (ret == -ENODEV)
  41. {
  42. starpu_shutdown();
  43. return STARPU_TEST_SKIPPED;
  44. }
  45. ret = starpu_task_wait(taskA);
  46. if (ret != 0)
  47. {
  48. starpu_shutdown();
  49. return EXIT_FAILURE;
  50. }
  51. /* taskA should have been destroyed by now. */
  52. struct sigaction sa;
  53. memset(&sa, 0, sizeof(sa));
  54. sa.sa_handler = abort_catcher;
  55. sigaction(SIGABRT, &sa, NULL);
  56. sigaction(SIGSEGV, &sa, NULL);
  57. starpu_task_declare_deps_array(taskB, 1, &taskA);
  58. ret = starpu_task_submit(taskB);
  59. if (ret == -ENODEV)
  60. {
  61. starpu_shutdown();
  62. return EXIT_FAILURE;
  63. }
  64. starpu_task_wait_for_all();
  65. starpu_shutdown();
  66. return EXIT_FAILURE;
  67. }