当前位置: 首页>>代码示例>>C++>>正文


C++ TestCase::GetName方法代码示例

本文整理汇总了C++中TestCase::GetName方法的典型用法代码示例。如果您正苦于以下问题:C++ TestCase::GetName方法的具体用法?C++ TestCase::GetName怎么用?C++ TestCase::GetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestCase的用法示例。


在下文中一共展示了TestCase::GetName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: RunProcessTestCase

int TestEnv::RunProcessTestCase(TestCase& obj, void(TestCase::*meth)(), int timeout)
{
    TestCaseCall call(obj, meth);
    TestEnv::in_child_process = true;
    HANDLE thread = (HANDLE)_beginthread( ThreadProc, 0, &call );
    if (thread == NULL)
    {
        REPORT_ERROR("TestEnv::RunProcessTestCase: failed to start a test case thread");
    }

    // make sure to restore main process's signal handlers before re-throwing an exception
    DWORD rc=0;
    DWORD result=WaitForSingleObject( (HANDLE)thread, timeout == 0 ? INFINITE : timeout*1000);
    try
    {
        switch (result)
        {
        case WAIT_OBJECT_0:
            if (GetExitCodeThread(thread, &rc) == 0)
                REPORT_ERROR("RunProcessTestCase failed");
            break;
        case WAIT_TIMEOUT:
            if (!CloseHandle(thread))
                REPORT_ERROR("CloseHandle failed");
            cerr << "child process timed out" << endl;            
            rc=TEST_CASE_TIMED_OUT;
            break;
        default:
            REPORT_ERROR("WaitForSingleObject failed");
            break;
        }
    }
    catch (const exception& ex)
    {
        REPORT_ERROR(obj.GetName() + " threw " + ex.what());
        rc=TEST_CASE_FAILED;
    }
    catch (const ncbi::NK::execution_aborted&)
    {
        REPORT_ERROR(obj.GetName() + " aborted ");
        rc=TEST_CASE_FAILED;
    }
    catch (...)
    {
        REPORT_ERROR(obj.GetName() + " threw something ");
        rc=TEST_CASE_FAILED;
        set_handlers(); 
        throw;
    }
#undef CALL_FAILED
    set_handlers(); 
    in_child_process = false;
    return (int)rc;
}
开发者ID:ImAWolf,项目名称:ncbi-vdb,代码行数:54,代码来源:systestenv.cpp

示例2: RunProcessTestCase

int TestEnv::RunProcessTestCase(TestCase& obj, void(TestCase::*meth)(), int timeout)
{
    int pid=fork();
    if (pid == -1)
    {
        REPORT_ERROR("RunProcessTestCase: fork() failed");
    }
    if (pid == 0)
    {   /* child process */
        if (timeout != 0)
        {
            struct sigaction act;
            memset(&act, 0, sizeof act);
            act.sa_handler = alarmHandler;
            act.sa_flags = SA_RESETHAND;
            sigaction(SIGALRM , &act, NULL);        
            alarm(timeout);
        }
        try 
        {
            in_child_process = true;
            (obj.*meth)();
        }   
        catch (const exception& ex)
        {
            cerr << obj.GetName() << " threw " << ex.what() << endl;
            exit(TEST_CASE_FAILED);
        }
        catch (const ncbi::NK::execution_aborted&)
        {
            cerr << obj.GetName() << " aborted " << endl;
            exit(TEST_CASE_FAILED);
        }
        catch (...)
        {
            cerr << obj.GetName() << " threw something " << endl;
            exit(TEST_CASE_FAILED);  
        }
        exit(0);
    }
    /* parent process */
    int status;
    if (waitpid(pid, &status, 0) != pid) /* suspend until the child terminates */
    {   
        REPORT_ERROR("RunProcessTestCase: wait() failed");
    }
    if (!WIFEXITED(status)) 
    {   
        REPORT_ERROR("RunProcessTestCase: child exited abnormally");
    }
    
    return WEXITSTATUS(status); /* exit status of the child process */
}
开发者ID:sungsoo,项目名称:sratoolkit,代码行数:53,代码来源:runprocesstestcase.cpp


注:本文中的TestCase::GetName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。