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

[2_1] Unit tests on a long list and stack overflow #192

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
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
Prev Previous commit
Next Next commit
wip
da-liii committed Oct 23, 2023
commit 623c2f41abe497b448eef713dc246703c55899c6
18 changes: 10 additions & 8 deletions tests/Kernel/Containers/list_test.cpp
Original file line number Diff line number Diff line change
@@ -141,13 +141,15 @@ TEST_CASE ("contains") {
CHECK_EQ (contains (normal, 3L), true);
}

TEST_CASE ("long list") {
mem_info ();
TEST_CASE ("long list under stack size") {
int initial_mem_used= mem_used ();
cout << "Initial mem used: " << initial_mem_used << LF;
list<string> long_l;
for (int i=0; i<300000; i++) {
if (i % 5000 == 0) {
mem_info ();
}
long_l= list<string> ("hello", long_l);
// increase the size to 5000, there will be a stackoverflow on Windows
for (int i=0; i<4000; i++) {
long_l= list<string> ("88888888", long_l);
}
}
int final_mem_used= mem_used ();
cout << "Final mem used: " << final_mem_used << LF;
cout << "Actual mem used: " << final_mem_used - initial_mem_used << LF;
}
3 changes: 3 additions & 0 deletions xmake.lua
Original file line number Diff line number Diff line change
@@ -187,6 +187,9 @@ function add_test_target(filepath)
if is_plat("windows") then
add_cxxflags("/utf-8")
add_ldflags("/LTCG")
-- https://learn.microsoft.com/en-us/cpp/build/reference/stack-stack-allocations?view=msvc-170
-- explicitly set stack size to 1M on windows
add_ldflags("/STACK:1048576")
end

if is_plat("windows") or is_plat("mingw") then