JSON cleanups and more tests updated
PATCH 4/13 rt_util: Copy command line before getopt_long() is called
In reply to Daniel WagnerBy default, getopt_long() permutes the contents of argv as it scans, so that eventually all the nonoptions are at the end. This is confusing in the JSON output, thus copy the command line before we call getopt_long().
Introduce a rt_init() which copies the command line. This makes also rt_write_json() function arguments a bit cleaner.
--- src/cyclictest/cyclictest.c | 3 +- src/include/rt-utils.h | 7 +++-- src/lib/rt-utils.c | 45 ++++++++++++--------------- src/oslat/oslat.c | 5 +-- src/pmqtest/pmqtest.c | 3 +- src/ptsematest/ptsematest.c | 3 +- src/rt-migrate-test/rt-migrate-test.c | 3 +- src/sched_deadline/cyclicdeadline.c | 4 ++- src/signaltest/signaltest.c | 3 +- src/sigwaittest/sigwaittest.c | 3 +- src/svsematest/svsematest.c | 3 +- 11 files changed, 44 insertions(+), 38 deletions(-)
src/cyclictest/cyclictest.c +2 -1
@@ -1778,6 +1778,7 @@ int main(int argc, char **argv)int i, ret =-1 ;int status; +rt_init (argc, argv);process_options (argc, argv, max_cpus);if (check_privs ())
@@ -2133,7 +2134,7 @@ int main(int argc, char **argv)printf ("\033[%dB" , num_threads +2 );if (strlen (outfile) !=0 ) -rt_write_json (outfile, argc, argv, write_stats,NULL ); +rt_write_json (outfile, write_stats,NULL );if (quiet) quiet =2 ;
src/include/rt-utils.h +4 -3
@@ -80,8 +80,9 @@ static inline int64_t calctime(struct timespec t) return time; } -void rt_write_json (const char *filename,int argc,char *argv[], -void (*cb)(FILE *,void *), -void *data); +void rt_init (int argc,char *argv[]); + +void rt_write_json (const char *filename, +void (*cb)(FILE *,void *),void *data);#endif /* __RT_UTILS.H */
src/lib/rt-utils.c +20 -25
91 lines not on this page · raw message
src/oslat/oslat.c +3 -2
@@ -796,6 +796,8 @@ int main(int argc, char *argv[])exit (1 ); } +rt_init (argc, argv); + g.app_name = argv[0 ]; g.rtprio =0 ; g.bucket_size =BUCKET_SIZE ;
@@ -860,8 +862,7 @@ int main(int argc, char *argv[])write_summary (threads);if (strlen (g.outfile) !=0 ) -rt_write_json (g.outfile, argc, argv, - write_summary_json, threads); +rt_write_json (g.outfile, write_summary_json, threads);if (g.cpu_list) {free (g.cpu_list);
src/pmqtest/pmqtest.c +2 -1
@@ -502,6 +502,7 @@ int main(int argc, char *argv[]) mqstat.mq_msgsize =8 ; mqstat.mq_flags =0 ; +rt_init (argc, argv);process_options (argc, argv);if (check_privs ())
@@ -650,7 +651,7 @@ int main(int argc, char *argv[]) .receiver = receiver, .sender = sender, }; -rt_write_json (outfile, argc, argv, write_stats, &ps); +rt_write_json (outfile, write_stats, &ps); } nomem:
src/ptsematest/ptsematest.c +2 -1
@@ -401,6 +401,7 @@ int main(int argc, char *argv[])sigset_t sigset;struct timespec maindelay; +rt_init (argc, argv);process_options (argc, argv);if (check_privs ())
@@ -518,7 +519,7 @@ int main(int argc, char *argv[]) .receiver = receiver, .sender = sender, }; -rt_write_json (outfile, argc, argv, write_stats, &ps); +rt_write_json (outfile, write_stats, &ps); } nomem:
src/rt-migrate-test/rt-migrate-test.c +2 -1
@@ -535,6 +535,7 @@ int main (int argc, char **argv)struct timespec intv;struct sched_param param; +rt_init (argc, argv);parse_options (argc, argv);signal (SIGINT , stop_log);
@@ -662,7 +663,7 @@ int main (int argc, char **argv)print_results ();if (strlen (outfile) !=0 ) -rt_write_json (outfile, argc, argv, write_stats,NULL ); +rt_write_json (outfile, write_stats,NULL );if (stop) {/*
src/sched_deadline/cyclicdeadline.c +3 -1
@@ -1009,6 +1009,8 @@ int main(int argc, char **argv)int i;int c; +rt_init (argc, argv); + cpu_count =sysconf (_SC_NPROCESSORS_CONF);if (cpu_count <1 )err_quit ("Can not calculate number of CPUS\n" );
@@ -1225,7 +1227,7 @@ int main(int argc, char **argv) }if (strlen (outfile) !=0 ) -rt_write_json (outfile, argc, argv, write_stats, sched_data); +rt_write_json (outfile, write_stats, sched_data);if (setcpu_buf)free (setcpu_buf);
src/signaltest/signaltest.c +2 -1
@@ -414,6 +414,7 @@ int main(int argc, char **argv)int status, cpu;int max_cpus =sysconf (_SC_NPROCESSORS_ONLN); +rt_init (argc, argv);process_options (argc, argv, max_cpus);if (check_privs ())
@@ -557,7 +558,7 @@ int main(int argc, char **argv)free (stat[i].values); }if (strlen (outfile) !=0 ) -rt_write_json (outfile, argc, argv, write_stats, par); +rt_write_json (outfile, write_stats, par);free (stat); outpar:
src/sigwaittest/sigwaittest.c +2 -1
@@ -473,6 +473,7 @@ int main(int argc, char *argv[])char f_opt[14 ];struct timespec launchdelay, maindelay; +rt_init (argc, argv);process_options (argc, argv);if (check_privs ())
@@ -705,7 +706,7 @@ int main(int argc, char *argv[]) .receiver = receiver, .sender = sender, }; -rt_write_json (outfile, argc, argv, write_stats, &ps); +rt_write_json (outfile, write_stats, &ps); } nomem:
src/svsematest/svsematest.c +2 -1
@@ -514,6 +514,7 @@ int main(int argc, char *argv[])if (myfile ==NULL ) myfile = argv[0 ]; +rt_init (argc, argv);process_options (argc, argv);if (check_privs ())
@@ -777,7 +778,7 @@ int main(int argc, char *argv[]) .receiver = receiver, .sender = sender, }; -rt_write_json (outfile, argc, argv, write_stats, &ps); +rt_write_json (outfile, write_stats, &ps); } nosem:
Signature · 1 line
2.30.1
cover JSON cleanups and more tests updated
The first two patches fixes the format string issue. Then there are a couple of patches which fixes the common JSON entries (command line, start_time, end_time).
Then there are patches which add the --output parameter to the missing rt-tests programs.
All patches are also available at:
https://github.com/igaw/rt-tests/tree/json-output-2021-03-04
Daniel Wagner (13):
cyclictest: Fix printf format specifier cyclicdeadline.c: Fix printf format specifier
signaltest: Add missing --output usage info
rt_util: Copy command line before getopt_long() is called
rt-util: Add start time of test execution for JSON output
pip_stress: Move test result output to main
pip_stress: Return failure code if test fails
pip_stress: Prepare arg parser to accept only long options
pip_stress: Add JSON output feature
pi_stress: Prepare command line parser for long options only
pi_stress: Add JSON output feature
ssdd: Add quiet command line option
ssdd: Add JSON output feature
src/cyclictest/cyclictest.c | 13 ++--- src/include/rt-utils.h | 9 ++-- src/lib/rt-utils.c | 77 +++++++++++++++------------ src/oslat/oslat.c | 6 ++- src/pi_tests/pi_stress.c | 65 +++++++++++++++++----- src/pi_tests/pip_stress.c | 47 +++++++++++----- src/pmqtest/pmqtest.c | 4 +- src/ptsematest/ptsematest.c | 4 +- src/rt-migrate-test/rt-migrate-test.c | 4 +- src/sched_deadline/cyclicdeadline.c | 12 +++-- src/signaltest/signaltest.c | 5 +- src/sigwaittest/sigwaittest.c | 4 +- src/ssdd/ssdd.c | 50 +++++++++++++---- src/svsematest/svsematest.c | 4 +- 14 files changed, 214 insertions(+), 90 deletions(-)
Signature · 1 line
2.30.1
PATCH 1/13 cyclictest: Fix printf format specifier
The fields are not uint64 just longs, update the printf format specifiers.
--- src/cyclictest/cyclictest.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
src/cyclictest/cyclictest.c +4 -5
@@ -11,7 +11,6 @@#include <stdio.h> #include <stdlib.h> #include <stdint.h> -#include <inttypes.h> #include <stdarg.h> #include <unistd.h> #include <fcntl.h>
@@ -1751,15 +1750,15 @@ static void write_stats(FILE *f, void *data)if (s->hist_array[j] ==0 )continue ;fprintf (f,"%s" , comma ?",\n" :"\n" ); -fprintf (f," \"%u\": %" PRIu64, j, s->hist_array[j]); +fprintf (f," \"%u\": %ld" , j, s->hist_array[j]); comma =1 ; }if (comma)fprintf (f,"\n" );fprintf (f," },\n" ); -fprintf (f," \"cycles\": %" PRIu64",\n" , s->cycles); -fprintf (f," \"min\": %" PRIu64",\n" , s->min); -fprintf (f," \"max\": %" PRIu64",\n" , s->max); +fprintf (f," \"cycles\": %ld,\n" , s->cycles); +fprintf (f," \"min\": %ld,\n" , s->min); +fprintf (f," \"max\": %ld,\n" , s->max);fprintf (f," \"avg\": %.2f,\n" , s->avg/s->cycles);fprintf (f," \"cpu\": %d,\n" , par[i]->cpu);fprintf (f," \"node\": %d\n" , par[i]->node);
Signature · 1 line
2.30.1
PATCH 2/13 cyclicdeadline.c: Fix printf format specifier
In reply to Daniel WagnerThe fields are not uint64 just longs, update the printf format specifiers.
--- src/sched_deadline/cyclicdeadline.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
src/sched_deadline/cyclicdeadline.c +3 -4
@@ -18,7 +18,6 @@#include <errno.h> #include <signal.h> #include <getopt.h> -#include <inttypes.h> #include <sys/syscall.h> #include <sys/types.h>
@@ -976,9 +975,9 @@ static void write_stats(FILE *f, void *data)for (i =0 ; i < nr_threads; i++) { s = &sd[i].stat;fprintf (f," \"%u\": {\n" , i); -fprintf (f," \"cycles\": %" PRIu64",\n" , s->cycles); -fprintf (f," \"min\": %" PRIu64",\n" , s->min); -fprintf (f," \"max\": %" PRIu64",\n" , s->max); +fprintf (f," \"cycles\": %ld,\n" , s->cycles); +fprintf (f," \"min\": %ld,\n" , s->min); +fprintf (f," \"max\": %ld\n" , s->max);fprintf (f," \"avg\": %.2f\n" , s->avg/s->cycles);fprintf (f," }%s\n" , i == nr_threads -1 ?"" :"," ); }
Signature · 1 line
2.30.1
PATCH 3/13 signaltest: Add missing --output usage info
In reply to Daniel Wagner--- src/signaltest/signaltest.c | 1 + 1 file changed, 1 insertion(+)
src/signaltest/signaltest.c +1 -0
@@ -189,6 +189,7 @@ static void display_help(int error)"-h --help display usage information\n" "-l LOOPS --loops=LOOPS number of loops: default=0(endless)\n" "-m --mlockall lock current and future memory allocations\n" +" --output=FILENAME write final results into FILENAME, JSON formatted\n" "-p PRIO --prio=PRIO priority of highest prio thread\n" "-q --quiet print a summary only on exit\n" "-t NUM --threads=NUM number of threads: default=2\n"
Signature · 1 line
2.30.1
PATCH 5/13 rt-util: Add start time of test execution for JSON output
In reply to Daniel WagnerStore the start time when the test starts to execute in the JSON output.
--- src/cyclictest/cyclictest.c | 1 + src/include/rt-utils.h | 2 ++ src/lib/rt-utils.c | 34 +++++++++++++++++++-------- src/oslat/oslat.c | 1 + src/pmqtest/pmqtest.c | 1 + src/ptsematest/ptsematest.c | 1 + src/rt-migrate-test/rt-migrate-test.c | 1 + src/sched_deadline/cyclicdeadline.c | 1 + src/signaltest/signaltest.c | 1 + src/sigwaittest/sigwaittest.c | 1 + src/svsematest/svsematest.c | 1 + 11 files changed, 35 insertions(+), 10 deletions(-)
src/cyclictest/cyclictest.c +1 -0
@@ -615,6 +615,7 @@ static void *timerthread(void *param)setitimer (ITIMER_REAL , &itimer,NULL ); } +rt_test_start (); stat->threadstarted++;while (!shutdown) {
src/include/rt-utils.h +2 -0
@@ -82,6 +82,8 @@ static inline int64_t calctime(struct timespec t)void rt_init (int argc,char *argv[]); +void rt_test_start (void ); +void rt_write_json (const char *filename,void (*cb)(FILE *,void *),void *data);
src/lib/rt-utils.c +24 -10
@@ -30,6 +30,7 @@#define TRACEBUFSIZ 1024#define MAX_COMMAND_LINE 4096 +#define MAX_TS_SIZE 64static char debugfileprefix[MAX_PATH ];static char *fileprefix;
@@ -37,6 +38,7 @@ static int trace_fd = -1;static int tracemark_fd =-1 ;static __threadchar tracebuf[TRACEBUFSIZ ];static char cmdline[MAX_COMMAND_LINE ]; +static char ts_start[MAX_TS_SIZE ];/* * Finds the tracing directory in a mounted debugfs
@@ -514,16 +516,31 @@ void rt_init(int argc, char *argv[]) } } +static void get_timestamp (char *tsbuf) +{ +struct timeval tv; +struct tm *tm; +time_t t; + +gettimeofday (&tv,NULL ); + t = tv.tv_sec; + tm =localtime (&t); +/* RFC 2822-compliant date format */ +strftime (tsbuf,MAX_TS_SIZE ,"%a, %d %b %Y %T %z" , tm); +} + +void rt_test_start (void ) +{ +get_timestamp (ts_start); +} +void rt_write_json (const char *filename,void (*cb)(FILE *,void *),void *data) {unsigned char buf[1 ];struct utsname uts; -struct timeval tv; -char tsbuf[64 ]; -struct tm *tm; +char ts_end[MAX_TS_SIZE ];FILE *f, *s; -time_t t;size_t n;int rt =0 ;
@@ -535,11 +552,7 @@ void rt_write_json(const char *filename,err_exit (errno,"Failed to open '%s'\n" , filename); } -gettimeofday (&tv,NULL ); - t = tv.tv_sec; - tm =localtime (&t); -/* RFC 2822-compliant date format */ -strftime (tsbuf,sizeof (tsbuf),"%a, %d %b %Y %T %z" , tm); +get_timestamp (ts_end); s =fopen ("/sys/kernel/realtime" ,"r" );if (s) {
@@ -556,7 +569,8 @@ void rt_write_json(const char *filename,fprintf (f," \"file_version\": 1,\n" );fprintf (f," \"cmdline:\": \"%s\",\n" , cmdline);fprintf (f," \"rt_test_version:\": \"%1.2f\",\n" ,VERSION ); -fprintf (f," \"finished\": \"%s\",\n" , tsbuf); +fprintf (f," \"start_time\": \"%s\",\n" , ts_start); +fprintf (f," \"end_time\": \"%s\",\n" , ts_end);fprintf (f," \"sysinfo\": {\n" );fprintf (f," \"sysname\": \"%s\",\n" , uts.sysname);fprintf (f," \"nodename\": \"%s\",\n" , uts.nodename);
src/oslat/oslat.c +1 -0
@@ -854,6 +854,7 @@ int main(int argc, char *argv[])printf ("Test starts...\n" );/* Reset n_threads to always run on all the cores */ g.n_threads = g.n_threads_total; +rt_test_start ();run_expt (threads, g.runtime);if (!g.quiet)
src/pmqtest/pmqtest.c +1 -0
@@ -583,6 +583,7 @@ int main(int argc, char *argv[])sigemptyset (&sigset);pthread_sigmask (SIG_SETMASK , &sigset,NULL ); +rt_test_start (); do { int newsamples = 0, newtimeoutcount = 0; int minsamples = INT_MAX;
src/ptsematest/ptsematest.c +1 -0
@@ -468,6 +468,7 @@ int main(int argc, char *argv[]) maindelay.tv_sec =0 ; maindelay.tv_nsec =50000000 ;/* 50 ms */ +rt_test_start ();while (!shutdown) {for (i =0 ; i < num_threads; i++) shutdown |= receiver[i].shutdown | sender[i].shutdown;
src/rt-migrate-test/rt-migrate-test.c +1 -0
@@ -621,6 +621,7 @@ int main (int argc, char **argv)setup_ftrace_marker (); +rt_test_start ();for (loop=0 ; loop < nr_runs; loop++) {unsigned long long end;
src/sched_deadline/cyclicdeadline.c +1 -0
@@ -1213,6 +1213,7 @@ int main(int argc, char **argv)if (duration)alarm (duration); +rt_test_start ();loop (sched_data, nr_threads);for (i =0 ; i < nr_threads; i++) {
src/signaltest/signaltest.c +1 -0
@@ -500,6 +500,7 @@ int main(int argc, char **argv) strerror(status)); } +rt_test_start ();while (!shutdown) {int allstarted =1 ;
src/sigwaittest/sigwaittest.c +1 -0
@@ -652,6 +652,7 @@ int main(int argc, char *argv[]) &sender[i]); } +rt_test_start ();while (!mustshutdown) {for (i =0 ; i < num_threads; i++) mustshutdown |= receiver[i].shutdown |
src/svsematest/svsematest.c +1 -0
@@ -724,6 +724,7 @@ int main(int argc, char *argv[]) &sender[i]); } +rt_test_start ();while (!mustshutdown) {for (i =0 ; i < num_threads; i++) mustshutdown |= receiver[i].shutdown |
Signature · 1 line
2.30.1
PATCH 6/13 pip_stress: Move test result output to main
In reply to Daniel WagnerInstead printing the result high() close directly move it to main() function to simplify the return code if the test fails.
--- src/pi_tests/pip_stress.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
src/pi_tests/pip_stress.c +7 -8
@@ -146,6 +146,7 @@ int main(int argc, char *argv[])exit (1 ); }else if (pid1 !=0 ) {/* parent code */ low (pid1); +exit (0 ); }else {/* child code */ pid2 =fork ();/* parent code */ if (pid2 ==-1 ) {
@@ -155,9 +156,15 @@ int main(int argc, char *argv[])high (pid2); }else {/* child code */ medium (); +exit (0 ); } } +if (statep->inversion) +printf ("Successfully used priority inheritance to handle an inversion\n" ); +else +printf ("No inversion incurred\n" ); +exit (0 ); }
@@ -222,14 +229,6 @@ void high(pid_t pid)Pthread_mutex_unlock (resource);kill (pid,SIGKILL );/* kill the medium thread */ waitpid (pid, &status,0 ); - -Pthread_mutex_lock (statep->mutex); - -if (statep->inversion) -printf ("Successfully used priority inheritance to handle an inversion\n" ); -else -printf ("No inversion incurred\n" ); -Pthread_mutex_unlock (statep->mutex); }/* mmap a page of anonymous shared memory */
Signature · 1 line
2.30.1
PATCH 8/13 pip_stress: Prepare arg parser to accept only long options
In reply to Daniel WagnerIntroduce the option value enums to be able to parse only long options.
--- src/pi_tests/pip_stress.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
src/pi_tests/pip_stress.c +8 -3
@@ -77,6 +77,10 @@ static void usage(int error)exit (error); } +enum option_values { +OPT_HELP =1 +}; +int main (int argc,char *argv[]) {void *mptr;/* memory pointer */
@@ -87,14 +91,15 @@ int main(int argc, char *argv[])for (;;) {struct option long_options[] = { - {"help" , no_argument,NULL ,'h' }, - {NULL ,0 ,NULL ,0 }, + {"help" , no_argument,NULL ,OPT_HELP }, + {NULL ,0 ,NULL ,0 } }; -int c =getopt_long (argc, argv,"s:h" , long_options,NULL ); +int c =getopt_long (argc, argv,"h" , long_options,NULL );if (c ==-1 )break ;switch (c) { +case OPT_HELP :case 'h' :usage (0 );break ;
Signature · 1 line
2.30.1
PATCH 9/13 pip_stress: Add JSON output feature
In reply to Daniel WagnerWrite the test results as JSON output to a file. This allows to simplifies any parsing later on.
--- src/pi_tests/pip_stress.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
src/pi_tests/pip_stress.c +21 -2
@@ -67,18 +67,23 @@ struct State *statep;const int policy =SCHED_FIFO ;static int prio_min;/* Initialized for the minimum priority of policy */ +static char outfile[MAX_PATH ]; + +static void write_stats (FILE *f,void *data); +static void usage (int error) {printf ("pip_stress V %1.2f\n" ,VERSION );printf ("Usage:\n" "pip_stress <options>\n" \ -"-h --help Show this help menu.\n" +"-h --help Show this help menu.\n" +" --output=FILENAME write final results into FILENAME, JSON formatted\n" );exit (error); }enum option_values { -OPT_HELP =1 +OPT_HELP =1 ,OPT_OUTPUT , };int main (int argc,char *argv[])
@@ -89,9 +94,11 @@ int main(int argc, char *argv[])int res;int *minimum_priority = (int *)&prio_min; +rt_init (argc, argv);for (;;) {struct option long_options[] = { {"help" , no_argument,NULL ,OPT_HELP }, + {"output" , required_argument,NULL ,OPT_OUTPUT }, {NULL ,0 ,NULL ,0 } };
@@ -103,6 +110,9 @@ int main(int argc, char *argv[])case 'h' :usage (0 );break ; +case OPT_OUTPUT : +strncpy (outfile, optarg,strnlen (optarg,MAX_PATH -1 )); +break ;default :usage (1 );break ;
@@ -145,6 +155,7 @@ int main(int argc, char *argv[])err_exit (err,NULL ); } +rt_test_start (); pid1 =fork ();if (pid1 ==-1 ) {perror ("fork" );
@@ -165,6 +176,9 @@ int main(int argc, char *argv[]) } } +if (strlen (outfile) !=0 ) +rt_write_json (outfile, write_stats,NULL ); +if (!statep->inversion) {printf ("No inversion incurred\n" );exit (1 );
@@ -370,3 +384,8 @@ int get_rt_prio(pid_t pid) }return param.sched_priority; } + +static void write_stats (FILE *f,void *data) +{ +fprintf (f," \"inversion\": %d\n" , statep->inversion); +}
Signature · 1 line
2.30.1
PATCH 10/13 pi_stress: Prepare command line parser for long options only
In reply to Daniel WagnerIntroduce option value enums in order to be able to parse long options only.
--- src/pi_tests/pi_stress.c | 45 ++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 13 deletions(-)
src/pi_tests/pi_stress.c +32 -13
@@ -1274,23 +1274,29 @@ int process_sched_line(const char *arg)return retval; } +enum option_values { +OPT_DEBUG =1 ,OPT_DURATION ,OPT_GROUPS ,OPT_HELP ,OPT_INVERSIONS , +OPT_MLOCKALL ,OPT_PROMPT ,OPT_QUIET ,OPT_RR ,OPT_SCHED , +OPT_UNIPROCESSOR ,OPT_VERBOSE ,OPT_VERSION , +}; +void process_command_line (int argc,char **argv) {for (;;) {struct option options[] = { - {"debug" , no_argument,NULL ,'d' }, - {"duration" , required_argument,NULL ,'D' }, - {"groups" , required_argument,NULL ,'g' }, - {"help" , no_argument,NULL ,'h' }, - {"inversions" , required_argument,NULL ,'i' }, - {"mlockall" , no_argument,NULL ,'m' }, - {"prompt" , no_argument,NULL ,'p' }, - {"quiet" , no_argument,NULL ,'q' }, - {"rr" , no_argument,NULL ,'r' }, - {"sched" , required_argument,NULL ,'s' }, - {"uniprocessor" , no_argument,NULL ,'u' }, - {"verbose" , no_argument,NULL ,'v' }, - {"version" , no_argument,NULL ,'V' }, + {"debug" , no_argument,NULL ,OPT_DEBUG }, + {"duration" , required_argument,NULL ,OPT_DURATION }, + {"groups" , required_argument,NULL ,OPT_GROUPS }, + {"help" , no_argument,NULL ,OPT_HELP }, + {"inversions" , required_argument,NULL ,OPT_INVERSIONS }, + {"mlockall" , no_argument,NULL ,OPT_MLOCKALL }, + {"prompt" , no_argument,NULL ,OPT_PROMPT }, + {"quiet" , no_argument,NULL ,OPT_QUIET }, + {"rr" , no_argument,NULL ,OPT_RR }, + {"sched" , required_argument,NULL ,OPT_SCHED }, + {"uniprocessor" , no_argument,NULL ,OPT_UNIPROCESSOR }, + {"verbose" , no_argument,NULL ,OPT_VERBOSE }, + {"version" , no_argument,NULL ,OPT_VERSION }, {NULL ,0 ,NULL ,0 }, };
@@ -1298,12 +1304,15 @@ void process_command_line(int argc, char **argv)if (c ==-1 )break ;switch (c) { +case OPT_DEBUG :case 'd' : debugging =1 ;break ; +case OPT_DURATION :case 'D' : duration =parse_time_string (optarg);break ; +case OPT_GROUPS :case 'g' : ngroups =strtol (optarg,NULL ,10 );if (ngroups > num_processors) {
@@ -1314,37 +1323,47 @@ void process_command_line(int argc, char **argv) }pi_info ("number of groups set to %d\n" , ngroups);break ; +case OPT_HELP :case 'h' :usage (0 );break ; +case OPT_INVERSIONS :case 'i' : inversions =strtol (optarg,NULL ,10 );pi_info ("doing %d inversion per group\n" , inversions);break ; +case OPT_MLOCKALL :case 'm' : lockall =1 ;break ; +case OPT_PROMPT :case 'p' : prompt =1 ;break ; +case OPT_QUIET :case 'q' : verbose =0 ; quiet =1 ;break ; +case OPT_RR :case 'r' : policy =SCHED_RR ;break ; +case OPT_SCHED :case 's' :if (process_sched_line (optarg))pi_error ("ignoring invalid options '%s'\n" , optarg);break ; +case OPT_UNIPROCESSOR :case 'u' : uniprocessor =1 ;break ; +case OPT_VERBOSE :case 'v' : verbose =1 ; quiet =0 ;break ; +case OPT_VERSION :case 'V' :printf ("pi_stress v%1.2f " ,VERSION );exit (0 );
Signature · 1 line
2.30.1
PATCH 12/13 ssdd: Add quiet command line option
In reply to Daniel WagnerThe quiet option is useful for automated test setups where only the final result of the run is interesting.
--- src/ssdd/ssdd.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-)
src/ssdd/ssdd.c +20 -9
@@ -64,9 +64,11 @@ static const char *get_state_name(int state)#define unused __attribute__((unused)) +static int quiet; +static int got_sigchld; -enum option_value {OPT_NFORKS =1 ,OPT_NITERS ,OPT_HELP }; +enum option_value {OPT_NFORKS =1 ,OPT_NITERS ,OPT_HELP ,OPT_QUIET };static void usage (int error) {
@@ -75,6 +77,7 @@ static void usage(int error)"ssdd <options>\n\n" "-f --forks=NUM number of forks\n" "-h --help print this message\n" +"-q --quiet suppress running output\n" "-i --iters=NUM number of iterations\n" );exit (error);
@@ -176,7 +179,8 @@ static int forktests(int testid)if (!child)child_process (); -printf ("forktest#%d/%d/%d: STARTING\n" , testid, parent, child); +if (!quiet) +printf ("forktest#%d/%d/%d: STARTING\n" , testid, parent, child); act.sa_sigaction = sigchld;sigemptyset (&act.sa_mask);
@@ -278,8 +282,8 @@ static int forktests(int testid)/* There is no need for the tracer to kill the tracee. It will * automatically exit when its owner, ie, us, exits. */ - -printf ("forktest#%d/%d: EXITING, no error\n" , testid, parent); +if (!quiet) +printf ("forktest#%d/%d: EXITING, no error\n" , testid, parent);exit (0 ); }
@@ -297,10 +301,11 @@ int main(int argc, char **argv)static struct option long_options[] = { {"forks" , required_argument,NULL ,OPT_NFORKS }, {"help" , no_argument,NULL ,OPT_HELP }, + {"quiet" , no_argument,NULL ,OPT_QUIET }, {"iters" , required_argument,NULL ,OPT_NITERS }, {NULL ,0 ,NULL ,0 }, }; -int c =getopt_long (argc, argv,"f:hi:" , long_options, &option_index); +int c =getopt_long (argc, argv,"f:hqi:" , long_options, &option_index);if (c ==-1 )break ;switch (c) {
@@ -312,6 +317,10 @@ int main(int argc, char **argv)case OPT_HELP :usage (0 );break ; +case OPT_QUIET : +case 'q' : + quiet =1 ; +break ;case 'i' :case OPT_NITERS : nsteps =atoi (optarg);
@@ -322,10 +331,12 @@ int main(int argc, char **argv) } } -printf ("#main : %d\n" ,getpid ()); -printf ("#forks: %d\n" , nforks); -printf ("#steps: %d\n" , nsteps); -printf ("\n" ); +if (!quiet) { +printf ("#main : %d\n" ,getpid ()); +printf ("#forks: %d\n" , nforks); +printf ("#steps: %d\n" , nsteps); +printf ("\n" ); + }for (i =0 ; i < nforks; i++) { child =fork ();
Signature · 1 line
2.30.1
PATCH 13/13 ssdd: Add JSON output feature
In reply to Daniel WagnerWrite the test results as JSON output to a file. This allows to simplifies any parsing later on.
--- src/ssdd/ssdd.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
src/ssdd/ssdd.c +22 -1
@@ -36,6 +36,8 @@#include <sys/wait.h> #include <sys/ptrace.h> +#include "rt-utils.h" +/* do_wait return values */ #define STATE_EXITED 1#define STATE_STOPPED 2
@@ -65,10 +67,11 @@ static const char *get_state_name(int state)#define unused __attribute__((unused))static int quiet; +static char outfile[MAX_PATH ];static int got_sigchld; -enum option_value {OPT_NFORKS =1 ,OPT_NITERS ,OPT_HELP ,OPT_QUIET }; +enum option_value {OPT_NFORKS =1 ,OPT_NITERS ,OPT_HELP ,OPT_OUTPUT ,OPT_QUIET };static void usage (int error) {
@@ -77,6 +80,7 @@ static void usage(int error)"ssdd <options>\n\n" "-f --forks=NUM number of forks\n" "-h --help print this message\n" +" --output=FILENAME write final results into FILENAME, JSON formatted\n" "-q --quiet suppress running output\n" "-i --iters=NUM number of iterations\n" );
@@ -287,6 +291,13 @@ static int forktests(int testid)exit (0 ); } +static void write_stats (FILE *f,void *data) +{ +int *error = data; + +fprintf (f," \"success\": %d\n" , !*error); +} +int main (int argc,char **argv) {int i, ret_sig, status;
@@ -295,12 +306,14 @@ int main(int argc, char **argv)setbuf (stdout,NULL ); +rt_init (argc, argv);for (;;) {int option_index =0 ;static struct option long_options[] = { {"forks" , required_argument,NULL ,OPT_NFORKS }, {"help" , no_argument,NULL ,OPT_HELP }, + {"output" , required_argument,NULL ,OPT_OUTPUT }, {"quiet" , no_argument,NULL ,OPT_QUIET }, {"iters" , required_argument,NULL ,OPT_NITERS }, {NULL ,0 ,NULL ,0 },
@@ -317,6 +330,9 @@ int main(int argc, char **argv)case OPT_HELP :usage (0 );break ; +case OPT_OUTPUT : +strncpy (outfile, optarg,strnlen (optarg,MAX_PATH -1 )); +break ;case OPT_QUIET :case 'q' : quiet =1 ;
@@ -348,6 +364,7 @@ int main(int argc, char **argv)forktests (i); } +rt_test_start ();for (i =0 ; i < nforks; i++) { status =do_wait (&wait_pid, &ret_sig);if (status !=STATE_EXITED ) {
@@ -363,5 +380,9 @@ int main(int argc, char **argv)printf ("%s.\n" , error ?"One or more tests FAILED" :"All tests PASSED" ); + +if (strlen (outfile) !=0 ) +rt_write_json (outfile, write_stats, &error); +exit (error); }
Signature · 1 line
2.30.1
PATCH 7/13 pip_stress: Return failure code if test fails
In reply to Daniel WagnerLet the test return a failure code when the test fails.
--- src/pi_tests/pip_stress.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
src/pi_tests/pip_stress.c +4 -4
@@ -160,11 +160,11 @@ int main(int argc, char *argv[]) } } -if (statep->inversion) -printf ("Successfully used priority inheritance to handle an inversion\n" ); -else +if (!statep->inversion) {printf ("No inversion incurred\n" ); - +exit (1 ); + } +printf ("Successfully used priority inheritance to handle an inversion\n" );exit (0 ); }
Signature · 1 line
2.30.1
PATCH 11/13 pi_stress: Add JSON output feature
In reply to Daniel WagnerWrite the test results as JSON output to a file. This allows to simplifies any parsing later on.
--- src/pi_tests/pi_stress.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
src/pi_tests/pi_stress.c +21 -1
@@ -99,6 +99,9 @@ int debugging = 0;int quiet =0 ;/* turn off all prints, default = 0 (off) */ +/* filename for JSON output */ +char outfile[MAX_PATH ]; +/* prompt to start test */ int prompt =0 ;
@@ -209,6 +212,7 @@ int create_group(struct group_parameters *group);unsigned long total_inversions (void );void banner (void );void summary (void ); +void write_stats (FILE *f,void *data);void wait_for_termination (void );int barrier_init (pthread_barrier_t *b,const pthread_barrierattr_t *attr,unsigned int count,const char *name);
@@ -235,6 +239,7 @@ int main(int argc, char **argv)/* process command line arguments */ +rt_init (argc, argv);process_command_line (argc, argv);/* set default sched attributes */
@@ -299,6 +304,7 @@ int main(int argc, char **argv) }/* report */ banner (); +rt_test_start (); start =time (NULL );/* turn loose the threads */
@@ -335,6 +341,10 @@ int main(int argc, char **argv)kill (0 ,SIGTERM ); finish =time (NULL );summary (); + +if (strlen (outfile) !=0 ) +rt_write_json (outfile, write_stats,NULL ); +if (lockall)munlockall ();exit (retval);
@@ -983,6 +993,7 @@ void usage(int error)"-h --help print this message\n" "-i INV --inversions=INV number of inversions per group (default is infinite)\n" "-m --mlockall lock current and future memory\n" +" --output=FILENAME write final results into FILENAME, JSON formatted\n" "-p --prompt prompt before starting the test\n" "-q --quiet suppress running output\n" "-r --rr use SCHED_RR for test threads [SCHED_FIFO]\n"
@@ -1276,7 +1287,7 @@ int process_sched_line(const char *arg)enum option_values {OPT_DEBUG =1 ,OPT_DURATION ,OPT_GROUPS ,OPT_HELP ,OPT_INVERSIONS , -OPT_MLOCKALL ,OPT_PROMPT ,OPT_QUIET ,OPT_RR ,OPT_SCHED , +OPT_MLOCKALL ,OPT_OUTPUT ,OPT_PROMPT ,OPT_QUIET ,OPT_RR ,OPT_SCHED ,OPT_UNIPROCESSOR ,OPT_VERBOSE ,OPT_VERSION , };
@@ -1290,6 +1301,7 @@ void process_command_line(int argc, char **argv) {"help", no_argument, NULL, OPT_HELP}, {"inversions", required_argument, NULL, OPT_INVERSIONS}, {"mlockall", no_argument, NULL, OPT_MLOCKALL}, + {"output", required_argument, NULL, OPT_OUTPUT}, {"prompt", no_argument, NULL, OPT_PROMPT}, {"quiet", no_argument, NULL, OPT_QUIET}, {"rr", no_argument, NULL, OPT_RR},
@@ -1336,6 +1348,9 @@ void process_command_line(int argc, char **argv)case 'm' : lockall =1 ;break ; +case OPT_OUTPUT : +strncpy (outfile, optarg,strnlen (optarg,MAX_PATH -1 )); +break ;case OPT_PROMPT :case 'p' : prompt =1 ;
@@ -1439,6 +1454,11 @@ void summary(void) t->tm_yday, t->tm_hour, t->tm_min, t->tm_sec); } +void write_stats (FILE *f,void *data) +{ +fprintf (f," \"inversion\": %lu\n" ,total_inversions ()); +} +int barrier_init (pthread_barrier_t *b,const pthread_barrierattr_t *attr,unsigned int count,const char *name)
Signature · 1 line
2.30.1
Re: [PATCH rt-tests v1 13/13] ssdd: Add JSON output feature
In reply to Daniel Wagnersrc/ssdd/ssdd.c static int forktests(int testid) · line 299
Quoted 6 lines · Daniel Wagner
src/ssdd/ssdd.c +6
-0+static void write_stats (FILE *f,void *data) +{ +int *error = data; + +fprintf (f," \"success\": %d\n" , !*error); +}
I think I add 'exit_code' to all of the tests.