[OS-BUILD PATCHv3 2/7] redhat/self-test: Add better dist-dump-variables test

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

 



From: Prarit Bhargava <prarit@xxxxxxxxxx>

redhat/self-test: Add better dist-dump-variables test

The current dist-dump-variables test is not adequate in that it only tests
a small number of fields.  Add a test to run create-data.sh and compare
that data against the stored "known good" output in self-test/data.

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

diff --git a/redhat/Makefile b/redhat/Makefile
index blahblah..blahblah 100644
--- a/redhat/Makefile
+++ b/redhat/Makefile
@@ -29,6 +29,10 @@ endif
 REDHAT:=$(TOPDIR)/redhat
 include $(TOPDIR)/Makefile.rhelver
 
+ifndef RHDISTDATADIR
+  RHDISTDATADIR=${REDHAT}/self-test/data
+endif
+
 RPMBUILD:=$(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \
                   else echo rpm; fi)
 
@@ -655,7 +659,7 @@ dist-self-test:
 	fi
 
 dist-self-test-data:
-	./self-test/data/create-data.sh ${REDHAT}/self-test/data
+	./self-test/data/create-data.sh
 
 dist-help:
 	@echo  'Cleaning targets:'
diff --git a/redhat/Makefile.variables b/redhat/Makefile.variables
index blahblah..blahblah 100644
--- a/redhat/Makefile.variables
+++ b/redhat/Makefile.variables
@@ -123,3 +123,7 @@ NO_CONFIGCHECKS ?=
 # This variable is only used to create self-test data.  It should not be
 # considered stable and may be changed or removed without warning.
 RHSELFTESTDATA ?=
+
+# This variable is used by the redhat/self-tests.  It should not be used be
+# considered stable and my be changed or removed without warning.
+RHDISTDATADIR ?=
diff --git a/redhat/self-test/1005-dist-dump-variables.bats b/redhat/self-test/1005-dist-dump-variables.bats
index blahblah..blahblah 100644
--- a/redhat/self-test/1005-dist-dump-variables.bats
+++ b/redhat/self-test/1005-dist-dump-variables.bats
@@ -1,57 +1,12 @@
 #!/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:
-    make dist-dump-variables | grep "=" | cut -d"=" -f1 | while read VAR; do unset "$VAR"; done
-    GIT=$BATS_TEST_DIRNAME/egit.sh HEAD=$tag EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile
-}
-
-function checkversion()
-{
-	echo "verifying _TAG=$1"
-	grep -E "^_TAG=$1" $ofile
-	echo "verifying RPMKVERSION=$2"
-	grep -E "^RPMKVERSION=$2" $ofile
-	echo "verifying RPMPATCHLEVEL=$3"
-	grep -E "^RPMKPATCHLEVEL=$3" $ofile
-	echo "verifying RPMSUBLEVEL=$4"
-	grep -E "^RPMKSUBLEVEL=$4" $ofile
-	echo "verifying RPMEXTRAVERSION=$5"
-	grep -E "^RPMKEXTRAVERSION=$5" $ofile
-	echo "verifying KEXTRAVERSION=$6"
-	grep -E "^KEXTRAVERSION=$6" $ofile
-	echo "verifying SNAPSHOT=$6"
-	grep -E "^SNAPSHOT=$7" $ofile
-	status=0
-}
-
-@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 "self-test-data check" {
+	mkdir -p $BATS_TMPDIR/data
+	RHDISTDATADIR=$BATS_TMPDIR/data make dist-self-test-data
 
-@test "dist-dump-variables v5.8-9-g565674d613d7" {
-    tag=v5.8-9-g565674d613d7
-    prologue $tag
-    checkversion $tag "5" "9" "0" "" ".rc0" "1"
-    [ "$status" = 0 ]
-}
+	redhat=$(make dist-dump-variables | grep "REDHAT=" | cut -d"=" -f2 | xargs)
 
-@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 ]
+	echo "Diffing directories ${redhat}/self-test/data and $BATS_TMPDIR/data"
+	diff -urNp -x create-data.sh ${redhat}/self-test/data $BATS_TMPDIR/data
+	[ -d $BATS_TMPDIR ] && rm -rf $BATS_TMPDIR/data
 }
diff --git a/redhat/self-test/data/create-data.sh b/redhat/self-test/data/create-data.sh
index blahblah..blahblah 100755
--- a/redhat/self-test/data/create-data.sh
+++ b/redhat/self-test/data/create-data.sh
@@ -1,7 +1,6 @@
 #!/usr/bin/bash
 
-target_dir=$1
-[ -z "${target_dir}" ] && echo "Missing target directory." && exit 1
+[ -z "${RHDISTDATADIR}" ] && echo "ERROR: RHDISTDATADIR undefined." && exit 1
 
 # This script generates 'dist-dump-variables' output for various configurations
 # using known ark commit IDs.  It uses this information as well as setting
@@ -15,21 +14,19 @@ target_dir=$1
 #    fce15c45d3fb := 5.16-rc5 + 2 additional commits
 #
 
-[ -z "$REDHAT" ] && echo "ERROR: execution only supported through 'make dist-self-test-data'" && exit 1
-
 for DISTRO in fedora rhel centos
 do
 	for commit in 78e36f3b0dae 2585cf9dfaad df0cc57e057f fce15c45d3fb
 	do
 		for DIST in .fc25 .el7
 		do
-			varfilename="${DISTRO}-${commit}${DIST}"
+			varfilename="${RHDISTDATADIR}/${DISTRO}-${commit}${DIST}"
 
 			echo "building $varfilename"
 
 			# CURDIR is a make special target and cannot be easily changed.  Omit
 			# CURDIR from the output.
-			make RHSELFTESTDATA=1 DIST="${DIST}" DISTRO="${DISTRO}" HEAD=${commit} dist-dump-variables | grep "=" | grep -v CURDIR >& "${target_dir}"/"${varfilename}"
+			make RHSELFTESTDATA=1 DIST="${DIST}" DISTRO="${DISTRO}" HEAD=${commit} dist-dump-variables | grep "=" | grep -v CURDIR >& "${varfilename}"
 
 			# When executed from a script, the variables in Makefile.variables are
 			# listed as having origin 'environment'.  This is because the script
@@ -37,7 +34,11 @@ do
 			# The 'dist-dump-variables' target explicitly omits these variables from
 			# its output.  As a workaround, read in the variables and output them to
 			# the data file.
-			cat Makefile.variables | grep -v "^#" | sed '/^$/d' | tr -d " " | awk -F "?=|:=" '{print $1}' | while read VAR; do echo $VAR=$(echo ${!VAR}); done >> "${target_dir}"/"${varfilename}"
+			cat Makefile.variables | grep -v "^#" | sed '/^$/d' | tr -d " " | awk -F "?=|:=" '{print $1}' | while read VAR
+			do
+				[ "$VAR" == "RHDISTDATADIR" ] && continue
+				echo "$VAR=$(echo ${!VAR})"
+			done >> "${varfilename}"
 		done
 	done
 done

--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1706
_______________________________________________
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