From building a multi-platform environment for Cpputest to tutorials

From building a multi-platform environment for the CppUTest environment to tutorials

March 2017 version

Task

It seems that TDD can be done even in the world of embedded C language Or rather, I really want an environment for testing legacy code. .. .. At that time, Great Person said that the framework called CppUTest is recommended. By the way, the work environment has finally moved to windows 10, and I want to do various things at this timing. Of course, I'm in trouble if I don't support my Mac and multi-platform Windows is particularly troublesome to build an environment, so I decided to go for it. .. .. Or rather, there is little Japanese information on CppUTest.

Various software versions

By the way, the IDE uses CLion 2016.3.3 It feels good to support multiple platforms

Building windows10 environment

  1. Introduced 64-bit version of cygwin (32bit version may be acceptable)

    • install from internet --Root Directory is by default (C: \ cygwin64) --Please enjoy the local package as you like
    • Direct Connection --Download sites should choose a Japanese server (search for hogehoge.jp) --Building the above environment with select package
  2. Clone CppUTest from github --Choose your favorite directory --Hereafter, the directory of CppUTest is referred to as \ .

  3. Build CppUTest with cygwin For the time being, just send the following command and it's OK

    cd <CppUTest>/cpputest_build
    ../configure
    make
    

You can check if the following command was installed properly as it is

```sh
make tdd
```

The test should run and pass or ignore If you have installed it successfully, you should set environment variables.

```sh
CPPUTEST_HOME=<CppUTest>  
```

It's a good idea to install the script as well.

```sh
cd <CppUTest>/scripts
chmod u+x *.sh
./InstallScripts.sh
```
  1. CppUTest bug? Corresponds to I picked up Tutorial and tried to build it. .. ..

Try it like this

```sh
git clone https://github.com/davisford/cmake-cpputest
cd cmake-cpputest
mkdir build
cd build
cmake ..
make
```

** It seems that even if you pick up the tutorial sample and make it as it is, it will not pass! !! !! ** **

An error occurs because there is no rule to make ‘\ /src/CppUTest/libCppUTest.a’ It seems that the library file cannot be copied to a proper directory

Located in ** \ / cpputest_build / lib **

**libCppUTest.a**
**libCppUTestExt.a**  

To ** \ / src / CppUTest ** and then execute the above command. .. .. It's sunny and you can now make

Building mac environment

It seems that it can be installed with Homebrew, but I did it with git git clone and below just like windows

** \ / cpputest_build / lib **

libCppUTest.a libCppUTestExt.a

Copy> to ** \ / src / CppUTest **

Don't forget

Bonus: Building a CLion environment

mac doesn't have to do anything special All you have to do is set windows and cygwin When I open the above tutorial sample in CLion, I get a warning due to a different version of cmake, but there is no problem with the build. For CLion, if you add -v to Program arguments in the build config, you can always see the test results and make progress.

Summary

For the time being, I wanted a comprehensive Japanese commentary from the introduction of cygwin to the construction of the CppUTest environment. If you do so far, you can stand at the starting point Right now, I'm groping for the time being and writing tests while fighting English.

References

-Embedded programming by test-driven development

Recommended Posts