Skip to content

Commit

Permalink
Revert "Merge pull request #255 from fnadeau/bugfix/cgreen-runner_nm_…
Browse files Browse the repository at this point in the history
…parsing"

This reverts commit a9fb016, reversing
changes made to 9314651.
  • Loading branch information
thoni56 committed Jun 29, 2022
1 parent d77d9d8 commit d5b4e61
Show file tree
Hide file tree
Showing 22 changed files with 551 additions and 1,014 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ addons:
- cmake
- lcov
- g++
- binutils-dev
- libiberty-dev
- valgrind

before_install:
Expand Down
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,18 @@ endif()
include(ConfigureChecks.cmake)
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)

# check subdirectories
add_subdirectory(src)
# Dependency on our own library so we can use CGREEN_LIBRARY in all subdirectories
if (CGREEN_WITH_STATIC_LIBRARY)
set(CGREEN_LIBRARY ${CGREEN_STATIC_LIBRARY})
else ()
set(CGREEN_LIBRARY ${CGREEN_SHARED_LIBRARY})
endif()

# check subdirectories
add_subdirectory(src)
add_subdirectory(doc)
add_subdirectory(include)

if (UNIX OR MSYS)
# reflective runner only supported on UNIX/binutils platforms
add_subdirectory(tools)
Expand Down
1 change: 0 additions & 1 deletion DefineOptions.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
option(CGREEN_WITH_STATIC_LIBRARY "Build with a static library" OFF)
option(CGREEN_WITH_UNIT_TESTS "Build unit tests" ON)
option(CGREEN_BUILD_RUNNER "Build auto-discovering cgreen-runner using libbfd" ON)
option(CGREEN_INTERNAL_WITH_GCOV "Build with test coverage instrumentation" OFF)
mark_as_advanced(CGREEN_INTERNAL_WITH_GCOV)
72 changes: 40 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,31 +90,29 @@ DIFF_TOOL_ARGUMENTS = $(1)_tests \

.PHONY: unit
unit: build-it
if [ -f build/tools/cgreen-runner ]; then \
cd build ; \
$(LDPATH) tools/cgreen-runner -c `find tests -name $(PREFIX)cgreen_c_tests$(SUFFIX)` ; \
r=$$((r + $$?)) ; \
$(LDPATH) tools/cgreen-runner -c `find tests -name $(PREFIX)cgreen_cpp_tests$(SUFFIX)` ; \
r=$$((r + $$?)) ; \
$(LDPATH) tools/cgreen-runner -c `find tools/tests -name $(PREFIX)cgreen_runner_tests$(SUFFIX)` ; \
r=$$((r + $$?)) ; \
cd tests ; \
$(LDPATH) $(XML_DIFF_TOOL) $(call DIFF_TOOL_ARGUMENTS,xml_output) ; \
r=$$((r + $$?)) ; \
$(LDPATH) $(DIFF_TOOL) $(call DIFF_TOOL_ARGUMENTS,assertion_messages) ; \
r=$$((r + $$?)) ; \
$(LDPATH) $(DIFF_TOOL) $(call DIFF_TOOL_ARGUMENTS,mock_messages) ; \
r=$$((r + $$?)) ; \
$(LDPATH) $(DIFF_TOOL) $(call DIFF_TOOL_ARGUMENTS,constraint_messages) ; \
r=$$((r + $$?)) ; \
$(LDPATH) $(DIFF_TOOL) $(call DIFF_TOOL_ARGUMENTS,custom_constraint_messages) ; \
r=$$((r + $$?)) ; \
$(LDPATH) $(DIFF_TOOL) $(call DIFF_TOOL_ARGUMENTS,ignore_messages) ; \
r=$$((r + $$?)) ; \
$(LDPATH) CGREEN_PER_TEST_TIMEOUT=1 $(DIFF_TOOL) $(call DIFF_TOOL_ARGUMENTS,failure_messages) ; \
r=$$((r + $$?)) ; \
exit $$r; \
fi
cd build ; \
$(LDPATH) tools/cgreen-runner -c `find tests -name $(PREFIX)cgreen_c_tests$(SUFFIX)` ; \
r=$$((r + $$?)) ; \
$(LDPATH) tools/cgreen-runner -c `find tests -name $(PREFIX)cgreen_cpp_tests$(SUFFIX)` ; \
r=$$((r + $$?)) ; \
$(LDPATH) tools/cgreen-runner -c `find tools/tests -name $(PREFIX)cgreen_runner_tests$(SUFFIX)` ; \
r=$$((r + $$?)) ; \
cd tests ; \
$(LDPATH) $(XML_DIFF_TOOL) $(call DIFF_TOOL_ARGUMENTS,xml_output) ; \
r=$$((r + $$?)) ; \
$(LDPATH) $(DIFF_TOOL) $(call DIFF_TOOL_ARGUMENTS,assertion_messages) ; \
r=$$((r + $$?)) ; \
$(LDPATH) $(DIFF_TOOL) $(call DIFF_TOOL_ARGUMENTS,mock_messages) ; \
r=$$((r + $$?)) ; \
$(LDPATH) $(DIFF_TOOL) $(call DIFF_TOOL_ARGUMENTS,constraint_messages) ; \
r=$$((r + $$?)) ; \
$(LDPATH) $(DIFF_TOOL) $(call DIFF_TOOL_ARGUMENTS,custom_constraint_messages) ; \
r=$$((r + $$?)) ; \
$(LDPATH) $(DIFF_TOOL) $(call DIFF_TOOL_ARGUMENTS,ignore_messages) ; \
r=$$((r + $$?)) ; \
$(LDPATH) CGREEN_PER_TEST_TIMEOUT=1 $(DIFF_TOOL) $(call DIFF_TOOL_ARGUMENTS,failure_messages) ; \
r=$$((r + $$?)) ; \
exit $$r

.PHONY: doc
doc: build
Expand All @@ -133,20 +131,30 @@ chunked: doc
asciidoctor-chunker build/doc/cgreen-guide-en.html -o docs
echo open $(PWD)/docs/index.html

############# Internal
.PHONY:build-it
build-it: build/Makefile
cmake --build build
.PHONY:valgrind
valgrind: build-it
@echo -n "Running all tests under Valgrind "
@> valgrind.log
@for lib in `ls build/tests/$(PREFIX)*_tests$(SUFFIX)` ; \
do \
echo -n "." ; \
LD_LIBRARY_PATH=build/src valgrind --leak-check=full build/tools/cgreen-runner $$lib >> valgrind.log 2>&1 ; \
done
@echo
grep --with-filename --line-number " lost: " valgrind.log | grep -v " 0 bytes" ; \
if [ $$? -eq 1 ] ; then echo "Nothing lost" ; fi

build:
mkdir -p build

build/Makefile: | build

############# Internal
.PHONY:build-it
build-it:
ifeq ($(OS),Darwin)
#cmake -DCMAKE_OSX_ARCHITECTURES="arm64e;x86_64" -S . -B build
cmake -S . -B build
else
cmake -S . -B build
endif
$(MAKE) -C build

.SILENT:
37 changes: 3 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,43 +67,12 @@ You can also clone the repository or download the source zip from [GitHub](http:
You need the [CMake](http://www.cmake.org) build system.
Most standard C/C++ compilers should work. GCC definitely does.

Perl, diff, find and sed are required to run unit-tests. Most distro will have
those already installed.

To build cgreen-runner, you need binutils development package. At runtime,
cgreen-runner only requires binutils library. Some distro do not distinguish the
two.

|Distro | Build | Run |
--- | --- | ---
|Arch|bintuils|bintuils|
|Cygwin|cygwin64-libbfd|cygwin64-libbfd|
|Debian|binutils-dev|libbinutils|
|Fedora|bintuils-devel|bintuils-devel|
|OpenSUSE|bintuils-devel|bintuils-devel|
Perl, diff, find and sed are required to run Cgreen's own
unit-tests. Most distro will have those already installed.

In the root directory run ``make``. That will configure and build the
library and the `cgreen-runner`, both supporting both C and C++. See
also the documentation. The later will only be build if build requirements are met.

Here are some example of how to build using docker for various distro:

```
# debian build (will not clean)
$ docker run --rm -v $PWD:/cgreen debian bash -c \
"apt update && apt -y install git cmake gcc g++ binutils-dev && cd /cgreen && make unit test"
# debian run (we cannot use make unit test since cmake will want to recompile)
$ docker run --rm -v $PWD:/cgreen debian bash -c \
'apt update && apt -y install libbinutils && cd /cgreen && ./build/tools/cgreen-runner $(find . -name *.so) rm -rf build'
# Fedora
$ docker run -t --rm -v $PWD:/cgreen fedora bash -c \
"/usr/bin/yum -y install cmake gcc g++ git diffutils findutils && cd /cgreen && make unit test && make clean"
# OpenSUSE
$ docker run --rm -v $PWD:/cgreen opensuse/tumbleweed bash -c \
'/usr/bin/zypper refresh && /usr/bin/zypper --non-interactive install git cmake gcc gcc-c++ git binutils-devel diffutils findutils && cd /cgreen && make unit test && make clean'
```
also the documentation.

## Using It

Expand Down
87 changes: 0 additions & 87 deletions cmake/Modules/FindLibBfd.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion cmake/Modules/FindValgrind.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ if (NOT Valgrind_FOUND)
set(Valgrind_FOUND ${Valgrind_FOUND} CACHE BOOL "Flag whether Valgrind package was found")
mark_as_advanced(Valgrind_FOUND Valgrind_EXECUTABLE)

endif ()
endif()
2 changes: 1 addition & 1 deletion cmake/Modules/MacroAddValgrindTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ macro (macro_add_valgrind_test)
)
set_tests_properties(
valgrind_${libname} PROPERTIES
FAIL_REGULAR_EXPRESSION "(definitely|indirectly|possible) lost: [1-9]"
FAIL_REGULAR_EXPRESSION "(definitely|indirectly|possibly) lost: [1-9]"
)
if (CYGWIN OR WIN32)
set_tests_properties(${ARGV1} PROPERTIES ENVIRONMENT PATH=${PROJECT_BINARY_DIR}/src:$ENV{PATH})
Expand Down
Loading

0 comments on commit d5b4e61

Please sign in to comment.