Relfix190fpTests.inc 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Round 190fp: the two release problems of 0.1.27.
  2. // (1) The Linux plugin download was missing from the release: every host on Ubuntu 22.04 (glibc 2.35) failed to load
  3. // LYNX Plugins.clap and the VST3s ("cannot allocate memory in static TLS block"). The crash guard's thread_local
  4. // frame pointer (platform/CrashGuard.cpp, round 190dt) was initial-exec; in a module a host loads with dlopen that
  5. // one variable makes the module's whole TLS block static (DF_STATIC_TLS), and glibc keeps only a small reserve for
  6. // those. In the exported plugins' runtime the frame is now a pthread key (as on macOS), and
  7. // scripts/check-linux-compat.sh fails a library that still asks for static TLS.
  8. // (2) Finishing the setup wizard started a full plugin scan even with "Look for new plugins in the background at every
  9. // start" unticked (QA 190fd O1: 20+ licence boxes on a PC with expired trials). core/AutoScanPolicy.h decides.
  10. #include "core/AutoScanPolicy.h"
  11. TEST (relfix190fp_wizard_finish_scans_only_when_asked)
  12. {
  13. using namespace lynx::autoscan;
  14. // ticked (the default): Finish starts the scan, unless "Scan now" already did
  15. CHECK (onWizardFinish (true, false));
  16. CHECK (! onWizardFinish (true, true));
  17. // unticked: no scan on Finish, whether or not one already ran
  18. CHECK (! onWizardFinish (false, false));
  19. CHECK (! onWizardFinish (false, true));
  20. // start-up: only a persistent window, after the wizard, with the box on
  21. CHECK (atStartup (true, true, true));
  22. CHECK (! atStartup (true, true, false));
  23. CHECK (! atStartup (true, false, true));
  24. CHECK (! atStartup (false, true, true));
  25. static_assert (! onWizardFinish (false, false) && atStartup (true, true, true));
  26. }
  27. TEST (relfix190fp_wizard_and_start_use_the_policy)
  28. {
  29. using namespace i18ntest;
  30. const auto wizard = readFile ("src/ui/SetupWizard.cpp");
  31. const auto finish = wizard.find ("void finishSetup()");
  32. CHECK (finish != std::string::npos);
  33. const auto end = wizard.find ("\n }\n", finish);
  34. CHECK (end != std::string::npos);
  35. const auto body = wizard.substr (finish, end - finish);
  36. CHECK (body.find ("autoscan::onWizardFinish (scanAtStart.getToggleState(), scanStarted)") != std::string::npos);
  37. // the old unconditional start is gone
  38. CHECK (body.find ("if (! scanStarted)") == std::string::npos);
  39. // "Scan now" still scans at once
  40. CHECK (wizard.find ("scanNow.onClick") != std::string::npos);
  41. const auto main = readFile ("src/ui/MainComponent.cpp");
  42. CHECK (main.find ("autoscan::atStartup (persistent, setupWizardDone(), backgroundScanAtStart())") != std::string::npos);
  43. }
  44. TEST (relfix190fp_crash_guard_has_no_static_tls_in_plugins)
  45. {
  46. using namespace i18ntest;
  47. const auto guard = readFile ("src/platform/CrashGuard.cpp");
  48. const auto tls = guard.find ("tls_model (\"initial-exec\")");
  49. CHECK (tls != std::string::npos);
  50. // the initial-exec variable sits in the #else of a branch that the exported plugins' runtime takes
  51. const auto branch = guard.rfind ("#if defined(__APPLE__) || defined(LYNX_GUARD_FRAME_KEY)", tls);
  52. CHECK (branch != std::string::npos);
  53. const auto elseAt = guard.find ("#else", branch);
  54. CHECK (elseAt != std::string::npos && elseAt < tls && guard.find ("#endif", branch) > tls);
  55. // ...set by the define only that runtime has (cmake/LynxPlugins.cmake)
  56. const auto define = guard.find ("#if defined(LYNX_EXPORT_VERSION)");
  57. CHECK (define != std::string::npos && define < branch);
  58. CHECK (guard.find ("#define LYNX_GUARD_FRAME_KEY 1", define) < branch);
  59. // the key is created on install for the same builds
  60. CHECK (guard.find ("#if defined(__APPLE__) || defined(LYNX_GUARD_FRAME_KEY)\n pthread_key_create (&frameKey, nullptr);")
  61. != std::string::npos);
  62. const auto plugins = readFile ("cmake/LynxPlugins.cmake");
  63. const auto defines = plugins.find ("set(LYNX_PLUGIN_DEFINES");
  64. CHECK (defines != std::string::npos && plugins.find ("LYNX_EXPORT_VERSION=", defines) != std::string::npos);
  65. CHECK (plugins.find ("target_compile_definitions(lynx_plugin_runtime PUBLIC ${LYNX_PLUGIN_DEFINES})") != std::string::npos);
  66. // the release check fails a Linux library that asks for static TLS
  67. const auto compat = readFile ("scripts/check-linux-compat.sh");
  68. const auto check = compat.find ("STATIC_TLS");
  69. CHECK (check != std::string::npos);
  70. CHECK (compat.find ("fail=1", check) != std::string::npos);
  71. }