From 26060c67924a8d9ad157ce0289c636d0573f4d61 Mon Sep 17 00:00:00 2001 From: Kacper Kasper Date: Sun, 5 Apr 2026 22:50:02 +0200 Subject: [PATCH] unittests: skip loading non-.so files * If any other file got into lib directory it would hang the runner. Change-Id: I29e8a975d0366c732469fb444b9d23d6c2523c97 Reviewed-on: https://review.haiku-os.org/c/haiku/+/10675 Reviewed-by: Kacper Kasper --- src/tools/cppunit/TestShell.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/tools/cppunit/TestShell.cpp b/src/tools/cppunit/TestShell.cpp index ae97da9717..e903238583 100644 --- a/src/tools/cppunit/TestShell.cpp +++ b/src/tools/cppunit/TestShell.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -139,9 +140,15 @@ BTestShell::LoadSuitesFrom(BDirectory *libDir) { while (libDir->GetNextEntry(&addonEntry, true) == B_OK) { status_t err; status_t addonStatus = B_ERROR; + bool getTestSuiteFound = false; err = addonEntry.GetPath(&addonPath); if (!err) { - cout << "Checking " << addonPath.Path() << "..." << endl; + cout << "Checking " << addonPath.Path() << ""; + BString filename(addonPath.Leaf()); + if (!filename.EndsWith(".so")) { + cout << ", wrong extension. Skipping." << endl; + continue; + } addonImage = load_add_on(addonPath.Path()); addonStatus = (addonImage >= 0 ? B_OK : B_ERROR); } @@ -149,9 +156,11 @@ BTestShell::LoadSuitesFrom(BDirectory *libDir) { err = get_image_symbol(addonImage, "getTestSuite", B_SYMBOL_TYPE_TEXT, reinterpret_cast(&func)); } else { - // cout << " getTestSuite error == " << err << endl; + // cout << ", getTestSuite error == " << err << endl; } if (err == B_OK) { + cout << ", found getTestSuite()"; + getTestSuiteFound = true; err = AddSuite(func()); if (err == B_OK) count++; @@ -160,15 +169,18 @@ BTestShell::LoadSuitesFrom(BDirectory *libDir) { err = get_image_symbol(addonImage, "getTestSuiteName", B_SYMBOL_TYPE_TEXT, reinterpret_cast(&nameF)); if(err == B_OK) { + cout << ", found getTestSuiteName()"; const char* testSuiteName = nameF(); CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(testSuiteName); AddSuite(static_cast(registry.makeTest())); count++; - } else { - // cout << " getTestSuiteName error == " << err << endl; + } else if (!getTestSuiteFound) { + cout << ", getTestSuiteName error == " << err << endl; + continue; } } + cout << ", OK." << endl; } return count; }