diff options
author | Uwe Hermann <uwe@hermann-uwe.de> | 2013-10-31 12:25:58 +0100 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2013-10-31 12:25:58 +0100 |
commit | 98e0b79b9fd2abf076054abc5f25c184b436cb87 (patch) | |
tree | 2c08919b111502e28da424eb0896c1239167f70a /tests | |
parent | 8915b34659332288aab38780d8f10d75c4c83e7f (diff) | |
download | libsigrokdecode-98e0b79b9fd2abf076054abc5f25c184b436cb87.tar.gz libsigrokdecode-98e0b79b9fd2abf076054abc5f25c184b436cb87.zip |
unittests: Update to recent API changes.
srd_session_config_set() is now called srd_session_metadata_set(), and
SRD_CONF_NUM_PROBES and SRD_CONF_UNITSIZE are dropped.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/check_session.c | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/tests/check_session.c b/tests/check_session.c index 19e7adb..53b874b 100644 --- a/tests/check_session.c +++ b/tests/check_session.c @@ -148,8 +148,8 @@ static void conf_check_ok(struct srd_session *sess, int key, uint64_t x) { int ret; - ret = srd_session_config_set(sess, key, g_variant_new_uint64(x)); - fail_unless(ret == SRD_OK, "srd_session_config_set(%p, %d, %" + ret = srd_session_metadata_set(sess, key, g_variant_new_uint64(x)); + fail_unless(ret == SRD_OK, "srd_session_metadata_set(%p, %d, %" PRIu64 ") failed: %d.", sess, key, x, ret); } @@ -157,8 +157,8 @@ static void conf_check_fail(struct srd_session *sess, int key, uint64_t x) { int ret; - ret = srd_session_config_set(sess, key, g_variant_new_uint64(x)); - fail_unless(ret != SRD_OK, "srd_session_config_set(%p, %d, %" + ret = srd_session_metadata_set(sess, key, g_variant_new_uint64(x)); + fail_unless(ret != SRD_OK, "srd_session_metadata_set(%p, %d, %" PRIu64 ") worked.", sess, key, x); } @@ -166,25 +166,25 @@ static void conf_check_fail_null(struct srd_session *sess, int key) { int ret; - ret = srd_session_config_set(sess, key, NULL); + ret = srd_session_metadata_set(sess, key, NULL); fail_unless(ret != SRD_OK, - "srd_session_config_set(NULL) for key %d worked.", key); + "srd_session_metadata_set(NULL) for key %d worked.", key); } static void conf_check_fail_str(struct srd_session *sess, int key, const char *s) { int ret; - ret = srd_session_config_set(sess, key, g_variant_new_string(s)); - fail_unless(ret != SRD_OK, "srd_session_config_set for key %d " + ret = srd_session_metadata_set(sess, key, g_variant_new_string(s)); + fail_unless(ret != SRD_OK, "srd_session_metadata_set() for key %d " "failed: %d.", key, ret); } /* - * Check whether srd_session_config_set() works. + * Check whether srd_session_metadata_set() works. * If it returns != SRD_OK (or segfaults) this test will fail. */ -START_TEST(test_session_config_set) +START_TEST(test_session_metadata_set) { uint64_t i; struct srd_session *sess; @@ -193,13 +193,9 @@ START_TEST(test_session_config_set) srd_session_new(&sess); /* Try a bunch of values. */ for (i = 0; i < 1000; i++) { - conf_check_ok(sess, SRD_CONF_NUM_PROBES, i); - conf_check_ok(sess, SRD_CONF_UNITSIZE, i); conf_check_ok(sess, SRD_CONF_SAMPLERATE, i); } /* Try the max. possible value. */ - conf_check_ok(sess, SRD_CONF_NUM_PROBES, 18446744073709551615ULL); - conf_check_ok(sess, SRD_CONF_UNITSIZE, 18446744073709551615ULL); conf_check_ok(sess, SRD_CONF_SAMPLERATE, 18446744073709551615ULL); srd_session_destroy(sess); srd_exit(); @@ -207,10 +203,10 @@ START_TEST(test_session_config_set) END_TEST /* - * Check whether srd_session_config_set() fails with invalid input. + * Check whether srd_session_metadata_set() fails with invalid input. * If it returns SRD_OK (or segfaults) this test will fail. */ -START_TEST(test_session_config_set_bogus) +START_TEST(test_session_metadata_set_bogus) { struct srd_session *sess; @@ -218,21 +214,13 @@ START_TEST(test_session_config_set_bogus) srd_session_new(&sess); /* Incorrect gvariant type (currently only uint64 is used). */ - conf_check_fail_str(sess, SRD_CONF_NUM_PROBES, ""); - conf_check_fail_str(sess, SRD_CONF_UNITSIZE, ""); conf_check_fail_str(sess, SRD_CONF_SAMPLERATE, ""); - conf_check_fail_str(sess, SRD_CONF_NUM_PROBES, "Foo"); - conf_check_fail_str(sess, SRD_CONF_UNITSIZE, "Foo"); conf_check_fail_str(sess, SRD_CONF_SAMPLERATE, "Foo"); /* NULL data pointer. */ - conf_check_fail_null(sess, SRD_CONF_NUM_PROBES); - conf_check_fail_null(sess, SRD_CONF_UNITSIZE); conf_check_fail_null(sess, SRD_CONF_SAMPLERATE); /* NULL session. */ - conf_check_fail(NULL, SRD_CONF_NUM_PROBES, 0); - conf_check_fail(NULL, SRD_CONF_UNITSIZE, 0); conf_check_fail(NULL, SRD_CONF_SAMPLERATE, 0); /* Invalid keys. */ @@ -263,8 +251,8 @@ Suite *suite_session(void) tc = tcase_create("config"); tcase_add_checked_fixture(tc, setup, teardown); - tcase_add_test(tc, test_session_config_set); - tcase_add_test(tc, test_session_config_set_bogus); + tcase_add_test(tc, test_session_metadata_set); + tcase_add_test(tc, test_session_metadata_set_bogus); suite_add_tcase(s, tc); return s; |