2009-03-21 01:39:04 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Automatic Testing Utility
|
2020-04-04 12:57:50 +02:00
|
|
|
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
2009-03-21 01:39:04 +00:00
|
|
|
* PURPOSE: Class implementing the interface to the "testman" Web Service
|
2020-04-04 12:57:50 +02:00
|
|
|
* COPYRIGHT: Copyright 2009-2020 Colin Finck (colin@reactos.org)
|
2009-03-21 01:39:04 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precomp.h"
|
|
|
|
|
2025-06-30 20:43:15 +02:00
|
|
|
static const CHAR szHostname[] = "reactos.org";
|
2020-04-04 20:34:41 +02:00
|
|
|
static const INTERNET_PORT ServerPort = 8443;
|
2025-06-30 20:43:15 +02:00
|
|
|
static const CHAR szServerFile[] = "testman/webservice/";
|
2009-03-21 01:39:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructs a CWebService object and immediately establishes a connection to the "testman" Web Service.
|
|
|
|
*/
|
|
|
|
CWebService::CWebService()
|
|
|
|
{
|
|
|
|
/* Zero-initialize variables */
|
|
|
|
m_TestID = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructs a CWebService object and closes all connections to the Web Service.
|
|
|
|
*/
|
|
|
|
CWebService::~CWebService()
|
|
|
|
{
|
|
|
|
if(m_TestID)
|
|
|
|
delete m_TestID;
|
|
|
|
}
|
|
|
|
|
2015-03-01 11:19:30 +00:00
|
|
|
/**
|
|
|
|
* Interface to other classes for finishing this test run
|
|
|
|
*
|
|
|
|
* @param TestType
|
|
|
|
* Constant pointer to a char array containing the test type to be run (i.e. "wine")
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CWebService::Finish(const char* TestType)
|
|
|
|
{
|
2020-04-09 03:04:44 +03:00
|
|
|
auto_array_ptr<char> Response;
|
2015-03-01 11:19:30 +00:00
|
|
|
string Data;
|
|
|
|
stringstream ss;
|
|
|
|
|
|
|
|
if (!m_TestID)
|
2019-04-28 12:20:37 +02:00
|
|
|
EXCEPTION("CWebService::Finish was called, but not a single result had been submitted!\n");
|
2015-03-01 11:19:30 +00:00
|
|
|
|
|
|
|
Data = "action=finish";
|
|
|
|
Data += Configuration.GetAuthenticationRequestString();
|
|
|
|
Data += "&testtype=";
|
|
|
|
Data += TestType;
|
|
|
|
Data += "&testid=";
|
|
|
|
Data += m_TestID;
|
|
|
|
|
2025-06-30 20:43:15 +02:00
|
|
|
Response.reset(DoRequest(szHostname, ServerPort, szServerFile, Data));
|
2015-03-01 11:19:30 +00:00
|
|
|
|
2020-04-09 03:04:44 +03:00
|
|
|
if (strcmp(Response, "OK"))
|
2015-03-01 11:19:30 +00:00
|
|
|
{
|
2020-04-09 03:04:44 +03:00
|
|
|
ss << "When finishing the test run, the server responded:" << endl << Response << endl;
|
2015-03-01 11:19:30 +00:00
|
|
|
SSEXCEPTION;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-21 01:39:04 +00:00
|
|
|
/**
|
|
|
|
* Requests a Test ID from the Web Service for our test run.
|
|
|
|
*
|
|
|
|
* @param TestType
|
|
|
|
* Constant pointer to a char array containing the test type to be run (i.e. "wine")
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CWebService::GetTestID(const char* TestType)
|
|
|
|
{
|
|
|
|
string Data;
|
|
|
|
|
|
|
|
Data = "action=gettestid";
|
|
|
|
Data += Configuration.GetAuthenticationRequestString();
|
|
|
|
Data += Configuration.GetSystemInfoRequestString();
|
|
|
|
Data += "&testtype=";
|
|
|
|
Data += TestType;
|
|
|
|
|
|
|
|
if(!Configuration.GetComment().empty())
|
|
|
|
{
|
|
|
|
Data += "&comment=";
|
|
|
|
Data += Configuration.GetComment();
|
|
|
|
}
|
|
|
|
|
2025-06-30 20:43:15 +02:00
|
|
|
m_TestID = DoRequest(szHostname, ServerPort, szServerFile, Data);
|
2009-03-21 01:39:04 +00:00
|
|
|
|
|
|
|
/* Verify that this is really a number */
|
|
|
|
if(!IsNumber(m_TestID))
|
|
|
|
{
|
|
|
|
stringstream ss;
|
|
|
|
|
|
|
|
ss << "Expected Test ID, but received:" << endl << m_TestID << endl;
|
|
|
|
SSEXCEPTION;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a Suite ID from the Web Service for this module/test combination.
|
|
|
|
*
|
|
|
|
* @param TestType
|
|
|
|
* Constant pointer to a char array containing the test type to be run (i.e. "wine")
|
|
|
|
*
|
|
|
|
* @param TestInfo
|
|
|
|
* Pointer to a CTestInfo object containing information about the test
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* Returns a pointer to a char array containing the Suite ID received from the Web Service.
|
|
|
|
* The caller needs to free that pointer.
|
|
|
|
*/
|
|
|
|
PCHAR
|
|
|
|
CWebService::GetSuiteID(const char* TestType, CTestInfo* TestInfo)
|
|
|
|
{
|
2020-04-09 03:04:44 +03:00
|
|
|
auto_array_ptr<char> SuiteID;
|
2009-03-21 01:39:04 +00:00
|
|
|
string Data;
|
|
|
|
|
|
|
|
Data = "action=getsuiteid";
|
|
|
|
Data += Configuration.GetAuthenticationRequestString();
|
|
|
|
Data += "&testtype=";
|
|
|
|
Data += TestType;
|
|
|
|
Data += "&module=";
|
|
|
|
Data += TestInfo->Module;
|
|
|
|
Data += "&test=";
|
|
|
|
Data += TestInfo->Test;
|
|
|
|
|
2025-06-30 20:43:15 +02:00
|
|
|
SuiteID.reset(DoRequest(szHostname, ServerPort, szServerFile, Data));
|
2009-03-21 01:39:04 +00:00
|
|
|
|
|
|
|
/* Verify that this is really a number */
|
2020-04-09 03:04:44 +03:00
|
|
|
if(!IsNumber(SuiteID))
|
2009-03-21 01:39:04 +00:00
|
|
|
{
|
|
|
|
stringstream ss;
|
|
|
|
|
2020-04-09 03:04:44 +03:00
|
|
|
ss << "Expected Suite ID, but received:" << endl << SuiteID << endl;
|
2009-03-21 01:39:04 +00:00
|
|
|
SSEXCEPTION;
|
|
|
|
}
|
|
|
|
|
|
|
|
return SuiteID.release();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface to other classes for submitting a result of one test
|
|
|
|
*
|
|
|
|
* @param TestType
|
|
|
|
* Constant pointer to a char array containing the test type to be run (i.e. "wine")
|
|
|
|
*
|
|
|
|
* @param TestInfo
|
|
|
|
* Pointer to a CTestInfo object containing information about the test
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CWebService::Submit(const char* TestType, CTestInfo* TestInfo)
|
|
|
|
{
|
2020-04-09 03:04:44 +03:00
|
|
|
auto_array_ptr<char> Response;
|
|
|
|
auto_array_ptr<char> SuiteID;
|
2009-03-21 01:39:04 +00:00
|
|
|
string Data;
|
|
|
|
stringstream ss;
|
|
|
|
|
|
|
|
if(!m_TestID)
|
|
|
|
GetTestID(TestType);
|
|
|
|
|
|
|
|
SuiteID.reset(GetSuiteID(TestType, TestInfo));
|
|
|
|
|
|
|
|
Data = "action=submit";
|
|
|
|
Data += Configuration.GetAuthenticationRequestString();
|
|
|
|
Data += "&testtype=";
|
|
|
|
Data += TestType;
|
|
|
|
Data += "&testid=";
|
|
|
|
Data += m_TestID;
|
|
|
|
Data += "&suiteid=";
|
2020-04-09 03:04:44 +03:00
|
|
|
Data += SuiteID;
|
2009-03-21 01:39:04 +00:00
|
|
|
Data += "&log=";
|
2015-07-26 10:02:03 +00:00
|
|
|
Data += EscapeString(TestInfo->Log);
|
2009-03-21 01:39:04 +00:00
|
|
|
|
2025-06-30 20:43:15 +02:00
|
|
|
Response.reset(DoRequest(szHostname, ServerPort, szServerFile, Data));
|
2009-03-21 01:39:04 +00:00
|
|
|
|
2020-04-09 03:04:44 +03:00
|
|
|
if (strcmp(Response, "OK"))
|
2015-03-01 11:19:30 +00:00
|
|
|
{
|
2020-04-09 03:04:44 +03:00
|
|
|
ss << "When submitting the result, the server responded:" << endl << Response << endl;
|
2015-03-01 11:19:30 +00:00
|
|
|
SSEXCEPTION;
|
|
|
|
}
|
2009-03-21 01:39:04 +00:00
|
|
|
}
|