Пример #1
0
void MainWindow::runTestScript(const QModelIndex& index)
{
	if(!editTestScript(index, IgnoreVisible))
	{
		// ScriptEditor had unsaved changes, prompted save/discard/cancel, user clicked cancel
		return;
	}
	delete m_hooqPlayer;
	m_testRunning = true;
	m_testList->setEnabled(false);

	const QString testName = index.data(TestModel::ScriptNameRole).toString();
	m_testResult = TestResult(testName);

	statusBar()->showMessage(tr("Running test '%1'...").arg(testName));

	m_interpreter->setScriptPath(index.data(TestModel::FilePathRole).toString());

	m_hooqPlayer = new Hooq::RemoteConnection(m_server, this);
	connect(
		m_hooqPlayer,
		SIGNAL(connected(QTcpSocket*)),
		m_interpreter,
		SLOT(setSocket(QTcpSocket*))
	);

	m_interpreter->run();
}
Пример #2
0
bool FTransform::DebugEqualMatrix(const FMatrix& Matrix) const
{
	FTransform TestResult(Matrix);
	if (!Equals(TestResult))
	{
		// see now which one isn't equal		
		if (!Scale3DEquals(TestResult.Scale3D, ScalarRegister(0.01f)))
		{
			UE_LOG(LogTransform, Log, TEXT("Matrix(S)\t%s"), *TestResult.GetScale3D().ToString());
			UE_LOG(LogTransform, Log, TEXT("VQS(S)\t%s"), *GetScale3D().ToString());
		}

		// see now which one isn't equal
		if (!RotationEquals(TestResult.Rotation))
		{
			UE_LOG(LogTransform, Log, TEXT("Matrix(R)\t%s"), *TestResult.GetRotation().ToString());
			UE_LOG(LogTransform, Log, TEXT("VQS(R)\t%s"), *GetRotation().ToString());
		}

		// see now which one isn't equal
		if (!TranslationEquals(TestResult.Translation, ScalarRegister(0.01f)))
		{
			UE_LOG(LogTransform, Log, TEXT("Matrix(T)\t%s"), *TestResult.GetTranslation().ToString());
			UE_LOG(LogTransform, Log, TEXT("VQS(T)\t%s"), *GetTranslation().ToString());
		}
		return false;
	}

	return true;
}
Пример #3
0
		void operator()(const TestInfo& ti)
		{
			if (!ti._success)
			{
				const std::string& suite = ti._sources.front().suite();
				
				sub_title(_os, suite + "::" + ti._name, 3, suite + "_" + ti._name);
				std::for_each(ti._sources.begin(), ti._sources.end(), TestResult(_os));
				back_ref(_os, suite, false);
			}
		}
Пример #4
0
 void operator()(const TestInfo& ti)
 {
     if (!ti._success)
     {
         table_node2_header(_os, ti._id);
         ///> cppunit的id是针对每个断言了,这里只显示第一个错误来兼容其xml格式测试报告
         if (ti._sources.size() > 0)
         {
             for_each(ti._sources.begin(), ++ti._sources.begin(), TestResult(_os));
         }
         table_node2_footer(_os);
     }
 }
Пример #5
0
TestResult TestRef::run()
{
	TestResult result;
	
	setUp();
	
	try {
		executeMethod();
	} catch (TestResult &r) {
		result = r;
	} catch (std::exception &e) {
		result = TestResult(e);
	} catch (...) {
		result = TestResult(false, "", 0, "", "unknown exception");
	}
	
	result.expectedFailure = getExpectFailure();
	
	tearDown();
	
	return result;
}
void SVMClassifier::test(Mat testData, Mat testLabels)
{
	testResult = TestResult();

	for (int i = 0; i < testData.rows; i++)
	{
		Mat sampleHist(0, testData.cols, CV_32FC1);
		sampleHist.push_back(testData.row(i));

		int response				= (int) svm->predict(sampleHist);
		int correctResponse			= testLabels.at<int>(i, 0);

		// cout << "correct: " << correctResponse << "\t-> response: " << response << endl;

		// evalute performance
		if (correctResponse == 1 && response == 1)
		{
			// true positives
			testResult.truePositive++;
		}
		else if (correctResponse == 0 && response == 1)
		{
			// false positives
			testResult.falsePositive++;
		}
		else if (correctResponse == 1 && response == 0)
		{
			// false negatives
			testResult.falseNegative++;
		}
		else if (correctResponse == 0 && response == 0)
		{
			// true negatives
			testResult.trueNegative++;
		}
	}
}
Пример #7
0
void MainWindow::logException(const QString& exception, const QStringList& backtrace)
{
	m_testResult = TestResult(m_testResult.name(), exception, backtrace);
}
Пример #8
0
static void
Test(int level)
{
	SQLRETURN result;
	SQLSMALLINT InParam = level;
	SQLSMALLINT OutParam = 1;
	SQLLEN cbReturnCode = 0, cbInParam = 0, cbOutParam = 0;
	SQLLEN cbOutString = SQL_NTS;

	char sql[80];

	printf("ODBC %d nocount %s select %s level %d\n", odbc_use_version3 ? 3 : 2,
	       g_nocount ? "yes" : "no", g_second_select ? "yes" : "no", level);

	ReturnCode = INVALID_RETURN;
	memset(&OutString, 0, sizeof(OutString));

	/* test with SQLExecDirect */
	sprintf(sql, "RAISERROR('An error occurred.', %d, 1)", level);
	result = odbc_command_with_result(odbc_stmt, sql);

	TestResult(result, level, "SQLExecDirect");

	/* test with SQLPrepare/SQLExecute */
	if (!SQL_SUCCEEDED(SQLPrepare(odbc_stmt, T(SP_TEXT), strlen(SP_TEXT)))) {
		fprintf(stderr, "SQLPrepare failure!\n");
		exit(1);
	}

	SQLBindParameter(odbc_stmt, 1, SQL_PARAM_OUTPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &ReturnCode, 0, &cbReturnCode);
	SQLBindParameter(odbc_stmt, 2, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &InParam, 0, &cbInParam);
	SQLBindParameter(odbc_stmt, 3, SQL_PARAM_OUTPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &OutParam, 0, &cbOutParam);
	strcpy(OutString, "Invalid!");
	SQLBindParameter(odbc_stmt, 4, SQL_PARAM_OUTPUT, SQL_C_CHAR, SQL_VARCHAR, OUTSTRING_LEN, 0, OutString, OUTSTRING_LEN,
			 &cbOutString);

	CHKExecute("S");

	/* first select, check data are returned.
	 * SET statements before does not affect results
	 */
	CheckData("");
	CHKFetch("S");
	CheckData("Here is the first row");

	result = SQLFetch(odbc_stmt);
	if (odbc_use_version3) {
		SQLTCHAR SqlState[6];
		SQLINTEGER NativeError;
		SQLTCHAR MessageText[1000];
		SQLSMALLINT TextLength;
		SQLRETURN expected;
		SQLLEN rows;

		if (result != SQL_NO_DATA)
			ODBC_REPORT_ERROR("SQLFetch should return NO DATA");
		CHKGetDiagRec(SQL_HANDLE_STMT, odbc_stmt, 1, SqlState, &NativeError, MessageText,
				       ODBC_VECTOR_SIZE(MessageText), &TextLength, "No");
		result = SQLMoreResults(odbc_stmt);
		expected = level > 10 ? SQL_ERROR : SQL_SUCCESS_WITH_INFO;
		if (result != expected)
			ODBC_REPORT_ERROR("SQLMoreResults returned unexpected result");
		if (!g_second_select && g_nocount) {
			if (ReturnCode == INVALID_RETURN) {
				result = SQLMoreResults(odbc_stmt);
			} else {
				CheckReturnCode(result, 0);
				ReturnCode = INVALID_RETURN;
				TestResult(result, level, "SQLMoreResults");
				ReturnCode = 0;
			}
		} else {
			TestResult(result, level, "SQLMoreResults");
		}

		/* a recordset with only warnings/errors do not contains rows */
		if (CHKRowCount(&rows, "SE") == SQL_SUCCESS && rows != -1)
			ODBC_REPORT_ERROR("SQLRowCount returned some rows");
	} else {
		/* in ODBC 2 errors/warnings are not handled as different recordset */
		TestResult(result, level, "SQLFetch");
	}

	if (odbc_driver_is_freetds())
		CheckData("");

	if (!g_second_select) {
		SQLLEN rows;

		if (CHKRowCount(&rows, "SE") == SQL_SUCCESS && rows != -1)
			ODBC_REPORT_ERROR("SQLRowCount returned some rows");
		CheckReturnCode(result, g_nocount ? 0 : INVALID_RETURN);

		result = SQLMoreResults(odbc_stmt);
#ifdef ENABLE_DEVELOPING
		if (result != SQL_NO_DATA)
			ODBC_REPORT_ERROR("SQLMoreResults should return NO DATA");

		ODBC_CHECK_ROWS(-2);
#endif
		CheckReturnCode(result, 0);
		return;
	}

	if (!odbc_use_version3 || !g_nocount) {
		/* mssql 2008 return SUCCESS_WITH_INFO with previous error */
		CHKMoreResults("S");
		result = SQL_SUCCESS;
	}

	CheckReturnCode(result, INVALID_RETURN);

	CheckData("");
	if (g_nocount && odbc_use_version3 && g_second_select && level >= 10) {
		if (CHKFetch("SE") == SQL_ERROR) {
			SQLMoreResults(odbc_stmt);
			CHKFetch("S");
		}
	} else {
		CHKFetch("S");
	}
	CheckData("Here is the last row");

	CHKFetch("No");
	CheckData("");

	if (!odbc_use_version3 || g_nocount)
		CheckReturnCode(result, 0);
#ifdef ENABLE_DEVELOPING
	else
		CheckReturnCode(result, INVALID_RETURN);
#endif

	/* FIXME how to handle return in store procedure ??  */
	result = SQLMoreResults(odbc_stmt);
#ifdef ENABLE_DEVELOPING
	if (result != SQL_NO_DATA)
		ODBC_REPORT_ERROR("SQLMoreResults return other data");
#endif

	CheckReturnCode(result, 0);

	CheckData("");
	ODBC_FREE();
}
Пример #9
0
bool UnitTestDriver::run_tests(std::vector<UnitTest *>& tests_to_run, const ArgumentMap& kwargs)
{
    std::time_t start_time = std::time(0);

    bool verbose = kwargs.count("verbose");
    bool concise = kwargs.count("concise");
    
    std::vector< TestResult > test_results;

    if (verbose && concise)
    {
        std::cout << "--verbose and --concise cannot be used together" << std::endl;
        exit(EXIT_FAILURE);
    }

    if (!concise)
        std::cout << "Running " << tests_to_run.size() << " unit tests." << std::endl;

    for(size_t i = 0; i < tests_to_run.size(); i++){
        UnitTest& test = *tests_to_run[i];

        if (verbose)
            std::cout << "Running " << test.name << "..." << std::flush;

        try
        {
            // time the test
            std::clock_t start = std::clock();

            // run the test
            test.run();

            // test passed
            record_result(TestResult(Pass, std::clock() - start, test), test_results);
        } 
        catch (unittest::UnitTestFailure& f)
        {
            record_result(TestResult(Failure, std::numeric_limits<std::clock_t>::max(), test, f.message), test_results);
        }
        catch (unittest::UnitTestKnownFailure& f)
        {
            record_result(TestResult(KnownFailure, std::numeric_limits<std::clock_t>::max(), test, f.message), test_results);
        }
        catch (std::bad_alloc& e)
        {
            record_result(TestResult(Error, std::numeric_limits<std::clock_t>::max(), test, e.what()), test_results);
        }
        catch (unittest::UnitTestError& e)
        {
            record_result(TestResult(Error, std::numeric_limits<std::clock_t>::max(), test, e.message), test_results);
        }

        // immediate report
        if (!concise)
        {
            if (verbose)
            {
                switch(test_results.back().status)
                {
                    case Pass:
                        std::cout << "\r[PASS] ";
                        std::cout << std::setw(10) << 1000.f * float(test_results.back().elapsed) / CLOCKS_PER_SEC << " ms";
                        break;
                    case Failure:
                        std::cout << "\r[FAILURE]           "; break;
                    case KnownFailure:
                        std::cout << "\r[KNOWN FAILURE]     "; break;
                    case Error:
                        std::cout << "\r[ERROR]             "; break;
                    default:
                        break;
                }

                std::cout << " " << test.name << std::endl;
            }
            else
            {
                switch(test_results.back().status)
                {
                    case Pass:
                        std::cout << "."; break;
                    case Failure:
                        std::cout << "F"; break;
                    case KnownFailure:
                        std::cout << "K"; break;
                    case Error:
                        std::cout << "E"; break;
                    default:
                        break;
                }
            }
        }

        if (!post_test_sanity_check(test, concise))
        {
            return false;
        }

        std::cout.flush();
    }

    double elapsed_minutes = double(std::time(0) - start_time) / 60;

    // summary report
    if (!concise)
        report_results(test_results, elapsed_minutes);


    // if any failures or errors return false
    for(size_t i = 0; i < test_results.size(); i++)
        if (test_results[i].status != Pass && test_results[i].status != KnownFailure)
            return false;

    // all tests pass or are known failures
    return true;
}
Пример #10
0
  /**
  * Returns a default test suite instance.
  */
 static TestResult newInstance() {
     return TestResult(new TestResult_API());
 }
Пример #11
0
bool Book::Process( FILE *infile, wxProgressDialog &progress )
{
    bool aborted = false;
    char buf[BOOK_BUFLEN+10];
    static char comment_buf[10000];
    int ch, comment_ch=0, previous_ch=0, push_back=0, len=0, move_number=0;
    STATE state=INIT, old_state, save_state=INIT;
    static int nag_value;
    fseek(infile,0,SEEK_END);
    unsigned long file_len=ftell(infile);
    rewind(infile);

    // Loop through characters
    ch = fgetc(infile);
    int old_percent = -1;
    unsigned char modulo_256=0;
    while( ch != EOF )
    {
        if( modulo_256 == 0 )
        {
            unsigned long file_offset=ftell(infile);
            int percent;
            if( file_len == 0 )
                percent = 100;
            else if( file_len < 10000000 )
                percent = (int)( (file_offset*100L) / file_len );
            else // if( file_len > 10000000 )
                percent = (int)( file_offset / (file_len/100L) );
            if( percent != old_percent )
            {
#if wxABI_VERSION > 28600
                if( progress.CanAcceptFocus() )
#endif
                progress.SetFocus();
                if( !progress.Update( percent>100 ? 100 : percent ) )
                {
                    aborted = true;
                    break;
                }
            }
            old_percent = percent;
        }
        modulo_256++;
        modulo_256 &= 0xff;
        if( push_back == '\0' )
        {
            error_buf[error_ptr++] = (char)ch;
            error_ptr &= (sizeof(error_buf)-1);
        }
        push_back = '\0';

        debug_buf[debug_ptr].c     = (char)ch;
        debug_buf[debug_ptr].state = state;
        debug_ptr++;
        debug_ptr &= (nbrof(debug_buf)-1);

        // State machine
        old_state = state;
        if( ch == '{' && (
                                state!=HEADER     &&
                                state!=IN_COMMENT &&
                                state!=IN_MOVE_BLACK &&
                                state!=IN_MOVE_WHITE
                         )
          )
        {
            save_state = state;
            comment_ch = '{';
            state = IN_COMMENT;
        }
        else if( ch == ';' && (
                                state!=HEADER     &&
                                state!=IN_COMMENT &&
                                state!=IN_MOVE_BLACK &&
                                state!=IN_MOVE_WHITE
                              )
               )
        {
            save_state = state;
            comment_ch = ';';
            state = IN_COMMENT;
        }
        else if( state==IN_COMMENT &&
                    (
                        (comment_ch=='{' && ch=='}') ||
                        (comment_ch==';' && ch!=';' && previous_ch=='\n')
                    )
               )
        {
            if( comment_ch == ';' )
                push_back = ch;
            comment_buf[len] = '\0';
            state = save_state;
        }
        else if( ch == '$' && (
                                state!=HEADER     &&
                                state!=IN_COMMENT &&
                                state!=IN_MOVE_BLACK &&
                                state!=IN_MOVE_WHITE
                         )
          )
        {
            save_state = state;
            state = IN_DOLLAR;
            nag_value = 0;
        }
        else if( state==IN_DOLLAR && isascii(ch) && isdigit(ch) )
        {
            nag_value = nag_value*10+(ch-'0');
        }
        else if( state==IN_DOLLAR && isascii(ch) && !isdigit(ch) )
        {
        /*  const char *nag_array[] =
            {
                "",
                " !",     // $1   
                " ?",     // $2   
                " !!",    // $3   
                " ??",    // $4   
                " !?",    // $5   
                " ?!",    // $6   
                "",       // $7   
                "",       // $8   
                " ??",    // $9   
                " =",     // $10  
                " =",     // $11  
                " =",     // $12  
                "",       // $13  
                " +=",    // $14  
                " =+",    // $15  
                " +/-",   // $16  
                " -/+",   // $17  
                " +-",    // $18  
                " -+",    // $19  
                " +-",    // $20  
                " -+"     // $21
            };   */
            push_back = ch;
            state = save_state;
        }
        else if( ch == '(' && (
                                state!=HEADER     &&
                                state!=IN_COMMENT &&
                                state!=ERROR_STATE      &&
                                state!=IN_MOVE_BLACK &&
                                state!=IN_MOVE_WHITE
                              )
               )
            state = Push(state);
        else if( ch == ')' && (
                                state!=HEADER     &&
                                state!=IN_COMMENT &&
                                state!=ERROR_STATE      &&
                                state!=IN_MOVE_BLACK &&
                                state!=IN_MOVE_WHITE
                              )
               )
        {
            state = Pop();
        }
        else
        {

            switch( state )
            {
                case IN_COMMENT:
                {
                    if( len < sizeof(comment_buf)-3 )
                    {
                        if( comment_ch == '{' )
                            comment_buf[len++] = (char)ch;
                        else
                        {
                            if( ch!=';' || previous_ch!='\n' )
                                comment_buf[len++] = (char)ch;
                        }
                    }
                    break;
                }

                case INIT:
                {
                    push_back = ch;
                    state = PREFIX;
                    break;
                }

                case PREFIX:
                {
                    if( ch == '[' )
                    {
                        state = HEADER;
                        push_back = ch;
                    }
                    else if( isascii(ch) && isdigit(ch) )
                    {
                        push_back = ch;
                        state = MOVE_NUMBER;
                    }
                    else if( ch == '*' )
                    {
                        push_back = ch;
                        state = MOVE_NUMBER;
                    }
                    break;
                }

                case HEADER:
                {
                    if( len < BOOK_BUFLEN )
                        buf[len++] = (char)ch;
                    if( ch == ']' )
                        state = PREFIX;
                    break;
                }

                case MOVE_NUMBER:
                {
                    if( ch=='.' || ch==' ' || ch=='\t' || ch=='\n' )
                    {
                        buf[len] = '\0';
                        len = 0;
                        if( TestResult(buf) )
                            state = PREFIX;
                        else if( (move_number=atoi(buf)) > 0 )
                        {
                            state = POST_MOVE_NUMBER;
                            if( ch == '.' )
                                push_back = ch;
                        }
                        else
                        {
                            Error( "Bad move number" );
                            state = ERROR_STATE;
                        }
                    }
                    else
                    {
                        if( len < BOOK_BUFLEN )
                            buf[len++] = (char)ch;
                        else
                        {
                            Error( "Internal buffer overflow" );
                            state = ERROR_STATE;
                        }
                    }
                    break;
                }

                case POST_MOVE_NUMBER:
                {
                    if( ch == '.' )
                        state = POST_MOVE_NUMBER_HAVE_PERIOD;
                    else if( ch!=' ' && ch!='\t' && ch!='\n' )
                    {
                        Error( "Bad move number" );
                        state = ERROR_STATE;
                    }
                    break;
                }

                case POST_MOVE_NUMBER_HAVE_PERIOD:
                {
                    if( ch == '.' )
                        state = POST_MOVE_NUMBER_BLACK;
                    else
                    {
                        push_back = ch;
                        state = PRE_MOVE_WHITE;
                    }
                    break;
                }

                case POST_MOVE_NUMBER_BLACK:
                {
                    if( ch != '.' )
                    {
                        push_back = ch;
                        state = PRE_MOVE_BLACK;
                    }
                    break;
                }

                case ERROR_STATE:
                {
                    if( ch == '[' )
                    {
                        push_back = ch;
                        state = PREFIX;
                    }
                    break;
                }

                case PRE_MOVE_WHITE:
                case PRE_MOVE_BLACK:
                {
                    if( ch == '[' )
                    {
                        push_back = ch;
                        state = PREFIX;
                    }
                    else if( isascii(ch) && isdigit(ch) )
                    {
                        push_back = ch;
                        state = MOVE_NUMBER;
                    }
                    else if( ch!=' ' && ch!='\t' && ch!='\n' )
                    {
                        push_back = ch;
                        state = (state==PRE_MOVE_WHITE?IN_MOVE_WHITE:IN_MOVE_BLACK);
                    }
                    break;
                }

                case IN_MOVE_WHITE:
                case IN_MOVE_BLACK:
                {
                    if( ch == '[' )
                    {
                        push_back = ch;
                        state = PREFIX;
                    }
                    else if( ch==' ' || ch=='\t' || ch=='\n' || ch=='(' || ch==')' || ch=='{' || ch=='}' || ch=='$' )
                    {
                        buf[len] = '\0';
                        len = 0;
                        if( TestResult(buf) )
                            state = PREFIX;
                        else if( !DoMove(state==IN_MOVE_WHITE,move_number,buf) )
                            state = ERROR_STATE;
                        else
                            state = (state==IN_MOVE_WHITE?PRE_MOVE_BLACK:BETWEEN_MOVES);
                        if( ch=='(' || ch==')' || ch=='{' || ch=='}' || ch=='?' )
                            push_back = ch;
                    }
                    else
                    {
                        if( len < BOOK_BUFLEN )
                            buf[len++] = (char)ch;
                        else
                        {
                            Error( "Internal buffer overflow" );
                            state = ERROR_STATE;
                        }
                    }
                    break;
                }

                case BETWEEN_MOVES:
                {
                    if( ch == '[' )
                    {
                        push_back = ch;
                        state = PREFIX;
                    }
                    else if( isascii(ch) && isdigit(ch) )
                    {
                        push_back = ch;
                        state = MOVE_NUMBER;
                    }
                    break;
                }
            }
        }

        // State changes
        if( state != old_state )
        {
            //fprintf( debug_log_file(), "State change %s->%s\n", ShowState(old_state), ShowState(state) );
            if( old_state == HEADER )
            {
                buf[len++] = '\0';
                Header( buf );
            }
            if( state==HEADER || state==IN_COMMENT || state==MOVE_NUMBER || state==IN_MOVE_WHITE || state==IN_MOVE_BLACK )
                len=0;
            if( state==PREFIX && ( 
                                    //old_state==IN_COMMENT || 
                                    old_state==BETWEEN_MOVES ||
                                    old_state==MOVE_NUMBER ||
                                    old_state==POST_MOVE_NUMBER ||
                                    old_state==POST_MOVE_NUMBER_HAVE_PERIOD ||
                                    old_state==POST_MOVE_NUMBER_BLACK ||
                                    old_state==PRE_MOVE_WHITE ||
                                    old_state==PRE_MOVE_BLACK ||
                                    old_state==IN_MOVE_WHITE  ||
                                    old_state==IN_MOVE_BLACK
                                 )
              )
            {
                GameOver();
            }
            if( state==PREFIX && old_state!=HEADER && old_state!=IN_COMMENT )
            {
                GameBegin();
            }
        }

        // Next character
        previous_ch = ch;
        if( push_back )
            ch = push_back;
        else
        {
            ch = fgetc(infile);
            if( ch==EOF &&  (
                                state==MOVE_NUMBER ||
                                state==POST_MOVE_NUMBER ||
                                state==POST_MOVE_NUMBER_HAVE_PERIOD ||
                                state==POST_MOVE_NUMBER_BLACK ||
                                state==PRE_MOVE_WHITE ||
                                state==PRE_MOVE_BLACK ||
                                state==BETWEEN_MOVES
                            )
              )
                GameOver();
        }
    }
    FileOver();
    return aborted;
}       
Пример #12
0
TestResult
Test::result()
{
    return TestResult( testCaseCount(), _failures, _name );
}
TestResult check(const TestEntry & entry)
{
	try
	{
		DB::Context context;

		auto storage_distributed_visits = StorageDistributedFake::create("remote_db", "remote_visits", entry.shard_count);
		auto storage_distributed_hits = StorageDistributedFake::create("distant_db", "distant_hits", entry.shard_count);

		DB::DatabasePtr database = std::make_shared<DB::DatabaseOrdinary>("test", "./metadata/test/");
		context.addDatabase("test", database);
		database->attachTable("visits_all", storage_distributed_visits);
		database->attachTable("hits_all", storage_distributed_hits);
		context.setCurrentDatabase("test");

		auto & settings = context.getSettingsRef();
		settings.distributed_product_mode = entry.mode;

		/// Парсить и обработать входящий запрос.
		DB::ASTPtr ast_input;
		if (!parse(ast_input, entry.input))
			return TestResult(false, "parse error");

		auto select_query = typeid_cast<DB::ASTSelectQuery *>(&*ast_input);

		bool success = true;

		try
		{
			DB::InJoinSubqueriesPreprocessor<StorageDistributedFake> preprocessor(select_query, context, storage_distributed_visits);
			preprocessor.perform();
		}
		catch (const DB::Exception & ex)
		{
			if (ex.code() == DB::ErrorCodes::DISTRIBUTED_IN_JOIN_SUBQUERY_DENIED)
				success = false;
			else
				throw;
		}
		catch (...)
		{
			throw;
		}

		if (success != entry.expected_success)
			return TestResult(false, "unexpected result");

		/// Парсить ожидаемый результат.
		DB::ASTPtr ast_expected;
		if (!parse(ast_expected, entry.expected_output))
			return TestResult(false, "parse error");

		/// Сравнить обработанный запрос и ожидаемый результат.
		bool res = equals(ast_input, ast_expected);
		std::string output = DB::queryToString(ast_input);

		return TestResult(res, output);
	}
	catch (DB::Exception & e)
	{
		return TestResult(false, e.displayText());
	}
}