Browse Source

Add a Coccinelle script that should be able to fix the return values of our tests.

In the main() function :
* replaces "return 77;" by "return STARPU_TEST_SKIPPED;"
* replaces "return 0;" by "return EXIT_SUCCESS;"

The output is sometimes quite ugly, though.
Cyril Roelandt 13 years ago
parent
commit
b1e69671e0

+ 39 - 0
tools/dev/experimental/test_return_values.cocci

@@ -0,0 +1,39 @@
+// I have no idea in Hell why we need "<... ...>", but this will not work with
+// "... ..."
+@@
+@@
+main(...)
+{
+<...
+-	return 0;
++	return EXIT_SUCCESS;
+...>
+}
+
+
+//
+// Is (..)*/common/helper.h included ?
+// XXX : OK, that suxx, but it should work. Is there a way to use a regular
+// expression to match a header ?
+@helper_included@
+@@
+(
+#include "common/helper.h"
+|
+#include "../common/helper.h"
+|
+#include "../../common/helper.h"
+|
+#include "../../../common/helper.h"
+)
+
+
+@depends on helper_included@
+@@
+main(...)
+{
+...
+-	return 77;
++	return STARPU_TEST_SKIPPED;
+...
+}

+ 34 - 0
tools/dev/experimental/test_return_values_test.c

@@ -0,0 +1,34 @@
+#include "../common/helper.h"
+
+static int
+return_77(void)
+{
+	return 77; /* Leave this statement alone ! */
+}
+
+int
+main(void)
+{
+	if (foo)
+	{
+		return 77; /* => return STARPU_TEST_SKIPPED; */
+	}
+	return 77; /* => return STARPU_TEST_SKIPPED; */
+}
+
+int
+main(void)
+{
+	if (bar)
+		return 0; /* => return EXIT_SUCCESS; */
+
+	/* XXX : This works, but the output is ugly :
+	 *
+	 * + return STARPU_TEST_SKIPPED; return STARPU_TEST_SKIPPED;
+	 */
+	if (foo)
+		return 77; /* => return STARPU_TEST_SKIPPED; */
+
+	return 77; /* => return STARPU_TEST_SKIPPED; */
+}
+