Linux-rt-users Archive on lore.kernel.org
 help / color / Atom feed
From: Daniel Wagner <dwagner@suse.de>
To: Clark Williams <williams@redhat.com>, John Kacur <jkacur@redhat.com>
Cc: linux-rt-users@vger.kernel.org, Daniel Wagner <dwagner@suse.de>
Subject: [PATCH rt-tests v3 14/33] rt-util: Remove superfluous arguments from rt_write_json
Date: Sat, 20 Mar 2021 19:38:10 +0100
Message-ID: <20210320183829.1318-15-dwagner@suse.de> (raw)
In-Reply-To: <20210320183829.1318-1-dwagner@suse.de>

We copy the command line via the rt_init() API and don't need
the argc, argv arguments for rt_write_json. Remove them.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/cyclictest/cyclictest.c           |  2 +-
 src/include/rt-utils.h                |  2 +-
 src/lib/rt-utils.c                    | 41 ++-------------------------
 src/oslat/oslat.c                     |  3 +-
 src/pmqtest/pmqtest.c                 |  2 +-
 src/ptsematest/ptsematest.c           |  2 +-
 src/rt-migrate-test/rt-migrate-test.c |  2 +-
 src/sched_deadline/cyclicdeadline.c   |  2 +-
 src/signaltest/signaltest.c           |  2 +-
 src/sigwaittest/sigwaittest.c         |  2 +-
 src/svsematest/svsematest.c           |  2 +-
 11 files changed, 12 insertions(+), 50 deletions(-)

diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index e817af217952..3f3b91bab53b 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -2134,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;
diff --git a/src/include/rt-utils.h b/src/include/rt-utils.h
index 1dbd3f1dd8e3..115791c55185 100644
--- a/src/include/rt-utils.h
+++ b/src/include/rt-utils.h
@@ -82,7 +82,7 @@ static inline int64_t calctime(struct timespec t)
 
 void rt_init(int argc, char *argv[]);
 
-void rt_write_json(const char *filename, int argc, char *argv[],
+void rt_write_json(const char *filename,
 		   void (*cb)(FILE *, void *),
 		   void *data);
 
diff --git a/src/lib/rt-utils.c b/src/lib/rt-utils.c
index 8f0e0943b137..f736a3449bf7 100644
--- a/src/lib/rt-utils.c
+++ b/src/lib/rt-utils.c
@@ -37,7 +37,6 @@ static int trace_fd = -1;
 static int tracemark_fd = -1;
 static __thread char tracebuf[TRACEBUFSIZ];
 static char test_cmdline[MAX_COMMAND_LINE];
-static int rt_init_run;
 
 /*
  * Finds the tracing directory in a mounted debugfs
@@ -513,35 +512,9 @@ void rt_init(int argc, char *argv[])
 
 		offset += len + 1;
 	}
-
-	rt_init_run = 1;
-}
-
-static char *get_cmdline(int argc, char *argv[])
-{
-	char *cmdline;
-	int len, i;
-
-	len = 0;
-	for (i = 0; i < argc; i++)
-		len += strlen(argv[i]) + 1;
-
-	cmdline = malloc(len);
-	if (!cmdline)
-		err_exit(ENOMEM, "Could not copy cmdline");
-
-	memset(cmdline, 0, len);
-	for (i = 0; i < argc;) {
-		cmdline = strcat(cmdline, argv[i]);
-		i++;
-		if (i < argc)
-			cmdline = strcat(cmdline, " ");
-	}
-
-	return cmdline;
 }
 
-void rt_write_json(const char *filename, int argc, char *argv[],
+void rt_write_json(const char *filename,
 		  void (*cb)(FILE *, void *),
 		  void *data)
 {
@@ -550,7 +523,6 @@ void rt_write_json(const char *filename, int argc, char *argv[],
 	struct timeval tv;
 	char tsbuf[64];
 	struct tm *tm;
-	char *cmdline = NULL;
 	FILE *f, *s;
 	time_t t;
 	size_t n;
@@ -564,12 +536,6 @@ void rt_write_json(const char *filename, int argc, char *argv[],
 			err_exit(errno, "Failed to open '%s'\n", filename);
 	}
 
-	if (!rt_init_run) {
-		cmdline = get_cmdline(argc, argv);
-		if (!cmdline)
-			err_exit(ENOMEM, "get_cmdline()");
-	}
-
 	gettimeofday(&tv, NULL);
 	t = tv.tv_sec;
 	tm = localtime(&t);
@@ -589,7 +555,7 @@ void rt_write_json(const char *filename, int argc, char *argv[],
 
 	fprintf(f, "{\n");
 	fprintf(f, "  \"file_version\": 1,\n");
-	fprintf(f, "  \"cmdline:\": \"%s\",\n", rt_init_run? test_cmdline : cmdline);
+	fprintf(f, "  \"cmdline:\": \"%s\",\n", test_cmdline);
 	fprintf(f, "  \"rt_test_version:\": \"%1.2f\",\n", VERSION);
 	fprintf(f, "  \"finished\": \"%s\",\n", tsbuf);
 	fprintf(f, "  \"sysinfo\": {\n");
@@ -605,9 +571,6 @@ void rt_write_json(const char *filename, int argc, char *argv[],
 
 	fprintf(f, "}\n");
 
-	if (!rt_init_run)
-		free(cmdline);
-
 	if (!filename || strcmp("-", filename))
 		fclose(f);
 }
diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c
index da7b25d48384..ac54d05697ef 100644
--- a/src/oslat/oslat.c
+++ b/src/oslat/oslat.c
@@ -862,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);
diff --git a/src/pmqtest/pmqtest.c b/src/pmqtest/pmqtest.c
index aae3c78f8a0a..f96b3d0bf400 100644
--- a/src/pmqtest/pmqtest.c
+++ b/src/pmqtest/pmqtest.c
@@ -651,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:
diff --git a/src/ptsematest/ptsematest.c b/src/ptsematest/ptsematest.c
index eb7ac4ccc823..a32bfc1698f0 100644
--- a/src/ptsematest/ptsematest.c
+++ b/src/ptsematest/ptsematest.c
@@ -519,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:
diff --git a/src/rt-migrate-test/rt-migrate-test.c b/src/rt-migrate-test/rt-migrate-test.c
index daa876d3e2b2..cdfbfafb200b 100644
--- a/src/rt-migrate-test/rt-migrate-test.c
+++ b/src/rt-migrate-test/rt-migrate-test.c
@@ -663,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) {
 		/*
diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
index 13a1812c13b3..e6811838b62d 100644
--- a/src/sched_deadline/cyclicdeadline.c
+++ b/src/sched_deadline/cyclicdeadline.c
@@ -1227,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);
diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c
index 4da8436e4296..6abf38b7821c 100644
--- a/src/signaltest/signaltest.c
+++ b/src/signaltest/signaltest.c
@@ -558,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:
diff --git a/src/sigwaittest/sigwaittest.c b/src/sigwaittest/sigwaittest.c
index a1808409730a..142419f9e315 100644
--- a/src/sigwaittest/sigwaittest.c
+++ b/src/sigwaittest/sigwaittest.c
@@ -706,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:
diff --git a/src/svsematest/svsematest.c b/src/svsematest/svsematest.c
index 24e5e7adf494..7c9d21edbab2 100644
--- a/src/svsematest/svsematest.c
+++ b/src/svsematest/svsematest.c
@@ -778,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:
-- 
2.30.2


  parent reply index

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-20 18:37 [PATCH rt-tests v3 00/33] JSON cleanups and more tests updated Daniel Wagner
2021-03-20 18:37 ` [PATCH rt-tests v3 01/33] cyclictest: Remove unused include header Daniel Wagner
2021-05-07 16:17   ` John Kacur
2021-03-20 18:37 ` [PATCH rt-tests v3 02/33] cyclicdeadline: " Daniel Wagner
2021-05-07 16:19   ` John Kacur
2021-03-20 18:37 ` [PATCH rt-tests v3 03/33] signaltest: Add missing --output usage info Daniel Wagner
2021-05-07 16:26   ` John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 04/33] rt-util: Add rt_init function Daniel Wagner
2021-05-07 16:27   ` John Kacur
2021-05-12  7:30     ` Daniel Wagner
2021-03-20 18:38 ` [PATCH rt-tests v3 05/33] cyclictest: Initialize rt-util Daniel Wagner
2021-05-07 16:28   ` John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 06/33] oslat: " Daniel Wagner
2021-05-07 16:29   ` John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 07/33] pmqtest: " Daniel Wagner
2021-05-07 16:29   ` John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 08/33] ptsematest: " Daniel Wagner
2021-05-07 16:30   ` John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 09/33] rt-migrate-test: " Daniel Wagner
2021-05-07 16:31   ` John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 10/33] cyclicdeadline: " Daniel Wagner
2021-05-07 16:31   ` John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 11/33] signaltest: " Daniel Wagner
2021-05-07 16:32   ` John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 12/33] sigwaittest: " Daniel Wagner
2021-05-07 16:33   ` John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 13/33] svematest: " Daniel Wagner
2021-05-07 16:34   ` John Kacur
2021-03-20 18:38 ` Daniel Wagner [this message]
2021-05-07 16:36   ` [PATCH rt-tests v3 14/33] rt-util: Remove superfluous arguments from rt_write_json John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 15/33] rt-util: Introduce rt_test_start() Daniel Wagner
2021-05-07 16:40   ` John Kacur
2021-05-12  7:33     ` Daniel Wagner
2021-03-20 18:38 ` [PATCH rt-tests v3 16/33] cyclictest: Record start of test execution Daniel Wagner
2021-05-07 16:41   ` John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 17/33] oslat: " Daniel Wagner
2021-05-07 16:41   ` John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 18/33] pmqtest: " Daniel Wagner
2021-05-07 16:43   ` John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 19/33] ptesematest: " Daniel Wagner
2021-05-07 16:43   ` John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 20/33] rt-migrate-test: " Daniel Wagner
2021-05-07 16:44   ` John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 21/33] cyclicdeadline: " Daniel Wagner
2021-05-07 16:45   ` John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 22/33] signaltest: " Daniel Wagner
2021-05-07 16:45   ` John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 23/33] sigwaittest: " Daniel Wagner
2021-05-07 16:46   ` John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 24/33] svsematest: " Daniel Wagner
2021-05-07 16:46   ` John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 25/33] rt-util: Add return_code to common section of JSON output Daniel Wagner
2021-05-07 16:49   ` John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 26/33] pip_stress: Move test result output to main Daniel Wagner
2021-05-07 16:55   ` John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 27/33] pip_stress: Return failure code if test fails Daniel Wagner
2021-05-07 16:54   ` John Kacur
2021-05-12  7:35     ` Daniel Wagner
2021-05-13 19:27       ` John Kacur
2021-05-14  6:58         ` Daniel Wagner
2021-03-20 18:38 ` [PATCH rt-tests v3 28/33] pip_stress: Prepare arg parser to accept only long options Daniel Wagner
2021-05-07 16:55   ` John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 29/33] pip_stress: Add JSON output feature Daniel Wagner
2021-05-07 16:58   ` John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 30/33] pi_stress: Prepare command line parser for long options only Daniel Wagner
2021-05-07 16:58   ` John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 31/33] pi_stress: Add JSON output feature Daniel Wagner
2021-05-07 16:59   ` John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 32/33] ssdd: Add quiet command line option Daniel Wagner
2021-05-07 17:00   ` John Kacur
2021-03-20 18:38 ` [PATCH rt-tests v3 33/33] ssdd: Add JSON output feature Daniel Wagner
2021-05-07 17:00   ` John Kacur
2021-03-22 15:50 ` [PATCH rt-tests v3 00/33] JSON cleanups and more tests updated John Kacur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210320183829.1318-15-dwagner@suse.de \
    --to=dwagner@suse.de \
    --cc=jkacur@redhat.com \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=williams@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-rt-users Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rt-users/0 linux-rt-users/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rt-users linux-rt-users/ https://lore.kernel.org/linux-rt-users \
		linux-rt-users@vger.kernel.org
	public-inbox-index linux-rt-users

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rt-users


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git