[PATCH xrandr-utils 5/8] Add unit test suite and a basic test of the geometry structs.
Bryce Harrington
bryce at canonical.com
Fri Jan 6 16:36:33 PST 2012
This follows the style of the X server test suite, using autoconf's
built-in support for make check using asserts.
The first test trivially checks the geometry structures.
Signed-off-by: Bryce Harrington <bryce at canonical.com>
---
COPYING | 1 +
Makefile.am | 2 +-
configure.ac | 1 +
test/.gitignore | 2 +
test/Makefile.am | 14 +++++++++++
test/README | 14 +++++++++++
test/geometry.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 99 insertions(+), 1 deletions(-)
create mode 100644 test/.gitignore
create mode 100644 test/Makefile.am
create mode 100644 test/README
create mode 100644 test/geometry.c
diff --git a/COPYING b/COPYING
index c405625..618bff9 100644
--- a/COPYING
+++ b/COPYING
@@ -1,6 +1,7 @@
Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
Copyright © 2002 Hewlett Packard Company, Inc.
Copyright © 2006 Intel Corporation
+Copyright © 2011 Canonical, Ltd.
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
diff --git a/Makefile.am b/Makefile.am
index 607dfc1..f6bb4f9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,7 +19,7 @@
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
-SUBDIRS = examples man src
+SUBDIRS = examples man src test
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = xrandr-utils.pc
diff --git a/configure.ac b/configure.ac
index b3694f8..4ccd1e0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,5 +58,6 @@ AC_CONFIG_FILES([
examples/Makefile
man/Makefile
src/Makefile
+ test/Makefile
xrandr-utils.pc])
AC_OUTPUT
diff --git a/test/.gitignore b/test/.gitignore
new file mode 100644
index 0000000..953f2c7
--- /dev/null
+++ b/test/.gitignore
@@ -0,0 +1,2 @@
+geometry
+xrandr
diff --git a/test/Makefile.am b/test/Makefile.am
new file mode 100644
index 0000000..bcd59ab
--- /dev/null
+++ b/test/Makefile.am
@@ -0,0 +1,14 @@
+check_PROGRAMS = geometry
+
+TESTS = $(check_PROGRAMS)
+
+AM_CFLAGS = \
+ $(RANDR_UTILS_CFLAGS) \
+ $(MALLOC_ZERO_CFLAGS) \
+ $(CWARNFLAGS)
+
+INCLUDES = -I$(top_srcdir)/include/X11/extensions
+
+TEST_LDADD = @RANDR_UTILS_LIBS@
+
+geometry_LDADD = $(TEST_LDADD)
diff --git a/test/README b/test/README
new file mode 100644
index 0000000..720a315
--- /dev/null
+++ b/test/README
@@ -0,0 +1,14 @@
+ libXrandrUtils test suite
+
+This suite contains a set of tests to verify the behavior of the
+XrandrUtils API. This suite follows the conventions of the X server
+test suite.
+
+= How to run the tests =
+Run "make check" in the test directory. This will compile the tests and
+execute them in the order specified by the TESTS variable in
+test/Makefile.am.
+
+== Adding a new test ==
+When adding a new test, ensure that you add a short description of what
+the test does and what the expected outcome is.
diff --git a/test/geometry.c b/test/geometry.c
new file mode 100644
index 0000000..bcdb044
--- /dev/null
+++ b/test/geometry.c
@@ -0,0 +1,66 @@
+/**
+ * Copyright © 2011 Canonical, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * Verify structures dealing with geometry.
+ */
+
+#include <assert.h>
+
+#include "XrandrUtils.h"
+
+/**
+ * Verify XRUPoint struct members
+ */
+static void geometry_point(void)
+{
+ XRUPoint p;
+ p.x = 1;
+ p.y = -1;
+
+ assert( 1 == p.x);
+ assert(-1 == p.y);
+}
+
+/**
+ * Verify XRUBox struct members
+ */
+static void geometry_box(void)
+{
+ XRUBox b;
+ b.x1 = b.y1 = 0;
+ b.x2 = b.y2 = 100;
+
+ assert( 0 == b.x1);
+ assert( 0 == b.y1);
+ assert(100 == b.x2);
+ assert(100 == b.y2);
+}
+
+int main(int argc, char** argv)
+{
+ geometry_point();
+ geometry_box();
+
+ return 0;
+}
--
1.7.4.1
More information about the xorg-devel
mailing list