Commit 40ef5ee1 authored by Philipp  Trunschke's avatar Philipp Trunschke

Merge branch 'development' of git.hemio.de:xerus/xerus into development

parents 09a02788 57fbdeda
Pipeline #1208 passed with stages
in 13 minutes and 35 seconds
......@@ -298,9 +298,13 @@ test:
@cat build/build_output.txt | grep "‘EnumMarker’ is deprecated" > build/required_tests.txt
./$(TEST_NAME) all
else
MAKE_PID := $(shell echo $$PPID)
JOB_FLAG := $(filter -j%, $(subst -j ,-j,$(shell ps T | grep "^\s*$(MAKE_PID).*$(MAKE)")))
test:
mkdir -p build
make $(TEST_NAME) &> build/build_output.txt
make $(TEST_NAME) $(JOB_FLAG) &> build/build_output.txt
@cat build/build_output.txt | grep "‘EnumMarker’ is deprecated" > build/required_tests.txt
./$(TEST_NAME) all
endif
......
......@@ -45,16 +45,16 @@
*/
#define XERUS_REQUIRE_TEST \
do { \
static const char * const xerusCCLocalFunctionLocation = LOCATION;\
static const char * const xerusCCLocalFunctionName = __PRETTY_FUNCTION__;\
\
struct xerus_test_a{ static void rt() {\
xerus::misc::CodeCoverage::register_test(LOCATION, xerusCCLocalFunctionName);\
} };\
using xerus_test_t = void (*)(); \
static xerus_test_t xerus_test_rtp __attribute__((section(".init_array"))) = &xerus_test_a::rt; \
(void) xerus_test_rtp; \
\
xerus::misc::CodeCoverage::covered(LOCATION, xerusCCLocalFunctionName); \
__asm__( \
".pushsection .cc_loc, \"a\", @progbits" "\n" \
".quad %c0" "\n" \
".quad %c1" "\n" \
".popsection" "\n" \
: : "i"(xerusCCLocalFunctionLocation), "i"(xerusCCLocalFunctionName) \
); \
xerus::misc::CodeCoverage::covered(xerusCCLocalFunctionLocation, xerusCCLocalFunctionName); \
\
XERUS_CC_MARK_WARNING \
} while(false)
......
......@@ -196,7 +196,7 @@ namespace xerus { namespace misc { namespace internal {
}
} // namespace misc
} // namespace xerus
} // namespace xerus
#else // No fancy callstack
#include <execinfo.h>
......
......@@ -71,17 +71,29 @@ namespace xerus { namespace misc { namespace CodeCoverage {
// requiredTests[file][lineNumber][functionIdentifier]
std::map<std::string, std::map<size_t, std::map<std::string, bool>>> requiredTests;
for(const auto& localTests : *testsRequiredInit) {
const auto locationParts = misc::explode(localTests.first, ':');
REQUIRE(locationParts.size() == 2, "Error parsing the required tests.");
// Load required tests from .cc_loc section
auto range = get_range_of_section(reinterpret_cast<void*>(&print_code_coverage) /* ie inside this executable */, ".cc_loc");
auto step = sizeof(uintptr_t);
size_t count = 0;
for (auto p = range.first; p < range.second; p += 2*step) {
char * loc = reinterpret_cast<char *>(*reinterpret_cast<uintptr_t*>(p));
const auto locationParts = misc::explode(loc, ':');
if (locationParts.size() != 2) {
LOG(warning, "i don't understand the required test location: '" << loc << "'");
continue;
}
const auto file = xerus::misc::normalize_pathname(locationParts[0]);
const auto lineNumber = xerus::misc::from_string<size_t>(locationParts[1]);
for(const auto& identifier : localTests.second) {
requiredTests[file][lineNumber][identifier] = false;
char * name = reinterpret_cast<char *>(*reinterpret_cast<uintptr_t*>(p+step));
if (requiredTests.count(file) == 0 || requiredTests[file].count(lineNumber) == 0 || requiredTests[file][lineNumber].count(name) == 0) {
requiredTests[file][lineNumber][name] = false;
count += 1;
}
// LOG(codeCoverage, count << " " << file << ":" << lineNumber);
}
// Load further required tests
try{
const auto testLines = xerus::misc::explode(xerus::misc::read_file("build/required_tests.txt"), '\n');
for(const auto& line : testLines) {
......@@ -95,6 +107,7 @@ namespace xerus { namespace misc { namespace CodeCoverage {
requiredTests[file][lineNumber][unknownName] = false;
}
}
} catch(...) {}
// Assing covered tests to required ones
for( const auto &test : *testsCovered ) {
......@@ -103,11 +116,14 @@ namespace xerus { namespace misc { namespace CodeCoverage {
const auto file = xerus::misc::normalize_pathname(locationParts[0]);
const auto lineNumber = xerus::misc::from_string<size_t>(locationParts[1]);
for( const auto& identifier : test.second ) {
REQUIRE(requiredTests.count(file) > 0 && requiredTests.at(file).count(lineNumber) > 0 && (requiredTests.at(file).at(lineNumber).count(identifier) > 0 || requiredTests.at(file).at(lineNumber).count(unknownName) > 0), "Test for: " << file << ":" << lineNumber << "( " << identifier << " ) is not required???");
if(requiredTests.at(file).at(lineNumber).count(unknownName) > 0) {
requiredTests[file][lineNumber][unknownName] = true;
if (requiredTests.count(file) > 0 && requiredTests.at(file).count(lineNumber) > 0 && (requiredTests.at(file).at(lineNumber).count(identifier) > 0 || requiredTests.at(file).at(lineNumber).count(unknownName) > 0)) {
if(requiredTests.at(file).at(lineNumber).count(unknownName) > 0) {
requiredTests[file][lineNumber][unknownName] = true;
} else {
requiredTests[file][lineNumber][identifier] = true;
}
} else {
requiredTests[file][lineNumber][identifier] = true;
LOG(warning, "Test for: " << file << ":" << lineNumber << "( " << identifier << " ) is not required???");
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment