fix: memory leaks in tests

Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
Rachel Powers 2023-07-03 20:04:24 -07:00
parent c5705705d5
commit 3c96d5e0d5
No known key found for this signature in database
GPG Key ID: E10E321EB160949B
3 changed files with 28 additions and 13 deletions

View File

@ -91,16 +91,25 @@ option(DEBUG_ADDRESS_SANITIZER "Enable Address Sanitizer in Debug builds" on)
if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND DEBUG_ADDRESS_SANITIZER) if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND DEBUG_ADDRESS_SANITIZER)
message(STATUS "Address Sanitizer enabeled for Debug builds, Turn it off with -DDEBUG_ADDRESS_SANITIZER=off") message(STATUS "Address Sanitizer enabeled for Debug builds, Turn it off with -DDEBUG_ADDRESS_SANITIZER=off")
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
# AppleClang and Clang if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -faddress-sanitizer -O1 -fno-omit-frame-pointer") # using clang with clang-cl front end
message(STATUS "Address Sanitizer available on Clang MSVC frontend")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fsanitize=address /O1 /Oy-")
else()
# AppleClang and Clang
message(STATUS "Address Sanitizer available on Clang")
set(cmake_cxx_flags "${cmake_cxx_flags} -fsanitize=address -O1 -fno-omit-frame-pointer")
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# GCC # GCC
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -O1 -fno-omit-frame-pointer") message(STATUS "Address Sanitizer available on GCC")
set(cmake_cxx_flags "${cmake_cxx_flags} -fsanitize=address -O1 -fno-omit-frame-pointer")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
# Intell compiler ? why? # Intell compiler ? why?
# no address sanitiser here though # no address sanitiser here though
message(STATUS "Address Sanitizer not available on Intell compilers") message(STATUS "Address Sanitizer not available on Intell compilers")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
message(STATUS "Address Sanitizer available on MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fsanitize=address /O1 /Oy-") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fsanitize=address /O1 /Oy-")
else() else()
message(STATUS "Address Sanitizer not available on unknown compiler ${CMAKE_CXX_COMPILER_ID}") message(STATUS "Address Sanitizer not available on unknown compiler ${CMAKE_CXX_COMPILER_ID}")

View File

@ -80,6 +80,7 @@ class BigConcurrentTaskThread : public QThread {
QCoreApplication::processEvents(); QCoreApplication::processEvents();
emit finished(); emit finished();
delete[] sub_tasks;
} }
public: public:

View File

@ -20,6 +20,8 @@
class VersionTest : public QObject { class VersionTest : public QObject {
Q_OBJECT Q_OBJECT
QStringList m_flex_test_names = {};
void addDataColumns() void addDataColumns()
{ {
QTest::addColumn<QString>("first"); QTest::addColumn<QString>("first");
@ -101,8 +103,9 @@ class VersionTest : public QObject {
QString first{split_line.first().simplified()}; QString first{split_line.first().simplified()};
QString second{split_line.last().simplified()}; QString second{split_line.last().simplified()};
auto new_test_name = test_name_template.arg(QString::number(test_number), "lessThan").toLatin1().data(); auto new_test_name = test_name_template.arg(QString::number(test_number), "lessThan");
QTest::newRow(new_test_name) << first << second << true << false; m_flex_test_names.append(new_test_name);
QTest::newRow(m_flex_test_names.last().toLatin1().data()) << first << second << true << false;
continue; continue;
} }
@ -112,8 +115,9 @@ class VersionTest : public QObject {
QString first{split_line.first().simplified()}; QString first{split_line.first().simplified()};
QString second{split_line.last().simplified()}; QString second{split_line.last().simplified()};
auto new_test_name = test_name_template.arg(QString::number(test_number), "equals").toLatin1().data(); auto new_test_name = test_name_template.arg(QString::number(test_number), "equals");
QTest::newRow(new_test_name) << first << second << false << true; m_flex_test_names.append(new_test_name);
QTest::newRow(m_flex_test_names.last().toLatin1().data()) << first << second << false << true;
continue; continue;
} }
@ -123,8 +127,9 @@ class VersionTest : public QObject {
QString first{split_line.first().simplified()}; QString first{split_line.first().simplified()};
QString second{split_line.last().simplified()}; QString second{split_line.last().simplified()};
auto new_test_name = test_name_template.arg(QString::number(test_number), "greaterThan").toLatin1().data(); auto new_test_name = test_name_template.arg(QString::number(test_number), "greaterThan");
QTest::newRow(new_test_name) << first << second << false << false; m_flex_test_names.append(new_test_name);
QTest::newRow(m_flex_test_names.last().toLatin1().data()) << first << second << false << false;
continue; continue;
} }
@ -140,10 +145,10 @@ class VersionTest : public QObject {
void test_flexVerTestVector() void test_flexVerTestVector()
{ {
QFETCH(QString, first); QString first = *static_cast<QString*>(QTest ::qData("first", ::qMetaTypeId<typename std ::remove_cv<QString>::type>()));
QFETCH(QString, second); QString second = *static_cast<QString*>(QTest ::qData("second", ::qMetaTypeId<typename std ::remove_cv<QString>::type>()));
QFETCH(bool, lessThan); bool lessThan = *static_cast<bool*>(QTest ::qData("lessThan", ::qMetaTypeId<typename std ::remove_cv<bool>::type>()));
QFETCH(bool, equal); bool equal = *static_cast<bool*>(QTest ::qData("equal", ::qMetaTypeId<typename std ::remove_cv<bool>::type>()));
const auto v1 = Version(first); const auto v1 = Version(first);
const auto v2 = Version(second); const auto v2 = Version(second);