Просмотр исходного кода

CTS: fix up the formt strings

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
Angus Salkeld 14 лет назад
Родитель
Сommit
12ab7f7b7d

+ 3 - 7
cts/agents/common_test_agent.c

@@ -49,7 +49,6 @@
 
 #include "common_test_agent.h"
 
-int32_t parse_debug = 0;
 static char big_and_buf_rx[HOW_BIG_AND_BUF];
 ta_do_command_fn do_command;
 static qb_loop_t *poll_handle;
@@ -81,8 +80,7 @@ static void ta_handle_command (int sock, char* msg)
 	int a = 0;
 	char* func = NULL;
 
-	if (parse_debug)
-		qb_log (LOG_DEBUG,"%s (MSG:%s)", __func__, msg);
+	qb_log(LOG_DEBUG,"(MSG:%s)", msg);
 
 	str_len = strtok_r (str, ":", &saveptr);
 	assert (str_len);
@@ -93,15 +91,13 @@ static void ta_handle_command (int sock, char* msg)
 		str_arg = strtok_r (NULL, ":", &saveptr);
 		if (func == NULL) {
 			/* first "arg" is the function */
-			if (parse_debug)
-				qb_log (LOG_DEBUG, "(LEN:%s, FUNC:%s)", str_len, str_arg);
+			qb_log (LOG_TRACE, "(LEN:%s, FUNC:%s)", str_len, str_arg);
 			func = str_arg;
 			a = 0;
 		} else {
 			args[a] = str_arg;
 			a++;
-			if (parse_debug)
-				qb_log (LOG_DEBUG, "(LEN:%s, ARG:%s)", str_len, str_arg);
+			qb_log (LOG_TRACE, "(LEN:%s, ARG:%s)", str_len, str_arg);
 		}
 	}
 	do_command (sock, func, args, a+1);

+ 0 - 1
cts/agents/common_test_agent.h

@@ -43,7 +43,6 @@
 #define FAIL_STR "FAIL"
 #define NOT_SUPPORTED_STR "NOT_SUPPORTED"
 
-extern int32_t parse_debug;
 #define HOW_BIG_AND_BUF 4096
 
 typedef void (*ta_do_command_fn) (int sock, char* func, char*args[], int num_args);

+ 1 - 2
cts/agents/cpg_test_agent.c

@@ -619,8 +619,7 @@ static void do_command (int sock, char* func, char*args[], int num_args)
 	char response[100];
 	struct cpg_name group_name;
 
-	if (parse_debug)
-		qb_log (LOG_DEBUG,"RPC:%s() called.", func);
+	qb_log (LOG_TRACE, "RPC:%s() called.", func);
 
 	if (strcmp ("cpg_mcast_joined",func) == 0) {
 		struct iovec iov[5];

+ 53 - 56
cts/agents/sam_test_agent.c

@@ -428,14 +428,14 @@ static int test4 (void)
 	}
 
 	if (instance_id == 1) {
-		qb_log (LOG_INFO, "%s iid %d: sam_start", instance_id);
+		qb_log (LOG_INFO, "iid %d: sam_start", instance_id);
 		err = sam_start ();
 		if (err != CS_OK) {
 			qb_log (LOG_ERR, "Can't start hc. Error %d", err);
 			return 1;
 		}
 
-		qb_log (LOG_INFO, "%s iid %d: sam_data_getsize 6", instance_id);
+		qb_log (LOG_INFO, "iid %d: sam_data_getsize 6", instance_id);
 		err = sam_data_getsize (&size);
 		if (err != CS_OK) {
 			qb_log (LOG_ERR, "Test should return CS_OK. Error returned %d", err);
@@ -446,7 +446,7 @@ static int test4 (void)
 			return 1;
 		}
 
-		qb_log (LOG_INFO, "%s iid %d: sam_data_restore 5", instance_id);
+		qb_log (LOG_INFO, "iid %d: sam_data_restore 5", instance_id);
 		err = sam_data_restore (saved_data2, sizeof (saved_data2));
 		if (err != CS_OK) {
 			qb_log (LOG_ERR, "Test should return CS_OK. Error returned %d", err);
@@ -462,7 +462,7 @@ static int test4 (void)
 			saved_data[i] = (char)(i - 5);
 		}
 
-		qb_log (LOG_INFO, "%s iid %d: sam_data_store 5", instance_id);
+		qb_log (LOG_INFO, "iid %d: sam_data_store 5", instance_id);
 		err = sam_data_store (saved_data, sizeof (saved_data) - 7);
 		if (err != CS_OK) {
 			qb_log (LOG_ERR, "Test should return CS_OK. Error returned %d", err);
@@ -473,14 +473,14 @@ static int test4 (void)
 	}
 
 	if (instance_id == 2) {
-		qb_log (LOG_INFO, "%s iid %d: sam_start", instance_id);
+		qb_log (LOG_INFO, "iid %d: sam_start", instance_id);
 		err = sam_start ();
 		if (err != CS_OK) {
 			qb_log (LOG_ERR, "Can't start hc. Error %d", err);
 			return 1;
 		}
 
-		qb_log (LOG_INFO, "%s iid %d: sam_data_getsize 7", instance_id);
+		qb_log (LOG_INFO, "iid %d: sam_data_getsize 7", instance_id);
 		err = sam_data_getsize (&size);
 		if (err != CS_OK) {
 			qb_log (LOG_ERR, "Test should return CS_OK. Error returned %d", err);
@@ -491,7 +491,7 @@ static int test4 (void)
 			return 1;
 		}
 
-		qb_log (LOG_INFO, "%s iid %d: sam_data_restore 6", instance_id);
+		qb_log (LOG_INFO, "iid %d: sam_data_restore 6", instance_id);
 		err = sam_data_restore (saved_data2, sizeof (saved_data2));
 		if (err != CS_OK) {
 			qb_log (LOG_ERR, "Test should return CS_OK. Error returned %d", err);
@@ -507,7 +507,7 @@ static int test4 (void)
 			return 1;
 		}
 
-		qb_log (LOG_INFO, "%s iid %d: sam_data_store 6", instance_id);
+		qb_log (LOG_INFO, "iid %d: sam_data_store 6", instance_id);
 		err = sam_data_store (NULL, 0);
 		if (err != CS_OK) {
 			qb_log (LOG_ERR, "Test should return CS_OK. Error returned %d", err);
@@ -518,7 +518,7 @@ static int test4 (void)
 	}
 
 	if (instance_id == 3) {
-		qb_log (LOG_INFO, "%s iid %d: sam_data_getsize 8", instance_id);
+		qb_log (LOG_INFO, "iid %d: sam_data_getsize 8", instance_id);
 		err = sam_data_getsize (&size);
 		if (err != CS_OK) {
 			qb_log (LOG_ERR, "Test should return CS_OK. Error returned %d", err);
@@ -537,7 +537,7 @@ static int test5_hc_cb (void)
 {
 	cs_error_t res;
 
-	qb_log (LOG_INFO, "%s %d", ++test5_hc_cb_count);
+	qb_log (LOG_INFO, "%d", ++test5_hc_cb_count);
 
 	res = sam_data_store (&test5_hc_cb_count, sizeof (test5_hc_cb_count));
 
@@ -572,7 +572,7 @@ static int test5 (void)
 	}
 
 	if (instance_id == 1) {
-		qb_log (LOG_INFO, "%s iid %d: hc callback register", instance_id);
+		qb_log (LOG_INFO, "iid %d: hc callback register", instance_id);
 		error = sam_hc_callback_register (test5_hc_cb);
 		if (error != CS_OK) {
 			qb_log (LOG_ERR, "Can't register hc cb. Error %d", error);
@@ -580,7 +580,7 @@ static int test5 (void)
 		}
 
 
-		qb_log (LOG_INFO, "%s iid %d: start", instance_id);
+		qb_log (LOG_INFO, "iid %d: start", instance_id);
 		error = sam_start ();
 		if (error != CS_OK) {
 			qb_log (LOG_ERR, "Can't start hc. Error %d", error);
@@ -589,7 +589,7 @@ static int test5 (void)
 
 		sleep (2);
 
-		qb_log (LOG_INFO, "%s iid %d: Failed. Wasn't killed.", instance_id);
+		qb_log (LOG_INFO, "iid %d: Failed. Wasn't killed.", instance_id);
 		return 1;
 	}
 
@@ -601,7 +601,7 @@ static int test5 (void)
 		}
 
 		if (hc_cb_count != 11) {
-			qb_log (LOG_ERR, "%s iid %d: Premature killed. hc_cb_count should be 11 and it is %d",
+			qb_log (LOG_ERR, "iid %d: Premature killed. hc_cb_count should be 11 and it is %d",
 				__FUNCTION__, instance_id - 1, hc_cb_count);
 			return 1;
 
@@ -615,7 +615,7 @@ static int test5 (void)
 static void test6_signal (int sig) {
 	cs_error_t error;
 
-	qb_log (LOG_INFO, "%s");
+	qb_enter();
 	test6_sig_delivered++;
 
 	if ((error = sam_data_store (&test6_sig_delivered, sizeof (test6_sig_delivered))) != CS_OK) {
@@ -653,17 +653,17 @@ static int test6 (void) {
 
 		signal (SIGUSR1, test6_signal);
 
-		qb_log (LOG_INFO, "%s iid %d: start", instance_id);
+		qb_log (LOG_INFO, " iid %d: start", instance_id);
 		error = sam_start ();
 		if (error != CS_OK) {
 			qb_log (LOG_ERR, "Can't start hc. Error %d", error);
 			return 1;
 		}
 
-		qb_log (LOG_INFO, "%s iid %d: sleep 1", instance_id);
+		qb_log (LOG_INFO, "iid %d: sleep 1", instance_id);
 		sleep (1);
 
-		qb_log (LOG_INFO, "%s iid %d: hc send", instance_id);
+		qb_log (LOG_INFO, "iid %d: hc send", instance_id);
 		error = sam_hc_send ();
 		if (error != CS_OK) {
 			qb_log (LOG_ERR, "Can't send hc. Error %d", error);
@@ -671,16 +671,16 @@ static int test6 (void) {
 		}
 
 
-		qb_log (LOG_INFO, "%s iid %d: wait for delivery of signal", instance_id);
+		qb_log (LOG_INFO, "iid %d: wait for delivery of signal", instance_id);
 		while (!test6_sig_delivered) {
 			sleep (1);
 		}
 
-		qb_log (LOG_INFO, "%s iid %d: wait for real kill", instance_id);
+		qb_log (LOG_INFO, "iid %d: wait for real kill", instance_id);
 
 		sleep (3);
 
-		qb_log (LOG_INFO, "%s iid %d: wasn't killed", instance_id);
+		qb_log (LOG_INFO, "iid %d: wasn't killed", instance_id);
 		return (1);
 	}
 
@@ -704,17 +704,17 @@ static int test6 (void) {
 
 		signal (SIGUSR1, test6_signal);
 
-		qb_log (LOG_INFO, "%s iid %d: start", instance_id);
+		qb_log (LOG_INFO, "iid %d: start", instance_id);
 		error = sam_start ();
 		if (error != CS_OK) {
 			qb_log (LOG_ERR, "Can't start hc. Error %d", error);
 			return 1;
 		}
 
-		qb_log (LOG_INFO, "%s iid %d: sleep 1", instance_id);
+		qb_log (LOG_INFO, "iid %d: sleep 1", instance_id);
 		sleep (1);
 
-		qb_log (LOG_INFO, "%s iid %d: hc send", instance_id);
+		qb_log (LOG_INFO, "iid %d: hc send", instance_id);
 		error = sam_hc_send ();
 		if (error != CS_OK) {
 			qb_log (LOG_ERR, "Can't send hc. Error %d", error);
@@ -722,12 +722,12 @@ static int test6 (void) {
 		}
 
 
-		qb_log (LOG_INFO, "%s iid %d: wait for delivery of signal", instance_id);
+		qb_log (LOG_INFO, "iid %d: wait for delivery of signal", instance_id);
 		while (!test6_sig_delivered) {
 			sleep (1);
 		}
 
-		qb_log (LOG_INFO, "%s iid %d: wasn't killed", instance_id);
+		qb_log (LOG_INFO, "iid %d: wasn't killed", instance_id);
 		return (1);
 	}
 
@@ -812,14 +812,14 @@ static int test_quorum (void) {
 		 */
 		pthread_create (&kill_thread, NULL, test7_thread, NULL);
 
-		qb_log (LOG_INFO, "%s iid %d: start - should block forever (waiting 5s)", instance_id);
+		qb_log (LOG_INFO, "iid %d: start - should block forever (waiting 5s)", instance_id);
 		err = sam_start ();
 		if (err != CS_OK) {
 			qb_log (LOG_ERR, "Can't start hc. Error %d", err);
 			return 2;
 		}
 
-		qb_log (LOG_INFO, "%s iid %d: wasn't killed", instance_id);
+		qb_log (LOG_INFO, "iid %d: wasn't killed", instance_id);
 		return (2);
 	}
 
@@ -833,7 +833,7 @@ static int test_quorum (void) {
 			return (2);
 		}
 
-		qb_log (LOG_INFO, "%s iid %d: start", instance_id);
+		qb_log (LOG_INFO, "iid %d: start", instance_id);
 		err = sam_start ();
 		if (err != CS_OK) {
 			qb_log (LOG_ERR, "Can't start hc. Error %d", err);
@@ -849,10 +849,10 @@ static int test_quorum (void) {
 			return (2);
 		}
 
-		qb_log (LOG_INFO, "%s iid %d: sleep 3", instance_id);
+		qb_log (LOG_INFO, "iid %d: sleep 3", instance_id);
 		sleep (3);
 
-		qb_log (LOG_INFO, "%s iid %d: wasn't killed", instance_id);
+		qb_log (LOG_INFO, "iid %d: wasn't killed", instance_id);
 		return (2);
 	}
 
@@ -881,13 +881,13 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 		return (1);
 	}
 
-	qb_log (LOG_INFO, "%s test %d", test_n);
+	qb_log (LOG_INFO, "test %d", test_n);
 
 	if (test_n == 2) {
 		/*
 		 * Object should not exist
 		 */
-		qb_log (LOG_INFO, "%s Testing if object exists (it shouldn't)");
+		qb_log (LOG_INFO, "Testing if object exists (it shouldn't)");
 
 		snprintf(key_name, CMAP_KEYNAME_MAXLEN, "resources.process.%d.state", pid);
 		err = cmap_get_string(cmap_handle, key_name, &str);
@@ -939,7 +939,7 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 		}
 		free(str);
 
-		qb_log (LOG_INFO, "%s iid %d: start", instance_id);
+		qb_log (LOG_INFO, "iid %d: start", instance_id);
 		err = sam_start ();
 		if (err != CS_OK) {
 			qb_log (LOG_ERR, "Can't start hc. Error %d", err);
@@ -958,7 +958,7 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 		}
 		free(str);
 
-		qb_log (LOG_INFO, "%s iid %d: stop", instance_id);
+		qb_log (LOG_INFO, "iid %d: stop", instance_id);
 		err = sam_stop ();
 		if (err != CS_OK) {
 			qb_log (LOG_ERR, "Can't stop hc. Error %d", err);
@@ -977,7 +977,7 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 		}
 		free(str);
 
-		qb_log (LOG_INFO, "%s iid %d: sleeping 5", instance_id);
+		qb_log (LOG_INFO, "iid %d: sleeping 5", instance_id);
 		sleep (5);
 
 		err = cmap_get_string(cmap_handle, key_name, &str);
@@ -992,7 +992,7 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 		}
 		free(str);
 
-		qb_log (LOG_INFO, "%s iid %d: start 2", instance_id);
+		qb_log (LOG_INFO, "iid %d: start 2", instance_id);
 		err = sam_start ();
 		if (err != CS_OK) {
 			qb_log (LOG_ERR, "Can't start hc. Error %d", err);
@@ -1012,12 +1012,12 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 		free(str);
 
 		if (test_n == 2) {
-			qb_log (LOG_INFO, "%s iid %d: sleeping 5. Should be killed", instance_id);
+			qb_log (LOG_INFO, "iid %d: sleeping 5. Should be killed", instance_id);
 			sleep (5);
 
 			return (2);
 		} else {
-			qb_log (LOG_INFO, "%s iid %d: Test HC", instance_id);
+			qb_log (LOG_INFO, "iid %d: Test HC", instance_id);
 			err = sam_hc_send ();
 			if (err != CS_OK) {
 				qb_log (LOG_ERR, "Can't send hc. Error %d", err);
@@ -1030,7 +1030,7 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 				qb_log (LOG_INFO, "Could not get \"last_updated\" key: %d.", err);
 				return (2);
 			}
-			qb_log (LOG_INFO, "%s iid %d: Sleep 1", instance_id);
+			qb_log (LOG_INFO, "iid %d: Sleep 1", instance_id);
 			sleep (1);
 			err = sam_hc_send ();
 			if (err != CS_OK) {
@@ -1050,7 +1050,7 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 				return (2);
 			}
 
-			qb_log (LOG_INFO, "%s iid %d: stop 2", instance_id);
+			qb_log (LOG_INFO, "iid %d: stop 2", instance_id);
 			err = sam_stop ();
 			if (err != CS_OK) {
 				qb_log (LOG_ERR, "Can't stop hc. Error %d", err);
@@ -1070,13 +1070,13 @@ static int test8 (pid_t pid, pid_t old_pid, int test_n) {
 			}
 			free(str);
 
-			qb_log (LOG_INFO, "%s iid %d: exiting", instance_id);
+			qb_log (LOG_INFO, "iid %d: exiting", instance_id);
 			return (0);
 		}
 	}
 
 	if (test_n == 3) {
-		qb_log (LOG_INFO, "%s Testing if status is failed");
+		qb_log (LOG_INFO, "Testing if status is failed");
 
 		/*
 		 * Previous should be FAILED
@@ -1116,7 +1116,7 @@ static int test9 (pid_t pid, pid_t old_pid, int test_n) {
 		return (1);
 	}
 
-	qb_log (LOG_INFO, "%s test %d", test_n);
+	qb_log (LOG_INFO, "test %d", test_n);
 
 	if (test_n == 1) {
 		qb_log (LOG_INFO, " initialize");
@@ -1161,7 +1161,7 @@ static int test9 (pid_t pid, pid_t old_pid, int test_n) {
 			}
 			free(str);
 
-			qb_log (LOG_INFO, "%s iid %d: start", instance_id);
+			qb_log (LOG_INFO, "iid %d: start", instance_id);
 			err = sam_start ();
 			if (err != CS_OK) {
 				qb_log (LOG_ERR, "Can't start hc. Error %d", err);
@@ -1180,14 +1180,14 @@ static int test9 (pid_t pid, pid_t old_pid, int test_n) {
 			}
 			free(str);
 
-			qb_log (LOG_INFO, "%s iid %d: waiting for kill", instance_id);
+			qb_log (LOG_INFO, "iid %d: waiting for kill", instance_id);
 			sleep (10);
 
 			return (2);
 		}
 
 		if (instance_id == 3) {
-			qb_log (LOG_INFO, "%s iid %d: mark failed", instance_id);
+			qb_log (LOG_INFO, "iid %d: mark failed", instance_id);
 			if (err != CS_OK) {
 				qb_log (LOG_ERR, "Can't start hc. Error %d", err);
 				return 2;
@@ -1207,7 +1207,7 @@ static int test9 (pid_t pid, pid_t old_pid, int test_n) {
 	}
 
 	if (test_n == 2) {
-		qb_log (LOG_INFO, "%s Testing if status is failed");
+		qb_log (LOG_INFO, "Testing if status is failed");
 
 		/*
 		 * Previous should be FAILED
@@ -1233,7 +1233,7 @@ static int test9 (pid_t pid, pid_t old_pid, int test_n) {
 
 static int hc_allways_respond_cb(void)
 {
-	qb_log (LOG_INFO, "%s() -> health check OK.");
+	qb_log (LOG_INFO, "health check OK.");
 	return 0;
 }
 
@@ -1256,7 +1256,7 @@ static int setup_hc (void)
 	}
 	err = sam_hc_callback_register (hc_allways_respond_cb);
 
-	qb_log (LOG_INFO, "%s instance id %d: start", instance_id);
+	qb_log (LOG_INFO, "instance id %d: start", instance_id);
 	err = sam_start ();
 	if (err != CS_OK) {
 		qb_log (LOG_ERR, "Can't start hc. Error %d", err);
@@ -1317,9 +1317,7 @@ static void do_command (int sock, char* func, char*args[], int num_args)
 	char response[100];
 	int err = 0;
 
-	if (parse_debug) {
-		qb_log (LOG_INFO, "RPC:%s() called.", func);
-	}
+	qb_log (LOG_INFO, "RPC:%s() called.", func);
 	if (strncmp ("test", func, 4) == 0) {
 		err = do_test_command(sock, func, args, num_args);
 	} else if (strcmp ("setup_hc", func) == 0) {
@@ -1328,13 +1326,13 @@ static void do_command (int sock, char* func, char*args[], int num_args)
 		err = sam_stop ();
 		if (err != CS_OK) {
 			err = -1;
-			qb_log (LOG_ERR,"%s RPC:%s sam_stop failed!", __func__, func);
+			qb_log (LOG_ERR,"RPC:%s sam_stop failed!", func);
 			snprintf (response, 100, "%s", FAIL_STR);
 		}
 		err = sam_finalize();
 	} else {
 		err = -1;
-		qb_log (LOG_ERR,"%s RPC:%s not supported!", __func__, func);
+		qb_log (LOG_ERR,"RPC:%s not supported!", func);
 		snprintf (response, 100, "%s", NOT_SUPPORTED_STR);
 	}
 
@@ -1353,6 +1351,5 @@ static void do_command (int sock, char* func, char*args[], int num_args)
 int
 main (int argc, char *argv[])
 {
-	parse_debug = 1;
 	return test_agent_run ("sam_test_agent", 9036, do_command, NULL);
 }

+ 5 - 7
cts/agents/votequorum_test_agent.c

@@ -85,8 +85,8 @@ static int vq_dispatch_wrapper_fn (
 {
 	cs_error_t error = votequorum_dispatch (vq_handle, CS_DISPATCH_ALL);
 	if (error != CS_OK) {
-		qb_log (LOG_ERR, "%s() got %s error, disconnecting.",
-			__func__, cs_strerror(error));
+		qb_log (LOG_ERR, "got %s error, disconnecting.",
+			cs_strerror(error));
 		votequorum_finalize(vq_handle);
 		qb_loop_poll_del (ta_poll_handle_get(), fd);
 		close (fd);
@@ -103,8 +103,8 @@ static int q_dispatch_wrapper_fn (
 {
 	cs_error_t error = quorum_dispatch (q_handle, CS_DISPATCH_ALL);
 	if (error != CS_OK) {
-		qb_log (LOG_ERR, "%s() got %s error, disconnecting.",
-			__func__, cs_strerror(error));
+		qb_log (LOG_ERR, "got %s error, disconnecting.",
+			cs_strerror(error));
 		quorum_finalize(q_handle);
 		qb_loop_poll_del (ta_poll_handle_get(), fd);
 		close (fd);
@@ -303,8 +303,7 @@ static void do_command (int sock, char* func, char*args[], int num_args)
 {
 	char response[100];
 
-	if (parse_debug)
-		qb_log (LOG_DEBUG,"RPC:%s() called.", func);
+	qb_log (LOG_INFO,"RPC:%s() called.", func);
 
 	if (strcmp ("votequorum_getinfo", func) == 0) {
 		getinfo (sock);
@@ -344,6 +343,5 @@ static void my_pre_exit(void)
 int
 main(int argc, char *argv[])
 {
-	parse_debug = 1;
 	return test_agent_run ("quorum_test_agent", 9037, do_command, my_pre_exit);
 }