//
#include <stdio.h>
#include <string.h>
+#include <pthread.h>
#include "tct_common.h"
#ifdef MOBILE
#include "tct-key-manager-core_tv.h"
#endif
-#ifdef COMMON_IOT
+#ifdef COMMON_IOT
#include "tct-key-manager-core_common_iot.h"
#endif //COMMON_IOT
#include <Elementary.h>
-typedef struct appdata {
- Evas_Object *win;
- Evas_Object *conform;
- Evas_Object *label;
-} appdata_s;
+#define MAX_TESTS 10000
+
+pthread_t worker_thread;
+
+struct fifo_t {
+ pthread_mutex_t mutt;
+ pthread_cond_t cond;
+ char *name[MAX_TESTS];
+ int wait;
+ int first;
+ int last;
+ int exit;
+} fifo;
+
+void fifo_init() {
+ pthread_mutex_init(&fifo.mutt, NULL);
+ pthread_cond_init(&fifo.cond, NULL);
+ fifo.wait = 0;
+ fifo.first = 0;
+ fifo.last = 0;
+ fifo.exit = 0;
+}
-static bool app_create(void *data)
-{
- return true;
+void fifo_push(char *ptr) {
+ pthread_mutex_lock(&fifo.mutt);
+ fifo.name[fifo.last++] = ptr;
+ pthread_mutex_unlock(&fifo.mutt);
+ pthread_cond_signal(&fifo.cond);
}
-static void app_control(app_control_h app_control, void *data)
-{
- 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)
- {
- 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;
+char *fifo_pop_block() {
+ char *result = NULL;
+ while (!fifo.exit) {
+ pthread_mutex_lock(&fifo.mutt);
+ if (fifo.first < fifo.last) {
+ result = fifo.name[fifo.first++];
+ pthread_mutex_unlock(&fifo.mutt);
+ return result;
+ }
+ fifo.wait = 1;
+ pthread_cond_wait(&fifo.cond, &fifo.mutt);
+ fifo.wait = 0;
+ pthread_mutex_unlock(&fifo.mutt);
}
+ return NULL;
+}
+
+void fifo_exit() {
+ fifo.exit = 1;
+ if (fifo.wait)
+ pthread_cond_signal(&fifo.cond);
+ else
+ pthread_cancel(worker_thread);
+}
+
+void app_control_logic(char *pszGetTCName) {
+ int i=0, result=0;
dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Executing TC Name = %s", __FUNCTION__, __LINE__, pszGetTCName);
for ( i = 0; tc_array[i].name; i++ )
return;
}
+void *worker(void *param) {
+ char *job;
+
+ while((job = fifo_pop_block()))
+ app_control_logic(job);
+
+ return NULL;
+}
+
+typedef struct appdata {
+ Evas_Object *win;
+ Evas_Object *conform;
+ Evas_Object *label;
+} appdata_s;
+
+static bool app_create(void *data)
+{
+ return true;
+}
+
+static void app_control(app_control_h app_control, void *data)
+{
+ char* pszGetTCName = NULL;
+ int nRet=0;
+ nRet = app_control_get_extra_data(app_control, "testcase_name", &pszGetTCName);
+ if(nRet != APP_CONTROL_ERROR_NONE)
+ {
+ 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;
+ }
+
+ fifo_push(pszGetTCName);
+ return;
+}
+
static void app_terminate(void *data)
{
- dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Application Package is now Terminating", __FUNCTION__, __LINE__);
+ fifo_exit();
+ pthread_join(worker_thread, NULL);
+ dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Application Package is now Terminating", __FUNCTION__, __LINE__);
}
int main(int argc, char *argv[])
event_callback.terminate = app_terminate;
event_callback.app_control = app_control;
+ fifo_init();
+ pthread_create(&worker_thread, NULL, worker, NULL);
+
//setting gcda file location for coverage
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__);