Skip to content

Commit

Permalink
fix(libsinsp/test): exclude other platforms from new tests
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Scolaro <roberto.scolaro21@gmail.com>
  • Loading branch information
therealbobo committed Mar 27, 2024
1 parent 6e055d8 commit 2455fcb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
3 changes: 3 additions & 0 deletions userspace/libsinsp/test/helpers/scoped_file_descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ limitations under the License.
*/

#if defined(__linux__)

#include "scoped_file_descriptor.h"

#include <unistd.h>
Expand Down Expand Up @@ -48,3 +50,4 @@ void scoped_file_descriptor::close()
}
m_closed = true;
}
#endif
3 changes: 3 additions & 0 deletions userspace/libsinsp/test/helpers/scoped_pipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ limitations under the License.
*/

#if defined(__linux__)

#include "scoped_pipe.h"

#include "scoped_file_descriptor.h"
Expand Down Expand Up @@ -60,3 +62,4 @@ void scoped_pipe::close()
m_read_end->close();
m_write_end->close();
}
#endif
16 changes: 12 additions & 4 deletions userspace/libsinsp/test/public_sinsp_API/sinsp_logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ limitations under the License.
*/

#if defined(__linux__)
#include <libsinsp/test/helpers/scoped_file_descriptor.h>
#include <libsinsp/test/helpers/scoped_pipe.h>
#endif

#include <gtest/gtest.h>
#include <libsinsp/sinsp.h>
Expand Down Expand Up @@ -48,6 +50,7 @@ class sinsp_logger_test : public testing::Test
void TearDown() {}

protected:
#if defined(__linux__)
/**
* Counts the number of non-overlapping times the given substr appears
* in the given target string.
Expand Down Expand Up @@ -176,6 +179,7 @@ class sinsp_logger_test : public testing::Test
}
}
}
#endif

/**
* This is used by some tests as the callback logging function.
Expand All @@ -196,6 +200,7 @@ class sinsp_logger_test : public testing::Test
static const std::string& get_callback_output() { return s_cb_output; }

private:
#if define(__linxu__)
/**
* Put the given file descriptor in non-blocking mode.
*
Expand All @@ -211,6 +216,7 @@ class sinsp_logger_test : public testing::Test

ASSERT_TRUE(fcntl(fd, F_SETFL, flags) >= 0);
}
#endif

static std::string s_cb_output;
};
Expand All @@ -219,10 +225,10 @@ std::string sinsp_logger_test::s_cb_output;

} // end namespace

//static void log_callback_fn(std::string&& str, const sinsp_logger::severity sev)
//{
// return;
//}
static void log_callback_fn(std::string&& str, const sinsp_logger::severity sev)
{
return;
}

TEST_F(sinsp_logger_test, constructor)
{
Expand Down Expand Up @@ -271,6 +277,7 @@ TEST_F(sinsp_logger_test, initial_state)
ASSERT_EQ(libsinsp_logger()->get_severity(), sinsp_logger::SEV_INFO);
}

#if defined(__linux__)
/**
* With no enabled log sinks, calls to the logging API should produce no
* output.
Expand Down Expand Up @@ -513,3 +520,4 @@ TEST_F(sinsp_logger_test, log_stderr_multithreaded)
ASSERT_TRUE(dup2(original_stderr, STDERR_FILENO) >= 0);
close(original_stderr);
}
#endif

0 comments on commit 2455fcb

Please sign in to comment.