diff mbox series

[2/2] network/netstress: set default options value after arg parsing

Message ID 20191112151131.5740-2-alexey.kodanev@oracle.com
State Accepted
Headers show
Series [1/2] network/netstress: fix -D option description | expand

Commit Message

Alexey Kodanev Nov. 12, 2019, 3:11 p.m. UTC
It fixes misleading warnings about multiple options being set:

$ netstress -H 127.0.0.1
tst_test.c:500: WARN: Option -H passed multiple times
tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s
...

But for the result path 'rpath', don't create a file if the option
is not set.

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 testcases/network/netstress/netstress.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Petr Vorel Nov. 13, 2019, 1:02 a.m. UTC | #1
Hi Alexey,

> It fixes misleading warnings about multiple options being set:

> $ netstress -H 127.0.0.1
> tst_test.c:500: WARN: Option -H passed multiple times
> tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s
> ...

> But for the result path 'rpath', don't create a file if the option
> is not set.

> Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>

Reviewed-by: Petr Vorel <pvorel@suse.cz>
Tested-by: Petr Vorel <pvorel@suse.cz>

Good catch :).

Kind regards,
Petr
Alexey Kodanev Nov. 13, 2019, 10:55 a.m. UTC | #2
On 13.11.2019 04:02, Petr Vorel wrote:
> Hi Alexey,
> 
>> It fixes misleading warnings about multiple options being set:
> 
>> $ netstress -H 127.0.0.1
>> tst_test.c:500: WARN: Option -H passed multiple times
>> tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s
>> ...
> 
>> But for the result path 'rpath', don't create a file if the option
>> is not set.
> 
>> Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
> 
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
> Tested-by: Petr Vorel <pvorel@suse.cz>
> 
> Good catch :).
> 

Thanks for review Petr, both patches applied.
diff mbox series

Patch

diff --git a/testcases/network/netstress/netstress.c b/testcases/network/netstress/netstress.c
index a5cc9a532..76d2fdb04 100644
--- a/testcases/network/netstress/netstress.c
+++ b/testcases/network/netstress/netstress.c
@@ -70,7 +70,7 @@  static int server_max_requests	= 3;
 static int client_max_requests	= 10;
 static int clients_num;
 static char *tcp_port;
-static char *server_addr	= "localhost";
+static char *server_addr;
 static char *source_addr;
 static char *server_bg;
 static int busy_poll		= -1;
@@ -101,7 +101,7 @@  static int sfd;
 static int wait_timeout = 60000;
 
 /* in the end test will save time result in this file */
-static char *rpath = "tfo_result";
+static char *rpath;
 static char *port_path = "netstress_port";
 static char *log_path = "netstress.log";
 
@@ -517,7 +517,8 @@  static void client_run(void)
 		SAFE_CLOSE(cfd);
 	}
 	/* the script tcp_fastopen_run.sh will remove it */
-	SAFE_FILE_PRINTF(rpath, "%ld", clnt_time);
+	if (rpath)
+		SAFE_FILE_PRINTF(rpath, "%ld", clnt_time);
 
 	tst_res(TPASS, "test completed");
 }
@@ -867,6 +868,9 @@  static void setup(void)
 	if (tst_parse_int(Aarg, &max_rand_msg_len, 10, max_msg_len))
 		tst_brk(TBROK, "Invalid max random payload size '%s'", Aarg);
 
+	if (!server_addr)
+		server_addr = "localhost";
+
 	if (max_rand_msg_len) {
 		max_rand_msg_len -= min_msg_len;
 		unsigned int seed = max_rand_msg_len ^ client_max_requests;