X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=decoder%2Fruntc.c;h=9dcb66daf03ed00a85f5008e1b5937546c9e0d29;hb=0e8085a835bf6faf0542d65dbdcf0f4e721464e6;hp=f58e0046a23d8f5ba29880b76a445147ac4a1f49;hpb=ec3de18f47d7cfeeed0756c4f87621259063c435;p=sigrok-test.git diff --git a/decoder/runtc.c b/decoder/runtc.c index f58e004..9dcb66d 100644 --- a/decoder/runtc.c +++ b/decoder/runtc.c @@ -332,10 +332,12 @@ static int run_testcase(char *infile, GSList *pdlist, struct output *op) GVariant *gvar; GHashTable *channels, *opts; GSList *pdl, *l; - int idx; + int idx, i; int max_channel; char **decoder_class; struct sr_session *sr_sess; + gboolean is_number; + const char *s; if (op->outfile) { if ((op->outfd = open(op->outfile, O_CREAT|O_WRONLY, 0600)) == -1) { @@ -378,7 +380,22 @@ static int run_testcase(char *infile, GSList *pdlist, struct output *op) (GDestroyNotify)g_variant_unref); for (l = pd->options; l; l = l->next) { option = l->data; - g_hash_table_insert(opts, option->key, option->value); + + is_number = TRUE; + s = g_variant_get_string(option->value, NULL); + for (i = 0; i < (int)strlen(s); i++) { + if (!isdigit(s[i])) + is_number = FALSE; + } + + if (is_number) { + /* Integer option value */ + g_hash_table_insert(opts, option->key, + g_variant_new_int64(strtoull(s, NULL, 10))); + } else { + /* String option value */ + g_hash_table_insert(opts, option->key, option->value); + } } if (!(di = srd_inst_new(sess, pd->name, opts))) return FALSE;