[PATCH 2/2] tests: add version sanity tests

U. Artie Eoff ullysses.a.eoff at intel.com
Fri Jan 24 10:26:18 PST 2014


From: "U. Artie Eoff" <ullysses.a.eoff at intel.com>

Test the WESTON_VERSION_AT_LEAST macro with at least
27 permutations of major.minor.micro.  That is, all
permutations where major, minor, and micro are less-than,
more-than, or equal to the current version parts.

Signed-off-by: U. Artie Eoff <ullysses.a.eoff at intel.com>
---
 tests/Makefile.am    |   8 +-
 tests/version-test.c | 259 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 266 insertions(+), 1 deletion(-)
 create mode 100644 tests/version-test.c

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8b85146..c16c677 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -2,7 +2,8 @@ TESTS = $(shared_tests) $(module_tests) $(weston_tests)
 
 shared_tests = \
 	config-parser.test		\
-	vertex-clip.test
+	vertex-clip.test		\
+	version.test
 
 module_tests =				\
 	surface-test.la			\
@@ -93,6 +94,11 @@ vertex_clip_test_LDADD =	\
 	libtest-runner.la	\
 	-lm -lrt
 
+version_test_SOURCES =		\
+	version-test.c
+version_test_LDADD =		\
+	libtest-runner.la
+
 libtest_client_la_SOURCES =		\
 	weston-test-client-helper.c	\
 	weston-test-client-helper.h	\
diff --git a/tests/version-test.c b/tests/version-test.c
new file mode 100644
index 0000000..40a1cbf
--- /dev/null
+++ b/tests/version-test.c
@@ -0,0 +1,259 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <assert.h>
+#include "version.h"
+#include "weston-test-runner.h"
+
+/* positive results */
+
+TEST(version_equal)
+{
+/* {0,0,0} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR, WESTON_VERSION_MINOR, WESTON_VERSION_MICRO)
+#else
+	assert(0);
+#endif
+}
+
+TEST(version_major_more)
+{
+/* {1,0,0} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR+1, WESTON_VERSION_MINOR, WESTON_VERSION_MICRO)
+#else
+	assert(0);
+#endif
+}
+
+TEST(version_minor_more)
+{
+/* {0,1,0} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR, WESTON_VERSION_MINOR+1, WESTON_VERSION_MICRO)
+#else
+	assert(0);
+#endif
+}
+
+TEST(version_micro_more)
+{
+/* {0,0,1} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR, WESTON_VERSION_MINOR, WESTON_VERSION_MICRO+1)
+#else
+	assert(0);
+#endif
+}
+
+TEST(version_major_more_minor_more)
+{
+/* {1,1,0} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR+1, WESTON_VERSION_MINOR+1, WESTON_VERSION_MICRO)
+#else
+	assert(0);
+#endif
+}
+
+TEST(version_major_more_micro_more)
+{
+/* {1,0,1} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR+1, WESTON_VERSION_MINOR, WESTON_VERSION_MICRO+1)
+#else
+	assert(0);
+#endif
+}
+
+TEST(version_minor_more_micro_more)
+{
+/* {0,1,1} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR, WESTON_VERSION_MINOR+1, WESTON_VERSION_MICRO+1)
+#else
+	assert(0);
+#endif
+}
+
+TEST(version_major_more_minor_less)
+{
+/* {1,-1,0} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR+1, WESTON_VERSION_MINOR-1, WESTON_VERSION_MICRO)
+#else
+	assert(0);
+#endif
+}
+
+TEST(version_major_more_micro_less)
+{
+/* {1,0,-1} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR+1, WESTON_VERSION_MINOR, WESTON_VERSION_MICRO-1)
+#else
+	assert(0);
+#endif
+}
+
+TEST(version_minor_more_micro_less)
+{
+/* {0,1,-1} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR, WESTON_VERSION_MINOR+1, WESTON_VERSION_MICRO-1)
+#else
+	assert(0);
+#endif
+}
+
+TEST(version_major_more_minor_less_micro_less)
+{
+/* {1,-1,-1} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR+1, WESTON_VERSION_MINOR-1, WESTON_VERSION_MICRO-1)
+#else
+	assert(0);
+#endif
+}
+
+TEST(version_major_more_minor_less_micro_more)
+{
+/* {1,-1,1} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR+1, WESTON_VERSION_MINOR-1, WESTON_VERSION_MICRO+1)
+#else
+	assert(0);
+#endif
+}
+
+TEST(version_major_more_minor_more_micro_less)
+{
+/* {1,1,-1} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR+1, WESTON_VERSION_MINOR+1, WESTON_VERSION_MICRO-1)
+#else
+	assert(0);
+#endif
+}
+
+TEST(version_major_more_minor_more_micro_more)
+{
+/* {1,1,1} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR+1, WESTON_VERSION_MINOR+1, WESTON_VERSION_MICRO+1)
+#else
+	assert(0);
+#endif
+}
+
+/* Negative Results */
+
+TEST(version_major_less)
+{
+/* {-1,0,0} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR-1, WESTON_VERSION_MINOR, WESTON_VERSION_MICRO)
+	assert(0);
+#endif
+}
+
+TEST(version_minor_less)
+{
+/* {0,-1,0} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR, WESTON_VERSION_MINOR-1, WESTON_VERSION_MICRO)
+	assert(0);
+#endif
+}
+
+TEST(version_micro_less)
+{
+/* {0,0,-1} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR, WESTON_VERSION_MINOR, WESTON_VERSION_MICRO-1)
+	assert(0);
+#endif
+}
+
+TEST(version_major_less_minor_less)
+{
+/* {-1,-1,0} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR-1, WESTON_VERSION_MINOR-1, WESTON_VERSION_MICRO)
+	assert(0);
+#endif
+}
+
+TEST(version_major_less_micro_less)
+{
+/* {-1,0,-1} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR-1, WESTON_VERSION_MINOR, WESTON_VERSION_MICRO-1)
+	assert(0);
+#endif
+}
+
+TEST(version_minor_less_micro_less)
+{
+/* {0,-1,-1} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR, WESTON_VERSION_MINOR-1, WESTON_VERSION_MICRO-1)
+	assert(0);
+#endif
+}
+
+TEST(version_major_less_minor_more)
+{
+/* {-1,1,0} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR-1, WESTON_VERSION_MINOR+1, WESTON_VERSION_MICRO)
+	assert(0);
+#endif
+}
+
+TEST(version_major_less_micro_more)
+{
+/* {-1,0,1} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR-1, WESTON_VERSION_MINOR, WESTON_VERSION_MICRO+1)
+	assert(0);
+#endif
+}
+
+TEST(version_minor_less_micro_more)
+{
+/* {0,-1,1} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR, WESTON_VERSION_MINOR-1, WESTON_VERSION_MICRO+1)
+	assert(0);
+#endif
+}
+
+TEST(version_major_less_minor_less_micro_less)
+{
+/* {-1,-1,-1} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR-1, WESTON_VERSION_MINOR-1, WESTON_VERSION_MICRO-1)
+	assert(0);
+#endif
+}
+
+TEST(version_major_less_minor_less_micro_more)
+{
+/* {-1,-1,1} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR-1, WESTON_VERSION_MINOR-1, WESTON_VERSION_MICRO+1)
+	assert(0);
+#endif
+}
+
+TEST(version_major_less_minor_more_micro_less)
+{
+/* {-1,1,-1} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR-1, WESTON_VERSION_MINOR+1, WESTON_VERSION_MICRO-1)
+	assert(0);
+#endif
+}
+
+TEST(version_major_less_minor_more_micro_more)
+{
+/* {-1,1,1} */
+#if WESTON_VERSION_AT_LEAST(WESTON_VERSION_MAJOR-1, WESTON_VERSION_MINOR+1, WESTON_VERSION_MICRO+1)
+	assert(0);
+#endif
+}
-- 
1.8.3.1



More information about the wayland-devel mailing list