Skip to contentSkip to conversation

Change in openvpn[master]: Add small unit test for buf_chomp

Openvpn-devel In review plaisthos (Code Review) 2 participants 6 messages Nov 22, 2024 – Dec 25, 2024 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1732292548000.Ia0799189d45223e0b987a5a4da5be60404388f1f@...2715...

#1 lore raw

Attention is currently required from: flichtenheld.

Hello flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/817?usp=email

to review the following change.

Change subject: Add small unit test for buf_chomp
......................................................................

Add small unit test for buf_chomp

Change-Id Ia0799189d45223e0b987a5a4da5be60404388f1f

---
M tests/unit_tests/openvpn/test_buffer.c

1 file changed, 28 insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/17/817/1

tests/unit_tests/openvpn/test_buffer.c +28 -1
index 0fb4697..d43d5c1 100644
@@ -426,6 +426,32 @@
 #endif
 }
 
+void
+test_buffer_chomp(void **state)
+{
+    struct gc_arena gc = gc_new();
+    struct buffer buf = alloc_buf_gc(1024, &gc);
+
+    const char test1[] =  "There is a nice 1234 year old tree!\n\r";
+    buf_write(&buf, test1, sizeof(test1));
+    buf_chomp(&buf);
+    /* Check that our own method agrees */
+    assert_true(string_check_buf(&buf, CC_PRINT | CC_NULL, CC_CRLF));
+    assert_string_equal(BSTR(&buf), "There is a nice 1234 year old tree!");
+
+    struct buffer buf2 = alloc_buf_gc(1024, &gc);
+    const char test2[] =  "CR_RESPONSE,MTIx\x0a\x00";
+    buf_write(&buf2, test2, sizeof(test2));
+    buf_chomp(&buf2);
+
+    buf_chomp(&buf2);
+    /* Check that our own method agrees */
+    assert_true(string_check_buf(&buf2, CC_PRINT | CC_NULL, CC_CRLF));
+    assert_string_equal(BSTR(&buf2), "CR_RESPONSE,MTIx");
+
+    gc_free(&gc);
+}
+
 int
 main(void)
 {
@@ -460,7 +486,8 @@
         cmocka_unit_test(test_buffer_gc_realloc),
         cmocka_unit_test(test_character_class),
         cmocka_unit_test(test_character_string_mod_buf),
-        cmocka_unit_test(test_snprintf)
+        cmocka_unit_test(test_snprintf),
+        cmocka_unit_test(test_buffer_chomp)
     };
 
     return cmocka_run_group_tests_name("buffer", tests, NULL, NULL);

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/817?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia0799189d45223e0b987a5a4da5be60404388f1f
Gerrit-Change-Number: 817
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/817?usp=email )

Change subject: Add small unit test for buf_chomp
......................................................................

Patch Set 1: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/817?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia0799189d45223e0b987a5a4da5be60404388f1f
Gerrit-Change-Number: 817
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Wed, 25 Dec 2024 16:56:08 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#3 lore raw

PATCH 1/1 Add small unit test for buf_chomp

In reply to a message not in the archive

From: Arne Schwabe <[email protected]...>

Change-Id Ia0799189d45223e0b987a5a4da5be60404388f1f

---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/817
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>

tests/unit_tests/openvpn/test_buffer.c +28 -1
index 0fb4697..d43d5c1 100644
@@ -426,6 +426,32 @@
 #endif
 }
 
+void
+test_buffer_chomp(void **state)
+{
+    struct gc_arena gc = gc_new();
+    struct buffer buf = alloc_buf_gc(1024, &gc);
+
+    const char test1[] =  "There is a nice 1234 year old tree!\n\r";
+    buf_write(&buf, test1, sizeof(test1));
+    buf_chomp(&buf);
+    /* Check that our own method agrees */
+    assert_true(string_check_buf(&buf, CC_PRINT | CC_NULL, CC_CRLF));
+    assert_string_equal(BSTR(&buf), "There is a nice 1234 year old tree!");
+
+    struct buffer buf2 = alloc_buf_gc(1024, &gc);
+    const char test2[] =  "CR_RESPONSE,MTIx\x0a\x00";
+    buf_write(&buf2, test2, sizeof(test2));
+    buf_chomp(&buf2);
+
+    buf_chomp(&buf2);
+    /* Check that our own method agrees */
+    assert_true(string_check_buf(&buf2, CC_PRINT | CC_NULL, CC_CRLF));
+    assert_string_equal(BSTR(&buf2), "CR_RESPONSE,MTIx");
+
+    gc_free(&gc);
+}
+
 int
 main(void)
 {
@@ -460,7 +486,8 @@
         cmocka_unit_test(test_buffer_gc_realloc),
         cmocka_unit_test(test_character_class),
         cmocka_unit_test(test_character_string_mod_buf),
-        cmocka_unit_test(test_snprintf)
+        cmocka_unit_test(test_snprintf),
+        cmocka_unit_test(test_buffer_chomp)
     };
 
     return cmocka_run_group_tests_name("buffer", tests, NULL, NULL);
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: Add small unit test for buf_chomp

Test code it always good :-) - and it does succeed!

Your patch has been applied to the master branch.

commit bd629d7c8b389bdece3c195552acf4343021b9b8

Author: Arne Schwabe
Date:   Wed Dec 25 17:56:29 2024 +0100
     Add small unit test for buf_chomp

     Signed-off-by: Arne Schwabe <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg30206.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#2) to the change originally created by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/817?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

Change subject: Add small unit test for buf_chomp
......................................................................

Add small unit test for buf_chomp

Change-Id Ia0799189d45223e0b987a5a4da5be60404388f1f

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30206.html

---
M tests/unit_tests/openvpn/test_buffer.c

1 file changed, 28 insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/17/817/2

tests/unit_tests/openvpn/test_buffer.c +28 -1
index 0fb4697..d43d5c1 100644
@@ -426,6 +426,32 @@
 #endif
 }
 
+void
+test_buffer_chomp(void **state)
+{
+    struct gc_arena gc = gc_new();
+    struct buffer buf = alloc_buf_gc(1024, &gc);
+
+    const char test1[] =  "There is a nice 1234 year old tree!\n\r";
+    buf_write(&buf, test1, sizeof(test1));
+    buf_chomp(&buf);
+    /* Check that our own method agrees */
+    assert_true(string_check_buf(&buf, CC_PRINT | CC_NULL, CC_CRLF));
+    assert_string_equal(BSTR(&buf), "There is a nice 1234 year old tree!");
+
+    struct buffer buf2 = alloc_buf_gc(1024, &gc);
+    const char test2[] =  "CR_RESPONSE,MTIx\x0a\x00";
+    buf_write(&buf2, test2, sizeof(test2));
+    buf_chomp(&buf2);
+
+    buf_chomp(&buf2);
+    /* Check that our own method agrees */
+    assert_true(string_check_buf(&buf2, CC_PRINT | CC_NULL, CC_CRLF));
+    assert_string_equal(BSTR(&buf2), "CR_RESPONSE,MTIx");
+
+    gc_free(&gc);
+}
+
 int
 main(void)
 {
@@ -460,7 +486,8 @@
         cmocka_unit_test(test_buffer_gc_realloc),
         cmocka_unit_test(test_character_class),
         cmocka_unit_test(test_character_string_mod_buf),
-        cmocka_unit_test(test_snprintf)
+        cmocka_unit_test(test_snprintf),
+        cmocka_unit_test(test_buffer_chomp)
     };
 
     return cmocka_run_group_tests_name("buffer", tests, NULL, NULL);

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/817?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia0799189d45223e0b987a5a4da5be60404388f1f
Gerrit-Change-Number: 817
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/817?usp=email )

Change subject: Add small unit test for buf_chomp
......................................................................

Add small unit test for buf_chomp

Change-Id Ia0799189d45223e0b987a5a4da5be60404388f1f

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30206.html

---
M tests/unit_tests/openvpn/test_buffer.c

1 file changed, 28 insertions(+), 1 deletion(-)
tests/unit_tests/openvpn/test_buffer.c +28 -1
index 0fb4697..d43d5c1 100644
@@ -426,6 +426,32 @@
 #endif
 }
 
+void
+test_buffer_chomp(void **state)
+{
+    struct gc_arena gc = gc_new();
+    struct buffer buf = alloc_buf_gc(1024, &gc);
+
+    const char test1[] =  "There is a nice 1234 year old tree!\n\r";
+    buf_write(&buf, test1, sizeof(test1));
+    buf_chomp(&buf);
+    /* Check that our own method agrees */
+    assert_true(string_check_buf(&buf, CC_PRINT | CC_NULL, CC_CRLF));
+    assert_string_equal(BSTR(&buf), "There is a nice 1234 year old tree!");
+
+    struct buffer buf2 = alloc_buf_gc(1024, &gc);
+    const char test2[] =  "CR_RESPONSE,MTIx\x0a\x00";
+    buf_write(&buf2, test2, sizeof(test2));
+    buf_chomp(&buf2);
+
+    buf_chomp(&buf2);
+    /* Check that our own method agrees */
+    assert_true(string_check_buf(&buf2, CC_PRINT | CC_NULL, CC_CRLF));
+    assert_string_equal(BSTR(&buf2), "CR_RESPONSE,MTIx");
+
+    gc_free(&gc);
+}
+
 int
 main(void)
 {
@@ -460,7 +486,8 @@
         cmocka_unit_test(test_buffer_gc_realloc),
         cmocka_unit_test(test_character_class),
         cmocka_unit_test(test_character_string_mod_buf),
-        cmocka_unit_test(test_snprintf)
+        cmocka_unit_test(test_snprintf),
+        cmocka_unit_test(test_buffer_chomp)
     };
 
     return cmocka_run_group_tests_name("buffer", tests, NULL, NULL);

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/817?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia0799189d45223e0b987a5a4da5be60404388f1f
Gerrit-Change-Number: 817
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged