From 3a6844c8ceb3296370a2c1bface8cb52f70514a2 Mon Sep 17 00:00:00 2001 From: Alexandre Pujol Date: Tue, 15 Oct 2024 16:18:53 +0100 Subject: [PATCH] tests(check): also checks files header. --- tests/check.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/check.sh b/tests/check.sh index a46d38e3..b6352415 100644 --- a/tests/check.sh +++ b/tests/check.sh @@ -10,6 +10,21 @@ set -eu -o pipefail readonly APPARMORD="apparmor.d" +_ensure_header() { + local file="$1" + headers=( + "# apparmor.d - Full set of apparmor profiles" + "# Copyright (C) " + "# SPDX-License-Identifier: GPL-2.0-only" + ) + for header in "${headers[@]}"; do + if ! grep -q "^$header" "$file"; then + echo "$file does not contain '$header'" + exit 1 + fi + done +} + _ensure_include() { local file="$1" local include="$2" @@ -37,6 +52,7 @@ _ensure_vim() { check_profiles() { echo "⋅ Checking if all profiles contain:" + echo " - apparmor.d header & license" echo " - 'abi ,'" echo " - 'profile '" echo " - 'include if exists '" @@ -50,6 +66,7 @@ check_profiles() { name="$(basename "$file")" name="${name/.apparmor.d/}" include="include if exists " + _ensure_header "$file" _ensure_include "$file" "$include" _ensure_abi "$file" _ensure_vim "$file" @@ -71,11 +88,13 @@ check_profiles() { check_abstractions() { echo "⋅ Checking if all abstractions contain:" + echo " - apparmor.d header & license" echo " - 'abi ,'" echo " - 'include if exists '" echo " - vim:syntax=apparmor" directories=( "$APPARMORD/abstractions/" "$APPARMORD/abstractions/app/" + "$APPARMORD/abstractions/attached/" "$APPARMORD/abstractions/bus/" "$APPARMORD/abstractions/common/" ) for dir in "${directories[@]}"; do @@ -83,6 +102,7 @@ check_abstractions() { name="$(basename "$file")" root="${dir/${APPARMORD}\/abstractions\//}" include="include if exists " + _ensure_header "$file" _ensure_include "$file" "$include" _ensure_abi "$file" _ensure_vim "$file"