check: Make sure to test this set of decoders, not the installed ones.
authorBert Vermeulen <bert@biot.com>
Wed, 11 Dec 2013 17:36:42 +0000 (18:36 +0100)
committerBert Vermeulen <bert@biot.com>
Wed, 11 Dec 2013 17:36:42 +0000 (18:36 +0100)
tests/Makefile.am
tests/check_decoder.c
tests/check_inst.c

index 5739a035c7730a944eaa4f44ba2563d26f139c1c..e70b3012d5c01be71d7712d01399872ca6892d10 100644 (file)
@@ -20,9 +20,7 @@
 
 if HAVE_CHECK
 TESTS = check_main
-
 check_PROGRAMS = ${TESTS}
-
 check_main_SOURCES = \
        $(top_builddir)/libsigrokdecode.h \
        check_main.c \
@@ -30,12 +28,10 @@ check_main_SOURCES = \
        check_decoder.c \
        check_inst.c \
        check_session.c
-
 check_main_CFLAGS = @check_CFLAGS@
-
 check_main_LDADD = $(top_builddir)/libsigrokdecode.la @check_LIBS@
-
-check_main_CPPFLAGS = $(CPPFLAGS_PYTHON)
+check_main_CPPFLAGS = $(CPPFLAGS_PYTHON) \
+       -DDECODERS_DIR='"$(abs_top_builddir)/decoders"'
 endif
 
 if HAVE_LIBSIGROK
index fe1b92f21765ac8e3b39a61b763e990c865a80e0..d62a1ebad38f81936175d1eb66ba9c53e9a150fa 100644 (file)
@@ -40,7 +40,7 @@ START_TEST(test_load_all)
 {
        int ret;
 
-       srd_init(NULL);
+       srd_init(DECODERS_DIR);
        ret = srd_decoder_load_all();
        fail_unless(ret == SRD_OK, "srd_decoder_load_all() failed: %d.", ret);
        srd_exit();
@@ -69,7 +69,7 @@ START_TEST(test_load)
 {
        int ret;
 
-       srd_init(NULL);
+       srd_init(DECODERS_DIR);
        ret = srd_decoder_load("uart");
        fail_unless(ret == SRD_OK, "srd_decoder_load(uart) failed: %d.", ret);
        ret = srd_decoder_load("spi");
@@ -86,7 +86,7 @@ END_TEST
  */
 START_TEST(test_load_bogus)
 {
-       srd_init(NULL);
+       srd_init(DECODERS_DIR);
        /* http://sigrok.org/bugzilla/show_bug.cgi?id=176 */
        fail_unless(srd_decoder_load(NULL) != SRD_OK);
        fail_unless(srd_decoder_load("") != SRD_OK);
@@ -109,7 +109,7 @@ END_TEST
  */
 START_TEST(test_load_valid_and_bogus)
 {
-       srd_init(NULL);
+       srd_init(DECODERS_DIR);
        fail_unless(srd_decoder_load("") != SRD_OK);
        fail_unless(srd_decoder_load("uart") == SRD_OK);
        fail_unless(srd_decoder_load("") != SRD_OK);
@@ -130,7 +130,7 @@ START_TEST(test_load_multiple)
 {
        int ret;
 
-       srd_init(NULL);
+       srd_init(DECODERS_DIR);
        ret = srd_decoder_load("uart");
        fail_unless(ret == SRD_OK, "Loading uart PD 1x failed: %d", ret);
        ret = srd_decoder_load("uart");
@@ -163,7 +163,7 @@ END_TEST
  */
 START_TEST(test_decoder_list)
 {
-       srd_init(NULL);
+       srd_init(DECODERS_DIR);
        srd_decoder_load_all();
        fail_unless(srd_decoder_list() != NULL);
        srd_exit();
@@ -177,7 +177,7 @@ END_TEST
  */
 START_TEST(test_decoder_list_no_load)
 {
-       srd_init(NULL);
+       srd_init(DECODERS_DIR);
        fail_unless(srd_decoder_list() == NULL);
        srd_exit();
 }
@@ -213,7 +213,7 @@ END_TEST
  */
 START_TEST(test_decoder_list_correct_numbers)
 {
-       srd_init(NULL);
+       srd_init(DECODERS_DIR);
        fail_unless(g_slist_length((GSList *)srd_decoder_list()) == 0);
        srd_decoder_load("spi");
        fail_unless(g_slist_length((GSList *)srd_decoder_list()) == 1);
@@ -233,7 +233,7 @@ END_TEST
  */
 START_TEST(test_get_by_id)
 {
-       srd_init(NULL);
+       srd_init(DECODERS_DIR);
        srd_decoder_load("uart");
        fail_unless(srd_decoder_get_by_id("uart") != NULL);
        fail_unless(srd_decoder_get_by_id("can") == NULL);
@@ -250,7 +250,7 @@ END_TEST
  */
 START_TEST(test_get_by_id_multiple)
 {
-       srd_init(NULL);
+       srd_init(DECODERS_DIR);
        srd_decoder_load("uart");
        fail_unless(srd_decoder_get_by_id("uart") != NULL);
        fail_unless(srd_decoder_get_by_id("uart") != NULL);
@@ -266,7 +266,7 @@ END_TEST
  */
 START_TEST(test_get_by_id_bogus)
 {
-       srd_init(NULL);
+       srd_init(DECODERS_DIR);
        fail_unless(srd_decoder_get_by_id(NULL) == NULL);
        fail_unless(srd_decoder_get_by_id("") == NULL);
        fail_unless(srd_decoder_get_by_id(" ") == NULL);
@@ -290,7 +290,7 @@ START_TEST(test_doc_get)
 {
        struct srd_decoder *dec;
 
-       srd_init(NULL);
+       srd_init(DECODERS_DIR);
        srd_decoder_load("uart");
        dec = srd_decoder_get_by_id("uart");
        fail_unless(srd_decoder_doc_get(dec) != NULL);
@@ -305,7 +305,7 @@ END_TEST
  */
 START_TEST(test_doc_get_null)
 {
-       srd_init(NULL);
+       srd_init(DECODERS_DIR);
        fail_unless(srd_decoder_doc_get(NULL) == NULL);
        srd_exit();
 }
index 25adc4f89160355ff42f6133cfe65a441192aaff..87dbe9117e069a18736199f2895a002bcac37137 100644 (file)
@@ -41,7 +41,7 @@ START_TEST(test_inst_new)
        struct srd_session *sess;
        struct srd_decoder_inst *inst;
 
-       srd_init(NULL);
+       srd_init(DECODERS_DIR);
        srd_decoder_load("uart");
        srd_session_new(&sess);
        inst = srd_inst_new(sess, "uart", NULL);
@@ -61,7 +61,7 @@ START_TEST(test_inst_new_multiple)
 
        inst1 = inst2 = inst3 = NULL;
 
-       srd_init(NULL);
+       srd_init(DECODERS_DIR);
        srd_decoder_load_all();
        srd_session_new(&sess);
 
@@ -98,7 +98,7 @@ START_TEST(test_inst_option_set_empty)
        struct srd_decoder_inst *inst;
        GHashTable *options;
 
-       srd_init(NULL);
+       srd_init(DECODERS_DIR);
        srd_decoder_load_all();
        srd_session_new(&sess);
        inst = srd_inst_new(sess, "uart", NULL);
@@ -122,7 +122,7 @@ START_TEST(test_inst_option_set_bogus)
        struct srd_decoder_inst *inst;
        GHashTable *options;
 
-       srd_init(NULL);
+       srd_init(DECODERS_DIR);
        srd_decoder_load_all();
        srd_session_new(&sess);
        inst = srd_inst_new(sess, "uart", NULL);