[OS-BUILD PATCHv7 3/5] [redhat] Makefile.common, self-test/egit.sh, 1005-dist-dump-variables.bats

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

 



From: Ben Crocker <bcrocker@xxxxxxxxxx>

• Makefile:

  Create new dist-self-test target and hook up the BATS
  self tests.  Check for the presence of /usr/bin/bats
  (via 'test -x') and complain if it is not installed.

• Makefile.common: make HEAD an overridable variable.
  Change
  GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H)
  to
  GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD))

  making the argument to 'git log' explicit and allowing it to be
  overridden by, e.g., self-tests.

• egit.sh: eliminate as-yet-unused merge-base case.

• self-test/1005-dist-dump-variables.bats: initial commit

The four tests in 1005-dist-dump-variables.bats test the RPM version
generation, name generation, and snapshot designation for several
previously chosen tags/commits.

The tags/commits chosen are:

a) v5.8
b) v5.8-rc7
c) v5.8-9-g565674d613d7
d) v5.8-rc5-99-g25ccd24ffd91

and the expected results are:
a) RPMVERSION = 5.8.0, no rc
b) RPMVERSION = 5.8.0, .rc7
c) RPMVERSION = 5.9.0, .rc0, snapshot
d) RPMVERSION = 5.8.0, .rc5, snapshot

Signed-off-by: Ben Crocker <bcrocker@xxxxxxxxxx>
---
 redhat/Makefile                               |  7 +++
 redhat/Makefile.common                        | 13 +++--
 .../self-test/1005-dist-dump-variables.bats   | 55 +++++++++++++++++++
 redhat/self-test/egit.sh                      |  9 ---
 4 files changed, 69 insertions(+), 15 deletions(-)
 create mode 100644 redhat/self-test/1005-dist-dump-variables.bats

diff --git a/redhat/Makefile b/redhat/Makefile
index fd10ac8f145d..84950bf876af 100644
--- a/redhat/Makefile
+++ b/redhat/Makefile
@@ -392,6 +392,13 @@ dist-dump-variables:
 	chmod +x $(REDHAT)/dist-dump-variables.sh
 	@$(REDHAT)/dist-dump-variables.sh
 
+dist-self-test:
+	@if test -x /usr/bin/bats; then \
+		bats $(REDHAT)/self-test/*.bats ; \
+	else \
+		echo "dist-self-test: The bats package is not installed" ; \
+	fi
+
 dist-help:
 	@echo  'Cleaning targets:'
 	@echo  '  dist-clean          - Clean redhat/configs/ and redhat/rpm/ directories.'
diff --git a/redhat/Makefile.common b/redhat/Makefile.common
index 80c3b8dfccd4..cdffa9fb3d3d 100644
--- a/redhat/Makefile.common
+++ b/redhat/Makefile.common
@@ -6,11 +6,12 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \
                    else echo rpm; fi)
 
 MACH :=  $(shell uname -m)
-RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}')
-RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}')
-RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}')
-RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}')
-GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H)
+HEAD ?= HEAD
+RPMKVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}')
+RPMKPATCHLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}')
+RPMKSUBLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}')
+RPMKEXTRAVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}')
+GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD))
 # marker is git tag which we base off of for exporting patches
 # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel
 # makefile as opposed to any adjusted version for snapshotting.
@@ -42,7 +43,7 @@ else
 endif
 ifeq ($(VERSION_ON_UPSTREAM),1)
   # master is expected to track mainline.
-  MERGE_BASE:=$(shell $(GIT) merge-base HEAD master)
+  MERGE_BASE:=$(shell $(GIT) merge-base $(HEAD) master)
   _TAG:=$(shell $(GIT) describe $(MERGE_BASE))
   # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash]
   SNAPSHOT:=$(shell echo $(_TAG) | grep -c '\-g')
diff --git a/redhat/self-test/1005-dist-dump-variables.bats b/redhat/self-test/1005-dist-dump-variables.bats
new file mode 100644
index 000000000000..9251ca4636d5
--- /dev/null
+++ b/redhat/self-test/1005-dist-dump-variables.bats
@@ -0,0 +1,55 @@
+#!/usr/bin/env bats
+
+function prologue()
+{
+    tag=$1
+    ofile=$BATS_TMPDIR/$tag.out
+    # Have to unset environment variables that may be inherited from supra-make:
+    grep "^[ 	]*[a-zA-Z_][a-zA-Z_0-9]*[ 	]*[:?]*=" \
+         $BATS_TEST_DIRNAME/../Makefile.common | \
+        sed -e 's/[ 	]*\([a-zA-Z_][a-zA-Z_0-9]*\).*/unset \1/' | \
+        sort | uniq > $BATS_TMPDIR/unset-vars.sh
+    source $BATS_TMPDIR/unset-vars.sh
+    GIT=$BATS_TEST_DIRNAME/egit.sh HEAD=$tag EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile
+}
+
+function checkversion()
+{
+    status=1
+    if grep -x "_TAG=$1" $ofile && \
+            grep -x "RPMKVERSION=$2" $ofile && grep -x "RPMKPATCHLEVEL=$3" $ofile && \
+            grep -x "RPMKSUBLEVEL=$4" $ofile && grep -x "RPMKEXTRAVERSION=$5" $ofile && \
+            grep -x "KEXTRAVERSION=$6" $ofile && \
+            grep -x "SNAPSHOT=$7" $ofile
+    then
+        status=$?
+    fi
+}
+
+@test "dist-dump-variables v5.8" {
+    tag=v5.8
+    prologue $tag
+    checkversion $tag "5" "8" "0" "" "" "0"
+    [ "$status" = 0 ]
+}
+
+@test "dist-dump-variables v5.8-rc7" {
+    tag=v5.8-rc7
+    prologue $tag
+    checkversion $tag "5" "8" "0" "-rc7" ".rc7" "0"
+    [ "$status" = 0 ]
+}
+
+@test "dist-dump-variables v5.8-9-g565674d613d7" {
+    tag=v5.8-9-g565674d613d7
+    prologue $tag
+    checkversion $tag "5" "9" "0" "" ".rc0" "1"
+    [ "$status" = 0 ]
+}
+
+@test "dist-dump-variables v5.8-rc5-99-g25ccd24ffd91" {
+    tag=v5.8-rc5-99-g25ccd24ffd91
+    prologue $tag
+    checkversion $tag "5" "8" "0" "-rc5" ".rc5" "1"
+    [ "$status" = 0 ]
+}
diff --git a/redhat/self-test/egit.sh b/redhat/self-test/egit.sh
index b998f868a314..f26921cc2aca 100755
--- a/redhat/self-test/egit.sh
+++ b/redhat/self-test/egit.sh
@@ -12,15 +12,6 @@ case $arg in
             git describe "$@"
         fi
         ;;
-    merge-base )
-        if [ -n "$EGIT_OVERRIDE_MERGE_BASE" ]
-        then
-            # This should be an SHA1:
-            echo "$EGIT_OVERRIDE_MERGE_BASE"
-        else
-            git merge-base "$@"
-        fi
-        ;;
     * )
         git "$arg" "$@"
         ;;
-- 
GitLab
_______________________________________________
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




[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