@@ -40,13 +40,16 @@ test_base::~test_base() {
4040 }
4141 ucs_assertv_always (m_state == FINISHED ||
4242 m_state == SKIPPED ||
43- m_state == NEW || /* can be skipped from a class constructor */
43+ m_state == NEW ||
44+ m_state == INITIALIZING ||
4445 m_state == ABORTED,
4546 " state=%d" , m_state);
4647}
4748
4849void test_base::set_num_threads (unsigned num_threads) {
49- if (m_state != NEW) {
50+ if (m_state == SKIPPED) {
51+ return ;
52+ } else if (m_state != NEW) {
5053 GTEST_FAIL () << " Cannot modify number of threads after test is started, "
5154 << " it must be done in the constructor." ;
5255 }
@@ -311,6 +314,10 @@ unsigned test_base::num_warnings()
311314}
312315
313316void test_base::SetUpProxy () {
317+ if (m_state == SKIPPED) {
318+ return ;
319+ }
320+
314321 ucs_assert (m_state == NEW);
315322 m_num_valgrind_errors_before = VALGRIND_COUNT_ERRORS;
316323 m_num_warnings_before = m_total_warnings;
@@ -324,6 +331,7 @@ void test_base::SetUpProxy() {
324331
325332 try {
326333 check_skip_test ();
334+ m_state = INITIALIZING;
327335 init ();
328336 m_initialized = true ;
329337 m_state = RUNNING;
@@ -427,7 +435,10 @@ void test_base::TestBodyProxy() {
427435}
428436
429437void test_base::skipped (const test_skip_exception& e) {
430- std::string reason = e.what ();
438+ skipped (e.what ());
439+ }
440+
441+ void test_base::skipped (const std::string& reason) {
431442 if (reason.empty ()) {
432443 detail::message_stream (" SKIP" );
433444 } else {
@@ -459,6 +470,14 @@ bool test_base::barrier() {
459470 }
460471}
461472
473+ void test_base::test_skip (const std::string& reason) {
474+ if (m_state == NEW) {
475+ skipped (reason); // Do not throw exception from the constructor
476+ } else if (m_state != SKIPPED) {
477+ throw test_skip_exception (reason);
478+ }
479+ }
480+
462481static void clear_dontcopy_regions_vma_cb (ucs_sys_vma_info_t *info, void *ctx) {
463482 int ret;
464483
0 commit comments