Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ci] Add cpp tests compiled via gcc on Linux #6315

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vsts-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ jobs:
METHOD: source
swig:
TASK: swig
cpp_tests:
TASK: cpp-tests
METHOD: with-sanitizers
steps:
- script: |
echo "##vso[task.setvariable variable=BUILD_DIRECTORY]$BUILD_SOURCESDIRECTORY"
Expand Down
7 changes: 3 additions & 4 deletions include/LightGBM/utils/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,16 @@
#if defined(_MSC_VER)
#include <malloc.h>
#elif MM_MALLOC
#include <mm_malloc.h>
#include <mm_malloc.h>
// https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
// https://www.oreilly.com/library/view/mac-os-x/0596003560/ch05s01s02.html
#elif defined(__GNUC__) && defined(HAVE_MALLOC_H)
#include <malloc.h>
#define _mm_malloc(a, b) memalign(b, a)
#define _mm_free(a) free(a)
#else
#include <stdlib.h>
#define _mm_malloc(a, b) malloc(a)
#define _mm_free(a) free(a)
#define _mm_malloc(a, b) malloc(a)
#define _mm_free(a) free(a)
#endif

namespace LightGBM {
Expand Down
23 changes: 8 additions & 15 deletions tests/cpp_tests/test_arrow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,7 @@ class ArrowChunkedArrayTest : public testing::Test {

/* ------------------------------------- SCHEMA CREATION ------------------------------------- */

template <typename T>
ArrowSchema create_primitive_schema() {
std::logic_error("not implemented");
}

template <>
ArrowSchema create_primitive_schema<float>() {
ArrowSchema create_primitive_schema_float() {
ArrowSchema schema;
schema.format = "f";
schema.name = nullptr;
Expand All @@ -171,8 +165,7 @@ class ArrowChunkedArrayTest : public testing::Test {
return schema;
}

template <>
ArrowSchema create_primitive_schema<bool>() {
ArrowSchema create_primitive_schema_bool() {
ArrowSchema schema;
schema.format = "b";
schema.name = nullptr;
Expand Down Expand Up @@ -213,7 +206,7 @@ class ArrowChunkedArrayTest : public testing::Test {
/* --------------------------------------------------------------------------------------------- */

TEST_F(ArrowChunkedArrayTest, GetLength) {
auto schema = create_primitive_schema<float>();
auto schema = create_primitive_schema_float();

std::vector<float> dat1 = {1, 2};
auto arr1 = create_primitive_array(dat1);
Expand Down Expand Up @@ -241,8 +234,8 @@ TEST_F(ArrowChunkedArrayTest, GetColumns) {
std::vector<ArrowArray*> arrs = {&arr1, &arr2};
auto arr = created_nested_array(arrs);

auto schema1 = create_primitive_schema<float>();
auto schema2 = create_primitive_schema<float>();
auto schema1 = create_primitive_schema_float();
auto schema2 = create_primitive_schema_float();
std::vector<ArrowSchema*> schemas = {&schema1, &schema2};
auto schema = create_nested_schema(schemas);

Expand All @@ -266,7 +259,7 @@ TEST_F(ArrowChunkedArrayTest, IteratorArithmetic) {
auto arr2 = create_primitive_array(dat2);
std::vector<float> dat3 = {7};
auto arr3 = create_primitive_array(dat3);
auto schema = create_primitive_schema<float>();
auto schema = create_primitive_schema_float();

ArrowArray arrs[3] = {arr1, arr2, arr3};
ArrowChunkedArray ca(3, arrs, &schema);
Expand Down Expand Up @@ -302,7 +295,7 @@ TEST_F(ArrowChunkedArrayTest, BooleanIterator) {
auto arr1 = create_primitive_array(dat1, 0, {2});
std::vector<bool> dat2 = {false, false, false, false, true, true, true, true, false, true};
auto arr2 = create_primitive_array(dat2, 1);
auto schema = create_primitive_schema<bool>();
auto schema = create_primitive_schema_bool();

ArrowArray arrs[2] = {arr1, arr2};
ArrowChunkedArray ca(2, arrs, &schema);
Expand All @@ -328,7 +321,7 @@ TEST_F(ArrowChunkedArrayTest, BooleanIterator) {
TEST_F(ArrowChunkedArrayTest, OffsetAndValidity) {
std::vector<float> dat = {0, 1, 2, 3, 4, 5, 6};
auto arr = create_primitive_array(dat, 2, {2, 3});
auto schema = create_primitive_schema<float>();
auto schema = create_primitive_schema_float();
ArrowChunkedArray ca(1, &arr, &schema);

auto it = ca.begin<double>();
Expand Down
Loading