X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=tests%2Flib.c;h=acdca674c49f079da546b8da7f50baf8a0613552;hb=d1a5f737816cd9bc8d4ddfeb6d8831a1c1c58bf9;hp=b3dc819090d094a22059ef472b39214197873f49;hpb=ba7dd8bbb8168cba432a844259a3e239aa5f36d7;p=libsigrok.git diff --git a/tests/lib.c b/tests/lib.c index b3dc8190..acdca674 100644 --- a/tests/lib.c +++ b/tests/lib.c @@ -23,9 +23,27 @@ #include #include #include -#include "../libsigrok.h" +#include "../include/libsigrok/libsigrok.h" #include "lib.h" +struct sr_context *srtest_ctx; + +void srtest_setup(void) +{ + int ret; + + ret = sr_init(&srtest_ctx); + fail_unless(ret == SR_OK, "sr_init() failed: %d.", ret); +} + +void srtest_teardown(void) +{ + int ret; + + ret = sr_exit(srtest_ctx); + fail_unless(ret == SR_OK, "sr_exit() failed: %d.", ret); +} + /* Get a libsigrok driver by name. */ struct sr_dev_driver *srtest_driver_get(const char *drivername) { @@ -64,25 +82,6 @@ struct sr_input_format *srtest_input_get(const char *id) return input; } -/* Get a libsigrok output format by ID. */ -struct sr_output_format *srtest_output_get(const char *id) -{ - struct sr_output_format **outputs, *output = NULL; - int i; - - outputs = sr_output_list(); - fail_unless(outputs != NULL, "No output modules found."); - - for (i = 0; outputs[i]; i++) { - if (strcmp(outputs[i]->id, id)) - continue; - output = outputs[i]; - } - fail_unless(output != NULL, "Output module '%s' not found.", id); - - return output; -} - /* Initialize a libsigrok driver. */ void srtest_driver_init(struct sr_context *sr_ctx, struct sr_dev_driver *driver) { @@ -211,21 +210,21 @@ void srtest_buf_to_file(const char *filename, const uint8_t *buf, uint64_t len) fclose(f); } -GArray *srtest_get_enabled_logic_probes(const struct sr_dev_inst *sdi) +GArray *srtest_get_enabled_logic_channels(const struct sr_dev_inst *sdi) { struct sr_channel *ch; - GArray *probes; + GArray *channels; GSList *l; - probes = g_array_new(FALSE, FALSE, sizeof(int)); - for (l = sdi->probes; l; l = l->next) { - probe = l->data; - if (probe->type != SR_PROBE_LOGIC) + channels = g_array_new(FALSE, FALSE, sizeof(int)); + for (l = sdi->channels; l; l = l->next) { + ch = l->data; + if (ch->type != SR_CHANNEL_LOGIC) continue; - if (probe->enabled != TRUE) + if (ch->enabled != TRUE) continue; - g_array_append_val(probes, probe->index); + g_array_append_val(channels, ch->index); } - return probes; + return channels; }