summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am28
-rw-r--r--tests/check-camera-list.in32
-rw-r--r--tests/test-camera-list.c70
3 files changed, 130 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4ab295ace..876e25082 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -3,6 +3,18 @@ INCLUDES = \
-I$(top_srcdir)/libgphoto2 \
-I$(top_srcdir)/libgphoto2_port/libgphoto2_port
+check_PROGRAMS = test-camera-list
+
+check_SCRIPTS = \
+ check-camera-list.sh
+
+EXTRA_DIST = \
+ check-camera-list.in
+
+TESTS = $(check_SCRIPTS)
+
+CLEANFILES = $(check_SCRIPTS)
+
noinst_PROGRAMS = \
test-gphoto2 \
test-filesys
@@ -12,3 +24,19 @@ test_gphoto2_LDADD = $(top_builddir)/libgphoto2/libgphoto2.la $(INTLLIBS)
test_filesys_SOURCE = test-filesys.c
test_filesys_LDADD = $(top_builddir)/libgphoto2/libgphoto2.la $(INTLLIBS)
+
+test_camera_list_SOURCE = test-camera-list.c
+test_camera_list_LDADD = $(top_builddir)/libgphoto2/libgphoto2.la $(INTLLIBS)
+
+clean-local:
+ rm -rf _inst
+
+%.sh: %.in
+ @echo "Creating $@"
+ @sed \
+ -e 's|@top_builddir\@|$(top_builddir)|g' \
+ -e 's|@camlibdir\@|$(camlibdir)|g' \
+ -e 's|@DESTDIR\@|$(DESTDIR)|g' \
+ -e 's|@MAKE\@|$(MAKE)|g' \
+ < "$<" > "$@"
+ @chmod +x $@
diff --git a/tests/check-camera-list.in b/tests/check-camera-list.in
new file mode 100644
index 000000000..fbd927a2b
--- /dev/null
+++ b/tests/check-camera-list.in
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+top_builddir="@top_builddir@"
+camlibdir="@camlibdir@"
+DESTDIR="@DESTDIR@"
+MAKE="@MAKE@"
+
+CAMLIBS="${DESTDIR}${camlibdir}"
+
+if test -d "${CAMLIBS}"; then
+ :
+elif test -d "$(pwd)/_inst/${camlibdir}"; then
+ DESTDIR="$(pwd)/_inst"
+ CAMLIBS="${DESTDIR}${camlibdir}"
+ :
+else
+ DESTDIR="$(pwd)/_inst"
+ CAMLIBS="${DESTDIR}${camlibdir}"
+ (cd "${top_builddir}" && ${MAKE} DESTDIR="$DESTDIR" install)
+ if test -d "${CAMLIBS}"; then
+ echo "Test installation successful"
+ else
+ echo "Test installation failed"
+ exit 1
+ fi
+fi
+
+echo "Using camlib dir: $CAMLIBS"
+export CAMLIBS
+
+#echo "FIXME: Actually list all cameras."
+./test-camera-list
diff --git a/tests/test-camera-list.c b/tests/test-camera-list.c
new file mode 100644
index 000000000..54f3826d0
--- /dev/null
+++ b/tests/test-camera-list.c
@@ -0,0 +1,70 @@
+/* test-gphoto2.c
+ *
+ * Copyright © 2001 Lutz Müller <lutz@users.sf.net>
+ * Copyright © 2005 Hans Ulrich Niedermann <gp@n-dimensional.de>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#include "config.h"
+
+#include <stdio.h>
+#include <gphoto2-camera.h>
+
+#define CHECK(f) {int res = f; if (res < 0) {printf ("ERROR: %s\n", gp_result_as_string (res)); return (1);}}
+
+int
+main (int argc, char *argv [])
+{
+ CameraAbilitiesList *al;
+ int i;
+ int count;
+
+ CHECK (gp_abilities_list_new (&al));
+ CHECK (gp_abilities_list_load (al, NULL));
+
+ count = gp_abilities_list_count (al);
+ if (count < 0) {
+ printf("gp_abilities_list_count error: %d\n", count);
+ return(1);
+ } else if (count == 0) {
+ printf("no camera drivers (camlibs) found in camlib dir\n");
+ return(1);
+ }
+
+ printf("No.|%-20s|%s\n",
+ "driver (camlib)",
+ "camera model");
+ printf("---+%-20s+%s\n",
+ "--------------------",
+ "-------------------------------------------");
+ for (i = 0; i < count; i++) {
+ CameraAbilities abilities;
+ CHECK (gp_abilities_list_get_abilities (al, i, &abilities));
+ printf("%3d|%-20s|%s\n", i+1,
+ abilities.id,
+ abilities.model);
+ }
+
+ CHECK (gp_abilities_list_free (al));
+ return (0);
+}
+
+/*
+ * Local variables:
+ * mode:c
+ * c-basic-offset:8
+ * End:
+ */