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

Fix 32bit Unittest Builds #1097

Merged
merged 3 commits into from
Sep 20, 2024
Merged

Fix 32bit Unittest Builds #1097

merged 3 commits into from
Sep 20, 2024

Conversation

COM8
Copy link
Member

@COM8 COM8 commented Aug 17, 2024

Something like time_t expires_time = 3905119080; // Expires=Wed, 30 Sep 2093 03:18:00 GMT is not easily possible on older 32 bit systems. But this is what we are using in our unit tests.

A solution was to skip converting time_t to a string and providing the string directly.

Changes

  • Replaced time_t with std::chrono where ever possible.

@barracuda156
Copy link
Contributor

I think this still fails:

/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_cpr/cpr/work/cpr-aa581c9d8060b2502707ad96a04f4829cc524fcb/test/head_tests.cpp: In member function 'virtual void HeadTests_CookieHeadTest_Test::TestBody()':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_cpr/cpr/work/cpr-aa581c9d8060b2502707ad96a04f4829cc524fcb/test/head_tests.cpp:57:111: error: overflow in conversion from 'long long int' to 'time_t' {aka 'long int'} changes value from '3905119080' to '-389848216' [-Werror=overflow]
   57 |             {"SID", "31d4d96e407aad42", "127.0.0.1", false, "/", true, std::chrono::system_clock::from_time_t(3905119080)},
      |                                                                                                               ^~~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_cpr/cpr/work/cpr-aa581c9d8060b2502707ad96a04f4829cc524fcb/test/head_tests.cpp:58:101: error: overflow in conversion from 'long long int' to 'time_t' {aka 'long int'} changes value from '3905119080' to '-389848216' [-Werror=overflow]
   58 |             {"lang", "en-US", "127.0.0.1", false, "/", true, std::chrono::system_clock::from_time_t(3905119080)},
      |                                                                                                     ^~~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [test/CMakeFiles/head_tests.dir/head_tests.cpp.o] Error 1
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_cpr/cpr/work/build'
make[1]: *** [test/CMakeFiles/head_tests.dir/all] Error 2
. . .
[ 50%] Linking CXX executable ../bin/delete_tests
cd /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_cpr/cpr/work/build/test && /opt/local/bin/cmake -E cmake_link_script CMakeFiles/delete_tests.dir/link.txt --verbose=ON
/opt/local/bin/g++-mp-14 -pipe -I/opt/local/libexec/openssl3/include -Os -DNDEBUG -I/opt/local/libexec/openssl3/include -isystem/opt/local/include -D_GLIBCXX_USE_CXX11_ABI=0 -Wall -Wextra -Wpedantic -Werror -arch ppc -mmacosx-version-min=10.6 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -L/opt/local/libexec/openssl3/lib -L/opt/local/lib -Wl,-headerpad_max_install_names CMakeFiles/delete_tests.dir/delete_tests.cpp.o -o ../bin/delete_tests  -Wl,-rpath,/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_cpr/cpr/work/build/lib ../lib/libtest_server.a ../lib/libcpr.1.11.0.dylib /opt/local/lib/libcurl.dylib /opt/local/lib/libgtest.a ../lib/libmongoose.a /opt/local/libexec/openssl3/lib/libssl.dylib /opt/local/libexec/openssl3/lib/libcrypto.dylib
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_cpr/cpr/work/build'
[ 50%] Built target delete_tests
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_cpr/cpr/work/cpr-aa581c9d8060b2502707ad96a04f4829cc524fcb/test/get_tests.cpp: In member function 'virtual void CookiesTests_BasicCookiesTest_Test::TestBody()':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_cpr/cpr/work/cpr-aa581c9d8060b2502707ad96a04f4829cc524fcb/test/get_tests.cpp:116:111: error: overflow in conversion from 'long long int' to 'time_t' {aka 'long int'} changes value from '3905119080' to '-389848216' [-Werror=overflow]
  116 |             {"SID", "31d4d96e407aad42", "127.0.0.1", false, "/", true, std::chrono::system_clock::from_time_t(3905119080)},
      |                                                                                                               ^~~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_cpr/cpr/work/cpr-aa581c9d8060b2502707ad96a04f4829cc524fcb/test/get_tests.cpp:117:101: error: overflow in conversion from 'long long int' to 'time_t' {aka 'long int'} changes value from '3905119080' to '-389848216' [-Werror=overflow]
  117 |             {"lang", "en-US", "127.0.0.1", false, "/", true, std::chrono::system_clock::from_time_t(3905119080)},
      |                                                                                                     ^~~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_cpr/cpr/work/cpr-aa581c9d8060b2502707ad96a04f4829cc524fcb/test/get_tests.cpp: In member function 'virtual void CookiesTests_EmptyCookieTest_Test::TestBody()':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_cpr/cpr/work/cpr-aa581c9d8060b2502707ad96a04f4829cc524fcb/test/get_tests.cpp:141:95: error: overflow in conversion from 'long long int' to 'time_t' {aka 'long int'} changes value from '3905119080' to '-389848216' [-Werror=overflow]
  141 |             {"SID", "", "127.0.0.1", false, "/", true, std::chrono::system_clock::from_time_t(3905119080)},
      |                                                                                               ^~~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_cpr/cpr/work/cpr-aa581c9d8060b2502707ad96a04f4829cc524fcb/test/get_tests.cpp:142:96: error: overflow in conversion from 'long long int' to 'time_t' {aka 'long int'} changes value from '3905119080' to '-389848216' [-Werror=overflow]
  142 |             {"lang", "", "127.0.0.1", false, "/", true, std::chrono::system_clock::from_time_t(3905119080)},
      |                                                                                                ^~~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_cpr/cpr/work/cpr-aa581c9d8060b2502707ad96a04f4829cc524fcb/test/get_tests.cpp: In member function 'virtual void CookiesTests_ClientSetCookiesTest_Test::TestBody()':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_cpr/cpr/work/cpr-aa581c9d8060b2502707ad96a04f4829cc524fcb/test/get_tests.cpp:163:111: error: overflow in conversion from 'long long int' to 'time_t' {aka 'long int'} changes value from '3905119080' to '-389848216' [-Werror=overflow]
  163 |             {"SID", "31d4d96e407aad42", "127.0.0.1", false, "/", true, std::chrono::system_clock::from_time_t(3905119080)},
      |                                                                                                               ^~~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_cpr/cpr/work/cpr-aa581c9d8060b2502707ad96a04f4829cc524fcb/test/get_tests.cpp:164:101: error: overflow in conversion from 'long long int' to 'time_t' {aka 'long int'} changes value from '3905119080' to '-389848216' [-Werror=overflow]
  164 |             {"lang", "en-US", "127.0.0.1", false, "/", true, std::chrono::system_clock::from_time_t(3905119080)},
      |                                                                                                     ^~~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_cpr/cpr/work/cpr-aa581c9d8060b2502707ad96a04f4829cc524fcb/test/get_tests.cpp: In member function 'virtual void CookiesTests_UnencodedCookiesTest_Test::TestBody()':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_cpr/cpr/work/cpr-aa581c9d8060b2502707ad96a04f4829cc524fcb/test/get_tests.cpp:178:117: error: overflow in conversion from 'long long int' to 'time_t' {aka 'long int'} changes value from '3905119080' to '-389848216' [-Werror=overflow]
  178 |             {"SID", "31d4d  %$  96e407aad42", "127.0.0.1", false, "/", true, std::chrono::system_clock::from_time_t(3905119080)},
      |                                                                                                                     ^~~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_cpr/cpr/work/cpr-aa581c9d8060b2502707ad96a04f4829cc524fcb/test/get_tests.cpp:179:101: error: overflow in conversion from 'long long int' to 'time_t' {aka 'long int'} changes value from '3905119080' to '-389848216' [-Werror=overflow]
  179 |             {"lang", "en-US", "127.0.0.1", false, "/", true, std::chrono::system_clock::from_time_t(3905119080)},
      |                                                                                                     ^~~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [test/CMakeFiles/get_tests.dir/get_tests.cpp.o] Error 1
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_cpr/cpr/work/build'
make[1]: *** [test/CMakeFiles/get_tests.dir/all] Error 2
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_cpr/cpr/work/cpr-aa581c9d8060b2502707ad96a04f4829cc524fcb/test/session_tests.cpp: In member function 'virtual void CookiesTests_BasicCookiesTest_Test::TestBody()':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_cpr/cpr/work/cpr-aa581c9d8060b2502707ad96a04f4829cc524fcb/test/session_tests.cpp:768:111: error: overflow in conversion from 'long long int' to 'time_t' {aka 'long int'} changes value from '3905119080' to '-389848216' [-Werror=overflow]
  768 |             {"SID", "31d4d96e407aad42", "127.0.0.1", false, "/", true, std::chrono::system_clock::from_time_t(3905119080)},
      |                                                                                                               ^~~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_cpr/cpr/work/cpr-aa581c9d8060b2502707ad96a04f4829cc524fcb/test/session_tests.cpp:769:101: error: overflow in conversion from 'long long int' to 'time_t' {aka 'long int'} changes value from '3905119080' to '-389848216' [-Werror=overflow]
  769 |             {"lang", "en-US", "127.0.0.1", false, "/", true, std::chrono::system_clock::from_time_t(3905119080)},
      |                                                                                                     ^~~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [test/CMakeFiles/session_tests.dir/session_tests.cpp.o] Error 1

This is building from master aa581c9 with three patches applied: ee96495, 42d2804 and 6cc1405

@COM8
Copy link
Member Author

COM8 commented Aug 18, 2024

Ah, ok. One last try please. Else I will setup a 32bit OS and debug there further.

@COM8 COM8 merged commit 3cbcacd into master Sep 20, 2024
97 of 105 checks passed
@COM8 COM8 deleted the fix/32bit_unittest_builds branch September 20, 2024 13:25
@barracuda156
Copy link
Contributor

@COM8 Sorry, I missed your reply. I will try to return to this soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants