Add travis sanitizers tests. (#3557)
* Add travis sanitizers tests. * Add gcc-7 in Travis. * Add SANITIZER_PATH for CMake. * Enable sanitizer tests in Travis. * Fix memory leaks in tests. * Fix all memory leaks reported by Address Sanitizer. * tests/cpp/helpers.h/CreateDMatrix now returns raw pointer.
This commit is contained in:
committed by
Rory Mitchell
parent
983cb0b374
commit
cf2d86a4f6
@@ -17,4 +17,6 @@ TEST(Objective, HingeObj) {
|
||||
{ eps, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, eps });
|
||||
|
||||
ASSERT_NO_THROW(obj->DefaultEvalMetric());
|
||||
|
||||
delete obj;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include "../helpers.h"
|
||||
|
||||
TEST(Objective, UnknownFunction) {
|
||||
EXPECT_ANY_THROW(xgboost::ObjFunction::Create("unknown_name"));
|
||||
EXPECT_NO_THROW(xgboost::ObjFunction::Create("reg:linear"));
|
||||
xgboost::ObjFunction* obj;
|
||||
EXPECT_ANY_THROW(obj = xgboost::ObjFunction::Create("unknown_name"));
|
||||
EXPECT_NO_THROW(obj = xgboost::ObjFunction::Create("reg:linear"));
|
||||
delete obj;
|
||||
}
|
||||
|
||||
@@ -25,4 +25,6 @@ TEST(Objective, PairwiseRankingGPair) {
|
||||
{0.9975f, 0.9975f, 0.9975f, 0.9975f});
|
||||
|
||||
ASSERT_NO_THROW(obj->DefaultEvalMetric());
|
||||
}
|
||||
|
||||
delete obj;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ TEST(Objective, LinearRegressionGPair) {
|
||||
{1, 1, 1, 1, 1, 1, 1, 1});
|
||||
|
||||
ASSERT_NO_THROW(obj->DefaultEvalMetric());
|
||||
|
||||
delete obj;
|
||||
}
|
||||
|
||||
TEST(Objective, LogisticRegressionGPair) {
|
||||
@@ -27,6 +29,8 @@ TEST(Objective, LogisticRegressionGPair) {
|
||||
{ 1, 1, 1, 1, 1, 1, 1, 1},
|
||||
{ 0.5f, 0.52f, 0.71f, 0.73f, -0.5f, -0.47f, -0.28f, -0.26f},
|
||||
{0.25f, 0.24f, 0.20f, 0.19f, 0.25f, 0.24f, 0.20f, 0.19f});
|
||||
|
||||
delete obj;
|
||||
}
|
||||
|
||||
TEST(Objective, LogisticRegressionBasic) {
|
||||
@@ -53,6 +57,8 @@ TEST(Objective, LogisticRegressionBasic) {
|
||||
for (int i = 0; i < static_cast<int>(io_preds.Size()); ++i) {
|
||||
EXPECT_NEAR(preds[i], out_preds[i], 0.01f);
|
||||
}
|
||||
|
||||
delete obj;
|
||||
}
|
||||
|
||||
TEST(Objective, LogisticRawGPair) {
|
||||
@@ -65,6 +71,8 @@ TEST(Objective, LogisticRawGPair) {
|
||||
{ 1, 1, 1, 1, 1, 1, 1, 1},
|
||||
{ 0.5f, 0.52f, 0.71f, 0.73f, -0.5f, -0.47f, -0.28f, -0.26f},
|
||||
{0.25f, 0.24f, 0.20f, 0.19f, 0.25f, 0.24f, 0.20f, 0.19f});
|
||||
|
||||
delete obj;
|
||||
}
|
||||
|
||||
TEST(Objective, PoissonRegressionGPair) {
|
||||
@@ -78,6 +86,8 @@ TEST(Objective, PoissonRegressionGPair) {
|
||||
{ 1, 1, 1, 1, 1, 1, 1, 1},
|
||||
{ 1, 1.10f, 2.45f, 2.71f, 0, 0.10f, 1.45f, 1.71f},
|
||||
{1.10f, 1.22f, 2.71f, 3.00f, 1.10f, 1.22f, 2.71f, 3.00f});
|
||||
|
||||
delete obj;
|
||||
}
|
||||
|
||||
TEST(Objective, PoissonRegressionBasic) {
|
||||
@@ -102,6 +112,8 @@ TEST(Objective, PoissonRegressionBasic) {
|
||||
for (int i = 0; i < static_cast<int>(io_preds.Size()); ++i) {
|
||||
EXPECT_NEAR(preds[i], out_preds[i], 0.01f);
|
||||
}
|
||||
|
||||
delete obj;
|
||||
}
|
||||
|
||||
TEST(Objective, GammaRegressionGPair) {
|
||||
@@ -114,6 +126,8 @@ TEST(Objective, GammaRegressionGPair) {
|
||||
{1, 1, 1, 1, 1, 1, 1, 1},
|
||||
{1, 1, 1, 1, 0, 0.09f, 0.59f, 0.63f},
|
||||
{0, 0, 0, 0, 1, 0.90f, 0.40f, 0.36f});
|
||||
|
||||
delete obj;
|
||||
}
|
||||
|
||||
TEST(Objective, GammaRegressionBasic) {
|
||||
@@ -138,6 +152,8 @@ TEST(Objective, GammaRegressionBasic) {
|
||||
for (int i = 0; i < static_cast<int>(io_preds.Size()); ++i) {
|
||||
EXPECT_NEAR(preds[i], out_preds[i], 0.01f);
|
||||
}
|
||||
|
||||
delete obj;
|
||||
}
|
||||
|
||||
TEST(Objective, TweedieRegressionGPair) {
|
||||
@@ -151,6 +167,8 @@ TEST(Objective, TweedieRegressionGPair) {
|
||||
{ 1, 1, 1, 1, 1, 1, 1, 1},
|
||||
{ 1, 1.09f, 2.24f, 2.45f, 0, 0.10f, 1.33f, 1.55f},
|
||||
{0.89f, 0.98f, 2.02f, 2.21f, 1, 1.08f, 2.11f, 2.30f});
|
||||
|
||||
delete obj;
|
||||
}
|
||||
|
||||
TEST(Objective, TweedieRegressionBasic) {
|
||||
@@ -175,6 +193,8 @@ TEST(Objective, TweedieRegressionBasic) {
|
||||
for (int i = 0; i < static_cast<int>(io_preds.Size()); ++i) {
|
||||
EXPECT_NEAR(preds[i], out_preds[i], 0.01f);
|
||||
}
|
||||
|
||||
delete obj;
|
||||
}
|
||||
|
||||
TEST(Objective, CoxRegressionGPair) {
|
||||
@@ -187,4 +207,6 @@ TEST(Objective, CoxRegressionGPair) {
|
||||
{ 1, 1, 1, 1, 1, 1, 1, 1},
|
||||
{ 0, 0, 0, -0.799f, -0.788f, -0.590f, 0.910f, 1.006f},
|
||||
{ 0, 0, 0, 0.160f, 0.186f, 0.348f, 0.610f, 0.639f});
|
||||
|
||||
delete obj;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ TEST(Objective, GPULinearRegressionGPair) {
|
||||
{1, 1, 1, 1, 1, 1, 1, 1});
|
||||
|
||||
ASSERT_NO_THROW(obj->DefaultEvalMetric());
|
||||
|
||||
delete obj;
|
||||
}
|
||||
|
||||
TEST(Objective, GPULogisticRegressionGPair) {
|
||||
@@ -29,6 +31,8 @@ TEST(Objective, GPULogisticRegressionGPair) {
|
||||
{ 1, 1, 1, 1, 1, 1, 1, 1},
|
||||
{ 0.5f, 0.52f, 0.71f, 0.73f, -0.5f, -0.47f, -0.28f, -0.26f},
|
||||
{0.25f, 0.24f, 0.20f, 0.19f, 0.25f, 0.24f, 0.20f, 0.19f});
|
||||
|
||||
delete obj;
|
||||
}
|
||||
|
||||
TEST(Objective, GPULogisticRegressionBasic) {
|
||||
@@ -55,6 +59,8 @@ TEST(Objective, GPULogisticRegressionBasic) {
|
||||
for (int i = 0; i < static_cast<int>(io_preds.Size()); ++i) {
|
||||
EXPECT_NEAR(preds[i], out_preds[i], 0.01f);
|
||||
}
|
||||
|
||||
delete obj;
|
||||
}
|
||||
|
||||
TEST(Objective, GPULogisticRawGPair) {
|
||||
@@ -67,4 +73,6 @@ TEST(Objective, GPULogisticRawGPair) {
|
||||
{ 1, 1, 1, 1, 1, 1, 1, 1},
|
||||
{ 0.5f, 0.52f, 0.71f, 0.73f, -0.5f, -0.47f, -0.28f, -0.26f},
|
||||
{0.25f, 0.24f, 0.20f, 0.19f, 0.25f, 0.24f, 0.20f, 0.19f});
|
||||
|
||||
delete obj;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user