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}" ]] +}