]> granicus.if.org Git - flex/commitdiff
test: skip pthread test when needed files missing.
authorExplorer09 <explorer09@gmail.com>
Tue, 7 Feb 2017 13:14:04 +0000 (21:14 +0800)
committerWill Estes <westes575@gmail.com>
Thu, 16 Feb 2017 14:33:35 +0000 (09:33 -0500)
"Unlisting" the pthread test when libpthread is not available is never
a good idea. Should let it compile into a stub program that returns
the "skip" status.

configure.ac and tests/Makefile.am are edited so that pthread test can
be built anyway, but only works (not as the stub) when both pthread.h
and libpthread are detected on the system.

Also fix a small typo in tests/pthread.l comments.

configure.ac
tests/Makefile.am
tests/pthread.l

index 3152ccc48c0fe2070a4f59b0d0c49cb7d6f64909..36bf58e242a43348bab8ee755e6baee82cf91f10 100644 (file)
@@ -119,12 +119,12 @@ AC_CHECK_HEADERS([inttypes.h libintl.h limits.h locale.h malloc.h netinet/in.h r
 # all we need is the preprocessor symbol defined since we don't need
 # LIBS to include libpthread for building flex.
 
+LIBPTHREAD=''
 AC_CHECK_LIB(pthread, pthread_mutex_lock,
-AC_DEFINE([HAVE_LIBPTHREAD], 1, [pthread library] ),
-AC_DEFINE([HAVE_LIBPTHREAD], 0, [pthread library] )
-)
-AC_CHECK_HEADERS([pthread.h])
-AM_CONDITIONAL([want_pthread], [test "x$ac_cv_lib_pthread_pthread_mutex_lock" = xyes])
+   [AC_CHECK_HEADERS([pthread.h], [LIBPTHREAD=-lpthread],
+      [AC_MSG_WARN([pthread tests will be skipped])])],
+   [AC_MSG_WARN([pthread tests will be skipped])])
+AC_SUBST([LIBPTHREAD])
 
 AC_CHECK_LIB(m, log10)
 
index 6b377052b36f727df22f007a08fd570a1f8616d7..845b76791e91fcb61b5189986153eff1a00c9e76 100644 (file)
@@ -113,10 +113,8 @@ DIRECT_TESTS = \
 I3_TESTS = \
        cxx_yywrap.i3
 
-if want_pthread
 PTHREAD_TESTS = \
        pthread.pthread
-endif
 
 ONE_TESTS = \
        lineno_nr.one \
@@ -331,7 +329,7 @@ dist_check_SCRIPTS = \
        testwrapper-direct.sh \
        testwrapper.sh
 
-pthread_pthread_LDADD = -lpthread
+pthread_pthread_LDADD = @LIBPTHREAD@
 
 # specify how to process .l files in order to test the flex built by make all
 
index 3f449d215712cea689959fbe22681a2df2eb18b3..eb9977860e2f74c86d940244984a412caa030bf2 100644 (file)
@@ -27,7 +27,7 @@
 
    We create N_THREADS number of threads. Each thread has it's own scanner.
    Each thread selects one of the files specified in ARGV, scans it, then
-   closes it. This is repeated N_SCANS numebr of times for each thread.
+   closes it. This is repeated N_SCANS number of times for each thread.
 
    The idea is to press the scanner to break under threads.
    If we see  "Scanner Jammed", then we know
@@ -90,18 +90,18 @@ static int process_text(char* s, yyscan_t  scanner)
 
 int main(int ARGC, char *ARGV[]);
 
-#ifndef HAVE_LIBPTHREAD
-  int main (int ARGC, char *ARGV[]) {
-    printf(
+#ifndef HAVE_PTHREAD_H
+int main (int ARGC, char *ARGV[]) {
+    puts(
        "TEST ABORTED because pthread library not available \n"
-       "-- This is expected on some systems. It is not a flex error.\n" );
-    return 0;
-  }
+       "-- This is expected on some systems. It is not a flex error.");
+    /* Exit status for a skipped test */
+    return 77;
+}
 #else
 
 #define N_THREADS 4
 #define N_SCANS   20
-#define INPUT_FILE "test.input"
 
 /* Each thread selects the next file to scan in round-robin fashion.
    If there are less files than threads, some threads may block. */
@@ -204,5 +204,5 @@ int main (int ARGC, char *ARGV[])
     return 0;
 }
 
-#endif /* HAVE_LIBPTHREAD */
+#endif /* HAVE_PTHREAD_H */