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
@@ -19,11 +19,11 @@ TEST(gpu_hist_experimental, TestSparseShard) {
|
||||
int max_bins = 4;
|
||||
auto dmat = CreateDMatrix(rows, columns, 0.9f);
|
||||
common::GHistIndexMatrix gmat;
|
||||
gmat.Init(dmat.get(),max_bins);
|
||||
gmat.Init((*dmat).get(),max_bins);
|
||||
TrainParam p;
|
||||
p.max_depth = 6;
|
||||
|
||||
dmlc::DataIter<SparsePage>* iter = dmat->RowIterator();
|
||||
dmlc::DataIter<SparsePage>* iter = (*dmat)->RowIterator();
|
||||
iter->BeforeFirst();
|
||||
CHECK(iter->Next());
|
||||
const SparsePage& batch = iter->Value();
|
||||
@@ -50,6 +50,8 @@ TEST(gpu_hist_experimental, TestSparseShard) {
|
||||
ASSERT_EQ(gidx[i * shard.row_stride + row_offset], shard.null_gidx_value);
|
||||
}
|
||||
}
|
||||
|
||||
delete dmat;
|
||||
}
|
||||
|
||||
TEST(gpu_hist_experimental, TestDenseShard) {
|
||||
@@ -58,11 +60,11 @@ TEST(gpu_hist_experimental, TestDenseShard) {
|
||||
int max_bins = 4;
|
||||
auto dmat = CreateDMatrix(rows, columns, 0);
|
||||
common::GHistIndexMatrix gmat;
|
||||
gmat.Init(dmat.get(),max_bins);
|
||||
gmat.Init((*dmat).get(),max_bins);
|
||||
TrainParam p;
|
||||
p.max_depth = 6;
|
||||
|
||||
dmlc::DataIter<SparsePage>* iter = dmat->RowIterator();
|
||||
dmlc::DataIter<SparsePage>* iter = (*dmat)->RowIterator();
|
||||
iter->BeforeFirst();
|
||||
CHECK(iter->Next());
|
||||
const SparsePage& batch = iter->Value();
|
||||
@@ -82,6 +84,8 @@ TEST(gpu_hist_experimental, TestDenseShard) {
|
||||
for (int i = 0; i < gmat.index.size(); i++) {
|
||||
ASSERT_EQ(gidx[i], gmat.index[i]);
|
||||
}
|
||||
|
||||
delete dmat;
|
||||
}
|
||||
|
||||
} // namespace tree
|
||||
|
||||
Reference in New Issue
Block a user