From patchwork Mon May 20 09:05:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7786 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4VjWs409xDz3wxG for ; Mon, 20 May 2024 09:06:32 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4VjWs20bjyz3B3; Mon, 20 May 2024 09:06:30 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VjWs203VNz331V; Mon, 20 May 2024 09:06:30 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4VjWrz1JCcz32W4 for ; Mon, 20 May 2024 09:06:27 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4VjWry1fhGzXY; Mon, 20 May 2024 09:06:26 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1716195986; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=496lRWQep/rWLT+vUq0AWrupTThbzM+E0hy+yWfeFhg=; b=Vu76yyEXug6mxRgy27qSGqWBY7oFEVsXyTcojvvoVoaeAHNnEgJBoX9Wb1JGKVvbX3RUUk ovQiQQRxD/YrHdBQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1716195986; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=496lRWQep/rWLT+vUq0AWrupTThbzM+E0hy+yWfeFhg=; b=ux+mj27JD68osO7h93TjVpBuVyCga6fb/WoVdmxAtRyxH6EsIZJUQTxAP+1/uXVRXcCTlt JMb9qB99ksOoL2SD/loEHie3L53wbS8jofHDdiYsV9QwlkBEb0A7BzRgU3J0Gypr13D/bD /2rgHcbxbMrHv7mb2fu9N+o+YE76HxLVGF4BdqjKINLYKkF5loPXaFTVOJHlUBP4TiROPS bqrn6GL2fdnL5u2uGHPPgOnc+w1yJeWwplgH9fFBY+GwUpaxiuSgBdrisUg2vbJ8YHBnc9 ido76Xjn3DYWwi/mkAl0D9/S41THSsdzfmBolXaxA0mkXM1BLB6TX/tjPbAYQg== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 01/21] test: Add bash lib for colors Date: Mon, 20 May 2024 11:05:51 +0200 Message-Id: <20240520090611.10406-2-jonatan.schlag@ipfire.org> In-Reply-To: <20240520090611.10406-1-jonatan.schlag@ipfire.org> References: <20240520090611.10406-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: CSVWJ6S3S27T2KG5CHOBCOBJ5L66RHVG X-Message-ID-Hash: CSVWJ6S3S27T2KG5CHOBCOBJ5L66RHVG X-MailFrom: jonatan.schlag@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This is borrowed from here: https://git.ipfire.org/?p=network.git;a=blob;f=src/functions/functions.colors;h=0bd6f97177c366f1d1ee4553043ae719430acdb2;hb=refs/heads/master Signed-off-by: Jonatan Schlag --- tests/lib_color.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/lib_color.sh diff --git a/tests/lib_color.sh b/tests/lib_color.sh new file mode 100644 index 000000000..6ca1c9864 --- /dev/null +++ b/tests/lib_color.sh @@ -0,0 +1,43 @@ +#!/usr/bin/bash + +# Regular colours +CLR_BLACK_R='\e[0;30m' +CLR_RED_R='\e[0;31m' +CLR_GREEN_R='\e[0;32m' +CLR_YELLOW_R='\e[0;33m' +CLR_BLUE_R='\e[0;34m' +CLR_PURPLE_R='\e[0;35m' +CLR_CYAN_R='\e[0;36m' +CLR_WHITE_R='\e[0;37m' + +# Bold colours +CLR_BLACK_B='\e[1;30m' +CLR_RED_B='\e[1;31m' +CLR_GREEN_B='\e[1;32m' +CLR_YELLOW_B='\e[1;33m' +CLR_BLUE_B='\e[1;34m' +CLR_PURPLE_B='\e[1;35m' +CLR_CYAN_B='\e[1;36m' +CLR_WHITE_B='\e[1;37m' + +# Background colors +CLR_BLACK_BG='\e[40m' +CLR_RED_BG='\e[41m' +CLR_GREEN_BG='\e[42m' +CLR_YELLOW_BG='\e[43m' +CLR_BLUE_BG='\e[44m' +CLR_PURPLE_BG='\e[45m' +CLR_CYAN_BG='\e[46m' +CLR_WHITE_BG='\e[47m' + +# Font decoration +FONT_RESET="\e[0m" +FONT_BOLD="\e[1m" +FONT_UNDERLINED="\e[4m" +FONT_BLINKING="\e[5m" +FONT_INVERTED="\e[7m" + +# Reset everything +CLR_RESET="${FONT_RESET}" + + From patchwork Mon May 20 09:05:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7787 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4VjWs544Vvz3wxG for ; Mon, 20 May 2024 09:06:33 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4VjWs31w0jz1Fb; Mon, 20 May 2024 09:06:31 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VjWs31Nj5z32w8; Mon, 20 May 2024 09:06:31 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4VjWs06pmtz2y2N for ; Mon, 20 May 2024 09:06:28 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4VjWs02YLKz2PV; Mon, 20 May 2024 09:06:28 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1716195988; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3c9qfvwiI0b2KhGo7Hp1UisXYc10n5u8chMNBMekolA=; b=j8lmroPCieK8AHSZuG9qEmlziQ3RNEKHMKpBnX3EisIohYlKvI+u4cE6adnCK6+gbL5hYB FJq4YPM1nofRiqBg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1716195988; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3c9qfvwiI0b2KhGo7Hp1UisXYc10n5u8chMNBMekolA=; b=epECaIJF/UqZJDUvfcVb3bU1IvgygIwCA4tBqfY57o7QzbJJ5ldDpg8d9L5pKvSoJjyk2x nu80Sx9lKahHo0pSKU8QYg14murm5LWRPnIqp4NNqvaBaVoe2XWdacut0UVu/uUEqUWkSB V1oPTU8N1Qdh5m3m/VIxs5eBbKOlv38N0uY4DEaAX+GuhlTzriqObRa1iScsPD56kdzgEm quBWYlewzEGL9NzOgH3eHe2SaY5xIrOrrRINo6TJLzmgFf7oNl3qc3d0aSalaOdKqEWfUQ fKtxO/hk91ZvafA+BPH+7O4b1129lkfAYty9zIT4+XKL6faxKa2M4uCc/4JvqQ== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 02/21] tests: Add bash lib Date: Mon, 20 May 2024 11:05:52 +0200 Message-Id: <20240520090611.10406-3-jonatan.schlag@ipfire.org> In-Reply-To: <20240520090611.10406-1-jonatan.schlag@ipfire.org> References: <20240520090611.10406-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: VCHFVUPTKILNUOORJBCEO5MJ5GMDD7MU X-Message-ID-Hash: VCHFVUPTKILNUOORJBCEO5MJ5GMDD7MU X-MailFrom: jonatan.schlag@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This allows use to write test with less effort as we can reuse functions Signed-off-by: Jonatan Schlag --- tests/lib.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/lib.sh diff --git a/tests/lib.sh b/tests/lib.sh new file mode 100644 index 000000000..7749d5158 --- /dev/null +++ b/tests/lib.sh @@ -0,0 +1,20 @@ +#!/usr/bin/bash + +LIB_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" + +. ${LIB_DIR}/lib_color.sh + +test_that() { + + if ! "$@" ; then + echo -e "${CLR_RED_BG} Test failed: ${*} ${CLR_RESET}" + return 1 + else + echo -e "${CLR_GREEN_BG} Test succeded: ${*} ${CLR_RESET}" + return 0 + fi +} + +var_has_value() { + [[ "${!1}" == "${2}" ]] +} From patchwork Mon May 20 09:05:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7788 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4VjWs62TLgz3wxV for ; Mon, 20 May 2024 09:06:34 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4VjWs347Qsz5d1; Mon, 20 May 2024 09:06:31 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VjWs32pMRz331V; Mon, 20 May 2024 09:06:31 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4VjWs142Q6z32W4 for ; Mon, 20 May 2024 09:06:29 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4VjWs12xKJz3B3; Mon, 20 May 2024 09:06:29 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1716195989; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LTcENVS1jjIVPn5ZOCxY2Uz6sou6ozqG28nk6C1grGM=; b=y+FN1nymxYbD248laO5bEEZR4a6r3zgeLOOqDjZgHvFobJASJzkOjZ8/pkFLGFj4MYkhhx kE4uMra3qTwwsVCw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1716195989; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LTcENVS1jjIVPn5ZOCxY2Uz6sou6ozqG28nk6C1grGM=; b=jgSpC0rnw+VF6ceslIKdafQ1IiEIyTT1N0fGcgxoB3tG8PGTgRaIIcLyVyB5G1QVW22AfB xi3CNumWMtpeQ1dyct8rgSAmA0opM4Km73PGQJFv6lI3cE3Ykp6Rsr+mMmd8S7ubl9F0tR PPnZR7P45/bKFSL+aGlVQo4552HZqMt5JoDMy2oxXgkJbOWVcAImnWi/NHV5//nYAf4ugG gfzjdAIdb1CUi0id+qD27tELjMOOpkSJfagUJfWczBta1ADocUrvbg1i1CT1sakoZ+8uhT 3DT9pC2dlxKsKsAEV04rXVtw49MHt++IpuH3pNcMmj+C1NnUUFDcpV5CTZEiSg== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 03/21] tests/lib.sh: Add function test_that_key_in_arry_has_value Date: Mon, 20 May 2024 11:05:53 +0200 Message-Id: <20240520090611.10406-4-jonatan.schlag@ipfire.org> In-Reply-To: <20240520090611.10406-1-jonatan.schlag@ipfire.org> References: <20240520090611.10406-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: KEQ7WN5CPTGF6UPP6DW7PHHHC6MCFFFG X-Message-ID-Hash: KEQ7WN5CPTGF6UPP6DW7PHHHC6MCFFFG X-MailFrom: jonatan.schlag@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: I think the name says it all. Signed-off-by: Jonatan Schlag --- tests/lib.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/lib.sh b/tests/lib.sh index 7749d5158..c51257e79 100644 --- a/tests/lib.sh +++ b/tests/lib.sh @@ -18,3 +18,17 @@ test_that() { var_has_value() { [[ "${!1}" == "${2}" ]] } + +test_that_key_in_arry_has_value() { + local array="${!1}" + local key="${2}" + local value="${3}" + + if [[ "${array[${key}]}" == "${value}" ]] ; then + echo -e "${CLR_GREEN_BG}Test succeded: The array '${1}' contains the value '${value}' under the key '${key}' ${CLR_RESET}" + return 0 + else + echo -e "${CLR_RED_BG}Test failed: The array '${1}' contains the value '${array[${key}]}' under the key '${key} and not '${value}' ${CLR_RESET}" + return 1 + fi +} From patchwork Mon May 20 09:05:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7789 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4VjWs81qxXz3wxG for ; Mon, 20 May 2024 09:06:36 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4VjWs452X4z5XX; Mon, 20 May 2024 09:06:32 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VjWs44Tfzz32W4; Mon, 20 May 2024 09:06:32 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4VjWs22ZVkz2y2N for ; Mon, 20 May 2024 09:06:30 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4VjWs20YxSz1Fb; Mon, 20 May 2024 09:06:30 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1716195990; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PS5ewSnQPmmMzdGFXAQQEdtKud0Fsw2iQV+sryX2rfM=; b=Mt+5bKZGXlb1o3Mdm103Es4bx+sPAR6h13bAS2ToPCiz70zPtS+5KrUDZSBf5naEjGg7yd XxOgXSKRLgV8esCg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1716195990; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PS5ewSnQPmmMzdGFXAQQEdtKud0Fsw2iQV+sryX2rfM=; b=ACvA1f4hWC3e2NAIXNtDmA50vg86wSXtvsQzk0ZuyOLx6wOqkG804BZx+XfGf3q1hBwzeH 7QuIiNRueA8M9Fw89RjBpF6HtMgx+Hng4yCz5gUxJemAH/tRJqhAvDZ9RpRuPrQZJvRDLo 8hico5zTH4H9wrTDy/wTEtoeqKJ9Wi5+9YjR+1atG0mEedDRdvw3OWDSXFoUcEgqaRdWh7 3bugXvPkGu5uahjGeEj5yb8Vm9Ts29V1FFaodFd8xXqLeiXo9JO9mrVDyo6TIJpkiyN4Ty FzsPYryE1UCTLRbxp+E2xDCwz9OfuXaVIlCTeq6c3vHlABx7LKGD3Q6gRkUvRA== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 04/21] tests/lib.sh: Add check if variable exists to test_that_key_in_arry_has_value Date: Mon, 20 May 2024 11:05:54 +0200 Message-Id: <20240520090611.10406-5-jonatan.schlag@ipfire.org> In-Reply-To: <20240520090611.10406-1-jonatan.schlag@ipfire.org> References: <20240520090611.10406-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: EWVBU2ANEBTHUGKGMLJD2GN2BTWGNYDM X-Message-ID-Hash: EWVBU2ANEBTHUGKGMLJD2GN2BTWGNYDM X-MailFrom: jonatan.schlag@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Jonatan Schlag --- tests/lib.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/lib.sh b/tests/lib.sh index c51257e79..373b7c3a0 100644 --- a/tests/lib.sh +++ b/tests/lib.sh @@ -24,6 +24,11 @@ test_that_key_in_arry_has_value() { local key="${2}" local value="${3}" + if [[ ! -v "${array}" ]]; then + echo -e "${CLR_RED_BG}Test failed: The array '${1}' does not exists. The variable is not set.${CLR_RESET}'" + return 1 + fi + if [[ "${array[${key}]}" == "${value}" ]] ; then echo -e "${CLR_GREEN_BG}Test succeded: The array '${1}' contains the value '${value}' under the key '${key}' ${CLR_RESET}" return 0 From patchwork Mon May 20 09:05:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7790 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4VjWsD3tScz3wxG for ; Mon, 20 May 2024 09:06:40 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4VjWs56l9Dz5SL; Mon, 20 May 2024 09:06:33 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VjWs56F4Wz2y2N; Mon, 20 May 2024 09:06:33 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4VjWs26ck8z32W4 for ; Mon, 20 May 2024 09:06:30 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4VjWs25Wwwz5N; Mon, 20 May 2024 09:06:30 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1716195990; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y5gQGNaZtz62TkBCGRwC52MNt+LvBpy3hohL27Nx8HU=; b=HaYjiOPHsNHA8HGGdCOmkt+4DL25yTXm+C4DIN3is0MV4BgCaI82pLsI392UOvRjR2Hynk 4jOBj1vbTG7aNUBQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1716195990; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y5gQGNaZtz62TkBCGRwC52MNt+LvBpy3hohL27Nx8HU=; b=ZJi7tAeMiOtYDT72o/UXrJ8k8JfETeGH1dZmxHu9HU5PDtRxjofEDqdTVMzyeWCqScaPVW UUMHBGIx5Bb7LIRGqEvP+3OdF9580SizvPholi4cZuxfAbO7s3Cs1cciMd68jZykkCK7lx Wdge1FI+FiIUrbM73U4vCppuC68wJuczIyG2axhwPKnwjhNeI536iXT8XBD+2d4IPy/Pi9 +cU1wNfiYrgJH7pLYncKbKXGhn832uSYoMY6UXYvjrnxQOO5ZW1uxhWpF7gA7a2OEwN8dv b4CX22Kkuk0s9b1oX9ciW56OM0fm34OH6K2dz5gk8Hnvp56WZ9HPv4rTxi59Jg== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 05/21] tests/lib.sh: Add logging functions Date: Mon, 20 May 2024 11:05:55 +0200 Message-Id: <20240520090611.10406-6-jonatan.schlag@ipfire.org> In-Reply-To: <20240520090611.10406-1-jonatan.schlag@ipfire.org> References: <20240520090611.10406-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: TSCJNDTTSFRBBQXRV5TO4BEOWFXYTKST X-Message-ID-Hash: TSCJNDTTSFRBBQXRV5TO4BEOWFXYTKST X-MailFrom: jonatan.schlag@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: So we can change the style of our log messages better. Signed-off-by: Jonatan Schlag --- tests/lib.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/lib.sh b/tests/lib.sh index 373b7c3a0..6483c41c3 100644 --- a/tests/lib.sh +++ b/tests/lib.sh @@ -4,13 +4,21 @@ LIB_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" . ${LIB_DIR}/lib_color.sh +log_test_failed(){ + echo -e "${CLR_RED_BG}Test failed: ${*}${CLR_RESET}'" +} + +log_test_succeded(){ + echo -e "${CLR_GREEN_BG}Test succeded: ${*}${CLR_RESET}" +} + test_that() { if ! "$@" ; then - echo -e "${CLR_RED_BG} Test failed: ${*} ${CLR_RESET}" + log_test_failed "${*}" return 1 else - echo -e "${CLR_GREEN_BG} Test succeded: ${*} ${CLR_RESET}" + log_test_succeded "${*}" return 0 fi } @@ -25,15 +33,15 @@ test_that_key_in_arry_has_value() { local value="${3}" if [[ ! -v "${array}" ]]; then - echo -e "${CLR_RED_BG}Test failed: The array '${1}' does not exists. The variable is not set.${CLR_RESET}'" + log_test_failed "The array '${1}' does not exists. The variable is not set." return 1 fi if [[ "${array[${key}]}" == "${value}" ]] ; then - echo -e "${CLR_GREEN_BG}Test succeded: The array '${1}' contains the value '${value}' under the key '${key}' ${CLR_RESET}" + log_test_succeded "The array '${1}' contains the value '${value}' under the key '${key}'" return 0 else - echo -e "${CLR_RED_BG}Test failed: The array '${1}' contains the value '${array[${key}]}' under the key '${key} and not '${value}' ${CLR_RESET}" + log_test_failed "The array '${1}' contains the value '${array[${key}]}' under the key '${key} and not '${value}'" return 1 fi } From patchwork Mon May 20 09:05:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7791 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4VjWsJ6DJ5z3wxG for ; Mon, 20 May 2024 09:06:44 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4VjWs719F9z5Vc; Mon, 20 May 2024 09:06:35 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VjWs70f3Dz2y2N; Mon, 20 May 2024 09:06:35 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4VjWs34RwLz32W4 for ; Mon, 20 May 2024 09:06:31 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4VjWs32wlMz2PV; Mon, 20 May 2024 09:06:31 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1716195991; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GXI8D9EOOui1ENNHRkLFTd0a1uOGQo16xTUL4KaXStM=; b=anpWhLLqF/kT2jOcDEtFuiqRnCwA5iaru2IWY3/lx6H5Boe4NneBrTgLkACwb4gLCiINDo dkBRE1wEQCGDByCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1716195991; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GXI8D9EOOui1ENNHRkLFTd0a1uOGQo16xTUL4KaXStM=; b=b6EFJ5YA/3YXrne1U35lyGnj3h8N5kbP6+j1e+n0JMWV3VpxYtvJuRssab6OkZREQ6gMQS uJb9voAhZacDGGSzHwSmD3opzqOBGv9aeSNx6vR7zMci5VpSmOaFTfKwaI+mYnjHnWXgYU qmOaqhKMqGluMKhht+othSSSfrMKi1DFeF8T8SRzQnngddedzDm+X0W8xC4ypFsTJ/+x1g Yo6SGZvejssIgscrIMPD9uzQbRRVJp+ZvTLvD8WNnDJuwxgOwMn8ss/C5J9sEk+qEbiVd7 TX9MDRbkUU6yR/Ig1tqFbCRR+01jdDVaRifVh2GgfrXdK6V+J6v3jqXDYo7T2w== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 06/21] tests/lib.sh: adjust to pytest logging style Date: Mon, 20 May 2024 11:05:56 +0200 Message-Id: <20240520090611.10406-7-jonatan.schlag@ipfire.org> In-Reply-To: <20240520090611.10406-1-jonatan.schlag@ipfire.org> References: <20240520090611.10406-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: GSXLZ3P6S7FLDOJNSPQVJNBRN5XGJEAZ X-Message-ID-Hash: GSXLZ3P6S7FLDOJNSPQVJNBRN5XGJEAZ X-MailFrom: jonatan.schlag@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Black on white is still the best to read. So we only style FAILED or PASSED in green or red. Signed-off-by: Jonatan Schlag --- tests/lib.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/lib.sh b/tests/lib.sh index 6483c41c3..079755410 100644 --- a/tests/lib.sh +++ b/tests/lib.sh @@ -5,11 +5,11 @@ LIB_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" . ${LIB_DIR}/lib_color.sh log_test_failed(){ - echo -e "${CLR_RED_BG}Test failed: ${*}${CLR_RESET}'" + echo -e "${CLR_RED_R}FAILED:${CLR_RESET} ${*}" } log_test_succeded(){ - echo -e "${CLR_GREEN_BG}Test succeded: ${*}${CLR_RESET}" + echo -e "${CLR_GREEN_R}PASSED:${CLR_RESET} ${*}" } test_that() { From patchwork Mon May 20 09:05:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7792 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4VjWsS4dxwz3wxG for ; Mon, 20 May 2024 09:06:52 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4VjWsB3CkPz5mj; Mon, 20 May 2024 09:06:38 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VjWs82DbSz337C; Mon, 20 May 2024 09:06:36 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4VjWs429kcz32W4 for ; Mon, 20 May 2024 09:06:32 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4VjWs401sPz5XX; Mon, 20 May 2024 09:06:31 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1716195992; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FIgGoulRE2LCqq6Rfb6zbtqk/V7YdU+tbS8NXmQVEac=; b=X1YxTHIcHfJUTDC18eBiWZ8qDY3WLFzjlCopJPahldlveR3UrYJkwdVmMaiqiqU6Tys92N EGepM5826wtrKLAA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1716195992; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FIgGoulRE2LCqq6Rfb6zbtqk/V7YdU+tbS8NXmQVEac=; b=QOIJ/gG5C/Cp0ugxcMJrmMpGunBgVu4hAeh+n0O2HcBRiZGkpfB+flut/67j+wEY9FrkOM zSNH+lbm426OUVy5Tc5eNj5v3d0W5fkS1hcTd3Y17fV/Sa8MR6281z6mnTc3W7+dhHmda6 qMGXRhMffDPpjVfK+dvcDNMgP3W9sRWA8CBkT0iuOqMkrofhcf1qWmjAykNwqpzE13ehrY +RT4/grjQrDbl0iswskuCbPPGupBd+4NlSVnIO3IEwCy8nk5vZANSz8Cu/SW0HhMPGlyOr ey10N3qq8jPlALELHDBU9xIbmC03i0713uDzoNjz8vMMTbi6FIiy3MSNtMU4KA== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 07/21] tests/lib.sh: Fix check if array is defined Date: Mon, 20 May 2024 11:05:57 +0200 Message-Id: <20240520090611.10406-8-jonatan.schlag@ipfire.org> In-Reply-To: <20240520090611.10406-1-jonatan.schlag@ipfire.org> References: <20240520090611.10406-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: VOE6M2VS6PGXVGDCAXHCAGMYA4PG6MM5 X-Message-ID-Hash: VOE6M2VS6PGXVGDCAXHCAGMYA4PG6MM5 X-MailFrom: jonatan.schlag@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: -v does a bad job here. We need to use declare here. Signed-off-by: Jonatan Schlag --- tests/lib.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/lib.sh b/tests/lib.sh index 079755410..0f4de8e43 100644 --- a/tests/lib.sh +++ b/tests/lib.sh @@ -29,10 +29,11 @@ var_has_value() { test_that_key_in_arry_has_value() { local array="${!1}" + local arrayname="${1}" local key="${2}" local value="${3}" - if [[ ! -v "${array}" ]]; then + if [[ ! "$(declare -p "${arrayname}")" =~ "declare -a" && ! "$(declare -p "${arrayname}")" =~ "declare -A" ]]; then log_test_failed "The array '${1}' does not exists. The variable is not set." return 1 fi From patchwork Mon May 20 09:05:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7796 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4VjWsl4VTxz3wxb for ; Mon, 20 May 2024 09:07:07 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4VjWsD3wdhz5mp; Mon, 20 May 2024 09:06:40 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VjWs940vsz32W4; Mon, 20 May 2024 09:06:37 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4VjWs45MZVz336n for ; Mon, 20 May 2024 09:06:32 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4VjWs446F8zXy; Mon, 20 May 2024 09:06:32 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1716195992; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IQ/Q9zie4WzrX6Gq+BJ5PDVlpD/BiLh6rOaudaSgPZU=; b=ZT5AHZcVWSnzHUZWzrsRFPWpMHIqG1BeVbuYEuxsHsOTGy5LuZ2Orb3fWKmcXLh4NLxyO3 ZjNXSG0MKoKRRQBA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1716195992; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IQ/Q9zie4WzrX6Gq+BJ5PDVlpD/BiLh6rOaudaSgPZU=; b=AAo+dor8lw5FHztszGZHlmtla9jgALwUpeiV/JAfTDqZEROQlbK1+tu1XJCaC4JPqaR2xX KIalBOrbJX9acFTYHKBlbHUWi20aQjz9lj5T+c4SybuxmBFCR1ftHh3ZWEpNUrpmY8C0K/ l6z9zQIp8MqBEWj5+mh3vynz8auLo5aFY7rVvS3KBjTEGTRq70p+BgnZVLMpDn7S86uRzx np/VKLtl60hwN+GrM5+qYHNsYAbhh25pVNqMk/EXMjDnxbwSrwc3OeNW7ESSmOPnXTDCl6 AH1OQHNEpdDyjS0vnGmMptCT9Y7ESBRZ+jNMvsV9If1TSct6syNF0Hgcse8Pdg== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 08/21] test_that_key_in_arry_has_value: Check if the key is defined Date: Mon, 20 May 2024 11:05:58 +0200 Message-Id: <20240520090611.10406-9-jonatan.schlag@ipfire.org> In-Reply-To: <20240520090611.10406-1-jonatan.schlag@ipfire.org> References: <20240520090611.10406-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: 5TO7GSIDFKOEPJ37LNLS6LZ7NGWILJWW X-Message-ID-Hash: 5TO7GSIDFKOEPJ37LNLS6LZ7NGWILJWW X-MailFrom: jonatan.schlag@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Jonatan Schlag --- tests/lib.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/lib.sh b/tests/lib.sh index 0f4de8e43..006862da6 100644 --- a/tests/lib.sh +++ b/tests/lib.sh @@ -38,6 +38,11 @@ test_that_key_in_arry_has_value() { return 1 fi + if [[ ! -v "${array[${key}]}" ]]; then + log_test_failed "The array does not contain the key '${key}', valid keys are: ${!array[*]}" + return 1 + fi + if [[ "${array[${key}]}" == "${value}" ]] ; then log_test_succeded "The array '${1}' contains the value '${value}' under the key '${key}'" return 0 From patchwork Mon May 20 09:05:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7795 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4VjWsl4Q1Wz3wxV for ; Mon, 20 May 2024 09:07:07 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4VjWsG0rVhz5nP; Mon, 20 May 2024 09:06:42 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VjWs95VPKz3370; Mon, 20 May 2024 09:06:37 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4VjWs53bs0z336Z for ; Mon, 20 May 2024 09:06:33 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4VjWs50sBDz5j3; Mon, 20 May 2024 09:06:33 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1716195993; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yNYZXEcIvro0vPwGX/GzaGbTkXh1bp2gxD3bnUWKcjs=; b=HbGYhikmqBRfNEzD4PwVlani3j2GkWlEXvLZiKO4FvNbFtHuPFKQmeRJC6BLBVWyf+GzLF g3cYXngRyMcMDLDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1716195993; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yNYZXEcIvro0vPwGX/GzaGbTkXh1bp2gxD3bnUWKcjs=; b=afCf8POJ44SK8qZp2txF0e//T0hy7c/msidZTiCUU6vmsA1HXMzjuP9+UtHpdi/6vhQEj1 qtYABPGlyVfC1YCKdSCxT5tBDB/vqpmUfyZ7k7RbZc646j72pWsz+xs0wuRNUtQQRXlJxs NMhRCtJuBg8K1va+5bhPJzmt7jXhIHBRSnmMaQ+ZkM/FBCBhg5uzOO6xK+wLNSe6G1hFYp G4toJ7WM6HFeQCSS4zz5xA5y4rlX2zLAAGaVTF3siuMpvjoP2uwumrhcE/t7fqR3oSFpfX r1sG09m8dATNf6VzdmMHOHx7alEyf2JrFjeDWCwCIZ4csCmisKmmLiEQgNSyew== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 09/21] tests/lib.sh: Use namref to access an array Date: Mon, 20 May 2024 11:05:59 +0200 Message-Id: <20240520090611.10406-10-jonatan.schlag@ipfire.org> In-Reply-To: <20240520090611.10406-1-jonatan.schlag@ipfire.org> References: <20240520090611.10406-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: 6VU6GFXR5F3SCBRHK25V2LM3EQIN6K3Z X-Message-ID-Hash: 6VU6GFXR5F3SCBRHK25V2LM3EQIN6K3Z X-MailFrom: jonatan.schlag@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: ! does not work here. So the solution here is: https://unix.stackexchange.com/questions/60584/how-to-use-a-variable-as-part-of-an-array-name/60585#60585 Signed-off-by: Jonatan Schlag --- tests/lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lib.sh b/tests/lib.sh index 006862da6..ad7c12cb0 100644 --- a/tests/lib.sh +++ b/tests/lib.sh @@ -28,7 +28,7 @@ var_has_value() { } test_that_key_in_arry_has_value() { - local array="${!1}" + local -n array="${1}" local arrayname="${1}" local key="${2}" local value="${3}" From patchwork Mon May 20 09:06:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7793 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4VjWsk1cjYz3wxG for ; Mon, 20 May 2024 09:07:06 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4VjWsJ5x7Nz5nX; Mon, 20 May 2024 09:06:44 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VjWsC0Twsz32xd; Mon, 20 May 2024 09:06:39 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4VjWs61kGhz2y2N for ; Mon, 20 May 2024 09:06:34 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4VjWs60FwXz5gZ; Mon, 20 May 2024 09:06:34 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1716195994; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1MfYgFu3R7m99FRB/IhbCZ/LsnAPiSQDA9IWq9R/wy4=; b=zeqzlD3Api9karDw2YFHblITRhxdptFwAqG4JFplqCRNVuvVJwc7/Ykx7OoqmYWz5Y7cy3 YVPG0TQ0wJwLk4Cw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1716195994; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1MfYgFu3R7m99FRB/IhbCZ/LsnAPiSQDA9IWq9R/wy4=; b=byIeNShfqkZjPJ5iflNjXmmKnk11s+BhBm/A+0unyG0rvOUtTAkJIcKvqKZIYPzHaYHiy9 1nzLt+apzpcZAoSM5zh8A5G6C2oAAkSWwHLwfx5qQIdtGHiCusxIJ9rgUv9SJJ+GOJw3So 2+doXoPrcFS4AprFnwLAvYmW9VphQJ4BhLNve8TCAFlZiWpan9QGwwgQL4QNpVXZ/gT47H R0IIBWLtW1kfdKIgMtavb3jG5PcysIofmf7pONJ/0y8DWnNjzVrb3w4bH0Ob2QBFlyf9Wm p89u3zu8wUPSwJ28incWtJVi4OTvj/rFlhQajQ7qMLbmPxH0vRekmqVbpqq8pQ== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 10/21] test_that_key_in_arry_has_value: Check if a key in an array exists Date: Mon, 20 May 2024 11:06:00 +0200 Message-Id: <20240520090611.10406-11-jonatan.schlag@ipfire.org> In-Reply-To: <20240520090611.10406-1-jonatan.schlag@ipfire.org> References: <20240520090611.10406-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: 3DRWKOQYJDAGRCVW5QJ7ZQ56TNX6VUC3 X-Message-ID-Hash: 3DRWKOQYJDAGRCVW5QJ7ZQ56TNX6VUC3 X-MailFrom: jonatan.schlag@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Jonatan Schlag --- tests/lib.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/lib.sh b/tests/lib.sh index ad7c12cb0..81bc1439c 100644 --- a/tests/lib.sh +++ b/tests/lib.sh @@ -38,7 +38,8 @@ test_that_key_in_arry_has_value() { return 1 fi - if [[ ! -v "${array[${key}]}" ]]; then + + if [[ "${array["${key}"]+_}" == "" ]]; then log_test_failed "The array does not contain the key '${key}', valid keys are: ${!array[*]}" return 1 fi From patchwork Mon May 20 09:06:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7794 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4VjWsl3FlQz3wxG for ; Mon, 20 May 2024 09:07:07 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4VjWsK20zLz5nc; Mon, 20 May 2024 09:06:45 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VjWsD2zxbz32w8; Mon, 20 May 2024 09:06:40 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4VjWs7047yz2y2N for ; Mon, 20 May 2024 09:06:35 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4VjWs653nVz5Vc; Mon, 20 May 2024 09:06:34 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1716195994; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mkZVoRNioq/xi0W7v5J0OjAM0HFuWW2D2tPl7mzCZtE=; b=+gusQnt7rsUGyvL6km5cEXLsUBAA4KOIxX1riLiOeXxBI9xghWCyr/5gFBcS08WESr+XV3 tpBtB7ti0tNBATBg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1716195994; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mkZVoRNioq/xi0W7v5J0OjAM0HFuWW2D2tPl7mzCZtE=; b=kaAUMJhm0FVEXYPh+jSVhL74+zSZu/VL020ZY1Ghez08UWXdHz8DBRsC6xtRhoFWrAjuHJ aa/C7z5l1oOcNLK2ay8Vzh47BLsaCchM144FqnbZ1JqSBOf4AuHAG29DPYOJBkrfAClR2m i/CaLSA2CtES8aHRttV+K+sTGirru4MW/hFJVdPXn8ZTalg1TBI4ABmGhMxeHqENMoBSLj pVxfYYRVfDLwbaSQHLRKQ2SVVnbKLvgC81vDanx3mHSDVTFAzdePA2ivd5o4Er2NQzZe9f qI9ZwfH7Hv1HFXbzAEooNXZDAbYXOznslcS2F4oWUK4b6KrZ2eNUq4Hgai4XqQ== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 11/21] tests: Add function to test the ouput of a bash function Date: Mon, 20 May 2024 11:06:01 +0200 Message-Id: <20240520090611.10406-12-jonatan.schlag@ipfire.org> In-Reply-To: <20240520090611.10406-1-jonatan.schlag@ipfire.org> References: <20240520090611.10406-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: 2BXAQHMNS5ZAGEJ5OKRNQ3NC4R2R4C76 X-Message-ID-Hash: 2BXAQHMNS5ZAGEJ5OKRNQ3NC4R2R4C76 X-MailFrom: jonatan.schlag@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Jonatan Schlag --- tests/lib.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/lib.sh b/tests/lib.sh index 81bc1439c..9ce0201b1 100644 --- a/tests/lib.sh +++ b/tests/lib.sh @@ -52,3 +52,32 @@ test_that_key_in_arry_has_value() { return 1 fi } + +test_that_output_is(){ + local reference_output_file="${1}" + local file_descriptor="${2}" + shift + shift + + local command="$@" + + local temp="$(mktemp)" + + case "${file_descriptor}" in + "stdout"|"1") + $command 1> "${temp}" 2>/dev/null + ;; + "stderr"|"2") + $command 2> "${temp}" 1>/dev/null + ;; + esac + + if diff -u "${temp}" "${reference_output_file}" &> /dev/null; then + log_test_succeded "The output of command '${command}' on file descriptor '${file_descriptor}' is equal to the reference output." + else + log_test_failed "The output of command '${command}' on file descriptor '${file_descriptor}' is unequal to the reference output." + diff -u --color "${reference_output_file}" "${temp}" + fi + + rm "${temp}" +} From patchwork Mon May 20 09:06:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7797 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4VjWsm1V5Mz3x0S for ; Mon, 20 May 2024 09:07:08 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4VjWsQ6RSbz5nl; Mon, 20 May 2024 09:06:50 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VjWsD4rplz337d; Mon, 20 May 2024 09:06:40 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4VjWs75H4gz32w8 for ; Mon, 20 May 2024 09:06:35 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4VjWs72gRYz5mn; Mon, 20 May 2024 09:06:35 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1716195995; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vmXyHDMJx/m5wyBkFJgPJsJ5w5WbrErOioTztTxF8AM=; b=YKsO21FHFM6pauhFvFgVIDfiaDQTL+iqDOa+BboC9zXdqyyv28w4pkH4JZxoL4+m5IOktM rb4Busvug+mXxODg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1716195995; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vmXyHDMJx/m5wyBkFJgPJsJ5w5WbrErOioTztTxF8AM=; b=sZ09kme8lIwFYb7n4czodnscAA+i+vY01YjQU4YVX4EO3Pray6hEFgGxDyjUXItmAnHWZ/ 5wtW6s4hpW+mHNp4biv5tXbqvtwGAepSk5k5jL+PSZml8HFrgZOekDE6t0tkSS/vXsfTBw ds7Sg5cyOWjKfe447N0Ez7CZx8d2ZNPHQkG+EWVP+VgrejycN3goHAPvMkyrC+TExEHZvD fjQrMpfP0UEiy7X4SKHa758kxtl4TqoQu74Z2bebpEtUBO9LZ2vYPW4J/NtLbY4y+2VeGJ o9/SxYlVnk6WC5k5qgq/59/4a+PrCWUC+flzrNQ8mkcHeTK99g7279RQMdwmyg== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 12/21] initscript functions: add readhash Date: Mon, 20 May 2024 11:06:02 +0200 Message-Id: <20240520090611.10406-13-jonatan.schlag@ipfire.org> In-Reply-To: <20240520090611.10406-1-jonatan.schlag@ipfire.org> References: <20240520090611.10406-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: YZH2BSTE7MXTGNPEZLVRM2XHHKRGSIY2 X-Message-ID-Hash: YZH2BSTE7MXTGNPEZLVRM2XHHKRGSIY2 X-MailFrom: jonatan.schlag@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: To avoid the usage of eval and to store the config in an key value array, we introduce an new function. The tests only check if we read the correct value to the correct variable. One comment on the implementation as this has created some headache: >From https://www.gnu.org/software/bash/manual/bash.html#Bourne-Shell-Builtins "When used in a function, declare makes each name local, as with the local command, unless the -g option is used." So we need to use -g here Signed-off-by: Jonatan Schlag --- src/initscripts/system/functions | 15 +++++++++++++++ tests/src/initscripts/system/functions/data/1 | 17 +++++++++++++++++ tests/src/initscripts/system/functions/test.sh | 16 ++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 tests/src/initscripts/system/functions/data/1 create mode 100755 tests/src/initscripts/system/functions/test.sh diff --git a/src/initscripts/system/functions b/src/initscripts/system/functions index b610143ab..44ce999d3 100644 --- a/src/initscripts/system/functions +++ b/src/initscripts/system/functions @@ -891,3 +891,18 @@ volume_fs_type() { stat -f --format="%T" ${1} } + +readhash() { + local array="${1}" + local file="${2}" + + declare -A -g "${array}" + + local line + while read -r line; do + local key="${line%=*}" + local val="${line#*=}" + + printf -v "${array}[${key}]" "%s" "${val}" + done < "${file}" +} diff --git a/tests/src/initscripts/system/functions/data/1 b/tests/src/initscripts/system/functions/data/1 new file mode 100644 index 000000000..8aca9422b --- /dev/null +++ b/tests/src/initscripts/system/functions/data/1 @@ -0,0 +1,17 @@ +CONFIG_TYPE=3 +GREEN_DEV=green0 +GREEN_MACADDR=00:c0:08:8a:a0:47 +GREEN_DRIVER=r8175 +RED_DEV=red0 +RED_MACADDR=00:c0:08:8a:a0:56 +RED_DRIVER=r8283 +BLUE_DEV='blue0 net0' +BLUE_MACADDR=bc:30:7d:58:6b:e3 +BLUE_DRIVER=rt2800 +RED_DHCP_HOSTNAME=ipfire +RED_DHCP_FORCE_MTU= +RED_ADDRESS=0.0.0.0 +RED_NETMASK=0.0.0.0 +RED_TYPE=PPPOE +RED_NETADDRESS=0.0.0.0 + diff --git a/tests/src/initscripts/system/functions/test.sh b/tests/src/initscripts/system/functions/test.sh new file mode 100755 index 000000000..ec502e199 --- /dev/null +++ b/tests/src/initscripts/system/functions/test.sh @@ -0,0 +1,16 @@ +#!/usr/bin/bash + +SCRIPT_PATH="$(dirname "$(readlink -f "$0")")" + +ROOT="$(readlink -f "${SCRIPT_PATH}/../../../../..")" + +. ${ROOT}/tests/lib.sh + +. ${ROOT}/src/initscripts/system/functions + +# read the date in +readhash "CONFIG" "${SCRIPT_PATH}/data/1" + +# test if we read the correct data +test_that_key_in_arry_has_value "CONFIG" "RED_DHCP_HOSTNAME" "ipfire" +test_that_key_in_arry_has_value "CONFIG" "BLUE_MACADDR" "bc:30:7d:58:6b:e3" From patchwork Mon May 20 09:06:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7800 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4VjWsp5YYsz3wxb for ; Mon, 20 May 2024 09:07:10 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4VjWsl3YmXzcS; Mon, 20 May 2024 09:07:07 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VjWsG6b21z336Z; Mon, 20 May 2024 09:06:42 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4VjWsD0w1kz2y2N for ; Mon, 20 May 2024 09:06:40 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4VjWs809GMz15J; Mon, 20 May 2024 09:06:36 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1716195996; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uISKL2l3A/kw68nYfY/vcC6+uwO13p2Wl0Fl+9foNfY=; b=1GVV/Do+SODGwq/ppbrkYpPE9qTs4sxVVnhhOBqmb3PbxwD3SGw28NoQ9XY6BoWb4ZRMqc NtVrHvJV8OLXSmCw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1716195996; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uISKL2l3A/kw68nYfY/vcC6+uwO13p2Wl0Fl+9foNfY=; b=DwjD2Oh92fzw8IMomqFlaw4oM3rkKyE+LnDQJhEaQC7+lPciPhLXfP9lnLnyENPTsMCrIU rZ+r5y2+fp7UOwjLqRk2hMcMPo2u86TiBY2uxksCBCBuicha/SMopVpfjQ/x387R1ddHDS rUV5K33VGK1tdJmsLKl5DRJ57YSeK1iTV7+jwFzK9fSY3Fxj9UZpv8zbVXLfza46UJunTd kk6NvE9McDnd6px6IccYd0uL0stLM/D7euoXchx/p1bRNNVxM5WDug6RujgMWhUl7VspBW yYh6ZhotJ7v8qdfkMFwFelOM8qCaNjWyRpkCICcbUGtlkZW090rgQDB22cX9Lw== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 13/21] initscript fkt: ignore blank lines in readhash Date: Mon, 20 May 2024 11:06:03 +0200 Message-Id: <20240520090611.10406-14-jonatan.schlag@ipfire.org> In-Reply-To: <20240520090611.10406-1-jonatan.schlag@ipfire.org> References: <20240520090611.10406-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: EIG65NEJFURIB22DSFD6CHORST7NPUHK X-Message-ID-Hash: EIG65NEJFURIB22DSFD6CHORST7NPUHK X-MailFrom: jonatan.schlag@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Jonatan Schlag --- src/initscripts/system/functions | 6 ++++++ tests/src/initscripts/system/functions/data/1_output_stderr | 0 tests/src/initscripts/system/functions/data/1_output_stdout | 0 tests/src/initscripts/system/functions/test.sh | 3 +++ 4 files changed, 9 insertions(+) create mode 100644 tests/src/initscripts/system/functions/data/1_output_stderr create mode 100644 tests/src/initscripts/system/functions/data/1_output_stdout diff --git a/src/initscripts/system/functions b/src/initscripts/system/functions index 44ce999d3..3f01be9e0 100644 --- a/src/initscripts/system/functions +++ b/src/initscripts/system/functions @@ -900,6 +900,12 @@ readhash() { local line while read -r line; do + + # Skip Blank Lines + if [[ ${line} =~ ^[[:space:]]*$ ]]; then + continue + fi + local key="${line%=*}" local val="${line#*=}" diff --git a/tests/src/initscripts/system/functions/data/1_output_stderr b/tests/src/initscripts/system/functions/data/1_output_stderr new file mode 100644 index 000000000..e69de29bb diff --git a/tests/src/initscripts/system/functions/data/1_output_stdout b/tests/src/initscripts/system/functions/data/1_output_stdout new file mode 100644 index 000000000..e69de29bb diff --git a/tests/src/initscripts/system/functions/test.sh b/tests/src/initscripts/system/functions/test.sh index ec502e199..8d644b8cd 100755 --- a/tests/src/initscripts/system/functions/test.sh +++ b/tests/src/initscripts/system/functions/test.sh @@ -14,3 +14,6 @@ readhash "CONFIG" "${SCRIPT_PATH}/data/1" # test if we read the correct data test_that_key_in_arry_has_value "CONFIG" "RED_DHCP_HOSTNAME" "ipfire" test_that_key_in_arry_has_value "CONFIG" "BLUE_MACADDR" "bc:30:7d:58:6b:e3" + +test_that_output_is "${SCRIPT_PATH}/data/1_output_stdout" "1" readhash "CONFIG" "${SCRIPT_PATH}/data/1" +test_that_output_is "${SCRIPT_PATH}/data/1_output_stderr" "2" readhash "CONFIG" "${SCRIPT_PATH}/data/1" From patchwork Mon May 20 09:06:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7799 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4VjWsp1Qvjz3wxV for ; Mon, 20 May 2024 09:07:10 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4VjWsl3szNz5nT; Mon, 20 May 2024 09:07:07 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VjWsJ1HZXz337G; Mon, 20 May 2024 09:06:44 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4VjWsD3tThz337G for ; Mon, 20 May 2024 09:06:40 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4VjWs84y0gz5gj; Mon, 20 May 2024 09:06:36 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1716195996; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5J65laUWy5/ZbKGuZsh5kQkkhXttJoe8CfjybmBJvng=; b=FhxhD9zloCPW0vKEWdx3FHAP1ItCQB2k4TjvnVFl12+8fwMoMsd0ArBpKo1pgKuzYGZhod nqifsrZtaD9R/OCQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1716195996; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5J65laUWy5/ZbKGuZsh5kQkkhXttJoe8CfjybmBJvng=; b=Xq7OmCdKDkJnBfgvAuksJYNSzrNCLBsOz7fusn15G3WeRDBIMS0oKJG1W5Xf9kEVAM3Qlc aDkPy2iz1lXE7CGlQCidmXbAjVVKk4kmZMv29YtqxR20oSGqjUTCQ7uq20+4bJn/BQqSUl eKGmxNYtWYGS5774EVLb41dHaccJfXpYj3agSw/ntcCj9W6TUDEbHp3mvIXKcS1VKPHaIc o/AFGZsBN03V/TiIpdXGoN+PEN7FQRM7RkjdI+55mYovfJ8Z4rnu4ktfS9YaYXG1iFrgba nNsDFnDU/dbmDtyQQMXXN8s5+kv5ddV6UrfcDyG5HJ1hIZeXaCRGbKapX9Zh+A== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 14/21] test: Add functions test_that_array_is_defined Date: Mon, 20 May 2024 11:06:04 +0200 Message-Id: <20240520090611.10406-15-jonatan.schlag@ipfire.org> In-Reply-To: <20240520090611.10406-1-jonatan.schlag@ipfire.org> References: <20240520090611.10406-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: FPIGW65IVG2EAS5Q6NJKJV4MJV3VJIVK X-Message-ID-Hash: FPIGW65IVG2EAS5Q6NJKJV4MJV3VJIVK X-MailFrom: jonatan.schlag@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: we need this check in multiple places so it makes sense to move this to a separate function. Signed-off-by: Jonatan Schlag --- tests/lib.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/lib.sh b/tests/lib.sh index 9ce0201b1..29f4e3b71 100644 --- a/tests/lib.sh +++ b/tests/lib.sh @@ -27,17 +27,25 @@ var_has_value() { [[ "${!1}" == "${2}" ]] } -test_that_key_in_arry_has_value() { - local -n array="${1}" +test_that_array_is_defined() { local arrayname="${1}" - local key="${2}" - local value="${3}" if [[ ! "$(declare -p "${arrayname}")" =~ "declare -a" && ! "$(declare -p "${arrayname}")" =~ "declare -A" ]]; then log_test_failed "The array '${1}' does not exists. The variable is not set." return 1 + else + log_test_succeded "The array '${1}' is defined." + return 0 fi +} + +test_that_key_in_arry_has_value() { + local -n array="${1}" + local arrayname="${1}" + local key="${2}" + local value="${3}" + test_that_array_is_defined "${arrayname}" || return 1 if [[ "${array["${key}"]+_}" == "" ]]; then log_test_failed "The array does not contain the key '${key}', valid keys are: ${!array[*]}" From patchwork Mon May 20 09:06:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7798 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4VjWsm6Djzz3wxG for ; Mon, 20 May 2024 09:07:08 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4VjWsX3dNZz5gB; Mon, 20 May 2024 09:06:56 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VjWsJ3blKz3374; Mon, 20 May 2024 09:06:44 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4VjWsG1C7Cz2y2N for ; Mon, 20 May 2024 09:06:42 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4VjWsC1XHDz5N; Mon, 20 May 2024 09:06:39 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1716195999; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oyeu0SQsdW6glOrtO8h6e/8HKLwcXzXJvm+lAh9rnhE=; b=RrgqDhVSn4/qxU7H2ZjXRvp9nuzEiE5ibY8b7wmOBfZhgplRYyd0yvL+6QmpPPOwXKCBVZ OwnlQEySZ5FwjiDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1716195999; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oyeu0SQsdW6glOrtO8h6e/8HKLwcXzXJvm+lAh9rnhE=; b=F3xLewPO+ilqQoWcnUHYnZh335Mg3rI7A9qv8uPYcNBJQidlxjuQ4hRlYmrGYBKZx50l9d GsFzHbLQuP+f8Xw86UeSvC84k2tmwmx2KYbeoZo5oRJMdMX8+e8JgCOjQLdRlEaFhi1TMN 5fYhmbNaRUVndnYdkDX7QIqEFiXKY5fn9DndZnhoRojh0DVGqSOevC9Ovghae18+8+c11u UiCPOJ63hSLCo4NlUtZqnB/f4Der/Ac8XnYDcqzl47jfDQHcgy9CPU7bxSNhztIwk4uGr+ zHUQSciUNCM4pLLR7ArEN6vGL2eWhJ2NDCSAc3cKK1DdU6ZgTSSfr4ZOts3KTA== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 15/21] tests: Add functions test_that_array_doesnt_have_key Date: Mon, 20 May 2024 11:06:05 +0200 Message-Id: <20240520090611.10406-16-jonatan.schlag@ipfire.org> In-Reply-To: <20240520090611.10406-1-jonatan.schlag@ipfire.org> References: <20240520090611.10406-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: 6BVJAHEHBYKJUMPFUVKAWBJQNOG4PL2Z X-Message-ID-Hash: 6BVJAHEHBYKJUMPFUVKAWBJQNOG4PL2Z X-MailFrom: jonatan.schlag@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Apparently we can set way more keys then I expected. So we need a function to check that we do not set certain key. Some keys need to be skipped. Signed-off-by: Jonatan Schlag --- tests/lib.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/lib.sh b/tests/lib.sh index 29f4e3b71..1eab92cf7 100644 --- a/tests/lib.sh +++ b/tests/lib.sh @@ -61,6 +61,24 @@ test_that_key_in_arry_has_value() { fi } +test_that_array_doesnt_have_key() { + local -n array="${1}" + local arrayname="${1}" + local key="${2}" + + test_that_array_is_defined "${arrayname}" || return 1 + + if [[ "${array["${key}"]+_}" == "_" ]]; then + log_test_failed "The array '${arrayname}' does contain the key '${key}'." + return 1 + else + log_test_succeded "The array '${arrayname}' does not contain the key '${key}'" + return 0 + fi + +} + + test_that_output_is(){ local reference_output_file="${1}" local file_descriptor="${2}" From patchwork Mon May 20 09:06:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7801 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4VjWsp73Tdz3x2Q for ; Mon, 20 May 2024 09:07:10 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4VjWsl4dnPz5md; Mon, 20 May 2024 09:07:07 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VjWsM5nXdz331V; Mon, 20 May 2024 09:06:47 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4VjWsJ6BcPz337R for ; Mon, 20 May 2024 09:06:44 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4VjWsF1Tfkz5gj; Mon, 20 May 2024 09:06:41 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1716196001; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i6xpAGoB9Lpek1RCNpKFbtR33sdrjPXLAMGVr7j0QsU=; b=TtfoHHsInHrv7LO5EaOzaNryZPqGxamLgaDNkXeYQ92fPRaQMzdqKuEXsguqNtFHJAtvpm E4vaenqVMpzxYmCg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1716196001; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i6xpAGoB9Lpek1RCNpKFbtR33sdrjPXLAMGVr7j0QsU=; b=jpHlJVyQZq6xWIix+4VsTaOTqxA6u3ur2CNUqdlJOoYizM7SZsEiLdv+ksVj1nR5SYdr9j voKhzKaSwgNbqPNPVBycTTqz9WixcNPjC2SovJcvM2bChNZ4fBSLCMd/vFq5P50jVyXFRj Q1SallHMLaomz0IK/9G8A+BB6jHEcrJdXq6Ss8AgVjneUmWykdXmbip5kXBpMEM8CvSpfy KrPXhiEumJcJhPEtnn2yn4A/4XmZla+JfcZ/IhX+ylHgbecMWLFzmwOYd31VvKnYf5kh8t 4TAG3kO2po+l6A32LQrPHTuOLeyae/GT9R/86IXyHAQJVEXOdOc8HNSmHsqBeg== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 16/21] initscripts fkt: Ignore comments in readhash Date: Mon, 20 May 2024 11:06:06 +0200 Message-Id: <20240520090611.10406-17-jonatan.schlag@ipfire.org> In-Reply-To: <20240520090611.10406-1-jonatan.schlag@ipfire.org> References: <20240520090611.10406-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: YHXVTABV5NHBT3S2UPFFU33C43KZMYPG X-Message-ID-Hash: YHXVTABV5NHBT3S2UPFFU33C43KZMYPG X-MailFrom: jonatan.schlag@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: As '#Another Comment' is a valid key we test this change by checking if the comments do not end up as keys in our array. Signed-off-by: Jonatan Schlag --- src/initscripts/system/functions | 5 +++++ tests/src/initscripts/system/functions/data/1 | 3 +++ tests/src/initscripts/system/functions/test.sh | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/src/initscripts/system/functions b/src/initscripts/system/functions index 3f01be9e0..6107463fc 100644 --- a/src/initscripts/system/functions +++ b/src/initscripts/system/functions @@ -906,6 +906,11 @@ readhash() { continue fi + # Skip Comments + if [[ ${line} =~ ^#.*$ ]]; then + continue + fi + local key="${line%=*}" local val="${line#*=}" diff --git a/tests/src/initscripts/system/functions/data/1 b/tests/src/initscripts/system/functions/data/1 index 8aca9422b..c75620b6b 100644 --- a/tests/src/initscripts/system/functions/data/1 +++ b/tests/src/initscripts/system/functions/data/1 @@ -5,6 +5,7 @@ GREEN_DRIVER=r8175 RED_DEV=red0 RED_MACADDR=00:c0:08:8a:a0:56 RED_DRIVER=r8283 +# Another Comment BLUE_DEV='blue0 net0' BLUE_MACADDR=bc:30:7d:58:6b:e3 BLUE_DRIVER=rt2800 @@ -15,3 +16,5 @@ RED_NETMASK=0.0.0.0 RED_TYPE=PPPOE RED_NETADDRESS=0.0.0.0 +# Comment for testing + # Comment for testing Comments with spaces before diff --git a/tests/src/initscripts/system/functions/test.sh b/tests/src/initscripts/system/functions/test.sh index 8d644b8cd..f1348a9e8 100755 --- a/tests/src/initscripts/system/functions/test.sh +++ b/tests/src/initscripts/system/functions/test.sh @@ -15,5 +15,11 @@ readhash "CONFIG" "${SCRIPT_PATH}/data/1" test_that_key_in_arry_has_value "CONFIG" "RED_DHCP_HOSTNAME" "ipfire" test_that_key_in_arry_has_value "CONFIG" "BLUE_MACADDR" "bc:30:7d:58:6b:e3" +# Test that comments are skipped +# apparently the way we read the file strips the whitespace, so the key does not contain any whitespace either +test_that_array_doesnt_have_key "CONFIG" "# Another Comment" +test_that_array_doesnt_have_key "CONFIG" "# Comment for testing" +test_that_array_doesnt_have_key "CONFIG" "# Comment for testing Comments with spaces before" + test_that_output_is "${SCRIPT_PATH}/data/1_output_stdout" "1" readhash "CONFIG" "${SCRIPT_PATH}/data/1" test_that_output_is "${SCRIPT_PATH}/data/1_output_stderr" "2" readhash "CONFIG" "${SCRIPT_PATH}/data/1" From patchwork Mon May 20 09:06:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7802 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4VjWsq4T4Wz3x0S for ; Mon, 20 May 2024 09:07:11 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4VjWsl6gytz19F; Mon, 20 May 2024 09:07:07 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VjWsN0G9fz336w; Mon, 20 May 2024 09:06:48 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4VjWsK21Qfz32xd for ; Mon, 20 May 2024 09:06:45 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4VjWsG0Z4pz5n2; Mon, 20 May 2024 09:06:42 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1716196002; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=amAJAI7GA6bRz9FeMwoo5ncLkRcc4Ie5GrNuhHsNjOI=; b=aKxncwS3J18gvJbs+73tboQ/jqXgK8B/RtmPzgingx6YpDRv+/gJCqfxrp01LT/56SFcPS M7P2e5SwtWMINWDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1716196002; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=amAJAI7GA6bRz9FeMwoo5ncLkRcc4Ie5GrNuhHsNjOI=; b=p4v5U8ozDa7xdHQy4r4H0RmNSTQyeVe27QyP5iYe89+eC7zvWUGjMDnsPJobqgUegKfXWM qP5GbvW227O9bGYIlaua6iaO2BuyoYk26clfl++mqkhAR1BVH45HCZf2xeLRa4bAA6yYHP 4FSu7u1PBfRwA/OUHaVGN8D6pEhVYB4O5MEFkt3E2wwk7LK63yFXcfItSkBefjc6p3S07Z MrG4s8FXnMftimRq9kV2Ussb9YnAIeJ5S12HPsNycc+lT1VGdJ3wM+psWUQphmroLLN/Fc 6V34H1mhpiD0nMEvsdKmdNfXVp2tpH3vGADMsplKdm/N9U6hrHgaKGzs4Y7ptQ== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 17/21] initscripts fkt: ignore invalid keys in readhash Date: Mon, 20 May 2024 11:06:07 +0200 Message-Id: <20240520090611.10406-18-jonatan.schlag@ipfire.org> In-Reply-To: <20240520090611.10406-1-jonatan.schlag@ipfire.org> References: <20240520090611.10406-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: FFZWQWWZ42Q4OWTC2QGV5T3BJO6TRNAF X-Message-ID-Hash: FFZWQWWZ42Q4OWTC2QGV5T3BJO6TRNAF X-MailFrom: jonatan.schlag@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Jonatan Schlag --- src/initscripts/system/functions | 6 ++++++ tests/src/initscripts/system/functions/data/2 | 20 +++++++++++++++++++ .../system/functions/data/2_output_stderr | 4 ++++ .../system/functions/data/2_output_stdout | 0 .../src/initscripts/system/functions/test.sh | 11 ++++++++++ 5 files changed, 41 insertions(+) create mode 100644 tests/src/initscripts/system/functions/data/2 create mode 100644 tests/src/initscripts/system/functions/data/2_output_stderr create mode 100644 tests/src/initscripts/system/functions/data/2_output_stdout diff --git a/src/initscripts/system/functions b/src/initscripts/system/functions index 6107463fc..bbcfab95d 100644 --- a/src/initscripts/system/functions +++ b/src/initscripts/system/functions @@ -914,6 +914,12 @@ readhash() { local key="${line%=*}" local val="${line#*=}" + # Skip lines with an invalid key + if ! [[ ${key} =~ ^[A-Za-z_][A-Za-z0-9_]*$ ]]; then + echo "Invalid key '${key}'" >&2 + continue + fi + printf -v "${array}[${key}]" "%s" "${val}" done < "${file}" } diff --git a/tests/src/initscripts/system/functions/data/2 b/tests/src/initscripts/system/functions/data/2 new file mode 100644 index 000000000..3e1a7028b --- /dev/null +++ b/tests/src/initscripts/system/functions/data/2 @@ -0,0 +1,20 @@ +CONFIG_TYPE=3 +GREEN_DEV=green0 +GREEN_MACADDR=00:c0:08:8a:a0:47 +GREEN_DRIVER=r8175 +-RED_DEV=red0 +RE??D_MACADDR=00:c0:08:8a:a0:56 +RED&&_DRIVER=r8283 +# Another Comment +0BLUE_DEV='blue0 net0' +BLUE_MACADDR=bc:30:7d:58:6b:e3 +BLUE_DRIVER=rt2800 +RED_DHCP_HOSTNAME=ipfire +RED_DHCP_FORCE_MTU= +RED_ADDRESS=0.0.0.0 +RED_NETMASK=0.0.0.0 +RED_TYPE=PPPOE +RED_NETADDRESS=0.0.0.0 + +# Comment for testing + # Comment for testing Comments with spaces before diff --git a/tests/src/initscripts/system/functions/data/2_output_stderr b/tests/src/initscripts/system/functions/data/2_output_stderr new file mode 100644 index 000000000..dfcf2154b --- /dev/null +++ b/tests/src/initscripts/system/functions/data/2_output_stderr @@ -0,0 +1,4 @@ +Invalid key '-RED_DEV' +Invalid key 'RE??D_MACADDR' +Invalid key 'RED&&_DRIVER' +Invalid key '0BLUE_DEV' diff --git a/tests/src/initscripts/system/functions/data/2_output_stdout b/tests/src/initscripts/system/functions/data/2_output_stdout new file mode 100644 index 000000000..e69de29bb diff --git a/tests/src/initscripts/system/functions/test.sh b/tests/src/initscripts/system/functions/test.sh index f1348a9e8..9981cc732 100755 --- a/tests/src/initscripts/system/functions/test.sh +++ b/tests/src/initscripts/system/functions/test.sh @@ -23,3 +23,14 @@ test_that_array_doesnt_have_key "CONFIG" "# Comment for testing Comments with sp test_that_output_is "${SCRIPT_PATH}/data/1_output_stdout" "1" readhash "CONFIG" "${SCRIPT_PATH}/data/1" test_that_output_is "${SCRIPT_PATH}/data/1_output_stderr" "2" readhash "CONFIG" "${SCRIPT_PATH}/data/1" + +# Check with invalid Lines (values and keys) + +readhash "CONFIG2" "${SCRIPT_PATH}/data/2" &> /dev/null + +# test if we read the correct data +test_that_key_in_arry_has_value "CONFIG2" "RED_DHCP_HOSTNAME" "ipfire" +test_that_key_in_arry_has_value "CONFIG2" "BLUE_MACADDR" "bc:30:7d:58:6b:e3" + +test_that_output_is "${SCRIPT_PATH}/data/2_output_stdout" "1" readhash "CONFIG2" "${SCRIPT_PATH}/data/2" +test_that_output_is "${SCRIPT_PATH}/data/2_output_stderr" "2" readhash "CONFIG2" "${SCRIPT_PATH}/data/2" From patchwork Mon May 20 09:06:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7803 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4VjWsr5CN7z3wxG for ; Mon, 20 May 2024 09:07:12 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4VjWsm1S2Lz5dv; Mon, 20 May 2024 09:07:08 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VjWsN1ljGz32xd; Mon, 20 May 2024 09:06:48 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4VjWsK2DbHz331V for ; Mon, 20 May 2024 09:06:45 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4VjWsJ4mJQz4XG; Mon, 20 May 2024 09:06:44 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1716196004; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d6CV/XcKOfMsW5i/miqVPSpfrqWXfoIhwwNjihFEYsk=; b=u/Q6aFXNszvkTMsqADxIEY+V35pkNW+aRj8y0FdA54/5C/wYo6IAGBnAFeIMJc3JNXriYR L16y9Ar/vOb5EdCQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1716196004; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d6CV/XcKOfMsW5i/miqVPSpfrqWXfoIhwwNjihFEYsk=; b=Dn/dcQnavVUVmHobAgU0Cyd0xtsl7EEI9UGic61BHyJxaeAu9mM5/xZ3hhh2CJYswG3FYi Qo3ybsZ3qNeJF7oJUtCrM9VbktkhhRwo21yyb1j9cfdMSUpd+mZT1YpLp48TxmFRbHBll1 eb3bR4L1XfiwmgtQGmkHkxy8bZnggDToiskv4uVEjPUtxN++mr7v1Dw/lGBqbK9GrGaHsb arbHFNmQ0IKb/Lzy3n8ROOm0EMoyM3mw3cEhE0GMfrYE2LOHZHBrEYfL4RMBcGStyTFEXS +XJ+uGHCiRsruQ3sR/wCm2PE44NTQ9DecfploMhs99y3gbd8jrVFfM+D4MNtfw== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 18/21] initscripts fkt: readhash should only parse lines with a = Date: Mon, 20 May 2024 11:06:08 +0200 Message-Id: <20240520090611.10406-19-jonatan.schlag@ipfire.org> In-Reply-To: <20240520090611.10406-1-jonatan.schlag@ipfire.org> References: <20240520090611.10406-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: LPDWIV3PBZZU2UFUHMDBXR5ZUF722YD5 X-Message-ID-Hash: LPDWIV3PBZZU2UFUHMDBXR5ZUF722YD5 X-MailFrom: jonatan.schlag@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: A line without a = is clearly invalid. Signed-off-by: Jonatan Schlag --- src/initscripts/system/functions | 6 ++++++ tests/src/initscripts/system/functions/data/2 | 1 + tests/src/initscripts/system/functions/data/2_output_stderr | 1 + 3 files changed, 8 insertions(+) diff --git a/src/initscripts/system/functions b/src/initscripts/system/functions index bbcfab95d..38a1316a8 100644 --- a/src/initscripts/system/functions +++ b/src/initscripts/system/functions @@ -911,6 +911,12 @@ readhash() { continue fi + # Skip lines without a = + if ! [[ ${line} =~ [^=]*=[^=]*$ ]]; then + echo "Invalid line '${line}'" >&2 + continue + fi + local key="${line%=*}" local val="${line#*=}" diff --git a/tests/src/initscripts/system/functions/data/2 b/tests/src/initscripts/system/functions/data/2 index 3e1a7028b..d1c4d327d 100644 --- a/tests/src/initscripts/system/functions/data/2 +++ b/tests/src/initscripts/system/functions/data/2 @@ -15,6 +15,7 @@ RED_ADDRESS=0.0.0.0 RED_NETMASK=0.0.0.0 RED_TYPE=PPPOE RED_NETADDRESS=0.0.0.0 +Line_without_a_equal_sign_is_also_invalid # Comment for testing # Comment for testing Comments with spaces before diff --git a/tests/src/initscripts/system/functions/data/2_output_stderr b/tests/src/initscripts/system/functions/data/2_output_stderr index dfcf2154b..cccd19af6 100644 --- a/tests/src/initscripts/system/functions/data/2_output_stderr +++ b/tests/src/initscripts/system/functions/data/2_output_stderr @@ -2,3 +2,4 @@ Invalid key '-RED_DEV' Invalid key 'RE??D_MACADDR' Invalid key 'RED&&_DRIVER' Invalid key '0BLUE_DEV' +Invalid line 'Line_without_a_equal_sign_is_also_invalid' From patchwork Mon May 20 09:06:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7804 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4VjWst0fvCz3wxV for ; Mon, 20 May 2024 09:07:14 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4VjWsm5N6Vz5p3; Mon, 20 May 2024 09:07:08 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VjWsh5x06z32w8; Mon, 20 May 2024 09:07:04 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4VjWsd58Knz32w8 for ; Mon, 20 May 2024 09:07:01 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4VjWsK5lC8z5Zb; Mon, 20 May 2024 09:06:45 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1716196005; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bmt9kL4/0WhedcpuevArx5u88LkhEK3AWmjEfIQFbQs=; b=DcUIGOZINApJnE13BKIYqweoJwlLV+jd3KONn4MGVQFAcniYCuiOq7RtxlhY2YTJ/v0RsE +6cH4aTsuZ/eqiDg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1716196005; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bmt9kL4/0WhedcpuevArx5u88LkhEK3AWmjEfIQFbQs=; b=MiwpA8BhGNcWB2LImKonnOU3CleLQ6geTJD+VRzTRTNkKb9dPGgM8aUDvofWmQwpNEhc9x /AMcOzD07zq0f471ljP9k2wALlquWgsBZ2C4eySiscAU9xBACUDcc39CNEKyNnKZuGDwh8 PIn1FiWTJ6QsS/v8sh0jDVIp1VWunKDIDTjeA1kyc1BOcqA9SQg3Z0ei6QQm2Ec+p8ABgM /ibqc1OGSe3PP16slGH0j+nabZtSjNh2R4H1h36DmP+Ni4FTZJEIwo/+5F+O5yfKvw83Q+ pCnGX93FZ0eRHGw24ZJX7zwomyu1eUslCn4D+htqOzWXQEqhHyci3yhiCFVd7w== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 19/21] initscripts fkt: Check for invalid values in readhash Date: Mon, 20 May 2024 11:06:09 +0200 Message-Id: <20240520090611.10406-20-jonatan.schlag@ipfire.org> In-Reply-To: <20240520090611.10406-1-jonatan.schlag@ipfire.org> References: <20240520090611.10406-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: 5D2OWIYOMMBTQP6YUOZKPOWBDYG47ENH X-Message-ID-Hash: 5D2OWIYOMMBTQP6YUOZKPOWBDYG47ENH X-MailFrom: jonatan.schlag@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Jonatan Schlag --- src/initscripts/system/functions | 6 ++++++ tests/src/initscripts/system/functions/data/2 | 8 ++++---- .../src/initscripts/system/functions/data/2_output_stderr | 4 ++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/initscripts/system/functions b/src/initscripts/system/functions index 38a1316a8..c9c4c0675 100644 --- a/src/initscripts/system/functions +++ b/src/initscripts/system/functions @@ -926,6 +926,12 @@ readhash() { continue fi + # Skip lines with invalid values + if ! [[ ${val} =~ ^[\'][\ A-Za-z0-9=/,.:%_@#+-]*[\']$ ]] && ! [[ ${val} =~ ^[A-Za-z0-9=/,.:%_@#+-]*$ ]]; then + echo "Invalid value '${val}' for key '${key}'" >&2 + continue + fi + printf -v "${array}[${key}]" "%s" "${val}" done < "${file}" } diff --git a/tests/src/initscripts/system/functions/data/2 b/tests/src/initscripts/system/functions/data/2 index d1c4d327d..760294c30 100644 --- a/tests/src/initscripts/system/functions/data/2 +++ b/tests/src/initscripts/system/functions/data/2 @@ -1,7 +1,7 @@ -CONFIG_TYPE=3 -GREEN_DEV=green0 -GREEN_MACADDR=00:c0:08:8a:a0:47 -GREEN_DRIVER=r8175 +CONFIG_TYPE=?3 +GREEN_DEV=gree!n0 +GREEN_MACADDR=00:c0:08:8a :a0:47 +GREEN_DRIVER="r8175" -RED_DEV=red0 RE??D_MACADDR=00:c0:08:8a:a0:56 RED&&_DRIVER=r8283 diff --git a/tests/src/initscripts/system/functions/data/2_output_stderr b/tests/src/initscripts/system/functions/data/2_output_stderr index cccd19af6..82f035e26 100644 --- a/tests/src/initscripts/system/functions/data/2_output_stderr +++ b/tests/src/initscripts/system/functions/data/2_output_stderr @@ -1,3 +1,7 @@ +Invalid value '?3' for key 'CONFIG_TYPE' +Invalid value 'gree!n0' for key 'GREEN_DEV' +Invalid value '00:c0:08:8a :a0:47' for key 'GREEN_MACADDR' +Invalid value '"r8175"' for key 'GREEN_DRIVER' Invalid key '-RED_DEV' Invalid key 'RE??D_MACADDR' Invalid key 'RED&&_DRIVER' From patchwork Mon May 20 09:06:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7805 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4VjWst2jPnz3wxb for ; Mon, 20 May 2024 09:07:14 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4VjWsm2TYBz5nr; Mon, 20 May 2024 09:07:08 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VjWsX3GHpz32fy; Mon, 20 May 2024 09:06:56 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4VjWsV2GcBz32fy for ; Mon, 20 May 2024 09:06:54 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4VjWsL5Dfbz15J; Mon, 20 May 2024 09:06:46 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1716196006; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qxZ9/olv1XdfcPMKhlM+jDC0B0OpMcP6wKLEySFbCo0=; b=8AGYxekjzwhPH8ADXCN1PYMi2rSc43Xr3bQudaBJgxsEH04wtTRhmoD1wPtxiLXWA3QDq1 5ws1UvpRIKHe1mCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1716196006; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qxZ9/olv1XdfcPMKhlM+jDC0B0OpMcP6wKLEySFbCo0=; b=cVRo/4MAip382RulY0hFT+5MHBN0qz8Fil0TxUo4vf3GF8RyNno/VvDlwP2CHGLFIEaXz2 QHMuajl0wjheGK0GYasdy70HmYAP2S4JnVuHmfPc2vuWJaHFxQ1sojcG9z+EHzl4hJREfU 2WY7GI7au+KFCdndeC419o985SH7B+BiF0szq/vSxeqCFqNRDpvCycXbZ0O9fRfP8pyq1h pOuIixXmSOUHOJUv1I8NrU2gYPbozlX19yijEE+6CHSbn2PNS8Jei+FFpx81o2Rv5zlO+i CU8++iEQJ7c5GTrp2+5ToSRLuop1+j7SE8fn48r9DZJ459Tg1DOId2snsjPwJA== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 20/21] initscripts fkt: keep readhash compatible with older implementation Date: Mon, 20 May 2024 11:06:10 +0200 Message-Id: <20240520090611.10406-21-jonatan.schlag@ipfire.org> In-Reply-To: <20240520090611.10406-1-jonatan.schlag@ipfire.org> References: <20240520090611.10406-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: PHFTJJASBOXZNEQIPZGDEUGQQGJ7Y2JP X-Message-ID-Hash: PHFTJJASBOXZNEQIPZGDEUGQQGJ7Y2JP X-MailFrom: jonatan.schlag@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: With the use of eval BLUE_DEV='blue0 net0' stored "blue0 net0" in the variable BLUE_DEV not "'blue0 net0'" Signed-off-by: Jonatan Schlag --- src/initscripts/system/functions | 4 ++++ tests/src/initscripts/system/functions/test.sh | 1 + 2 files changed, 5 insertions(+) diff --git a/src/initscripts/system/functions b/src/initscripts/system/functions index c9c4c0675..6d72e4119 100644 --- a/src/initscripts/system/functions +++ b/src/initscripts/system/functions @@ -932,6 +932,10 @@ readhash() { continue fi + # strip leading and trailing single quotes + val="${val#\'}" + val="${val%\'}" + printf -v "${array}[${key}]" "%s" "${val}" done < "${file}" } diff --git a/tests/src/initscripts/system/functions/test.sh b/tests/src/initscripts/system/functions/test.sh index 9981cc732..1a715d7d9 100755 --- a/tests/src/initscripts/system/functions/test.sh +++ b/tests/src/initscripts/system/functions/test.sh @@ -14,6 +14,7 @@ readhash "CONFIG" "${SCRIPT_PATH}/data/1" # test if we read the correct data test_that_key_in_arry_has_value "CONFIG" "RED_DHCP_HOSTNAME" "ipfire" test_that_key_in_arry_has_value "CONFIG" "BLUE_MACADDR" "bc:30:7d:58:6b:e3" +test_that_key_in_arry_has_value "CONFIG" "BLUE_DEV" "blue0 net0" # Test that comments are skipped # apparently the way we read the file strips the whitespace, so the key does not contain any whitespace either From patchwork Mon May 20 09:06:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7806 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4VjWsv6N5Pz3x0S for ; Mon, 20 May 2024 09:07:15 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4VjWsp1jMQz5j3; Mon, 20 May 2024 09:07:10 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VjWsp13qLz2y2N; Mon, 20 May 2024 09:07:10 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4VjWsl4NXfz2y2N for ; Mon, 20 May 2024 09:07:07 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4VjWsQ5Ls5z5dv; Mon, 20 May 2024 09:06:50 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1716196010; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZGU/6y2nUMStvmCNVH7JLdDrVlh0bzQQQV1Mv2Zf1dE=; b=W46NAGY2WumvKgy+QlsPsdAHTGe16ULZVu281FPzjxJQCbNGdhi44EwNDUTAkTX9r6IQuF gn4FUjYuG7Y84zBQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1716196010; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZGU/6y2nUMStvmCNVH7JLdDrVlh0bzQQQV1Mv2Zf1dE=; b=U/oFkZBt8rI4mDVz2g5LMO2NZxaS3+zbw0FgDVoW+JPb8k7Jw1mLnOaOme+bqkhDfu+LKj xRuZlQg8ykiiuVJp2ekEDmLQ1qLoQWXxt6NehCjKQ/AzBIgDgtuFnsbZzoGgFposV+Mwrh 3sRnZL78WnrC2kcW2Ngyj13+iIMXT6Tas9LH/UX/tsY43nQ2ZuJALeT1vywtQb7/EeHQoJ OXc7yjppn+0Swjxibeq6YrUP52FvKZ03BsqQ8y2lZiHLxcRLM7t5OuN8caS2smGZaPQhgu RVjXJypqFLSoIEMFbWhKO/kjNHRJvagcfiFYGpHwkuF0O5V5Y+KtFcFg5oBkTw== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 21/21] initscripts fkt: Fix shebang Date: Mon, 20 May 2024 11:06:11 +0200 Message-Id: <20240520090611.10406-22-jonatan.schlag@ipfire.org> In-Reply-To: <20240520090611.10406-1-jonatan.schlag@ipfire.org> References: <20240520090611.10406-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: PUY3P2QJN64MKV7T6LNEOAYQKKYLS7F4 X-Message-ID-Hash: PUY3P2QJN64MKV7T6LNEOAYQKKYLS7F4 X-MailFrom: jonatan.schlag@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: We use features only available in bash. So we should state correctly that the script should be executed in bash. As sh is a symlink to bash this makes not differences on a ipfire system. But my linter is less chatty with this change. Signed-off-by: Jonatan Schlag --- src/initscripts/system/functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/initscripts/system/functions b/src/initscripts/system/functions index 6d72e4119..0775d74a1 100644 --- a/src/initscripts/system/functions +++ b/src/initscripts/system/functions @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash ############################################################################### # # # IPFire.org - A linux based firewall #