summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGerhard Sittig <gerhard.sittig@gmx.net>2017-12-17 22:24:10 +0100
committerUwe Hermann <uwe@hermann-uwe.de>2018-03-31 20:44:21 +0200
commit51c51ffb941e728672baccfd5d2e2ae67674e424 (patch)
tree904585662aa8d220aa47cdf29f5394a9bf636a04 /tests
parent9553e9622bb26dfbe6296ef6f330b1cf0f5b40e6 (diff)
downloadlibsigrokdecode-51c51ffb941e728672baccfd5d2e2ae67674e424.tar.gz
libsigrokdecode-51c51ffb941e728672baccfd5d2e2ae67674e424.zip
test: add simple "no data" test case for decoder "terminate and reset"
Introduce a "reset" group of tests. Whip up a first test step which runs the "terminate and reset" routine for decoder stacks after session creation, start, and meta data setup. No input data gets processed, no decoder output is tested yet.
Diffstat (limited to 'tests')
-rw-r--r--tests/session.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/session.c b/tests/session.c
index f9e42df..e79496e 100644
--- a/tests/session.c
+++ b/tests/session.c
@@ -224,6 +224,36 @@ START_TEST(test_session_metadata_set_bogus)
}
END_TEST
+/*
+ * Check whether srd_session_terminate_reset() succeeds on newly created
+ * sessions, as well as after calling start() and meta(). No data is fed
+ * to decoders here.
+ */
+START_TEST(test_session_reset_nodata)
+{
+ struct srd_session *sess;
+ int ret;
+ GVariant *data;
+
+ srd_init(NULL);
+ srd_session_new(&sess);
+ ret = srd_session_terminate_reset(sess);
+ fail_unless(ret == SRD_OK, "srd_session_terminate_reset() failed: %d.", ret);
+ ret = srd_session_start(sess);
+ fail_unless(ret == SRD_OK, "srd_session_start() failed: %d.", ret);
+ ret = srd_session_terminate_reset(sess);
+ fail_unless(ret == SRD_OK, "srd_session_terminate_reset() failed: %d.", ret);
+ data = g_variant_new_uint64(1000000);
+ ret = srd_session_metadata_set(sess, SRD_CONF_SAMPLERATE, data);
+ fail_unless(ret == SRD_OK, "srd_session_metadata_set() failed: %d.", ret);
+ ret = srd_session_terminate_reset(sess);
+ fail_unless(ret == SRD_OK, "srd_session_terminate_reset() failed: %d.", ret);
+ ret = srd_session_destroy(sess);
+ fail_unless(ret == SRD_OK, "srd_session_destroy() failed: %d.", ret);
+ srd_exit();
+}
+END_TEST
+
Suite *suite_session(void)
{
Suite *s;
@@ -246,5 +276,9 @@ Suite *suite_session(void)
tcase_add_test(tc, test_session_metadata_set_bogus);
suite_add_tcase(s, tc);
+ tc = tcase_create("reset");
+ tcase_add_test(tc, test_session_reset_nodata);
+ suite_add_tcase(s, tc);
+
return s;
}