From: daiyoung777.kim
Date: Sat, 1 Dec 2012 04:56:02 +0000 (+0900)
Subject: -supported report that has compliance check format
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3fd85570d268c55be515b7a4d0de9a0fb9f5e1c6;p=sdk%2Femulator%2Femulator-test.git
-supported report that has compliance check format
---
diff --git a/vts/script/main.lua b/vts/script/main.lua
index bd1d7b1..5bb872e 100644
--- a/vts/script/main.lua
+++ b/vts/script/main.lua
@@ -11,12 +11,19 @@ env = Env();
env.modulepath = "~/tizen-sdk/tools/emulator/bin";
env.emulator_manager_module = "emulator-manager.jar";
env.vmname = "created_from_lua";
+env.report_file_prefix_summary = "summary_";
+env.report_file_prefix_details = "details_";
+env.report_dir = "../report/"; -- assume that has been created.
+--env.modulepath = "/c/tizen-sdk/tools/emulator/bin";
--env.modulepath = "c:\\tizen-sdk\\tools\\emulator\\bin";
+--model = TCModel();
+--model:SetEnv(env);
+--settcmodel(model);
-model = TCModel();
-model:SetEnv(env);
+-- set test model object
+SetEnv(env);
local script_path = "..//script//"
@@ -31,21 +38,23 @@ dofile(script_path .. "tc_compliance_web_ide.lua")
dofile(script_path .. "tc_compliance_native_ide.lua")
-tclib.kill_emulator();
+--tclib.kill_emulator();
-- call test case in each lua file's function
test_emulator_manager(env);
-test_network_check();
-test_audio_video();
+--test_network_check();
+--test_audio_video();
--test_camera();
-test_event_injector();
+--test_event_injector();
test_compliance_web_ide(env);
test_compliance_native_ide(env);
tclib.kill_emulator();
-test_skinserver();
---
+--test_skinserver();
--
+---model:Stop();
+
+-
print("All test was completed");
--
--
diff --git a/vts/script/tc_emulator_manager.lua b/vts/script/tc_emulator_manager.lua
index 7adf7e7..95e229c 100644
--- a/vts/script/tc_emulator_manager.lua
+++ b/vts/script/tc_emulator_manager.lua
@@ -33,26 +33,31 @@ function test_emulator_manager(env)
local em_tst1 = TcEM_create("create_vm");
local em_tst2 = TcEM_create_select_size_of_the_ram("create_select_ram");
local em_tst3 = TcEM_create_select_resolution("create_select_res");
- local em_tst4 = TcEM_create_select_display_density("create_select_disp");
- local em_tst5 = TcEM_create_select_file_sharing("create_select_file_share");
- local em_tst6 = TcEM_create_select_hw_virtualization("create_select_hw_vritualization");
- local em_tst7 = TcEM_clone("clone");
+ --local em_tst4 = TcEM_create_select_display_density("create_select_disp");
+ --local em_tst5 = TcEM_create_select_file_sharing("create_select_file_share");
+ --local em_tst6 = TcEM_create_select_hw_virtualization("create_select_hw_vritualization");
+ --local em_tst7 = TcEM_clone("clone");
em_suite = TsEM("emulator-manager-test");
em_suite:AddTest(em_tst1);
em_suite:AddTest(em_tst2);
em_suite:AddTest(em_tst3);
- em_suite:AddTest(em_tst4);
- em_suite:AddTest(em_tst5);
- em_suite:AddTest(em_tst6);
- em_suite:AddTest(em_tst7);
+ --em_suite:AddTest(em_tst4);
+ --em_suite:AddTest(em_tst5);
+ --em_suite:AddTest(em_tst6);
+ --em_suite:AddTest(em_tst7);
--
--
+ -- emulator-manager create -n test -p
+
-- add emulator launching test
- add_launching_test(em_suite);
+ --add_launching_test(em_suite);
+
+ --model:Add(em_suite);
+ AddTestSuite(em_suite);
em_suite:runTest();
diff --git a/vts/src/Report.cpp b/vts/src/Report.cpp
index f889b45..12bb1f9 100644
--- a/vts/src/Report.cpp
+++ b/vts/src/Report.cpp
@@ -4,27 +4,36 @@
#include
#include
#include "util.h"
+#include "tcbase.h"
+#include "reportformat.h"
#define __HTML_OUTPUT_FILE "report.html"
+namespace te_test {
//
-//HtmlFileReport
+//DetailReport
//
-HtmlFileReport::HtmlFileReport(TCModel* model) : Report(model)
+DetailReport::DetailReport(TCModel* model) : Report(model)
{
- std::string filename, timestr;
- make_timestamp(timestr);
+ std::string filename;
+
filename = "..//report//";
- filename.append(timestr);
- filename.append("_Report.html");
- m_fp = fopen(filename.c_str(), "wt");
+ filename.append(model->m_timestr);
+ filename.append("_Report.html");
+ m_fp = fopen(filename.c_str(), "wt");
+ if (m_fp == NULL)
+ {
+ printf("[ERROR] : fail to create html report\n");
+ return;
+ }
+
config_css();
BeginTable();
MakeColumnHeader();
}
-HtmlFileReport::~HtmlFileReport()
+DetailReport::~DetailReport()
{
EndTable();
if (m_fp)
@@ -40,7 +49,7 @@ font-weight: bold; \
font-size: 11px; \
color: #404040;} "
-void HtmlFileReport::config_css()
+void DetailReport::config_css()
{
if (!m_fp)
return;
@@ -53,21 +62,21 @@ void HtmlFileReport::config_css()
fprintf(m_fp, "\n");
}
-void HtmlFileReport::BeginTable()
+void DetailReport::BeginTable()
{
if (!m_fp)
return;
fprintf(m_fp, "\n");
}
-void HtmlFileReport::EndTable()
+void DetailReport::EndTable()
{
if (!m_fp)
return;
fprintf(m_fp, "
\n");
}
-void HtmlFileReport::BeginRow(const int tclevel)
+void DetailReport::BeginRow(const int tclevel)
{
if (!m_fp)
return;
@@ -83,7 +92,7 @@ void HtmlFileReport::BeginRow(const int tclevel)
fprintf(m_fp, "\n", color.c_str());
}
-void HtmlFileReport::EndRow()
+void DetailReport::EndRow()
{
if (!m_fp)
return;
@@ -91,12 +100,12 @@ void HtmlFileReport::EndRow()
}
-void HtmlFileReport::MakeColumnHeader()
+void DetailReport::MakeColumnHeader()
{
if (!m_fp)
return;
- std::string headerstr = "
Test time | Category | Sub category | Test Case | TC Level | Result | Command | Output | Etc |
";
+ std::string headerstr = "Time | Category | Sub category | TCs | TC Level | Result | Command | Output | Etc |
";
fprintf(m_fp, "%s\n", headerstr.c_str());
}
@@ -120,22 +129,139 @@ void make_tclevel_str(const int tclevel, std::string& levelstr)
}
}
-void HtmlFileReport::Write(const int tclevel, tscptr cat, tscptr subcat,
- tscptr tcname, bool issucc, tscptr cmd, tscptr output, tscptr etc)
+void DetailReport::Write(tscstr timestr, tscstr tclevelstr, const int tclevel, tscstr cat, tscstr subcat,
+ tscstr tcname, bool issucc, tscstr cmd, tscstr output, tscstr etc)
{
if (!m_fp)
return;
BeginRow(tclevel);
- std::string timestr;
- make_timestamp(timestr);
- std::string tclevelstr;
- make_tclevel_str(tclevel, tclevelstr);
+ fprintf(m_fp, "%s | %s | %s | %s | %s | | %s | %s | %s | ",
+ timestr, cat, subcat, tcname, tclevelstr, issucc ? "blue>SUCCEED" : "red>FAILURE", cmd, output, etc);
+
+}
+
+//
+
+SummaryReport::SummaryReport(TCModel* model) : Report(model)
+{
+ std::string filename;
+
+ filename = "..//report//";
+ filename.append(model->m_timestr);
+ filename.append("_SummaryReport.html");
+
+ m_fp = fopen(filename.c_str(), "wt");
+ if (m_fp == NULL)
+ {
+ printf("[ERROR] : fail to create html report\n");
+ return;
+ }
+}
- fprintf(m_fp, "%s | %s | %s | %s | %s | | %s | %s | %s | ", timestr.c_str(), cat, subcat, tcname, tclevelstr.c_str(), issucc ? "blue>SUCCEED" : "red>FAILURE", cmd, output, etc);
+SummaryReport::~SummaryReport()
+{
+ if (m_fp)
+ fclose(m_fp);
+}
+void SummaryReport::Write(tscstr timestr, tscstr tclevelstr, const int tclevel, tscstr cat, tscstr subcat,
+ tscstr tcname, bool issucc, tscstr cmd, tscstr output, tscstr etc)
+{
+ if (!m_fp)
+ return;
}
+void SummaryReport::Summarize()
+{
+ _PrintTitle();
+ _BeginTable();
+ _PrintColumnHeader();
+
+
+ TCLIST& tclist = m_model->GetTcList();
+
+ _S_FOR_NEXT(TCLIST, tclist, it)
+ {
+ smart_ptr tc = (*it);
+ if (!tc.valid())
+ continue;
+
+ _BeginRow();
+ __FPRINT_TC_ROW(m_fp, tc->GetName(), tc->GetTotCnt(), tc->GetSuccCnt(), tc->GetFailCnt(), tc->GetNotTested(), (tc->IsSucceed() ? "SUCCEED" : "FAILURE"));
+ _EndRow();
+ }
+
+ __FPRINT_TC_TOT_ROW(m_fp, m_model->m_tot_cnt, m_model->m_succ_cnt, m_model->m_fail_cnt, m_model->m_not_tested, (m_model->m_fail_cnt == 0) ? "SUCCEED" : "FAILED");
+
+ _EndTable();
+
+ _PrintSummary();
+}
+
+void SummaryReport::_PrintTitle()
+{
+ if (!m_fp)
+ return;
+
+ fprintf(m_fp, "%s",_TITLE_STR);
+
+}
+
+void SummaryReport::_PrintSummary()
+{
+ if (!m_fp)
+ return;
+
+
+ std::string linkstr;
+ linkstr = m_model->m_timestr;
+ linkstr.append("_Report.html");
+
+
+ __FPRINT_SUMMARY(m_fp, m_model->m_fail_cnt == 0 ? "SUCCEED" : "FAILED", linkstr.c_str());
+
+ //fprintf(m_fp, _HTML_SUMMARY_STR, "FAILED");
+}
+
+void SummaryReport::_BeginTable()
+{
+ if (!m_fp)
+ return;
+
+ fprintf(m_fp, "");
+
+}
+
+void SummaryReport::_EndTable()
+{
+ if (!m_fp)
+ return;
+ fprintf(m_fp, "
\n");
+}
+
+void SummaryReport::_BeginRow()
+{
+ if (!m_fp)
+ return;
+ fprintf(m_fp, "");
+}
+
+void SummaryReport::_EndRow()
+{
+ if (!m_fp)
+ return;
+ fprintf(m_fp, "
\n");
+}
+void SummaryReport::_PrintColumnHeader()
+{
+ if (!m_fp)
+ return;
+ fprintf(m_fp, _HTML_COLUMNHEADER_STR);
+}
+
+
//
// StdOutReport
//
@@ -149,19 +275,13 @@ StdOutReport::~StdOutReport()
}
-void StdOutReport::Write(const int tclevel, tscptr cat, tscptr subcat,
- tscptr tcname, bool issucc, tscptr cmd, tscptr output, tscptr etc)
+void StdOutReport::Write(tscstr timestr, tscstr tclevelstr, const int tclevel, tscstr cat, tscstr subcat,
+ tscstr tcname, bool issucc, tscstr cmd, tscstr output, tscstr etc)
{
- std::string timestr;
- make_timestamp(timestr);
- std::string tclevelstr;
- make_tclevel_str(tclevel, tclevelstr);
-
-
printf("\n\n\n");
printf("#---------------------------------------------------------------------------\n");
printf("#\n");
- printf("@ time : %s \n", timestr.c_str());
+ printf("@ time : %s \n", timestr);
printf("@ command : %s \n", cmd);
printf("@ result : %s \n", (issucc) ? "SUCCEED" : "FAILURE");
printf("@ stdout :\n%s \n", output);
@@ -169,32 +289,43 @@ void StdOutReport::Write(const int tclevel, tscptr cat, tscptr subcat,
}
+void StdOutReport::Summarize()
+{
+ printf("\n\n\n\n");
+ printf("********************************************************************\n");
+ printf("*\tSummary :\n");
+ printf("*\n");
+ printf("*\tTotal : %d \n", m_model->m_tot_cnt);
+ printf("*\tSucceed : %d \n", m_model->m_succ_cnt);
+ printf("*\tFailure :%d \n", m_model->m_fail_cnt);
+ printf("*\tNot tested: %d \n", m_model->m_not_tested);
+ printf("*\n");
+ printf("*\tResult :%s \n", (m_model->m_fail_cnt == 0) ? "Succeed" : "Failure");
+ printf("*\n");
+ printf("********************************************************************\n\n");
+}
+
//
// ReportMgr
//
-ReportMgr::ReportMgr()
+ReportMgr::ReportMgr(TCModel* model)
{
- Add(new HtmlFileReport(GetTCModel()));
- Add(new StdOutReport(GetTCModel()));
+ Add(tsnew DetailReport(model));
+ Add(tsnew SummaryReport(model));
+ Add(tsnew StdOutReport(model));
}
ReportMgr::~ReportMgr()
{
- std::cout << "~ReportMgr called" << std::endl;
Destroy();
}
void ReportMgr::Destroy()
{
- while (m_list.size() > 0)
- {
- Report* p = m_list.front();
- if (p)
- delete p;
- m_list.pop_front();
- }
+ Summarize();
+ m_list.clear();
}
void ReportMgr::Add(Report* report)
@@ -210,31 +341,45 @@ void ReportMgr::Remove(Report* report)
m_list.erase(it);
}
-void ReportMgr::Write(const int tclevel, tscptr cat,tscptr subcat,
- tscptr tcname, bool issucc, tscptr cmd, tscptr output, tscptr etc)
+void ReportMgr::Write(const int tclevel, tscstr cat,tscstr subcat,
+ tscstr tcname, bool issucc, tscstr cmd, tscstr output, tscstr etc)
{
- __REPORT_LIST::iterator it;
- for(it = m_list.begin(); it != m_list.end(); it++)
+ std::string timestr;
+ make_timestamp(timestr);
+ std::string tclevelstr;
+ make_tclevel_str(tclevel, tclevelstr);
+
+ _S_FOR_NEXT(__REPORT_LIST, m_list, it)
{
- Report* report = (*it);
- if (!report)
+ smart_ptr report = (*it);
+ if (!report.valid())
continue;
- report->Write(tclevel, cat, subcat, tcname, issucc, cmd, output, etc);
+ report->Write(timestr.c_str(), tclevelstr.c_str(), tclevel, cat, subcat, tcname, issucc, cmd, output, etc);
}
}
+void ReportMgr::Summarize()
+{
+ _S_FOR_NEXT(__REPORT_LIST, m_list, it)
+ {
+ smart_ptr report = (*it);
+ if (!report.valid())
+ continue;
+ report->Summarize();
+ }
+
+}
//
//
-ReportMgr* GetReportMgr()
-{
- static ReportMgr mgr;
- return &mgr;
-}
-ReportMgr* CreateReportMgr()
+ReportMgr* CreateReportMgr(TCModel* model)
{
- ReportMgr* mgr = new ReportMgr;
- return mgr;
+ smart_ptr rp = tsnew ReportMgr(model);
+ if (!rp.valid())
+ return tsnull;
+ return rp.detach();
}
-//
+
+} // end of namespace
+
diff --git a/vts/src/Report.h b/vts/src/Report.h
index d9a4c0d..2786363 100644
--- a/vts/src/Report.h
+++ b/vts/src/Report.h
@@ -5,32 +5,39 @@
#include
#include
#include "types.h"
-#include "tcbase.h"
+#include "obj.h"
+#include "base.h"
-using namespace te_test;
+namespace te_test {
+class TCModel;
class Report
+ : public Ref
{
public:
Report(TCModel* model) : m_model(model)
{}
- virtual ~Report(){}
- virtual void Write(const int tclevel, tscptr cat, tscptr subcat,
- tscptr tcname, bool issucc, tscptr cmd, tscptr output, tscptr etc) = 0;
+ virtual void Write(tscstr timestr, tscstr tclevelstr, const int tclevel, tscstr cat, tscstr subcat,
+ tscstr tcname, bool issucc, tscstr cmd, tscstr output, tscstr etc) = 0;
+
+ virtual void Summarize(){};
TCModel* m_model;
};
-class HtmlFileReport : public Report
+class DetailReport
+ : public Report
{
public:
- HtmlFileReport(TCModel* model);
- ~HtmlFileReport();
- void Write(const int tclevel, tscptr cat, tscptr subcat,
- tscptr tcname, bool issucc, tscptr cmd, tscptr output, tscptr etc);
+ DetailReport(TCModel* model);
+ ~DetailReport();
+ void Write(tscstr timestr, tscstr tclevelstr, const int tclevel, tscstr cat, tscstr subcat,
+ tscstr tcname, bool issucc, tscstr cmd, tscstr output, tscstr etc);
+ void Summarize(){};
+private:
void config_css();
void BeginTable();
void EndTable();
@@ -40,30 +47,62 @@ public:
FILE* m_fp;
};
-class StdOutReport : public Report
+class SummaryReport
+ : public Report
+{
+public:
+ SummaryReport(TCModel* model);
+ ~SummaryReport();
+ void Write(tscstr timestr, tscstr tclevelstr, const int tclevel, tscstr cat, tscstr subcat,
+ tscstr tcname, bool issucc, tscstr cmd, tscstr output, tscstr etc);
+ void Summarize();
+
+private:
+ void _PrintTitle();
+ void _PrintSummary();
+
+ void _BeginTable();
+ void _EndTable();
+ void _BeginRow();
+ void _EndRow();
+ void _PrintColumnHeader();
+
+
+ FILE* m_fp;
+};
+
+
+class StdOutReport
+ : public Report
{
public:
StdOutReport(TCModel* model);
~StdOutReport();
- void Write(const int tclevel, tscptr cat, tscptr subcat,
- tscptr tcname, bool issucc, tscptr cmd, tscptr output, tscptr etc);
+ void Write(tscstr timestr, tscstr tclevelstr, const int tclevel, tscstr cat, tscstr subcat,
+ tscstr tcname, bool issucc, tscstr cmd, tscstr output, tscstr etc);
+
+ void Summarize();
};
//
// ReportMgr
//
class ReportMgr
+ : public Ref
{
public:
- ReportMgr();
+
+ ReportMgr(TCModel* model);
~ReportMgr();
void Destroy();
- typedef std::list __REPORT_LIST;
-
- void Write(const int tclevel, tscptr cat,tscptr subcat,
- tscptr tcname, bool issucc, tscptr cmd, tscptr output, tscptr etc);
+
+ void Write(const int tclevel, tscstr cat,tscstr subcat,
+ tscstr tcname, bool issucc, tscstr cmd, tscstr output, tscstr etc);
+ void Summarize();
+private:
+ typedef std::list< smart_ptr > __REPORT_LIST;
void Add(Report* report);
void Remove(Report* report);
@@ -71,8 +110,9 @@ public:
};
-ReportMgr* GetReportMgr();
+ReportMgr* CreateReportMgr(TCModel* model);
+
-ReportMgr* CreateReportMgr();
+} // end of namesapce
#endif
diff --git a/vts/src/TcEM.cpp b/vts/src/TcEM.cpp
index 9b22362..b7474e4 100644
--- a/vts/src/TcEM.cpp
+++ b/vts/src/TcEM.cpp
@@ -4,13 +4,14 @@
// updated date : ...
// comments :
////////////////////////////////////////
-
-#include "TcEM.h"
#include
#include
#include
\
+ \
+ \
+
\
+ \
+ \
+ l\
+ Final \
+ Result : %s
\
+ \
+ \
+ l\
+ Click \
+ this link which provides \
+ details of test results.
\
+ \
+ \
+ l\
+ If you have some problems with an \
+ emulator-test, you can contact us those are below.
\
+ \
+ \
+ n\
+ DA : ±èÁÖ¿µ ¼ö¼® Email : j0.kim@samsung.com
\
+ \
+ \
+ n\
+ WEB-IDE : ±è°È£ ¼ö¼® Email : kh5325.kim@samsung.com \
+
\
+ \
+ \
+ n\
+ NATIVE-IDE : ±è°È£ ¼ö¼® Email : kh5325.kim@samsung.com
\
+\
+"
+
+
+#define __FPRINT_SUMMARY(fp, retval01, link02) \
+ fprintf(fp, _HTML_SUMMARY_STR, retval01, link02)
+
+
+
+#define __HTML_TC_ROW_STR "\
+\
+ \
+ %s \
+ | \
+ \
+ \
+ %d \
+ | \
+ \
+ \
+ %d \
+ | \
+ \
+ \
+ %d \
+ | \
+ \
+ \
+ %d \
+ | \
+ \
+ \
+ %s \
+ | "
+
+
+#define __FPRINT_TC_ROW(fp, module0, total1, pass2, fail3, nottested4, result5) \
+ fprintf(fp, __HTML_TC_ROW_STR, module0, total1, pass2, fail3, nottested4, result5)
+
+
+#define __HTML_TC_TOT_ROW_STR "\
+ \
+ \
+ \
+ Total \
+ | \
+ \
+ \
+ %d \
+ | \
+ \
+ \
+ %d \
+ | \
+ \
+ \
+ %d \
+ | \
+ \
+ \
+ %d \
+ | \
+ \
+ \
+ %s \
+ | \
+
"
+
+
+#define __FPRINT_TC_TOT_ROW(fp, total1, pass2, fail3, nottested4, result5) \
+ fprintf(fp, __HTML_TC_TOT_ROW_STR, total1, pass2, fail3, nottested4, result5)
+#endif
\ No newline at end of file
diff --git a/vts/src/smartptr.h b/vts/src/smartptr.h
index a10537d..8e7cf59 100644
--- a/vts/src/smartptr.h
+++ b/vts/src/smartptr.h
@@ -2,6 +2,7 @@
#define __smartptr_h__
#include "reserved.h"
+#include
template
class smart_ptr
@@ -149,13 +150,13 @@ public:
return _ptr == tsnull;
}
inline bool valid() const
- {
- return _ptr != tsnull;
+ {
+ return (_ptr != tsnull);
}
//
inline bool safe() const
{
- return this != tsnull;
+ return (this != tsnull);
}
//
inline smart_ptr& attach(T* ptr)
diff --git a/vts/src/sshell.cpp b/vts/src/sshell.cpp
index 72d1227..9c17e85 100644
--- a/vts/src/sshell.cpp
+++ b/vts/src/sshell.cpp
@@ -69,6 +69,7 @@ bool sshell::exec()
int state;
char buff[sshell::MAX_LINE];
+ printf("%s\n", m_cmd.c_str());
fp = popen(m_cmd.c_str(), "r");
if (fp == NULL)
@@ -78,11 +79,14 @@ bool sshell::exec()
return false;
}
- while (fgets(buff, sshell::MAX_LINE, fp) != NULL)
+ while (!feof(fp))
{
- printf("%s", buff);
-
- m_output += buff;
+ while (fgets(buff, sshell::MAX_LINE, fp) != NULL)
+ {
+ printf("%s", buff);
+
+ m_output += buff;
+ }
}
state = pclose(fp);
diff --git a/vts/src/tcbase.cpp b/vts/src/tcbase.cpp
index 3c830c4..61cdf4e 100644
--- a/vts/src/tcbase.cpp
+++ b/vts/src/tcbase.cpp
@@ -6,26 +6,26 @@
#include "tcbase.h"
#include "Report.h"
+#include "util.h"
namespace te_test {
-//
-// TestCase
-//
-bool FormatStr(const char* fmt, va_list varg, std::string& retval)
+//TCModel* g_tcmodel;
+
+// TObj
+
+TObj::TObj(const char* name)
+ : m_bOptional(false), m_parent(NULL), m_tclevel(eTC_LEVEL_TESTCASE),
+ m_bResult(false), m_name(name), m_desc("-"),
+ m_tot_cnt(0), m_succ_cnt(0), m_fail_cnt(0), m_not_tested(0), m_RepeatCount(1)
{
- retval = "";
- char buf[1024];
- int ret = vsnprintf(buf, 1024, fmt, varg);
- if (ret == -1)
- return false;
- buf[ret] = 0;
+ m_model = GetTCModel();
+}
- retval = ret;
- return true;
+TObj::~TObj()
+{
}
-//
void TObj::SetName(const char name)
{
@@ -87,6 +87,25 @@ bool TObj::IsOptional() const
return m_bOptional;
}
+void TObj::write_report(const int tclevel, tscstr cat, tscstr subcat, tscstr tcname, bool issucc, tscstr cmd, tscstr output, tscstr etc)
+{
+ if (!m_model)
+ return;
+
+ if (tclevel == eTC_LEVEL_TESTCASE)
+ {
+ if (issucc)
+ m_model->inc_succ_cnt();
+ else
+ m_model->inc_fail_cnt();
+ }
+
+ ReportMgr* report = m_model->GetReportMgr();
+ if (!report)
+ return;
+ report->Write(tclevel, cat, subcat, tcname, issucc, cmd, output, etc);
+}
+
//
// TC implementations
@@ -95,7 +114,6 @@ bool TObj::IsOptional() const
TC::TC(const char* name) : TObj(name)
{
SetLevel(eTC_LEVEL_TESTCASE);
- m_model = GetTCModel();
}
TC::~TC()
@@ -107,6 +125,7 @@ void TC::Add(TObj* tc)
{
tc->SetParent(this);
m_tclist.insert(m_tclist.end(), tc);
+ m_tot_cnt = m_tclist.size();
}
// todo : this code was not verified
@@ -116,6 +135,7 @@ void TC::Remove(TObj* tc)
__TC_LIST::iterator it = std::find(m_tclist.begin(), m_tclist.end(), tc);
if (it != m_tclist.end())
m_tclist.erase(it);
+ m_tot_cnt = m_tclist.size();
}
TObj* TC::Get(int idx)
@@ -128,15 +148,17 @@ TObj* TC::Get(int idx)
bool TC::Test()
{
Prepare();
- ChildTest();
+
+ RunChild();
- MakeResult();
+ _MakeResult();
Finish();
+
return m_bResult;
}
-void TC::ChildTest()
+void TC::RunChild()
{
int i = 0;
for (i = 0; i < m_RepeatCount; i++)
@@ -146,17 +168,23 @@ void TC::ChildTest()
TObj* tc = it->get();
if (tc)
{
+ if (m_model)
+ m_model->OnStarted(tc);
+
bool ret = tc->Test();
if (ret)
- m_ChildSuccessCount++;
+ m_succ_cnt++;
+ else
+ m_fail_cnt++;
+
+ if (m_model)
+ m_model->OnStopped(tc);
}
- }
- m_CurrentPos++;
+ }
}
- m_CurrentPos = 0;
}
-void TC::MakeResult()
+void TC::_MakeResult()
{
_S_FOR_NEXT(__TC_LIST, m_tclist, it)
{
@@ -176,47 +204,40 @@ void TC::MakeResult()
if (!ret)
break;
}
- //m_bResult = (m_tclist.size() == m_ChildSuccessCount) ? true : false;
-}
-
-void make_tc_names(const int tclevel, TObj* tc, std::string& cat, std::string& subcat, std::string& tcname)
-{
- if (tclevel == eTC_LEVEL_TESTSUITE)
- {
- cat = tc->GetName();
- subcat = "-";
- tcname = "-";
- }
- else if (tclevel == eTC_LEVEL_TESTCASE)
- {
- TObj* parent = tc->GetParent();
- cat = (parent) ? parent->GetName() : tc->GetName();
- subcat = tc->GetName();
- tcname = tc->GetName();
-
- }
- else if (tclevel == eTC_LEVEL_METHOD)
- {
- TObj* parent = tc->GetParent();
- TObj* grand = (parent) ? parent->GetParent() : NULL;
- cat = (grand) ? grand->GetName() : "-";
- subcat = (parent) ? parent->GetName() : "-";
- tcname = tc->GetName();
- }
}
void TC::Finish()
{
+ m_tot_cnt = m_tclist.size();
+
char outstr[512];
- sprintf(outstr, "Total = %d, Success = %d, Failure = %d",
- m_tclist.size(), m_ChildSuccessCount, (m_tclist.size() - m_ChildSuccessCount));
+ sprintf(outstr, "Total = %d, Success = %d, Failure = %d", m_tot_cnt, m_succ_cnt, m_fail_cnt);
std::string cat, subcat, tcname;
make_tc_names(m_tclevel, this, cat, subcat, tcname);
- ReportMgr* report = GetReportMgr();
- if (report)
- report->Write(m_tclevel, cat.c_str(), subcat.c_str(), m_name.c_str(), m_bResult, "-", outstr, m_desc.c_str());
+ write_report(m_tclevel, cat.c_str(), subcat.c_str(), m_name.c_str(), m_bResult, "-", outstr, m_desc.c_str());
+}
+
+// Env
+
+Env::Env()
+{
+ m_modulepath = "~/tizen-sdk/tools/emulator/bin";
+ m_emulator_manager_module = "emulator-manager.jar";
+ m_vmname = "testvm";
+
+ m_script_play_test = "/opt/home/root/codec_test_automation.sh";
+ m_script_encdec_test = "/opt/home/root/codec_test_automation.sh";
+
+ m_report_dir = "..//report//";
+
+ m_report_file_prefix_summary = "report_summary";
+ m_report_file_prefix_details = "report_tc";
+}
+
+Env::~Env()
+{
}
//
@@ -224,25 +245,69 @@ void TC::Finish()
//
TCModel::TCModel()
-: m_succ_cnt(0), m_fail_cnt(0), m_tot_cnt(0)
-{}
+: m_succ_cnt(0), m_fail_cnt(0), m_tot_cnt(0), m_not_tested(0)
+{
+ Init();
+}
TCModel::~TCModel()
{
Cleanup();
}
-void TCModel::IncSucc()
+void TCModel::Start()
+{
+ Run();
+}
+
+void TCModel::Stop()
+{
+ if (m_report.valid())
+ m_report = tsnull;
+}
+
+void TCModel::OnStarted(TObj* tc)
+{
+
+}
+
+void TCModel::OnStopped(TObj* tc)
+{
+
+}
+
+void TCModel::Run()
+{
+ _S_FOR_NEXT(TCLIST, m_tclist, it)
+ {
+ smart_ptr tc = (*it);
+ if (!tc.valid())
+ {
+ printf("[ERROR] : TCModel::Run\n");
+ break;
+ }
+ OnStarted(tc);
+
+ tc->Test();
+
+ OnStopped(tc);
+ }
+}
+
+
+
+void TCModel::inc_succ_cnt()
{
m_succ_cnt++;
m_tot_cnt++;
}
-void TCModel::IncFail()
+void TCModel::inc_fail_cnt()
{
m_fail_cnt++;
m_tot_cnt++;
}
+
void TCModel::SetEnv(const Env& env)
{
m_env = env;
@@ -251,17 +316,94 @@ void TCModel::SetEnv(const Env& env)
void TCModel::Add(TC* tc)
{
m_tclist.insert(m_tclist.end(), tc);
+ //m_tot_cnt = m_tclist.size();
+}
+
+ReportMgr* TCModel::GetReportMgr()
+{
+ if (!m_report.valid())
+ return tsnull;
+ return const_cast(m_report.get());
+}
+
+TCLIST& TCModel::GetTcList()
+{
+ return m_tclist;
+}
+
+void TCModel::Init()
+{
+ make_timestamp(m_timestr);
+
+ if (!m_report.attach(CreateReportMgr(this)).valid())
+ if (!m_report)
+ {
+ printf("[ERROR] : fail to create reprotmgr\n");
+ return;
+ }
+
+
+ printf("[INFO] : TCModel::Init\n");
}
void TCModel::Cleanup()
{
+ Stop();
m_tclist.clear();
}
+
+
+//
+void SetEnv(Env* env)
+{
+ TCModel* mdl = GetTCModel();
+ mdl->SetEnv(*env);
+}
+
+void SetTCModel(TCModel* model)
+{
+ TCModel* mdl = GetTCModel();
+ mdl->SetEnv(model->m_env);
+ //g_tcmodel = model;
+}
+
+void AddTestSuite(TC* tc)
+{
+ TCModel* mdl = GetTCModel();
+ mdl->Add(tc);
+}
+
TCModel* GetTCModel()
{
- static TCModel model;
- return &model;
+ static TCModel stmodel;
+ return &stmodel;
+}
+
+void make_tc_names(const int tclevel, TObj* tc, std::string& cat, std::string& subcat, std::string& tcname)
+{
+ if (tclevel == eTC_LEVEL_TESTSUITE)
+ {
+ cat = tc->GetName();
+ subcat = "-";
+ tcname = "-";
+ }
+ else if (tclevel == eTC_LEVEL_TESTCASE)
+ {
+ TObj* parent = tc->GetParent();
+ cat = (parent) ? parent->GetName() : tc->GetName();
+ subcat = tc->GetName();
+ tcname = tc->GetName();
+
+ }
+ else if (tclevel == eTC_LEVEL_METHOD)
+ {
+ TObj* parent = tc->GetParent();
+ TObj* grand = (parent) ? parent->GetParent() : NULL;
+ cat = (grand) ? grand->GetName() : "-";
+ subcat = (parent) ? parent->GetName() : "-";
+ tcname = tc->GetName();
+ }
}
} // end of namespace
diff --git a/vts/src/tcbase.h b/vts/src/tcbase.h
index 9737361..e525af0 100644
--- a/vts/src/tcbase.h
+++ b/vts/src/tcbase.h
@@ -7,11 +7,11 @@
#include
#include
#include
-#include
#include "sshell.h"
#include "tcmacro.h"
#include "obj.h"
#include "base.h"
+#include "Report.h"
namespace te_test {
@@ -27,7 +27,6 @@ enum
eTC_LEVEL_MODULE = 3
};
-
class CommandResultHandler
{
public:
@@ -55,6 +54,10 @@ public:
std::string m_successToken;
};
+class TCModel;
+
+TCModel* GetTCModel();
+
//
// TObj class
//
@@ -62,13 +65,8 @@ class TObj
: public Ref
{
public:
- TObj(const char* name)
- : m_bOptional(false), m_parent(NULL), m_tclevel(eTC_LEVEL_TESTCASE),
- m_bResult(false), m_name(name), m_desc("-"),
- m_ChildSuccessCount(0), m_RepeatCount(1), m_CurrentPos(0)
- {
- }
- virtual ~TObj(){}
+ TObj(const char* name);
+ virtual ~TObj();
void SetName(const char name);
void SetDesc(const char desc);
@@ -82,7 +80,6 @@ public:
virtual void Prepare(){}
virtual bool Test(){ return true; }
- virtual void MakeResult(){}
virtual void Finish(){}
virtual void AddParam(std::string name){}
@@ -93,205 +90,35 @@ public:
virtual bool IsSucceed() const;
virtual void SetOptional(const bool bOptional);
virtual bool IsOptional() const;
+
+
+ int GetSuccCnt() const { return m_succ_cnt; }
+ int GetFailCnt() const { return m_fail_cnt; }
+ int GetTotCnt() const { return m_tot_cnt; }
+ int GetNotTested() const { return m_not_tested; }
+
+ void write_report(const int tclevel, tscstr cat,tscstr subcat, tscstr tcname, bool issucc, tscstr cmd, tscstr output, tscstr etc);
protected:
int m_RepeatCount;
- int m_CurrentPos;
- int m_ChildSuccessCount;
+
+ int m_succ_cnt;
+ int m_fail_cnt;
+ int m_tot_cnt;
+ int m_not_tested;
+
+
std::string m_name;
std::string m_desc;
int m_tclevel;
bool m_bResult;
TObj* m_parent;
bool m_bOptional;
-};
-class TCModel;
-
-TCModel* GetTCModel();
-
-//
-// CommandTest class
-//
-template
-class CommandTest : public TObj
-{
-public:
- enum
- {
- eCALLTYPE_NORMAL = 0,
- eCALLTYPE_WAIT = 1,
- eCALLTYPE_REPEAT_WAIT = 2
- };
-
- CommandTest(const char* name) :
- TObj(name), m_calltype(eCALLTYPE_NORMAL), m_timeout_milli(0)
- {
- m_model = GetTCModel();
- }
-
- virtual bool Test();
-
- void AddParam(std::string name)
- {
- if (!name.empty())
- {
- m_cmd.append(" ");
- m_cmd.append(name);
- }
- }
- void AddParam(std::string name, std::string value)
- {
- if (!name.empty())
- {
- m_cmd.append(" ");
- m_cmd.append(name);
- }
- if (!value.empty())
- {
- m_cmd.append(" ");
- m_cmd.append(value);
- }
- }
-
-
- void AddParamEX(std::string name)
- {
- if (!name.empty())
- {
- m_extparams.append(" ");
- m_extparams.append(name);
- }
- }
- void AddParamEX(std::string name, std::string value)
- {
- if (!name.empty())
- {
- m_extparams.append(" ");
- m_extparams.append(name);
- }
- if (!value.empty())
- {
- m_extparams.append(" ");
- m_extparams.append(value);
- }
- }
-
- bool SetCommand(const char* cmd);
-
- void SetCallType(const int calltype)
- {
- m_calltype = calltype;
- }
-
- void SetWaitStr(const char* str)
- {
- m_waitstr = str;
- }
-
-protected:
- void FormatCommand(std::string& retval, const char* fmt, ...);
- bool Exec();
- virtual void MakeResult();
- std::string m_cmd;
- std::string m_extparams;
- std::string m_resultstr;
- std::string m_waitstr;
- RESULT_PROC m_resultProc;
TCModel* m_model;
-
- int m_timeout_milli;
- int m_calltype;
};
-bool FormatStr(const char* fmt, va_list varg, std::string& retval);
-
-template
-void CommandTest::FormatCommand(std::string& retval, const char* fmt, ...)
-{
- va_list varg;
- va_start(varg, fmt);
- FormatStr(fmt, varg, retval);
- va_end(varg);
-}
-
-template
-bool CommandTest::SetCommand(const char* cmd)
-{
- if (!cmd)
- return false;
- m_cmd = cmd;
- return true;
-}
-
-template
-void CommandTest::MakeResult()
-{
- bool ret = m_resultProc.GetResult(m_resultstr);
-
- m_bResult = (ret);
-}
-
-template
-bool CommandTest::Exec()
-{
- if (m_cmd.empty())
- return false;
-
- if (!m_extparams.empty())
- m_cmd.append(m_extparams);
-
- m_resultstr = "";
-
- sshell scmd(m_cmd.c_str());
- switch (m_calltype)
- {
- case eCALLTYPE_NORMAL:
- {
- if (!scmd.exec())
- return false;
- }
- break;
- case eCALLTYPE_WAIT :
- {
- if (!scmd.exec_and_wait_str(1000 * 60, m_waitstr.c_str()))
- return false;
- }
- break;
- case eCALLTYPE_REPEAT_WAIT :
- {
- if (!scmd.repeat_exec_and_wait_str(1000 * 60, m_waitstr.c_str()))
- return false;
- }
- break;
- }
-
- m_resultstr = scmd.result();
- return true;
-}
-
-template
-bool CommandTest::Test()
-{
- Prepare();
-
- if (!Exec())
- goto fail;
-
- MakeResult();
-
- Finish();
- return m_bResult;
-fail:
-
- m_bResult = false;
- Finish();
- return m_bResult;
-}
-
-//
// TC class
-//
class TC : public TObj
{
@@ -304,12 +131,11 @@ public:
TObj* Get(int idx);
virtual bool Test();
- virtual void MakeResult();
+ void _MakeResult();
virtual void Finish();
- TCModel* m_model;
private:
- void ChildTest();
+ void RunChild();
typedef std::vector< smart_ptr > __TC_LIST;
__TC_LIST m_tclist;
@@ -320,49 +146,72 @@ private:
struct Env
{
- Env()
- {
- m_modulepath = "~/tizen-sdk/tools/emulator/bin";
- m_emulator_manager_module = "emulator-manager.jar";
- m_vmname = "testvm";
-
- m_script_play_test = "/opt/home/root/codec_test_automation.sh";
- m_script_encdec_test = "/opt/home/root/codec_test_automation.sh";
-
- }
+public:
+ Env();
+ virtual ~Env();
std::string m_modulepath;
std::string m_emulator_manager_module;
std::string m_vmname;
std::string m_script_play_test;
- std::string m_script_encdec_test;
+ std::string m_script_encdec_test;
+
+
+ std::string m_report_dir;
+ std::string m_report_file_prefix_summary;
+ std::string m_report_file_prefix_details;
};
+typedef std::list< smart_ptr > TCLIST;
+
class TCModel
{
public:
TCModel();
virtual ~TCModel();
- void IncSucc();
- void IncFail();
+ virtual void Start();
+ virtual void Stop();
+
+ void OnStarted(TObj* tc);
+ void OnStopped(TObj* tc);
+
void SetEnv(const Env& env);
void Add(TC* tc);
+ void inc_succ_cnt();
+ void inc_fail_cnt();
+
+ ReportMgr* GetReportMgr();
+
+ TCLIST& GetTcList();
+
Env m_env;
+
+ std::string m_timestr;
private:
+ void Init();
void Cleanup();
- typedef std::list< smart_ptr > TCLIST;
+ void Run();
+
TCLIST m_tclist;
+ smart_ptr m_report;
+public:
int m_succ_cnt;
int m_fail_cnt;
int m_tot_cnt;
+ int m_not_tested;
};
+void SetTCModel(TCModel* model);
+
+void SetEnv(Env* env);
+
+void AddTestSuite(TC* tc);
void make_tc_names(const int tclevel, TObj* tc, std::string& cat, std::string& subcat, std::string& tcname);
diff --git a/vts/src/tccmd.cpp b/vts/src/tccmd.cpp
index 6e40308..a4401a1 100644
--- a/vts/src/tccmd.cpp
+++ b/vts/src/tccmd.cpp
@@ -8,7 +8,7 @@ namespace te_test {
// scmd
-scmd::scmd(const char* name) : CommandTest(name)
+scmd::scmd(const char* name) : cmdtest(name)
{
SetLevel(eTC_LEVEL_METHOD);
}
@@ -33,19 +33,19 @@ void scmd::Finish()
std::string cat, subcat, tcname;
make_tc_names(m_tclevel, this, cat, subcat, tcname);
- ReportMgr* report = GetReportMgr();
- if (report)
- report->Write(m_tclevel, cat.c_str(), subcat.c_str(), tcname.c_str(),
- m_bResult, m_cmd.c_str(), m_resultstr.c_str(), "...");
-
+ write_report(m_tclevel, cat.c_str(), subcat.c_str(), tcname.c_str(), m_bResult, m_cmd.c_str(), m_resultstr.c_str(), "...");
}
// java
sjava::sjava(const char* name) : scmd(name)
{
char buf[1024];
- sprintf(buf, "java -jar %s/%s", m_model->m_env.m_modulepath.c_str(), m_model->m_env.m_emulator_manager_module.c_str());
-
+#ifdef WIN32
+ sprintf(buf, "java -jar %s\\%s", m_model->m_env.m_modulepath.c_str(), m_model->m_env.m_emulator_manager_module.c_str());
+#else
+ sprintf(buf, "java -jar %s/%s", m_model->m_env.m_modulepath.c_str(), m_model->m_env.m_emulator_manager_module.c_str());
+#endif
+ //printf("%s\n", buf);
m_cmd = buf;
}
@@ -59,7 +59,7 @@ ssdb::ssdb(const char* name) : scmd(name)
}
//
-// cmd suite which is collection of command
+// cmd suite which is collection of commands
//
cmd_suite::cmd_suite(const char* name) : TC(name)
@@ -67,13 +67,6 @@ cmd_suite::cmd_suite(const char* name) : TC(name)
SetLevel(eTC_LEVEL_TESTSUITE);
}
-void cmd_suite::runTest()
-{
- Prepare();
- Test();
- Finish();
-}
-
void cmd_suite::AddCmdTest(scmd* tc)
{
Add(tc);
diff --git a/vts/src/tccmd.h b/vts/src/tccmd.h
index 73aa00a..ccb2002 100644
--- a/vts/src/tccmd.h
+++ b/vts/src/tccmd.h
@@ -3,11 +3,12 @@
#include "tcbase.h"
#include "tinythread.h"
+#include "cmdtest.h"
namespace te_test {
-class scmd : public CommandTest
+class scmd : public cmdtest
{
public:
scmd(const char* name);
@@ -17,20 +18,20 @@ public:
void AddParam1(std::string name)
{
- CommandTest::AddParam(name);
+ cmdtest::AddParam(name);
}
void AddParam2(std::string name, std::string value)
{
- CommandTest::AddParam(name, value);
+ cmdtest::AddParam(name, value);
}
void AddParamEX1(std::string name)
{
- CommandTest::AddParamEX(name);
+ cmdtest::AddParamEX(name);
}
void AddParamEX2(std::string name, std::string value)
{
- CommandTest::AddParamEX(name, value);
+ cmdtest::AddParamEX(name, value);
}
};
@@ -55,8 +56,6 @@ class cmd_suite : public TC
public:
cmd_suite(const char* name);
- void runTest();
-
void AddCmdTest(scmd* tc);
void AddCmdTestStr(std::string cmd);
void AddSDBCommandStr(std::string param);
diff --git a/vts/src/tcnetwork.cpp b/vts/src/tcnetwork.cpp
index 6fecfab..ef81cd3 100644
--- a/vts/src/tcnetwork.cpp
+++ b/vts/src/tcnetwork.cpp
@@ -144,13 +144,7 @@ void stcpnet::Finish()
std::string cat, subcat, tcname;
make_tc_names(m_tclevel, this, cat, subcat, tcname);
- ReportMgr* report = GetReportMgr();
- if (!report)
- return;
-
- report->Write(m_tclevel, cat.c_str(), subcat.c_str(), tcname.c_str(), m_bResult, m_request_log.c_str(), m_result_log.c_str(), "...");
-
-
+ write_report(m_tclevel, cat.c_str(), subcat.c_str(), tcname.c_str(), m_bResult, m_request_log.c_str(), m_result_log.c_str(), "...");
}
void stcpnet::add_request_log(const char* str)
diff --git a/vts/src/util.cpp b/vts/src/util.cpp
index 1b1c4a4..bf1b4ab 100644
--- a/vts/src/util.cpp
+++ b/vts/src/util.cpp
@@ -1,5 +1,6 @@
#include "util.h"
#include
+#include
#ifdef WIN32
#include
@@ -8,6 +9,19 @@
#endif
+bool format_str(const char* fmt, va_list varg, std::string& retval)
+{
+ retval = "";
+ char buf[1024];
+ int ret = vsnprintf(buf, 1024, fmt, varg);
+ if (ret == -1)
+ return false;
+ buf[ret] = 0;
+
+ retval = ret;
+ return true;
+}
+
void replacetext(std::string& str, const char* szsrc, const char* szdest)
{
std::string strsrc(szsrc);
@@ -30,31 +44,12 @@ void make_timestamp(std::string& ret)
ts = localtime(<ime);
char buf[512];
+ //strftime(buf, sizeof(buf), "%a %Y-%m-%d %H:%M:%S %Z", ts);
+ strftime(buf, sizeof(buf), "%a_%Y-%m-%d_%H-%M-%S", ts);
- strftime(buf, sizeof(buf), "%a %Y-%m-%d %H:%M:%S %Z", ts);
-
- /*sprintf(buf, "[%d] %d %d %d_%d:%d:%d",
- ts->tm_wday, /* Mon - Sun
- ts->tm_mday,
- ts->tm_mon+1,
- ts->tm_year+1900,
- ts->tm_hour,
- ts->tm_min,
- ts->tm_sec);*/
-
- //sprintf(buf, "%s", asctime(localtime(<ime)));
ret = buf;
}
-//void util_sleep(int milisec)
-//{
-// struct timespec req = { 0 };
-// struct timespec rem = { 0 };
-// req.tv_sec = (milisec / 1000);
-// req.tv_nsec = (milisec - req.tv_sec * 1000) * 1000000;
-// nanosleep(&req,&rem);
-//}
-
void ssleep(int seconds)
{
#ifdef WIN32
diff --git a/vts/src/util.h b/vts/src/util.h
index 63cbef1..271b7c4 100644
--- a/vts/src/util.h
+++ b/vts/src/util.h
@@ -4,8 +4,9 @@
#include
#include
#include
+#include
-
+bool format_str(const char* fmt, va_list varg, std::string& retval);
void replacetext(std::string& str, const char* szsrc, const char* szdest);
void make_timestamp(std::string& ret);
void ssleep(int seconds);