[Openvpn-devel,v3] Add %d, %u and %lu tests to test_argv unit tests.

Message ID 20180623191538.29317-1-gert@greenie.muc.de
State Accepted
Headers show
Series
  • [Openvpn-devel,v3] Add %d, %u and %lu tests to test_argv unit tests.
Related show

Commit Message

Gert Doering June 23, 2018, 7:15 p.m.
Some basic integer tests to verify signed, unsigned and
long unsigned (1L) printing.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
--
v2: test %lu with "1" as windows and linux/i386 do not have 64 bit long
v3: fix 2^33 in commit message, use "1L" for proper data type (Selva)
---
 tests/unit_tests/openvpn/test_argv.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Selva Nair June 23, 2018, 7:21 p.m. | #1
Hi,

On Sat, Jun 23, 2018 at 3:15 PM, Gert Doering <gert@greenie.muc.de> wrote:

> Some basic integer tests to verify signed, unsigned and
> long unsigned (1L) printing.
>
> Signed-off-by: Gert Doering <gert@greenie.muc.de>
> --
> v2: test %lu with "1" as windows and linux/i386 do not have 64 bit long
> v3: fix 2^33 in commit message, use "1L" for proper data type (Selva)
> ---
>  tests/unit_tests/openvpn/test_argv.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/tests/unit_tests/openvpn/test_argv.c
> b/tests/unit_tests/openvpn/test_argv.c
> index 4a3ba559..0fdd3f0a 100644
> --- a/tests/unit_tests/openvpn/test_argv.c
> +++ b/tests/unit_tests/openvpn/test_argv.c
> @@ -116,8 +116,12 @@ argv_str__multiple_argv__correct_output(void **state)
>      argv_printf(&a, "%s%sc", PATH1, PATH2);
>      argv_printf_cat(&a, "%s", PARAM1);
>      argv_printf_cat(&a, "%s", PARAM2);
> +    argv_printf_cat(&a, "%d", -1);
> +    argv_printf_cat(&a, "%u", -1);
> +    argv_printf_cat(&a, "%lu", 1L );
>      output = argv_str(&a, &gc, PA_BRACKET);
> -    assert_string_equal(output, "[" PATH1 PATH2 "] [" PARAM1 "] [" PARAM2
> "]");
> +    assert_string_equal(output, "[" PATH1 PATH2 "] [" PARAM1 "] [" PARAM2
> "]"
> +                               " [-1] [4294967295] [1]");
>
>      argv_reset(&a);
>      gc_free(&gc);
>


Looks good now. An unconditional ACK this time.

Selva
<div dir="ltr">Hi,<div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jun 23, 2018 at 3:15 PM, Gert Doering <span dir="ltr">&lt;<a href="mailto:gert@greenie.muc.de" target="_blank">gert@greenie.muc.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Some basic integer tests to verify signed, unsigned and<br>
</span>long unsigned (1L) printing.<br>
<span class=""><br>
Signed-off-by: Gert Doering &lt;<a href="mailto:gert@greenie.muc.de">gert@greenie.muc.de</a>&gt;<br>
--<br>
v2: test %lu with &quot;1&quot; as windows and linux/i386 do not have 64 bit long<br>
</span>v3: fix 2^33 in commit message, use &quot;1L&quot; for proper data type (Selva)<br>
<span class="">---<br>
 tests/unit_tests/openvpn/test_<wbr>argv.c | 6 +++++-<br>
 1 file changed, 5 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/tests/unit_tests/openvpn/<wbr>test_argv.c b/tests/unit_tests/openvpn/<wbr>test_argv.c<br>
</span>index 4a3ba559..0fdd3f0a 100644<br>
<span class="">--- a/tests/unit_tests/openvpn/<wbr>test_argv.c<br>
+++ b/tests/unit_tests/openvpn/<wbr>test_argv.c<br>
@@ -116,8 +116,12 @@ argv_str__multiple_argv__<wbr>correct_output(void **state)<br>
     argv_printf(&amp;a, &quot;%s%sc&quot;, PATH1, PATH2);<br>
     argv_printf_cat(&amp;a, &quot;%s&quot;, PARAM1);<br>
     argv_printf_cat(&amp;a, &quot;%s&quot;, PARAM2);<br>
+    argv_printf_cat(&amp;a, &quot;%d&quot;, -1);<br>
+    argv_printf_cat(&amp;a, &quot;%u&quot;, -1);<br>
</span>+    argv_printf_cat(&amp;a, &quot;%lu&quot;, 1L );<br>
<span class="im HOEnZb">     output = argv_str(&amp;a, &amp;gc, PA_BRACKET);<br>
-    assert_string_equal(output, &quot;[&quot; PATH1 PATH2 &quot;] [&quot; PARAM1 &quot;] [&quot; PARAM2 &quot;]&quot;);<br>
+    assert_string_equal(output, &quot;[&quot; PATH1 PATH2 &quot;] [&quot; PARAM1 &quot;] [&quot; PARAM2 &quot;]&quot;<br>
+                               &quot; [-1] [4294967295] [1]&quot;);<br>
<br>
     argv_reset(&amp;a);<br>
     gc_free(&amp;gc);<br></span></blockquote><div><br></div><div><br></div><div>Looks good now. An unconditional ACK this time.</div><div><br></div><div>Selva</div></div></div></div></div>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Gert Doering June 23, 2018, 7:33 p.m. | #2
Patch has been applied to the master and release/2.4 branch.

commit 4376805d8fd2a5d4a3a7c5e4f60948a3ef76ff3b (master)
commit 6b27704dafcb60e995601178bbcfac751207e93e (release/2.4)
Author: Gert Doering
Date:   Sat Jun 23 21:15:38 2018 +0200

     Add %d, %u and %lu tests to test_argv unit tests.

     Signed-off-by: Gert Doering <gert@greenie.muc.de>
     Acked-by: Selva Nair <selva.nair@gmail.com>
     Message-Id: <20180623191538.29317-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/search?l=mid&q=20180623191538.29317-1-gert@greenie.muc.de
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

Patch

diff --git a/tests/unit_tests/openvpn/test_argv.c b/tests/unit_tests/openvpn/test_argv.c
index 4a3ba559..0fdd3f0a 100644
--- a/tests/unit_tests/openvpn/test_argv.c
+++ b/tests/unit_tests/openvpn/test_argv.c
@@ -116,8 +116,12 @@  argv_str__multiple_argv__correct_output(void **state)
     argv_printf(&a, "%s%sc", PATH1, PATH2);
     argv_printf_cat(&a, "%s", PARAM1);
     argv_printf_cat(&a, "%s", PARAM2);
+    argv_printf_cat(&a, "%d", -1);
+    argv_printf_cat(&a, "%u", -1);
+    argv_printf_cat(&a, "%lu", 1L );
     output = argv_str(&a, &gc, PA_BRACKET);
-    assert_string_equal(output, "[" PATH1 PATH2 "] [" PARAM1 "] [" PARAM2 "]");
+    assert_string_equal(output, "[" PATH1 PATH2 "] [" PARAM1 "] [" PARAM2 "]"
+				" [-1] [4294967295] [1]");
 
     argv_reset(&a);
     gc_free(&gc);