GithubHelp home page GithubHelp logo

winspool / csmith.sh Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 6 KB

create testfiles with csmith and check compiler results. With TAP output

Shell 100.00%
compiler csmith fuzzing script testing c tap tcc test-anything-protocol tinycc

csmith.sh's Introduction

csmith.sh

Welcome to a nice script with TAP output to generate testfiles with csmith
and compare the results of a testing c/c++ compiler ( $TESTCC | $TESTCXX )
with the results of a reference c/c++ compiler ( $REFCC | $REFCXX )

On failure, additional helper scripts for 'creduce' are created.

Usage:

 csmith.sh [first_seed] [-] [last_seed]

csmith is called with a seed value to create reproducible testfiles
default range for the seed value is 0 - 1000
(use command line args for other ranges)
(a single value test the compilers with only one specific testfile)

Supported environment variable

  • DEBUG print many extra informations

  • CSMITH_BIN use a different csmith binary

  • CSMITH_OPTIONS use additional options for csmith

  • RUNTIME_DIR use this directory as working directory [ $XDG_RUNTIME_DIR/$subdir | /tmp/$subdir ]

  • CSMITH_INCLUDE csmith include path for the compiler [ $CSMITH_INCLUDE ]

  • REFCC c reference compiler [ $HOSTCC | $BUILDCC | $def_refcc ]

  • REFCXX c++ reference compiler[ $HOSTCXX | $BUILDCXX | $def_refcxx ]

  • REFCCFLAGS extra flags for the c reference compiler

  • REFCXXFLAGS extra flags for the c++ reference compiler

  • TESTCC c compiler to test [ $CC ]

  • TESTCXX c++ compiler to test [ $CXX ]

  • TESTCCFLAGS extra flags for the c compiler to test [ $CCFLAGS ]

  • TESTCXXFLAGS extra flags for the c++ compiler to test [ $CXXFLAGS ]

Define the reference compiler and related flags in the scriptname

The scriptname can be used to define the std mode, a reference compiler and related flags.
At the end of the first part (upto the first dot), the underscore can be used to select the std.
After the ".sh" extension was stripped, the remaining dots are used to split additional options.

Examples:

  • csmith.tcc.sh
  • csmith_c11.gcc.-m32.sh
  • csmith.clang.--target.x86_64-linux-musl.sh

More details

Testfiles are created in a subdirectory of XDG_RUNTIME_DIR (which is normally a RAM-disc, based on tmpfs).
This is much faster and avoids write pressure on a physical disc (probably a flash disc).

When building or running a test binary or comparing the result fails,
additional shell scripts are created, which can be used for "creduce" as "interestingness_test"

To avoid to fill up the disc, all files for the current seed value are deleted,
when both compile variants work and running the created programs produced the same result.

The output of this script is compatible to TAP: Test Anything Protocol

LICENSE: MIT

csmith.sh's People

Contributors

winspool avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.