# we don’t want to use relative paths, so we set these variables
PROJECT_DIR=/home/erling/tdd/lightscheduler
SRC_DIR=$(PROJECT_DIR)/src
TEST_DIR=$(PROJECT_DIR)/test
# specify where the source code and includes are located
INCLUDE_DIRS=$(SRC_DIR)
SRC_DIRS=$(SRC_DIR)
# specify where the test code is located
TEST_SRC_DIRS = $(TEST_DIR)
# what to call the test binary
TEST_TARGET=test_runner.x
# where the cpputest library is located
CPPUTEST_HOME=/home/erling/tdd/cpputest
# run MakefileWorker.mk with the variables defined here
include MakefileWorker.mk
extern "C"
{
#include "LightScheduler.h"
}
#include "CppUTest/TestHarness.h"
TEST_GROUP(LightScheduler)
{
void setup()
{
LightScheduler_Create();
}
void teardown()
{
LightScheduler_Destroy();
}
};
TEST(LightScheduler, Create)
{
FAIL("Start here");
}
> $ make
compiling LightScheduler.c
mkdir -p objs//home/erling/tdd/lightscheduler/src/
cc -g -Wstrict-prototypes -Wall -Wextra -Werror -Wshadow -Wswitch-default -Wswitch-enum -Wconversion -Wno-long-long -pedantic-errors -Wsign-conversion -include /home/erling/tdd/cpputest/include/CppUTest/MemoryLeakDetectorMallocMacros.h -I/home/erling/tdd/lightscheduler/src -c -MMD -MP -o objs//home/erling/tdd/lightscheduler/src/LightScheduler.o /home/erling/tdd/lightscheduler/src/LightScheduler.c
Building archive lib/libname_this_in_the_makefile.a
mkdir -p lib/
ar rvc lib/libname_this_in_the_makefile.a objs//home/erling/tdd/lightscheduler/src/LightScheduler.o objs//home/erling/tdd/lightscheduler/src/main.o
r - objs//home/erling/tdd/lightscheduler/src/LightScheduler.o
r - objs//home/erling/tdd/lightscheduler/src/main.o
ranlib lib/libname_this_in_the_makefile.a
Linking test_runner.x
g++ -o test_runner.x objs//home/erling/tdd/lightscheduler/test/AllTests.o objs//home/erling/tdd/lightscheduler/test/LightSchedulerTest.o lib/libname_this_in_the_makefile.a /home/erling/tdd/cpputest/lib/libCppUTest.a -g
START_TIME=1587396244
rm -f objs//home/erling/tdd/lightscheduler/src/LightScheduler.gcda objs//home/erling/tdd/lightscheduler/src/main.gcda objs//home/erling/tdd/lightscheduler/test/AllTests.gcda objs//home/erling/tdd/lightscheduler/test/LightSchedulerTest.gcda gcov_output.txt gcov_report.txt gcov_error.txt ; echo "Running test_runner.x"; ./test_runner.x
Running test_runner.x
Segmentation fault (core dumped)
Makefile:25: recipe for target 'run' failed
make[1]: *** [run] Error 139
make[1]: Leaving directory '/home/erling/tdd/lightscheduler/test'
Makefile:16: recipe for target 'test' failed
make: *** [test] Error 2
Program received signal SIGSEGV, Segmentation fault.
0x0000555555567705 in UtestShell::destroyTest (
this=0x55555577c1c0 <TEST_LightScheduler_Create_TestShell_instance>, test=0x1) at src/CppUTest/Utest.cpp:195
195 delete test;
--
You received this message because you are subscribed to the Google Groups "cpputest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cpputest+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cpputest/892eebed-17ce-48dc-ad3a-86efd77d94c4%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cpputest/CAFmdjq1yX4PMC8tA%3DVY_FLM8Hxb9aLH7Qe9EU%3DOL%2BzSQVvt68w%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cpputest/CA%2BViiWehGHRH4G%3DDmzXQKmkpABmqebP1q6ut2LP7canqdOty%3Dw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cpputest/CAMHLqDkwMJfE-YWJ7PgqNpX977sgRjd6uPGJVH93x0%3Dn5A11%2BQ%40mail.gmail.com.
Hi Erling
Your main is a c file. Try changing it to main.cpp and add this content.
#include "CppUTest/CommandLineTestRunner.h"
int main(int ac, char** av)
{
return RUN_ALL_TESTS(ac, av);
}
HTH
James Grenning - Author of TDD for Embedded C - wingman-sw.com/tddec
wingman-sw.com
wingman-sw.com/blog
twitter.com/jwgrenning
facebook.com/wingman.sw
To view this discussion on the web visit https://groups.google.com/d/msgid/cpputest/CA%2BViiWcyX3m1Jm_FW8yfg6a7MQ8acHQxbBo2bJC6RmbPo2%2BEiA%40mail.gmail.com.