Git Product home page Git Product logo

gen-xfakes's Introduction

Crash to Pass Toolkit

legacy-build and gen-xfakes

This repo has two scripts to help C and C++ programmers drag unwilling legacy C and C++ into a test harness.

The recipe for getting legacy C/C++ is described in TDD How-to: Get your Legacy C Into a Test Harness

legacy-build.sh

Runs the makefile in the working directory, captures the output and makes a suggestion about how to solve the current problem. If you use CppUTest, some suggestions can be cut and pasted into your makefile.

Finally, when you get to linker errors, legacy-build will run gen-xfakes to generate eploding fakes to get you past linker problems and on to running your code.

Set your build so that it fails on the first error. For gcc and clang -Wfatal-errors.

So far, this has been tested on

  • ubuntu gcc version 9.3.0.
  • mac osx gcc version 7.4.0

gen-xfakes

Generate exploding fakes from c/c++ linker error output (used for unit testing).

For C linker errors, the resutling file can be added to the build and those link errors go away. They later turn into runtime errors as exit the test runner whenever you code executes and exploding fake. For C++ errors, you need to do some editing.

Usage

Capture the linker error output and feed it to the gen-xfakes.sh


$ make 2>error-output.txt
$ path/to/gen-xfakes.sh error-output.txt xfakes

gen-xfakes.sh produces three files with the supplied basename xfakes

xfakes-c.c C linkage fakes, ready to add to your build
xfakes-cpp.cpp C++ linkage fakes, edits needed
xfakes-cpp-globals.cpp C++ undefined globals, edits needed

Supported formats

  • g++ linker output
  • clang
  • Visual Studio -- best guess
  • Feel free to give me a contribution
  • All these compilers are moving target, so you may have to fiddle with it.

To be supported formats

Examples

See test/example-output/gcc-link-errors.txt for example input. The output files are found in test/golden.

A full explanation of how to use gen-xfakes is on my blog here.

Run the tests on your machine

Clone everying including the tests

$ git clone <repo>
$ git submodule update --init

Run the tests

cd tests
./all-tests.sh

gen-xfakes's People

Contributors

jwgrenning 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.