Skip to content

Commit

Permalink
Merge branch 'llvm-3.5' into llvm-3.6
Browse files Browse the repository at this point in the history
Additional tests for "make check".
  • Loading branch information
spakin committed Jul 22, 2015
2 parents 01ec567 + fb0e3f1 commit c89936f
Show file tree
Hide file tree
Showing 10 changed files with 236 additions and 15 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ before_install:
export CXX="clang++-${LLVM_VERSION}";
export CC="clang-${LLVM_VERSION}";
fi
- export LLVM_CONFIG=llvm-config-${LLVM_VERSION}
- export LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
- export BF_CLANG="clang-${LLVM_VERSION}"
- export BF_CLANGXX="clang++-${LLVM_VERSION}"
- export BF_GCC="gcc-{GCC_VERSION}"
- export BF_GXX="g++{GCC_VERSION}"

script:
- autoreconf -i && ./configure && make distcheck
Expand Down
5 changes: 5 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ else
ax_cv_file_dragonegg_so="$DRAGONEGG"
fi
AM_CONDITIONAL([HAVE_DRAGONEGG], [test x$ax_cv_file_dragonegg_so != xno])
if test x$ax_cv_file_dragonegg_so = xno ; then
AC_SUBST([use_dragonegg], [no])
else
AC_SUBST([use_dragonegg], [yes])
fi

dnl Generate all of the Byfl Makefiles and other files.
AC_CONFIG_FILES([Makefile])
Expand Down
37 changes: 32 additions & 5 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,45 @@
# By Scott Pakin <pakin@lanl.gov> #
###################################

TESTS = bf-clang-no-opts.sh
TESTS = \
bf-clang-no-opts.sh \
bf-clang++-no-opts.sh \
bf-gcc-no-opts.sh \
bf-clang-many-opts.sh

EXTRA_DIST = bf-clang-no-opts.sh simple.c
EXTRA_DIST = \
$(TESTS) \
simple.c \
simple.cpp

AM_TESTS_ENVIRONMENT = \
AWK='$(AWK)'; export AWK; \
PERL='$(PERL)'; export PERL; \
srcdir='$(srcdir)'; export srcdir; \
top_srcdir='$(top_srcdir)'; export top_srcdir; \
top_builddir='$(top_builddir)'; export top_builddir;
top_builddir='$(top_builddir)'; export top_builddir; \
use_dragonegg='$(use_dragonegg)'; export use_dragonegg;

CLEANFILES = simple simple.byfl
# bf-clang++ isn't normally symlinked until install time. Symlink it here.
bf-clang++-no-opts.sh: bf-clang++
bf-clang++: $(top_builddir)/tools/wrappers/bf-clang
$(LN_S) $(top_builddir)/tools/wrappers/bf-clang bf-clang++

CLEANFILES = \
simple-clang-no-opts \
simple-clang-no-opts.byfl \
simple-clang-many-opts \
simple-clang-many-opts.byfl \
simple-clang++-no-opts \
simple-clang++-no-opts.byfl \
simple-gcc-no-opts \
simple-gcc-no-opts.byfl \
simple.o \
bf-clang++

# On OS X we may wind up with a simple.dSYM directory that needs to be deleted.
clean-local:
$(RM) -r simple.dSYM
$(RM) -r simple-clang-no-opts.dSYM
$(RM) -r simple-clang-many-opts.dSYM
$(RM) -r simple-clang++-no-opts.dSYM
$(RM) -r simple-gcc-no-opts.dSYM
50 changes: 50 additions & 0 deletions tests/bf-clang++-no-opts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#! /bin/sh

##########################################
# Try compiling a simple program with #
# bf-clang++ and no special Byfl options #
# #
# By Scott Pakin <pakin@lanl.gov> #
##########################################

# Define some helper variables. The ":-" ones will normally be
# provided by the Makefile.
AWK=${AWK:-awk}
PERL=${PERL:-perl}
srcdir=${srcdir:-../../tests}
top_srcdir=${top_srcdir:-../..}
top_builddir=${top_builddir:-..}
clangxx=${BF_CLANGXX:-clang++}
bf_clangxx="./bf-clang++"

# Log everything we do. Fail on the first error.
set -e
set -x

# Test 1: Do the C compiler and linker work at all?
"$clangxx" -g -o simple-clang++-no-opts "$srcdir/simple.cpp"

# Test 2: Do the C compiler and linker work when invoked from the Byfl
# wrapper script?
env BF_DISABLE=byfl \
"$PERL" -I"$top_srcdir/tools/wrappers" \
"$bf_clangxx" -bf-plugin="$top_builddir/lib/bytesflops/.libs/bytesflops.so" \
-bf-verbose -g -o simple-clang++-no-opts "$srcdir/simple.cpp" \
-L"$top_builddir/lib/byfl/.libs"

# Test 3: Can the Byfl wrapper script compile, instrument, and link a program?
"$PERL" -I"$top_srcdir/tools/wrappers" \
"$bf_clangxx" -bf-plugin="$top_builddir/lib/bytesflops/.libs/bytesflops.so" \
-bf-verbose -g -o simple-clang++-no-opts "$srcdir/simple.cpp" \
-L"$top_builddir/lib/byfl/.libs"

# Test 4: Does the Byfl-instrumented program run without error?
env LD_LIBRARY_PATH="$top_builddir/lib/byfl/.libs:$LD_LIBRARY_PATH" \
./simple-clang++-no-opts

# Test 5: Can we postprocess the binary output? Are the results correct within
# an order of magnitude?
int_ops=`"$top_builddir/tools/postproc/bfbin2csv" --include=Program --flat-output simple-clang++-no-opts.byfl | "$AWK" -F, '$3 ~ /Integer operations/ {print $4}'`
if [ ! -z "$int_ops" ] && [ "$int_ops" -lt 100000 ] ; then
exit 1
fi
52 changes: 52 additions & 0 deletions tests/bf-clang-many-opts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#! /bin/sh

#######################################
# Try compiling a simple program with #
# bf-clang and many Byfl options #
# #
# By Scott Pakin <pakin@lanl.gov> #
#######################################

# Define some helper variables. The ":-" ones will normally be
# provided by the Makefile.
AWK=${AWK:-awk}
PERL=${PERL:-perl}
srcdir=${srcdir:-../../tests}
top_srcdir=${top_srcdir:-../..}
top_builddir=${top_builddir:-..}
clang=${BF_CLANG:-clang}
bf_clang="$top_builddir/tools/wrappers/bf-clang"

# Log everything we do. Fail on the first error.
set -e
set -x

# Test 1: Do the C compiler and linker work at all?
"$clang" -O2 -g -o simple-clang-many-opts "$srcdir/simple.c"

# Test 2: Do the C compiler and linker work when invoked from the Byfl
# wrapper script?
env BF_DISABLE=byfl \
"$PERL" -I"$top_srcdir/tools/wrappers" \
"$bf_clang" -bf-plugin="$top_builddir/lib/bytesflops/.libs/bytesflops.so" \
-bf-verbose -O2 -g -o simple-clang-many-opts "$srcdir/simple.c" \
-L"$top_builddir/lib/byfl/.libs" \
-bf-unique-bytes -bf-by-func -bf-call-stack -bf-vectors -bf-every-bb -bf-reuse-dist -bf-mem-footprint -bf-types -bf-inst-mix -bf-data-structs -bf-inst-deps

# Test 3: Can the Byfl wrapper script compile, instrument, and link a program?
"$PERL" -I"$top_srcdir/tools/wrappers" \
"$bf_clang" -bf-plugin="$top_builddir/lib/bytesflops/.libs/bytesflops.so" \
-bf-verbose -O2 -g -o simple-clang-many-opts "$srcdir/simple.c" \
-L"$top_builddir/lib/byfl/.libs" \
-bf-unique-bytes -bf-by-func -bf-call-stack -bf-vectors -bf-every-bb -bf-reuse-dist -bf-mem-footprint -bf-types -bf-inst-mix -bf-data-structs -bf-inst-deps

# Test 4: Does the Byfl-instrumented program run without error?
env LD_LIBRARY_PATH="$top_builddir/lib/byfl/.libs:$LD_LIBRARY_PATH" \
./simple-clang-many-opts

# Test 5: Can we postprocess the binary output? Are the results correct within
# an order of magnitude?
int_ops=`"$top_builddir/tools/postproc/bfbin2csv" --include=Program --flat-output simple-clang-many-opts.byfl | "$AWK" -F, '$3 ~ /Integer operations/ {print $4}'`
if [ ! -z "$int_ops" ] && [ "$int_ops" -lt 100000 ] ; then
exit 1
fi
19 changes: 14 additions & 5 deletions tests/bf-clang-no-opts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,42 @@

# Define some helper variables. The ":-" ones will normally be
# provided by the Makefile.
AWK=${AWK:-awk}
PERL=${PERL:-perl}
srcdir=${srcdir:-../../tests}
top_srcdir=${top_srcdir:-../..}
top_builddir=${top_builddir:-..}
clang=${BF_CLANG:-clang}
bf_clang="$top_builddir/tools/wrappers/bf-clang"

# Log everything we do.
# Log everything we do. Fail on the first error.
set -e
set -x

# Test 1: Do the C compiler and linker work at all?
"$clang" -g -o simple "$srcdir/simple.c"
"$clang" -g -o simple-clang-no-opts "$srcdir/simple.c"

# Test 2: Do the C compiler and linker work when invoked from the Byfl
# wrapper script?
env BF_DISABLE=byfl \
"$PERL" -I"$top_srcdir/tools/wrappers" \
"$bf_clang" -bf-plugin="$top_builddir/lib/bytesflops/.libs/bytesflops.so" \
-bf-verbose -g -o simple "$srcdir/simple.c" \
-bf-verbose -g -o simple-clang-no-opts "$srcdir/simple.c" \
-L"$top_builddir/lib/byfl/.libs"

# Test 3: Can the Byfl wrapper script compile, instrument, and link a program?
"$PERL" -I"$top_srcdir/tools/wrappers" \
"$bf_clang" -bf-plugin="$top_builddir/lib/bytesflops/.libs/bytesflops.so" \
-bf-verbose -g -o simple "$srcdir/simple.c" \
-bf-verbose -g -o simple-clang-no-opts "$srcdir/simple.c" \
-L"$top_builddir/lib/byfl/.libs"

# Test 4: Does the Byfl-instrumented program run without error?
env LD_LIBRARY_PATH="$top_builddir/lib/byfl/.libs:$LD_LIBRARY_PATH" \
./simple
./simple-clang-no-opts

# Test 5: Can we postprocess the binary output? Are the results correct within
# an order of magnitude?
int_ops=`"$top_builddir/tools/postproc/bfbin2csv" --include=Program --flat-output simple-clang-no-opts.byfl | "$AWK" -F, '$3 ~ /Integer operations/ {print $4}'`
if [ ! -z "$int_ops" ] && [ "$int_ops" -lt 100000 ] ; then
exit 1
fi
56 changes: 56 additions & 0 deletions tests/bf-gcc-no-opts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#! /bin/sh

#######################################
# Try compiling a simple program with #
# bf-gcc and no special Byfl options #
# #
# By Scott Pakin <pakin@lanl.gov> #
#######################################

# Define some helper variables. The ":-" ones will normally be
# provided by the Makefile.
AWK=${AWK:-awk}
PERL=${PERL:-perl}
srcdir=${srcdir:-../../tests}
top_srcdir=${top_srcdir:-../..}
top_builddir=${top_builddir:-..}
gcc=${BF_GCC:-gcc}
bf_gcc="$top_builddir/tools/wrappers/bf-gcc"
use_draongegg=${use_draongegg:-yes}

# Skip this test if we don't have DragonEgg.
if [ "x$use_dragonegg" != xyes ] ; then
exit 77
fi

# Log everything we do. Fail on the first error.
set -e
set -x

# Test 1: Do the C compiler and linker work at all?
"$gcc" -g -o simple-gcc-no-opts "$srcdir/simple.c"

# Test 2: Do the C compiler and linker work when invoked from the Byfl
# wrapper script?
env BF_DISABLE=byfl \
"$PERL" -I"$top_srcdir/tools/wrappers" \
"$bf_gcc" -bf-plugin="$top_builddir/lib/bytesflops/.libs/bytesflops.so" \
-bf-verbose -g -o simple-gcc-no-opts "$srcdir/simple.c" \
-L"$top_builddir/lib/byfl/.libs"

# Test 3: Can the Byfl wrapper script compile, instrument, and link a program?
"$PERL" -I"$top_srcdir/tools/wrappers" \
"$bf_gcc" -bf-plugin="$top_builddir/lib/bytesflops/.libs/bytesflops.so" \
-bf-verbose -g -o simple-gcc-no-opts "$srcdir/simple.c" \
-L"$top_builddir/lib/byfl/.libs"

# Test 4: Does the Byfl-instrumented program run without error?
env LD_LIBRARY_PATH="$top_builddir/lib/byfl/.libs:$LD_LIBRARY_PATH" \
./simple-gcc-no-opts

# Test 5: Can we postprocess the binary output? Are the results correct within
# an order of magnitude?
int_ops=`"$top_builddir/tools/postproc/bfbin2csv" --include=Program --flat-output simple-gcc-no-opts.byfl | "$AWK" -F, '$3 ~ /Integer operations/ {print $4}'`
if [ ! -z "$int_ops" ] && [ "$int_ops" -lt 100000 ] ; then
exit 1
fi
2 changes: 1 addition & 1 deletion tests/simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

int main (int argc, char *argv[])
{
int iters = argc > 1 ? atoi(argv[1]) : 1000;
int iters = argc > 1 ? atoi(argv[1]) : 100000;
int i;
int sum = 0;

Expand Down
19 changes: 19 additions & 0 deletions tests/simple.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/***********************************
* Do some simple, pointless work *
* By Scott Pakin <pakin@lanl.gov> *
***********************************/

#include <iostream>
#include <cstdlib>

int main (int argc, const char *argv[])
{
int iters = argc > 1 ? atoi(argv[1]) : 100000;
int i;
int sum = 0;

for (i = 0; i < iters; i++)
sum = sum*34564793 + i;
std::cout << "Sum is " << sum << '\n';
return 0;
}
5 changes: 2 additions & 3 deletions tools/wrappers/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
# By Scott Pakin <pakin@lanl.gov> #
############################################


if HAVE_DRAGONEGG
BF_GCC=bf-gcc
BF_GCC_SCRIPT=bf-gcc
endif

nodist_bin_SCRIPTS = \
$(BF_GCC) \
$(BF_GCC_SCRIPT) \
bf-clang \
bf-inst

Expand Down

0 comments on commit c89936f

Please sign in to comment.