On Tue, 2012-05-01 at 13:10 +1000, Peter Hutterer wrote:
> On Mon, Apr 30, 2012 at 11:40:47AM +0100, Bastien Nocera wrote:
> > On Mon, 2012-04-30 at 15:53 +1000, Peter Hutterer wrote:
> > > Test each tablet returned for some basic sanity (largely >= 0 values)
> > 
> > Are you going to hook that up?
> 
> hook it up to? 'make check' runs all the tests, I'm not sure what else you
> mean here.

Missed that bit, thanks.

> > > Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
> > 
> > Reviewed-By: Bastien Nocera <had...@hadess.net>
> 
> thanks.
> 
> Cheers,
>   Peter
> > 
> > > ---
> > >  test/Makefile.am       |    3 +-
> > >  test/tablet-validity.c |   95 
> > > ++++++++++++++++++++++++++++++++++++++++++++++++
> > >  2 files changed, 97 insertions(+), 1 deletion(-)
> > >  create mode 100644 test/tablet-validity.c
> > > 
> > > diff --git a/test/Makefile.am b/test/Makefile.am
> > > index 7ef0e52..090a1e2 100644
> > > --- a/test/Makefile.am
> > > +++ b/test/Makefile.am
> > > @@ -1,4 +1,4 @@
> > > -noinst_PROGRAMS=load dbverify
> > > +noinst_PROGRAMS=load dbverify tablet-validity
> > >  
> > >  TESTS=$(noinst_PROGRAMS)
> > >  
> > > @@ -6,3 +6,4 @@ INCLUDES=-I$(top_srcdir)/libwacom 
> > > -DTOPSRCDIR="\"$(top_srcdir)\""
> > >  
> > >  load_LDADD=$(top_builddir)/libwacom/libwacom.la
> > >  dbverify_LDADD=$(top_builddir)/libwacom/libwacom.la
> > > +tablet_validity_LDADD=$(top_builddir)/libwacom/libwacom.la
> > > diff --git a/test/tablet-validity.c b/test/tablet-validity.c
> > > new file mode 100644
> > > index 0000000..ac53903
> > > --- /dev/null
> > > +++ b/test/tablet-validity.c
> > > @@ -0,0 +1,95 @@
> > > +/*
> > > + * Copyright © 2012 Red Hat, Inc.
> > > + *
> > > + * Permission to use, copy, modify, distribute, and sell this software
> > > + udo y 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 Red Hat
> > > + * not be used in advertising or publicity pertaining to distribution
> > > + * of the software without specific, written prior permission.  Red
> > > + * Hat makes no representations about the suitability of this software
> > > + * for any purpose.  It is provided "as is" without express or implied
> > > + * warranty.
> > > + *
> > > + * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
> > > + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
> > > + * NO EVENT SHALL THE AUTHORS 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.
> > > + *
> > > + * Authors:
> > > + *       Peter Hutterer (peter.hutte...@redhat.com)
> > > + */
> > > +
> > > +#ifdef HAVE_CONFIG_H
> > > +#include "config.h"
> > > +#endif
> > > +
> > > +#define _GNU_SOURCE
> > > +#include <stdio.h>
> > > +#include <stdlib.h>
> > > +#include <string.h>
> > > +#include <dirent.h>
> > > +#include <sys/types.h>
> > > +#include <sys/stat.h>
> > > +#include <fcntl.h>
> > > +#include "libwacom.h"
> > > +#include <assert.h>
> > > +#include <unistd.h>
> > > +
> > > +static void verify_tablet(WacomDevice *device)
> > > +{
> > > + const char *name;
> > > + int nstyli;
> > > +
> > > + name = libwacom_get_name(device);
> > > + if (strcmp(name, "Generic") == 0)
> > > +         return;
> > > +
> > > + printf("Verifying tablet %s\n", name);
> > > + assert(libwacom_get_class(device) != WCLASS_UNKNOWN);
> > > + assert(name && strlen(name) > 0);
> > > + if (libwacom_get_bustype(device) != WBUSTYPE_SERIAL) {
> > > +         assert(libwacom_get_vendor_id(device) > 0);
> > > +         assert(libwacom_get_product_id(device) > 0);
> > > + }
> > > + assert(libwacom_get_match(device) != NULL);
> > > + assert(libwacom_get_matches(device) != NULL);
> > > + assert(libwacom_get_width(device) > 0);
> > > + assert(libwacom_get_height(device) > 0);
> > > + assert(libwacom_get_num_buttons(device) >= 0);
> > > + assert(libwacom_get_supported_styli(device, &nstyli) != NULL);
> > > + assert(nstyli > 0);
> > > + assert(libwacom_get_ring_num_modes(device) >= 0);
> > > + assert(libwacom_get_ring2_num_modes(device) >= 0);
> > > + assert(libwacom_get_num_strips(device) >= 0);
> > > + assert(libwacom_get_strips_num_modes(device) >= 0);
> > > + assert(libwacom_get_bustype(device) != WBUSTYPE_UNKNOWN);
> > > +}
> > > +
> > > +int main(int argc, char **argv)
> > > +{
> > > + WacomDeviceDatabase *db;
> > > + WacomDevice **device, **devices;
> > > +
> > > + db = libwacom_database_new_for_path(TOPSRCDIR"/data");
> > > + if (!db)
> > > +         printf("Failed to load data from %s", TOPSRCDIR"/data");
> > > + assert(db);
> > > +
> > > + devices = libwacom_list_devices_from_database(db, NULL);
> > > + assert(devices);
> > > + assert(*devices);
> > > +
> > > + for (device = devices; *device; device++)
> > > +         verify_tablet(*device);
> > > +
> > > + libwacom_database_destroy (db);
> > > +
> > > + return 0;
> > > +}
> > > +
> > > +/* vim: set noexpandtab tabstop=8 shiftwidth=8: */
> > 
> > 
> > 



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to