* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include <config.h>
#include <stdio.h>
#include <string.h>
+#include <glib.h>
+#include <glib/gstdio.h>
#include <check.h>
-#include "../libsigrok.h"
+#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)
struct sr_dev_driver **drivers, *driver = NULL;
int i;
- drivers = sr_driver_list();
+ drivers = sr_driver_list(srtest_ctx);
fail_unless(drivers != NULL, "No drivers found.");
for (i = 0; drivers[i]; i++) {
struct sr_dev_driver **drivers, *driver;
int i, ret;
- drivers = sr_driver_list();
+ drivers = sr_driver_list(srtest_ctx);
fail_unless(drivers != NULL, "No drivers found.");
for (i = 0; drivers[i]; i++) {
struct sr_dev_inst *sdi;
GVariant *gvar;
- sdi = g_slist_nth_data(driver->priv, 0);
+ sdi = g_slist_nth_data(driver->context, 0);
gvar = g_variant_new_uint64(samplerate);
- ret = driver->config_set(SR_CONF_SAMPLERATE, gvar, sdi);
+ ret = driver->config_set(SR_CONF_SAMPLERATE, gvar, sdi, NULL);
g_variant_unref(gvar);
fail_unless(ret == SR_OK, "%s: Failed to set SR_CONF_SAMPLERATE: %d.",
struct sr_dev_inst *sdi;
GVariant *gvar;
- sdi = g_slist_nth_data(driver->priv, 0);
+ sdi = g_slist_nth_data(driver->context, 0);
- ret = driver->config_get(SR_CONF_SAMPLERATE, &gvar, sdi);
+ ret = driver->config_get(SR_CONF_SAMPLERATE, &gvar, sdi, NULL);
samplerate = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
fail_unless(s == samplerate, "%s: Incorrect samplerate: %" PRIu64 ".",
drivername, s);
}
+
+GArray *srtest_get_enabled_logic_channels(const struct sr_dev_inst *sdi)
+{
+ struct sr_channel *ch;
+ GArray *channels;
+ GSList *l;
+
+ channels = g_array_new(FALSE, FALSE, sizeof(int));
+ for (l = sr_dev_inst_channels_get(sdi); l; l = l->next) {
+ ch = l->data;
+ if (ch->type != SR_CHANNEL_LOGIC)
+ continue;
+ if (ch->enabled != TRUE)
+ continue;
+ g_array_append_val(channels, ch->index);
+ }
+
+ return channels;
+}