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 */
20 static inline void lutf_log_print(bool error, char *color1, char *color2,
21 char *file, int line, char *fmt, ...)
25 char debugtimestr[30];
29 /* check if the log file has grown too large */
31 if (st.st_size > LARGE_LOG_FILE)
32 out = freopen(outlog, "w", out);
35 ctime_r(&debugnow, debugtimestr);
36 for (di = 0; di < 30; di++) {
37 if (debugtimestr[di] == '\n')
38 debugtimestr[di] = '\0';
41 fprintf(out, "%s%s %s:%s:%d " RESET "%s- ", color1,
42 (error) ? "ERROR" : "", debugtimestr, file, line, color2);
44 vfprintf(out, fmt, args);
46 fprintf(out, RESET"\n");
50 #define PERROR(fmt, args...) lutf_log_print(true, BOLDRED, RED, __FILE__, __LINE__, fmt, ## args)
51 #define PDEBUG(fmt, args...) lutf_log_print(false, BOLDGREEN, GREEN, __FILE__, __LINE__, fmt, ## args)
53 typedef struct hb_info_s {
54 struct sockaddr_in master_address;
55 int agent_telnet_port;
56 char node_name[MAX_STR_LEN];
59 typedef struct lutf_listener_info_s {
63 } lutf_listener_info_t;
65 typedef struct lutf_config_params_s {
66 lutf_listener_info_t l_info;
67 lutf_run_mode_t shell; /* run in [non]-interactive or daemon mode */
68 char *cfg_path; /* path to config file */
69 char *lutf_path; /* path to lutf */
70 char *py_path; /* other python specific paths */
71 char *master_name; /* name of master. Important if I'm an agent */
72 char *suite; /* name of suite to run. Run all if not present */
73 char *suite_list; /* list of suites to run. Takes precedence
74 over single suite parameter */
75 char *script; /* name of script to run. Suite must be specified */
76 char *pattern; /* file match pattern */
77 char *results_file; /* path to results file */
78 char *tmp_dir; /* directory to put temporary files */
79 struct cYAML *agents; /* list of agents to wait for before
82 } lutf_config_params_t;
84 extern lutf_config_params_t g_lutf_cfg;
86 static inline const char *lutf_rc2str(lutf_rc_t rc)
88 static const char * const str[] = {
89 [EN_LUTF_RC_OK] = "RC_OK",
90 [EN_LUTF_RC_FAIL*-1] = "RC_FAIL",
91 [EN_LUTF_RC_SYS_ERR*-1] = "RC_SYSTEM_ERROR",
92 [EN_LUTF_RC_BAD_VERSION*-1] = "RC_BAD_VERSION",
93 [EN_LUTF_RC_SOCKET_FAIL*-1] = "RC_SOCKET_FAIL",
94 [EN_LUTF_RC_BIND_FAILED*-1] = "RC_BIND_FAIL",
95 [EN_LUTF_RC_LISTEN_FAILED*-1] = "RC_LISTEN_FAIL",
96 [EN_LUTF_RC_CLIENT_CLOSED*-1] = "RC_CLIENT_CLOSED",
97 [EN_LUTF_RC_ERR_THREAD_STARTUP*-1] = "RC_ERR_THREAD_START",
98 [EN_LUTF_RC_AGENT_NOT_FOUND*-1] = "RC_AGENT_NOT_FOUND",
99 [EN_LUTF_RC_PY_IMPORT_FAIL*-1] = "RC_PY_IMPORT_FAIL",
100 [EN_LUTF_RC_PY_SCRIPT_FAIL*-1] = "RC_PY_SCRIPT_FAIL",
101 [EN_LUTF_RC_RPC_FAIL*-1] = "RC_RPC_FAIL",
102 [EN_LUTF_RC_OOM*-1] = "RC_OOM",
103 [EN_LUTF_RC_BAD_PARAM*-1] = "RC_BAD_PARAM",
104 [EN_LUTF_RC_BAD_ADDR*-1] = "RC_BAD_ADDR",
105 [EN_LUTF_RC_MISSING_PARAM*-1] = "RC_MISSING_PARAM",
106 [EN_LUTF_RC_TIMEOUT*-1] = "RC_TIMEOUT",
109 if (rc <= EN_LUTF_RC_MAX)
117 int establishTCPConnection(unsigned long uiAddress,
123 lutf_rc_t sendTcpMessage(int iTcpSocket, char *pcBody, int iBodySize);
125 lutf_rc_t lutf_send_msg(int fd, char *msg, size_t msg_size,
126 lutf_msg_type_t type);
128 lutf_rc_t populateMsgHdr(int rsocket, char *msg_hdr,
129 int msg_type, int msg_size,
130 int lutf_version_number);
132 lutf_rc_t readTcpMessage(int iFd, char *pcBuffer,
133 int iBufferSize, int iTimeout);
135 lutf_rc_t closeTcpConnection(int iTcpSocket);