]> sigrok.org Git - libsigrokdecode.git/blobdiff - tests/runtc.c
runtc: Fix conditional build on non-Linux systems.
[libsigrokdecode.git] / tests / runtc.c
index 902ca8e1dd4aff2b1295cbe822dc620c00d9f632..9ba51f4a4ca8f4453f78e3aca70d812bd87e6236 100644 (file)
@@ -191,6 +191,8 @@ static void srd_cb_bin(struct srd_proto_data *pdata, void *cb_data)
 {
        struct srd_proto_data_binary *pdb;
        struct output *op;
+       GString *out;
+       unsigned int i;
 
        DBG("Binary output from %s", pdata->pdo->di->inst_id);
        op = cb_data;
@@ -207,7 +209,15 @@ static void srd_cb_bin(struct srd_proto_data *pdata, void *cb_data)
                 */
                return;
 
-       if (write(op->outfd, pdb->data, pdb->size) == -1)
+       out = g_string_sized_new(128);
+       g_string_printf(out, "%"PRIu64"-%"PRIu64" %s:",
+                       pdata->start_sample, pdata->end_sample,
+                       pdata->pdo->di->inst_id);
+       for (i = 0; i < pdb->size; i++) {
+               g_string_append_printf(out, " %.2x", pdb->data[i]);
+       }
+       g_string_append(out, "\n");
+       if (write(op->outfd, out->str, out->len) == -1)
                ERR("SRD_OUTPUT_BINARY callback write failure!");
 
 }
@@ -297,39 +307,6 @@ static void sr_cb(const struct sr_dev_inst *sdi,
 
 }
 
-int get_stats(int stats[2])
-{
-       FILE *f;
-       size_t len;
-       int tmp;
-       char *buf;
-
-       stats[0] = stats[1] = -1;
-       if (!(f = fopen("/proc/self/status", "r")))
-               return FALSE;
-       len = 128;
-       buf = malloc(len);
-       while (getline(&buf, &len, f) != -1) {
-               if (strcasestr(buf, "vmpeak:")) {
-                       stats[0] = strtoul(buf + 10, NULL, 10);
-               } else if (strcasestr(buf, "vmsize:")) {
-                       tmp = strtoul(buf + 10, NULL, 10);
-                       if (tmp > stats[0])
-                               stats[0] = tmp;
-               } else if (strcasestr(buf, "vmhwm:")) {
-                       stats[1] = strtoul(buf + 6, NULL, 10);
-               } else if (strcasestr(buf, "vmrss:")) {
-                       tmp = strtoul(buf + 10, NULL, 10);
-                       if (tmp > stats[0])
-                               stats[0] = tmp;
-               }
-       }
-       free(buf);
-       fclose(f);
-
-       return TRUE;
-}
-
 static int run_testcase(char *infile, GSList *pdlist, struct output *op)
 {
        struct srd_session *sess;