[OS-BUILD PATCH 16/16] redhat/self-test: Add test to verify SPEC variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Prarit Bhargava <prarit@xxxxxxxxxx>

redhat/self-test: Add test to verify SPEC variables

This test looks at the spec file variable replacement code in
redhat/genspec.sh and confirms that each variable begins with "SPEC".

Signed-off-by: Prarit Bhargava <prarit@xxxxxxxxxx>

diff --git a/redhat/docs/makefile-changes.rst b/redhat/docs/makefile-changes.rst
index blahblah..blahblah 100644
--- a/redhat/docs/makefile-changes.rst
+++ b/redhat/docs/makefile-changes.rst
@@ -46,6 +46,12 @@ external scripts.  Variables in this file should be considered stable.
 Variables still may be deprecated and will follow the guidelines in
 "Deprecating variables and targets" section below.
 
+Variable Naming
+===============
+
+Variables names prefixed with SPEC indicate that the variable is used
+in redhat/kernel.spec.template (see redhat/genspec.sh).
+
 Deprecating variables and targets
 =================================
 
diff --git a/redhat/genspec.sh b/redhat/genspec.sh
index blahblah..blahblah 100755
--- a/redhat/genspec.sh
+++ b/redhat/genspec.sh
@@ -56,6 +56,7 @@ if [ "$PATCHLIST_URL" != "none" ]; then
 	SPECPATCHLIST_CHANGELOG=1
 fi
 
+# self-test begin
 test -f "$SOURCES/$SPECFILE" &&
 	sed -i -e "
 	/%%SPECCHANGELOG%%/r $SOURCES/$SPECCHANGELOG
@@ -73,6 +74,7 @@ test -f "$SOURCES/$SPECFILE" &&
 	s/%%SPECPATCHLIST_CHANGELOG%%/$SPECPATCHLIST_CHANGELOG/
 	s/%%SPECVERSION%%/$SPECVERSION/
 	s/%%SPECTARFILE_RELEASE%%/$SPECTARFILE_RELEASE/" "$SOURCES/$SPECFILE"
+# self-test end
 
 # We depend on work splitting of BUILDOPTS
 # shellcheck disable=SC2086
diff --git a/redhat/self-test/1006-verify-SPEC-variables.bats b/redhat/self-test/1006-verify-SPEC-variables.bats
new file mode 100644
index blahblah..blahblah 100644
--- /dev/null
+++ b/redhat/self-test/1006-verify-SPEC-variables.bats
@@ -0,0 +1,24 @@
+#!/usr/bin/env bats
+
+@test "verify SPEC variables" {
+# This test looks at the spec file variable replacement code in
+# redhat/genspec.sh and confirms that each variable begins with "SPEC".
+
+# This looks at the code and replaces each / with a new-line character, removes
+# any whitespace and entry entries beginning with valid "%%SPEC" or $"SPEC".
+# "$SOURCES" lines are also okay as it is used to point to the changelog and
+# the specfile.
+awk '/# self-test begin/, /# self-test end/' $BATS_TEST_DIRNAME/../genspec.sh | grep -v "^#" | tr "/" "\n" | tr -d "\"" | sed -r '/^\s*$/d' | grep -v "%%SPEC" | grep -v "\$SPEC" | grep -v "\$SOURCES" | while read LINE
+do
+	case $(echo $LINE | xargs) in
+	s) ;;
+	d) ;;
+#"sed -i -e") ;;
+	*)
+		echo " "
+		echo "ERROR: Variables passed between genspec.sh and the spec file must begin with %%SPEC or \$SPEC."
+		exit 1
+		;;
+	esac
+done
+}

--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1727
_______________________________________________
kernel mailing list -- kernel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to kernel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/kernel@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure




[Index of Archives]     [Fedora General Discussion]     [Older Fedora Users Archive]     [Fedora Advisory Board]     [Fedora Security]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Mentors]     [Fedora Package Announce]     [Fedora Package Review]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Coolkey]     [Yum Users]     [Tux]     [Yosemite News]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [USB]     [Asterisk PBX]

  Powered by Linux