[LTP] [PATCH] pan/ltp-pan.c: Add execution time field in results/logs

Dylan Jhong dylan@andestech.com
Tue Aug 9 10:27:01 CEST 2022


The current log only shows the success or failure of testcases, but
execution time is also one of the important indicators to observe LTP
testcases.

In this patch, we modified the format of the logs in results/ and added
a column to record the execution time.

Signed-off-by: Dylan Jhong <dylan@andestech.com>
---
 pan/ltp-pan.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/pan/ltp-pan.c b/pan/ltp-pan.c
index 0bdb51477..1bb255b4a 100644
--- a/pan/ltp-pan.c
+++ b/pan/ltp-pan.c
@@ -132,7 +132,11 @@ zoo_t zoofile;
 static char *reporttype = NULL;
 
 /* Common format string for ltp-pan results */
-#define ResultFmt	"%-50s %-10.10s"
+#define ResultFmt           "%-50s %-10.10s"
+#define ExitValTitleFmt     "%-12.12s"
+#define ExitValFmt          "%-12d"
+#define ExecTimeTitleFmt    "%-20.20s"
+#define ExecTimeFmt         "%-20d"
 
 /* zoolib */
 int rec_signal;			/* received signal */
@@ -354,10 +358,10 @@ int main(int argc, char **argv)
 			fprintf(logfile, "Test Start Time: %s\n", s);
 			fprintf(logfile,
 				"-----------------------------------------\n");
-			fprintf(logfile, ResultFmt" %-10.10s\n",
-				"Testcase", "Result", "Exit Value");
-			fprintf(logfile, ResultFmt" %-10.10s\n",
-				"--------", "------", "------------");
+			fprintf(logfile, ResultFmt" "ExitValTitleFmt" "ExecTimeTitleFmt"\n",
+				"Testcase", "Result", "Exit Value", "Execution Time(sec)");
+			fprintf(logfile, ResultFmt" "ExitValTitleFmt" "ExecTimeTitleFmt"\n",
+				"--------", "------", "----------", "-------------------");
 		}
 		fflush(logfile);
 	}
@@ -829,10 +833,11 @@ check_pids(struct tag_pgrp *running, int *num_active, int keep_active,
 						}
 
 						fprintf(logfile,
-							ResultFmt" %-5d\n",
+							ResultFmt" "ExitValFmt" "ExecTimeFmt"\n",
 							running[i].cmd->name,
 							result_str,
-							w);
+							w,
+							(int)(t - running[i].mystime));
 					}
 
 					fflush(logfile);
@@ -1108,10 +1113,11 @@ run_child(struct coll_entry *colle, struct tag_pgrp *active, int quiet_mode,
 				if (termid != 0)
 					++ * failcnt;
 
-				fprintf(logfile, ResultFmt" %-5d\n",
+				fprintf(logfile, ResultFmt" "ExitValFmt" "ExecTimeFmt"\n",
 					colle->name,
 					((termid != 0) ? "FAIL" : "PASS"),
-					termid);
+					termid,
+					(int)(end_time - active->mystime));
 			}
 			fflush(logfile);
 		}
-- 
2.34.1



More information about the ltp mailing list