Skip to main content

GUnit

App for executing C/C++ unit tests using GDB.

Documentation: https://github.com/estcube/GUnit/wiki

Installation

The easiest way to install Gunit is through pip: https://pypi.org/project/gunit/

pip install gunit

Example

For example if OpenOCD is used as GDB server and we are testing on an ARM chip. Please note that you need to have the openOCD server running in the background.

Secondly, all the outputs will be put into gunit directory. To specify where the directory will be generated, define build_dir argument for the constructor. By default, it will be your current working directory.

from gunit import GUnit

# Create a GUnit object for OpenOCD
gunit = GUnit.openOCD("localhost:9000", executable='arm-none-eabi-gdb')

# Execute the tests in the compiled file
gunit.test("test.elf")

# Construct a JUnit test report
gunit.junit()

Here you can see a simple example of the .cpp file that could be used with the python example above.

#include "GUnit.hpp"

gunit::test t1(
  "test1",                  // Name of the test case
  [](){                     // Lambda expression
    gunit::affirm(20) > 10; // The test case to check
  }
);

gunit::test t2("test2", [](){
  gunit::affirm(10) > 20;
  gunit::affirm(11) > 20;
});

gunit::test t3("test3", [](){
  std::list l1 = std::list<int>();
  l1.push_back(10);
  l1.push_back(12);
  l1.push_back(14);

  std::list l2 = std::list<int>();
  l2.push_back(10);
  l2.push_back(12);
  l2.push_back(14);

  gunit::affirm(l1) == l2;
});

gunit::test t4("test4", [](){
  std::list l1 = std::list<int>();
  l1.push_back(10);
  l1.push_back(12);
  l1.push_back(14);

  std::list l2 = std::list<int>();
  l2.push_back(10);
  l2.push_back(22);
  l2.push_back(34);

  gunit::affirm(l1) == l2;
});

gunit::test t5("test5", [](){
  struct a {
    int b;
    char c;
    char d;
    char e;
    char f;
  };

  struct a one(10, 'a', 'e', 'i', 'o');
  struct a two(10, 'a', 'e', 'i', 'o');

  gunit::affirm(one) == two;
});

gunit::test t6("test6", [](){
  struct a {
    int b;
    char c;
    char d;
    char e;
    char f;
  };

  struct a one(10, 'a', 'e', 'i', 'o');
  struct a two(22, 'x', 'e', 'o', 'm');

  gunit::affirm(one) == two;
});

gunit::test t7("test7", [](){
  gunit::affirm(10) > 5;
  gunit::affirm(10) >= 10;
  gunit::affirm(10) <= 10;
  gunit::affirm(10) <= 15;
  gunit::affirm(1.0) == 1.0;
  gunit::affirm(2.0) != 1.0;
});

int main() {
  gunit::suite::run(); // The test are added into the global test list on creation of the test struct
  gunit::end();        // Signal the end of the unit test
  while(1);
}

Release files for gunit 0.1.59

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gunit 0.1.59
File Size Uploaded
gunit-0.1.59.tar.gz 6.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gunit 0.1.59
File Interpreter ABI Platform
gunit-0.1.59-py3-none-any.whl Python 3 none any Details

Total release size: 14.6 kB

Release files / gunit-0.1.59.tar.gz

Download URL gunit-0.1.59.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d2df0da44eaffe63ac5b3dde5ae752f1b432eb12285b59f4d3ca48d96cd1ddb7
BLAKE2b-256 checksum
How to use checksums
3e6051ca21714a1455020d0b97c59328cee327c7e57e78debeffc726c9f6fb7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.10

Release files / gunit-0.1.59-py3-none-any.whl

Download URL gunit-0.1.59-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b03704fe0b206b740086d52f4ad8f3062f90044a5bfe11ac3fc0d21ab5973ba2
BLAKE2b-256 checksum
How to use checksums
b2496b5c7868ffdf96ff7196592ca3bbf598624b14dfa159852ce7e40a994d0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.1.59 This release

2 release files

0.1.58

2 release files

0.1.57

2 release files

0.1.56

2 release files

0.1.54

2 release files

0.1.53

2 release files

0.1.52

2 release files

0.1.47

2 release files

0.1.46

2 release files

0.1.45

2 release files

0.1.44

2 release files

0.1.43

2 release files

0.1.42

2 release files

0.1.41

2 release files

0.1.40

2 release files

0.1.39

2 release files

0.1.38

2 release files

0.1.37

2 release files

0.1.36

2 release files

0.1.35

2 release files

0.1.34

2 release files

0.1.33

2 release files

0.1.32

2 release files

0.1.31

2 release files

0.1.30

2 release files

0.1.29

2 release files

0.1.28

2 release files

0.1.27

2 release files

0.1.26

2 release files

0.1.25

2 release files

0.1.24

2 release files

0.1.23

2 release files

0.1.22

2 release files

0.1.21

2 release files

0.1.20

2 release files

0.1.19

2 release files

0.1.18

2 release files

0.1.17

2 release files

0.1.16

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page