From patchwork Sun Jun 16 16:02:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7880 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 4W2Hqs2NZJz3ws3 for ; Sun, 16 Jun 2024 16:03:37 +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 4W2Hqr4GcDz5pN; Sun, 16 Jun 2024 16:03:36 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4W2Hqr3jwTz33FL; Sun, 16 Jun 2024 16:03: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 4W2Hql2MfKz33Fh for ; Sun, 16 Jun 2024 16:03: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 4W2Hql0s5sz5nr; Sun, 16 Jun 2024 16:03:31 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1718553811; 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=h8O30gjaF/CkkL4pBYzk6Y6qkWIeKW1wCTGibBFeFL4=; b=tayKWP2aOeLPfAutd5RYqGTP1xlQnYf3WbfLBoio6c7ybYjIqQtWz00a7SIB9E9z5j4v05 IkCOWkl0T1LGYQDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1718553811; 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=h8O30gjaF/CkkL4pBYzk6Y6qkWIeKW1wCTGibBFeFL4=; b=ICoP6tMgOnll1P1OhpGsWld059jdqo3ocGJ+Ac3o8GXR6+0gI7TH2V/kKYqELJshGBmijP voYBcXwl8LtDPHMvZgzdFrRDXL4+erO84qD23orkKk//YoC+66EjszgWslRCt4VBqL5fHn jJQrrYKkGyJJHc08xh8nuiOQ3uYfNZEkHTVWAe2iFBCTDdHlhdPB6A+i4oao227kV4kOha KTWaOEh74GAl346IwWXBdR5mHMV4wtetNP4yZuaxkw1qAXqFLa7O+5AZl78qlYKTIHZ7Np 4ktcSnb4eH5qQkM6Yp8UGjUIm+khBBP9gZTrh+h2/1Uy2pvY1d5AfrZVA32j8Q== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH v2 18/18] initscripts fkt: Check that readhash returns 1 on a missing file Date: Sun, 16 Jun 2024 18:02:45 +0200 Message-Id: <20240616160245.18865-19-jonatan.schlag@ipfire.org> In-Reply-To: <20240616160245.18865-1-jonatan.schlag@ipfire.org> References: <20240616160245.18865-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: JG7AYPGB2OG3XVCFWNXEA5FTTMEDLFAB X-Message-ID-Hash: JG7AYPGB2OG3XVCFWNXEA5FTTMEDLFAB 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: It already does that, so the function is not changed Signed-off-by: Jonatan Schlag --- tests/src/initscripts/system/functions/test.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/src/initscripts/system/functions/test.sh b/tests/src/initscripts/system/functions/test.sh index e7f695f55..dbcbd45ef 100755 --- a/tests/src/initscripts/system/functions/test.sh +++ b/tests/src/initscripts/system/functions/test.sh @@ -10,6 +10,7 @@ ROOT="$(readlink -f "${SCRIPT_PATH}/../../../../..")" # read the date in readhash "CONFIG" "${SCRIPT_PATH}/data/1" +test_command [ $? == 0 ] # test if we read the correct data test_value_in_array "CONFIG" "RED_DHCP_HOSTNAME" "ipfire" @@ -27,6 +28,8 @@ test_that_output_is "${SCRIPT_PATH}/data/1_output_stderr" "2" readhash "CONFIG" # Check with invalid Lines (values and keys) readhash "CONFIG2" "${SCRIPT_PATH}/data/2" &> /dev/null +test_command [ $? == 0 ] + # test if we read the correct data test_value_in_array "CONFIG2" "RED_DHCP_HOSTNAME" "ipfire" @@ -39,4 +42,6 @@ test_value_in_array "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" - +# Check non existent file +readhash "CONFIG3" "${SCRIPT_PATH}/data/-1" &> /dev/null +test_command [ $? == 1 ]