From patchwork Sun Jun 16 16:02:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7863 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 4W2HqP3Ggxz3ws3 for ; Sun, 16 Jun 2024 16:03:13 +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 4W2HqJ1HsMz1X1; Sun, 16 Jun 2024 16:03:08 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4W2HqJ0d8tz33Fr; Sun, 16 Jun 2024 16:03:08 +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 4W2HqG5gXmz2xtd for ; Sun, 16 Jun 2024 16:03:06 +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 4W2HqF4dNpz2sm; Sun, 16 Jun 2024 16:03:05 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1718553785; 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=BNMPKb7BeG81zVS+iNYzcnnQGiMAOeIWTlcN/bs7zdU=; b=fkczhbu1abcupUFNJ6B4pjeECmLsg9a9ksAoDInXmSUI7GH5HodaEWRfqXZLuM/n58wr8q NBYj9l1KefIXMhBA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1718553785; 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=BNMPKb7BeG81zVS+iNYzcnnQGiMAOeIWTlcN/bs7zdU=; b=dRV9OkJuuvbfpwvBM3pjtAAi7zhSdQdLN4n0BijtEi49nHfpzTYwAS3Quj8JaomUwtbJnF K2oXkf3PvEPGMKdUye4/ijvUhis4Gade279CwKJ33AS2UlkZhVKa2KPBZ+AFdapXHDVjry jQvcFExD+tVxJJ6oAGAtrbQxNKk3OiYwlzxE8w3IUoa6KGfLmrBuhdBWUlhQFTbofXDNE7 IXAtgYtUxjAx7jEtTYTEYTsroTbfjT6Bs5mMUCd+JEe3GWmaumNAD6dWvR6epPQSiVNwMg SvjDR68RW2eAP82ynF15GyG8IOfAQ86+A+0iH3Q+qNt3oPkOYu0EiNQXZgv3+A== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH v2 01/18] tests: Add bash lib Date: Sun, 16 Jun 2024 18:02:28 +0200 Message-Id: <20240616160245.18865-2-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: KNBGJPG4JZILZB5FF6QX2GKRVVOVNFUB X-Message-ID-Hash: KNBGJPG4JZILZB5FF6QX2GKRVVOVNFUB 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 | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/lib.sh diff --git a/tests/lib.sh b/tests/lib.sh new file mode 100644 index 000000000..dd5e3f535 --- /dev/null +++ b/tests/lib.sh @@ -0,0 +1,27 @@ +#!/usr/bin/bash + +# Get the path of this file. +# This ist rather complex as we do not want the calling script file +# That why we use BASH_SOURCE[0] +LIB_DIR="$(readlink -f "${BASH_SOURCE[0]}")" +# In LIB_DIR is currently saved the path to this file you are currently reading +# but we need the directory where it is located so: +LIB_DIR="$(dirname "${LIB_DIR}")" + + +. ${LIB_DIR}/lib_color.sh + +test_command() { + + 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}" ]] +}