}
END_TEST
+/*
+ * Check whether srd_decoder_unload_all() works.
+ * If it returns != SRD_OK (or segfaults) this test will fail.
+ */
+START_TEST(test_unload_all)
+{
+ int ret;
+
+ srd_init(DECODERS_TESTDIR);
+ ret = srd_decoder_load_all();
+ fail_unless(ret == SRD_OK, "srd_decoder_load_all() failed: %d.", ret);
+ ret = srd_decoder_unload_all();
+ fail_unless(ret == SRD_OK, "srd_decoder_unload_all() failed: %d.", ret);
+ srd_exit();
+}
+END_TEST
+
+/*
+ * Check whether srd_decoder_unload_all() works without prior srd_init().
+ * If it returns != SRD_OK (or segfaults) this test will fail.
+ */
+START_TEST(test_unload_all_no_init)
+{
+ int ret;
+
+ ret = srd_decoder_unload_all();
+ fail_unless(ret == SRD_OK, "srd_decoder_unload_all() failed: %d.", ret);
+}
+END_TEST
+
+/*
+ * Check whether srd_decoder_unload_all() works multiple times.
+ * If it returns != SRD_OK (or segfaults) this test will fail.
+ */
+START_TEST(test_unload_all_multiple)
+{
+ int ret, i;
+
+ srd_init(DECODERS_TESTDIR);
+ for (i = 0; i < 10; i++) {
+ ret = srd_decoder_load_all();
+ fail_unless(ret == SRD_OK, "srd_decoder_load_all() failed: %d.", ret);
+ ret = srd_decoder_unload_all();
+ fail_unless(ret == SRD_OK, "srd_decoder_unload_all() failed: %d.", ret);
+ }
+ srd_exit();
+}
+END_TEST
+
+/*
+ * Check whether srd_decoder_unload_all() works multiple times (no load).
+ * If it returns != SRD_OK (or segfaults) this test will fail.
+ */
+START_TEST(test_unload_all_multiple_noload)
+{
+ int ret, i;
+
+ srd_init(DECODERS_TESTDIR);
+ for (i = 0; i < 10; i++) {
+ ret = srd_decoder_unload_all();
+ fail_unless(ret == SRD_OK, "srd_decoder_unload_all() failed: %d.", ret);
+ }
+ srd_exit();
+}
+END_TEST
+
+/*
+ * Check whether srd_decoder_unload() works.
+ * If it returns != SRD_OK (or segfaults) this test will fail.
+ */
+START_TEST(test_unload)
+{
+ int ret;
+ struct srd_decoder *dec;
+
+ srd_init(DECODERS_TESTDIR);
+ ret = srd_decoder_load("uart");
+ fail_unless(ret == SRD_OK, "srd_decoder_load(uart) failed: %d.", ret);
+ dec = srd_decoder_get_by_id("uart");
+ fail_unless(dec != NULL);
+ ret = srd_decoder_unload(dec);
+ fail_unless(ret == SRD_OK, "srd_decoder_unload() failed: %d.", ret);
+ srd_exit();
+}
+END_TEST
+
+/*
+ * Check whether srd_decoder_unload(NULL) fails.
+ * If it returns SRD_OK (or segfaults) this test will fail.
+ */
+START_TEST(test_unload_null)
+{
+ srd_init(DECODERS_TESTDIR);
+ fail_unless(srd_decoder_unload(NULL) != SRD_OK);
+ srd_exit();
+}
+END_TEST
+
+/*
+ * Check whether srd_decoder_unload(NULL) fails without prior srd_init().
+ * If it returns SRD_OK (or segfaults) this test will fail.
+ */
+START_TEST(test_unload_null_no_init)
+{
+ fail_unless(srd_decoder_unload(NULL) != SRD_OK);
+}
+END_TEST
+
/*
* Check whether srd_decoder_list() returns a non-empty list.
* If it returns an empty list (or segfaults) this test will fail.
tcase_add_test(tc, test_load_nonexisting_pd_dir);
suite_add_tcase(s, tc);
+ tc = tcase_create("unload");
+ tcase_add_checked_fixture(tc, srdtest_setup, srdtest_teardown);
+ tcase_add_test(tc, test_unload_all);
+ tcase_add_test(tc, test_unload_all_no_init);
+ tcase_add_test(tc, test_unload_all_multiple);
+ tcase_add_test(tc, test_unload_all_multiple_noload);
+ tcase_add_test(tc, test_unload);
+ tcase_add_test(tc, test_unload_null);
+ tcase_add_test(tc, test_unload_null_no_init);
+ suite_add_tcase(s, tc);
+
tc = tcase_create("list");
tcase_add_checked_fixture(tc, srdtest_setup, srdtest_teardown);
tcase_add_test(tc, test_decoder_list);