From: Bert Vermeulen Date: Sun, 22 Dec 2013 22:07:23 +0000 (+0100) Subject: runtc: Fix conditional build on non-Linux systems. X-Git-Tag: libsigrokdecode-0.3.0~178 X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=commitdiff_plain;h=919ace16e7100fccd51fda16c6d40fc3ad9915e2 runtc: Fix conditional build on non-Linux systems. --- diff --git a/configure.ac b/configure.ac index 1728c60..88855e0 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/tests/Makefile.am b/tests/Makefile.am index a3df6b3..bd0858f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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) \ diff --git a/tests/runtc.c b/tests/runtc.c index 33cc8f2..9ba51f4 100644 --- a/tests/runtc.c +++ b/tests/runtc.c @@ -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;