Browse Source

tests/datawizard/interfaces: use enum exit_code type when possible

Nathalie Furmento 13 years ago
parent
commit
25b7f47c18

+ 3 - 3
tests/datawizard/interfaces/bcsr/bcsr_interface.c

@@ -83,7 +83,7 @@ struct test_config bcsr_config =
 #endif /* !STARPU_USE_OPENCL */
 	.handle        = &bcsr_handle,
 	.dummy_handle  = &bcsr2_handle,
-	.copy_failed   = 0,
+	.copy_failed   = SUCCESS,
 	.name          = "bcsr_interface"
 };
 
@@ -136,7 +136,7 @@ test_bcsr_cpu_func(void *buffers[], void *args)
  	uint32_t c   = ((struct starpu_bcsr_interface *)buffers[0])->c;
 	if (r != R || c != C)
 	{
-		bcsr_config.copy_failed = 1;
+		bcsr_config.copy_failed = FAILURE;
 		return;
 	}
 	nnz *= (r*c);
@@ -148,7 +148,7 @@ test_bcsr_cpu_func(void *buffers[], void *args)
 	{
 		if (val[i] != i * factor)
 		{
-			bcsr_config.copy_failed = 1;
+			bcsr_config.copy_failed = FAILURE;
 			return;
 		}
 		val[i] *= -1;

+ 3 - 3
tests/datawizard/interfaces/block/block_interface.c

@@ -48,7 +48,7 @@ struct test_config block_config =
 #endif
 	.handle        = &block_handle,
 	.dummy_handle  = &block2_handle,
-	.copy_failed   = 0,
+	.copy_failed   = SUCCESS,
 	.name          = "block_interface"
 };
 
@@ -107,7 +107,7 @@ static void test_block_cpu_func(void *buffers[], void *args)
 	int *block = (int *) STARPU_BLOCK_GET_PTR(buffers[0]);
 	unsigned int i, j, k;
 	int val = 0;
-	block_config.copy_failed = 0;
+	block_config.copy_failed = SUCCESS;
 	for (k = 0; k < nz; k++)
 	{
 		for (j = 0; j < ny; j++)
@@ -116,7 +116,7 @@ static void test_block_cpu_func(void *buffers[], void *args)
 			{
                                 if (block[(k*ldz)+(j*ldy)+i] != factor * val)
 				{
-					block_config.copy_failed = 1;
+					block_config.copy_failed = FAILURE;
 					return;
 				}
 				else

+ 2 - 2
tests/datawizard/interfaces/csr/csr_interface.c

@@ -59,7 +59,7 @@ struct test_config csr_config =
 #endif
 	.handle        = &csr_handle,
 	.dummy_handle  = &csr2_handle,
-	.copy_failed   = 0,
+	.copy_failed   = SUCCESS,
 	.name          = "csr_interface"
 };
 
@@ -130,7 +130,7 @@ test_csr_cpu_func(void *buffers[], void *args)
 	{
 		if (val[i] != (i+1) * factor)
 		{
-			csr_config.copy_failed = 1;
+			csr_config.copy_failed = FAILURE;
 			return;
 		}
 		val[i] *= -1;

+ 2 - 2
tests/datawizard/interfaces/matrix/matrix_interface.c

@@ -48,7 +48,7 @@ struct test_config matrix_config =
 #endif
 	.handle        = &matrix_handle,
 	.dummy_handle  = &matrix2_handle,
-	.copy_failed   = 0,
+	.copy_failed   = SUCCESS,
 	.name          = "matrix_interface"
 };
 
@@ -105,7 +105,7 @@ test_matrix_cpu_func(void *buffers[], void *args)
 	{
 		if (val[i] != i * factor)
 		{
-			matrix_config.copy_failed = 1;
+			matrix_config.copy_failed = FAILURE;
 			return;
 		}
 		val[i] *= -1;

+ 2 - 2
tests/datawizard/interfaces/multiformat/multiformat_interface.c

@@ -44,7 +44,7 @@ struct test_config multiformat_config =
 #endif
 	.handle        = &multiformat_handle,
 	.dummy_handle  = &multiformat_dummy_handle,
-	.copy_failed   = 0,
+	.copy_failed   = SUCCESS,
 	.name          = "multiformat_interface"
 };
 
@@ -66,7 +66,7 @@ test_multiformat_cpu_func(void *buffers[], void *args)
 			FPRINTF(stderr, "(%d %d) [%d]", aos[i].x, aos[i].y, factor);
 		if (aos[i].x != i * factor || aos[i].y != i * factor)
 		{
-			multiformat_config.copy_failed = 1;
+			multiformat_config.copy_failed = FAILURE;
 		}
 		aos[i].x = -aos[i].x;
 		aos[i].y = -aos[i].y;

+ 0 - 14
tests/datawizard/interfaces/test_interfaces.c

@@ -33,20 +33,6 @@ static struct test_config *current_config;
 - OpenCL to OpenCL support
 */
 
-/*
- * Users do not know about this enum. They only know that SUCCESS is 0, and
- * FAILURE is 1. Therefore, the values of SUCCESS and FAILURE shall not be
- * changed.
- */
-enum exit_code
-{
-	SUCCESS                 = 0,
-	FAILURE                 = 1,
-	UNTESTED                = 2,
-	TASK_CREATION_FAILURE   = 3,
-	TASK_SUBMISSION_FAILURE = 4
-};
-
 static char *
 enum_to_string(int exit_code)
 {

+ 17 - 2
tests/datawizard/interfaces/test_interfaces.h

@@ -18,6 +18,21 @@
 
 #include "../../helper.h"
 
+/*
+ * Users do not know about this enum. They only know that SUCCESS is 0, and
+ * FAILURE is 1. Therefore, the values of SUCCESS and FAILURE shall not be
+ * changed.
+ */
+enum exit_code
+{
+	SUCCESS                 = 0,
+	FAILURE                 = 1,
+	UNTESTED                = 2,
+	TASK_CREATION_FAILURE   = 3,
+	TASK_SUBMISSION_FAILURE = 4
+};
+
+
 struct test_config
 {
 	/* A pointer to a registered handle */
@@ -41,8 +56,8 @@ struct test_config
 #endif
 
 	/* The previous codelets must update this field at the end of their
-	 * execution. copy_failed must be 1 if the copy failed, 0 otherwise. */
-	int copy_failed;
+	 * execution. copy_failed must be FAILURE if the copy failed, SUCCESS otherwise. */
+	enum exit_code copy_failed;
 
 	/* A human-readable name for the test */
 	const char *name;

+ 2 - 2
tests/datawizard/interfaces/variable/variable_interface.c

@@ -46,7 +46,7 @@ struct test_config variable_config =
 #endif
 	.handle       = &variable_handle,
 	.dummy_handle = &variable2_handle,
-	.copy_failed  = 0,
+	.copy_failed  = SUCCESS,
 	.name         = "variable_interface"
 };
 
@@ -62,7 +62,7 @@ test_variable_cpu_func(void *buffers[], void *args)
 	factor = *(int *)args;
 
 	if (*val != 42 * factor)
-		variable_config.copy_failed = 1;
+		variable_config.copy_failed = FAILURE;
 	else
 		*val *= -1;
 }

+ 2 - 2
tests/datawizard/interfaces/vector/test_vector_interface.c

@@ -44,7 +44,7 @@ struct test_config vector_config =
 #endif
 	.handle        = &vector_handle,
 	.dummy_handle  = &vector2_handle,
-	.copy_failed   = 0,
+	.copy_failed   = SUCCESS,
 	.name          = "vector_interface"
 };
 
@@ -92,7 +92,7 @@ static void test_vector_cpu_func(void *buffers[], void *args)
 	{
 		if (val[i] != i*factor)
 		{
-			vector_config.copy_failed = 1;
+			vector_config.copy_failed = FAILURE;
 			return;
 		}
 		val[i] = -val[i];

+ 1 - 1
tests/datawizard/interfaces/void/void_interface.c

@@ -37,7 +37,7 @@ struct test_config void_config =
 #endif
 	.handle        = &void_handle,
 	.dummy_handle  = &void2_handle,
-	.copy_failed   = 0,
+	.copy_failed   = SUCCESS,
 	.name          = "void_interface"
 };