Browse Source

Add a test that makes sure StarPU fails to make one task depend on a previously destroyed task.

Cyril Roelandt 13 years ago
parent
commit
d37d762bd9
2 changed files with 79 additions and 0 deletions
  1. 1 0
      tests/Makefile.am
  2. 78 0
      tests/main/dependency_on_destroyed_task.c

+ 1 - 0
tests/Makefile.am

@@ -109,6 +109,7 @@ starpu_machine_display_SOURCES	=	../tools/starpu_machine_display.c
 
 noinst_PROGRAMS =				\
 	starpu_machine_display			\
+	main/dependency_on_destroyed_task       \
 	main/deprecated_func			\
 	main/deprecated_buffer			\
 	main/restart				\

+ 78 - 0
tests/main/dependency_on_destroyed_task.c

@@ -0,0 +1,78 @@
+#include <signal.h>
+#include <stdlib.h>
+
+#include "../helper.h"
+
+/*
+ * It is possible to depend on a task that is over, but not on a task that has
+ * already been destroyed. In this test, we make sure things go wrong if taskB
+ * depends upon the destroyed taskA. It should trigger STARPU_ASSERT or
+ * STARPU_ABORT somewhere in StarPU, so we can try and cath SIGABRT. Note that
+ * the error might be weirder, leading this test to fail. In this case, it is
+ * probably OK to disable it for a while :-) Maybe we could also detect
+ * destroyed tasks in starpu_task_declare_deps_array.
+ */
+static void abort_catcher(int sig)
+{
+	(void) sig;
+	starpu_shutdown();
+
+	/* Here, failure is success. */
+	exit(EXIT_SUCCESS);
+} 
+
+int
+main(void)
+{
+	int ret;
+	struct starpu_task *taskA, *taskB;
+
+	ret = starpu_init(NULL);
+	if (ret == -ENODEV)
+	{
+		return STARPU_TEST_SKIPPED;
+	}
+
+	taskA = starpu_task_create();
+	taskA->cl = NULL;
+	taskA->detach = 0;
+
+	taskB = starpu_task_create();
+	taskB->cl = NULL;
+
+
+	ret = starpu_task_submit(taskA);
+	if (ret == -ENODEV)
+	{
+		starpu_shutdown();
+		return STARPU_TEST_SKIPPED;
+	}
+
+	ret = starpu_task_wait(taskA);
+	if (ret != 0)
+	{
+		starpu_shutdown();
+		return EXIT_FAILURE;
+	}
+
+	/* taskA should have been destroyed by now. */
+	struct sigaction sa;
+	sa.sa_handler = abort_catcher;
+	sigaction(SIGABRT, &sa, NULL);
+	sigaction(SIGSEGV, &sa, NULL);
+
+	starpu_task_declare_deps_array(taskB, 1, &taskA);
+
+	ret = starpu_task_submit(taskB);
+	if (ret == -ENODEV)
+	{
+		starpu_shutdown();
+		return EXIT_FAILURE;
+	}
+
+	starpu_task_wait_for_all();
+	starpu_shutdown();
+
+	return EXIT_FAILURE;
+}
+