9 #include "lutf_common.h"
10 #include "lutf_agent.h"
11 #include "lutf_message.h"
16 #define OUT_LOG_NAME "lutf_out.log"
17 #define OUT_PY_LOG "lutf_py.log"
18 #define LARGE_LOG_FILE 400000000 /* 400 MB */
22 char debugtimestr[30];
24 static inline void lutf_log_print(bool error, char *color1, char *color2,
25 char *file, int line, char *fmt, ...)
29 char debugtimestr[30];
33 /* check if the log file has grown too large */
35 if (st.st_size > LARGE_LOG_FILE)
36 out = freopen(outlog, "w", out);
39 ctime_r(&debugnow, debugtimestr);
40 for (di = 0; di < 30; di++) {
41 if (debugtimestr[di] == '\n')
42 debugtimestr[di] = '\0';
45 fprintf(out, "%s%s %s:%s:%d " RESET "%s- ", color1,
46 (error) ? "ERROR" : "", debugtimestr, file, line, color2);
48 vfprintf(out, fmt, args);
50 fprintf(out, RESET"\n");
54 #define PERROR(fmt, args...) lutf_log_print(true, BOLDRED, RED, __FILE__, __LINE__, fmt, ## args)
55 #define PDEBUG(fmt, args...) lutf_log_print(false, BOLDGREEN, GREEN, __FILE__, __LINE__, fmt, ## args)
57 typedef struct hb_info_s {
58 struct sockaddr_in master_address;
59 int agent_telnet_port;
60 char node_name[MAX_STR_LEN];
63 typedef struct lutf_listener_info_s {
67 } lutf_listener_info_t;
69 typedef struct lutf_config_params_s {
70 lutf_listener_info_t l_info;
71 lutf_run_mode_t shell; /* run in [non]-interactive or daemon mode */
72 char *cfg_path; /* path to config file */
73 char *lutf_path; /* path to lutf */
74 char *py_path; /* other python specific paths */
75 char *master_name; /* name of master. Important if I'm an agent */
76 char *suite; /* name of suite to run. Run all if not present */
77 char *script; /* name of script to run. Suite must be specified */
78 char *pattern; /* file match pattern */
79 char *results_file; /* path to results file */
80 char *tmp_dir; /* directory to put temporary files */
81 struct cYAML *agents; /* list of agents to wait for before
84 } lutf_config_params_t;
86 lutf_config_params_t g_lutf_cfg;
88 static inline char *lutf_rc2str(lutf_rc_t rc)
91 [EN_LUTF_RC_OK] = "RC_OK",
92 [EN_LUTF_RC_FAIL*-1] = "RC_FAIL",
93 [EN_LUTF_RC_SYS_ERR*-1] = "RC_SYSTEM_ERROR",
94 [EN_LUTF_RC_BAD_VERSION*-1] = "RC_BAD_VERSION",
95 [EN_LUTF_RC_SOCKET_FAIL*-1] = "RC_SOCKET_FAIL",
96 [EN_LUTF_RC_BIND_FAILED*-1] = "RC_BIND_FAIL",
97 [EN_LUTF_RC_LISTEN_FAILED*-1] = "RC_LISTEN_FAIL",
98 [EN_LUTF_RC_CLIENT_CLOSED*-1] = "RC_CLIENT_CLOSED",
99 [EN_LUTF_RC_ERR_THREAD_STARTUP*-1] = "RC_ERR_THREAD_START",
100 [EN_LUTF_RC_AGENT_NOT_FOUND*-1] = "RC_AGENT_NOT_FOUND",
101 [EN_LUTF_RC_PY_IMPORT_FAIL*-1] = "RC_PY_IMPORT_FAIL",
102 [EN_LUTF_RC_PY_SCRIPT_FAIL*-1] = "RC_PY_SCRIPT_FAIL",
103 [EN_LUTF_RC_RPC_FAIL*-1] = "RC_RPC_FAIL",
104 [EN_LUTF_RC_OOM*-1] = "RC_OOM",
105 [EN_LUTF_RC_BAD_PARAM*-1] = "RC_BAD_PARAM",
106 [EN_LUTF_RC_BAD_ADDR*-1] = "RC_BAD_ADDR",
107 [EN_LUTF_RC_MISSING_PARAM*-1] = "RC_MISSING_PARAM",
108 [EN_LUTF_RC_TIMEOUT*-1] = "RC_TIMEOUT",
111 if (rc <= EN_LUTF_RC_MAX)
119 int establishTCPConnection(unsigned long uiAddress,
125 lutf_rc_t sendTcpMessage(int iTcpSocket, char *pcBody, int iBodySize);
127 lutf_rc_t lutf_send_msg(int fd, char *msg, size_t msg_size,
128 lutf_msg_type_t type);
130 lutf_rc_t populateMsgHdr(int rsocket, char *msg_hdr,
131 int msg_type, int msg_size,
132 int lutf_version_number);
134 lutf_rc_t readTcpMessage(int iFd, char *pcBuffer,
135 int iBufferSize, int iTimeout);
137 lutf_rc_t closeTcpConnection(int iTcpSocket);