Skip to content

Commit 65148be

Browse files
authored
Properly register libuv scheduler in ObjectStore tests (#6699)
* Properly register libuv scheduler in ObjectStore tests * remove uv stubs in realm-fuzzer * changelog
1 parent 22fd7a3 commit 65148be

File tree

7 files changed

+17
-21
lines changed

7 files changed

+17
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
### Internals
1919
* Update History Command tool to work with realms with fileformat v23 ([PR #6970](https://github.com/realm/realm-core/pull/6970))
20+
* Don't edit the ObjectStore target to enable the libuv scheduler in tests, just register the factory instead. ([PR #6699](https://github.com/realm/realm-core/pull/6699))
2021

2122
----------------------------------------------
2223

test/object-store/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,7 @@ if(NOT APPLE AND NOT EMSCRIPTEN AND NOT WINDOWS_STORE)
193193
endif()
194194

195195
target_link_libraries(ObjectStoreTests ${libuv_target})
196-
# FIXME: ObjectStore itself shouldn't care about this, but we need to refactor scheduler.cpp to make it happen
197-
target_compile_definitions(ObjectStore PUBLIC REALM_HAVE_UV=1)
198-
get_property(libuv_include_dir TARGET ${libuv_target} PROPERTY INCLUDE_DIRECTORIES)
199-
target_include_directories(ObjectStore PRIVATE ${libuv_include_dir})
196+
target_compile_definitions(ObjectStoreTests PRIVATE TEST_SCHEDULER_UV=1)
200197

201198
if (MSVC)
202199
get_target_property(comp_opts ${libuv_target} COMPILE_OPTIONS)

test/object-store/main.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
#include <realm/util/features.h>
2323
#include <realm/util/to_string.hpp>
2424

25+
#if TEST_SCHEDULER_UV
26+
#include <realm/object-store/util/uv/scheduler.hpp>
27+
#endif
28+
2529
#include <catch2/catch_all.hpp>
2630
#include <catch2/reporters/catch_reporter_cumulative_base.hpp>
2731
#include <catch2/catch_test_case_info.hpp>
@@ -72,6 +76,12 @@ int main(int argc, const char** argv)
7276
}
7377
}
7478

79+
#if TEST_SCHEDULER_UV
80+
realm::util::Scheduler::set_default_factory([]() {
81+
return std::make_shared<realm::util::UvMainLoopScheduler>();
82+
});
83+
#endif
84+
7585
Catch::Session session;
7686
session.useConfigData(config);
7787
int result = session.run(argc, argv);

test/object-store/util/event_loop.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <stdexcept>
2727
#include <vector>
2828

29-
#if REALM_USE_UV
29+
#if TEST_SCHEDULER_UV
3030
#include <uv.h>
3131
#elif REALM_PLATFORM_APPLE
3232
#include <realm/util/cf_ptr.hpp>
@@ -87,7 +87,7 @@ struct EventLoop::Impl {
8787
~Impl();
8888

8989
private:
90-
#if REALM_USE_UV
90+
#if TEST_SCHEDULER_UV
9191
Impl(uv_loop_t* loop);
9292

9393
std::vector<util::UniqueFunction<void()>> m_pending_work;
@@ -132,7 +132,7 @@ void EventLoop::run_pending()
132132
return m_impl->run_pending();
133133
}
134134

135-
#if REALM_USE_UV
135+
#if TEST_SCHEDULER_UV
136136

137137
bool EventLoop::has_implementation()
138138
{

test/realm-fuzzer/CMakeLists.txt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,3 @@ if(REALM_LIBFUZZER)
3232
target_link_libraries(realm-libfuzz TestUtil ObjectStore)
3333
endif()
3434
endif()
35-
36-
# on Apple platforms we use the built-in CFRunLoop
37-
# everywhere else it's libuv, except UWP where it doesn't build
38-
if(NOT APPLE AND NOT WINDOWS_STORE)
39-
target_link_libraries(realm-afl++ uv_a)
40-
if(REALM_LIBFUZZER)
41-
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
42-
target_link_libraries(realm-libfuzz uv_a)
43-
endif()
44-
endif()
45-
endif()

test/realm-fuzzer/fuzz_configurator.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "fuzz_configurator.hpp"
1919
#include "fuzz_object.hpp"
2020
#include "../util/test_path.hpp"
21+
#include <realm/object-store/util/scheduler.hpp>
2122

2223
FuzzConfigurator::FuzzConfigurator(FuzzObject& fuzzer, const std::string& input, bool use_input_file,
2324
const std::string& name)
@@ -34,6 +35,7 @@ void FuzzConfigurator::setup_realm_config()
3435
{
3536
m_config.path = m_path;
3637
m_config.schema_version = 0;
38+
m_config.scheduler = realm::util::Scheduler::make_dummy();
3739
if (m_use_encryption) {
3840
const char* key = m_fuzzer.get_encryption_key();
3941
const char* i = key;

test/realm-fuzzer/fuzz_engine.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
#include <cstring>
2626
#include <fstream>
2727
#include <cstdlib>
28-
#if REALM_USE_UV
29-
#include <uv.h>
30-
#endif
3128

3229
class FuzzConfigurator;
3330
class FuzzEngine {

0 commit comments

Comments
 (0)