From patchwork Wed Dec 25 16:56:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4018 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:998b:b0:5e7:b9eb:58e8 with SMTP id d11csp5235688mav; Wed, 25 Dec 2024 08:56:42 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVMCvH8AQ9KEQ8kV5yhkHtaRc64Qnmhr+IGhkgfQJsHmlklhhvi42guHOe92xmM2sLQ9oLrF60X3ok=@openvpn.net X-Google-Smtp-Source: AGHT+IGcQLg8pwG11CuLpJPYqmDN2jcoVyfmusGjrhEYWKonKfzRAIijS+K49U2gUiQjsK3mz3tY X-Received: by 2002:a05:6871:4e48:b0:296:dd30:e90f with SMTP id 586e51a60fabf-2a7fb0b7623mr10293134fac.16.1735145802410; Wed, 25 Dec 2024 08:56:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735145802; cv=none; d=google.com; s=arc-20240605; b=QfjanvxI9xMCspnA1RmGf45I2Ag1kHzJw64XDbZTXrprSKtauWJbfv7dTL0ha2Rx9X iEldKG+FktW125Heb7cNmTxHJOP2bNLtu0eSZuT+dZYOA8KPmg7h3IU3F027+zS04gUa ZDyqD3UVnAsRHPVfqFYT7glnGbGQR0HOeVcA1dvdhkdSEeucFP/T3J2rui/PB5sa/OPV zznVSnLaue07xfLlaQ7zbkbUr6HAkykgs1A/rFb2GlRsmn/RLeondfORl7guuCszjPYF jvVCW2y4Gu1T50QmJzQ024jDLJefDO06lV3nTArrwFPh7VQbNw63id0pPejVQ/nyAZgC gouw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature; bh=UaPEgn4a1ajLZVImSnwgwKWTN/Xp6+ZqkvMkBEwb1x8=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=f6kZwl3Lhg9y0wdJ18peKuEVCkLV0HC1zBQZGTFcAQ5BmtKWR+6a0aLhZlj2UrSQnV rlAXTk2Hf7loQlrjpjGdq/ErAq8ChFe+r3uD9SFam1QbpBOEjlRsqa7KqS8LXss1UsCk oGanot866usc/kg4DHCOMNZBBsF5rdEClI+ltJxsdUOZPYhZs4R8UmIWfXB5BUZyCbAE KBBAvN2Tq042ugVaTffVGK4x2Yx4cfYOukL0lqNrrPLBOiacsIXcSD4iZX02udXQf2id aRMolRtExZ5wBAms8/1ZSMSG0tdUrIdNeO7zY14CCkCy2PgG11CBRn55RGiAZMKuizvi h9/g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=YVmm+VSu; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=TRZg2fGs; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 006d021491bc7-5f4db5d6ed2si8929515eaf.35.2024.12.25.08.56.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Dec 2024 08:56:42 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=YVmm+VSu; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=TRZg2fGs; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1tQUga-0003UX-7w; Wed, 25 Dec 2024 16:56:39 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1tQUgY-0003UR-Hi for openvpn-devel@lists.sourceforge.net; Wed, 25 Dec 2024 16:56:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=1O6EA9DywyaXomQfiIA7IkrslGXyVfOAg9kUPUPcVuo=; b=YVmm+VSuTZTUBfe/KR0STZxCmv jsT7qUyYOHweBbUSR0dMf99mAXiPKE/tvwQ7eW+AC+7cLqPMS2Ns2ysfPkvMd8k7UWUULR4LbCRuM ELw1cIfY3DdXX5cgw46SqSg70dqhftvsCPlbXF57uJP5FwwIjLi5v5NzI7BQ3Zdmbp+Q=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=1O6EA9DywyaXomQfiIA7IkrslGXyVfOAg9kUPUPcVuo=; b=TRZg2fGsFTN0tL4XvoEGjY9QQp OE4fV7euhGrFd3ny7eAsYCEb0wvzA0jKpNkywY+T6kjleCoZDMTMHcqB+a6CABT2J/i/LXfiVagSa qkYQR0HMTzHogB79cfj2n02MDzsuIR6eoefOpkymhYHn9nyd24JIaywUydntiCctVyPA=; Received: from dhcp-174.greenie.muc.de ([193.149.48.174] helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1tQUgW-0002OU-M0 for openvpn-devel@lists.sourceforge.net; Wed, 25 Dec 2024 16:56:37 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.17.1.9/8.17.1.9) with ESMTP id 4BPGuUut005568 for ; Wed, 25 Dec 2024 17:56:30 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.17.1.9/8.17.1.9/Submit) id 4BPGuUxV005567 for openvpn-devel@lists.sourceforge.net; Wed, 25 Dec 2024 17:56:30 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Wed, 25 Dec 2024 17:56:29 +0100 Message-ID: <20241225165629.5558-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-2.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Arne Schwabe Change-Id: Ia0799189d45223e0b987a5a4da5be60404388f1f Signed-off-by: Arne Schwabe Acked-by: Gert Doering --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Content analysis details: (0.0 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [193.149.48.174 listed in bl.score.senderscore.com] 0.0 RCVD_IN_VALIDITY_SAFE_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [193.149.48.174 listed in sa-accredit.habeas.com] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record X-Headers-End: 1tQUgW-0002OU-M0 Subject: [Openvpn-devel] [PATCH v1] Add small unit test for buf_chomp X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1819432245134900578?= X-GMAIL-MSGID: =?utf-8?q?1819432245134900578?= From: Arne Schwabe Change-Id: Ia0799189d45223e0b987a5a4da5be60404388f1f Signed-off-by: Arne Schwabe Acked-by: Gert Doering --- 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 diff --git a/tests/unit_tests/openvpn/test_buffer.c b/tests/unit_tests/openvpn/test_buffer.c index 0fb4697..d43d5c1 100644 --- a/tests/unit_tests/openvpn/test_buffer.c +++ b/tests/unit_tests/openvpn/test_buffer.c @@ -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);