]> sigrok.org Git - libsigrokdecode.git/commitdiff
runtc: Fix conditional build on non-Linux systems.
authorBert Vermeulen <redacted>
Sun, 22 Dec 2013 22:07:23 +0000 (23:07 +0100)
committerBert Vermeulen <redacted>
Sun, 22 Dec 2013 22:07:23 +0000 (23:07 +0100)
configure.ac
tests/Makefile.am
tests/runtc.c

index 1728c60bf7e2d5a1f3c08244de01c91311fb17d2..88855e010a0b10144a5a695733150f8f23564677 100644 (file)
@@ -77,6 +77,9 @@ AC_SUBST(SRD_LIB_VERSION_AGE)
 AC_SUBST(SRD_LIB_VERSION)
 AC_SUBST(SRD_LIB_LDFLAGS)
 
+# assume we can build tests/runtc unless proven otherwise
+build_runtc="yes"
+
 # Checks for libraries.
 
 # libglib-2.0 is always needed.
@@ -123,18 +126,16 @@ PKG_CHECK_MODULES([check], [check >= 0.9.4],
        LIBS="$LIBS $check_LIBS"], [have_check="no"])
 AM_CONDITIONAL(HAVE_CHECK, test x"$have_check" = "xyes")
 
+# Protocol decoder test framework
 PKG_CHECK_MODULES([libsigrok], [libsigrok >= 0.2.0],
-       [have_libsigrok="yes";
-               LIBSIGROK_CFLAGS="$libsigrok_CFLAGS";
-               LIBSIGROK_LIBS="$libsigrok_LIBS"],
-       [have_libsigrok="no"])
-AM_CONDITIONAL(HAVE_LIBSIGROK, test x"$have_libsigrok" = "xyes")
+       [LIBSIGROK_CFLAGS="$libsigrok_CFLAGS"; LIBSIGROK_LIBS="$libsigrok_LIBS"],
+       [build_runtc="no"])
 AC_SUBST([LIBSIGROK_CFLAGS])
 AC_SUBST([LIBSIGROK_LIBS])
 
 # Checks for header files.
 # These are already checked: inttypes.h stdint.h stdlib.h string.h unistd.h.
-# AC_CHECK_HEADERS([])
+AC_CHECK_HEADER([sys/resource.h], [], [build_runtc="no"])
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_C_INLINE
@@ -165,6 +166,8 @@ AC_SUBST(SRD_PACKAGE_VERSION_MINOR)
 AC_SUBST(SRD_PACKAGE_VERSION_MICRO)
 AC_SUBST(SRD_PACKAGE_VERSION)
 
+AM_CONDITIONAL(BUILD_RUNTC, test x"$build_runtc" = "xyes")
+
 AC_CONFIG_FILES([Makefile
                 version.h
                 libsigrokdecode.pc
@@ -182,6 +185,7 @@ echo "  - Library version (current:revision:age): $SRD_LIB_VERSION"
 echo "  - Prefix: $prefix"
 echo "  - Building on: $build"
 echo "  - Building for: $host"
+echo "  - Building protocol decoder test framework: $build_runtc"
 echo
 echo "Detected libraries:"
 echo
index a3df6b324098bf8e61ca3ed515d86a280ae3940c..bd0858ff12ab89867264890d100ca15fe0a9a277 100644 (file)
@@ -34,7 +34,7 @@ check_main_CPPFLAGS = $(CPPFLAGS_PYTHON) \
        -DDECODERS_DIR='"$(abs_top_builddir)/decoders"'
 endif
 
-if HAVE_LIBSIGROK
+if BUILD_RUNTC
 noinst_PROGRAMS = runtc
 runtc_SOURCES = runtc.c
 runtc_CPPFLAGS = $(CPPFLAGS_PYTHON) $(LIBSIGROK_CFLAGS) \
index 33cc8f260c77948289f7abe6239455ee4539e658..9ba51f4a4ca8f4453f78e3aca70d812bd87e6236 100644 (file)
@@ -307,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;