dependency_on_destroyed_task.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. #ifdef STARPU_HAVE_VALGRIND_H
  14. int
  15. main(void)
  16. {
  17. return STARPU_TEST_SKIPPED;
  18. }
  19. #else
  20. static void abort_catcher(int sig)
  21. {
  22. (void) sig;
  23. starpu_shutdown();
  24. /* Here, failure is success. */
  25. exit(EXIT_SUCCESS);
  26. }
  27. int
  28. main(void)
  29. {
  30. int ret;
  31. struct starpu_task *taskA, *taskB;
  32. ret = starpu_init(NULL);
  33. if (ret == -ENODEV)
  34. {
  35. return STARPU_TEST_SKIPPED;
  36. }
  37. taskA = starpu_task_create();
  38. taskA->cl = NULL;
  39. taskA->detach = 0;
  40. taskB = starpu_task_create();
  41. taskB->cl = NULL;
  42. ret = starpu_task_submit(taskA);
  43. if (ret == -ENODEV)
  44. {
  45. starpu_shutdown();
  46. return STARPU_TEST_SKIPPED;
  47. }
  48. ret = starpu_task_wait(taskA);
  49. if (ret != 0)
  50. {
  51. starpu_shutdown();
  52. return EXIT_FAILURE;
  53. }
  54. /* taskA should have been destroyed by now. */
  55. struct sigaction sa;
  56. memset(&sa, 0, sizeof(sa));
  57. sa.sa_handler = abort_catcher;
  58. sigaction(SIGABRT, &sa, NULL);
  59. sigaction(SIGSEGV, &sa, NULL);
  60. starpu_task_declare_deps_array(taskB, 1, &taskA);
  61. ret = starpu_task_submit(taskB);
  62. if (ret == -ENODEV)
  63. {
  64. starpu_shutdown();
  65. return EXIT_FAILURE;
  66. }
  67. starpu_task_wait_for_all();
  68. starpu_shutdown();
  69. return EXIT_FAILURE;
  70. }
  71. #endif