Skip to content

Commit

Permalink
PR #9338 from Matan: [LibCI] move test functions/variables into test.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
maloel authored Jul 5, 2021
2 parents 3fe95d4 + f640a52 commit c777ea6
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 83 deletions.
1 change: 1 addition & 0 deletions common/utilities/number/stabilized-value.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <atomic>
#include <mutex>
#include <deque>
#include <unordered_map>

namespace utilities {
namespace number {
Expand Down
6 changes: 0 additions & 6 deletions unit-tests/algo/algo-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@
#include "../catch.h"

#include <easylogging++.h>
#ifdef BUILD_SHARED_LIBS
// With static linkage, ELPP is initialized by librealsense, so doing it here will
// create errors. When we're using the shared .so/.dll, the two are separate and we have
// to initialize ours if we want to use the APIs!
INITIALIZE_EASYLOGGINGPP
#endif

#if defined( __ALGO_EPSILON )
#define __EPSILON __ALGO_EPSILON
Expand Down
8 changes: 0 additions & 8 deletions unit-tests/live/d400/test-hdr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@
#include "../../catch.h"
#include "../../unit-tests-common.h"

#include <easylogging++.h>
#ifdef BUILD_SHARED_LIBS
// With static linkage, ELPP is initialized by librealsense, so doing it here will
// create errors. When we're using the shared .so/.dll, the two are separate and we have
// to initialize ours if we want to use the APIs!
INITIALIZE_EASYLOGGINGPP
#endif

using namespace rs2;

// HDR CONFIGURATION TESTS
Expand Down
6 changes: 0 additions & 6 deletions unit-tests/live/extrinsics/test-consistency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
//#test:device SR300*

#include <easylogging++.h>
#ifdef BUILD_SHARED_LIBS
// With static linkage, ELPP is initialized by librealsense, so doing it here will
// create errors. When we're using the shared .so/.dll, the two are separate and we have
// to initialize ours if we want to use the APIs!
INITIALIZE_EASYLOGGINGPP
#endif

#include "../../catch.h"

Expand Down
12 changes: 2 additions & 10 deletions unit-tests/log/log-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,9 @@

#pragma once

#include <librealsense2/rs.hpp> // Include RealSense Cross Platform API

#include "../catch.h"

#include <unit-tests/test.h>
#include <easylogging++.h>
#ifdef BUILD_SHARED_LIBS
// With static linkage, ELPP is initialized by librealsense, so doing it here will
// create errors. When we're using the shared .so/.dll, the two are separate and we have
// to initialize ours if we want to use the APIs!
INITIALIZE_EASYLOGGINGPP
#endif


// Define our own logging macro for debugging to stdout
// Can possibly turn it on automatically based on the Catch options supplied
Expand Down
3 changes: 1 addition & 2 deletions unit-tests/log/test-c-all.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2020 Intel Corporation. All Rights Reserved.

//#cmake:add-file log-common.h
#include "log-common.h"


Expand All @@ -19,7 +18,7 @@ void c_callback( rs2_log_severity severity, rs2_log_message const* msg, void * a
}


TEST_CASE( "Logging C ALL", "[log]" ) {
TEST_CASE( "Logging C ALL" ) {
c_n_callbacks = 0;

// ALL == will log everything
Expand Down
17 changes: 17 additions & 0 deletions unit-tests/test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2021 Intel Corporation. All Rights Reserved.

#include <string>


#include <easylogging++.h>
#ifdef BUILD_SHARED_LIBS
// With static linkage, ELPP is initialized by librealsense, so doing it here will
// create errors. When we're using the shared .so/.dll, the two are separate and we have
// to initialize ours if we want to use the APIs!
INITIALIZE_EASYLOGGINGPP
#endif

namespace test {
std::string context;
}
9 changes: 1 addition & 8 deletions unit-tests/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@ namespace test {
extern std::string context;
}

#include "librealsense2/rs.hpp"
#include <librealsense2/rs.hpp>

#include "catch.h"

#include <easylogging++.h>
#ifdef BUILD_SHARED_LIBS
// With static linkage, ELPP is initialized by librealsense, so doing it here will
// create errors. When we're using the shared .so/.dll, the two are separate and we have
// to initialize ours if we want to use the APIs!
INITIALIZE_EASYLOGGINGPP
#endif
6 changes: 0 additions & 6 deletions unit-tests/types/test-pose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
// Copyright(c) 2020 Intel Corporation. All Rights Reserved.

#include <easylogging++.h>
#ifdef BUILD_SHARED_LIBS
// With static linkage, ELPP is initialized by librealsense, so doing it here will
// create errors. When we're using the shared .so/.dll, the two are separate and we have
// to initialize ours if we want to use the APIs!
INITIALIZE_EASYLOGGINGPP
#endif

#include "../catch.h"

Expand Down
5 changes: 4 additions & 1 deletion unit-tests/unit-test-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def generate_cmake( builddir, testdir, testname, filelist, custom_main ):
set( SRC_FILES ''' + filelist + '''
)
add_executable( ''' + testname + ''' ${SRC_FILES} )
source_group( "Common Files" FILES ${ELPP_FILES} ${CATCH_FILES}''' )
source_group( "Common Files" FILES ${ELPP_FILES} ${CATCH_FILES} ''' + dir + '''/test.cpp''' )
if not custom_main:
handle.write( ' ' + dir + '/unit-test-default-main.cpp' )
handle.write( ''' )
Expand Down Expand Up @@ -254,6 +254,9 @@ def process_cpp( dir, builddir ):
for include in includes:
filelist.append( include )

# all tests use the common test.cpp file
filelist.append( root + "/unit-tests/test.cpp" )

# 'cmake:custom-main' indicates that the test is defining its own main() function.
# If not specified we use a default main() which lives in its own .cpp:
if not custom_main:
Expand Down
8 changes: 1 addition & 7 deletions unit-tests/unit-test-default-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ See below for each of the custom options...

// We are not using the main from catch2
#define CATCH_CONFIG_RUNNER
#include <unit-tests/catch/catch.hpp>
#include <string>
#include <librealsense2/rs.hpp> // rs2::log_to_console

namespace test {
std::string context;
}
#include <unit-tests/test.h>

using namespace Catch::clara;

Expand Down
8 changes: 0 additions & 8 deletions unit-tests/utilities/imgui/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,3 @@

#include "../../catch.h"

#include <easylogging++.h>
#ifdef BUILD_SHARED_LIBS
// With static linkage, ELPP is initialized by librealsense, so doing it here will
// create errors. When we're using the shared .so/.dll, the two are separate and we have
// to initialize ours if we want to use the APIs!
INITIALIZE_EASYLOGGINGPP
#endif

6 changes: 0 additions & 6 deletions unit-tests/utilities/string/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,4 @@
#include "../../catch.h"

#include <easylogging++.h>
#ifdef BUILD_SHARED_LIBS
// With static linkage, ELPP is initialized by librealsense, so doing it here will
// create errors. When we're using the shared .so/.dll, the two are separate and we have
// to initialize ours if we want to use the APIs!
INITIALIZE_EASYLOGGINGPP
#endif

8 changes: 1 addition & 7 deletions unit-tests/utilities/time/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@

#include "../../catch.h"

#include <easylogging++.h>
#ifdef BUILD_SHARED_LIBS
// With static linkage, ELPP is initialized by librealsense, so doing it here will
// create errors. When we're using the shared .so/.dll, the two are separate and we have
// to initialize ours if we want to use the APIs!
INITIALIZE_EASYLOGGINGPP
#endif
#include <thread>

const auto TEST_DELTA_TIME_MS = 500;
const auto TEST_DELTA_TIME = std::chrono::milliseconds(TEST_DELTA_TIME_MS);
8 changes: 0 additions & 8 deletions unit-tests/utilities/time/test-waiting-on.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2021 Intel Corporation. All Rights Reserved.

#include <easylogging++.h>
#ifdef BUILD_SHARED_LIBS
// With static linkage, ELPP is initialized by librealsense, so doing it here will
// create errors. When we're using the shared .so/.dll, the two are separate and we have
// to initialize ours if we want to use the APIs!
INITIALIZE_EASYLOGGINGPP
#endif

#include <unit-tests/catch.h>
#include <common/utilities/time/waiting-on.h>
#include <queue>
Expand Down

0 comments on commit c777ea6

Please sign in to comment.