aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2025-03-13 12:31:16 +0100
committerBenoit Germain <benoit.germain@ubisoft.com>2025-03-13 12:31:16 +0100
commitc0555fd48ee1f56c9ea6f8df99af97f78bdcf6ce (patch)
tree2d176f8d2acc914fb38949893e76858c13843bf8
parentfb03f0e208801406400334014ebcf453ff6f1db0 (diff)
downloadlanes-c0555fd48ee1f56c9ea6f8df99af97f78bdcf6ce.tar.gz
lanes-c0555fd48ee1f56c9ea6f8df99af97f78bdcf6ce.tar.bz2
lanes-c0555fd48ee1f56c9ea6f8df99af97f78bdcf6ce.zip
Disable unit test "lanes.stack checker" in Release builds
-rw-r--r--src/debug.hpp1
-rw-r--r--unit_tests/scripts/lane/uncooperative_shutdown.lua2
-rw-r--r--unit_tests/shared.cpp27
3 files changed, 23 insertions, 7 deletions
diff --git a/src/debug.hpp b/src/debug.hpp
index 66541c0..9ebea1f 100644
--- a/src/debug.hpp
+++ b/src/debug.hpp
@@ -40,6 +40,7 @@ class StackChecker final
40 DECLARE_UNIQUE_TYPE(Relative, int); 40 DECLARE_UNIQUE_TYPE(Relative, int);
41 DECLARE_UNIQUE_TYPE(Absolute, int); 41 DECLARE_UNIQUE_TYPE(Absolute, int);
42 42
43 // offer a way to bypass C assert during unit testing
43 static inline bool CallsCassert{ true }; 44 static inline bool CallsCassert{ true };
44 45
45 StackChecker(lua_State* const L_, Relative const offset_, SourceLocation const& where_ = Where()) 46 StackChecker(lua_State* const L_, Relative const offset_, SourceLocation const& where_ = Where())
diff --git a/unit_tests/scripts/lane/uncooperative_shutdown.lua b/unit_tests/scripts/lane/uncooperative_shutdown.lua
index ce7df57..56c936b 100644
--- a/unit_tests/scripts/lane/uncooperative_shutdown.lua
+++ b/unit_tests/scripts/lane/uncooperative_shutdown.lua
@@ -12,7 +12,7 @@ local lane = function()
12end 12end
13 13
14-- the generator 14-- the generator
15local g1 = lanes.gen("*", lane) 15local g1 = lanes.gen("*", {name = "auto"}, lane)
16 16
17-- launch lane 17-- launch lane
18local h1 = g1() 18local h1 = g1()
diff --git a/unit_tests/shared.cpp b/unit_tests/shared.cpp
index 08025f2..f9697a5 100644
--- a/unit_tests/shared.cpp
+++ b/unit_tests/shared.cpp
@@ -104,12 +104,11 @@ namespace
104// ################################################################################################# 104// #################################################################################################
105// ################################################################################################# 105// #################################################################################################
106 106
107#if HAVE_LUA_ASSERT()
107TEST_CASE("lanes.stack checker") 108TEST_CASE("lanes.stack checker")
108{ 109{
109 LuaState _L{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } }; 110 LuaState _L{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ false } };
110#if HAVE_LUA_ASSERT()
111 StackChecker::CallsCassert = false; 111 StackChecker::CallsCassert = false;
112#endif // HAVE_LUA_ASSERT()
113 112
114 auto _doStackCheckerTest = [&_L](lua_CFunction const _f, LuaError const _expected) { 113 auto _doStackCheckerTest = [&_L](lua_CFunction const _f, LuaError const _expected) {
115 lua_pushcfunction(_L, _f); 114 lua_pushcfunction(_L, _f);
@@ -152,11 +151,27 @@ TEST_CASE("lanes.stack checker")
152 return 0; 151 return 0;
153 }; 152 };
154 153
155 _doStackCheckerTest(_unbalancedStack1, LuaError::ERRRUN); 154 SECTION("unbalanced stack")
156 _doStackCheckerTest(_balancedStack1, LuaError::OK); 155 {
157 _doStackCheckerTest(_goodStart, LuaError::OK); 156 _doStackCheckerTest(_unbalancedStack1, LuaError::ERRRUN);
158 _doStackCheckerTest(_badStart, LuaError::ERRRUN); 157 }
158
159 SECTION("balanced stack")
160 {
161 _doStackCheckerTest(_balancedStack1, LuaError::OK);
162 }
163
164 SECTION("good start")
165 {
166 _doStackCheckerTest(_goodStart, LuaError::OK);
167 }
168
169 SECTION("bad start")
170 {
171 _doStackCheckerTest(_badStart, LuaError::ERRRUN);
172 }
159} 173}
174#endif // HAVE_LUA_ASSERT()
160 175
161// ################################################################################################# 176// #################################################################################################
162// ################################################################################################# 177// #################################################################################################