ltp-pan: Increase allowed width of test name in logs
PATCH 1/1 ltp-pan: Increase allowed width of test name in logs
ltp-pan truncates the test name when logging the outcome of tests. This is causing issues with tooling which is expecting to parse unique test names from the log.
cgroup_fj_stress_cpuacct_2_2_o PASS 0 cgroup_fj_stress_cpuacct_3_3_o PASS 0 cgroup_fj_stress_cpuacct_4_4_o PASS 0 cgroup_fj_stress_cpuacct_2_9_o PASS 0 cgroup_fj_stress_cpuacct_10_3_ PASS 0
Fix this by increasing the expected size of test name and removing the hard restriction on the size of the name. Refactor the format string into a global variable as it seems to be repeated multiple times.
---
Hi,
This was noticed after we enabled the cgroup_fj_stress* tests. The problem leads to the result parsing scripts to fail.
Thanks,
Punit
pan/ltp-pan.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
pan/ltp-pan.c +5 -4
@@ -129,6 +129,7 @@ static char *panname = NULL;static char *test_out_dir =NULL ;/* dir to buffer output to */ zoo_t zoofile;static char *reporttype =NULL ; +static char *result_fmt ="%-50s %-10.10s %-10.10s\n" ;/* zoolib */ int rec_signal;/* received signal */
@@ -350,9 +351,9 @@ int main(int argc, char **argv)fprintf (logfile,"Test Start Time: %s\n" , s);fprintf (logfile,"-----------------------------------------\n" ); -fprintf (logfile,"%-30.20s %-10.10s %-10.10s\n" , +fprintf (logfile, result_fmt,"Testcase" ,"Result" ,"Exit Value" ); -fprintf (logfile,"%-30.20s %-10.10s %-10.10s\n" , +fprintf (logfile, result_fmt,"--------" ,"------" ,"------------" ); }fflush (logfile);
@@ -825,7 +826,7 @@ check_pids(struct tag_pgrp *running, int *num_active, int keep_active, }fprintf (logfile, -"%-30.30s %-10.10s %-5d\n" , + result_fmt, running[i].cmd->name, result_str, w);
@@ -1104,7 +1105,7 @@ run_child(struct coll_entry *colle, struct tag_pgrp *active, int quiet_mode,if (termid !=0 ) ++ * failcnt; -fprintf (logfile,"%-30.30s %-10.10s %-5d\n" , +fprintf (logfile, result_fmt, colle->name, ((termid !=0 ) ?"FAIL" :"PASS" ), termid);
Signature · 1 line
2.18.0
PATCH 1/1 ltp-pan: Increase allowed width of test name in logs
Hi!
Quoted 1 line
+static char
*result_fmt= "%-50s %-10.10s %-10.10s\n";
This should be a macro otherwise the compilation will fail for some compilers since the format string passed to fprintf() is not a static string.
Other than that it looks fine.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 1/1 ltp-pan: Increase allowed width of test name in logs
ltp-pan truncates the test name when logging the outcome of tests. This is causing issues with tooling which is expecting to parse unique test names from the log.
cgroup_fj_stress_cpuacct_2_2_o PASS 0 cgroup_fj_stress_cpuacct_3_3_o PASS 0 cgroup_fj_stress_cpuacct_4_4_o PASS 0 cgroup_fj_stress_cpuacct_2_9_o PASS 0 cgroup_fj_stress_cpuacct_10_3_ PASS 0
Fix this by increasing the expected size of test name and removing the hard restriction on the size of the name. Refactor the format string into a global variable as it seems to be repeated multiple times.
---
Hi Cyril,
Thanks for the feedback. I've updated the patch to use macros now.
Regards,
Punit
pan/ltp-pan.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
pan/ltp-pan.c +7 -4
@@ -130,6 +130,9 @@ static char *test_out_dir = NULL; /* dir to buffer output to */zoo_t zoofile;static char *reporttype =NULL ; +/* Output format of ltp-pan results */ +#define ResultFmt "%-50s %-10.10s %-10.10s\n"; +/* zoolib */ int rec_signal;/* received signal */ int send_signal;/* signal to send */
@@ -350,9 +353,9 @@ int main(int argc, char **argv)fprintf (logfile,"Test Start Time: %s\n" , s);fprintf (logfile,"-----------------------------------------\n" ); -fprintf (logfile,"%-30.20s %-10.10s %-10.10s\n" , +fprintf (logfile, ResultFmt,"Testcase" ,"Result" ,"Exit Value" ); -fprintf (logfile,"%-30.20s %-10.10s %-10.10s\n" , +fprintf (logfile, ResultFmt,"--------" ,"------" ,"------------" ); }fflush (logfile);
@@ -825,7 +828,7 @@ check_pids(struct tag_pgrp *running, int *num_active, int keep_active, }fprintf (logfile, -"%-30.30s %-10.10s %-5d\n" , + ResultFmt, running[i].cmd->name, result_str, w);
@@ -1104,7 +1107,7 @@ run_child(struct coll_entry *colle, struct tag_pgrp *active, int quiet_mode,if (termid !=0 ) ++ * failcnt; -fprintf (logfile,"%-30.30s %-10.10s %-5d\n" , +fprintf (logfile, ResultFmt, colle->name, ((termid !=0 ) ?"FAIL" :"PASS" ), termid);
Signature · 1 line
2.18.0
PATCH v2 1/1 ltp-pan: Increase allowed width of test name in logs
Hi!
pan/ltp-pan.c static char *test_out_dir = NULL; /* dir to buffer output to */ · line 134
Quoted 10 lines
pan/ltp-pan.c +2
-0@@ -130,6 +130,9 @@ static char *test_out_dir = NULL; /* dir to buffer output to */zoo_t zoofile;static char *reporttype =NULL ; +/* Output format of ltp-pan results */ +#define ResultFmt "%-50s %-10.10s %-10.10s\n";
The ltp-pan does not even compile with this because of the semicolon.
Can you please at least compile-test your changes before sumbitting.
Quoted 25 lines
pan/ltp-pan.c +3
-3/* zoolib */ int rec_signal;/* received signal */ int send_signal;/* signal to send */ @@ -350,9 +353,9 @@ int main(int argc, char **argv)fprintf (logfile,"Test Start Time: %s\n" , s);fprintf (logfile,"-----------------------------------------\n" ); -fprintf (logfile,"%-30.20s %-10.10s %-10.10s\n" , +fprintf (logfile, ResultFmt,"Testcase" ,"Result" ,"Exit Value" ); -fprintf (logfile,"%-30.20s %-10.10s %-10.10s\n" , +fprintf (logfile, ResultFmt,"--------" ,"------" ,"------------" ); }fflush (logfile);@@ -825,7 +828,7 @@ check_pids(struct tag_pgrp *running, int *num_active, int keep_active, }fprintf (logfile, -"%-30.30s %-10.10s %-5d\n" , + ResultFmt, running[i].cmd->name, result_str, w);
pan/ltp-pan.c run_child(struct coll_entry *colle, struct tag_pgrp *active, int quiet_mode, · line 1113
Quoted 8 lines
pan/ltp-pan.c +1
-1@@ -1104,7 +1107,7 @@ run_child(struct coll_entry *colle, struct tag_pgrp *active, int quiet_mode,if (termid !=0 ) ++ * failcnt; -fprintf (logfile,"%-30.30s %-10.10s %-5d\n" , +fprintf (logfile, ResultFmt, colle->name, ((termid !=0 ) ?"FAIL" :"PASS" ), termid);
Looking closer these two are actually different in the last column. So I suppose that we can extract only the first two columns as with:
#define ResultFmt "%-50s %-10.10s"
... fprintf(..., ResultFmt" %-10.10%s\n", ...); ... fprintf(,,,, ResultFmt" %-5d\n", ...); ...
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 1/1 ltp-pan: Increase allowed width of test name in logs
Quoted 9 lines · Cyril Hrubis
Hi!
Quoted 8 lines
pan/ltp-pan.c +0
-0@@ -130,6 +130,9 @@ static char *test_out_dir = NULL; /* dir to buffer output to */zoo_t zoofile;static char *reporttype =NULL ;
Quoted 6 lines
pan/ltp-pan.c static char *test_out_dir = NULL; /* dir to buffer output to */ · line 134
Quoted 2 lines
pan/ltp-pan.c +2
-0+/* Output format of ltp-pan results */ +#define ResultFmt "%-50s %-10.10s %-10.10s\n";The ltp-pan does not even compile with this because of the semicolon.
Can you please at least compile-test your changes before sumbitting.
Ack! That is very sloppy of me. I'll be more careful going forward.
Quoted 37 lines
Quoted 25 lines
pan/ltp-pan.c +3
-3/* zoolib */ int rec_signal;/* received signal */ int send_signal;/* signal to send */ @@ -350,9 +353,9 @@ int main(int argc, char **argv)fprintf (logfile,"Test Start Time: %s\n" , s);fprintf (logfile,"-----------------------------------------\n" ); -fprintf (logfile,"%-30.20s %-10.10s %-10.10s\n" , +fprintf (logfile, ResultFmt,"Testcase" ,"Result" ,"Exit Value" ); -fprintf (logfile,"%-30.20s %-10.10s %-10.10s\n" , +fprintf (logfile, ResultFmt,"--------" ,"------" ,"------------" ); }fflush (logfile);@@ -825,7 +828,7 @@ check_pids(struct tag_pgrp *running, int *num_active, int keep_active, }fprintf (logfile, -"%-30.30s %-10.10s %-5d\n" , + ResultFmt, running[i].cmd->name, result_str, w);pan/ltp-pan.c run_child(struct coll_entry *colle, struct tag_pgrp *active, int quiet_mode, · line 1113
Quoted 8 lines
pan/ltp-pan.c +1
-1@@ -1104,7 +1107,7 @@ run_child(struct coll_entry *colle, struct tag_pgrp *active, int quiet_mode,if (termid !=0 ) ++ * failcnt; -fprintf (logfile,"%-30.30s %-10.10s %-5d\n" , +fprintf (logfile, ResultFmt, colle->name, ((termid !=0 ) ?"FAIL" :"PASS" ), termid);Looking closer these two are actually different in the last column. So I suppose that we can extract only the first two columns as with:
Quoted 7 lines
#define ResultFmt "%-50s %-10.10s"
... fprintf(..., ResultFmt" %-10.10%s\n", ...); ... fprintf(,,,, ResultFmt" %-5d\n", ...); ...
I've taken this approach now and will send an updated patch with the changes.
Thanks,
Punit