#include <app.h>
#include <dlog.h>
-static char* key;
-static char* fname;
-static int nNum;
-int run_testcases()
+static bool app_create(void *data)
+{
+ return true;
+}
+
+static void app_control(app_control_h app_control, void *data)
{
- int result = -1;
- int i;
- gsize byte_size;
- const gchar* encoded_byte;
- guchar* byte = NULL;
-
- static const size_t sz_byte_len = sizeof(size_t);
- static const size_t sz_type = sizeof(int);
- static const size_t sz_keysize = sizeof(size_t);
- static const size_t sz_size = sizeof(size_t);
-
- char* func_name = fname;//argv[1];
- if (nNum > 2)
+ char* pszGetTCName = NULL;
+ int i = 0, result = 0, nRet = 0;
+ nRet = app_control_get_extra_data(app_control, "testcase_name", &pszGetTCName);
+ if (nRet != APP_CONTROL_ERROR_NONE)
{
- encoded_byte = key;//argv[3];
- byte = g_base64_decode(encoded_byte,&byte_size);
- byte += sz_byte_len; byte += sz_type;
- size_t keysize = *((size_t *)byte); byte += sz_keysize;
- byte += keysize;
- size_t size = *((size_t *)byte); byte += sz_size;
- void *val = (void *)byte; byte += size;
- func_name = strdup((char *)val);
- }
-
- dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Executing TC Name = %s", __FUNCTION__, __LINE__, func_name);
- for (i = 0; tc_array[i].name; i++)
+ dlog_print(DLOG_ERROR, "NativeTCT", "[%s:%d] app_control_get_extra_data returns error = %d", __FUNCTION__, __LINE__, nRet);
+ PRINT_UTC_LOG("\\n[%s][Line : %d]Unable to fetch test case name: app_control_get_extra_data API call fails\\n", __FILE__, __LINE__);
+ PRINT_TC_RESULT("%d", 1);
+ FREE_MEMORY_TC(pszGetTCName);
+ return;
+ }
+
+ dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Executing TC Name = %s", __FUNCTION__, __LINE__, pszGetTCName);
+ for (i = 0; tc_array[i].name; i++)
{
- if (!strncmp(func_name, tc_array[i].name, strlen(func_name)))
- {
- dlog_print(DLOG_INFO, "NativeTCT", "%s : Startup begin", func_name);
- if (tc_array[i].startup)
- {
- tc_array[i].startup();
- }
- dlog_print(DLOG_INFO, "NativeTCT", "%s : Startup end", func_name);
-
- dlog_print(DLOG_INFO, "NativeTCT", "%s : Body begin", func_name);
- result = tc_array[i].function();
- dlog_print(DLOG_INFO, "NativeTCT", "%s : Body end", func_name);
-
- dlog_print(DLOG_INFO, "NativeTCT", "%s : Cleanup begin", func_name);
- if (tc_array[i].cleanup)
+ if (0 == strncmp(pszGetTCName, tc_array[i].name, strlen(pszGetTCName)))
{
- tc_array[i].cleanup();
+ dlog_print(DLOG_INFO, "NativeTCT", "%s : Startup begin", pszGetTCName);
+ if (tc_array[i].startup)
+ {
+ tc_array[i].startup();
+ }
+ dlog_print(DLOG_INFO, "NativeTCT", "%s : Startup end", pszGetTCName);
+
+ dlog_print(DLOG_INFO, "NativeTCT", "%s : Body begin", pszGetTCName);
+ result = tc_array[i].function();
+ dlog_print(DLOG_INFO, "NativeTCT", "%s returns value = %d", pszGetTCName, result);
+ dlog_print(DLOG_INFO, "NativeTCT", "%s : Body end", pszGetTCName);
+
+ dlog_print(DLOG_INFO, "NativeTCT", "%s : Cleanup begin", pszGetTCName);
+ if (tc_array[i].cleanup)
+ {
+ tc_array[i].cleanup();
+ }
+ dlog_print(DLOG_INFO, "NativeTCT", "%s : Cleanup end", pszGetTCName);
+ PRINT_TC_RESULT("%d", result);
+ FREE_MEMORY_TC(pszGetTCName);
+ return;
}
- dlog_print(DLOG_INFO, "NativeTCT", "%s : Cleanup end", func_name);
- FILE *fres = fopen("/tmp/tcresult","w"); fprintf(fres, "%d", result); fclose(fres); return result;
- }
- }
-
- dlog_print(DLOG_ERROR, "NativeTCT", "[%s:%d] Unable to execute %s : Unknown Test Case Name", __FUNCTION__, __LINE__, func_name);
- printf("Unknown testcase name: \"%s\"\n", func_name);
- return 2;
-}
+ }
+ dlog_print(DLOG_ERROR, "NativeTCT", "[%s:%d] Unable to execute %s : Unknown Test Case Name", __FUNCTION__, __LINE__, pszGetTCName);
+ PRINT_UTC_LOG("\\n[%s][Line : %d]Unable to execute %s : Unknown Test Case Name\\n", __FILE__, __LINE__, pszGetTCName);
+ PRINT_TC_RESULT("%d", 1);
+ FREE_MEMORY_TC(pszGetTCName);
+ return;
+}
-static bool app_create(void *data)
+static void app_terminate(void *data)
{
- run_testcases();
- return false; // quit app
+ dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Application Package is now Terminating", __FUNCTION__, __LINE__);
}
int main(int argc, char *argv[])
{
int ret = 0;
- fname = argv[1];
- key = argv[3];
- nNum = argc;
- ui_app_lifecycle_callback_s event_callback = {0,};
+
+ ui_app_lifecycle_callback_s event_callback = { 0, };
event_callback.create = app_create;
+ event_callback.terminate = app_terminate;
+ event_callback.app_control = app_control;
//setting gcda file location for coverage
- setenv("GCOV_PREFIX","/tmp",1);
+ setenv("GCOV_PREFIX", "/tmp", 1);
dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Coverage *.gcda File location set to /tmp/home/abuild/rpmbuild/BUILD/ ", __FUNCTION__, __LINE__);
dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Application Main Function is Invoked", __FUNCTION__, __LINE__);
-
ret = ui_app_main(argc, argv, &event_callback, NULL);
if (ret != APP_ERROR_NONE)
{
dlog_print(DLOG_ERROR, "NativeTCT", "Application ui_app_main call gets failed. err = %d", ret);
- FPRINTF("\\n[Line No : %d]Unable to execute test cases: ui_app_main API call gets failed\n", __LINE__);
+ PRINT_UTC_LOG("\\n[%s][Line : %d]Application ui_app_main call gets failed. err = %d\\n", __FILE__, __LINE__, ret);
+ PRINT_TC_RESULT("%d", 1);
+ return ret;
}
-
+
dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Application Package is Terminated", __FUNCTION__, __LINE__);
return ret;
}
+