-bool TestManager::clearPool() throw() {
- if (!tests()) return false;
- for (test_pool_it it = a_testPool.begin(); it != a_testPool.end(); it++) delete it->second;
- // TODO: stop the possible command threads or there will be a core dump
+bool TestManager::clearPool(std::string &result) throw() {
+
+ result = "";
+
+ if (!tests()) {
+ result = "there are not programmed test cases to be removed";
+ return false;
+ }
+
+ int total = a_testPool.size();
+ int unsafe = 0;
+
+ test_pool_it it;
+ for (it = a_testPool.begin(); it != a_testPool.end(); it++) {
+ if (!it->second->safeToClear()) { // Check that non pending threads are running (command steps):
+ unsafe++;
+ }
+ }
+
+ if (unsafe > 0) {
+ result = "some test cases cannot be removed (";
+ result += anna::functions::asString(unsafe);
+ result += "/";
+ result += anna::functions::asString(total);
+ result += "), mainly those having running-thread steps. Check for stuck external procedures or try later.";
+ return false;
+ }
+
+ // Here is safe to clear:
+ for (it = a_testPool.begin(); it != a_testPool.end(); it++) {
+ delete it->second;
+ }