From b64c9051e7f39cd93e909565ec59a05957b80f91 Mon Sep 17 00:00:00 2001 From: John Regehr Date: Wed, 21 Feb 2018 10:13:30 -0700 Subject: [PATCH] remove unsupported utah-local scripts --- utah/autoconf/README | 9 - utah/autoconf/ax_boost_base.m4 | 198 --- utah/autoconf/ax_boost_program_options.m4 | 105 -- utah/scripts/README.TXT | 3 - utah/scripts/coverage/README.COV | 67 - utah/scripts/coverage/build_gcov_compilers.pl | 321 ----- utah/scripts/coverage/gen_cov.pl | 340 ------ utah/scripts/coverage/parse_cov_results.pl | 247 ---- utah/scripts/jxyang/RunSafely.sh | 168 --- utah/scripts/jxyang/compilers.txt | 14 - utah/scripts/jxyang/parallel_test.pl | 48 - utah/scripts/jxyang/setup.sh | 16 - utah/scripts/jxyang/test.pl | 356 ------ utah/scripts/old_john_driver/RunSafely.sh | 168 --- .../scripts/old_john_driver/build_compiler.pl | 295 ----- .../old_john_driver/evaluate_program.pl | 1086 ----------------- utah/scripts/old_john_driver/find_crash.pl | 27 - utah/scripts/old_john_driver/kill_random.pl | 13 - utah/scripts/old_john_driver/launchn.pl | 50 - utah/scripts/old_john_driver/random_test.pl | 303 ----- .../random_test_llvm_killer.pl | 50 - utah/scripts/old_john_driver/run_program.pl | 487 -------- utah/scripts/old_john_driver/see_results.sh | 3 - utah/scripts/old_john_driver/test_csmith.pl | 185 --- utah/scripts/one_off/binsrch_det.pl | 129 -- utah/scripts/one_off/binsrch_randomized.pl | 91 -- utah/scripts/one_off/collect_results.pl | 34 - utah/scripts/one_off/compare_size.pl | 62 - utah/scripts/one_off/compare_sizes.pl | 28 - utah/scripts/one_off/compiler_test_xuejun.txt | 57 - utah/scripts/one_off/conf.pl | 118 -- .../create_result_table_for_journal_paper.pl | 344 ------ utah/scripts/one_off/extract_csum.pl | 14 - utah/scripts/one_off/find_args.pl | 62 - utah/scripts/one_off/find_termination_bugs.pl | 96 -- utah/scripts/one_off/make_progs.pl | 24 - utah/scripts/one_off/nonterm.pl | 36 - utah/scripts/one_off/normalize.pl | 44 - utah/scripts/one_off/quest_test.pl | 62 - utah/scripts/one_off/random_test_vc.pl | 207 ---- utah/scripts/one_off/reducer_driver.pl | 315 ----- utah/scripts/one_off/run_tests.pl | 71 -- utah/scripts/one_off/runit_test.pl | 64 - utah/scripts/one_off/select_writes.pl | 10 - utah/scripts/one_off/simd.pl | 132 -- utah/scripts/one_off/size_hist.pl | 65 - utah/scripts/one_off/size_test.pl | 24 - utah/scripts/one_off/small_seeds.pl | 53 - utah/scripts/one_off/test_clang.pl | 44 - utah/scripts/one_off/test_clang2.pl | 45 - utah/scripts/one_off/test_compcert.pl | 82 -- utah/scripts/one_off/test_framac.pl | 179 --- utah/scripts/one_off/test_warnings.pl | 118 -- utah/scripts/one_off/testlto.pl | 35 - utah/scripts/one_off/unwrap_math.pl | 147 --- utah/scripts/seq_reduce/seq_reduce.pl | 375 ------ 56 files changed, 7726 deletions(-) delete mode 100644 utah/autoconf/README delete mode 100644 utah/autoconf/ax_boost_base.m4 delete mode 100644 utah/autoconf/ax_boost_program_options.m4 delete mode 100644 utah/scripts/README.TXT delete mode 100644 utah/scripts/coverage/README.COV delete mode 100755 utah/scripts/coverage/build_gcov_compilers.pl delete mode 100755 utah/scripts/coverage/gen_cov.pl delete mode 100755 utah/scripts/coverage/parse_cov_results.pl delete mode 100644 utah/scripts/jxyang/RunSafely.sh delete mode 100644 utah/scripts/jxyang/compilers.txt delete mode 100644 utah/scripts/jxyang/parallel_test.pl delete mode 100644 utah/scripts/jxyang/setup.sh delete mode 100644 utah/scripts/jxyang/test.pl delete mode 100755 utah/scripts/old_john_driver/RunSafely.sh delete mode 100755 utah/scripts/old_john_driver/build_compiler.pl delete mode 100755 utah/scripts/old_john_driver/evaluate_program.pl delete mode 100755 utah/scripts/old_john_driver/find_crash.pl delete mode 100755 utah/scripts/old_john_driver/kill_random.pl delete mode 100755 utah/scripts/old_john_driver/launchn.pl delete mode 100755 utah/scripts/old_john_driver/random_test.pl delete mode 100755 utah/scripts/old_john_driver/random_test_llvm_killer.pl delete mode 100755 utah/scripts/old_john_driver/run_program.pl delete mode 100755 utah/scripts/old_john_driver/see_results.sh delete mode 100755 utah/scripts/old_john_driver/test_csmith.pl delete mode 100755 utah/scripts/one_off/binsrch_det.pl delete mode 100755 utah/scripts/one_off/binsrch_randomized.pl delete mode 100755 utah/scripts/one_off/collect_results.pl delete mode 100755 utah/scripts/one_off/compare_size.pl delete mode 100755 utah/scripts/one_off/compare_sizes.pl delete mode 100644 utah/scripts/one_off/compiler_test_xuejun.txt delete mode 100755 utah/scripts/one_off/conf.pl delete mode 100755 utah/scripts/one_off/create_result_table_for_journal_paper.pl delete mode 100755 utah/scripts/one_off/extract_csum.pl delete mode 100755 utah/scripts/one_off/find_args.pl delete mode 100755 utah/scripts/one_off/find_termination_bugs.pl delete mode 100755 utah/scripts/one_off/make_progs.pl delete mode 100755 utah/scripts/one_off/nonterm.pl delete mode 100755 utah/scripts/one_off/normalize.pl delete mode 100755 utah/scripts/one_off/quest_test.pl delete mode 100755 utah/scripts/one_off/random_test_vc.pl delete mode 100755 utah/scripts/one_off/reducer_driver.pl delete mode 100755 utah/scripts/one_off/run_tests.pl delete mode 100755 utah/scripts/one_off/runit_test.pl delete mode 100755 utah/scripts/one_off/select_writes.pl delete mode 100755 utah/scripts/one_off/simd.pl delete mode 100755 utah/scripts/one_off/size_hist.pl delete mode 100755 utah/scripts/one_off/size_test.pl delete mode 100755 utah/scripts/one_off/small_seeds.pl delete mode 100755 utah/scripts/one_off/test_clang.pl delete mode 100755 utah/scripts/one_off/test_clang2.pl delete mode 100755 utah/scripts/one_off/test_compcert.pl delete mode 100755 utah/scripts/one_off/test_framac.pl delete mode 100755 utah/scripts/one_off/test_warnings.pl delete mode 100755 utah/scripts/one_off/testlto.pl delete mode 100755 utah/scripts/one_off/unwrap_math.pl delete mode 100755 utah/scripts/seq_reduce/seq_reduce.pl diff --git a/utah/autoconf/README b/utah/autoconf/README deleted file mode 100644 index a3b51d5f7..000000000 --- a/utah/autoconf/README +++ /dev/null @@ -1,9 +0,0 @@ -## -*- mode: Text -*- - -The files in this directory come from the Autoconf macro archive: - - http://www.gnu.org/software/ac-archive/ - -We copy these into the `acinclude.m4' file for this project. - -## End of file. diff --git a/utah/autoconf/ax_boost_base.m4 b/utah/autoconf/ax_boost_base.m4 deleted file mode 100644 index e56bb7380..000000000 --- a/utah/autoconf/ax_boost_base.m4 +++ /dev/null @@ -1,198 +0,0 @@ -##### http://autoconf-archive.cryp.to/ax_boost_base.html -# -# SYNOPSIS -# -# AX_BOOST_BASE([MINIMUM-VERSION]) -# -# DESCRIPTION -# -# Test for the Boost C++ libraries of a particular version (or newer) -# -# If no path to the installed boost library is given the macro -# searchs under /usr, /usr/local, /opt and /opt/local and evaluates -# the $BOOST_ROOT environment variable. Further documentation is -# available at . -# -# This macro calls: -# -# AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS) -# -# And sets: -# -# HAVE_BOOST -# -# LAST MODIFICATION -# -# 2007-07-28 -# -# COPYLEFT -# -# Copyright (c) 2007 Thomas Porschberg -# -# Copying and distribution of this file, with or without -# modification, are permitted in any medium without royalty provided -# the copyright notice and this notice are preserved. - -AC_DEFUN([AX_BOOST_BASE], -[ -AC_ARG_WITH([boost], - AS_HELP_STRING([--with-boost@<:@=DIR@:>@], [use boost (default is yes) - it is possible to specify the root directory for boost (optional)]), - [ - if test "$withval" = "no"; then - want_boost="no" - elif test "$withval" = "yes"; then - want_boost="yes" - ac_boost_path="" - else - want_boost="yes" - ac_boost_path="$withval" - fi - ], - [want_boost="yes"]) - -if test "x$want_boost" = "xyes"; then - boost_lib_version_req=ifelse([$1], ,1.20.0,$1) - boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'` - boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'` - boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'` - boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` - if test "x$boost_lib_version_req_sub_minor" = "x" ; then - boost_lib_version_req_sub_minor="0" - fi - WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor` - AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req) - succeeded=no - - dnl first we check the system location for boost libraries - dnl this location ist chosen if boost libraries are installed with the --layout=system option - dnl or if you install boost with RPM - if test "$ac_boost_path" != ""; then - BOOST_LDFLAGS="-L$ac_boost_path/lib" - BOOST_CPPFLAGS="-I$ac_boost_path/include" - else - for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do - if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then - BOOST_LDFLAGS="-L$ac_boost_path_tmp/lib" - BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include" - break; - fi - done - fi - - CPPFLAGS_SAVED="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" - export CPPFLAGS - - LDFLAGS_SAVED="$LDFLAGS" - LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" - export LDFLAGS - - AC_LANG_PUSH(C++) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - @%:@include - ]], [[ - #if BOOST_VERSION >= $WANT_BOOST_VERSION - // Everything is okay - #else - # error Boost version is too old - #endif - ]])],[ - AC_MSG_RESULT(yes) - succeeded=yes - found_system=yes - ],[ - ]) - AC_LANG_POP([C++]) - - - - dnl if we found no boost with system layout we search for boost libraries - dnl built and installed without the --layout=system option or for a staged(not installed) version - if test "x$succeeded" != "xyes"; then - _version=0 - if test "$ac_boost_path" != ""; then - BOOST_LDFLAGS="-L$ac_boost_path/lib" - if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then - for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do - _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` - V_CHECK=`expr $_version_tmp \> $_version` - if test "$V_CHECK" = "1" ; then - _version=$_version_tmp - fi - VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` - BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE" - done - fi - else - for ac_boost_path in /usr /usr/local /opt /opt/local ; do - if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then - for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do - _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` - V_CHECK=`expr $_version_tmp \> $_version` - if test "$V_CHECK" = "1" ; then - _version=$_version_tmp - best_path=$ac_boost_path - fi - done - fi - done - - VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` - BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE" - BOOST_LDFLAGS="-L$best_path/lib" - - if test "x$BOOST_ROOT" != "x"; then - if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/lib" && test -r "$BOOST_ROOT/stage/lib"; then - version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'` - stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'` - stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'` - V_CHECK=`expr $stage_version_shorten \>\= $_version` - if test "$V_CHECK" = "1" ; then - AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT) - BOOST_CPPFLAGS="-I$BOOST_ROOT" - BOOST_LDFLAGS="-L$BOOST_ROOT/stage/lib" - fi - fi - fi - fi - - CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" - export CPPFLAGS - LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" - export LDFLAGS - - AC_LANG_PUSH(C++) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - @%:@include - ]], [[ - #if BOOST_VERSION >= $WANT_BOOST_VERSION - // Everything is okay - #else - # error Boost version is too old - #endif - ]])],[ - AC_MSG_RESULT(yes) - succeeded=yes - found_system=yes - ],[ - ]) - AC_LANG_POP([C++]) - fi - - if test "$succeeded" != "yes" ; then - if test "$_version" = "0" ; then - AC_MSG_ERROR([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in . See http://randspringer.de/boost for more documentation.]]) - else - AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).]) - fi - else - AC_SUBST(BOOST_CPPFLAGS) - AC_SUBST(BOOST_LDFLAGS) - AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available]) - fi - - CPPFLAGS="$CPPFLAGS_SAVED" - LDFLAGS="$LDFLAGS_SAVED" -fi - -]) diff --git a/utah/autoconf/ax_boost_program_options.m4 b/utah/autoconf/ax_boost_program_options.m4 deleted file mode 100644 index 8bbc2fc00..000000000 --- a/utah/autoconf/ax_boost_program_options.m4 +++ /dev/null @@ -1,105 +0,0 @@ -##### http://autoconf-archive.cryp.to/ax_boost_program_options.html -# -# SYNOPSIS -# -# AX_BOOST_PROGRAM_OPTIONS -# -# DESCRIPTION -# -# Test for program options library from the Boost C++ libraries. The -# macro requires a preceding call to AX_BOOST_BASE. Further -# documentation is available at -# . -# -# This macro calls: -# -# AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) -# -# And sets: -# -# HAVE_BOOST_PROGRAM_OPTIONS -# -# LAST MODIFICATION -# -# 2007-11-22 -# -# COPYLEFT -# -# Copyright (c) 2007 Thomas Porschberg -# -# Copying and distribution of this file, with or without -# modification, are permitted in any medium without royalty provided -# the copyright notice and this notice are preserved. - -AC_DEFUN([AX_BOOST_PROGRAM_OPTIONS], -[ - AC_ARG_WITH([boost-program-options], - AS_HELP_STRING([--with-boost-program-options@<:@=special-lib@:>@], - [use the program options library from boost - it is possible to specify a certain library for the linker - e.g. --with-boost-program-options=boost_program_options-gcc-mt-1_33_1 ]), - [ - if test "$withval" = "no"; then - want_boost="no" - elif test "$withval" = "yes"; then - want_boost="yes" - ax_boost_user_program_options_lib="" - else - want_boost="yes" - ax_boost_user_program_options_lib="$withval" - fi - ], - [want_boost="yes"] - ) - - if test "x$want_boost" = "xyes"; then - AC_REQUIRE([AC_PROG_CC]) - export want_boost - CPPFLAGS_SAVED="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" - export CPPFLAGS - LDFLAGS_SAVED="$LDFLAGS" - LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" - export LDFLAGS - AC_CACHE_CHECK([whether the Boost::Program_Options library is available], - ax_cv_boost_program_options, - [AC_LANG_PUSH(C++) - AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include - ]], - [[boost::program_options::options_description generic("Generic options"); - return 0;]]), - ax_cv_boost_program_options=yes, ax_cv_boost_program_options=no) - AC_LANG_POP([C++]) - ]) - if test "$ax_cv_boost_program_options" = yes; then - AC_DEFINE(HAVE_BOOST_PROGRAM_OPTIONS,,[define if the Boost::PROGRAM_OPTIONS library is available]) - BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'` - if test "x$ax_boost_user_program_options_lib" = "x"; then - for libextension in `ls $BOOSTLIBDIR/libboost_program_options*.{so,a}* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_program_options.*\)\.so.*$;\1;' -e 's;^lib\(boost_program_options.*\)\.a*$;\1;'` ; do - ax_lib=${libextension} - AC_CHECK_LIB($ax_lib, exit, - [BOOST_PROGRAM_OPTIONS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) link_program_options="yes"; break], - [link_program_options="no"]) - done - if test "x$link_program_options" != "xyes"; then - for libextension in `ls $BOOSTLIBDIR/boost_program_options*.{dll,a}* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_program_options.*\)\.dll.*$;\1;' -e 's;^\(boost_program_options.*\)\.a*$;\1;'` ; do - ax_lib=${libextension} - AC_CHECK_LIB($ax_lib, exit, - [BOOST_PROGRAM_OPTIONS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) link_program_options="yes"; break], - [link_program_options="no"]) - done - fi - else - for ax_lib in $ax_boost_user_program_options_lib boost_program_options-$ax_boost_user_program_options_lib; do - AC_CHECK_LIB($ax_lib, main, - [BOOST_PROGRAM_OPTIONS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) link_program_options="yes"; break], - [link_program_options="no"]) - done - fi - if test "x$link_program_options" != "xyes"; then - AC_MSG_ERROR([Could not link against [$ax_lib] !]) - fi - fi - CPPFLAGS="$CPPFLAGS_SAVED" - LDFLAGS="$LDFLAGS_SAVED" - fi -]) diff --git a/utah/scripts/README.TXT b/utah/scripts/README.TXT deleted file mode 100644 index 78fc2a200..000000000 --- a/utah/scripts/README.TXT +++ /dev/null @@ -1,3 +0,0 @@ -N.B. probably none of these scripts is generally useful. The -"csmith/scripts" directory contains programs believed to be useful to -people who are not Csmith developers. \ No newline at end of file diff --git a/utah/scripts/coverage/README.COV b/utah/scripts/coverage/README.COV deleted file mode 100644 index 8647839bd..000000000 --- a/utah/scripts/coverage/README.COV +++ /dev/null @@ -1,67 +0,0 @@ - -- This is the README for coverage tests - -************************************************************ -- Quick start to build optimized compilers: - * setup $COV_BASE_HOME environment, e.g in bash: - export COV_BASE_HOME=/uusoc/exports/scratch/chenyang/branch-test, - where holds all coverage stuff - - * cd $COV_BASE_HOME - mkdir sources - - and check out csmith: - - svn co svn+ssh://bas.flux.utah.edu/home/eeide/cs6110/project/svn/csmith/trunk csmith - - * cd csmith/utah/scripts - - * ./build_gcov_compilers.pl -enable-opt - - * optimized gcc and clang were installed in $COV_BASE_HOME/bin - -************************************************************ - -- Coverage test steps: - - * setup $COV_BASE_HOME environment, e.g in bash: - export COV_BASE_HOME=/uusoc/exports/scratch/chenyang/branch-test, - where holds all coverage stuff - - * cd $COV_BASE_HOME - mkdir sources - - and check out csmith: - - svn co svn+ssh://bas.flux.utah.edu/home/eeide/cs6110/project/svn/csmith/trunk csmith - - and the hacked lcov: - - svn co svn+ssh://shell.cs.utah.edu/uusoc/res/embed/users/regehr/embedded_code_repo/yang/coverage/lcov-1.8 lcov-1.8 - - * run build_gcov_compilers.pl script, which will: - - - download compilers sources to $COV_BASE_HOME/sources; - - - build compilers with appropriate options - - - install compilers to $COV_BASE_HOME - - * run gen_cov.pl, which will run coverage tests for llvm and gcc. - For each tested compilers, the script will: - - - run the compilers' testsuite, - - - generate coverage data for the above test, two important data: - ${compiler}_summary.txt: At the bottom of this file, you will see the summary - of line, function and branch coverage; - - ${compiler}_html: this dir contains all coverage htmls - - - run csmith to generate 10,000 random programs, and compile those programs - using the tested compilers; - - - generate accumulated coverage data: - - ${compiler}_summary_ext.txt and ${compiler}_html_ext - diff --git a/utah/scripts/coverage/build_gcov_compilers.pl b/utah/scripts/coverage/build_gcov_compilers.pl deleted file mode 100755 index cd3473c9a..000000000 --- a/utah/scripts/coverage/build_gcov_compilers.pl +++ /dev/null @@ -1,321 +0,0 @@ -#!/usr/bin/perl - -use strict; -use File::Spec::Functions qw(splitpath); -use Sys::CPU; - -######################################################## - -my $NICE = "nice -10"; - -my $CPUS = Sys::CPU::cpu_count(); - -my $COV_BASE_HOME = $ENV{"COV_BASE_HOME"}; - -######################################################## - -#die "please set env $COV_BASE_HOME first!" -# if (!defined($COV_BASE_HOME)); - -# for my convenience -if (!defined($COV_BASE_HOME)) { - $COV_BASE_HOME = "/uusoc/exports/scratch/chenyang/tmp/branch_test"; -} - -my $COMPILER_SOURCES_HOME = "$COV_BASE_HOME/sources"; - -my @compilers = ( - "gcc", - "llvm", - "llvm-regular", - "llvm-gcc", -); - -my %paths = ( - "gcc" => ["$COMPILER_SOURCES_HOME", "current-gcc"], - "llvm" => ["$COMPILER_SOURCES_HOME", "llvm"], - "llvm-regular" => ["$COMPILER_SOURCES_HOME", "llvm-regular"], - "llvm-gcc" => ["$COMPILER_SOURCES_HOME", "llvm-gcc-4.2"], - "clang" => ["$COMPILER_SOURCES_HOME/llvm/tools", "clang"], - "llvm-testsuite" => ["$COMPILER_SOURCES_HOME/llvm/projects", "test-suite"], -); - -my %svn_dependencies = ( - "llvm" => "clang", -); - -my %svn_repos = ( - "gcc" => "svn://gcc.gnu.org/svn/gcc/trunk", - "llvm" => "http://llvm.org/svn/llvm-project/llvm/trunk", - "llvm-regular" => "http://llvm.org/svn/llvm-project/llvm/trunk", - "llvm-gcc" => "http://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk", - "clang" => "http://llvm.org/svn/llvm-project/cfe/trunk", - "llvm-testsuite" => "http://llvm.org/svn/llvm-project/test-suite/trunk", -); - -my %dependencies = ( - "gcc" => ["gmp", "mpc", "mpfr", "libelf"], -); - -my %programs = ( - "gmp" => "ftp://ftp.gmplib.org/pub/gmp-5.0.1/gmp-5.0.1.tar.bz2", - "mpfr" => "http://www.mpfr.org/mpfr-current/mpfr-3.0.0.tar.gz", - "mpc" => "http://www.multiprecision.org/mpc/download/mpc-0.8.2.tar.gz", - "libelf" => "http://www.mr511.de/software/libelf-0.8.13.tar.gz", -); - -my $enable_optimized = ""; - -my %config_options = ( - "gcc" => "--prefix=$COV_BASE_HOME --program-prefix=current- --enable-languages=c,c++ --enable-lto --enable-coverage --disable-bootstrap", - "gcc-opt" => "--prefix=$COV_BASE_HOME --program-prefix=current- --enable-languages=c,c++ --enable-lto --enable-coverage=opt --disable-bootstrap", - "llvm" => "--prefix=$COV_BASE_HOME", - "llvm-opt" => "--prefix=$COV_BASE_HOME --enable-optimized", - "llvm-regular" => "--prefix=$COV_BASE_HOME --enable-optimized", - "llvm-gcc" => "--prefix=$COV_BASE_HOME --enable-languages=c,c++ --program-prefix=llvm- --enable-checking --enable-llvm=$COMPILER_SOURCES_HOME/llvm-regular/build --disable-bootstrap --disable-multilib", -); - -my %make_options = ( - "gcc" => "", - "llvm" => "ENABLE_COVERAGE=1", - "llvm-regular" => "", - "llvm-gcc" => "", -); - -sub runit ($) { - my $cmd = shift; - print "$cmd\n"; - if ((system "$NICE $cmd") != 0) { - return -1; - } - my $exit_value = $? >> 8; - return $exit_value; -} - -sub parse_path($) { - my ($path) = @_; - return (@$path[0], @$path[1]); -} - -sub download($$$$); -sub download($$$$) { - my ($program, $path, $dir, $svn_repo) = @_; - my $prog_path = "$path/$dir"; - - if (-d "$prog_path") { - print "changing to $prog_path\n"; - chdir $prog_path or die; - my $cmd = "svn update ."; - my $res = runit($cmd); - if ($res == 0) { - return; - } - else { - system "rm -rf $prog_path"; - } - } - - print "changing to $path\n"; - chdir $path or die; - my $cmd = "svn co $svn_repo $dir"; - my $res = runit($cmd); - die "can't check out $program from $svn_repo to $path/$dir" - if ($res != 0); - - my $extra_program = $svn_dependencies{$program}; - return if (!defined($extra_program)); - my ($extra_path, $extra_dir) = parse_path($paths{$extra_program}); - my $extra_svn_repo = $svn_repos{$extra_program}; - download($extra_program, $extra_path, $extra_dir, $extra_svn_repo); -} - -sub download_dependencies($$) { - my ($program, $path) = @_; - my $extra_programs = $dependencies{$program}; - - return if (!defined($extra_programs)); - - print "chaning to $path\n"; - chdir $path or die; - foreach my $extra_program (@$extra_programs) { - my $orig_program_path = $programs{$extra_program}; - my ($dummy1, $dummy2, $orig_program) = splitpath($orig_program_path); - - my ($cmd, $res); - if (!(-f $orig_program)) { - $cmd = "wget $orig_program_path"; - $res = runit($cmd); - die "can't wget $orig_program_path" if ($res != 0); - die "can't download $orig_program_path" - if (!(-f $orig_program)); - } - - my $uncompressed_name; - if ($orig_program =~ m/(.+)\.tar$/) { - $cmd = "tar xvf $orig_program"; - $uncompressed_name = $1; - } - elsif ($orig_program =~ m/(.+)\.tar\.gz$/) { - $cmd = "tar zxvf $orig_program"; - $uncompressed_name = $1; - } - elsif ($orig_program =~ m/(.+)\.tar.bz2$/) { - $cmd = "bzip2 -d -c $orig_program | tar xvf -"; - $uncompressed_name = $1; - } - else { - die "unsupported file format: $orig_program"; - } - - $res = runit($cmd); - die "can't uncompress $orig_program" if ($res != 0); - die "$uncompressed_name doesn't exist!" - if (!(-d $uncompressed_name)); - system "rm -rf $extra_program"; - system "mv $uncompressed_name $extra_program"; - } -} - - -sub download_all() { - foreach my $program (@compilers) { - my ($path, $dir) = parse_path($paths{$program}); - my $svn_repo = $svn_repos{$program}; - - download($program, $path, $dir, $svn_repo); - download_dependencies($program, "$path/$dir"); - } -} - -sub configure($$) { - my ($compiler, $build_path) = @_; - - if (($compiler eq "llvm") || ($compiler eq "gcc")) { - $compiler .= $enable_optimized; - } - my $config_option = $config_options{$compiler}; - - die if (!defined $config_option); - system "rm -rf $build_path"; - mkdir "$build_path" or die; - - print "chaning to $build_path\n"; - chdir "$build_path" or die; - - #my $cmd = "../configure $config_option > /dev/null 2>&1"; - my $cmd = "../configure $config_option"; - my $res = runit($cmd); - die "can't configure $compiler!" if ($res != 0); -} - -sub make($$) { - my ($compiler, $build_path) = @_; - my $make_option = $make_options{$compiler}; - - print "chaning to $build_path\n"; - chdir $build_path or die; - - #my $cmd = "make $make_option > /dev/null 2>&1"; - my $cmd = "make -j $CPUS $make_option"; - my $res = runit($cmd); - die "can't make $compiler!" if ($res != 0); - - #$cmd = "make $make_option install > /dev/null 2>&1"; - if ($compiler ne "llvm-regular") { - $cmd = "make -j $CPUS $make_option install"; - $res = runit($cmd); - } - #die "can't install $compiler!" if ($res != 0); -} - -sub verify($$) { - my ($compiler, $build_path) = @_; - - print "changing to $build_path\n"; - chdir $build_path or die; - my $files = "*.gcno"; - my @gcnos = `find . -name $files`; - die "*.gcno doesn't exist!" if (@gcnos == 0); -} - -sub prepare_testsuites() { - my $program = "llvm-testsuite"; - my ($path, $dir) = parse_path($paths{$program}); - my $svn_repo = $svn_repos{$program}; - - download($program, $path, $dir, $svn_repo); - - my $working_dir = "$COMPILER_SOURCES_HOME/llvm/build"; - print "chaning to $working_dir\n"; - chdir $working_dir or die; - - my $cp_cmd; - - if ($enable_optimized eq '') { - $cp_cmd = 'cp -r Debug+Coverage+Asserts Debug+Asserts'; - } - else { - $cp_cmd = 'cp -r Release+Coverage+Asserts Release+Asserts'; - } - - my $res = runit($cp_cmd); - die "Can't exec $cp_cmd" if ($res != 0); - - $ENV{"PATH"} = "$COV_BASE_HOME/bin:$ENV{'PATH'}"; - my $opt = ""; - $opt = "--enable-optimized" if (not ($enable_optimized eq "")); - $res = runit("../configure $opt"); - die "Can't configure llvm-testsuite!" if ($res != 0); -} - -sub go_build() { - foreach (@compilers) { - my ($path, $dir) = parse_path($paths{$_}); - my $build_path = "$path/$dir/build"; - configure($_, $build_path); - make($_, $build_path); - if (($_ eq "llvm") || ($_ eq "gcc")) { - verify($_, $build_path); - } - if ($_ eq "llvm") { - prepare_testsuites(); - } - } -} - -sub help() { - print "build_gcov_compiler.pl [-no-update] [-enable-opt]\n"; -} - -sub main() { - my $opt; - my @unused = (); - my $update = 1; - while(defined ($opt = shift @ARGV)) { - if ($opt eq "-no-update") { - $update = 0; - } - elsif ($opt eq "-enable-opt") { - $enable_optimized = "-opt"; - } - else { - help(); - die; - } - } - - if ($update) { - download_all(); - } - go_build(); -} - -if (!(-d $COV_BASE_HOME)) { - mkdir $COV_BASE_HOME or die; -} -if (!(-d "$COMPILER_SOURCES_HOME")) { - mkdir "$COMPILER_SOURCES_HOME" or die; -} - -main(); - diff --git a/utah/scripts/coverage/gen_cov.pl b/utah/scripts/coverage/gen_cov.pl deleted file mode 100755 index e74f53bbc..000000000 --- a/utah/scripts/coverage/gen_cov.pl +++ /dev/null @@ -1,340 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; -use Digest::MD5 qw(md5); -use File::stat; - -my $COV_BASE_HOME = $ENV{"COV_BASE_HOME"}; - -#die "please set env $COV_BASE_HOME first!" -# if (!defined($COV_BASE_HOME)); - -# for my convenience -if (!defined($COV_BASE_HOME)) { - $COV_BASE_HOME = "/uusoc/exports/scratch/chenyang/branch-test"; -} - -my $PATH = "$COV_BASE_HOME/bin"; -my $COMPILER_SOURCES_HOME = "$COV_BASE_HOME/sources"; - -# tmp setting on bethe where expect was installed locally -# we don't need those if expect was installed via apt-get, etc -my $EXPECT_BASE_HOME = "$COV_BASE_HOME/expect/usr"; - -my $VOLATILE_HOME = "$COMPILER_SOURCES_HOME/volatile"; - -$PATH = "$EXPECT_BASE_HOME/bin:$VOLATILE_HOME:$PATH"; - -$ENV{"PATH"} = "$PATH:$ENV{'PATH'}"; - -if (defined($ENV{'LD_LIBRARY_PATH'})) { - $ENV{"LD_LIBRARY_PATH"} = "$EXPECT_BASE_HOME/lib:$ENV{'LD_LIBRARY_PATH'}"; -} -else { - $ENV{"LD_LIBRARY_PATH"} = "$EXPECT_BASE_HOME/lib"; -} - -my $CSMITH_HOME = "$COMPILER_SOURCES_HOME/csmith"; -my $CSMITH = "$CSMITH_HOME/src/csmith"; - -my $LCOV_HOME = "$COMPILER_SOURCES_HOME/lcov-1.8/bin"; -my $LCOV = "$LCOV_HOME/lcov"; -my $LCOV_GEN_HTML = "$LCOV_HOME/genhtml"; -my $COV_DATA_HOME = "$COV_BASE_HOME/test_data"; - -my %compilers = ( - "gcc" => "$COV_BASE_HOME/bin/current-gcc", - #"clang" => "$COV_BASE_HOME/bin/clang", - "llvm" => "$COV_BASE_HOME/bin/clang", -); - -my %compiler_build_paths = ( - "gcc" => "$COMPILER_SOURCES_HOME/current-gcc/build", - "llvm" => "$COMPILER_SOURCES_HOME/llvm/build", - "clang" => "$COMPILER_SOURCES_HOME/llvm/build/tools/clang", - "llvm-testsuite" => "$COMPILER_SOURCES_HOME/llvm/build/projects/test-suite", -); - -my %base_cov_dirs = ( - "gcc" => "$COMPILER_SOURCES_HOME/current-gcc/build/gcc", -); - -my %base_checks = ( - "gcc" => ["gcc", "make check-c"], - "llvm" => ["llvm", "ENABLE_COVERAGE=1 make check", "llvm", "ENABLE_COVERAGE=1 make unittests", "llvm-testsuite", "ENABLE_COVERAGE=1 make", "clang", "ENABLE_COVERAGE=1 make test"], - #"llvm" => ["llvm-testsuite", "ENABLE_COVERAGE=1 make"], - #"llvm" => ["clang", "ENABLE_COVERAGE=TRUE make test"], - "clang" => ["clang", "ENABLE_COVERAGE=1 make test"], -); - -my %compilation_opts = ( - "gcc" => [ "-O0", - "-O1", - "-O2 -march=core2 -mtune=core2 -fno-stack-protector -fomit-frame-pointer", - "-Os", - "-O3 -fwhole-program -combine"], - "clang" => [ "-O0", - "-O1", - "-O2 -march=core2 -mtune=core2 -fomit-frame-pointer -fno-stack-protector", - "-Os", - "-O3"], - "llvm" => [ "-O0", - "-O1", - "-O2 -march=core2 -mtune=core2 -fomit-frame-pointer -fno-stack-protector", - "-Os", - "-O3"], -); - -# the number of testcases generated by csmith -my $NUMBER_OF_TESTCASES = 10000; - -my $CSMITH_OPTS = " --no-paranoid --bitfields ia32 --packed-struct "; - -my $CSMITH_TIMEOUT = 60; - -my $COMPILER_TIMEOUT = 600; - -my $MIN_PROGRAM_SIZE = 10000; - -my $CSMITH_OUT = "$COV_DATA_HOME/csmith_out"; - -my $TEST_FAILS_OUT = "$COV_DATA_HOME/compilers_fail_out.txt"; - -my %prog_checksums = (); - -sub runit ($) { - my $cmd = shift; - my $res = (system "$cmd"); - my $exit_value = $? >> 8; - return $exit_value; -} - -sub gen_lcov_info($$$) { - my ($compiler, $build_path, $lcov_info) = @_; - - system "rm -rf $lcov_info"; - my $cmd; - my $base_cov_dir = $base_cov_dirs{$compiler}; - - if (defined($base_cov_dir)) { - $cmd = "$LCOV -c -d $build_path -b $base_cov_dir -o $lcov_info"; - } - else { - $cmd = "$LCOV -c -d $build_path -o $lcov_info"; - } - die "Can't generate lcov info for $compiler" - if ((system "$cmd") != 0); - - die "Can't generate $lcov_info" - if (!(-f $lcov_info)); -} - -sub gen_base_cov_data($) { - my ($compiler) = @_; - my $build_path = $compiler_build_paths{$compiler}; - my $checks = $base_checks{$compiler}; - - # clear old gcdas - die if ((system "$LCOV -z -d $build_path") != 0); - - print "changing to $build_path\n"; - chdir $build_path or die; - # generate baseline cov data - #foreach my $check (@$checks) { - # system "$check"; - #} - for (my $i = 0; $i < @$checks; $i = $i + 2) { - my $check_path = $compiler_build_paths{@$checks[$i]}; - print "chaning to $check_path\n"; - chdir $check_path or die; - system "@$checks[$i+1]"; - } - - print "changing to $compiler_build_paths{$compiler}\n"; - chdir $compiler_build_paths{$compiler} or die; - - my $cmd = "find $build_path -name '*.gcda'"; - my @gcdas = `$cmd`; - die "no gcdas!" if (@gcdas == 0); -} - -# 0 -> good -sub is_good_prog($) { - my ($cfile) = @_; - - my $filesize = stat("$cfile")->size; - if ($filesize < $MIN_PROGRAM_SIZE) { - return (-1, ""); - } - - open INF, "<$cfile" or die; - my $prog = ""; - my $seed = ""; - while (my $line = ) { - chomp $line; - if ($line =~ /Seed:\s+([0-9]+)$/) { - $seed = $1; - } - $prog .= "$line "; - } - close INF; - - ($prog =~ s/\/\*(.*?)\*\///g); - my $digest = md5($prog); - if ($prog_checksums{$digest}) { - return (-1, ""); - } - - return (0, $seed); -} - -sub test_compilers($) { - my ($cfile) = @_; - - my $res_str = ""; - my $res_code = 0; - - foreach my $compiler (keys %compilers) { - my $compiler_exec = $compilers{$compiler}; - my $opts = $compilation_opts{$compiler}; - foreach my $opt (@$opts) { - my $opt_str = $opt; - ($opt_str =~ s/\ //g); - ($opt_str =~ s/\://g); - ($opt_str =~ s/\-//g); - ($opt_str =~ s/\///g); - if (length($opt_str)>40) { - $opt_str = substr ($opt_str, 0, 40); - } - - my $exe = "${compiler}${opt_str}_exe"; - ($exe =~ s/\.//g); - my $extra_opts = " -w -DINLINE="; - my $out = "rand.out"; - my $compilerout = "${exe}_compiler.out"; - - my $command = "RunSafely.sh $COMPILER_TIMEOUT 1 /dev/null $compilerout $compiler_exec $opt $extra_opts $cfile -o $exe -I${CSMITH_HOME}/runtime"; - - my $res = runit ($command); - if (($res != 0) || (!(-e $exe))) { - $res_code = -1; - if ($res == 137) { - $res_str .= "COMPILER FAILURE: TIMEOUT\n"; - } else { - $res_str .= "COMPILER FAILURE with return code $res; output is:\n"; - open INF, "<$compilerout" or die; - while (my $line = ) { $res_str .= " $line"; } - close INF; - } - } - } - } - - return ($res_code, $res_str); -} - -sub do_one_test() { - my $cfile = "rand.c"; - print "chaning to $CSMITH_OUT\n"; - chdir $CSMITH_OUT or die; - - system "rm -rf ./*"; - my $cmd = "$CSMITH_HOME/src/csmith $CSMITH_OPTS --output $cfile"; - #print "$cmd\n"; - my $res = runit ("RunSafely.sh $CSMITH_TIMEOUT 1 /dev/zero csmith_output.txt $cmd"); - - my $seed; - ($res, $seed) = is_good_prog($cfile); - if ($res != 0) { - return -1; - } - - if ($res != 0 || !(-e "$cfile")) { - open OUTF, ">>$TEST_FAILS_OUT" or die; - print OUTF "csmith FAILS with seed: $seed\n"; - close OUTF; - return -1; - } - - my $res_str; - ($res, $res_str) = test_compilers($cfile); - if ($res != 0) { - open OUTF, ">>$TEST_FAILS_OUT" or die; - print OUTF "TESTING COMPILER FAILS with seed: $seed\n"; - print OUTF "$res_str\n"; - close OUTF; - } - return 0; -} - -sub run_csmith() { - if (-d $CSMITH_OUT) { - system "rm -rf $CSMITH_OUT/*"; - } - else { - mkdir $CSMITH_OUT; - } - - my $count = 0; - system "rm -rf $TEST_FAILS_OUT"; - - while ($count < $NUMBER_OF_TESTCASES) { - my $res; - $res = do_one_test(); - if ($res == 0) { - $count++; - print "Successfully ran csmith[$count]\n"; - } - } -} - -sub gen_lcov_html($$$) { - my ($summary, $html_outdir, $lcov_info) = @_; - - if (!(-d $html_outdir)) { - mkdir $html_outdir; - } - else { - system "rm -rf $html_outdir/*"; - } - - my $cmd = "$LCOV_GEN_HTML $lcov_info -o $html_outdir --summary-output=$summary"; - - die "Can't generate html info for $lcov_info" - if ((system "$cmd") != 0); -} - -sub gen_extended_cov() { - foreach my $compiler (keys %compilers) { - my $build_path = $compiler_build_paths{$compiler}; - my $extended_lcov_info = "$COV_DATA_HOME/$compiler" . "_extended.info"; - my $html_outdir = "$COV_DATA_HOME/${compiler}_html_ext"; - my $summary = "$COV_DATA_HOME/${compiler}_summary_ext.txt"; - - gen_lcov_info($compiler, $build_path, $extended_lcov_info); - gen_lcov_html($summary, $html_outdir, $extended_lcov_info); - } -} - -sub gen_base_cov() { - foreach my $compiler (keys %compilers) { - my $build_path = $compiler_build_paths{$compiler}; - my $base_lcov_info = "$COV_DATA_HOME/$compiler.info"; - my $html_outdir = "$COV_DATA_HOME/${compiler}_html"; - my $summary = "$COV_DATA_HOME/${compiler}_summary.txt"; - - gen_base_cov_data($compiler); - gen_lcov_info($compiler, $build_path, $base_lcov_info); - gen_lcov_html($summary, $html_outdir, $base_lcov_info); - } -} - -if (!(-d $COV_DATA_HOME)) { - mkdir "$COV_DATA_HOME"; -} - -gen_base_cov(); -run_csmith(); -gen_extended_cov(); - diff --git a/utah/scripts/coverage/parse_cov_results.pl b/utah/scripts/coverage/parse_cov_results.pl deleted file mode 100755 index b0b027b8c..000000000 --- a/utah/scripts/coverage/parse_cov_results.pl +++ /dev/null @@ -1,247 +0,0 @@ -#!/usr/bin/perl - -use File::Basename; - -use strict; - - -my $COV_BASE_HOME = $ENV{"COV_BASE_HOME"}; - -#die "please set env $COV_BASE_HOME first!" -# if (!defined($COV_BASE_HOME)); - -# for my convenience -if (!defined($COV_BASE_HOME)) { - $COV_BASE_HOME = "/uusoc/exports/scratch/chenyang/branch-test/test_data"; -} - -my $COV_DATA_HOME = "$COV_BASE_HOME"; -my $LN_OUT = "$COV_BASE_HOME/ln.out"; -my $FN_OUT = "$COV_BASE_HOME/fn.out"; -my $BR_OUT = "$COV_BASE_HOME/br.out"; - -my %base_overall_info = (); -my %ext_overall_info = (); -my %ln_sum = (); -my %fn_sum = (); -my %br_sum = (); - -sub help() { - print "parse_cov_results base_summary extended_summary filter_files.txt\n"; -} - -sub good_file($$) { - my ($file, $dirs) = @_; - - my $s = dirname($file); - $s =~ s/^\s+|\s+$//g; - - my $rv = $dirs->{$s}; - if (defined($rv)) { - return $rv; - } - else { - return 0; - } -} - -# file format: -# filename ln_found ln_hit fn_found fn_hits br_found br_hits -sub read_file($$$$$$) { - my ($file, $ln_ref, $fn_ref, $br_ref, $overall_ref, $dirs) = @_; - open INF, "<$file" or die; - - my $total_fns = 0; - my $total_hit_fns = 0; - my $total_lns = 0; - my $total_hit_lns = 0; - my $total_brs = 0; - my $total_hit_brs = 0; - - while(my $line = ) { - chomp $line; - if ($line =~ m/^#Overall/) { - } - elsif ($line =~ m/^#(.*)functions(.*)\(([0-9]*) of ([0-9]*) functions\)/) { - #$overall_ref->{"functions"} = "$3 $4"; - } - elsif ($line =~ m/^#(.*)lines(.*)\(([0-9]*) of ([0-9]*) lines\)/) { - #$overall_ref->{"lines"} = "$3 $4"; - } - elsif ($line =~ m/^#(.*)branches(.*)\(([0-9]*) of ([0-9]*) branches\)/) { - #$overall_ref->{"branches"} = "$3 $4"; - } - else { - my @a = split(' ', $line); - if (@a != 7) { - close INF; - die "invalid line[$line] in $file"; - } - if (!good_file($a[0], $dirs)) { - next; - } - - $ln_ref->{$a[0]} = [$a[1], $a[2]]; - $total_lns += $a[1]; - $total_hit_lns += $a[2]; - $fn_ref->{$a[0]} = [$a[3], $a[4]]; - $total_fns += $a[3]; - $total_hit_fns += $a[4]; - $br_ref->{$a[0]} = [$a[5], $a[6]]; - $total_brs += $a[5]; - $total_hit_brs += $a[6]; - } - } - $overall_ref->{"functions"} = "$total_hit_fns $total_fns"; - $overall_ref->{"lines"} = "$total_hit_lns $total_lns"; - $overall_ref->{"branches"} = "$total_hit_brs $total_brs"; - - close INF; -} - -sub sort_ln_byinc { - return $ln_sum{$b} <=> $ln_sum{$a}; -} - -sub sort_fn_byinc { - return $fn_sum{$b} <=> $fn_sum{$a}; -} - -sub sort_br_byinc { - return $br_sum{$b} <=> $br_sum{$a}; -} - -sub get_inc($$$) { - my ($base, $base_found, $ext_found) = @_; - - if ($base == 0) { - return (0, 0.0); - } - else { - my $diff = $ext_found - $base_found; - return ($diff, 100 * ($diff / $base)); - } -} - -sub gen_summary($$$) { - my ($sum, $base_info, $ext_info) = @_; - - foreach my $file (keys %$ext_info) { - (my $ext_found, my $ext_hits) = @{$ext_info->{$file}}; - my $base_found = "X111"; - my $base_hits = "X222"; - my $a = $base_info->{$file}; - my $inc; - my $inc_per; - - if (!defined($a)) { - $inc = $ext_hits; - $inc_per = 100.0; - } - else { - ($base_found, $base_hits) = @$a; - # warn "[$file]: unmatched found!" if ($base_found != $ext_found); - warn "[$file]: $ext_found < $base_found!" if ($ext_found < $base_found); - ($inc, $inc_per) = get_inc($base_found, $base_hits, $ext_hits); - } - $sum->{sprintf "$file\t$base_found\t$base_hits\t$ext_hits\t$inc\t%%%.4f\n", $inc_per} = $inc_per; - } -} - -sub dump_overall(*$) { - local *OUT = $_[0]; - my $flag = $_[1]; - - my ($base_overall_hits, $base_overall_found) = split(' ', $base_overall_info{$flag}); - my ($ext_overall_hits, $ext_overall_found) = split(' ', $ext_overall_info{$flag}); - - print OUT " $flag: \n"; - print OUT " old: ($base_overall_hits of $base_overall_found)\n"; - print OUT " new: ($ext_overall_hits of $ext_overall_found)\n"; - my ($inc, $inc_per) = get_inc($base_overall_found, $base_overall_hits, $ext_overall_hits); - my $s = sprintf "increment: %s, %%%.4f", $inc, $inc_per; - print OUT " $s\n\n"; -} - -sub dump_sum($$) { - my ($out, $flag) = @_; - local *OUT; - - open OUT, ">$out" or die; - print OUT "Overall Coverage Rate:\n"; - dump_overall(*OUT, $flag); - - print OUT "\nBreak Down:\n"; - print OUT "file_name\t${flag}_found\told_${flag}_hits\tnew_${flag}_hits\tincrement\tincremental_percentage\n"; - - if ($flag eq "lines") { - foreach (sort sort_ln_byinc keys %ln_sum) { - print OUT $_; - } - } - elsif ($flag eq "functions") { - foreach (sort sort_fn_byinc keys %fn_sum) { - print OUT $_; - } - } - elsif ($flag eq "branches") { - foreach (sort sort_br_byinc keys %br_sum) { - print OUT $_; - } - } - else { - die "Invalid flag[$flag]"; - } - close OUT; -} - -sub get_dirs($$) { - my ($fname, $dirs) = @_; - - open INF, "<$fname" or die; - - while(my $line = ) { - chomp $line; - $line =~ s/^\s+|\s+$//g; - next if (!length($line)); - $dirs->{$line} = 1; - } - - close INF; -} - -sub analyze($$$) { - my ($base_file, $extended_file, $dirs_file) = @_; - - my %base_ln_info = (); - my %ext_ln_info = (); - my %base_fn_info = (); - my %ext_fn_info = (); - my %base_br_info = (); - my %ext_br_info = (); - my %dirs = (); - - get_dirs($dirs_file, \%dirs); - - read_file($base_file, \%base_ln_info, \%base_fn_info, \%base_br_info, \%base_overall_info, \%dirs); - read_file($extended_file, \%ext_ln_info, \%ext_fn_info, \%ext_br_info, \%ext_overall_info, \%dirs); - - gen_summary(\%ln_sum, \%base_ln_info, \%ext_ln_info); - gen_summary(\%fn_sum, \%base_fn_info, \%ext_fn_info); - gen_summary(\%br_sum, \%base_br_info, \%ext_br_info); -} - -########################################################### - -die "$COV_DATA_HOME doesn't exist!" if (!(-d $COV_DATA_HOME)); - -if (@ARGV != 3) { - help(); - die; -} - -analyze($ARGV[0], $ARGV[1], $ARGV[2]); -dump_sum($LN_OUT, "lines"); -dump_sum($FN_OUT, "functions"); -dump_sum($BR_OUT, "branches"); - diff --git a/utah/scripts/jxyang/RunSafely.sh b/utah/scripts/jxyang/RunSafely.sh deleted file mode 100644 index 59570bcda..000000000 --- a/utah/scripts/jxyang/RunSafely.sh +++ /dev/null @@ -1,168 +0,0 @@ -#!/bin/sh -# -# Program: RunSafely.sh -# -# Synopsis: This script simply runs another program. If the program works -# correctly, this script has no effect, otherwise it will do things -# like print a stack trace of a core dump. It always returns -# "successful" so that tests will continue to be run. -# -# This script funnels stdout and stderr from the program into the -# fourth argument specified, and outputs a .time file which -# contains a timing of the program and the program's exit code. -# -# If the parameter is 0 then this script always returns 0, -# regardless of the actual exit of the . -# If the parameter is non-zero then this script returns -# the exit code of the . If there is an error in getting -# the 's exit code, this script returns 99. -# -# If optional parameters -r -l are -# specified, it execute the program remotely using rsh. -# -# Syntax: -# -# RunSafely.sh [-r ] [-l ] -# -# -# where: -# is the remote host to execute the program -# is the username on the remote host -# is the maximum number of seconds to let the run -# is 1 if the program must exit with 0 return code -# is a file from which standard input is directed -# is a file to which standard output and error are directed -# is the path to the program to run -# are the arguments to pass to the program. -# -if [ $# -lt 4 ]; then - echo "./RunSafely.sh " - exit 1 -fi - -DIR=${0%%`basename $0`} - -RHOST= -RUSER=`id -un` -FLAG=$1 -if [ $1 = "-r" ]; then - RHOST=$2 - shift 2 -fi -if [ $1 = "-l" ]; then - RUSER=$2 - shift 2 -fi - -ULIMIT=$1 -EXITOK=$2 -INFILE=$3 -OUTFILE=$4 -PROGRAM=$5 -shift 5 -SYSTEM=`uname -s` - -ULIMITCMD="" -case $SYSTEM in - CYGWIN*) - ;; - Darwin*) - # Disable core file emission, the script doesn't find it anyway because it is put - # into /cores. - ULIMITCMD="$ULIMITCMD ulimit -c 0;" - ULIMITCMD="$ULIMITCMD ulimit -t $ULIMIT;" - # To prevent infinite loops which fill up the disk, specify a limit on size of - # files being output by the tests. 10 MB should be enough for anybody. ;) - ULIMITCMD="$ULIMITCMD ulimit -f 10485760;" - ;; - *) - ULIMITCMD="$ULIMITCMD ulimit -t $ULIMIT;" - ULIMITCMD="$ULIMITCMD ulimit -c unlimited;" - # To prevent infinite loops which fill up the disk, specify a limit on size of - # files being output by the tests. 10 MB should be enough for anybody. ;) - ULIMITCMD="$ULIMITCMD ulimit -f 10485760;" - - ULIMITCMD="$ULIMITCMD ulimit -m 2000000 -v 2000000;" - #ULIMITCMD="$ULIMITCMD ulimit -m 2000000 -v 2000000;" -esac -rm -f core core.* - -# -# Run the command, timing its execution. -# The standard output and standard error of $PROGRAM should go in $OUTFILE, -# and the standard error of time should go in $OUTFILE.time. Note that the -# return code of the program is appended to the $OUTFILE on an "Exit Val =" -# line. -# -# To get the time program and the specified program different output filenames, -# we tell time to launch a shell which in turn executes $PROGRAM with the -# necessary I/O redirection. -# -PWD=`pwd` -COMMAND="$PROGRAM $*" -if [ "$SYSTEM" = "Darwin" ]; then - COMMAND="${DIR}TimedExec.sh $ULIMIT $PWD $COMMAND" -fi - -if [ "x$RHOST" = x ] ; then - ( sh -c "$ULIMITCMD time -p $COMMAND >$OUTFILE 2>&1 < $INFILE; echo exit \$?" ) 2>&1 \ - | awk -- '\ -BEGIN { cpu = 0.0; } -/^user/ { cpu += $2; print; } -/^sys/ { cpu += $2; print; } -!/^user/ && !/^sys/ { print; } -END { printf("cpu time= %f\n", cpu); }' > ${OUTFILE}.time -else - rm -f "$PWD/${PROGRAM}.command" - rm -f "$PWD/${PROGRAM}.remote" - rm -f "$PWD/${PROGRAM}.remote.time" - echo "$ULIMITCMD cd $PWD; (time -p ($COMMAND > $OUTFILE.remote 2>&1 < $INFILE;); echo exit $?) > $OUTFILE.remote.time 2>&1" > "$PWD/${PROGRAM}.command" - chmod +x "$PWD/${PROGRAM}.command" - - ( rsh -l $RUSER $RHOST "ls $PWD/${PROGRAM}.command" ) > /dev/null 2>&1 - ( rsh -l $RUSER $RHOST "$PWD/${PROGRAM}.command" ) - cat $OUTFILE.remote.time | awk -- '\ -BEGIN { cpu = 0.0; } -/^user/ { cpu += $2; print; } -/^sys/ { cpu += $2; print; } -!/^user/ && !/^sys/ { print; } -END { printf("program %f\n", cpu); }' > ${OUTFILE}.time -sleep 1 -cp -f $OUTFILE.remote $OUTFILE -rm -f $OUTFILE.remote -rm -f $OUTFILE.remote.time -fi - -exitval=`grep '^exit ' $OUTFILE.time | sed -e 's/^exit //'` -if [ -z "$exitval" ] ; then - exitval=99 - echo "TEST $PROGRAM failed: CAN'T GET EXIT CODE!" -fi -echo "exit $exitval" >> $OUTFILE - -if [ "$EXITOK" -ne 0 ] ; then - if test "$exitval" -ne 0 ; then - echo "test $PROGRAM failed: EXIT != 0" - fi -else - exitval=0 -fi - -if ls | egrep "^core" > /dev/null -then - # If we are on a sun4u machine (UltraSparc), then the code we're generating - # is 64 bit code. In that case, use gdb-64 instead of gdb. - myarch=`uname -m` - if [ "$myarch" = "sun4u" ] - then - GDB="gdb-64" - else - GDB=gdb - fi - - corefile=`ls core* | head -n 1` - echo "where 100" > StackTrace.$$ - $GDB -q -batch --command=StackTrace.$$ --core=$corefile $PROGRAM < /dev/null - rm -f StackTrace.$$ $corefile -fi -exit "$exitval" diff --git a/utah/scripts/jxyang/compilers.txt b/utah/scripts/jxyang/compilers.txt deleted file mode 100644 index 2bc1e7dc1..000000000 --- a/utah/scripts/jxyang/compilers.txt +++ /dev/null @@ -1,14 +0,0 @@ -$COMPILER_HOME/gcc-320/bin/gcc-320 -$COMPILER_HOME/gcc-330/bin/gcc-330 -$COMPILER_HOME/gcc-340/bin/gcc-340 -$COMPILER_HOME/gcc-400/bin/gcc-400 -$COMPILER_HOME/gcc-410/bin/gcc-410 -$COMPILER_HOME/gcc-420/bin/gcc-420 -$COMPILER_HOME/gcc-430/bin/gcc-430 -$COMPILER_HOME/gcc-440/bin/gcc-440 -$COMPILER_HOME/gcc-450/bin/gcc-450 -#$COMPILER_HOME/llvm-gcc-25/bin/llvm-gcc-25 -$COMPILER_HOME/clang-26/bin/clang -$COMPILER_HOME/clang-27/bin/clang -$COMPILER_HOME/clang-28/bin/clang -$COMPILER_HOME/clang-29/bin/clang diff --git a/utah/scripts/jxyang/parallel_test.pl b/utah/scripts/jxyang/parallel_test.pl deleted file mode 100644 index 7f5255021..000000000 --- a/utah/scripts/jxyang/parallel_test.pl +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/perl -w -use strict; -use warnings; - -sub usage () { - die "usage: parallel_test.pl \n"; -} - -if (scalar (@ARGV) != 3 || $ARGV[0] < 2 || !(-e $ARGV[1])) { - usage(); -} - -my $CPUS = $ARGV[0]; -print "running on $CPUS cpus\n"; - -my $CONFIG_FILE = $ARGV[1]; -my $CSMITH_OPTION = $ARGV[2]; -my @ALT_OPTIONS = (); - -if ($CSMITH_OPTION =~ /--no-(.*)/) { - push @ALT_OPTIONS, $CSMITH_OPTION; - push @ALT_OPTIONS, "--$1"; -} -# todo: for options like "max-block-depth 8", try to make -# a list of alternative options including "max-block-depth 2", -# "max-block-depth 4" etc if there is enough CPUs - -my $cpu_per_option = $CPUS / @ALT_OPTIONS; -print "using $cpu_per_option CPU each for options: "; -print @ALT_OPTIONS; -print "\n"; - -for (my $i=0; $i<@ALT_OPTIONS; $i++) { - $ALT_OPTIONS[$i] =~ /--(.*)/; - my $opt = $1; - $opt =~ s/ //g; - for (my $j=0; $j<$cpu_per_option; $j++) { - my $cpuid = $i * $cpu_per_option + $j; - my $dir = "work$cpuid"; - system "rm -rf $dir"; - system "mkdir $dir"; - chdir $dir; - my $cmd = "nohup ../test.pl 0 ../$CONFIG_FILE $ALT_OPTIONS[$i] > ${opt}_output.txt 2>&1 &"; - print "running $cmd on CPU $cpuid\n"; - system $cmd; - chdir ".."; - } -} \ No newline at end of file diff --git a/utah/scripts/jxyang/setup.sh b/utah/scripts/jxyang/setup.sh deleted file mode 100644 index 7bc61d50e..000000000 --- a/utah/scripts/jxyang/setup.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -sudo -s -cd /z -tar xvfz /proj/randtest/compilers-64bit-ubuntu.tar.gz -rm -rf llvm-gcc-25 -cp -r /proj/randtest/csmith . -export CSMITH_HOME=/z/csmith -export COMPILER_HOME=/z -export PATH=$PATH:/z/csmith/scripts -cd /z/csmith/src; g++ *.cpp -DPACKAGE_STRING -o csmith -cd /z/csmith/scripts/ -chmod 755 * -# change the following line to the Csmith option you want to disable/enable -# also change the number of cores if necessary -# ./parallel_test.pl 8 compilers.txt --no-math64 \ No newline at end of file diff --git a/utah/scripts/jxyang/test.pl b/utah/scripts/jxyang/test.pl deleted file mode 100644 index 4998cccf1..000000000 --- a/utah/scripts/jxyang/test.pl +++ /dev/null @@ -1,356 +0,0 @@ -#!/usr/bin/perl -w -## -## Copyright (c) 2011 The University of Utah -## All rights reserved. -## -## This file is part of `csmith', a random generator of C programs. -## -## Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are met: -## -## * Redistributions of source code must retain the above copyright notice, -## this list of conditions and the following disclaimer. -## -## * Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in the -## documentation and/or other materials provided with the distribution. -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -## ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -## LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -## POSSIBILITY OF SUCH DAMAGE. - -################################################################# - -use strict; -use File::stat; - -################################################################# -#################### user-configurable stuff #################### - -# programs shorter than this many bytes are too boring to test -my $MIN_PROGRAM_SIZE = 8000; - -# kill Csmith after this many seconds -my $CSMITH_TIMEOUT = 90; - -# kill a compiler after this many seconds -my $COMPILER_TIMEOUT = 120; - -# kill a compiler's output after this many seconds -my $PROG_TIMEOUT = 8; - -# extra options here -my $CSMITH_USER_OPTIONS = ""; -my $CSMITH_EXTRA_OPTIONS = ""; - -################# end user-configurable stuff ################### - -my $RUN_PROGRAM = 0; - -my $CSMITH_HOME = $ENV{"CSMITH_HOME"}; -my $good = 0; -my $crash_bug = 0; -my $wrongcode_bug = 0; -my $csmith_bug = 0; - -my $HEADER = "-I$CSMITH_HOME/runtime"; -my $CYGWIN_HEADER = "-I`cygpath -d ${CSMITH_HOME}/runtime`"; -my $COMPILE_OPTIONS = ""; -my @COMPILERS; - -sub read_value_from_file($$) { - my ($fn, $match) = @_; - open INF, "<$fn" or die; - while (my $line = ) { - $line =~ s/\r?\n?$//; # get rid of LF/CR - if ($line =~ /$match/) { - close INF; - return $1; - } - } - close INF; - return ""; -} - -sub write_bug_desc_to_file($$) { - my ($fn, $desc) = @_; - open OUT, ">>$fn" or die "cannot write to $fn\n"; - print OUT "/* $desc */\n"; - close OUT; -} - -# properly parse the return value from system() -sub runit ($$$) { - my ($cmd, $timeout, $out) = @_; - my $res = system "RunSafely.sh $timeout 1 /dev/null $out $cmd"; - my $success = 0; - if ($? == -1) { - print "can't execute $cmd\n"; - } - elsif ($? & 127) { - print "died while executing $cmd\n"; - } - elsif ($res == -1) { - print "can't execute $cmd\n"; - } - else { - $success = 1; - } - my $exit_value = $? >> 8; - if ($exit_value == 137) { - print "hangs while executing $cmd\n"; - $success = 0; - } - return ($success, $exit_value); -} - -# compile a program and execute -# return code 0: normal; -# 1: compiler crashes; -# 2: compiler hangs; -# 3: executable crashes; -# 4: executable hangs -sub compile_and_run($$$$) { - my ($compiler, $src_file, $exe, $out) = @_; - my $command = "$compiler $src_file $COMPILE_OPTIONS $HEADER -o $exe"; - - my @a = split(" ", $compiler); - # special treatment of MS compiler: convert header path to unix-style - if ($a[0] =~ /cl$/) { - $command = "$compiler $src_file $COMPILE_OPTIONS $CYGWIN_HEADER -o $exe"; - } - - # compile random program - my ($res, $exit_value) = runit($command, $COMPILER_TIMEOUT, "compiler.out"); - # print "after run compiler: $res, $exit_value\n"; - if (($res == 0) || (!(-e $exe))) { - # exit code 137 means time out - if ($exit_value != 137) { - # dump the crash message - if ($command =~ /clang/) { - system "grep Assertion compiler.out"; - } else { - system "grep internal compiler.out"; - } - } - return ($exit_value == 137 ? 2 : 1); - } - - # run random program - if ($RUN_PROGRAM) { - ($res, $exit_value) = runit("./$exe", $PROG_TIMEOUT, $out); - # print "after run program: $res, $exit_value\n"; - if (($res == 0) || (!(-e $out))) { - # exit code 137 means time out - return ($exit_value == 137 ? 4 : 3); - } - } - return 0; -} - -# evaluate a random program -# return code: -2: crashes (a likely wrong-code bug) -# -1: hangs (not interesting) -# 0: normal, but found no compiler error (not interesting) -# 1: found compiler crash error(s) -# 2: found compiler wrong code error(s) -sub evaluate_program ($) { - my ($test_file) = @_; - my @checksums; - my @tested_compilers; - my $interesting = 0; - my $i = 0; - my @OPT_LEVELS = ("-O0", "-O1", "-O2", "-O3", "-Os"); - foreach my $compiler (@COMPILERS) { - foreach my $opt_level (@OPT_LEVELS) { - my $out = "out$i.log"; - my $exe = "a.out$i"; - $i++; - my $compiler_opt = "$compiler $opt_level -w "; - my $res = compile_and_run($compiler_opt, $test_file, $exe, $out); - - if ($res) { - if ($res == 1 || $res == 2) { - print "Compiler error! Can't compile with $compiler_opt $COMPILE_OPTIONS $HEADER"; - $interesting = 1; - } - elsif ($res == 3) { - write_bug_desc_to_file($test_file, "random program crashed!"); - # random program crashes, a likely wrong-code bug, but - # can't rule out the probablity of a Csmith bug - $interesting = -2; - last; - } else { - print "random program hangs!\n"; - # program hangs, not interesting - $interesting = -1; - last; - } - } - else { - if ($RUN_PROGRAM) { - die "cannot find $out.\n" if (!(-e $out)); - my $sum = read_value_from_file($out, "checksum = (.*)"); - $interesting = 2 if - (scalar(@checksums) > 0 && $sum ne $checksums[0]); - push @checksums, $sum; - push @tested_compilers, "$compiler $COMPILE_OPTIONS"; - } - } - } - } - if ($interesting >= 1) { - if ($interesting == 2) { - write_bug_desc_to_file ($test_file, - "Found checksum difference between compiler implementations"); - for (my $i=0; $i < scalar (@checksums); $i++) { - write_bug_desc_to_file ($test_file, - "$tested_compilers[$i]: $checksums[$i]"); - } - } - write_bug_desc_to_file($test_file, - "please refer to http://embed.cs.utah.edu/csmith/using.html on how to report a bug"); - } - system "rm -f out*.log a.out* test*.obj compiler.out csmith.out"; - return $interesting; -} - -sub test_one ($) { - (my $n) = @_; - my $cfile = "test$n.c"; - my $seed; - my $filesize; - - # run Csmith until generate a big enough program - while (1) { - unlink $cfile; - my $cmd = "$CSMITH_HOME/src/csmith $CSMITH_USER_OPTIONS $CSMITH_EXTRA_OPTIONS --output $cfile"; - my ($res, $exitcode) = runit($cmd, $CSMITH_TIMEOUT, "csmith.out"); - # print "after run csmith: $res, $exitcode\n"; - - $seed = read_value_from_file($cfile, "Seed:\\s+([0-9]+)"); - die "Random program $cfile has no seed information!\n" if (!$seed); - - if ($res == 0) { - print "CSMITH BUG FOUND: number $csmith_bug\n"; - $csmith_bug++; - system "cp $cfile csmith_bug_${csmith_bug}.c"; - next; - } - else { - $filesize = stat("$cfile")->size; - # print "$cfile is $filesize bytes\n"; - last if ($filesize >= $MIN_PROGRAM_SIZE); - } - } - - print "seed= $seed, size= $filesize\n"; - - # test if the random program is interesting - my $ret = evaluate_program($cfile); - if ($ret >= 0) { - $good++; - print "GOOD PROGRAM: number $good\n"; - if ($ret == 1) { - print "crash error number $crash_bug\n"; - $crash_bug++; - # system "cp $cfile crash${crash_bug}.c"; - } - if ($ret == 2 || $ret == -2) { - print "LIKELY WRONG CODE ERROR FOUND: number $wrongcode_bug\n"; - $wrongcode_bug++; - # system "cp $cfile wrong${wrongcode_bug}.c"; - } - } else { - print "BAD PROGRAM: doesn't count towards goal.\n"; - } - unlink $cfile; - return $ret; -} - -sub usage () { - print "usage: test.pl (0 for unlimited) \n"; - exit -1; -} - -########################### main ################################## - -if (!(-f "$CSMITH_HOME/runtime/csmith.h")) { - print "Please point the environment variable CSMITH_HOME to the top-level\n"; - print "directory of your Csmith tree before running this script.\n"; - exit(-1); -} - -my $nargs = scalar(@ARGV); - -if ($nargs == 2) { - # no problem -} elsif ($nargs == 3) { - if ($ARGV[2] eq "--with-wrong-code-bugs") { - # without timeout, we cannot test wrong code bugs - my $r = system("timeout 1 date > /dev/null 2>&1"); - if ($?) { - print "Cannot find timeout on your system. Switch to finding crash bugs only.\n"; - } else { - print "Finding both crash bugs and wrong-code bugs\n"; - $RUN_PROGRAM = 1; - } - } else { - $CSMITH_EXTRA_OPTIONS = $ARGV[2]; - } -} else { - usage(); -} - -my $cnt = $ARGV[0]; -usage() unless ($cnt =~ /^[0-9]+$/ && $cnt >= 0); - -my ($second0, $minute0, $hour0, $dayOfMonth0, $month0) = localtime(); -$month0++; -print "start time: $month0/$dayOfMonth0 $hour0:$minute0\n"; - -# figure out what compilers to test -my $infile = $ARGV[1]; -open INF, "<$infile" or die "Cannot read configuration file ${infile}.\n"; -while (my $line = ) { - $line =~ s/\r?\n?$//; # get rid of LF/CR - if ($line && !($line =~ /^\s*#/)) { - my $res = system ("echo \"int main() { return 0;}\" > foo.c ; $line foo.c > /dev/null 2>&1"); - unlink "foo.c", "a.out"; - die "cannot execute compiler $line\n" if ($res); - push @COMPILERS, $line; - } -} -close INF; - -# MAIN LOOP -my $i = 0; -while ($cnt == 0 || $i < $cnt) { - if (test_one ($i) != -1) { - $i++; - } - print "\n"; - # print out time once per day - my ($second, $minute, $hour, $dayOfMonth, $month) = localtime(); - if ($hour == $hour0 && $minute == $minute0 && $second == $second0 && $dayOfMonth != $dayOfMonth0) { - $month++; - $dayOfMonth0 = $dayOfMonth; - print "current time: $month/$dayOfMonth $hour:$minute\n"; - } -} - -print "Total csmith errors found: $csmith_bug\n"; -print "Total crash errors found: $crash_bug\n"; -if ($RUN_PROGRAM) { - print "Total wrong-code errors found: $wrongcode_bug\n"; -} - -################################################################## diff --git a/utah/scripts/old_john_driver/RunSafely.sh b/utah/scripts/old_john_driver/RunSafely.sh deleted file mode 100755 index 61b56defb..000000000 --- a/utah/scripts/old_john_driver/RunSafely.sh +++ /dev/null @@ -1,168 +0,0 @@ -#!/bin/sh -# -# Program: RunSafely.sh -# -# Synopsis: This script simply runs another program. If the program works -# correctly, this script has no effect, otherwise it will do things -# like print a stack trace of a core dump. It always returns -# "successful" so that tests will continue to be run. -# -# This script funnels stdout and stderr from the program into the -# fourth argument specified, and outputs a .time file which -# contains a timing of the program and the program's exit code. -# -# If the parameter is 0 then this script always returns 0, -# regardless of the actual exit of the . -# If the parameter is non-zero then this script returns -# the exit code of the . If there is an error in getting -# the 's exit code, this script returns 99. -# -# If optional parameters -r -l are -# specified, it execute the program remotely using rsh. -# -# Syntax: -# -# RunSafely.sh [-r ] [-l ] -# -# -# where: -# is the remote host to execute the program -# is the username on the remote host -# is the maximum number of seconds to let the run -# is 1 if the program must exit with 0 return code -# is a file from which standard input is directed -# is a file to which standard output and error are directed -# is the path to the program to run -# are the arguments to pass to the program. -# -if [ $# -lt 4 ]; then - echo "./RunSafely.sh " - exit 1 -fi - -DIR=${0%%`basename $0`} - -RHOST= -RUSER=`id -un` -FLAG=$1 -if [ $1 = "-r" ]; then - RHOST=$2 - shift 2 -fi -if [ $1 = "-l" ]; then - RUSER=$2 - shift 2 -fi - -ULIMIT=$1 -EXITOK=$2 -INFILE=$3 -OUTFILE=$4 -PROGRAM=$5 -shift 5 -SYSTEM=`uname -s` - -ULIMITCMD="" -case $SYSTEM in - CYGWIN*) - ;; - Darwin*) - # Disable core file emission, the script doesn't find it anyway because it is put - # into /cores. - ULIMITCMD="$ULIMITCMD ulimit -c 0;" - ULIMITCMD="$ULIMITCMD ulimit -t $ULIMIT;" - # To prevent infinite loops which fill up the disk, specify a limit on size of - # files being output by the tests. 10 MB should be enough for anybody. ;) - ULIMITCMD="$ULIMITCMD ulimit -f 10485760;" - ;; - *) - ULIMITCMD="$ULIMITCMD ulimit -t $ULIMIT;" - ULIMITCMD="$ULIMITCMD ulimit -c unlimited;" - # To prevent infinite loops which fill up the disk, specify a limit on size of - # files being output by the tests. 10 MB should be enough for anybody. ;) - ULIMITCMD="$ULIMITCMD ulimit -f 10485760;" - - #ULIMITCMD="$ULIMITCMD ulimit -m 2000000 -v 2000000;" - #ULIMITCMD="$ULIMITCMD ulimit -m 2000000 -v 2000000;" -esac -rm -f core core.* - -# -# Run the command, timing its execution. -# The standard output and standard error of $PROGRAM should go in $OUTFILE, -# and the standard error of time should go in $OUTFILE.time. Note that the -# return code of the program is appended to the $OUTFILE on an "Exit Val =" -# line. -# -# To get the time program and the specified program different output filenames, -# we tell time to launch a shell which in turn executes $PROGRAM with the -# necessary I/O redirection. -# -PWD=`pwd` -COMMAND="$PROGRAM $*" -if [ "$SYSTEM" = "Darwin" ]; then - COMMAND="${DIR}TimedExec.sh $ULIMIT $PWD $COMMAND" -fi - -if [ "x$RHOST" = x ] ; then - ( sh -c "$ULIMITCMD $COMMAND >$OUTFILE 2>&1 < $INFILE; echo exit \$?" ) 2>&1 \ - | awk -- '\ -BEGIN { cpu = 0.0; } -/^user/ { cpu += $2; print; } -/^sys/ { cpu += $2; print; } -!/^user/ && !/^sys/ { print; } -END { printf("cpu time= %f\n", cpu); }' > ${OUTFILE}.time -else - rm -f "$PWD/${PROGRAM}.command" - rm -f "$PWD/${PROGRAM}.remote" - rm -f "$PWD/${PROGRAM}.remote.time" - echo "$ULIMITCMD cd $PWD; (time -p ($COMMAND > $OUTFILE.remote 2>&1 < $INFILE;); echo exit $?) > $OUTFILE.remote.time 2>&1" > "$PWD/${PROGRAM}.command" - chmod +x "$PWD/${PROGRAM}.command" - - ( rsh -l $RUSER $RHOST "ls $PWD/${PROGRAM}.command" ) > /dev/null 2>&1 - ( rsh -l $RUSER $RHOST "$PWD/${PROGRAM}.command" ) - cat $OUTFILE.remote.time | awk -- '\ -BEGIN { cpu = 0.0; } -/^user/ { cpu += $2; print; } -/^sys/ { cpu += $2; print; } -!/^user/ && !/^sys/ { print; } -END { printf("program %f\n", cpu); }' > ${OUTFILE}.time -sleep 1 -cp -f $OUTFILE.remote $OUTFILE -rm -f $OUTFILE.remote -rm -f $OUTFILE.remote.time -fi - -exitval=`grep '^exit ' $OUTFILE.time | sed -e 's/^exit //'` -if [ -z "$exitval" ] ; then - exitval=99 - echo "TEST $PROGRAM failed: CAN'T GET EXIT CODE!" -fi -echo "exit $exitval" >> $OUTFILE - -if [ "$EXITOK" -ne 0 ] ; then - if test "$exitval" -ne 0 ; then - echo "test $PROGRAM failed: EXIT != 0" - fi -else - exitval=0 -fi - -if ls | egrep "^core" > /dev/null -then - # If we are on a sun4u machine (UltraSparc), then the code we're generating - # is 64 bit code. In that case, use gdb-64 instead of gdb. - myarch=`uname -m` - if [ "$myarch" = "sun4u" ] - then - GDB="gdb-64" - else - GDB=gdb - fi - - corefile=`ls core* | head -n 1` - echo "where 100" > StackTrace.$$ - $GDB -q -batch --command=StackTrace.$$ --core=$corefile $PROGRAM < /dev/null - rm -f StackTrace.$$ $corefile -fi -exit "$exitval" diff --git a/utah/scripts/old_john_driver/build_compiler.pl b/utah/scripts/old_john_driver/build_compiler.pl deleted file mode 100755 index e40dcd052..000000000 --- a/utah/scripts/old_john_driver/build_compiler.pl +++ /dev/null @@ -1,295 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -use Sys::CPU; - -################################################################# - -# TODO: don't make a copy of the source tree, just set build_dir -# to be somewhere else - -# TODO: add a "force" option that first removes this compiler from -# the unbuildable list, if it's in there - -# specification: -# return success if the requested version is already in the path -# return success if we can build the requested version -# return fail otherwise - -################################################################# - -my $TOPDIR = $ENV{"HOME"}."/z"; - -my $NICE = "nice -10"; - -my $LINK_TO = "$TOPDIR/bin"; -my $BUILD_HOME = "$TOPDIR/compiler-build"; -my $SOURCE_HOME = "$TOPDIR/compiler-source"; -my $INSTALL_HOME = "$TOPDIR/compiler-install"; -my $FAIL_FILE_LLVM = "${SOURCE_HOME}/unbuildable_llvm.txt"; -my $FAIL_FILE_GCC = "${SOURCE_HOME}/unbuildable_gcc.txt"; - -#my $CC = "CC=llvm-gcc CXX=llvm-g++"; -#my $CC = "CC=current-gcc CXX=current-g++"; -#my $CC = "CC=gcc-4.3 CXX=g++-4.3"; -my $CC = ""; - -#my $EXPENSIVE = "--enable-expensive-checks"; -my $EXPENSIVE = ""; - -#my $LLVM_CHECKS = "$EXPENSIVE --enable-debug-runtime --disable-optimized"; -my $LLVM_CHECKS = "--enable-checking=release --enable-optimized"; - -################################################################# - -my $CPUS = Sys::CPU::cpu_count(); -print "looks like we have $CPUS cpus\n"; - -#$CPUS = 1; - -my $C_EXE; -my $CPP_EXE; -my $BARE_C_EXE; -my $BARE_CPP_EXE; -my $PROGRAM_PREFIX; -my $REV; -my $OREV; -my $INSTALL_DIR; -my $COMPILER; -my $FAIL_FILE; -my @dirs_to_delete = (); - -# properly parse the return value from system() -sub runit ($) { - my $cmd = shift; - - if ((system "$NICE $cmd") != 0) { - print "build_compiler FAILING: system '$cmd': $?"; - return -1; - } - - my $exit_value = $? >> 8; - return $exit_value; -} - -sub abort_if_fail ($) { - my $cmd = shift; - my $res = runit ($cmd); - if ($res != 0) { - print "build $COMPILER FAILING and recording this version as unbuildable\n"; - open OUTF, ">>$FAIL_FILE" or die "cannot open fail file $FAIL_FILE for appending"; - print OUTF "${C_EXE}\n"; - close OUTF; - # NOTE-- this leaves trash sitting around - #foreach my $d (@dirs_to_delete) { - # system ("rm -rf $d"); - #} - exit (-1); - } -} - -sub usage() { - die "usage: build_compiler.pl llvm|gcc rev|LATEST"; -} - -sub build_gcc() { - my $GCC_DIR="$BUILD_HOME/gcc-r$REV"; - my $GCC_INSTALL_DIR="$INSTALL_HOME/gcc-r$REV-install"; - - push @dirs_to_delete, $GCC_DIR; - push @dirs_to_delete, $GCC_INSTALL_DIR; - - abort_if_fail ("rm -rf $GCC_DIR"); - chdir $BUILD_HOME or die; - - abort_if_fail ("cp -r $SOURCE_HOME/gcc $GCC_DIR"); - chdir $GCC_DIR or die; - abort_if_fail ("svn update -r $REV"); - - abort_if_fail ("mkdir build"); - chdir "build" or die; - - abort_if_fail ("../configure --with-libelf=/usr/local --enable-lto --prefix=$GCC_INSTALL_DIR --program-prefix=$PROGRAM_PREFIX --enable-languages=c,c++ "); - abort_if_fail ("make -j${CPUS}"); - abort_if_fail ("make install"); - - abort_if_fail ("ln -sf $GCC_INSTALL_DIR/bin/${PROGRAM_PREFIX}gcc $LINK_TO/${C_EXE}"); - abort_if_fail ("ln -sf $GCC_INSTALL_DIR/bin/${PROGRAM_PREFIX}g++ $LINK_TO/${CPP_EXE}"); - - if ($OREV eq "LATEST") { - abort_if_fail ("ln -sf $GCC_INSTALL_DIR/bin/${PROGRAM_PREFIX}gcc $LINK_TO/${BARE_C_EXE}"); - abort_if_fail ("ln -sf $GCC_INSTALL_DIR/bin/${PROGRAM_PREFIX}g++ $LINK_TO/${BARE_CPP_EXE}"); - } - - print "cleaning up..."; - - system ("$NICE rm -rf $GCC_DIR"); -} - -sub build_llvm() { - my $LLVM_DIR="$BUILD_HOME/llvm-r$REV"; - my $LLVMGCC_DIR="$BUILD_HOME/llvm-gcc-r$REV-src"; - my $LLVM_INSTALL_DIR="$INSTALL_HOME/llvm-gcc-r$REV-install"; - - push @dirs_to_delete, $LLVM_DIR; - push @dirs_to_delete, $LLVMGCC_DIR; - push @dirs_to_delete, $LLVM_INSTALL_DIR; - - abort_if_fail ("rm -rf $LLVM_DIR"); - chdir $BUILD_HOME or die "couldn't chdir to $BUILD_HOME"; - - abort_if_fail ("cp -r $SOURCE_HOME/llvm $LLVM_DIR"); - chdir $LLVM_DIR or die; - abort_if_fail ("svn update -r $REV"); - chdir "$LLVM_DIR/tools/clang" or die; - abort_if_fail ("svn update -r $REV"); - - chdir $LLVM_DIR or die; - abort_if_fail ("$CC ./configure $LLVM_CHECKS --prefix=$LLVM_INSTALL_DIR"); - abort_if_fail ("make VERBOSE=0 -j${CPUS}"); - abort_if_fail ("make install"); - - #abort_if_fail ("rm -rf $LLVMGCC_DIR"); - #chdir $BUILD_HOME or die; - - #abort_if_fail ("cp -r $BUILD_HOME/llvm-gcc $LLVMGCC_DIR"); - #chdir $LLVMGCC_DIR or die; - #abort_if_fail ("svn update -r $REV"); - - #chdir $LLVMGCC_DIR or die; - #abort_if_fail ("mkdir build"); - #chdir "build" or die; - #abort_if_fail ("$CC ../configure $LLVM_CHECKS --prefix=$LLVM_INSTALL_DIR --program-prefix=$PROGRAM_PREFIX --enable-languages=c,c++ --enable-llvm=$LLVM_DIR"); - #abort_if_fail ("make VERBOSE=1 -j${CPUS}"); - #abort_if_fail ("make install"); - #abort_if_fail ("ln -sf $LLVM_INSTALL_DIR/bin/${PROGRAM_PREFIX}gcc $LINK_TO/${C_EXE}"); - #abort_if_fail ("ln -sf $LLVM_INSTALL_DIR/bin/${PROGRAM_PREFIX}g++ $LINK_TO/${CPP_EXE}"); - - abort_if_fail ("ln -sf $LLVM_INSTALL_DIR/bin/bugpoint $LINK_TO"); - abort_if_fail ("ln -sf $LLVM_INSTALL_DIR/bin/clang $LINK_TO"); - abort_if_fail ("ln -sf $LLVM_INSTALL_DIR/bin/clang++ $LINK_TO"); - abort_if_fail ("ln -sf $LLVM_INSTALL_DIR/bin/llc $LINK_TO"); - abort_if_fail ("ln -sf $LLVM_INSTALL_DIR/bin/lli $LINK_TO"); - abort_if_fail ("ln -sf $LLVM_INSTALL_DIR/bin/llvm-ar $LINK_TO"); - abort_if_fail ("ln -sf $LLVM_INSTALL_DIR/bin/llvm-as $LINK_TO"); - abort_if_fail ("ln -sf $LLVM_INSTALL_DIR/bin/llvm-bcanalyzer $LINK_TO"); - abort_if_fail ("ln -sf $LLVM_INSTALL_DIR/bin/llvmc $LINK_TO"); - abort_if_fail ("ln -sf $LLVM_INSTALL_DIR/bin/llvm-config $LINK_TO"); - abort_if_fail ("ln -sf $LLVM_INSTALL_DIR/bin/llvm-dis $LINK_TO"); - abort_if_fail ("ln -sf $LLVM_INSTALL_DIR/bin/llvm-extract $LINK_TO"); - abort_if_fail ("ln -sf $LLVM_INSTALL_DIR/bin/llvm-ld $LINK_TO"); - abort_if_fail ("ln -sf $LLVM_INSTALL_DIR/bin/llvm-link $LINK_TO"); - abort_if_fail ("ln -sf $LLVM_INSTALL_DIR/bin/llvm-nm $LINK_TO"); - abort_if_fail ("ln -sf $LLVM_INSTALL_DIR/bin/llvm-prof $LINK_TO"); - abort_if_fail ("ln -sf $LLVM_INSTALL_DIR/bin/llvm-ranlib $LINK_TO"); - abort_if_fail ("ln -sf $LLVM_INSTALL_DIR/bin/llvm-stub $LINK_TO"); - abort_if_fail ("ln -sf $LLVM_INSTALL_DIR/bin/opt $LINK_TO"); - abort_if_fail ("ln -sf $LLVM_INSTALL_DIR/bin/tblgen $LINK_TO"); - - if ($OREV eq "LATEST") { - abort_if_fail ("ln -sf $LLVM_INSTALL_DIR/bin/${PROGRAM_PREFIX}gcc $LINK_TO/${BARE_C_EXE}"); - abort_if_fail ("ln -sf $LLVM_INSTALL_DIR/bin/${PROGRAM_PREFIX}g++ $LINK_TO/${BARE_CPP_EXE}"); - } - - print "cleaning up..."; - - system ("$NICE rm -rf $LLVM_DIR"); - system ("$NICE rm -rf $LLVMGCC_DIR"); -} - -########################### main ################################ - -usage() if (scalar(@ARGV) != 2); - -$COMPILER = $ARGV[0]; -$OREV = $ARGV[1]; - -usage() if (!(($OREV =~ /^\d+$/) || ($OREV eq "LATEST"))); - -if ($OREV eq "LATEST") { - my $r; - chdir $SOURCE_HOME or die; - runit ("rm -rf trunk"); - my $TRUNKDIR; - if ($COMPILER eq "llvm") { - $TRUNKDIR = "trunk-llvm"; - open INF, "svn co -N http://llvm.org/svn/llvm-project/llvm/trunk $TRUNKDIR |" or die; - } else { - $TRUNKDIR = "trunk-gcc"; - open INF, "svn co -N svn://gcc.gnu.org/svn/gcc/trunk $TRUNKDIR |" or die; - } - while () { - if (/Checked out revision ([0-9]+)\./) { - $r = $1; - } - } - close INF; - die if (!defined($r)); - $REV = $r; - runit ("rm -rf $TRUNKDIR"); - print "latest rev of $COMPILER id $REV\n"; -} else { - $REV = $OREV; -} - -if ($COMPILER eq "llvm") { - $FAIL_FILE = $FAIL_FILE_LLVM; - $PROGRAM_PREFIX = "llvm-r${REV}-"; - $BARE_C_EXE = "llvm-gcc"; - $BARE_CPP_EXE = "llvm-g++"; -} elsif ($COMPILER eq "gcc") { - $FAIL_FILE = $FAIL_FILE_GCC; - $PROGRAM_PREFIX = "r${REV}-"; - $BARE_C_EXE = "current-gcc"; - $BARE_CPP_EXE = "current-g++"; -} else { - usage(); -} - -$C_EXE = "${PROGRAM_PREFIX}gcc"; -$CPP_EXE = "${PROGRAM_PREFIX}g++"; - -open INF, "<$FAIL_FILE" or die "oops-- fail file $FAIL_FILE does not exist"; -while (my $line = ) { - chomp $line; - if ($line eq $C_EXE) { - print "build_compiler FAILING: this version previously determined to be unbuildable\n"; - exit (-1); - } -} -close INF; - -my $worked = 0; -if (open(CMD,"| $C_EXE -O -x c - -S -o /dev/null")) { - print CMD<<"END"; -\#include -int main (void) -{ - printf (\"hello\\n\"); - return 0; -} -END - close(CMD); - my $ret = $? >> 8; - if ($ret == 0) { - $worked = 1; - } -} - -if ($worked) { - print "build_compiler SUCCESS -- runnable ${C_EXE} already exists\n"; - exit 0; -} - -if ($COMPILER eq "llvm") { - build_llvm(); -} elsif ($COMPILER eq "gcc") { - build_gcc(); -} else { - die; -} - -print "build $COMPILER SUCCESS -- installed $C_EXE and $CPP_EXE\n"; -exit 0; - -################################################################# diff --git a/utah/scripts/old_john_driver/evaluate_program.pl b/utah/scripts/old_john_driver/evaluate_program.pl deleted file mode 100755 index 259b0b65b..000000000 --- a/utah/scripts/old_john_driver/evaluate_program.pl +++ /dev/null @@ -1,1086 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; -use Benchmark; -use English; -use LockFile::Simple; - -# TODO: check for program crash (vs. timeout) - -# TODO: factor out version search code; automatically check -# if it valgrinds clean; when we do a version search, save -# the temp dir - -# TODO: we hold the lock for too long, put it into compile_llvm? - -# abstract over compilation and evaluation strategies - -# properly propagate run_program failures upwards - -# piece together byte-level information from run_program - -# distinguish between programs that compile and those that run inside the timeout - -#################################################################### - -my $SKIP = 0; - -my $NOTEFILE_PREFIX="logged_"; - -my $xxtra = "-DCSMITH_MINIMAL"; - -#my $notmp = "-DUSE_MATH_MACROS_NOTMP"; -my $notmp = ""; - -#my $CCOMP_BF = "-fbitfields"; -my $CCOMP_BF = "-fbitfields"; - -# I don't know the reason, but on our mini mac, current-gcc complains about "can't find -lgcc" -# So remove the comment below if we do tests on maya -#my $CCOMP_EXTRA_LDIR = "-L/Users/Shared/compilers/lib/gcc/x86_64-apple-darwin10.2.0/4.5.0"; -my $CCOMP_EXTRA_LDIR = ""; - -my $COMPILER_TIMEOUT = 600; - -my $COMPILER_TIMEOUT_RES = 137; - -# see if it helps to wrap volatile accesses in function calls? -my $TRY_WRAP = 0; - -my $NO_VOLCHECK = 0; -my $USE_VOLCHECK = 1; -my $USE_PINTOOL = 2; - -my $CHECK_VOLATILE = $NO_VOLCHECK; - -if (defined($ENV{"PIN_CMD"})) { - $CHECK_VOLATILE = $USE_PINTOOL; -} - -my $VALGRIND_ON_COMPILER = 0; - -my $RUN_PROGRAM = 1; - -my $DO_TRIAGE = 0; - -my $VERSION_SEARCH = 0; - -my $BAIL_ON_ZERO_WRITES = 0; - -#################################################################### - -my $CSMITH_HOME=$ENV{"CSMITH_HOME"}; -die "oops: CSMITH_HOME environment variable needs to be set" - if (!defined($CSMITH_HOME)); - -my $VOLATILE_HOME=$CSMITH_HOME."/utah/scripts/john_driver"; - -my $LOCKFN = "/var/tmp/version_search_lockfile"; - -#################################################################### - -my @gcc_opts2 = ( - "-O0", - #"-O1", - #"-O2", - #"-Os", - "-O3", - ); - -my @gcc_opts9 = ( - "-O0 -fwrapv", - "-O1 -fwrapv", - "-O2 -fwrapv", - "-Os -fwrapv", - "-O3 -fwrapv", - ); - -my $DRAGONEGG = "-fplugin=/home/regehr/z/compiler-source/dragonegg/dragonegg.so"; - -my @dragonegg_opts = ( - "-O0 $DRAGONEGG", - "-O1 $DRAGONEGG", - "-O2 $DRAGONEGG", - "-Os $DRAGONEGG", - "-O3 $DRAGONEGG", - ); - -my @gcc_opts3 = ( - "-O0", - #"-O1 -fomit-frame-pointer -fwhole-program", - #"-O2", - #"-Os", - "-O3 -march=corei7 -mtune=corei7", - ); - -my @gcc_opts4 = ( - "-O0", - "-Os", - "-Os -fno-asynchronous-unwind-tables -fno-common -fno-delete-null-pointer-checks -fno-dwarf2-cfi-asm -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-strict-aliasing -fno-strict-overflow -fstack-protector -fstack-protector-all -ftest-coverage -g -m32 -march=i486 -mno-3dnow -mno-mmx -mno-sse -mno-sse2 -mpreferred-stack-boundary=2 -msoft-float", - ); - -my @gcc_opts5 = ( - "-O0", - "-O1", - "-O2 -march=core2 -mtune=core2 -fno-stack-protector -fomit-frame-pointer", - "-Os", - "-Os -fconserve-stack -fno-asynchronous-unwind-tables -fno-common -fno-delete-null-pointer-checks -fno-dwarf2-cfi-asm -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-strict-aliasing -fno-strict-overflow -fprofile-arcs -fstack-protector -ftest-coverage -funit-at-a-time -g -m64 -maccumulate-outgoing-args -mno-3dnow -mno-mmx -mno-red-zone -mno-sse -mno-sse2 -mtune=generic -pg", - "-O3 -fwhole-program -combine", - ); - -my @clang_opts = ( - "-O0 ", - "-O1 ", - "-O2 -march=core2 -mtune=core2 -fomit-frame-pointer -fno-stack-protector ", - "-Os ", - "-O3 ", - ); - -my @clangwrapv_opts = ( - "-O0 -fwrapv", - "-O1 -fwrapv", - "-O2 -fwrapv -march=core2 -mtune=core2 -fomit-frame-pointer -fno-stack-protector", - "-Os -fwrapv", - "-O3 -fwrapv", - ); - -my @gcc_686_opts = ( - "-O0 -march=i686", - "-O1 -march=i686", - "-O2 -march=i686", - "-Os -march=i686", - "-O3 -march=i686", - ); - -my @llvm_opts_sse3 = ( - "-O0 -msse3", - "-O1 -msse3", - "-O2 -msse3", - "-Os -msse3", - "-O3 -msse3", - ); - -my @armcc_opts = ( - "-O0", - "-O1", - "-O2 -Ospace", - "-O2 -Otime", - "-O3 -Ospace", - "-O3 -Otime", - ); - -my @dcc_opts = ( - "-tARMES:windiss -DSTANDALONE", - "-tARMES:windiss -DSTANDALONE -O", - "-tARMES:windiss -DSTANDALONE -XO", - ); - -my @gcc_opts_noO0 = ("-O1", - "-Os", - "-O2", - "-O3"); - -my @gcc_opts = ("-O0", - "-O1", - "-Os", - "-O2", - "-O3"); - -my @Oonly = ("-O"); - -my @Osonly = ("-Os"); - -my @none = ("-DTCC"); - -my @O0sonly = ("-O0", "-Os"); - -my @O0only = ("-O0"); - -my @suncc_opts = ( - "", - "-xO1", - "-xO2", - "-xO3", - "-xO4", - "-xO5", - "-fast", - ); - -my @icc_opts = ( - "-O0", - "-O1", - "-Os", - "-O2", - "-fast -ipo", - ); - -my @gcc_with_ccomp_opts = ( - "-m32 -O0 -DUSE_MATH_MACROS_NOTMP -D__COMPCERT__ $CCOMP_EXTRA_LDIR", - "-m32 -O2 -DUSE_MATH_MACROS_NOTMP -D__COMPCERT__ $CCOMP_EXTRA_LDIR", - ); - -my @ccomp_opts = ( - "-D__COMPCERT__ -DUSE_MATH_MACROS_NOTMP -fpacked-structs -fbitfields -fstruct-passing -fstruct-assign $CCOMP_BF", -); - -my @avrdeputy = ("avr", - "deputy", - "my-deputy-avr.pl", - \@Osonly); - -my @clang_Oonly = ("ia32", - "clang", - "clang", - \@Oonly); - -my @lance = ("ia32", - "clang", - "run-lance", - \@Osonly); - -my @tendra = ("ia32", - "tendracc", - "tendracc", - \@gcc_opts2); - -my @llvmgcc = ("ia32", - "llvm", - "llvm-gcc", - \@gcc_opts2); - -my @cparser = ("ia32", - "cparser", - "cparser-driver", - \@Osonly); - -my @tcc = ("ia32", - "tcc", - "tcc", - \@none); - -my @dcc = ("windiss", - "dcc", - "dcc", - \@dcc_opts); - -my @armcc = ("arm", - "armcc", - "armcc", - \@armcc_opts); - -my @avrgcc = ("avr", - "gcc", - "avr-gcc", - \@gcc_opts2); - -my @avrgcc34 = ("avr", - "gcc", - "avr-gcc-3.4", - \@gcc_opts2); - -my @mspgcc = ("msp", - "gcc", - "msp430-gcc", - \@gcc_opts2); - -my @avrgcc42_O0sonly = ("avr", - "gcc", - "avr-gcc-4.2", - \@O0sonly); - -my @avrgcc42 = ("avr", - "gcc", - "avr-gcc-4.2", - \@gcc_opts2); - -my @deputy = ("ia32", - "deputy", - "/home/regehr/tmp/deputy/bin/deputy", - \@Osonly); - -my @nesc = ("ia32", - "nesc", - "nescc", - \@Osonly); - -my @gcc = ("ia32", - "gcc", - "gcc", - \@gcc_opts2); - -my $Z = "/home/regehr/z/compilers"; - -my @clang26 = ("ia32", - "llvm", - "$Z/clang-26/bin/clang", - \@gcc_opts2); - -my @llvmgcc27 = ("ia32", - "llvm", - "llvm-gcc-27", - \@gcc_opts2); - -my @clang27 = ("ia32", - "llvm", - "$Z/clang-27/bin/clang", - \@gcc_opts2); - -my @llvmgcc28 = ("ia32", - "llvm", - "llvm-gcc-28", - \@gcc_opts2); - -my @clang28 = ("ia32", - "llvm", - "$Z/clang-28/bin/clang", - \@gcc_opts2); - -my @llvmgcc29 = ("ia32", - "llvm", - "llvm-gcc-29", - \@gcc_opts2); - -my @clang29 = ("ia32", - "llvm", - "$Z/clang-29/bin/clang", - \@gcc_opts2); - -my @gcc460 = ("ia32", - "gcc", - "$Z/gcc-460/bin/gcc-460", - \@gcc_opts2); - -my @open64 = ("ia32", - "opencc", - "opencc", - \@gcc_opts2); - -my @gcc450 = ("ia32", - "gcc", - "$Z/gcc-450/bin/gcc-450", - \@gcc_opts2); - -my @gcc440 = ("ia32", - "gcc", - "$Z/gcc-440/bin/gcc-440", - \@gcc_opts2); - -my @gcc430 = ("ia32", - "gcc", - "$Z/gcc-430/bin/gcc-430", - \@gcc_opts2); - -my @gcc420 = ("ia32", - "gcc", - "$Z/gcc-420/bin/gcc-420", - \@gcc_opts2); - -my @gcc410 = ("ia32", - "gcc", - "$Z/gcc-410/bin/gcc-410", - \@gcc_opts2); - -my @gcc400 = ("ia32", - "gcc", - "$Z/gcc-400/bin/gcc-400", - \@gcc_opts2); - -my @gcc340 = ("ia32", - "gcc", - "$Z/gcc-340/bin/gcc-340", - \@gcc_opts2); - -my @gcc330 = ("ia32", - "gcc", - "$Z/gcc-330/bin/gcc-330", - \@gcc_opts2); - -my @gcc320 = ("ia32", - "gcc", - "$Z/gcc-320/bin/gcc-320", - \@gcc_opts2); - -my @clang = ("ia32", - "clang", - "clang", - \@gcc_opts3); - -my @clangpp = ("ia32", - "clang", - "clang++", - \@gcc_opts2); - -my @gcccurrent = ("ia32", - "gcc", - "current-gcc", - \@gcc_opts3); - -my @gppcurrent = ("ia32", - "gcc", - "current-g++", - \@gcc_opts3); - -my @dragonegg = ("ia32", - "gcc", - "gcc-4.5", - \@dragonegg_opts); - -my @gcccurrent2 = ("ia32", - "gcc", - "current-gcc", - \@gcc_opts4); - -my @gcccurrent_Oonly = ("ia32", - "gcc", - "current-gcc", - \@Oonly); - -my @gcccurrent_O0only = ("ia32", - "gcc", - "current-gcc", - \@O0only); - -my @suncc = ("ia32", - "suncc", - "suncc", - \@suncc_opts); - -my @llvmgcc19 = ("ia32", - "llvm", - "llvm-gcc-19", - \@gcc_opts2); - -my @llvmgcc20 = ("ia32", - "llvm", - "llvm-gcc-20", - \@gcc_opts2); - -my @llvmgcc21 = ("ia32", - "llvm", - "llvm-gcc-21", - \@gcc_opts2); - -my @llvmgcc22 = ("ia32", - "llvm", - "llvm-gcc-22", - \@gcc_opts2); - -my @llvmgcc23 = ("ia32", - "llvm", - "llvm-gcc-23", - \@gcc_opts2); - -my @llvmgcc24 = ("ia32", - "llvm", - "llvm-gcc-24", - \@gcc_opts2); - -my @llvmgcc25 = ("ia32", - "llvm", - "llvm-gcc-25", - \@gcc_opts2); - -my @llvmgcc26 = ("ia32", - "llvm", - "llvm-gcc-26", - \@gcc_opts2); - -my @llvmgcc22O0only = ("ia32", - "llvm", - "llvm-gcc-2.2", - \@O0only); - -my @llvmgcccurrent = ("ia32", - "llvm", - "llvm-gcc-current", - \@gcc_opts2); - -my @llvmgcc_Oonly = ("ia32", - "llvm", - "llvm-gcc", - \@Oonly); - -my @icc = ("ia32", - "icc", - "icc", - \@icc_opts); - -my @icc_O0only = ("ia32", - "icc", - "icc", - \@O0only); - -my @gcc_with_ccomp = ( - "ia32", - "gcc", - "current-gcc", - \@gcc_with_ccomp_opts); - -my @clang_with_ccomp = ( - "ia32", - "gcc", - "clang", - \@gcc_with_ccomp_opts); - -my @ccomp = ( - "ia32", - "ccomp", - "ccomp", - \@ccomp_opts); - -my @llvms = ( - \@llvmgcc20, - \@llvmgcc21, - \@llvmgcc22, - \@llvmgcc23, - \@llvmgcc24, - ); - -my @compilers_to_test = ( - - \@clang, - \@gcccurrent, - - #\@gcc320, - #\@gcc330, - #\@gcc340, - #\@gcc400, - #\@gcc410, - #\@gcc420, - #\@gcc430, - #\@gcc440, - #\@gcc450, - #\@gcc460, - #\@clang26, - #\@clang27, - #\@clang28, - #\@clang29, - - #\@icc, - #\@suncc, - #\@open64, - - # \@tcc, - - #\@gcc_with_ccomp, - #\@ccomp, - ##\@clang_with_ccomp, - - #\@gcc, - - #\@clangpp, - #\@gppcurrent, - - #\@gcc400, - - #\@gcccurrent, - #\@dragonegg, - - #\@dcc, - #\@lance, - #\@gcccurrent, - #\@llvmgcc, - #\@clang, - - #\@gppcurrent, - #\@avrgcc, - #\@gcccurrent_O0only, - #\@armcc, - #\@cparser, - #\@llvmgcc24, - #\@llvmgcc_Oonly, - #\@gcccurrent_Oonly, - - ); - -#################################################################### - -# properly parse the return value from system() -sub runit ($) { - my $cmd = shift; - - my $start = new Benchmark; - my $res = (system "$cmd"); - my $end = new Benchmark; - my $dur = timediff($end, $start); - my $exit_value = $? >> 8; - return ($exit_value, $dur); -} - -# build and run the app, with timeouts for both the compiler and the program -sub compile_and_run ($$$$$$$) { - (my $root, my $arch, my $compiler, - my $opt, my $volref, my $wrap_volatiles, my $custom_options) = @_; - my %vols = %{$volref}; - - print "[$arch] $compiler $opt : "; - - my $opt_str = $opt; - ($opt_str =~ s/\ //g); - ($opt_str =~ s/\://g); - ($opt_str =~ s/\-//g); - ($opt_str =~ s/\///g); - if (length($opt_str)>40) { - $opt_str = substr ($opt_str, 0, 40); - } - - my $exe; - my $xtra; - if ($arch eq "ia32" || $arch eq "windiss") { - $exe = "${root}${compiler}${opt_str}_exe"; - ($exe =~ s/\.//g); - ($exe =~ s/\///g); - $xtra = ""; - } elsif ($arch eq "avr") { - $exe = "${root}${compiler}${opt_str}.elf"; - $xtra = "-mmcu=atmega128 -fwhole-program"; - } elsif ($arch eq "msp" ) { - $exe = "${root}${compiler}${opt_str}.elf"; - $xtra = "-mmcu=msp430x1611"; - } elsif ($arch eq "arm" ) { - $exe = "${root}${compiler}${opt_str}.axf"; - $xtra = "--cpu=ARM926EJ-S -L--datacompressor=off -W"; - } else { - die; - } - - my $srcfile = "$root.c"; - - if ($compiler eq "ccomp") { - $xtra .= " -DINLINE="; - # $srcfile = "${root}_small.c"; - } else { - $xtra .= " -w -DINLINE="; - } - - my $wrapstr; - if ($wrap_volatiles) { - $wrapstr = "-DWRAP_VOLATILES=1"; - } else { - $wrapstr = "-DWRAP_VOLATILES=0"; - } - - my $valgrind = ""; - if ($VALGRIND_ON_COMPILER) { - $valgrind = "/home/regehr/valgrind-inst/bin/valgrind --trace-children=yes"; - } - - my $out = "${exe}.out"; - my $compilerout = "${exe}_compiler.out"; - - # ccomp doesn't allow -I option appearing after $srcfile - #my $command = "RunSafely.sh $COMPILER_TIMEOUT 1 /dev/null $compilerout $valgrind $compiler $opt $xtra $srcfile -o $exe $custom_options $wrapstr $notmp -I${CSMITH_HOME}/runtime"; - my $command = "RunSafely.sh $COMPILER_TIMEOUT 1 /dev/null $compilerout $valgrind $compiler $opt $xtra $xxtra $notmp -I${CSMITH_HOME}/runtime $srcfile -o $exe $custom_options $wrapstr $notmp "; - - print "$command\n"; - - (my $res, my $dur) = runit ($command); - - if (($res != 0) || (!(-e $exe))) { - if ($res == $COMPILER_TIMEOUT_RES) { - print STDERR "COMPILER FAILURE: TIMEOUT\n"; - } else { - print STDERR "COMPILER FAILURE with return code $res; output is:\n"; - open INF, "<$compilerout" or die; - while (my $line = ) { print " $line"; } - close INF; - } - return (-2,"",-1); - } - - if ($VALGRIND_ON_COMPILER) { - open INF, "<$compilerout" or die; - while (my $line = ) { - if ($line =~ /ERROR SUMMARY: ([0-9]+) /) { - my $errcount = $1; - print "$line"; - if ($errcount > 0) { - print "SAFETY FAILURE: $line"; - } - } - } - close INF; - } - - if (!$RUN_PROGRAM) { - return (0,"",0); - } - - ($res, $dur) = runit ("run_program.pl $exe $srcfile $arch $CHECK_VOLATILE $compiler > $out"); - - if (-f "vol_addr.txt") { - system("mv vol_addr.txt ${exe}_vol_addr.txt"); - } - - if ($res != 0) { - print "couldn't compute access summary\n"; - return (-1,"",-1); - } - - system "grep 'cpu time' ${exe}.raw-out.time"; - - my $result = ""; - my $code_size = 0; - - open INF, "<$out" or die; - while (my $line = ) { - if ($line =~ /CODE SIZE ([0-9]+)$/) { - $code_size = $1; - } else { - $result .= $line; - } - } - close INF; - - die if (!defined($code_size)); - - return (0,$result,$code_size); - } - -# return a hash whose keys are the names of volatile variables -sub find_volatiles ($) { - (my $cfile) = @_; - - open INF, "<$cfile.c" or die; - my %vols; - my $vcount = 0; - while (my $line = ) { - chomp $line; - if ($line =~ /\/\/ VOLATILE GLOBAL (.+)$/) { - my $v = $1; - $vols{$v} = 1; - $vcount++; - print "volatile $v\n"; - } - } - close INF; - - print "$vcount volatile variables\n"; - - return ($vcount, \%vols); - } - -sub instantiate_test_scripts ($$$$) { - (my $infn, my $opt1, my $opt, my $base_compiler) = @_; - open INF, "<$infn" or die; - open OUTF, ">./test1.sh" or die; - while () { - (s/XX_WORKING_OPT/$opt1/g); - (s/XX_BROKEN_OPT/$opt/g); - if ($base_compiler eq "llvm") { - (s/XX_COMPILER/llvm-gcc/g); - } elsif ($base_compiler eq "gcc") { - (s/XX_COMPILER/gcc/g); - } elsif ($base_compiler eq "armcc") { - # nothing - } else { - die; - } - print OUTF; - } - close INF; - close OUTF; - open INF, "<$infn" or die; - open OUTF, ">./test2.sh" or die; - while () { - (s/XX_WORKING_OPT/$opt1/g); - (s/XX_BROKEN_OPT/$opt/g); - (s/XX_COMPILER/\$1/g); - print OUTF; - } - close INF; - close OUTF; - runit ("chmod a+x ./test1.sh") || die; - runit ("chmod a+x ./test2.sh") || die; -} - -my $lockmgr; - -sub lockit() { - $lockmgr = LockFile::Simple->make ( - -autoclean => 1, - -max => 10, - -nfs => 1, - -hold => 15000, - -stale => 1, - ); - my $res = $lockmgr->lock($LOCKFN); - if (!$res) { - print "couldn't get lockfile to build compiler -- not doing triage on this bug\n"; - } - return $res; -} - -sub unlockit() { - $lockmgr->unlock($LOCKFN); -} - -sub triage ($$$$$$$) { - (my $compiler, my $templ, - my $opt1, my $opt, - my $root, my $base_compiler, - my $version_searchp, my $arch) = @_; - return if (!$DO_TRIAGE); - return if ( - $base_compiler ne "gcc" && - $base_compiler ne "llvm" && - $base_compiler ne "armcc"); - if (lockit()) { - my $res; - print "diffing $opt1 and $opt\n"; - runit "cp $root.c small.c" or die; - instantiate_test_scripts ($templ, $opt1, $opt, $base_compiler); - if ($VERSION_SEARCH) { - if ($base_compiler ne "armcc" && - $arch ne "avr") { - $res = runit ("version_search.pl $base_compiler"); - } - } - runit ("reduce_miscompile.sh > reduce_log.txt 2>&1"); - print ("reduced size: "); - runit ("wc -c small.c"); - if ($VERSION_SEARCH) { - if ($base_compiler ne "armcc" && - $arch ne "avr") { - $res = runit ("version_search.pl $base_compiler"); - } - } - unlockit(); - } - } - -sub test_compiler ($$$$$) { - (my $root, my $compiler_ref, my $volsref, my $wrap, - my $custom_options) = @_; - - (my $arch, my $base_compiler, my $compiler, my $optref) = @{$compiler_ref}; - my @OPTS = @{$optref}; - - my $undef; - - print "--------------------\n"; - - if ($SKIP) { - if ((-f "../../${NOTEFILE_PREFIX}checksum_$compiler.txt") && - (-f "../../${NOTEFILE_PREFIX}checksum_$compiler.txt")) { - print "skipping $compiler\n"; - return (0, 0, 0, "f", 1); - } - } - - my %results; - my %csums; - my $min_code_size = 100000000; - my $success = 0; - my $compiler_fail = 0; - - my %var_reads; - my %var_writes; - my %num_reads; - my %num_writes; - my $first = 1; - - foreach my $opt (@OPTS) { - (my $res, my $res_str, my $code_size) = - compile_and_run ($root, $arch, $compiler, - $opt, $volsref, $wrap, $custom_options); - $num_reads{$opt} = 0; - $num_writes{$opt} = 0; - if ($res == 0) { - $success++; - if ($RUN_PROGRAM) { - if ($code_size < $min_code_size) { - $min_code_size = $code_size; - } - my $checksum_regex = "checksum = (TIMEOUT|[0-9a-fA-F]+)\\s*"; - die if ((!($res_str =~ s/$checksum_regex//)) && - (!($res_str =~ "TIMEOUT"))); - my $csum = $1; - print "$res_str"; - print "checksum = $csum\n"; - $results{$opt} = $res_str; - $csums{$opt} = $csum; - - my $tot_reads = 0; - my $tot_writes = 0; - - while ($res_str =~ /([0-9a-zA-Z\_]+): ([0-9]+) reads, ([0-9]+) writes/g) { - $var_reads{$opt}{$1} = $2; - $var_writes{$opt}{$1} = $3; - $num_reads{$opt} += $2; - $num_writes{$opt} += $3; - $tot_reads += $2; - $tot_writes += $3; - } - - if ($first && - $BAIL_ON_ZERO_WRITES && - $tot_writes == 0) { - print "BAILING due to zero volatile writes\n"; - return (1, 0, $undef, $undef, 1); - } - $first = 0; - - } - } elsif ($res == -2) { - $compiler_fail++; - } else { - die if ($res != -1); - return (1, 0, $undef, $undef); - } - } - - my $result; - my $csum; - my $writes; - my $interesting = 0; - - if ($compiler_fail > 0) { - print "COMPILER FAILED $compiler WRAP=$wrap\n"; - system "touch ../../${NOTEFILE_PREFIX}crash_$compiler.txt"; - $interesting = 1; - } - - if ($success > 0) { - - my $consistent = 1; - my $opt1; - - print "CODE SIZE $compiler WRAP=$wrap ${min_code_size}\n"; - - foreach my $opt (keys %results) { - - if (defined($result)) { - if (($csum ne $csums{$opt}) && - ($csum ne "TIMEOUT" && $csums{$opt} ne "TIMEOUT")) { - print "INTERNAL CHECKSUM FAILURE $compiler $opt WRAP=$wrap\n"; - system "touch ../../${NOTEFILE_PREFIX}checksum_$compiler.txt"; - $interesting = 1; - triage($compiler, - "$VOLATILE_HOME/test-${arch}-${base_compiler}-wrong-code-template.sh", - $opt1, $opt, $root, $base_compiler, $arch); - $consistent = 0; - last; - } - if ($CHECK_VOLATILE) { - if ($result ne $results{$opt}) { - my $write_problem = ""; - if ($num_writes{$opt} != $writes) { - $write_problem = " WRITES"; - } - print "INTERNAL VOLATILE FAILURE${write_problem} $compiler $opt WRAP=$wrap\n"; - $interesting = 1; - triage($compiler, - "$VOLATILE_HOME/test-${arch}-${base_compiler}-volatile-template.sh", - $opt1, $opt, $root, $base_compiler, $arch); - $consistent = 0; - last; - } - } - } else { - $writes = $num_writes{$opt}; - $opt1 = $opt; - $result = $results{$opt}; - $csum = $csums{$opt}; - } - } - - return (0, $consistent, $result, $csum, $interesting); - - } else { - return (0, 0, $result, $csum, $interesting); - } - } - -sub test_program ($$) { - (my $root, my $custom_options) = @_; - - my $vcount; - my $volsref; - my %mt; - - if ($CHECK_VOLATILE == $USE_VOLCHECK) { - ($vcount, $volsref) = find_volatiles ($root); - } else { - $volsref = \%mt; - } - - my @wraps; - if ($TRY_WRAP) { - @wraps = (0,1); - } else { - @wraps = (0); - } - - my $result; - my $csum; - - my $interesting = 0; - - foreach my $compiler_ref (@compilers_to_test) { - foreach my $wrap (@wraps) { - (my $abort_test, my $consistent, my $tmp_result, my $tmp_csum, my $tmp_interesting) = - test_compiler ($root, $compiler_ref, $volsref, $wrap, - $custom_options); - return -1 if ($abort_test != 0); - - if ($tmp_interesting) { - $interesting = 1; - } - - (my $arch, my $base_compiler, my $compiler, my $optref) = @{$compiler_ref}; - print "COMPLETED TEST $compiler WRAP=$wrap\n"; - - # ignore internally inconsistent results - if ($consistent) { - if (defined ($result) && - defined ($csum)) { - if ($CHECK_VOLATILE) { - if ($result ne $tmp_result) { - print "EXTERNAL VOLATILE FAILURE\n"; - $interesting = 1; - } - } - if (($csum ne $tmp_csum) && - ($csum ne "TIMEOUT") && - ($tmp_csum ne "TIMEOUT")) { - print "EXTERNAL CHECKSUM FAILURE\n"; - $interesting = 1; - } - } else { - $result = $tmp_result; - $csum = $tmp_csum; - } - } - } - } - - if ($interesting) { - return 1; - } else { - return 0; - } -} - -#################################################################### - -# on darwin timeout res is 152 instead of 137 -if ($OSNAME =~ /darwin/) { - $COMPILER_TIMEOUT_RES = 152; -} - -die "expecting filename" if scalar(@ARGV < 1); - -my $fn = $ARGV[0]; - -my $custom_options = ""; -if (scalar(@ARGV)==2) { - $custom_options = $ARGV[1]; -} - -my $res = test_program ($fn, $custom_options); -exit ($res); - -#################################################################### - diff --git a/utah/scripts/old_john_driver/find_crash.pl b/utah/scripts/old_john_driver/find_crash.pl deleted file mode 100755 index 998d9b920..000000000 --- a/utah/scripts/old_john_driver/find_crash.pl +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -use File::Temp qw/ tempfile tempdir /; - -my $args = ""; -foreach (@ARGV) { - $args .= "$_ "; -} - -system "$args > errs.txt 2>&1"; - -open INF, ") { - $errs .= $_; -} -close INF; - -if (($args =~ /gcc/ && $errs =~ /ternal compiler/) || - ($args =~ /clang/ && $errs =~ /Assertion/)) { - (my $fh, my $filename) = tempfile( "tmpfileXXXXXX" ); - system "cp small.c $filename"; - open OUTF, ">>$filename" or die; - print OUTF "// $args\n"; - close OUTF; -} diff --git a/utah/scripts/old_john_driver/kill_random.pl b/utah/scripts/old_john_driver/kill_random.pl deleted file mode 100755 index 502d66f9d..000000000 --- a/utah/scripts/old_john_driver/kill_random.pl +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/perl -w - -use strict; - -open INF, "ps axuww |" or die; -while () { - next if (!(/random\_test/)); - my @l = split /\s+/; - my $pid = $l[1]; - print "killing $pid\n"; - system "kill -9 $pid"; -} -close INF; diff --git a/utah/scripts/old_john_driver/launchn.pl b/utah/scripts/old_john_driver/launchn.pl deleted file mode 100755 index 718b711d5..000000000 --- a/utah/scripts/old_john_driver/launchn.pl +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/perl -w - -# add options to backup or delete existing data - -use strict; -use warnings; -use Sys::CPU; - -my $NICE = ""; - -sub usage () { - die "usage: launchn.pl [number] [seedfile]\n"; -} - -my $SEEDFILE = ""; -my $CPUS; -my $argc = scalar (@ARGV); - -if ($argc == 0) { - $CPUS = Sys::CPU::cpu_count(); - print "looks like we have $CPUS cpus\n"; -} elsif ($argc >= 1) { - $CPUS = $ARGV[0]; - usage() if (!($CPUS =~ /^[0-9]+$/)); - if ($argc == 2) { - $SEEDFILE = $ARGV[1]; - } -} else { - usage(); -} - -open INF, "ps axu |" or die; -while () { - if (/random\_test/) { - print "oops-- kill existing random_test.pl processes first!\n"; - exit; - } -} -close INF; - -system "nohup random_test_llvm_killer.pl > llvm_killer.log 2>&1 &"; - -system "rm -rf work*"; - -for (my $i=0; $i<$CPUS; $i++) { - my $dir = "work$i"; - system "mkdir $dir"; - system "$NICE nohup random_test.pl $dir $SEEDFILE > $dir/output.txt 2>&1 &"; -} - diff --git a/utah/scripts/old_john_driver/random_test.pl b/utah/scripts/old_john_driver/random_test.pl deleted file mode 100755 index d5c35f8b9..000000000 --- a/utah/scripts/old_john_driver/random_test.pl +++ /dev/null @@ -1,303 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -use Digest::MD5 qw(md5 md5_hex md5_base64); -use File::stat; - -# when errors are detected, fork off reduction scripts - -################################################################## - -my $USE_SWARM = 1; - -my @ALL_SWARM_OPTS = ( - "argc", - "arrays", - "bitfields", - #"checksum", - "comma-operators", - "compound-assignment", - "consts", - "divs", - "embedded-assigns", - "incr-decr-operators", - "jumps", - "longlong", - "force-non-uniform-arrays", - "math64", - "muls", - "packed-struct", - "paranoid", - "pointers", - "structs", - "unions", - "volatiles", - "volatile-pointers", - #"return-structs", - #"arg-structs", - #"return-unions", - #"arg-unions", - #"dangling-global-pointers", - #"return-dead-pointer", - #"union-read-type-sensitive", - ); - -my $SAVE_BADS = 0; - -my $MIN_PROGRAM_SIZE = 30000; - -my $CSMITH_TIMEOUT = 180; - -my $PROVIDE_SEED = 1; - - -my $XTRA = ""; - -#$XTRA .= "--no-safe-math"; -#$XTRA .= "--force-non-uniform-arrays "; -#$XTRA .= "--no-unions "; -#$XTRA .= "--no-unions "; -#$XTRA .= "--no-argc"; -#$XTRA .= "--concise "; -#$XTRA .= "--no-paranoid "; -#$XTRA .= "--random-random "; -#$XTRA .= "--math-notmp "; -#$XTRA .= "--bitfields "; - -#my $PACK = "--packed-struct"; -my $PACK = ""; - -my $QUIET = "--quiet"; -#my $QUIET = ""; - -my $notmp = "-DUSE_MATH_MACROS_NOTMP"; -#my $notmp = ""; - -my $PINTOOL_VOL_ADDR = "vol_addr.txt"; - -# my $platform = "x86"; -my $platform = "x86_64"; - -# remove the comment below to enable ccomp test -#my $CSMITH_CCOMP = "--bitfields --no-math64 --no-volatiles --ccomp"; -# my $CSMITH_CCOMP = "$BF --quiet --enable-volatile-tests x86 --vol-addr-file $PINTOOL_VOL_ADDR --no-math64 --ccomp --max-array-dim 3 --max-array-len-per-dim 5 --max-struct-fields 5 --math-notmp"; -my $CSMITH_CCOMP = ""; - -# set up pintool for volatile testing -my $use_pintool = 0; -# my $use_pintool = 1; - -#my $PIN_MODE = "-output_mode verbose"; # We are not supporting it right now -my $PIN_MODE = ""; - -if ($use_pintool) { - # Before you could use pintool to test volatile accesses, change the pintool location when necessary! - my $PIN_HOME = $ENV{"PIN_HOME"}; - die "oops: PIN_HOME environment variable needs to be set" - if (!defined($PIN_HOME)); - - $XTRA .= " --enable-volatile-tests $platform --vol-addr-file $PINTOOL_VOL_ADDR "; - my $pin_cmd; - - # make sure we are going to use the correct version of pinatrace.so, - # i.e., obj-ia32/pinatrace.so for x86 and obj-intel64/pinatrace.so for x86_64. - # For testing compcert, we use the ia32 version - if (($platform eq "x86") || (not ($CSMITH_CCOMP eq ""))) { - $pin_cmd = "$PIN_HOME/ia32/bin/pinbin -t $PIN_HOME/source/tools/ManualExamples/obj-ia32/pinatrace.so -vol_input $PINTOOL_VOL_ADDR $PIN_MODE --"; - } - elsif ($platform eq "x86_64") { - $pin_cmd = "$PIN_HOME/pin.sh -injection child -t $PIN_HOME/source/tools/ManualExamples/obj-intel64/pinatrace.so -vol_input $PINTOOL_VOL_ADDR $PIN_MODE --"; - } - else { - die "Invalid platform[$platform] for pintool!"; - } - - $ENV{"PIN_CMD"} = $pin_cmd; -} - -################################################################## - -my $CSMITH_HOME = $ENV{"CSMITH_HOME"}; - -my $good = 0; - -my %checksums; - -my $TIMED_TEST; - -# properly parse the return value from system() -sub runit ($) { - my $cmd = shift; - my $res = (system "$cmd"); - my $exit_value = $? >> 8; - return $exit_value; -} - -sub doit ($$) { - (my $n, my $work) = @_; - print "------ RANDOM PROGRAM $n ------\n"; - if ($TIMED_TEST || ($n%100)==0) { - print "timestamp: "; - system "date"; - } - my $nstr = sprintf "%06d", $n; - my $dir = "${work}/$nstr"; - - system "mkdir $dir"; - chdir $dir; - - my $fn = "rand$nstr"; - my $cfile = "${fn}.c"; - - my $SEED = ""; - if ($PROVIDE_SEED) { - my $n = int (rand (2147483647)); - $SEED = "-s $n"; - print "seed = $n\n"; - } - if ($TIMED_TEST) { - die if ($PROVIDE_SEED); - my $line = ; - if (!$line) { - print "input exhausted, exiting.\n"; - exit (0); - } - chomp $line; - printf "seedfile line: $line\n"; - die if (!($line =~ /\(([0-9]+)\,([0-9]+)\,([0-9]+)\)/)); - $SEED = "-s $1 --max-block-size $2 --max-funcs $3"; - } - - my $SWARM_OPTS = ""; - if ($USE_SWARM) { - foreach my $opt (@ALL_SWARM_OPTS) { - if (rand() < 0.5) { - $SWARM_OPTS .= " --$opt "; - } else { - $SWARM_OPTS .= " --no-$opt "; - } - } - } - - my $cmd; - if ($CSMITH_CCOMP eq "") { - $cmd = "$CSMITH_HOME/src/csmith $SEED $SWARM_OPTS $PACK $XTRA --output $cfile"; - } - else { - $cmd = "$CSMITH_HOME/src/csmith $SEED $SWARM_OPTS $CSMITH_CCOMP $XTRA --output $cfile"; - } - if ($PROVIDE_SEED) { - print "$cmd\n"; - } - my $res = runit ("RunSafely.sh $CSMITH_TIMEOUT 1 /dev/zero csmith_output.txt $cmd"); - - if ($res != 0 || !(-e "$cfile")) { - print "CSMITH FAILED\n"; - system "cat csmith_output.txt"; - chdir "../.."; - system "rm -rf $dir"; - return; - } - - my $filesize = stat("$cfile")->size; - print "$cfile is $filesize bytes\n"; - if (($filesize < $MIN_PROGRAM_SIZE) && !$TIMED_TEST) { - print "FILE TOO SMALL\n"; - chdir "../.."; - system "rm -rf $dir"; - return; - } - - my $seed; - my $prog = ""; - my $vcount = 0; - - open INF, "<$cfile" or die; - while (my $line = ) { - if ($line =~ /volatile/) { - $vcount++; - } - if ($line =~ /Seed:\s+([0-9]+)$/) { - $seed = $1; - } - chomp $line; - $prog .= "$line "; - } - close INF; - die if (!defined($seed)); - if (!$PROVIDE_SEED) { - print "regenerate with: '$cmd -s $seed'\n"; - } - - ($prog =~ s/\/\*(.*?)\*\///g); - my $digest = md5($prog); - if ($checksums{$digest}) { - print "BAD PROGRAM: DUPLICATE\n"; - chdir "../.."; - system "rm -rf $dir"; - return; - } - $checksums{$digest} = 1; - - if ($vcount < 1) { - print "NOT ENOUGH VOLATILES\n"; - chdir "../.."; - system "rm -rf $dir"; - return; - } - - if (0 && $CSMITH_CCOMP ne "") { - # ccomp doesn't like asserts, regenerate random programs without asserts. - my $noparanoid_cfile = "${fn}_small.c"; - my $cmd1 = "$CSMITH_HOME/src/csmith $CSMITH_CCOMP -s $seed --output $noparanoid_cfile"; - my $res1 = runit ("RunSafely.sh $CSMITH_TIMEOUT 1 /dev/zero randprog_output.txt $cmd1"); - } - - my $ret = system "evaluate_program.pl $fn"; - my $rc = ($ret>>8) & 0xff; - - chdir "../.."; - - #print "evaluate program returned $rc\n"; - - if ($rc == 0 || $rc == 1) { - print "GOOD PROGRAM: number $good\n"; - $good++; - } else { - print "BAD PROGRAM: doesn't count towards goal.\n"; - } - - # if ($rc != 1 && !$SAVE_BADS) { - if (1) { - system "rm -rf $dir"; - } -} - -if (scalar(@ARGV) != 1 && - scalar(@ARGV) != 2) { - die "usage: random_test.pl work_dir [seedfile]"; -} - -my $work = $ARGV[0]; - -if (!(-d $work)) { - die "error: create work dir '$work' first"; -} - -if (scalar(@ARGV)==2) { - my $seedfile = $ARGV[1]; - open SEEDFILE, "<$seedfile" or die "error: cannot open seed file $seedfile"; - $TIMED_TEST = 1; - $PROVIDE_SEED = 0; -} else { - $TIMED_TEST = 0; -} - -my $i = 0; -while (1) { - doit ($i, $work); - $i++; - print "\n"; -} - -################################################################## diff --git a/utah/scripts/old_john_driver/random_test_llvm_killer.pl b/utah/scripts/old_john_driver/random_test_llvm_killer.pl deleted file mode 100755 index 61464a9f3..000000000 --- a/utah/scripts/old_john_driver/random_test_llvm_killer.pl +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/perl -w - -use strict; - -while (1) { - - my $now; - - open INF, "date |" or die; - my $d = ; - chomp $d; - close INF; - if ($d =~ /([0-9]+):([0-9]+):([0-9]+)/) { - my $h = $1; - my $m = $2; - $now = ($h*60)+$m; - } else { - die; - } - - print "now = $now\n"; - - open INF, "ps ax -o comm=,pid=,pgrp=,bsdstart= |" or die; - while (my $line = ) { - chomp $line; - next if (!($line =~ /^cc1/)); - die if (!($line =~ /\s+([0-9]+)\s+(.*)\s+(.*)$/)); - my $pid = $1; - my $pgrp = $2; - my $stime = $3; - my $age = 999; - if ($stime =~ /([0-9]+):([0-9]+)/) { - my $h = $1; - my $m = $2; - my $t = ($h*60)+$m; - $age = $now - $t; - } - print "$line age=$age\n"; - print "pid=$pid start time=$stime age=$age\n"; - if ($age >= 3 || $age < 0) { - my $cmd = "kill -9 $pid"; - print "executing: $cmd\n"; - system "$cmd"; - } - } - close INF; - - sleep (30); - -} diff --git a/utah/scripts/old_john_driver/run_program.pl b/utah/scripts/old_john_driver/run_program.pl deleted file mode 100755 index 0a4bfad42..000000000 --- a/utah/scripts/old_john_driver/run_program.pl +++ /dev/null @@ -1,487 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -use warnings; -use English; -use Math::BigInt; -use Benchmark; - -#################################################################### - -my $USE_VOLCHECK = 1; - -my $USE_PINTOOL = 2; - -my $CHECK_VOLATILE; - -my $TIMEOUT = 5; - -my $BAIL_ON_TIMEOUT = 1; - -my $COMPILER_TIMEOUT_RES = 137; - -my $PINTOOL_PREFIX = ""; - -if (defined($ENV{"PIN_CMD"})) { - $PINTOOL_PREFIX = $ENV{"PIN_CMD"}; -} - -#################################################################### - -#{ -# my $ofh = select STDOUT; -# $| = 1; -# select $ofh; -#} - -my %name_to_addr; -my %addr_to_name; - -my $exe; - -my $print_sizep = 1; - -# properly parse the return value from system() -sub runit ($) { - my $cmd = shift; - - my $start = new Benchmark; - my $res = (system "$cmd"); - my $exit_value = $? >> 8; - my $end = new Benchmark; - my $dur = timediff($end, $start); - return ($exit_value, $dur); -} - -# return a hash whose keys are the names of volatile variables -sub find_volatiles ($) { - (my $cfile) = @_; - - open INF, "<$cfile" or die "FAIL couldn't read cfile"; - my %vols; - my $vcount = 0; - while (my $line = ) { - chomp $line; - if ($line =~ /\/\/ VOLATILE GLOBAL (.+)$/) { - my $v = $1; - $vols{$v} = 1; - $vcount++; - print "volatile $v\n"; - } - } - close INF; - - print "$vcount volatile variables\n"; - - return ($vcount, \%vols); -} - -sub parse_output ($$$$) { - (my $out, my $arch, my $volref, my $timeout) = @_; - - my %vols = %{$volref}; - my %reads = (); - my %writes = (); - my $vol_accesses = ""; - - if (($CHECK_VOLATILE == $USE_VOLCHECK) && ($arch eq "ia32" || $arch eq "arm")) { - foreach my $v (sort keys %vols) { - $reads{$v} = 0; - $writes{$v} = 0; - } - } - - # oi... - if ($arch eq "arm") { - system "cat armul.trc >> $out" || die; - } - - open INF, "<$out" or die "FAIL couldn't open program output file '$out'"; - my $csum; - - if ($timeout) { - $csum = "TIMEOUT"; - } - - while (my $line = ) { - - #print $line; - - chomp $line; - - if ($arch eq "ia32" || $arch eq "arm" || $arch eq "windiss") { - if ($line =~ /checksum = ([0-9a-fA-F]+)/) { - $csum = $1; - next; - } - if (($CHECK_VOLATILE == $USE_VOLCHECK) && - $arch eq "arm" && - $line =~ /^M[NS]([RW])([1-4]).... ([0-9a-fA-F]+) ([0-9a-fA-F]+)$/) { - my $action = $1; - my $bytes = $2; - my $hexaddr = $3; - my $val = $4; - my $addr = hex($hexaddr); - my $var = $addr_to_name{$addr}; - - next if (!defined($var)); - - ## FIXME TODO handle fragmented accesses - - if ($action eq "R") { - $reads{$var}++; - } elsif ($action eq "W") { - $writes{$var}++; - } else { - die "FAIL impossible action '$action' in volcheck output"; - } - next; - } - - if (($CHECK_VOLATILE == $USE_VOLCHECK) && - $arch eq "ia32" && - $line =~ /\s(load|store)\s+0x([0-9a-fA-F]+)\s+([0-9]+)\s+([0-9]+)$/) { - my $action = $1; - my $hexaddr = $2; - my $addr = hex($hexaddr); - my $bytes = $3; - my $count = $4; - my $var = $addr_to_name{$addr}; - - next if (!defined($var)); - - ## FIXME TODO handle fragmented accesses - - if ($action eq "load") { - next if (!defined($reads{$var})); - $reads{$var} = $count; - } elsif ($action eq "store") { - next if (!defined($writes{$var})); - $writes{$var} = $count; - } else { - die "FAIL impossible action '$action' in volcheck output"; - } - next; - } - if (($CHECK_VOLATILE == $USE_PINTOOL) && - ($arch eq "ia32") && - ($line =~ /([0-9a-fA-F]+):\s+([0-9]+)\s+reads,\s+([0-9]+)\s+writes$/)) { - $vol_accesses .= "$line\n"; - } - - } elsif ($arch eq "avr") { - - #print "$line\n"; - - if ($line =~ /r30\:r31 = 0x([0-9a-fA-F]+)/) { - $csum = $1; - next; - } - - my $num_or_nan = "[0-9\\.]+|\\(NaN\\)"; - - if (($CHECK_VOLATILE == $USE_VOLCHECK) && - $line =~ /^\s*0x([0-9a-fA-F]+):\s+([0-9]+)\s+($num_or_nan)\s+\%\s+([0-9]+)\s+($num_or_nan)\s+%\s*$/) { - my $addr = hex($1); - my $reads = $2; - my $writes = $4; - my $var = $addr_to_name{$addr + 0x800000}; - - #print "addr = $addr, reads = $reads, writes = $writes\n"; - - next if ($reads == 0 && $writes == 0); - next if (!defined($var)); # FAIL here? - die "bug FAIL" if (defined($reads{$var})); - die "bug FAIL" if (defined($writes{$var})); - $reads{$var} = $reads; - $writes{$var} = $writes-1; # correct for initialization - next; - } - } elsif ($arch eq "msp") { - if ($line =~ /checksum = ([0-9a-fA-F]+)/) { - $csum = $1; - } - - if (($CHECK_VOLATILE == $USE_VOLCHECK) && - $line =~ /\[ ([0-9]+) reads: ([0-9]+) writes: ([0-9]+) \]/) { - my $addr = $1; - my $reads = $2; - my $writes = $3; - - my $var = $addr_to_name{$addr}; - - #print "addr = $addr, reads = $reads, writes = $writes\n"; - - next if (!defined($var)); - die "bug FAIL" if (defined($reads{$var})); - die "bug FAIL" if (defined($writes{$var})); - $reads{$var} = $reads; - $writes{$var} = $writes-1; # correct for initialization - next; - } - } else { - die "unknown arch '$arch'"; - } - } - - if (!defined($csum)) { - print STDERR "BAILING -- no checksum\n"; - exit (-1); - } - - my $results = "checksum = $csum\n"; - - my $lame = 1; - if ($CHECK_VOLATILE == $USE_VOLCHECK) { - foreach my $v (sort keys %vols) { - #print "$v\n"; - die "bug FAIL" if (!defined($reads{$v})); - die "bug FAIL" if (!defined($writes{$v})); - if ($reads{$v} != 1 || $writes{$v} != 0) { - $lame = 0; - } - $results .= "$v: $reads{$v} reads, $writes{$v} writes\n"; - } - } - elsif ($CHECK_VOLATILE == $USE_PINTOOL) { - $results .= "$vol_accesses"; - } - - if (0) { - #if ($lame) { - print STDERR "BAILING -- lame accesses\n"; - exit (-1); - } - - return $results; -} - -sub get_syms ($) { - (my $nm) = @_; - open INF, "$nm $exe |" or die "FAIL"; - while () { - if (/^([0-9a-fA-F]+) [RrBbDd] ([0-9a-zA-Z\_]+)$/) { - #my $address = hex($1); - my $address = Math::BigInt->new($1)->as_hex; - my $name = $2; - $name_to_addr{$name} = $address; - $addr_to_name{$address} = $name; - # print "$name is at $address\n"; - } - } - close INF; -} - -sub get_arm_syms () { - open INF, "fromelf -s $exe |" or die "FAIL"; - while () { - if (/([0-9]+)\s+([0-9a-zA-Z\_]+)\s+0x([0-9a-fA-F]+)/) { - my $address = hex($3); - my $name = $2; - $name_to_addr{$name} = $address; - $addr_to_name{$address} = $name; - } - } - close INF; -} - -sub print_size ($) { - (my $sizecmd) = @_; - open INF, "$sizecmd $exe |" or die "FAIL"; - my $l1 = ; - my $l2 = ; - ($l2 =~ /^\s*([0-9]+)\s/); - my $bytes = $1; - close INF; - print "CODE SIZE $bytes\n"; -} - -############################## main ########################### - -my $VOLATILE_HOME=$ENV{"CSMITH_HOME"}."/utah/scripts/john_driver"; -die "oops: VOLATILE_HOME environment variable needs to be set" - if (!defined($VOLATILE_HOME)); - -my $nargs = scalar(@ARGV); - -die "FAIL expecting exe-filename c-filename architecture check_volatile? compiler [nosize]" if - ($nargs != 4 && $nargs != 5); -$exe = $ARGV[0]; -my $cfile = $ARGV[1]; -my $arch = $ARGV[2]; -$CHECK_VOLATILE = $ARGV[3]; -my $compiler = $ARGV[4]; -if ($nargs == 6) { - if ($ARGV[5] eq "nosize") { - $print_sizep = 0; - } else { - die "FAIL 6th arg must be 'nosize'"; - } -} - -# on darwin timeout res is 152 instead of 137 -if ($OSNAME =~ /darwin/) { - $COMPILER_TIMEOUT_RES = 152; -} - -# print "$exe $cfile $arch\n"; - -die "FAIL" if ( - ($arch ne "avr") && - ($arch ne "ia32") && - ($arch ne "msp") && - ($arch ne "arm") && - ($arch ne "windiss") - ); - -my $out = "${exe}.raw-out"; - -my %vols = (); -if ($CHECK_VOLATILE == $USE_VOLCHECK) { - %vols = %{find_volatiles($cfile)}; -} - -my $timeout = 0; - -if ($arch eq "ia32") { - - my $cmd_prefix = ""; - my $res = 0; - my $dur; - - if ($CHECK_VOLATILE == $USE_VOLCHECK) { - $cmd_prefix = "valgrind --tool=volcheck --trace-mem=yes --missing-loc-ok=yes --print-mem-per=no"; - } - elsif ($CHECK_VOLATILE == $USE_PINTOOL) { - $cmd_prefix = "$PINTOOL_PREFIX"; - # I don't know why , but pintool make TIMEOUT doesn't work. - # So we run exe without pintool and if it's timeout, then - # we don't need to hang on forever - ($res, $dur) = runit ("RunSafely.sh $TIMEOUT 1 /dev/null $out ./$exe"); - $TIMEOUT = 30; - } - - if (!$res) { - ($res, $dur) = runit ("RunSafely.sh $TIMEOUT 1 /dev/null $out $cmd_prefix ./$exe"); - } - - if ($res == $COMPILER_TIMEOUT_RES) { - print STDERR "TIMEOUT\n"; - if ($BAIL_ON_TIMEOUT) { - exit (-1); - } else { - $timeout = 1; - } - } elsif ($res != 0) { - print STDERR "UNEXPECTED $arch $compiler PROGRAM FAIL, retval = ${res}\n"; - exit (-1); - } - - get_syms ("nm"); - if ($print_sizep) { - print_size ("size"); - } - -} elsif ($arch eq "windiss") { - - # hack-- we won't worry about a timeout - - my $cmd = "windiss ./$exe"; - (my $res, my $dur) = runit ("RunSafely.sh 30 1 /dev/null $out ${cmd}"); - - if ($res == 137) { - print STDERR "TIMEOUT\n"; - exit (-1); - } - - if ($res != 0) { - print STDERR "UNEXPECTED $arch $compiler PROGRAM FAIL, retval = ${res}\n"; - exit (-1); - } - -} elsif ($arch eq "arm") { - - my $arm_cmd = "rvdebug --batch --script=${VOLATILE_HOME}/rvd_script_1"; - system "rm -f armul.trc"; - system "cp -f $exe __image.axf"; - # extra long time out-- this is just to cover up stupid bugs, the - # sim is supposed to timeout on its own due to watchdog! - (my $res, my $dur) = runit ("RunSafely.sh 300 1 /dev/null $out ${arm_cmd}"); - system "cp -f armul.trc $exe.trc" || die; - system "rm -f __image.axf" || die; - - if ($res == 137) { - print STDERR "TIMEOUT\n"; - exit (-1); - } - - if ($res != 0) { - print STDERR "UNEXPECTED $arch $compiler PROGRAM FAIL, retval = ${res}\n"; - exit (-1); - } - - get_arm_syms(); - -} elsif ($arch eq "avr") { - get_syms ("avr-nm"); - my $watches = ""; - my $first = 1; - foreach my $v (keys %vols) { - my $addr = $name_to_addr{$v} - 0x800000; - if (defined($addr)) { - if (!$first) { - $watches .= ","; - } else { - $first = 0; - } - $watches .= "$v"; - } else { - # not an error to get here -- compiler can eliminate - # unused volatiles - } - } - my $avrora_options = "-platform=mica2 -simulation=sensor-network -monitors=memory,break -colors=false -seconds=15"; - my $avrora_cmd = "java -server avrora.Main $avrora_options -locations=$watches $exe > $out"; - # print STDERR "${avrora_cmd}\n"; - (my $res, my $dur) = runit ("${avrora_cmd}"); - - if ($res == 137) { - print STDERR "TIMEOUT\n"; - exit (-1); - } - - if ($res != 0) { - print STDERR "UNEXPECTED $arch $compiler PROGRAM FAIL, retval = ${res}\n"; - exit (-1); - } - - if ($print_sizep) { - print_size ("avr-size"); - } - -} elsif ($arch eq "msp") { - get_syms ("msp430-nm"); - my $mspsim_cmd = "java se.sics.mspsim.platform.sky.SkyNode $exe -nogui > $out"; - (my $res, my $dur) = runit ("RunSafely.sh $TIMEOUT 1 /dev/null $out $mspsim_cmd"); - - if ($res == 137) { - print STDERR "TIMEOUT\n"; - exit (-1); - } - - if ($res != 0) { - print STDERR "UNEXPECTED $arch $compiler PROGRAM FAIL, retval = ${res}\n"; - exit (-1); - } - - if ($print_sizep) { - print_size ("msp430-size"); - } -} else { - die "FAIL"; -} - -my $result = parse_output ($out, $arch, \%vols, $timeout); -print "$result"; -# print STDERR $result; -exit (0); diff --git a/utah/scripts/old_john_driver/see_results.sh b/utah/scripts/old_john_driver/see_results.sh deleted file mode 100755 index ee2e762fe..000000000 --- a/utah/scripts/old_john_driver/see_results.sh +++ /dev/null @@ -1,3 +0,0 @@ -grep FAIL work*/output.txt | grep -v 'COMPILER FAILURE' -echo -n 'tests: ' -grep GOOD work*/output.txt | wc -l diff --git a/utah/scripts/old_john_driver/test_csmith.pl b/utah/scripts/old_john_driver/test_csmith.pl deleted file mode 100755 index a96fec676..000000000 --- a/utah/scripts/old_john_driver/test_csmith.pl +++ /dev/null @@ -1,185 +0,0 @@ -#!/usr/bin/perl -w -## -## Copyright (c) 2011 The University of Utah -## All rights reserved. -## -## This file is part of `csmith', a random generator of C programs. -## -## Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are met: -## -## * Redistributions of source code must retain the above copyright notice, -## this list of conditions and the following disclaimer. -## -## * Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in the -## documentation and/or other materials provided with the distribution. -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -## ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -## LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -## POSSIBILITY OF SUCH DAMAGE. - -use strict; -use File::stat; - -## This is a simple tester for Csmith itself. - -####################################################################### - -my $MIN_PROGRAM_SIZE = 8000; -my $CSMITH_HOME = $ENV{"CSMITH_HOME"}; -my $COMPILER = "gcc -w -O0"; - -my $EXTRA_OPTIONS = "--no-unions"; - -#my $VALGRIND = ""; -my $VALGRIND = "valgrind -q --error-exitcode=66 "; - -#my $RUN_PROGRAM = 0; -my $RUN_PROGRAM = 1; - -#my $RUN_KCC = 0; -my $RUN_KCC = 1; - -####################################################################### - -my $HEADER = "-I${CSMITH_HOME}/runtime -DCSMITH_MINIMAL"; - -# properly parse the return value from system() -sub runit ($$) { - my ($cmd, $out) = @_; - print "about to run '$cmd'\n"; - my $res = system "$cmd"; - my $exit_value = $? >> 8; - $exit_value = $? & 127 if ($? & 127); - return $exit_value; -} - -sub yesno ($) { - (my $opt) = @_; - if (rand() < 0.5) { - return " --$opt "; - } else { - return " --no-$opt "; - } -} - -my $n_good = 0; - -sub run_test () { - my $cfile = "test.c"; - my $ofile = "test.exe"; - my $ofile_kcc = "test_kcc.exe"; - - system "rm -f $cfile $ofile $ofile_kcc"; - - my $CSMITH_OPTIONS = ""; - if (rand()<0.5) { $CSMITH_OPTIONS .= " --quiet "; } - # if (rand()<0.5) { $CSMITH_OPTIONS .= " --concise "; } - $CSMITH_OPTIONS .= yesno ("math64"); - $CSMITH_OPTIONS .= yesno ("paranoid"); - $CSMITH_OPTIONS .= yesno ("longlong"); - $CSMITH_OPTIONS .= yesno ("pointers"); - $CSMITH_OPTIONS .= yesno ("arrays"); - $CSMITH_OPTIONS .= yesno ("jumps"); - $CSMITH_OPTIONS .= yesno ("consts"); - $CSMITH_OPTIONS .= yesno ("volatiles"); - $CSMITH_OPTIONS .= yesno ("volatile-pointers"); - $CSMITH_OPTIONS .= yesno ("checksum"); - $CSMITH_OPTIONS .= yesno ("divs"); - $CSMITH_OPTIONS .= yesno ("muls"); - $CSMITH_OPTIONS .= yesno ("compound-assignment"); - $CSMITH_OPTIONS .= yesno ("structs"); - $CSMITH_OPTIONS .= yesno ("packed-struct"); - $CSMITH_OPTIONS .= yesno ("bitfields"); - $CSMITH_OPTIONS .= yesno ("argc"); - - my $cmd = "$VALGRIND $CSMITH_HOME/src/csmith $CSMITH_OPTIONS $EXTRA_OPTIONS --output $cfile"; - my $res = runit ($cmd, "csmith.out"); - if ($res != 0 || !(-f $cfile) ) { - print "Failed to generate program: $cmd\n"; - exit (-1); - } - my $filesize = stat($cfile)->size; - if ($filesize < $MIN_PROGRAM_SIZE) { - return; - } - system "grep Seed $cfile"; - system "ls -l $cfile"; - system "rm -f $ofile"; - my $cmd2 = "$COMPILER $cfile $HEADER -o $ofile"; - $res = runit ($cmd2, "csmith.out"); - if ($res != 0 || !(-f $ofile)) { - print "Failed to compile program generated by $cmd\n"; - exit (-1); - } - - if ($RUN_PROGRAM) { - my $cmd3 = "RunSafely.sh 2 1 /dev/null out.txt $VALGRIND ./$ofile"; - $res = runit ($cmd3, "out2.txt"); - if ($res != 0 && $res != 137) { - print "Compiled random program died with error code $res\n"; - exit (-1); - } - if ($res == 137) { - print "Timed out.\n"; - return; - } - } - - if ($RUN_KCC) { - - my $cmd3 = "kcc $cfile $HEADER -o $ofile_kcc"; - $res = runit ($cmd3, "csmith.out"); - if ($res != 0 || !(-f $ofile_kcc)) { - print "KCC failed to compile program generated by $cmd\n"; - exit (-1); - } - - my $cmd4 = "RunSafely.sh 600 1 /dev/null out.txt ./$ofile_kcc"; - $res = runit ($cmd4, "out2.txt"); - if ($res != 0 && $res != 137) { - print "KCC output died with error code $res\n"; - exit (-1); - } - if ($res == 137) { - print "Timed out.\n"; - return; - } - } - - $n_good++; - print "finished with test case $n_good.\n\n"; -} - -sub run_tests ($) { - (my $n_tests) = @_; - - while ($n_tests == -1 || $n_good < $n_tests) { - run_test (); - } -} - -########################### main ################################## - -if (!(-f "$CSMITH_HOME/runtime/csmith.h")) { - print "Please point the environment variable CSMITH_HOME to the top-level\n"; - print "directory of your Csmith tree before running this script.\n"; - exit(-1); -} - -my $cnt = $ARGV[0]; -$cnt = -1 if (!defined($cnt)); -$EXTRA_OPTIONS = $ARGV[1] if (@ARGV==2); -print "extra = $EXTRA_OPTIONS\n"; -run_tests ($cnt); - -################################################################## diff --git a/utah/scripts/one_off/binsrch_det.pl b/utah/scripts/one_off/binsrch_det.pl deleted file mode 100755 index 2c45f0698..000000000 --- a/utah/scripts/one_off/binsrch_det.pl +++ /dev/null @@ -1,129 +0,0 @@ -#!/usr/bin/perl -w - -use strict; - -my $SIZE = 50; - -my $total_tests = 0; - -my $REPS = 10000; - -my %results; -my $tests; - -sub check_results ($) { - (my $i) = @_; - my $r = $results{$i}; - my $foo; - if (!(defined($r))) { - $foo = "x"; - } else { - $foo = $r; - } - #print "checking $i (result = $foo)\n"; - $tests++; - return $r; -} - -for (my $rep = 0; $rep < $REPS; $rep++) { - -%results = (); -$tests = 0; - -my $flip = int (rand ($SIZE-1))+2; -#print "flip element is $flip\n"; -for (my $i=1; $i<=$SIZE; $i++) { - if ($i > 1 && - $i < $SIZE && - $i != $flip && - rand() < 0.25) { - # leave undefined - } else { - if ($i < $flip) { - $results{$i} = 1; - } else { - $results{$i} = 0; - } - } -} - -my $lo = 1; -my $hi = $SIZE; - -OUTER: -while (1) { - die if ($lo >= $hi); - die if ($results{$lo} != 1); - die if ($results{$hi} != 0); - - # normal binsearch termination condition - last if (($hi-$lo)==1); - - my $mid = int (($hi+$lo)/2); - goto MORE if (defined(check_results($mid))); - - goto LINEAR if (($hi-$lo)<12); - - $mid = $lo + int (($hi-$lo)*0.750); - goto MORE if (defined(check_results($mid))); - - $mid = $lo + int (($hi-$lo)*0.250); - goto MORE if (defined(check_results($mid))); - - $mid = $lo + int (($hi-$lo)*0.125); - goto MORE if (defined(check_results($mid))); - - $mid = $lo + int (($hi-$lo)*0.375); - goto MORE if (defined(check_results($mid))); - - $mid = $lo + int (($hi-$lo)*0.675); - goto MORE if (defined(check_results($mid))); - - $mid = $lo + int (($hi-$lo)*0.825); - goto MORE if (defined(check_results($mid))); - - LINEAR: - # linear scan to force termination - #print "backing off to linear scan\n"; - for (my $i=$lo+1; $i<=$hi; $i++) { - my $x = check_results ($i); - if (defined($x) && - $x == 0) { - $hi = $i; - last OUTER; - } - } - die; - - MORE: - # regular binary search - - #print "lo = $lo, hi = $hi, mid = $mid\n"; - die if ($mid <= $lo); - die if ($mid >= $hi); - - my $r = check_results ($mid); - die if (!defined($r)); - if ($r == 0) { - $hi = $mid; - } else { - $lo = $mid; - } - next OUTER; - -} - -die if ($results{$lo} != 1); -die if ($results{$hi} != 0); -print "first broken version is: $hi\n"; -die if ($hi != $flip); - -$total_tests += $tests; - -#print "\n\n"; - -} - -my $av = (0.0 + $total_tests) / $REPS; - -print "$av average tests\n"; diff --git a/utah/scripts/one_off/binsrch_randomized.pl b/utah/scripts/one_off/binsrch_randomized.pl deleted file mode 100755 index 4e46fceb7..000000000 --- a/utah/scripts/one_off/binsrch_randomized.pl +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/perl -w - -use strict; - -my $SIZE = 50; -my $MAX_RETRY = 4; - -my $total_tests = 0; - -my $REPS = 10000; - -for (my $rep = 0; $rep < $REPS; $rep++) { - -my %results; - -my $flip = int (rand ($SIZE-1))+2; -#print "flip element is $flip\n"; -for (my $i=1; $i<=$SIZE; $i++) { - if ($i > 1 && - $i < $SIZE && - $i != $flip && - rand() < 0.25) { - # leave undefined - } else { - if ($i < $flip) { - $results{$i} = 0; - } else { - $results{$i} = 1; - } - } -} - -my $hi = $SIZE; -my $lo = 1; -my $tests = 0; - -OUTER: -while (1) { - die if ($lo >= $hi); - die if ($results{$lo} != 0); - die if ($results{$hi} != 1); - - last if (($hi-$lo)==1); - my $retry_count = 0; - - RETRY: - my $mid = $lo + 1 + int (rand ($hi-$lo-1)); - #print "lo = $lo, hi = $hi, mid = $mid\n"; - die if ($mid <= $lo); - die if ($mid >= $hi); - $tests++; - - if (!(defined($results{$mid}))) { - if ($retry_count < $MAX_RETRY) { - $retry_count++; - #print "retry $retry_count of $MAX_RETRY\n"; - goto RETRY; - } - # linear scan - #print "backing off to linear scan\n"; - for (my $i=$lo+1; $i<=$hi; $i++) { - my $x = $results{$i}; - $tests++; - if (defined($x) && - $x == 1) { - $hi = $i; - last OUTER; - } - } - die; - } else { - # regular binary search - if ($results{$mid} == 0) { - $lo = $mid; - } else { - $hi = $mid; - } - } -} - -die if ($results{$lo} != 0); -die if ($results{$hi} != 1); -print "first broken version is $hi\n"; -die if ($hi != $flip); - -$total_tests += $tests; -} - -my $av = (0.0 + $total_tests) / $REPS; - -print "$av average tests\n"; diff --git a/utah/scripts/one_off/collect_results.pl b/utah/scripts/one_off/collect_results.pl deleted file mode 100755 index 6b3be7320..000000000 --- a/utah/scripts/one_off/collect_results.pl +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/perl -w - -use strict; - -my @hosts = ( - "node-1.tribe2.alchemy.emulab.net", - "node-2.tribe2.alchemy.emulab.net", - "node-3.tribe2.alchemy.emulab.net", - "node-4.tribe2.alchemy.emulab.net", - "node-5.tribe2.alchemy.emulab.net", - "node-6.tribe2.alchemy.emulab.net", - "node-7.tribe2.alchemy.emulab.net", - "node-8.tribe2.alchemy.emulab.net", - "node-9.tribe2.alchemy.emulab.net", - "node-10.tribe2.alchemy.emulab.net", - ); - -my $DIR = "/mnt/volatile_testing/volatile/workXXX"; -my $max_host = 10; - -my $N=2; - -my $num = 20; -foreach my $host (@hosts) { - for (my $i=0; $i<$N; $i++) { - $num++; - my $dir = $DIR; - ($dir =~ s/XXX/$i/); - my $cmd = "scp $host:$dir/output.txt output/output$num.txt"; - print "$cmd\n"; - system $cmd; - # system "bzip2 -9v output/output$n.txt"; - } -} diff --git a/utah/scripts/one_off/compare_size.pl b/utah/scripts/one_off/compare_size.pl deleted file mode 100755 index 505af0be4..000000000 --- a/utah/scripts/one_off/compare_size.pl +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -use warnings; - -my %count; -my %cycles1; -my %bytes1; -my %cycles2; -my %bytes2; - -my @versions = ("4.1.2", "4.2.2"); -my @opts = ("0","1","2","s","3"); - -while () { - - if (/^([a-zA-Z0-9\.]+) ([0-9]+) cycles ([0-9]+) bytes$/) { - my $name = $1; - my $cyc = $2; - my $byt = $3; - - die if (!($name =~ /^rand([0-9]+)avrgcc([0-9\.]+)O([0123s])\.elf/)); - my $prog = $1; - my $version = $2; - my $opt = $3; - - $cycles1{$prog}{$version}{$opt} = $cyc; - $bytes1{$prog}{$version}{$opt} = $byt; - $cycles2{$prog}{$opt}{$version} = $cyc; - $bytes2{$prog}{$opt}{$version} = $byt; - $count{$prog}++; - - next; - } -} - -my $n = 0; -my %t_cycles; -my %t_bytes; - -foreach my $prog (keys %cycles1) { - next if ($count{$prog} != 10); - $n++; - foreach my $ver (@versions) { - foreach my $opt (@opts) { - $t_cycles{$ver}{$opt} += $cycles1{$prog}{$ver}{$opt}; - $t_bytes{$ver}{$opt} += $bytes1{$prog}{$ver}{$opt}; - } - } -} - -print "averaging over $n programs\n"; - -{ - foreach my $opt (@opts) { - foreach my $ver (@versions) { - my $a_cycles = int (($t_cycles{$ver}{$opt} * 1.0) / $n); - my $a_bytes = int (($t_bytes{$ver}{$opt} * 1.0) / $n); - print "$ver -O$opt $a_cycles cycles, $a_bytes bytes\n"; - } - } -} diff --git a/utah/scripts/one_off/compare_sizes.pl b/utah/scripts/one_off/compare_sizes.pl deleted file mode 100755 index 8cdeb3767..000000000 --- a/utah/scripts/one_off/compare_sizes.pl +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -sub code_size ($) { - (my $fn) = @_; - open INF, "size -d $fn |" or die; - my $junk = ; - my $line = ; - die if (!($line =~ /^\s+([0-91]+)\s+/)); - my $size = $1; - close INF; - return $size; -} - -my $s1 = code_size ($ARGV[0]); -my $s2 = code_size ($ARGV[1]); - -my $ratio = (0.0+$s1)/$s2; - -print " ( $s1 $s2 $ratio )\n"; - -if ($ratio > 8.0) { - exit 0; -} else { - exit -1; -} diff --git a/utah/scripts/one_off/compiler_test_xuejun.txt b/utah/scripts/one_off/compiler_test_xuejun.txt deleted file mode 100644 index ceb070025..000000000 --- a/utah/scripts/one_off/compiler_test_xuejun.txt +++ /dev/null @@ -1,57 +0,0 @@ -# compiler implementations (long format) -# /home/jason/compilers/gcc-420/install/bin/gcc-420 -O0 -# /home/jason/compilers/gcc-420/install/bin/gcc-420 -O1 -# /home/jason/compilers/gcc-420/install/bin/gcc-420 -O2 -# /home/jason/compilers/gcc-420/install/bin/gcc-420 -O3 -# /home/jason/compilers/gcc-420/install/bin/gcc-420 -Os -# /home/jason/compilers/gcc-430/install/bin/gcc-430 -O0 -# /home/jason/compilers/gcc-430/install/bin/gcc-430 -O1 -#/home/jason/compilers/gcc-430/install/bin/gcc-430 -O2 -#/home/jason/compilers/gcc-430/install/bin/gcc-430 -O3 -#/home/jason/compilers/gcc-430/install/bin/gcc-430 -Os -/home/jason/compilers/gcc-440/install/bin/gcc-440 -O0 -/home/jason/compilers/gcc-440/install/bin/gcc-440 -O1 -/home/jason/compilers/gcc-440/install/bin/gcc-440 -O2 -/home/jason/compilers/gcc-440/install/bin/gcc-440 -O3 -/home/jason/compilers/gcc-440/install/bin/gcc-440 -Os -/home/jason/compilers/gcc-443/install/bin/gcc-443 -O0 -/home/jason/compilers/gcc-443/install/bin/gcc-443 -O1 -/home/jason/compilers/gcc-443/install/bin/gcc-443 -O2 -/home/jason/compilers/gcc-443/install/bin/gcc-443 -O3 -/home/jason/compilers/gcc-443/install/bin/gcc-443 -Os -/home/jason/compilers/gcc-444/install/bin/gcc-444 -O0 -/home/jason/compilers/gcc-444/install/bin/gcc-444 -O1 -/home/jason/compilers/gcc-444/install/bin/gcc-444 -O2 -/home/jason/compilers/gcc-444/install/bin/gcc-444 -O3 -/home/jason/compilers/gcc-444/install/bin/gcc-444 -Os -/home/jason/compilers/gcc-445/install/bin/gcc-445 -O0 -/home/jason/compilers/gcc-445/install/bin/gcc-445 -O1 -/home/jason/compilers/gcc-445/install/bin/gcc-445 -O2 -/home/jason/compilers/gcc-445/install/bin/gcc-445 -O3 -/home/jason/compilers/gcc-445/install/bin/gcc-445 -Os -/home/jason/compilers/gcc-450/install/bin/gcc-450 -O0 -/home/jason/compilers/gcc-450/install/bin/gcc-450 -O1 -/home/jason/compilers/gcc-450/install/bin/gcc-450 -O2 -/home/jason/compilers/gcc-450/install/bin/gcc-450 -O3 -/home/jason/compilers/gcc-450/install/bin/gcc-450 -Os -/home/jason/compilers/clang-27/install/bin/clang-27 -O0 -/home/jason/compilers/clang-27/install/bin/clang-27 -O1 -/home/jason/compilers/clang-27/install/bin/clang-27 -O2 -/home/jason/compilers/clang-27/install/bin/clang-27 -O3 -/home/jason/compilers/clang-27/install/bin/clang-27 -Os -/home/jason/compilers/clang-28/install/bin/clang-28 -O0 -/home/jason/compilers/clang-28/install/bin/clang-28 -O1 -/home/jason/compilers/clang-28/install/bin/clang-28 -O2 -/home/jason/compilers/clang-28/install/bin/clang-28 -O3 -/home/jason/compilers/clang-28/install/bin/clang-28 -Os - -# compiler implementations (short format: if you set your pathes before testing) -# gcc -O0 -# gcc -O1 -# gcc -O2 -# gcc -O3 -# gcc -Os -# M$ compilers -# cl -Od -# cl -O1 -# cl -Ox diff --git a/utah/scripts/one_off/conf.pl b/utah/scripts/one_off/conf.pl deleted file mode 100755 index 8dd7e0f4d..000000000 --- a/utah/scripts/one_off/conf.pl +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/perl -w - -############################################################# - -use strict; -use warnings; - -############################################################# - -my $N = 10000; -my $PROB = 0.0001; - -my $REPS = 10000; - -############################################################# - -sub normal_approx ($$) { - (my $fail, my $n) = @_; - return 0.0 if ($fail==0); - my $phat = 1.0 * $fail / $n; - my $zc = 1.96; # 95% - my $plus_minus = $zc * sqrt (($phat*(1.0-$phat))/$n); - return ($phat-$plus_minus,$phat+$plus_minus); -} - -sub wilson_score ($$) { - (my $fail, my $n) = @_; - my $phat = 1.0 * $fail / $n; - my $zc = 1.96; # 95% - - my $term1 = - $phat + - ((1.0/(2.0*$n)) * ($zc * $zc)); - - my $term2 = - $zc * - sqrt ((($phat*(1.0-$phat))/$n) + - (($zc * $zc) / (4.0 * $n * $n)) - ); - - my $term3 = - 1.0 + - ((1.0/$n) * ($zc * $zc)); - - my $lo = ($term1 - $term2) / $term3; - my $hi = ($term1 + $term2) / $term3; - - return ($lo, $hi); -} - -############################################################# - -sub print_wilson ($$) { - (my $fail, my $n) = @_; - (my $lo, my $hi) = wilson_score ($fail, $n); - $lo *= 100; - $hi *= 100; - printf "%f .. %f for %d out of %d\n", $lo, $hi, $fail, $n; -} - -if (0) { - my $level = 1.0/1000000; - my $t = 1000; - my $c; - do { - $c = wilson_score (0, $t); - print "$t $c\n"; - $t += 1000; - } while ($c > $level); -} - -if (0) { - print_wilson (0, 1000); - print_wilson (0, 10000); - print_wilson (0, 100000); - print_wilson (0, 1000000); - exit 0; -} - -if (1) { - - for (my $zz=0; $zz<20; $zz++) { - - my $inside = 0; - my $rep; - - for ($rep = 0; $rep < $REPS; $rep++) { - - my $fail = 0; - - for (my $i=0; $i<$N; $i++) { - my $r = rand(); - if ($r < $PROB) { - $fail++; - } else { - } - } - my $rate = 1.0 * $fail / $N; - #(my $lo, my $hi) = normal_approx ($fail, $N); - (my $lo, my $hi) = wilson_score ($fail, $N); - #print "$fail / $N failures for internal $lo .. $hi "; - if ($PROB >= $lo && - $PROB <= $hi) { - $inside++; - #print ("inside!\n"); - } else { - #print ("outside!\n"); - } - } - - my $pct = 100.0 * $inside / $REPS; - - print "actual probability was inside the confidence interval $pct % of the time\n"; - } -} - -############################################################# - diff --git a/utah/scripts/one_off/create_result_table_for_journal_paper.pl b/utah/scripts/one_off/create_result_table_for_journal_paper.pl deleted file mode 100755 index dd9c719c5..000000000 --- a/utah/scripts/one_off/create_result_table_for_journal_paper.pl +++ /dev/null @@ -1,344 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -use warnings; - -##################################################################### - -# dump seeds for good programs into a separate file - -##################################################################### - -my $GOAL=100000; - -my $SIZE=0; - -my $WRAP=0; - -my $MIN=1e-5; - -##################################################################### - -my %vol_error = (); -my %csum_error = (); -my %crash_error = (); -my %size = (); -my %total = (); - -my %tmp_vol_error = (); -my %tmp_csum_error = (); -my %tmp_crash_error = (); -my %tmp_size = (); -my %tmp_total = (); - -my %compilers = (); - -my $n = 0; - -sub def1($) { - (my $x) = @_; - return $x if (defined($x)); - return 0; -} - -my $cur_prog; - -if (scalar(@ARGV)==0) { - die "no input files specified"; -} - -my @files = @ARGV; - -foreach my $fn (@files) { - print "$fn\n"; - open INF, "<$fn" or die; - while (my $line = ) { - - # print $line; - - # here we do not care about inconsistency across tools - next if ($line =~ /EXTERNAL/); - - if ($line =~ /RANDOM PROGRAM ([0-9]+) /) { - $cur_prog = $1; - %tmp_vol_error = (); - %tmp_csum_error = (); - %tmp_crash_error = (); - %tmp_size = (); - %tmp_total = (); - next; - } - my $useful = "COMPILER FAILED|VOLATILE FAILURE|CHECKSUM FAILURE|COMPLETED TEST"; - if ($line =~ /($useful) ([a-zA-Z0-9\-\.]+) WRAP=(0|1)/) { - my $status = $1; - my $compiler = $2; - my $wrap = $3; - - die if (!$WRAP && $wrap==1); - - $compilers{$compiler} = 1; - - if ($status =~ /VOLATILE/) { - die if (defined($tmp_vol_error{$wrap}{$compiler})); - $tmp_vol_error{$wrap}{$compiler} = 1; - $tmp_total{$wrap}{$compiler} = 1; - next; - } - if ($status =~ /COMPILER/) { - die if (defined($tmp_crash_error{$wrap}{$compiler})); - $tmp_crash_error{$wrap}{$compiler} = 1; - $tmp_total{$wrap}{$compiler} = 1; - next; - } - if ($status =~ /CHECKSUM/) { - die if (defined($tmp_csum_error{$wrap}{$compiler})); - $tmp_csum_error{$wrap}{$compiler} = 1; - $tmp_total{$wrap}{$compiler} = 1; - next; - } - if ($status =~ /COMPLETED/) { - $tmp_total{$wrap}{$compiler} = 1; - next; - } - die; - } - if ($line =~ /CODE SIZE ([a-zA-Z0-9\-\.]+) WRAP=(0|1) ([0-9]+)$/) { - my $compiler = $1; - my $wrap = $2; - my $size = $3; - die if (defined($tmp_size{$wrap}{$compiler})); - $tmp_size{$wrap}{$compiler} = $size; - next; - } - - my @wraps; - if ($WRAP) { - @wraps = (0,1); - } else { - @wraps = (0); - } - - if ($line =~ /GOOD PROGRAM/) { - foreach my $wrap (@wraps) { - foreach my $compiler (keys %{$tmp_total{$wrap}}) { - - if ($SIZE) { - my $s = $tmp_size{$wrap}{$compiler}; - die if (!defined($s)); - $size{$wrap}{$compiler} += $s; - } - - my $csum = def1($tmp_csum_error{$wrap}{$compiler}); - my $vol = def1($tmp_vol_error{$wrap}{$compiler}); - my $crash = def1($tmp_crash_error{$wrap}{$compiler}); - - $csum_error{$wrap}{$compiler} += $csum; - $vol_error{$wrap}{$compiler} += $vol; - $crash_error{$wrap}{$compiler} += $crash; - $total{$wrap}{$compiler}++; - } - } - - $n++; - last if ($n >= $GOAL); - - if (($n%1000)==0) { - my $k = $n/1000; - print "${k} K\n"; - } - - next; - } - - die if ($line =~ /RANDOM/); - die if ($line =~ /VOLATILE FAIL/); - die if ($line =~ /CHECKSUM FAIL/); - die if ($line =~ /COMPILER FAIL/); - die if ($line =~ /COMPLET/); - die if ($line =~ /CODE SIZE/); - } - close INF; - last if ($n >= $GOAL); -} - -if ($WRAP) { - print "compiler vol fail vol w/wrap change csum fail +size\n"; -} else { - print "compiler vol fail csum fail crash\n"; -} - -my $all_total; -my $t_vol_errs = 0; -my $t_vol_errs_w = 0; - -open VOL, ">volatile_errors.txt" or die; -open CSUM, ">checksum_errors.txt" or die; -open CRASH, ">crash_errors.txt" or die; - -my %version_map = - ("llvm-gcc-2.0" => "2.0", - "llvm-gcc-2.1" => "2.1", - "llvm-gcc-2.2" => "2.2", - "llvm-gcc-2.3" => "2.3", - "llvm-gcc-2.4" => "2.4", - ); - -sub by_version_map { - return $version_map{$a} <=> $version_map{$b}; -} - -# todo-- implement exact binomial test? or call out to R for this? - -sub wilson_score ($$) { - (my $fail, my $n) = @_; - my $phat = 1.0 * $fail / $n; - my $zc = 1.96; # 95% - - my $term1 = - $phat + - ((1.0/(2.0*$n)) * ($zc * $zc)); - - my $term2 = - $zc * - sqrt ((($phat*(1.0-$phat))/$n) + - (($zc * $zc) / (4.0 * $n * $n)) - ); - - my $term3 = - 1.0 + - ((1.0/$n) * ($zc * $zc)); - - my $lo = ($term1 - $term2) / $term3; - my $hi = ($term1 + $term2) / $term3; - - return ($lo, $hi); -} - -sub max ($$) { - (my $a, my $b) = @_; - return $a if ($a>$b); - return $b; -} - -foreach my $compiler (sort by_version_map keys %compilers) { - my $t = $total{0}{$compiler}; - - # print "$compiler $t\n"; - - if ($WRAP) { - die if ($t != $total{1}{$compiler}); - } - die if (defined($all_total) && ($t != $all_total)); - $all_total = $t; - - $t_vol_errs += $vol_error{0}{$compiler}; - if ($WRAP) { - $t_vol_errs_w += $vol_error{1}{$compiler}; - } - - my $vol_errors = $vol_error{0}{$compiler}; - my $vol_frac = 1.0 * $vol_errors / $t; - (my $vol_lower, my $vol_upper) = wilson_score ($vol_errors, $t); - - #print "volatile 95%: $vol_lower .. $vol_upper \n"; - - my $csum_errors = $csum_error{0}{$compiler}; - my $csum_frac = 1.0 * $csum_errors / $t; - (my $csum_lower, my $csum_upper) = wilson_score ($csum_errors, $t); - - #print "checksum 95%: $csum_lower .. $csum_upper \n"; - - my $crash_errors = $crash_error{0}{$compiler}; - my $crash_frac = 1.0 * $crash_errors / $t; - (my $crash_lower, my $crash_upper) = wilson_score ($crash_errors, $t); - - my $vol_frac_orig = $vol_frac; - my $csum_frac_orig = $csum_frac; - my $crash_frac_orig = $crash_frac; - - $vol_frac = max ($vol_frac, $MIN); - $csum_frac = max ($csum_frac, $MIN); - $crash_frac = max ($crash_frac, $MIN); - - $vol_lower = max ($vol_lower, $MIN); - $csum_lower = max ($csum_lower, $MIN); - $crash_lower = max ($crash_lower, $MIN); - - my $vol_pct = (100.0 * $vol_frac); - my $csum_pct = (100.0 * $csum_frac); - my $crash_pct = (100.0 * $crash_frac); - - my $vol_pct_orig = (100.0 * $vol_frac_orig); - my $csum_pct_orig = (100.0 * $csum_frac_orig); - my $crash_pct_orig = (100.0 * $crash_frac_orig); - - my $ver = $version_map{$compiler}; - - print VOL "$ver $vol_pct ".($vol_lower*100.0)." "; - print VOL (($vol_upper-$vol_lower)*100.0); - printf VOL " %.3g%%\n", $vol_pct_orig; - - print CSUM "$ver $csum_pct ".($csum_lower*100.0)." "; - print CSUM (($csum_upper-$csum_lower)*100.0); - printf CSUM " %.3g%%\n", $csum_pct_orig; - - print CRASH "$ver $crash_pct ".($crash_lower*100.0)." "; - print CRASH (($crash_upper-$crash_lower)*100.0); - printf CRASH " %.3g%%\n", $crash_pct_orig; - - my $sz; - if ($SIZE) { - $sz = 1.0 * $size{0}{$compiler} / $t; - } - - if ($WRAP) { - my $vol_pct_w = (100.0 * $vol_error{1}{$compiler} / $t)+0.00000000000001; - my $vol_change = 100.0 * (($vol_pct - $vol_pct_w) / $vol_pct); - - my $csum_pct_w = (100.0 * $csum_error{1}{$compiler} / $t)+0.00000000000001; - my $csum_change = 100.0 * (($csum_pct - $csum_pct_w) / $csum_pct); - - my $sz_w = 1.0 * $size{1}{$compiler} / $t; - my $inc = (100.0 * ($sz_w / $sz)) - 100.0; - -# format = -#@<<<<<<<<<<<<< & @###### & @###### & & @###### \\ -#$compiler, $vol_error{0}{$compiler}, $vol_error{1}{$compiler}, $csum_error{0}{$compiler} -#. -# write; - -# format = -#@<<<<<<<<<<<<< & @##.###\% & @##.###\% & @###\% & @##.#\% & @##.###\% \\ -#$compiler, $vol_pct, $vol_pct_w, $vol_change, $inc, $csum_pct -#. -# write; - - } else { - format = -@<<<<<<<<<<<<< @##.###% @>>>>>> @##.###% @>>>>>>> @##.###% @>>>>>> \\ -$compiler, $vol_pct, $vol_errors, $csum_pct, $csum_errors, $crash_pct, $crash_errors -. - write; - } -} - -close VOL; -close CSUM; -close CRASH; - -print "$all_total random programs were tested\n"; -#print "there were $t_vol_errs volatile errors\n"; -if ($WRAP) { - print "there were $t_vol_errs_w volatile errors in wrapped programs\n"; - my $inc = 100.0 * (($t_vol_errs - $t_vol_errs_w) / $t_vol_errs); - printf "%2.2f%% of errors were fixed using wrappers\n", $inc; -} - -system "gnuplot < llvm_graphs.gp"; - -foreach my $epsfile (sort glob "*.eps") { - system "epstopdf $epsfile"; - my $root = $epsfile; - ($root =~ s/\.eps$//g); - system "convert -trim -density 400x400 $root.pdf $root.png"; -} diff --git a/utah/scripts/one_off/extract_csum.pl b/utah/scripts/one_off/extract_csum.pl deleted file mode 100755 index e207dc7de..000000000 --- a/utah/scripts/one_off/extract_csum.pl +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/perl -w - -use strict; - -while (my $line = ) { - chomp $line; - if ($line =~ /r30:r31 = 0x([0-9a-fA-F]+)$/) { - my $csum = $1; - print "$csum\n"; - exit 0; - } -} - -exit 1; diff --git a/utah/scripts/one_off/find_args.pl b/utah/scripts/one_off/find_args.pl deleted file mode 100755 index 17bde6fd6..000000000 --- a/utah/scripts/one_off/find_args.pl +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/perl -w - -use strict; - -my %opts; - -while (my $line = ) { - my @l = split (" ", $line); - my $f = shift (@l); - - next if ($f ne "gcc"); - - my $i = 0; - my $bad = 0; - - while (1) { - last if ($i >= scalar (@l)); - my $opt = $l[$i]; - if ($opt =~ /\.S$/) { - $bad = 1; - $i = 1000000; - } elsif ($opt eq "-isystem" || - $opt eq "-o" || - $opt eq "-include") { - splice (@l, $i, 2); - } elsif ( - $opt eq "-pipe" || - $opt =~ /^\-D/ || - $opt =~ /^\-W/ || - $opt =~ /^\-I/ || - $opt eq "-nostdinc" || - $opt eq "-nostdlib" || - $opt eq "-ffreestanding" || - $opt eq "-fPIC" || - $opt =~ /\.c$/ || - $opt =~ /\.o$/ || - $opt eq "-c" - ) { - splice (@l, $i, 1); - } else { - $i++; - } - } - - if (!$bad) { - my @l2 = sort @l; - @l = @l2; - my $s = ""; - foreach my $opt (@l) { - $s .= "$opt "; - } - $opts{$s}++; - } -} - -sub bynum { - return $opts{$a} <=> $opts{$b}; -} - -foreach my $opt (sort bynum keys %opts) { - print "$opts{$opt} $opt\n"; -} diff --git a/utah/scripts/one_off/find_termination_bugs.pl b/utah/scripts/one_off/find_termination_bugs.pl deleted file mode 100755 index a178c668d..000000000 --- a/utah/scripts/one_off/find_termination_bugs.pl +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/perl -w - -use strict; - -my $num; -my $cur; -my %times; -my %csums; -my $n_terminate; -my $n_nonterminate; - -my $all_term = 0; -my $all_nonterm = 0; -my $mixed = 0; -my $n = 0; -my $repro; -my %outs; - -while (my $line = ) { - #print "$line"; - chomp $line; - if ($line =~ /\-\-\-\-\-\- RANDOM PROGRAM ([0-9]+) \-\-\-\-\-\-/) { - $num = $1; - %times = (); - %csums = (); - $n_terminate = 0; - $n_nonterminate = 0; - undef($cur); - undef($repro); - next; - } - if ($line =~ /regenerate/) { - $repro = $line; - } - if ($line =~ /^\[ia32\] (.*) : /) { - $cur = $1; - next; - } - if ($line =~ /^cpu time= ([0-9\.]+)$/) { - die $line if (!defined($cur)); - my $time = $1; - $times{$cur} = $time; - next; - } - if ($line =~ /^checksum = ([0-9a-zA-Z]+)$/) { - die if (!defined($cur)); - my $csum = $1; - $csums{$cur} = $csum; - if ($csum eq "TIMEOUT") { - $n_nonterminate++; - } else { - $n_terminate++; - } - next; - } - if ($line =~ /GOOD PROGRAM/) { - die if (!defined($cur)); - if ($n_terminate == 0) { - $all_nonterm++; - } elsif ($n_nonterminate == 0) { - $all_term++; - } else { - $mixed++; - my $out = ""; - $out .= "---------- program $n ----------\n"; - $out .= "$repro\n"; - my $max = 0; - my $min = 100000; - foreach my $k (sort keys %times) { - $out .= "$times{$k} $k $csums{$k}\n"; - my $t = $times{$k}; - if ($t > $max) { $max = $t; } - if ($t < $min) { $min = $t; } - } - if ($min<0.01) { $min = 0.01; } - my $ratio = $max/$min; - $out .= "ratio: $ratio\n"; - $out .= "\n"; - $outs{$ratio} = $out; - } - $n++; - } -} - -sub bynum { - return $a <=> $b; -} - -foreach my $k (sort bynum keys %outs) { - print $outs{$k}; -} - -print "\n"; -print "$n good tests\n"; -print "${all_nonterm} non-terminating, ${all_term} terminating, ${mixed} mixed\n"; - diff --git a/utah/scripts/one_off/make_progs.pl b/utah/scripts/one_off/make_progs.pl deleted file mode 100755 index f8be82a09..000000000 --- a/utah/scripts/one_off/make_progs.pl +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -use File::stat; - -sub runit ($) { - my $cmd = shift; - my $res = (system "$cmd"); - my $exit_value = $? >> 8; - return $exit_value; -} - -my $n=0; -while (1) { - last if ($n == 25); - my $fn = sprintf "output/prog_%02d.c", $n; - print "$fn\n"; - runit ("../src/csmith > $fn"); - next if (!(-e $fn)); - my $filesize = stat($fn)->size; - next if ($filesize < 15000 || - $filesize > 100000); - $n++; -} diff --git a/utah/scripts/one_off/nonterm.pl b/utah/scripts/one_off/nonterm.pl deleted file mode 100755 index 2bf673955..000000000 --- a/utah/scripts/one_off/nonterm.pl +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/perl -w -## -## Copyright (c) 2011 The University of Utah -## All rights reserved. -## -## This file is part of `csmith', a random generator of C programs. -## -## Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are met: -## -## * Redistributions of source code must retain the above copyright notice, -## this list of conditions and the following disclaimer. -## -## * Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in the -## documentation and/or other materials provided with the distribution. -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -## ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -## LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -## POSSIBILITY OF SUCH DAMAGE. - -use strict; - -if (rand()<0.5) { - while (1) { sleep (10000); } -} else { - while (1) { } -} diff --git a/utah/scripts/one_off/normalize.pl b/utah/scripts/one_off/normalize.pl deleted file mode 100755 index 139b5077a..000000000 --- a/utah/scripts/one_off/normalize.pl +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/perl -w - -use strict; - -my $f = $ARGV[0]; -die if (!(-f $f)); - -my $s=""; - -open INF, "<$f" or die; -while () { - $s .= $_; -} -close INF; -system "mv $f ${f}.bak"; - -$s =~ s/safe_add_func_int8_t_s_s/foo/g; -$s =~ s/safe_add_func_uint8_t_u_u/bux/g; -$s =~ s/safe_rshift_func_int8_t_s_s/bar/g; -$s =~ s/safe_mod_func_int64_t_s_s/baz/g; -$s =~ s/safe_lshift_func_uint16_t_u_s/biz/g; - -$s =~ s/typedef signed char int8_t;//; -$s =~ s/typedef unsigned char uint8_t;//; -$s =~ s/typedef short int int16_t;//; -$s =~ s/typedef unsigned short int uint16_t;//; -$s =~ s/typedef int int32_t;//; -$s =~ s/typedef unsigned int uint32_t;//; -$s =~ s/__extension__ typedef long long int int64_t;//; -$s =~ s/__extension__ typedef unsigned long long int uint64_t;//; - -$s =~ s/uint8_t/unsigned char/g; -$s =~ s/uint16_t/unsigned short/g; -$s =~ s/uint32_t/unsigned/g; -$s =~ s/uint64_t/unsigned long long/g; - -$s =~ s/int8_t/signed char/g; -$s =~ s/int16_t/short/g; -$s =~ s/int32_t/int/g; -$s =~ s/int64_t/long long/g; - -open OUTF, ">$f" or die; -print OUTF $s; -close OUTF; diff --git a/utah/scripts/one_off/quest_test.pl b/utah/scripts/one_off/quest_test.pl deleted file mode 100755 index 99f02565b..000000000 --- a/utah/scripts/one_off/quest_test.pl +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/perl -w - -use strict; - -my $DIR = $ARGV[0]; - -die if (!defined($DIR)); - -sub runit ($) { - my $cmd = shift; - - if ((system "$cmd") != 0) { - print "system '$cmd' failed: $?"; - return -1; - } - - my $exit_value = $? >> 8; - return $exit_value; -} - -my @gcc_opts = ("-O0", - "-O1", - "-O2", - "-O3", - "-Os"); - -my @no_opts = (""); - -my @llvm = ("llvm-gcc", \@gcc_opts); -my @gcc = ("current-gcc", \@gcc_opts); -my @clang1 = ("clang-driver-opt", \@no_opts); -my @clang2 = ("clang-driver-noopt", \@no_opts); - -my @ccs = (\@llvm, \@gcc, \@clang1, \@clang2); - -my $n = 0; -while (1) { - print "$n\n"; - $n++; - system "rm -f prog"; - system "quest -n 200 -s 3 > $DIR/prog_$n.c"; - foreach my $ccref (@ccs) { - (my $cc, my $optref) = @{$ccref}; - my @opts = @{$optref}; - foreach my $opt (@opts) { - my $compile = "$cc $DIR/prog_$n.c -o $DIR/prog $opt"; - print "$compile : "; - my $res1 = runit ("$compile > /dev/null 2>&1"); - if ($res1==0) { - my $res2 = runit ("$DIR/prog"); - if ($res2==0) { - print "TEST GOOD\n"; - } else { - print "TEST FAIL\n"; - } - } else { - print "COMPILER FAIL\n"; - } - } - } - system "bzip2 -9qf $DIR/prog_$n.c"; -} diff --git a/utah/scripts/one_off/random_test_vc.pl b/utah/scripts/one_off/random_test_vc.pl deleted file mode 100755 index a1a1b2543..000000000 --- a/utah/scripts/one_off/random_test_vc.pl +++ /dev/null @@ -1,207 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -use File::stat; -################################################################## -my $MIN_PROGRAM_SIZE = 10000; -my $CSMITH_TIMEOUT = 90; -my $COMPILER_TIMEOUT = 10; -my $PROG_TIMEOUT = 5; - -my $XTRA = "--no-paranoid "; -my $BF = " --bitfields ia32"; -my $PACK = "--packed-struct"; -my $QUIET = "--quiet"; -my $platform = "x86"; - -################################################################## -my $CSMITH_HOME = $ENV{"CSMITH_HOME"}; -my $good = 0; -my $bug = 0; -my @COMPILERS = ( - "cl -Od", - "cl -O1", - "cl -O2", - "cl -Og", - "cl -Oi", - "cl -Os", - "cl -Ot", - "cl -Ox", - "cl -Oy", -); -my $HEADER = "-I$CSMITH_HOME/runtime"; - -sub read_value_from_file($$) { - my ($fn, $match) = @_; - open INF, "<$fn" or die; - while (my $line = ) { - chomp $line; - if ($line =~ /$match/) { - close INF; - return $1; - } - } - close INF; - return ""; -} - - -# properly parse the return value from system() -sub runit ($$$) { - my ($cmd, $timeout, $out) = @_; - # print "before running $cmd\n"; - my $res = system "timeout $timeout $cmd &> $out"; - my $success = 0; - if ($? == -1) { - print "can't execute $cmd\n"; - } - elsif ($? & 127) { - print "died while executing $cmd\n"; - } - else { - $success = 1; - } - my $exit_value = $? >> 8; - if ($exit_value == 124) { - print "hangs while executing $cmd\n"; - $success = 0; - } - return ($success, $exit_value); -} - -# compile a program and execute -# return 0: normal; 1: compiler crashed; 2: compiler hang; 3: executable crashed; 4: executable hang -sub compile_and_run($$$$) { - my ($compiler, $src_file, $exe, $out) = @_; - my $command = "$compiler $src_file $HEADER -o $exe"; - # print "$command\n"; - my ($res, $exit_value) = runit($command, $COMPILER_TIMEOUT, "compiler.out"); - # print "after run compiler: $res, $exit_value\n"; - if (($res == 0) || (!(-e $exe))) { - return ($exit_value == 124 ? 2 : 1); # exit code 124 means time out, see timeout.sh - } - ($res, $exit_value) = runit("./$exe", $PROG_TIMEOUT, $out); - # print "after run program: $res, $exit_value\n"; - if (($res == 0) || (!(-e $out))) { - return ($exit_value == 124 ? 4 : 3); # exit code 124 means time out, see timeout.sh - } - return 0; -} - -sub evaluate_program ($) { - my ($test_file) = @_; - my $checksum = ""; - my $i = 0; - foreach my $compiler (@COMPILERS) { - my $out = "out$i.log"; - my $exe = "a$i.exe"; - $i++; - my $res = compile_and_run($compiler, $test_file, $exe, $out); - open INF, "ps axu |" or die; - while () { - if (/\/sh/) { - system "ps axu"; - exit; - } - } - close INF; - - if ($res) { - if ($res == 1 || $res == 2) { - print "compiler error! Can't compile $test_file with $compiler\n"; - return 1; - } - if ($res == 3) { - print "random program crashed!\n"; - return 1; - } - print "random program hangs!\n"; - return -1; # program hangs, not interesting - } - else { - my $sum = read_value_from_file($out, "checksum = (.*)"); - if ($sum ne $checksum && $checksum ne "") { - print "find checksum difference!\n"; - return 1; - } - $checksum = $sum; - } - } - return 0; -} - -sub test_one ($$) { - (my $n, my $work) = @_; - print "------ RANDOM PROGRAM $n ------\n"; - if (($n%100)==0) { - print "timestamp: "; - system "date"; - } - my $nstr = sprintf "%06d", $n; - my $dir = "${work}/$nstr"; - - system "mkdir $dir"; - chdir $dir; - - my $fn = "rand$nstr"; - my $cfile = "${fn}.c"; - - # run Csmith - my $cmd = "$CSMITH_HOME/src/csmith $BF $PACK $XTRA --output $cfile"; - my ($res, $exitcode) = runit($cmd, $CSMITH_TIMEOUT, "csmith.out"); - # print "after run csmith: $res, $exitcode\n"; - - if ($res == 0 || !(-e "$cfile")) { - print "CSMITH FAILED\n"; - system "cat csmith.out"; - chdir "../"; - system "rm -rf $dir"; - return; - } - - my $filesize = stat("$cfile")->size; - print "$cfile is $filesize bytes\n"; - if (($filesize < $MIN_PROGRAM_SIZE)) { - print "FILE TOO SMALL\n"; - chdir "../"; - system "rm -rf $dir"; - return; - } - - my $seed = read_value_from_file($cfile, "Seed:\\s+([0-9]+)"); - die if (!$seed); - - # test if the random program is interesting - my $ret = evaluate_program($cfile); - chdir "../"; - - if ($ret == 0 || $ret == 1) { - print "GOOD PROGRAM: number $good\n"; - $good++; - if ($ret == 1) { - print "FAILURE-INDUCING PROGRAM: number $bug\n"; - $bug++; - } - } else { - print "BAD PROGRAM: doesn't count towards goal.\n"; - } -} - -########################### main ################################## -if (scalar(@ARGV) != 2) { - print "usage: random_test_msvc.pl work_dir testcase_cnt (0 for unlimited)\n"; - exit -1; -} -my $work = $ARGV[0]; -my $cnt = $ARGV[1]; -if (!(-d $work)) { - die "error: create work dir '$work' first"; -} -my $i = 0; -while ($cnt <=0 || $i < $cnt) { - test_one ($i, $work); - $i++; - print "\n"; -} -print "total errors found: $bug\n"; -################################################################## diff --git a/utah/scripts/one_off/reducer_driver.pl b/utah/scripts/one_off/reducer_driver.pl deleted file mode 100755 index 81028fe75..000000000 --- a/utah/scripts/one_off/reducer_driver.pl +++ /dev/null @@ -1,315 +0,0 @@ -#!/usr/bin/perl -w -use strict; -use Net::Domain qw(hostname hostfqdn hostdomain); -use Cwd; - -my $CSMITH_HOME = $ENV{"CSMITH_HOME"}; -die "please set CSMITH_HOME env first!" - if (!defined($CSMITH_HOME)); - -my $VOLATILE = $ENV{"VOLATILE_HOME"}; -die "please set VOLATILE_HOME env first!" - if (!defined($VOLATILE)); - -$ENV{"PATH"} = "$ENV{VOLATILE_HOME}:$ENV{PATH}"; - -my $host = hostname(); -my $TEST_ROOT = "$CSMITH_HOME/reducer"; -if (@ARGV != 1 && @ARGV != 2 && @ARGV != 3) { - die "usage: reducer_driver.pl [test-root-dir] [eager-blind-simple-berkeley]\n\n"; -} -my $RESULT_FILE = $ARGV[0]; -if (@ARGV >= 2) { - $TEST_ROOT = $ARGV[1]; - if ($TEST_ROOT eq ".") { - $TEST_ROOT = cwd(); - } -} - -my $do_eager = 1; -my $do_blind = 1; -my $do_simple = 1; -my $do_berkeley = 1; -if (@ARGV == 3) { - $ARGV[2] =~ /(\d)-(\d)-(\d)-(\d)/; - $do_eager = $1; - $do_blind = $2; - $do_simple = $3; - $do_berkeley = $4; -} - -sub get_reduce_cmd() { - open INF, "./runme" or die; - my $cmd = ; - chomp $cmd; - close INF; - return $cmd; -} - -sub prepare_berkeley($) { - my ($seed) = @_; - my $cmd = get_reduce_cmd(); - my @a = split("[\'\"]", $cmd); - if (@a < 4) { - print "wrong cmd: $cmd\n"; - return 0; - } - my $OPT = ""; - if (@a == 6) { - $OPT = $a[5]; - print "OPT = $OPT\n"; - } - my @b = split(" ", $a[1]); - my @c = split(" ", $a[3]); - if (@b < 2 || @c < 2) { - print "wrong cmd: $cmd\n"; - return 0; - } - my $compiler1 = $b[0]; - my $compiler2 = $c[0]; - # print "compiler is $compiler\n"; - my $sed_cmd = "sed s#CC1=llvm-gcc#CC1=$compiler1# < $VOLATILE/bug_tests/test-wrong-code.sh > t1.sh"; - # print "sed cmd = $sed_cmd\n"; - system $sed_cmd; - $sed_cmd = "sed s#CC2=llvm-gcc#CC2=$compiler2# < t1.sh > t2.sh"; - system $sed_cmd; - $sed_cmd = "sed s#OPT1=-O0#OPT1=$b[1]# < t2.sh > t3.sh"; - system $sed_cmd; - $sed_cmd = "sed s#OPT2=-Os#OPT2=$c[1]# < t3.sh > test1.sh"; - system $sed_cmd; - system "chmod 755 test1.sh"; - - system "rm -f t1.sh t2.sh t3.sh"; - if (!(-e "pre_reduction.c") || !(-s "pre_reduction.c")) { - my $csmith_cmd = "$CSMITH_HOME/src/csmith --concise -s $seed $OPT > pre_reduction.c"; - system $csmith_cmd; - } - return 1; -} - -# find the reduction rate from the log file -sub read_reduction_rate($) { - my ($input) = @_; - if (open INF, "<$input") { - while (my $line = ) { - if ($line =~ /reduction rate: ([\d\.]+) ===/) { - close INF; - my $rate = sprintf("%.2f", $1); - # print "rate = $1\n"; - return $rate; - } - } - close INF; - } - return -1; -} - -sub find_or_calc_rate($$) { - my ($method, $seed) = @_; - my $rate = read_reduction_rate("$method.log"); - if ($rate == -1 && (-e "pre_reduction.c") && (-e "$method$seed.c")) { - my $fsize1 = -s "pre_reduction.c"; - my $fsize2 = -s "$method$seed.c"; - # print "using $method$seed.c size: $fsize2\n"; - my $rate0 = (1 - ($fsize2 / $fsize1)) * 100; - $rate = sprintf("%.2f", $rate0); - } - return $rate; -} - -sub reduce_testcase($$$) { - my ($dir, $rates, $times) = @_; - print "work in $dir\n"; - chdir($dir) or die "$!"; - my $cmd0 = get_reduce_cmd(); - my @a = split(" ", $cmd0); - my $seed = $a[1]; - - if ($do_eager) { - system ("rm -f eager.log"); - my $stime = time(); - system ("./runme > eager.log 2>&1"); - my $time_usage = time() - $stime; - my $rate = read_reduction_rate("eager.log"); - push @$rates, $rate; - push @$times, $time_usage; - system ("rm -f *out* *small* after* works.c"); - } else { - push @$rates, find_or_calc_rate("eager", $seed); - push @$times, 0; - } - if ($do_blind) { - my $cmd = $cmd0; - $cmd =~ s/eager/blind_eager/g; - system ("rm -f blind.log"); - my $stime = time(); - system ("$cmd > blind.log 2>&1"); - my $time_usage = time() - $stime; - - my $rate = read_reduction_rate("blind.log"); - push @$rates, $rate; - push @$times, $time_usage; - system ("rm -f *out* *small* after* works.c"); - } else { - push @$rates, find_or_calc_rate("blind", $seed); - push @$times, 0; - } - my $bok = 0; - if ($do_berkeley) { - if (prepare_berkeley($seed)) { - system "cp pre_reduction.c small.c"; - my $stime = time(); - system "godelta > berkeley.log 2>&1"; - my $time_usage = time() - $stime; - - # make sure the reduction is good - my $res = system "./test1.sh >/dev/null"; - $res = $res >> 8; - if (!$res) { - my $fsize1 = -s "pre_reduction.c"; - my $fsize2 = -s "small.c"; - my $rate0 = (1 - ($fsize2 / $fsize1)) * 100; - $bok = 1; - my $rate = sprintf("%.2f", $rate0); - system "cp small.c berkeley$seed.c"; - push @$rates, $rate; - push @$times, $time_usage; - } - system "rm -f *small* *out* gcc* log multi*"; - } - } - if (!$bok) { - push @$rates, find_or_calc_rate("berkeley", $seed); - push @$times, 0; - } - if ($do_simple) { - my $cmd = $cmd0; - $cmd =~ s/eager/simple/g; - system ("rm -f simple.log"); - my $stime = time(); - system ("$cmd > simple.log 2>&1"); - my $time_usage = time() - $stime; - - my $rate = read_reduction_rate("simple.log"); - push @$rates, $rate; - push @$times, $time_usage; - system ("rm -f *out* *small* works.c"); - } else { - push @$rates, find_or_calc_rate("simple", $seed); - push @$times, 0; - } - - my $revision = "unknown"; - if ($cmd0 =~ /r(\d+)-/) { - $revision = $1; - } - # find the name of the compiler - if ($cmd0 =~ /clang /) { - return ("clang", $revision, $seed); - } - elsif ($cmd0 =~ /gcc /) { - return ("gcc", $revision, $seed); - } - else { - return ("unknown", $revision, $seed); - } -} - -##################################################################### -# loop through the test directories under $CSMITH_HOME/reducer, and -# run various kinds of reduction on the test cases, the results are -# written into $RESULT_FILE -##################################################################### -sub create_log() { - my $rate_results_in_latex = ""; - my $time_results_in_latex = ""; - - my $total_rate0 = 1; - my $total_rate1 = 1; - my $total_rate2 = 1; - my $total_rate3 = 1; - my $test_cnt0 = 0; - my $test_cnt1 = 0; - my $test_cnt2 = 0; - my $test_cnt3 = 0; - - system "rm -f $TEST_ROOT/$RESULT_FILE"; - for my $dir (glob("$TEST_ROOT/test*")) { - my @rates = (); - my @times = (); - # only check test cases for 64-bit for now - if ($dir =~ /x86/) { - next; - } - my ($compiler, $revision, $seed) = reduce_testcase($dir, \@rates, \@times); - $dir =~ /test(\d+)/; - my $id = $1; - my $platform = "x86-64"; - - $rate_results_in_latex = "$id & $seed & $platform & $compiler & & $rates[0] & $rates[1] & $rates[3] & $rates[2]"; - $time_results_in_latex = "$id & $seed & $platform & $compiler & & $times[0] & $times[1] & $times[3] & $times[2]"; - print "rates: $rate_results_in_latex\n"; - print "times: $time_results_in_latex\n"; - - # write to file - open OUT, ">>../$RESULT_FILE" or die; - print OUT "$rate_results_in_latex\n"; - print OUT "$time_results_in_latex\n"; - close OUT; - - # statistical: use geometric mean - if ($rates[0] != -1) { - $total_rate0 *= $rates[0]/100.0; - $test_cnt0++; - } - if ($rates[1] != -1) { - $total_rate1 *= $rates[1]/100.0; - $test_cnt1++; - } - if ($rates[2] != -1) { - $total_rate2 *= $rates[2]/100.0; - $test_cnt2++; - } - if ($rates[3] != -1) { - $total_rate3 *= $rates[3]/100.0; - $test_cnt3++; - } - } - - # calculate averages - my $avg_rate0 = sprintf("%.2f", ($total_rate0 ** (1.0 / $test_cnt0)) *100.0); - my $avg_rate1 = sprintf("%.2f", ($total_rate1 ** (1.0 / $test_cnt1)) *100.0); - my $avg_rate2 = sprintf("%.2f", ($total_rate2 ** (1.0 / $test_cnt2)) *100.0); - my $avg_rate3 = sprintf("%.2f", ($total_rate3 ** (1.0 / $test_cnt3)) *100.0); - $rate_results_in_latex = "average & N/A & N/A & N/A & & $avg_rate0 & $avg_rate1 & $avg_rate3 & $avg_rate2"; - print "average rates: $avg_rate0 $avg_rate1 $avg_rate3 $avg_rate2\n"; - chdir("..") or die "$!"; - open OUT, ">>$RESULT_FILE" or die; - print OUT "$rate_results_in_latex\n"; - close OUT; -} - -################### main ################################## -create_log(); -# convert log file into tex file -if (-e "$RESULT_FILE") { - open OUT, ">table.tex" or die; - open INF, "<$RESULT_FILE" or die; - print OUT '\documentclass[english]{article}', "\n"; - print OUT '\begin{document}', "\n"; - print OUT '\begin{table}\small', "\n"; - print OUT '\caption{Performance of reduction techniques}', "\n"; - print OUT '\begin{tabular}{| c | c | c | c | c | c | c | c | c |}', "\n"; - print OUT '\hline', "\n"; - print OUT 'id & seed & platform & compiler & manual & eager & blind & simple & berkeley \\\\', "\n"; - while (my $line = ) { - print OUT $line, ' \\\\', "\n"; - $line = ; - } - print OUT '\end{tabular}', "\n"; - print OUT '\end{table}', "\n"; - print OUT '\end{document}', "\n"; - close OUT; - close INF; -} - diff --git a/utah/scripts/one_off/run_tests.pl b/utah/scripts/one_off/run_tests.pl deleted file mode 100755 index 0489d2c95..000000000 --- a/utah/scripts/one_off/run_tests.pl +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -use File::stat; - -my $N = 1000000; - -my $MIN_SIZE = 10000; - -my $VALGRIND = ""; -# my $VALGRIND = "valgrind -q"; - -sub runit ($) { - my $cmd = shift; - my $res = (system "$cmd"); - my $exit_value = $? >> 8; - return $exit_value; -} - -my $n = 0; - -my %totals = (); -my %counts = (); -my %max = (); -my %max_seed = (); -my $x=0; - -while (1) { - my $seed = int(rand(4000000000)); - #my $seed = $x++; - my $res = runit ("$VALGRIND ../src/csmith -s $seed --bitfields ia32 --packed-struct -o foo.c 2>>errs.txt"); - if ($res == 0) { - if (stat("foo.c")->size >= $MIN_SIZE) { - open INF, ") { - if ($line =~ /^XXX (.*): ([+-]?(\d+\.\d+|\d+\.|\.\d+|\d+)([eE][+-]?\d+)?)$/) { - my $stat = $1; - my $num = $2; - $counts{$stat}++; - if (!defined($max{$stat})) { - $max{$stat} = $num; - } else { - if ($num > $max{$stat}) { - $max{$stat} = $num; - $max_seed{$stat} = $seed; - } - } - $totals{$stat} += $num; - next; - } - die "oops bad stats line '$line'" if ($line =~ /XXX/); - } - if ($n%10000==0) { - print "$n\n"; - } - $n++; - last if ($n == $N); - } - } else { - print "failed for seed $seed\n"; - } -} - -foreach my $k (sort keys %totals) { - my $count = $counts{$k}; - my $avg = sprintf "%.2f", $totals{$k} / $count; - my $max = sprintf "%.2f", $max{$k}; - my $s = $max_seed{$k}; - print "$k\n"; - print " occurred $count times, max value= $max, max seed = $s, average value= $avg\n"; -} diff --git a/utah/scripts/one_off/runit_test.pl b/utah/scripts/one_off/runit_test.pl deleted file mode 100755 index c0c78c39f..000000000 --- a/utah/scripts/one_off/runit_test.pl +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/perl -w - -## No license, we won't release this file. - -############################################################################### - -use strict; -use File::stat; -use File::Temp; -use Cwd; - -# 0 : success -# 1 : timeout -# 2 : ... -sub runit ($$$) { - my ($command, $timeout, $out) = @_; - - print "\n\ntimeout is $timeout\n"; - - my $res; - eval { - local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required - alarm $timeout; - system "$command"; - alarm 0; - $res = $?; - }; - - my $success = 0; - my $exit_value; - - if ($@ eq "alarm\n") { - print "'$command' timed out after $timeout second(s)\n"; - $exit_value = -1; - goto out; - } - - if ($res & 127) { - print "died while executing '$command'\n"; - goto out; - } - - if ($res == -1) { - print "can't execute '$command'\n"; - goto out; - } - - $success = 1; - $exit_value = $res >> 8; - - out: - print "command '$command' has success = $success, exit value = $exit_value\n"; - return ($success, $exit_value); -} - -if (1) { - while (1) { - runit ("./nonterm.pl", 1+int(rand(3)), ""); - } -} else { - runit ("sleep 5", 1, "/dev/null"); - runit ("sleep 1", 5, "/dev/null"); - runit ("gleep 1", 5, "/dev/null"); -} diff --git a/utah/scripts/one_off/select_writes.pl b/utah/scripts/one_off/select_writes.pl deleted file mode 100755 index e5fddb459..000000000 --- a/utah/scripts/one_off/select_writes.pl +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/perl -w - -use strict; - -while () { - if (/ ([0-9]+ writes)/) { - print "$1\n"; - } -} -exit 0; diff --git a/utah/scripts/one_off/simd.pl b/utah/scripts/one_off/simd.pl deleted file mode 100755 index 8939e4ab2..000000000 --- a/utah/scripts/one_off/simd.pl +++ /dev/null @@ -1,132 +0,0 @@ -#!/usr/bin/perl -w -use strict; -use File::stat; - -####################################################################### - -my $MIN_PROGRAM_SIZE = 8000; -my $EXTRA_OPTIONS = ""; -my $CSMITH_HOME = $ENV{"CSMITH_HOME"}; -my $COMPILER = "icc -w"; - -####################################################################### - -my $HEADER = "-I${CSMITH_HOME}/runtime"; - -# find lines in a file that match a given pattern, return line# in the file -sub match_in_file($$\@) { - my ($fn, $match, $matched) = @_; - open INF, "<$fn" or die "Can't open $fn\n"; - my $cnt = 0; - while (my $line = ) { - chomp $line; - if ($line =~ /$match/) { - push @$matched, $line; - } - $cnt++; - } - close INF; - return $cnt; -} - -# properly parse the return value from system() -sub runit ($$) { - my ($cmd, $out) = @_; - print "before running $cmd\n"; - my $res = system "$cmd"; - my $exit_value = $? >> 8; - $exit_value = $? & 127 if ($? & 127); - return $exit_value; -} - -sub yesno ($) { - (my $opt) = @_; - if (rand()<0.5) { - return " --$opt "; - } else { - return " --no-$opt "; - } -} - -sub run_tests ($) { - (my $n_tests) = @_; - - my $accum_percentage = 0; - my $n_good = 0; - my $n_simd = 0; - my $cfile = "test.c"; - my $ofile = "test.exe"; - while ($n_tests == -1 || $n_good < $n_tests) { - system "rm -f $cfile"; - - my $CSMITH_OPTIONS = ""; - if (rand()<0.5) { $CSMITH_OPTIONS .= " --quiet "; } - #$CSMITH_OPTIONS .= yesno ("math64"); - $CSMITH_OPTIONS .= yesno ("paranoid"); - $CSMITH_OPTIONS .= yesno ("longlong"); - $CSMITH_OPTIONS .= yesno ("pointers"); - $CSMITH_OPTIONS .= yesno ("arrays"); - $CSMITH_OPTIONS .= yesno ("jumps"); - $CSMITH_OPTIONS .= yesno ("consts"); - $CSMITH_OPTIONS .= yesno ("volatiles"); - #$CSMITH_OPTIONS .= yesno ("volatile-pointers"); - $CSMITH_OPTIONS .= yesno ("checksum"); - $CSMITH_OPTIONS .= yesno ("divs"); - $CSMITH_OPTIONS .= yesno ("muls"); - - my $cmd = "$CSMITH_HOME/src/csmith $CSMITH_OPTIONS $EXTRA_OPTIONS --output $cfile"; - my $res = runit ($cmd, "csmith.out"); - if ($res != 0 || !(-f $cfile) ) { - print "Failed to generate program: $cmd\n"; - exit (-1); - } - my $filesize = stat($cfile)->size; - if ($filesize < $MIN_PROGRAM_SIZE) { - next; - } - system "grep Seed $cfile"; - system "ls -l $cfile"; - system "rm -f $ofile"; - - # these flags works for gcc and icc - my $cmd2 = "$COMPILER $cfile $HEADER -O3 -mssse3 -S -o $ofile"; - $res = runit ($cmd2, "csmith.out"); - if ($res!=0 || !(-f $ofile)) { - print "Failed to compile program generated by $cmd\n"; - #exit (-1); - } - - my @simd_instructions; - # look for simd instructions (integer operations only) such as padd[x], psub[x], etc, but not including pxor, - # which is commonly used to create a bunch of zeros. - # Also use line number as the approximation of the instruction number - my $instr_cnt = match_in_file($ofile, "^(\\s+p[a-s][a-z]+.*%xmm)", @simd_instructions); - if (scalar @simd_instructions) { - my $percentage = @simd_instructions / $instr_cnt * 100; - print "found SIMD instruction: $simd_instructions[0], simd accounts for $percentage% of total instruction\n"; - $accum_percentage += $percentage; - $n_simd++; - } - $n_good++; - print "test case $n_good\n"; - } - my $avg_percentage = $accum_percentage / $n_good; - print "average SIMD percentage: $avg_percentage ($n_simd out of $n_good programs)\n"; -} - -########################### main ################################## - -if (!(-f "$CSMITH_HOME/runtime/csmith.h")) { - print "Please point the environment variable CSMITH_HOME to the top-level\n"; - print "directory of your Csmith tree before running this script."; - exit(-1); -} - -my $cnt = $ARGV[0]; -$cnt = -1 if (!defined($cnt)); -$EXTRA_OPTIONS = $ARGV[1] if (@ARGV==2); -print "extra = $EXTRA_OPTIONS\n"; -run_tests ($cnt); - - -################################################################## diff --git a/utah/scripts/one_off/size_hist.pl b/utah/scripts/one_off/size_hist.pl deleted file mode 100755 index e448909fc..000000000 --- a/utah/scripts/one_off/size_hist.pl +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -my $BUCKET_SIZE = 100; - -my %hist; -my $max = 0; -my %sizes; -my $reg; - -while (my $line = ) { - - chomp $line; - - if ($line =~ /regenerate with/) { - $reg = $line; - } - - if ($line =~ /RANDOM PROGRAM/) { - my $s1 = $sizes{"clang"}; - my $s2 = $sizes{"current-gcc"}; - next if (!defined($s1) || - !defined($s2)); - - # $ratio = (0.0+$s1)/$s2; - - # print "$ratio $s1 $s2 $reg\n"; - - print "$s1 $s2\n"; - - %sizes = (); - $reg = ""; - next; - } - - if ($line =~ /CODE SIZE (.+) WRAP=[01] ([0-9]+)$/) { - my $compiler = $1; - my $size = $2+0.0; - my $bucket = int($size/$BUCKET_SIZE); - $hist{$compiler}{$bucket}++; - if ($bucket > $max) { - $max = $bucket; - } - $sizes{$compiler} = $size; - next; - } - -} - -exit; - -foreach my $compiler (sort keys %hist) { - open OUTF, ">$compiler.txt" or die; - for (my $i=0; $i<$max; $i++) { - my $x = $i*$BUCKET_SIZE; - my $y = $hist{$compiler}{$i}; - if (!defined($y)) { - $y = 0; - } - print OUTF "$x $y\n"; - } - close OUTF; -} diff --git a/utah/scripts/one_off/size_test.pl b/utah/scripts/one_off/size_test.pl deleted file mode 100755 index 683cba02c..000000000 --- a/utah/scripts/one_off/size_test.pl +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -use File::stat; - -my $CSMITH = $ENV{"CSMITH_HOME"}."/src/csmith"; - -my $N = 1000; - -for (my $funcs = 1; $funcs < 100; $funcs++) { - my $total = 0.0; - my $block = 1 + int ($funcs / 10); - for (my $n=0; $n<$N; $n++) { - system "rm -f foo.c"; - system "$CSMITH --max-funcs $funcs --max-block-size $block --concise > foo.c"; - if (-f "foo.c") { - $total += stat("foo.c")->size; - } else { - $n--; - } - } - my $avg = $total / $N; - print "$funcs $block $avg\n"; -} diff --git a/utah/scripts/one_off/small_seeds.pl b/utah/scripts/one_off/small_seeds.pl deleted file mode 100755 index 718608cff..000000000 --- a/utah/scripts/one_off/small_seeds.pl +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/perl -w - -use strict; - -my $seed; -my $size; -my %crash; -my %wrong; - -while (my $line = ) { - if ($line =~ /RANDOM PROGRAM/) { - undef ($seed); - next; - } - if ($line =~ /seed = ([0-9]+)$/) { - $seed = $1; - next; - } - if ($line =~ /is ([0-9]+) bytes/) { - $size = $1; - next; - } - if ($line =~ /COMPILER FAILED gcc/) { - die if (!defined($seed)); - die if (!defined($size)); - $crash{$seed} = $size; - } - if ($line =~ /CHECKSUM FAIL/) { - die if (!defined($seed)); - die if (!defined($size)); - $wrong{$seed} = $size; - } -} - -sub bysize1 { - return $wrong{$a} <=> $wrong{$b}; -} - -sub bysize2 { - return $crash{$a} <=> $crash{$b}; -} - -print "wrong code:\n"; - -foreach my $s (sort bysize1 keys %wrong) { - print " seed= $s size= $wrong{$s}\n"; -} - -print "crash:\n"; - -foreach my $s (sort bysize2 keys %crash) { - print " seed= $s size= $crash{$s}\n"; -} diff --git a/utah/scripts/one_off/test_clang.pl b/utah/scripts/one_off/test_clang.pl deleted file mode 100755 index 53bd694c1..000000000 --- a/utah/scripts/one_off/test_clang.pl +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/perl -w - -use strict; - -sub runit ($) { - my $cmd = shift; - my $res = (system "$cmd"); - my $exit_value = $? >> 8; - return $exit_value; -} - -my $n = 0; - -my %totals = (); -my %counts = (); -my %all_out; - -while (1) { - my $seed = int(rand(4000000000)); - my $res = runit ("../src/csmith -s $seed > foo.c"); - my @opts = ("0", "1", "2", "s", "3"); - foreach my $opt (@opts) { - $res = runit ("RunSafely.sh 10 1 /dev/null out.txt clang -ccc-host-triple msp430-generic-generic -ccc-clang-archs msp430 -x c -O$opt -S foo.c -w -I/home/regehr/csmith/src > /dev/null 2>&1"); - open INF, ") { - $output .= $line; - } - close INF; - if ($output =~ /Cannot yet select/ || - $output =~ /Do not know how to legalize this operator/) { - } else { - $all_out{$output} = "$opt $seed"; - } - } - $n++; - print "$n\n"; - last if ($n == 5000); -} - -foreach my $x (keys %all_out) { - print "\n\n********************************************** $all_out{$x} \n\n\n"; - print $x; -} diff --git a/utah/scripts/one_off/test_clang2.pl b/utah/scripts/one_off/test_clang2.pl deleted file mode 100755 index 168454f06..000000000 --- a/utah/scripts/one_off/test_clang2.pl +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/perl -w - -use strict; - -sub runit ($) { - my $cmd = shift; - my $res = (system "$cmd"); - my $exit_value = $? >> 8; - return $exit_value; -} - -my $n = 0; - -my %totals = (); -my %counts = (); -my %all_out; - -foreach my $fn (@ARGV) { - my @opts = ("0", "1", "2", "s", "3"); - foreach my $opt (@opts) { - print "$fn $opt\n"; - my $res = runit ("RunSafely.sh 10 1 /dev/null out.txt clang -ccc-host-triple msp430-generic-generic -ccc-clang-archs msp430 -x c -fheinous-gnu-extensions -O$opt $fn -S -w -I/home/regehr/csmith/src > /dev/null 2>&1"); - open INF, ") { - $output .= $line; - } - close INF; - if ($output =~ /no such instruction/ || - $output =~ /Cannot yet select/ || - $output =~ /Do not know how to legalize this operator/) { - } else { - $all_out{$output} .= "[$fn $opt] "; - } - } - $n++; - print "$n\n"; - last if ($n == 2000); -} - -foreach my $x (keys %all_out) { - print "\n\n********************************************** $all_out{$x} \n\n\n"; - print $x; - print "\n\n**********************************************\n\n\n"; -} diff --git a/utah/scripts/one_off/test_compcert.pl b/utah/scripts/one_off/test_compcert.pl deleted file mode 100755 index f8cfa482a..000000000 --- a/utah/scripts/one_off/test_compcert.pl +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -use File::stat; - -my $N = 1000000; - -my $MIN_SIZE = 10000; - -my $VALGRIND = ""; -# my $VALGRIND = "valgrind -q"; - -sub runit ($) { - my $cmd = shift; - my $res = (system "$cmd"); - my $exit_value = $? >> 8; - return $exit_value; -} - -my $n = 0; - -my %totals = (); -my %counts = (); -my %max = (); -my %max_seed = (); -my $x=0; - -while (1) { - my $seed = int(rand(4000000000)); - #my $seed = $x++; - my $res = runit ("$VALGRIND ../src/csmith -s $seed --no-pointers --bitfields ia32 --no-arrays --no-math64 --no-return-structs --no-arg-structs > foo.c"); - if ($res == 0) { - if (stat("foo.c")->size >= $MIN_SIZE) { - open INF, ") { - if ($line =~ /^XXX (.*): ([+-]?(\d+\.\d+|\d+\.|\.\d+|\d+)([eE][+-]?\d+)?)$/) { - my $stat = $1; - my $num = $2; - $counts{$stat}++; - if (!defined($max{$stat})) { - $max{$stat} = $num; - } else { - if ($num > $max{$stat}) { - $max{$stat} = $num; - $max_seed{$stat} = $seed; - } - } - $totals{$stat} += $num; - next; - } - die "oops bad stats line '$line'" if ($line =~ /XXX/); - } - if ($n%10000==0) { - print "$n\n"; - } - $n++; - last if ($n == $N); - - system "rm -f foo.s"; - #print "\n\n\n\n"; - system "ccomp -D__COMPCERT__ -I/home/regehr/csmith/src -S foo.c >out.txt 2>&1"; - if (-f "foo.s") { - print "compiler succeeded\n"; - } else { - system "cat out.txt"; - print "compiler failed for seed $seed\n"; - system "wc foo.c"; - } - } - } else { - print "failed for seed $seed\n"; - } -} - -foreach my $k (sort keys %totals) { - my $count = $counts{$k}; - my $avg = sprintf "%.2f", $totals{$k} / $count; - my $max = sprintf "%.2f", $max{$k}; - my $s = $max_seed{$k}; - print "$k\n"; - print " occurred $count times, max value= $max, max seed = $s, average value= $avg\n"; -} diff --git a/utah/scripts/one_off/test_framac.pl b/utah/scripts/one_off/test_framac.pl deleted file mode 100755 index 3f306b266..000000000 --- a/utah/scripts/one_off/test_framac.pl +++ /dev/null @@ -1,179 +0,0 @@ -#!/usr/bin/perl -w -## -## Copyright (c) 2011 The University of Utah -## All rights reserved. -## -## This file is part of `csmith', a random generator of C programs. -## -## Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are met: -## -## * Redistributions of source code must retain the above copyright notice, -## this list of conditions and the following disclaimer. -## -## * Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in the -## documentation and/or other materials provided with the distribution. -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -## ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -## LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -## POSSIBILITY OF SUCH DAMAGE. - -use strict; - -############################################################ - -my $CC = "clang"; - -my $IGNORE_CSMITH_CRASH = 0; -my $IGNORE_COMPILER_CRASH = 0; -my $IGNORE_FRAMAC_CRASH = 1; - -my $MAX_SLEVEL = 50; - -my $PROG_TIMEOUT = 5; - -my $FC = "--no-checksum --no-argc --no_return_dead_ptr "; - -$FC .= "--no-volatiles "; -#$FC .= "--no-volatile-pointers "; - -$FC .= "--no-arrays "; - -$FC .= "--bitfields "; -#$FC .= "--packed-struct "; - -$FC .= "--no-pointers "; - -#$FC .= "--no-structs "; - -# packed struct - -############################################################ - -my $CSMITH=$ENV{"CSMITH_HOME"}; -die "please export environment variable CSMITH_HOME" if (!defined($CSMITH)); - -my $FRAMAC=$ENV{"FRAMAC_HOME"}; -die "please export environment variable FRAMAC_HOME" if (!defined($FRAMAC)); - -sub one_test($) { - (my $seed) = @_; - - start: - my $s=""; - if ($seed != 0) { - $s = "-s $seed"; - } - - system "$CSMITH/src/csmith $FC > foo.c"; - { - my $exit_value = $? >> 8; - if ($exit_value != 0) { - goto start if ($IGNORE_CSMITH_CRASH); - die; - } - } - - { - system "$CC -E -D__FRAMAC foo.c -I$CSMITH/runtime > foo_pp.c"; - my $cc_exit_value = $? >> 8; - if ($cc_exit_value != 0) { - goto start if ($IGNORE_COMPILER_CRASH); - die; - } - } - - system "grep Seed foo.c"; - - my $SLEVEL = int(rand($MAX_SLEVEL)); - my $cmd = "${FRAMAC}/bin/toplevel.opt -val -slevel $SLEVEL foo_pp.c"; - print "$cmd\n"; - - system "RunSafely.sh 60 1 /dev/null framac_out.txt $cmd"; - my $fc_exit_value = $? >> 8; - print "frama-c result = $fc_exit_value\n"; - if ($fc_exit_value != 0 && $fc_exit_value != 137) { - die if (!$IGNORE_FRAMAC_CRASH); - } - - open INF, ") { - chomp $line; - if ($line =~ /Frama_C_dump_assert_each called/) { - $log = 1; - next; - } - if ($line =~ /End of Frama_C_dump_assert_each output/) { - $log = 0; - next; - } - next if ($line =~ /crc/); - next if ($line =~ /undefined/); - next if ($line =~ /print_hash/); - if ($log) { - die $line if (!($line =~ s/\s*\&\& //)); - $asserts .= " assert($line);\n"; - $nasserts++; - } - } - close INF; - - if ($nasserts<1) { - return if ($seed != 0); - goto start; - } - - print "$asserts"; - print "$nasserts asserts\n"; - - open INF, "foo_assert.c" or die; - while (my $line = ) { - if ($line =~ /platform_main_end\(0\)\;/) { - print OUTF $asserts; - } else { - print OUTF $line; - } - } - close INF; - close OUTF; - - { - system "$CC -w -O0 -D__FRAMAC foo_assert.c -I$CSMITH/runtime -o foo_assert"; - my $cc_exit_value = $? >> 8; - if ($cc_exit_value != 0) { - goto start if ($IGNORE_COMPILER_CRASH); - die; - } - } - - my $res = system "RunSafely.sh $PROG_TIMEOUT 1 /dev/null out2 ./foo_assert"; - my $exit_value = $? >> 8; - print "exit_value = $exit_value\n"; - die() if ($exit_value != 0 && $exit_value != 137); -} - -my $args = scalar(@ARGV); - -if ($args==0) { - for (my $i=0;; $i++) { - print "\n\n[$i]\n"; - one_test(0); - } -} elsif ($args==1) { - one_test ($ARGV[0]); -} else { - die; -} diff --git a/utah/scripts/one_off/test_warnings.pl b/utah/scripts/one_off/test_warnings.pl deleted file mode 100755 index 76547e811..000000000 --- a/utah/scripts/one_off/test_warnings.pl +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -use File::stat; - -my $N = 50000; - -my $MIN_SIZE = 1; - -my $VALGRIND = ""; -# my $VALGRIND = "valgrind -q"; - -sub runit ($) { - my $cmd = shift; - my $res = (system "$cmd"); - my $exit_value = $? >> 8; - return $exit_value; -} - -my $n = 0; - -my %totals = (); -my %counts = (); -my %max = (); -my %max_seed = (); -my $x=0; - -my %warn_size = (); -my %warn_seed = (); - -while (1) { - my $seed = int(rand(4000000000)); - #my $seed = $x++; - my $res = runit ("RunSafely.sh 60 0 /dev/zero output.txt ../src/csmith -s $seed --bitfields ia32 --packed-struct --random-random > foo.c"); - if ($res == 0) { - if (stat("foo.c")->size >= $MIN_SIZE) { - open INF, ") { - if ($line =~ /^XXX (.*): ([+-]?(\d+\.\d+|\d+\.|\.\d+|\d+)([eE][+-]?\d+)?)$/) { - my $stat = $1; - my $num = $2; - $counts{$stat}++; - if (!defined($max{$stat})) { - $max{$stat} = $num; - } else { - if ($num > $max{$stat}) { - $max{$stat} = $num; - $max_seed{$stat} = $seed; - } - } - $totals{$stat} += $num; - next; - } - die "oops bad stats line '$line'" if ($line =~ /XXX/); - } - if ($n%100==0) { - print "$n\n"; - } - $n++; - last if ($n == $N); - - system "rm -f out.txt"; - system "current-gcc -O2 -Wall foo.c -I/home/regehr/csmith/src >out.txt 2>&1"; - open INF, ") { - - next if (/At top level:/); - next if (/In function \‘(.*)\’:/); - - if (/: warning: (.*)$/) { - my $warn = $1; - next if ($warn =~ /unused variable \‘/); - next if ($warn =~ /comparison is always true due to limited range of data type/); - next if ($warn =~ /overflow in implicit constant conversion/); - next if ($warn =~ /large integer implicitly truncated to unsigned type/); - next if ($warn =~ /comparison is always false due to limited range of data type/); - next if ($warn =~ /‘safe_(.*)\’ defined but not used/); - next if ($warn =~ /‘crc32_8bytes\’ defined but not used/); - next if ($warn =~ /address of \‘(.*)\’ will never be NULL/); - next if ($warn =~ /function returns address of local variable/); - next if ($warn =~ /may be used uninitialized/); - - if ($warn =~ /\‘(.*)\’ is used uninitialized in this function/) { - my $var = $1; - die if (!($warn =~ s/$1/some_variable/)); - } - - my $size = stat("foo.c")->size; - if (!defined($warn_size{$warn}) || ($size < $warn_size{$warn})) { - $warn_size{$warn} = $size; - $warn_seed{$warn} = $seed; - } - } - - #print; - } - close INF; - - } - } else { - print "failed for seed $seed\n"; - } -} - -foreach my $k (sort keys %totals) { - my $count = $counts{$k}; - my $avg = sprintf "%.2f", $totals{$k} / $count; - my $max = sprintf "%.2f", $max{$k}; - my $s = $max_seed{$k}; - print "$k\n"; - print " occurred $count times, max value= $max, max seed = $s, average value= $avg\n"; -} - -print "\n\n"; - -foreach my $k (sort keys %warn_size) { - print "$k size=$warn_size{$k} seed=$warn_seed{$k}\n"; -} diff --git a/utah/scripts/one_off/testlto.pl b/utah/scripts/one_off/testlto.pl deleted file mode 100755 index f0598bc49..000000000 --- a/utah/scripts/one_off/testlto.pl +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -use warnings; - -sub runit ($) { - my $cmd = shift; - my $res = (system "$cmd"); - my $exit_value = $? >> 8; - return $exit_value; -} - -my $n=0; - -while (1) { - $n++; - print "program $n\n"; - runit ("rm -rf output"); - runit ("../src/csmith --max-split-files 3"); - chdir "output" or die; - runit ("current-gcc -w -O3 -flto -c -I/home/regehr/csmith/src rnd_output0.c >/dev/null 2>&1"); - runit ("current-gcc -w -O3 -flto -c -I/home/regehr/csmith/src rnd_output1.c >/dev/null 2>&1"); - runit ("current-gcc -w -O3 -flto -c -I/home/regehr/csmith/src rnd_output2.c >/dev/null 2>&1"); - runit ("current-gcc -w -O3 -flto *.o -o rand1 -fwhole-program >/dev/null 2>&1"); - runit ("current-gcc -w -O3 -I/home/regehr/csmith/src *.c -o rand2 >/dev/null 2>&1"); - runit ("llvm-gcc -w -O3 -I/home/regehr/csmith/src *.c -o rand3 >/dev/null 2>&1"); - runit ("RunSafely.sh 3 0 /dev/zero output1 ./rand1"); - runit ("RunSafely.sh 3 0 /dev/zero output2 ./rand2"); - runit ("RunSafely.sh 3 0 /dev/zero output3 ./rand3"); - runit ("cat output1 | grep check"); - runit ("cat output2 | grep check"); - runit ("cat output3 | grep check"); - chdir ".." or die; -} - diff --git a/utah/scripts/one_off/unwrap_math.pl b/utah/scripts/one_off/unwrap_math.pl deleted file mode 100755 index 673f8e11b..000000000 --- a/utah/scripts/one_off/unwrap_math.pl +++ /dev/null @@ -1,147 +0,0 @@ -#!/usr/bin/perl -w -## -## Copyright (c) 2011 The University of Utah -## All rights reserved. -## -## This file is part of `csmith', a random generator of C programs. -## -## Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are met: -## -## * Redistributions of source code must retain the above copyright notice, -## this list of conditions and the following disclaimer. -## -## * Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in the -## documentation and/or other materials provided with the distribution. -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -## ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -## LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -## POSSIBILITY OF SUCH DAMAGE. - -# TODO: run all versions under Peng's checked Clang - -#my $VERBOSE = 1; -my $VERBOSE = 0; - -my $CSMITH_HOME = $ENV{"CSMITH_HOME"}; -die if (!defined($CSMITH_HOME)); - -sub runit ($$) -{ - (my $cmd, my $out) = @_; - my $whole_cmd = "$cmd > $out 2>&1"; - print "${whole_cmd}\n" if $VERBOSE; - system $whole_cmd; - my $exit = $? >> 8; - die "FAILED: '$cmd'" if ($exit != 0); -} - -sub run_timeout ($$) -{ - (my $cmd, my $out) = @_; - my $whole_cmd = "RunSafely.sh 5 1 /dev/null $out $cmd"; - print "${whole_cmd}\n" if $VERBOSE; - system $whole_cmd; - my $exit = $? >> 8; - die "FAILED: '$cmd'" if ($exit != 0 && $exit != 137); - return $exit; -} - -sub go() { - print "\n--------------------------------------------\n"; - - restart: - system "rm -f foo.c foo_id.c foo_unwrap.c wrapper.h"; - - my $seed = int(rand(1000000000)); - - runit ("$CSMITH_HOME/src/csmith -s $seed", "foo.c"); - runit ("$CSMITH_HOME/src/csmith -s $seed --identify-wrappers", "foo_id.c"); - open INF, "; - chomp $line; - my $nwraps; - if ($line =~ /define N_WRAP ([0-9]+)$/) { - $nwraps = $1; - } - close INF; - die if (!defined($nwraps)); - goto restart if ($nwraps < 10); - - print "seed = $seed\n"; - - runit ("current-gcc -O0 foo.c -o foo -I${CSMITH_HOME}/runtime", "gcc-out.txt"); - my $res = run_timeout ("./foo", "out.txt"); - return if ($res != 0); - system "cat out.txt | grep checksum"; - - runit ("current-gcc -O0 foo_id.c -o foo_id -DLOG_WRAPPERS -I. -I${CSMITH_HOME}/runtime", "gcc-out.txt"); - $res = run_timeout ("./foo_id", "out.txt"); - return if ($res != 0); - system "cat out.txt"; - - open INF, ") { - if ($line =~ /executed wrappers: (.*)$/) { - $executed = $1; - } - if ($line =~ /dead wrappers: (.*)$/) { - $dead = $1; - } - if ($line =~ /at least once: (.*)$/) { - $failed = $1; - } - if ($line =~ /never executed\): (.*)$/) { - $notfailed = $1; - } - } - close INF; - - die if (!defined($executed) || - !defined($dead) || - !defined($failed) || - !defined($notfailed)); - - my @l; - @l = split(/,/,$executed); - my $nexecuted = scalar(@l); - @l = split(/,/,$dead); - my $ndead = scalar(@l); - print "$nexecuted executed, $ndead did not\n"; - - @l = split(/,/,$failed); - my $nfailed = scalar(@l); - @l = split(/,/,$notfailed); - my $nnotfailed = scalar(@l); - print "$nfailed failed, $nnotfailed did not\n"; - - if ($nfailed == 0) { - # magic code for "eliminate all wrappers" - $failed = "0"; - } - - runit ("$CSMITH_HOME/src/csmith -s $seed --safe-math-wrappers $failed", "foo_unwrap.c"); - - runit ("current-gcc -O0 foo_unwrap.c -o foo_unwrap -I${CSMITH_HOME}/runtime", "gcc-out.txt"); - $res = run_timeout ("./foo_unwrap", "out.txt"); - return if ($res != 0); - system "grep checksum out.txt"; - -} - -for (my $i=0; $i<100; $i++) { - go(); -} diff --git a/utah/scripts/seq_reduce/seq_reduce.pl b/utah/scripts/seq_reduce/seq_reduce.pl deleted file mode 100755 index 19cd18032..000000000 --- a/utah/scripts/seq_reduce/seq_reduce.pl +++ /dev/null @@ -1,375 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -use File::stat; - -# TODO: -# -# use temp dirs -# handle compiler crash bugs and program crash bugs -# optionally optimize for reduced execution time using PIN -# to count insns -# -# more sophisticated search: simulated annealing, backtracking, etc. -# running on multiple cores -# log results to a file that can be gnuplotted - -############################################################## - -my $CSMITH_HOME = $ENV{"CSMITH_HOME"}; -die "please set CSMITH_HOME env first!" if (!defined($CSMITH_HOME)); - -#my $VOLATILE = $ENV{"VOLATILE_HOME"}; -#die "please set VOLATILE_HOME env first!" if (!defined($VOLATILE)); - -#$ENV{"PATH"} = "$ENV{VOLATILE_HOME}:$ENV{PATH}"; - -my $COMPILER_TIMEOUT = 600; -my $PROG_TIMEOUT = 2; - -# in second -my $TEST_TIMEOUT = 20 * 60; - -if (@ARGV != 4 && @ARGV != 3 && @ARGV != 5) { - die "usage: simple_delta.pl \n\n"; -} - -my $seed = $ARGV[0]; -my $COMPILER1 = $ARGV[1]; -my $COMPILER2 = $ARGV[2]; -my $OPTS = "--concise "; -if (@ARGV >= 4) { - $OPTS = "$OPTS$ARGV[3]"; -} - -my $crash_string = ""; -if (@ARGV == 5) { - $crash_string = $ARGV[4]; -} - -my $cfile = "small.c"; -my $tmp_cfile = "small_tmp.c"; -my $backup_cfile = "works.c"; -my $deltafile = "delta.out"; -my $backup_deltafile = "works.out"; -my $indent = " "; -my $HEADER = "-DCSMITH_MINIMAL -I$CSMITH_HOME/runtime"; -my $STOP_AFTER = 300000; -my $SUFFIX1 = "_a"; -my $SUFFIX2 = "_b"; -my $EXE1 = "$cfile$SUFFIX1"; -my $EXE2 = "$cfile$SUFFIX2"; -my $COMPILER_OUT1 = "compiler_out$SUFFIX1"; -my $COMPILER_OUT2 = "compiler_out$SUFFIX2"; -my $PROG_OUT1 = "prog_out$SUFFIX1"; -my $PROG_OUT2 = "prog_out$SUFFIX2"; - -############################################################## - -sub runit ($) { - (my $cmd) = @_; - if ((system "$cmd") != 0) { - return -1; - } - return ($? >> 8); -} - -sub read_file($\@$) { - my ($input, $out, $match) = @_; - my $cnt = 0; - open INF, "<$input" or die; - while (my $line = ) { - chomp $line; - if ($line =~ /$match/) { - push @$out, $line; - $cnt++; - } - } - close INF; - return $cnt; - } - -sub read_file_with_substring($\@$) { - my ($input, $out, $substring) = @_; - my $cnt = 0; - open INF1, "<$input" or die; - while (my $line = ) { - chomp $line; - if (index($line, $substring) != -1) { - push @$out, $line; - $cnt++; - } - } - close INF1; - return $cnt; -} - -sub compile($$$$) { - my ($compiler, $src_file, $exe, $out) = @_; - my $res = 0; - my $dur; - - my $command = "RunSafely.sh $COMPILER_TIMEOUT 1 /dev/null $out $compiler $src_file $HEADER -o $exe"; - ($res, $dur) = runit($command); - if (($res != 0) || (!(-e $exe))) { - # timeout - if ($res == 137) { - print "$indent COMPILER($compiler) FAILURE: TIMEOUT\n"; - } - else { - print "$indent COMPILER($compiler) FAILURE: return code $res \n"; - print "$indent check the output file $out for details\n"; - } - return -1; - } - else { - return 0; - } -} - -sub run_exe ($$$) { - my ($exe, $out, $param) = @_; - my $res = 0; - my $dur; - my $command = "RunSafely.sh $PROG_TIMEOUT 1 /dev/null $out ./$exe $param >/dev/null 2>&1"; - ($res, $dur) = runit($command); - if ($res) { - # print "res = $res\n"; - # timeout - if ($res == 137) { - print "$indent Running $exe FAILURE: TIMEOUT\n"; - return 1; - } - if ($res == 139) { - print "$indent Running $exe FAILURE: core dump\n"; - return 2; - } - else { - # print "$indent Running $exe FAILURE: return code $res\n"; - return 3; - } - } - return 0; -} - -# rv: 1 - not equal, 0 - equal -sub compare($\@$\@$$) { - my ($file1, $out1, $file2, $out2, $flag1, $match) = @_; - - read_file($file1, @$out1, $match); - read_file($file2, @$out2, $match); - - if ($flag1 && (@$out1 != @$out2)) { - print "$indent COMPARISON FAILS: two outputs must have the different number of lines."; - return -1; - } - else { - if (@$out1 != @$out2) { - return 1; - } - - for (my $i=0; $i < @$out1; $i++) { - return 1 if $out1->[$i] ne $out2->[$i]; - } - } - return 0; -} - -my $test_count = 0; -my $ARGS="-g -Wmissing-prototypes -Werror=missing-prototypes -Wreturn-type -Werror=return-type -Wstrict-prototypes -Werror=strict-prototypes $HEADER"; -my $EXTRA='-Wuninitialized -Werror=uninitialized'; -# flag1 == 1: we check if two outputs have the same lines. -# flag2 == 1: we check the line which is "checksum = xxxx". -sub run_wrong_code_test ($$$) { - my ($test_file, $flag1, $match) = @_; - system "rm -f gcc.txt"; - system "gcc $ARGS $EXTRA -O0 $test_file -o a.out > gcc.txt 2>&1"; - my @tmp = (); - if (read_file("gcc.txt", @tmp, "no return statement") || - read_file("gcc.txt", @tmp, "control reaches") || - # read_file("gcc.txt", @tmp, "initia") || - read_file("gcc.txt", @tmp, "proto")) { - system("cp $test_file gcc_fail.c"); - print "$indent compiler error! Can't compile $test_file with gcc\n"; - return 0; - } - - $test_count++; - my $res; - $res = compile($COMPILER1, $test_file, "$EXE1$test_count", "$COMPILER_OUT1$test_count"); - if ($res) { - print "$indent compiler error! Can't compile $test_file with $COMPILER1\n"; - return 0; - } - - $res = compile($COMPILER2, $test_file, "$EXE2$test_count", "$COMPILER_OUT2$test_count"); - if ($res) { - print "$indent compiler error! Can't compile $test_file with $COMPILER2\n"; - return 0; - } - - $res = run_exe("$EXE1$test_count", "$PROG_OUT1$test_count", ""); - if ($res) { - #print "$indent can't run the program: $EXE1$test_count\n"; - return 0; - } - - $res = run_exe("$EXE2$test_count", "$PROG_OUT2$test_count", ""); - if ($res) { - #print "$indent can't run the program: $EXE2$test_count\n"; - return 0; - } - - my @OUTPUT1 = (); - my @OUTPUT2 = (); - $res = compare("$PROG_OUT1$test_count", @OUTPUT1, "$PROG_OUT2$test_count", @OUTPUT2, $flag1, $match); - - if ($res == -1) { - die "comparison error!\n"; - } - return $res; -} - -sub run_crash_test($$) { - my ($test_file, $match) = @_; - system "rm -f gcc.txt"; - system "gcc $ARGS $EXTRA -O0 $test_file -o a.out > gcc.txt 2>&1"; - my @tmp = (); - if (read_file("gcc.txt", @tmp, "no return statement") || - read_file("gcc.txt", @tmp, "control reaches") || - # read_file("gcc.txt", @tmp, "initia") || - read_file("gcc.txt", @tmp, "proto")) { - system("cp $test_file gcc_fail.c"); - print "$indent compiler error! Can't compile $test_file with gcc\n"; - return 0; - } - - $test_count++; - my $res; - $res = compile($COMPILER1, $test_file, "$EXE1$test_count", "$COMPILER_OUT1$test_count"); - if ($res) { - if (read_file_with_substring("$COMPILER_OUT1$test_count", @tmp, $match)) { - print "$indent crash string $match found for $test_file with $COMPILER1\n"; - return 1; - } - else { - print "$indent no crash string $match found for $test_file with $COMPILER1\n"; - return 0; - } - } - else { - print "$indent no crash error found for $test_file with $COMPILER1\n"; - return 0; - } -} - -sub run_test($$$) { - my ($test_file, $flag1, $match) = @_; - - if ($crash_string eq "") { - return run_wrong_code_test($test_file, $flag1, $match); - } - else { - return run_crash_test($test_file, $crash_string); - } -} - -sub get_score ($) { - (my $fn) = @_; - return stat($fn)->size; - - # open INF, "<$fn" or die; - # my $score = 0; - # while (my $line = ) { - # if ($line =~ /safe_/) { - # $score += 500; - # } - # $score += length($line); - # } - # close INF; - # return $score; -} - -############################ MAIN ############################ - -print "seed = $seed\n"; - -$OPTS =~ s/-s\s+[0-9]+//g; - -system "${CSMITH_HOME}/src/csmith -s $seed $OPTS --delta-monitor simple --delta-output $deltafile > $cfile"; - -my $res = run_test($cfile, 0, "checksum "); -if (!$res) { - die "oops-- initial test 1 fails\n"; -} -print "initial test 1 succeeds\n"; - -system "${CSMITH_HOME}/src/csmith $OPTS --go-delta simple --delta-input $deltafile --no-delta-reduction > $cfile"; - -$res = run_test($cfile, 0, "checksum "); -if (!$res) { - die "oops-- initial test 2 fails\n"; -} -print "initial test 2 succeeds\n"; - -system "cp $cfile aaa.c"; -my $orig_sz = get_score($cfile); - -my $n = 0; -my $prev_time = time(); -my $total_time = 0; - -print "initial score = $orig_sz\n"; -while (1) { - my $sz = get_score($cfile); - # invariant-- test succeeds here - system "cp $cfile ${backup_cfile}"; - system "cp $deltafile ${backup_deltafile}"; - - $n++; - if ($n > $STOP_AFTER) { - last; - } - if (($n % 10000) == 0) { - print "$n reps done\n"; - } - - system "${CSMITH_HOME}/src/csmith $OPTS --go-delta simple --delta-input ${backup_deltafile} --delta-output ${deltafile} > $cfile"; - my $new_sz = get_score ($cfile); - - my $success = 0; - - if ($new_sz < $sz) { - my $pct = sprintf "%.1f", 100*(1.0-((0.0+$new_sz)/$orig_sz)); - my $r2 = run_test($cfile, 0, "checksum "); - if ($r2) { - print "$n : new score = $new_sz (reduced by $pct %) : "; - print "test succeeded\n"; - #print "success!!! new score = $new_sz($pct)\n"; - $success = 1; - } else { - # print "test failed\n"; - } - } else { - # print "not smaller\n"; - } - - if (!$success) { - system "cp ${backup_cfile} $cfile"; - system "cp ${backup_deltafile} $deltafile"; - } else { - $sz = $new_sz; - } - my $curr_time = time(); - $total_time += ($curr_time - $prev_time); - $prev_time = $curr_time; - print "elapsed time: $total_time\n"; - if ($total_time > $TEST_TIMEOUT) { - last; - } -} -system "cp $cfile simple$seed.c"; -my $sz = get_score($cfile); -my $rate = sprintf "%.1f", 100*(1.0-((0.0+$sz)/$orig_sz)); -print "=== simple delta reduction rate: $rate ===\n"; -print "final reduced file: simple$seed.c\n";