|
@@ -4,7 +4,6 @@
|
|
|
#include "CharEncoding.h"
|
|
|
#include "SynSerial.h"
|
|
|
#include "IRControl.h"
|
|
|
-#include "WinSsh2Proc.h"
|
|
|
|
|
|
CSATExecutor::CSATExecutor(void)
|
|
|
{
|
|
@@ -25,8 +24,7 @@ CSATExecutor::~CSATExecutor(void)
|
|
|
bool CSATExecutor::IsTaskExist(SATHTTP::STTask &task)
|
|
|
{
|
|
|
#ifdef _DEBUG
|
|
|
- if ( task.taskInfo.strTaskType == "FUNCTIONALITY" )
|
|
|
- {
|
|
|
+ if ( task.taskInfo.strTaskType == "FUNCTIONALITY" ) {
|
|
|
AutoThreadSection ats(&m_csSomkingTask);
|
|
|
// 如果任务存在,删除原来的;
|
|
|
std::list<SATHTTP::STTask>::iterator it = m_vtSmokingTask.begin();
|
|
@@ -39,7 +37,11 @@ bool CSATExecutor::IsTaskExist(SATHTTP::STTask &task)
|
|
|
}
|
|
|
|
|
|
// 再将任务添加入队列;
|
|
|
- m_vtSmokingTask.push_back(task);
|
|
|
+ if ( _tcsicmp(task.taskInfo.strTaskType.c_str(), "3") != 0 ) {
|
|
|
+ // 被中止的任务不入队;
|
|
|
+ m_vtSmokingTask.push_back(task);
|
|
|
+ }
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
#endif
|
|
@@ -233,18 +235,13 @@ SATHTTP::STCase* CSATExecutor::ExecuteFreeCaseScript(SATHTTP::STTask* pTask)
|
|
|
// 获取未执行的脚本;
|
|
|
SATHTTP::STCase* pCase = GetFreeCaseScript(pTask);
|
|
|
if (pCase) {
|
|
|
-#if 1 // 额外追加代码:清除之前的xml文件;
|
|
|
-#if 0
|
|
|
- std::string xmlpath = GLOBAL::g_stSATConfig.szCaseResultDir;
|
|
|
-#else
|
|
|
std::string xmlpath = pCase->_strFileDir;
|
|
|
-#endif
|
|
|
xmlpath.append("detail\\");
|
|
|
xmlpath.append(pCase->_strFileName);
|
|
|
xmlpath.append("_result.xml");
|
|
|
- // 删除文件;
|
|
|
+ // 删除前面留的文件;
|
|
|
DeleteFile(xmlpath.c_str());
|
|
|
-#endif
|
|
|
+
|
|
|
// 命令行:{"Round": %d}
|
|
|
TCHAR szCommandLine[MAX_PATH] = { 0 };
|
|
|
_stprintf_s(szCommandLine, _T("{'Round': %s}"), pCase->_strRoundNum.c_str());
|
|
@@ -460,8 +457,7 @@ bool CSATExecutor::UpdateDevice()
|
|
|
stUpdateDeviceReq.strEndTime = "";
|
|
|
stUpdateDeviceReq.strCPU = "";
|
|
|
stUpdateDeviceReq.devicelist.assign(m_vtDevice.begin(), m_vtDevice.end());
|
|
|
- if ( !::UpdateDeviceMessage(url, stUpdateDeviceReq, stUpdateDeviceResp) )
|
|
|
- {
|
|
|
+ if ( !::UpdateDeviceMessage(url, stUpdateDeviceReq, stUpdateDeviceResp) ) {
|
|
|
GLOBAL::WriteTextLog(GLOBAL::SAT_EXE, "更新设备信息失败");
|
|
|
return false;
|
|
|
}
|
|
@@ -667,12 +663,8 @@ bool CSATExecutor::ReportCaseItemFinish(SATHTTP::STTask* pTask, SATHTTP::STCase
|
|
|
// 再上传图片;
|
|
|
std::string img;
|
|
|
for (std::vector<std::string>::iterator it = caseItem.imgs.begin(); it != caseItem.imgs.end(); it++ ) {
|
|
|
-#if 0
|
|
|
- img = GLOBAL::g_stSATConfig.szCaseResultDir;
|
|
|
-#else
|
|
|
// 使用脚本路径;
|
|
|
img = pCase->_strFileDir;
|
|
|
-#endif
|
|
|
img.append(it->substr(3));
|
|
|
img = GLOBAL::Replace(img, "/", "\\");
|
|
|
GLOBAL::WriteTextLog(GLOBAL::SAT_EXE, "图片路径=%s", img.c_str());
|
|
@@ -785,12 +777,7 @@ bool CSATExecutor::ReportCaseFinish(SATHTTP::STTask* pTask, SATHTTP::STCase *pCa
|
|
|
bool CSATExecutor::ReportCaseResult(SATHTTP::STTask* pTask, SATHTTP::STCase *pCase)
|
|
|
{
|
|
|
// 获取xml文件内容;
|
|
|
-#if 0
|
|
|
- std::string xmlpath = GLOBAL::g_stSATConfig.szCaseResultDir;
|
|
|
-#else
|
|
|
- // 使用脚本自身路径作为根目录;
|
|
|
std::string xmlpath = pCase->_strFileDir;
|
|
|
-#endif
|
|
|
xmlpath.append("detail\\");
|
|
|
xmlpath.append(pCase->_strFileName + _T("_"));
|
|
|
xmlpath.append(pCase->_strRoundNum);
|
|
@@ -1073,31 +1060,25 @@ bool CSATExecutor::GetCaseXMLResult(std::string xmlpath, std::vector<STCaseItem>
|
|
|
STCaseItem cItem;
|
|
|
tinyxml2::XMLElement *pItem = pXmlElent->FirstChildElement();
|
|
|
while (pItem) {
|
|
|
- if (_tcsicmp(pItem->Value(), _T("name")) == 0)
|
|
|
- {
|
|
|
+ if (_tcsicmp(pItem->Value(), _T("name")) == 0) {
|
|
|
cItem.name = pItem->GetText();
|
|
|
}
|
|
|
- else if (_tcsicmp(pItem->Value(), _T("result")) == 0)
|
|
|
- {
|
|
|
+ else if (_tcsicmp(pItem->Value(), _T("result")) == 0) {
|
|
|
if ( _tcsicmp(pItem->GetText(), _T("Pass")) == 0 )
|
|
|
cItem.result = true;
|
|
|
else
|
|
|
cItem.result = false;
|
|
|
}
|
|
|
- else if (_tcsicmp(pItem->Value(), _T("data")) == 0)
|
|
|
- {
|
|
|
+ else if (_tcsicmp(pItem->Value(), _T("data")) == 0) {
|
|
|
cItem.data = pItem->GetText();
|
|
|
}
|
|
|
- else if (_tcsicmp(pItem->Value(), _T("log")) == 0)
|
|
|
- {
|
|
|
+ else if (_tcsicmp(pItem->Value(), _T("log")) == 0) {
|
|
|
cItem.log = pItem->GetText();
|
|
|
}
|
|
|
- else if (_tcsicmp(pItem->Value(), _T("remark")) == 0)
|
|
|
- {
|
|
|
+ else if (_tcsicmp(pItem->Value(), _T("remark")) == 0) {
|
|
|
cItem.remark = pItem->GetText();
|
|
|
}
|
|
|
- else if (_tcsicmp(pItem->Value(), _T("screen")) == 0)
|
|
|
- {
|
|
|
+ else if (_tcsicmp(pItem->Value(), _T("screen")) == 0) {
|
|
|
cItem.imgs.push_back(pItem->GetText());
|
|
|
}
|
|
|
|
|
@@ -1131,16 +1112,13 @@ int CSATExecutor::AttachTaskInfo2Buffer(SATPROTO::TaskInfo (&pbuff)[SATPROTO::MA
|
|
|
// 任务名称;
|
|
|
memcpy_s(pbuff[count].szTaskName, SATPROTO::MAX_NAME, it->taskInfo.strTaskName.c_str(), it->taskInfo.strTaskName.size());
|
|
|
// 任务状态;
|
|
|
- if ( it->taskInfo._nExecutionState == SATHTTP::UNEXECUTED )
|
|
|
- {
|
|
|
+ if ( it->taskInfo._nExecutionState == SATHTTP::UNEXECUTED ) {
|
|
|
_stprintf_s(pbuff[count].szStatus, SATPROTO::MAX_STATUS, _T("未执行"));
|
|
|
}
|
|
|
- else if (it->taskInfo._nExecutionState == SATHTTP::INEXECUTED)
|
|
|
- {
|
|
|
+ else if (it->taskInfo._nExecutionState == SATHTTP::INEXECUTED) {
|
|
|
_stprintf_s(pbuff[count].szStatus, SATPROTO::MAX_STATUS, _T("执行中"));
|
|
|
}
|
|
|
- else if (it->taskInfo._nExecutionState == SATHTTP::EXECUTED)
|
|
|
- {
|
|
|
+ else if (it->taskInfo._nExecutionState == SATHTTP::EXECUTED) {
|
|
|
_stprintf_s(pbuff[count].szStatus, SATPROTO::MAX_STATUS, _T("已执行"));
|
|
|
}
|
|
|
|
|
@@ -1156,37 +1134,29 @@ int CSATExecutor::AttachTaskInfo2Buffer(SATPROTO::TaskInfo (&pbuff)[SATPROTO::MA
|
|
|
// 用例日志路径;
|
|
|
memcpy_s(pbuff[count].ssCases[nIndex].szCaseLogPath, MAX_PATH, _case->_strCaseLog.c_str(), _case->_strCaseLog.size());
|
|
|
// 用例执行状态;
|
|
|
- if (_case->_nExecutionState == SATHTTP::UNEXECUTED)
|
|
|
- {
|
|
|
+ if (_case->_nExecutionState == SATHTTP::UNEXECUTED) {
|
|
|
_stprintf_s(pbuff[count].ssCases[nIndex].szExecStatus, SATPROTO::MAX_STATUS, _T("未执行"));
|
|
|
}
|
|
|
- else if (_case->_nExecutionState == SATHTTP::INEXECUTED)
|
|
|
- {
|
|
|
+ else if (_case->_nExecutionState == SATHTTP::INEXECUTED) {
|
|
|
_stprintf_s(pbuff[count].ssCases[nIndex].szExecStatus, SATPROTO::MAX_STATUS, _T("执行中"));
|
|
|
}
|
|
|
- else if (_case->_nExecutionState == SATHTTP::EXECUTED)
|
|
|
- {
|
|
|
+ else if (_case->_nExecutionState == SATHTTP::EXECUTED) {
|
|
|
_stprintf_s(pbuff[count].ssCases[nIndex].szExecStatus, SATPROTO::MAX_STATUS, _T("已执行"));
|
|
|
}
|
|
|
// 用例执行结果;
|
|
|
- if ( _case->_nExecutionResult == SATHTTP::NONE )
|
|
|
- {
|
|
|
+ if ( _case->_nExecutionResult == SATHTTP::NONE ) {
|
|
|
_stprintf_s(pbuff[count].ssCases[nIndex].szResultStatus, SATPROTO::MAX_STATUS, _T("无"));
|
|
|
}
|
|
|
- else if ( _case->_nExecutionResult == SATHTTP::SUCCESS )
|
|
|
- {
|
|
|
+ else if ( _case->_nExecutionResult == SATHTTP::SUCCESS ) {
|
|
|
_stprintf_s(pbuff[count].ssCases[nIndex].szResultStatus, SATPROTO::MAX_STATUS, _T("成功"));
|
|
|
}
|
|
|
- else if ( _case->_nExecutionResult == SATHTTP::FAIL )
|
|
|
- {
|
|
|
+ else if ( _case->_nExecutionResult == SATHTTP::FAIL ) {
|
|
|
_stprintf_s(pbuff[count].ssCases[nIndex].szResultStatus, SATPROTO::MAX_STATUS, _T("失败"));
|
|
|
}
|
|
|
- else if ( _case->_nExecutionResult == SATHTTP::ABNORMAL )
|
|
|
- {
|
|
|
+ else if ( _case->_nExecutionResult == SATHTTP::ABNORMAL ) {
|
|
|
_stprintf_s(pbuff[count].ssCases[nIndex].szResultStatus, SATPROTO::MAX_STATUS, _T("异常"));
|
|
|
}
|
|
|
- else if ( _case->_nExecutionResult == SATHTTP::OVERTIME )
|
|
|
- {
|
|
|
+ else if ( _case->_nExecutionResult == SATHTTP::OVERTIME ) {
|
|
|
_stprintf_s(pbuff[count].ssCases[nIndex].szResultStatus, SATPROTO::MAX_STATUS, _T("超时"));
|
|
|
}
|
|
|
|
|
@@ -1211,43 +1181,9 @@ void CSATExecutor::SmokeTaskPretreated(std::list<SATHTTP::STTask>::iterator &it)
|
|
|
if ( it == m_vtSmokingTask.end() )
|
|
|
return;
|
|
|
|
|
|
- /* logic
|
|
|
- pkBuildServerInfo = {}
|
|
|
- if 获取服务器信息(pTask->szBuildServerName, pkBuildServerInfo) == false then
|
|
|
- return
|
|
|
- end
|
|
|
-
|
|
|
- pkSoftInfo = {}
|
|
|
- if 获取软件信息(pTask->szTaskName, pkSoftInfo) == false then
|
|
|
- return
|
|
|
- end
|
|
|
-
|
|
|
- pkTimeInfo = {}
|
|
|
- if 获取执行时间信息(pTask->szTaskName, pkTimeInfo) == false then
|
|
|
- return
|
|
|
- end
|
|
|
-
|
|
|
- while ( 是否到达执行时间(pkTimeInfo) == false )
|
|
|
- sleep(1000)
|
|
|
- end
|
|
|
- //
|
|
|
- */
|
|
|
#ifdef _DEBUG
|
|
|
SATHTTP::STTask *pTask = (SATHTTP::STTask*)&*it;
|
|
|
|
|
|
- SATHTTP::STBuildServerInfo buildSerInfo;
|
|
|
- buildSerInfo.strBuildServerName = _T("RT2851");
|
|
|
- buildSerInfo.strBuildServerAddress = _T("10.201.251.254");
|
|
|
- buildSerInfo.nBuildServerPort = 22;
|
|
|
- buildSerInfo.strBuildServerUser = "wjf";
|
|
|
- buildSerInfo.strBuildServerPwd = "wjf2019";
|
|
|
- buildSerInfo.strBuildServerImgPath = "/home/RT2841_2851_dailybuild";
|
|
|
-
|
|
|
- pTask->SoftwareInfo.strProjectId = "100";
|
|
|
- pTask->SoftwareInfo.strSoftwareName = "2851";
|
|
|
- pTask->SoftwareInfo.strSoftwareNumber = "";
|
|
|
- pTask->SoftwareInfo.strSoftwareVersion = "";
|
|
|
-
|
|
|
//pTask->taskInfo.strSomkingCycle = _T("{ \"type\" : 0, \"day\" : 0, \"week\" : 0, \"time\" : \"20:30\" } ");
|
|
|
pTask->taskInfo.stSomkingCycle.nType = 1;
|
|
|
pTask->taskInfo.stSomkingCycle.nWeek = 0;
|
|
@@ -1263,7 +1199,7 @@ void CSATExecutor::SmokeTaskPretreated(std::list<SATHTTP::STTask>::iterator &it)
|
|
|
|
|
|
// 获取执行时间;
|
|
|
int hour, minute;
|
|
|
- sscanf(pTask->taskInfo.stSomkingCycle.strTime.c_str(), _T("%d:%d"), &hour, &minute);
|
|
|
+ sscanf_s(pTask->taskInfo.stSomkingCycle.strTime.c_str(), _T("%d:%d"), &hour, &minute);
|
|
|
// 是否到达指定时间;
|
|
|
if ( pTask->taskInfo.stSomkingCycle.nType == 0 ) {// 立即;
|
|
|
bTimeIsUp = true;
|
|
@@ -1284,20 +1220,7 @@ void CSATExecutor::SmokeTaskPretreated(std::list<SATHTTP::STTask>::iterator &it)
|
|
|
|
|
|
// 到达执行时间;
|
|
|
if ( bTimeIsUp ) {
|
|
|
- std::string strImagePath;
|
|
|
- // 检测编译服务器是否有升级包;
|
|
|
- if ( !IsUpgradeImageExist(buildSerInfo, pTask->SoftwareInfo, strImagePath) ) {
|
|
|
- // 任务失败;
|
|
|
- // 如何提交这个里的失败结果 ?
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // 如果有升级包,下载到本地;
|
|
|
-
|
|
|
- // 如果下载成功且md5校验成功, adb命令上传到电视中;
|
|
|
-
|
|
|
- // 上传成功,等待升级成功;
|
|
|
-
|
|
|
+ // 下载任务,并添加到队列中;
|
|
|
DownloadTask(*pTask);
|
|
|
// 移除;
|
|
|
it = m_vtSmokingTask.erase(it);
|
|
@@ -1305,93 +1228,6 @@ void CSATExecutor::SmokeTaskPretreated(std::list<SATHTTP::STTask>::iterator &it)
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
-bool CSATExecutor::IsUpgradeImageExist(SATHTTP::STBuildServerInfo &buildSerInfo, SATHTTP::STUpgradeImgInfo &softWareInfo, std::string &imagePath)
|
|
|
-{
|
|
|
- // 获取当前时间(1900-01-01开始的Unix时间戳);
|
|
|
- __time64_t gmt = time(NULL);
|
|
|
- struct tm gmtm = { 0 };
|
|
|
- // 时间戳转成本地时间;
|
|
|
- localtime_s(&gmtm, &gmt);
|
|
|
- // 拼路径;
|
|
|
- TCHAR szImageName[MAX_PATH] = {0};
|
|
|
- TCHAR szImagePath[MAX_PATH] = {0};
|
|
|
- // 路径;
|
|
|
- _stprintf_s(szImagePath, _T("%s/DailyBuild_%s_%02d%02d"),
|
|
|
- buildSerInfo.strBuildServerImgPath.c_str(),
|
|
|
- softWareInfo.strSoftwareName.c_str(), gmtm.tm_mon+1, gmtm.tm_mday);
|
|
|
- // 文件;
|
|
|
- _stprintf_s(szImageName, _T("signed-ota_rt2851_update.zip"));
|
|
|
-
|
|
|
- std::string data;
|
|
|
- std::string command;
|
|
|
- command.append(_T("ls "));
|
|
|
- command.append(szImagePath);
|
|
|
- // 连接服务器查看路径是否存在;
|
|
|
- CWinSsh2Proc winssh2;
|
|
|
- if ( winssh2.InitSocket() ) {
|
|
|
- if ( winssh2.ssh2_connect(buildSerInfo.strBuildServerAddress, buildSerInfo.strBuildServerUser, buildSerInfo.strBuildServerPwd, buildSerInfo.nBuildServerPort) ) {
|
|
|
- if ( winssh2.ssh2_execute_command(command, data) ) {
|
|
|
- // 以\n为分隔符;
|
|
|
- std::vector<std::string> vt;
|
|
|
- GLOBAL::Split(data, "\n", vt);
|
|
|
- // 遍历:是否有指定文件名存在;
|
|
|
- for (std::vector<std::string>::iterator it = vt.begin(); it != vt.end(); it++ ) {
|
|
|
- if ( _tcsicmp(it->c_str(), szImageName) == 0 ) {
|
|
|
- // 存在该镜像文件;
|
|
|
- imagePath.append(szImagePath);
|
|
|
- imagePath.append("/");
|
|
|
- imagePath.append(szImageName);
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return false;
|
|
|
-}
|
|
|
-
|
|
|
-bool CSATExecutor::DownloadImage(SATHTTP::STBuildServerInfo &buildSerInfo, std::string strImagePath, std::string strLocalPath)
|
|
|
-{
|
|
|
- std::string md5;
|
|
|
- std::string data;
|
|
|
- std::string command;
|
|
|
- command.append(_T("md5sum "));
|
|
|
- command.append(strImagePath);
|
|
|
- // 连接服务器查看路径是否存在;
|
|
|
- CWinSsh2Proc winssh2;
|
|
|
- if ( winssh2.InitSocket() ) {
|
|
|
- if ( winssh2.ssh2_connect(buildSerInfo.strBuildServerAddress, buildSerInfo.strBuildServerUser, buildSerInfo.strBuildServerPwd, buildSerInfo.nBuildServerPort) ) {
|
|
|
- // 先记录出md5值;
|
|
|
- if ( winssh2.ssh2_execute_command(command, data) ) {
|
|
|
- // 以2空格为分隔符;
|
|
|
- std::vector<std::string> vt;
|
|
|
- GLOBAL::Split(data, " ", vt);
|
|
|
- if ( vt.size() == 2) {
|
|
|
- md5 = vt.at(0);
|
|
|
- // 下载镜像;
|
|
|
- if ( winssh2.ssh2_sftp_download(strImagePath, strLocalPath) ) {
|
|
|
- // 下载成功,计算本地镜像md5值;
|
|
|
- }
|
|
|
- else {
|
|
|
- // 下载失败,任务失败;
|
|
|
- // 提交任务失败;
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- // 获取md5失败,任务失败;
|
|
|
- // 提交任务失败;
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- return false;
|
|
|
-}
|
|
|
-
|
|
|
void CSATExecutor::StartWork()
|
|
|
{
|
|
|
m_hEventHearbeat = CreateEvent(NULL, TRUE, FALSE, NULL);
|
|
@@ -1791,8 +1627,7 @@ DWORD CSATExecutor::WathTVPortThread(PVOID lpVoid)
|
|
|
buffer = (char*)szBuffer;
|
|
|
__time64_t gmt = time(NULL);// 获取当前日历时间(1900-01-01开始的Unix时间戳);
|
|
|
// 遍历是否有符合的子串;
|
|
|
- for ( std::vector<std::string>::iterator it = vtNotifyReboot.begin(); it != vtNotifyReboot.end(); it++ )
|
|
|
- {
|
|
|
+ for ( std::vector<std::string>::iterator it = vtNotifyReboot.begin(); it != vtNotifyReboot.end(); it++ ) {
|
|
|
if ( _tcsstr(buffer.c_str(), it->c_str()) ) {
|
|
|
nType = 1;
|
|
|
bAbnormal = true;
|
|
@@ -1801,8 +1636,7 @@ DWORD CSATExecutor::WathTVPortThread(PVOID lpVoid)
|
|
|
}
|
|
|
|
|
|
if ( !bAbnormal ) {
|
|
|
- for ( std::vector<std::string>::iterator it = vtNotifyShutdown.begin(); it != vtNotifyShutdown.end(); it++ )
|
|
|
- {
|
|
|
+ for ( std::vector<std::string>::iterator it = vtNotifyShutdown.begin(); it != vtNotifyShutdown.end(); it++ ) {
|
|
|
if ( _tcsstr(buffer.c_str(), it->c_str()) ) {
|
|
|
nType = -1;
|
|
|
bAbnormal = true;
|
|
@@ -1817,8 +1651,7 @@ DWORD CSATExecutor::WathTVPortThread(PVOID lpVoid)
|
|
|
#ifdef _DEBUG
|
|
|
TRACE3("判断时间%ld-通知时间%ld=相差时间%ld\n\n", gmt, GLOBAL::g_PyNotify.datetime, nd);
|
|
|
#endif
|
|
|
- if ( nd < 60)
|
|
|
- {
|
|
|
+ if ( nd < 60) {
|
|
|
// 监测的类型与通知类型是否一致;
|
|
|
if ( (nType == 1 && GLOBAL::g_PyNotify.report_type == _T("reboot")) ||
|
|
|
(nType == -1 && GLOBAL::g_PyNotify.report_type == _T("shutdown")) )
|