From ce5fb0f9579d8d437bfed3238b3f96fddd73359f Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Aug 19 2022 13:04:00 +0000
Subject: [PATCH 1/6] Remove jar_archive test


Unlike other tests, jar_archive is written in shell and we want to
keep only Java tests.  Besides that, functionality of jar_archive
should be already covered by bytecode_version test that unpacks JAR
files - it should fail in case .jar file is not a ZIP file.

---

diff --git a/test_scripts/jar_archive.sh b/test_scripts/jar_archive.sh
deleted file mode 100755
index 423ec73..0000000
--- a/test_scripts/jar_archive.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#/bin/bash
-
-set -e
-
-source ./common.sh
-
-exitcode=0
-
-for rpm in $(find "${TEST_ARTIFACTS}" -maxdepth 1 \( -name '*.rpm' -and ! -name '*.src.rpm' \)); do
-    mkdir rpm_content
-    rpm2cpio "${rpm}" | cpio -idm -D rpm_content
-    if [ -d rpm_content/usr/share/java ]; then
-        for jar_file in $(find rpm_content/usr/share/java -type f -name '*.jar'); do
-            file "${jar_file}" | grep "Zip archive data" || {
-                echo "[FAIL] ${rpm}: File ${jar_file#rpm_content} is not a zip archive"
-                exitcode=1
-            }
-        done
-    fi
-    rm -rf rpm_content
-done
-
-exit ${exitcode}
diff --git a/tests.fmf b/tests.fmf
index de421ca..7c3335f 100644
--- a/tests.fmf
+++ b/tests.fmf
@@ -85,11 +85,3 @@ require:
       according to this change https://fedoraproject.org/wiki/Changes/Drop_i686_JDKs
       (configurable)
     test: ./jp_validator.sh ExclusiveArchCheck
-
-  /jar_archive:
-    description: >
-      Check whether each .jar file is a valid .zip archive.
-    require+:
-      - cpio
-      - file
-    test: ./jar_archive.sh

From 98466568e8da1de676734cdc5accda3c2f5610e1 Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Aug 19 2022 13:04:00 +0000
Subject: [PATCH 2/6] Merge test_scripts/common.sh into jp_validator.sh


---

diff --git a/test_scripts/common.sh b/test_scripts/common.sh
deleted file mode 100755
index 4414eb9..0000000
--- a/test_scripts/common.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/bash
-
-set -e
-
-if [ -z "${TEST_ARTIFACTS}" ]; then
-    TEST_ARTIFACTS="/var/share/test-artifacts/"
-fi
-
-export TEST_ARTIFACTS
diff --git a/test_scripts/jp_validator.sh b/test_scripts/jp_validator.sh
index 642683b..e1d490e 100755
--- a/test_scripts/jp_validator.sh
+++ b/test_scripts/jp_validator.sh
@@ -2,7 +2,9 @@
 
 set -e
 
-source ./common.sh
+if [ -z "${TEST_ARTIFACTS}" ]; then
+    TEST_ARTIFACTS="/var/share/test-artifacts/"
+fi
 
 if [ -z "${CONFIG_SRC_DIR}" ]; then
     CONFIG_SRC_DIR='../config/src'

From 8fea3a912be48d0e37b20a9f4a8aba376aaa9d9a Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Aug 19 2022 13:04:00 +0000
Subject: [PATCH 3/6] Move jp_validator.sh out of test_scripts/ directory


---

diff --git a/jp_validator.sh b/jp_validator.sh
new file mode 100755
index 0000000..5b58928
--- /dev/null
+++ b/jp_validator.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+set -e
+
+if [ -z "${TEST_ARTIFACTS}" ]; then
+    TEST_ARTIFACTS="/var/share/test-artifacts/"
+fi
+
+if [ -z "${CONFIG_SRC_DIR}" ]; then
+    CONFIG_SRC_DIR='config/src'
+fi
+
+if [ -z "${CONFIG_BIN_DIR}" ]; then
+    CONFIG_BIN_DIR='config/bin'
+fi
+
+mkdir -p "${CONFIG_BIN_DIR}"
+
+if [ -z "${JP_VALIDATOR_IMAGE}" ]; then
+    JP_VALIDATOR_IMAGE='quay.io/mizdebsk/javapackages-validator'
+fi
+
+# /mnt/envroot required by SymlinkConfig
+
+podman run --privileged\
+ --mount type=bind,source="${TEST_ARTIFACTS}",target='/mnt/test_artifacts/',readonly\
+ --mount type=bind,source="${CONFIG_SRC_DIR}",target='/mnt/config/src',readonly\
+ --mount type=bind,source="${CONFIG_BIN_DIR}",target='/mnt/config/bin'\
+ --mount type=bind,source='/',target='/mnt/envroot',readonly\
+ -it "${JP_VALIDATOR_IMAGE}" ${@} '/mnt/test_artifacts/'\
+;
diff --git a/test_scripts/jp_validator.sh b/test_scripts/jp_validator.sh
deleted file mode 100755
index e1d490e..0000000
--- a/test_scripts/jp_validator.sh
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/bash
-
-set -e
-
-if [ -z "${TEST_ARTIFACTS}" ]; then
-    TEST_ARTIFACTS="/var/share/test-artifacts/"
-fi
-
-if [ -z "${CONFIG_SRC_DIR}" ]; then
-    CONFIG_SRC_DIR='../config/src'
-fi
-
-if [ -z "${CONFIG_BIN_DIR}" ]; then
-    CONFIG_BIN_DIR='../config/bin'
-fi
-
-mkdir -p "${CONFIG_BIN_DIR}"
-
-if [ -z "${JP_VALIDATOR_IMAGE}" ]; then
-    JP_VALIDATOR_IMAGE='quay.io/mizdebsk/javapackages-validator'
-fi
-
-# /mnt/envroot required by SymlinkConfig
-
-podman run --privileged\
- --mount type=bind,source="${TEST_ARTIFACTS}",target='/mnt/test_artifacts/',readonly\
- --mount type=bind,source="${CONFIG_SRC_DIR}",target='/mnt/config/src',readonly\
- --mount type=bind,source="${CONFIG_BIN_DIR}",target='/mnt/config/bin'\
- --mount type=bind,source='/',target='/mnt/envroot',readonly\
- -it "${JP_VALIDATOR_IMAGE}" ${@} '/mnt/test_artifacts/'\
-;
diff --git a/tests.fmf b/tests.fmf
index 7c3335f..0b42dcd 100644
--- a/tests.fmf
+++ b/tests.fmf
@@ -1,6 +1,5 @@
 contact:
   - Marian Koncek <mkoncek@redhat.com>
-path: /test_scripts
 require:
   - bash
   - findutils

From 987692b1f0e2545d5b3990e9c690b00b1ca5d6aa Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Aug 19 2022 13:04:00 +0000
Subject: [PATCH 4/6] Set environment variables directly in fmf file


---

diff --git a/jp_validator.sh b/jp_validator.sh
index 5b58928..7e996bc 100755
--- a/jp_validator.sh
+++ b/jp_validator.sh
@@ -2,24 +2,8 @@
 
 set -e
 
-if [ -z "${TEST_ARTIFACTS}" ]; then
-    TEST_ARTIFACTS="/var/share/test-artifacts/"
-fi
-
-if [ -z "${CONFIG_SRC_DIR}" ]; then
-    CONFIG_SRC_DIR='config/src'
-fi
-
-if [ -z "${CONFIG_BIN_DIR}" ]; then
-    CONFIG_BIN_DIR='config/bin'
-fi
-
 mkdir -p "${CONFIG_BIN_DIR}"
 
-if [ -z "${JP_VALIDATOR_IMAGE}" ]; then
-    JP_VALIDATOR_IMAGE='quay.io/mizdebsk/javapackages-validator'
-fi
-
 # /mnt/envroot required by SymlinkConfig
 
 podman run --privileged\
diff --git a/tests.fmf b/tests.fmf
index 0b42dcd..ebcf5f4 100644
--- a/tests.fmf
+++ b/tests.fmf
@@ -4,6 +4,11 @@ require:
   - bash
   - findutils
   - podman
+environment:
+  TEST_ARTIFACTS: /var/share/test-artifacts
+  CONFIG_SRC_DIR: config/src
+  CONFIG_BIN_DIR: config/bin
+  JP_VALIDATOR_IMAGE: quay.io/mizdebsk/javapackages-validator
 
 /symlink:
   description: >

From 4253715afae5813745cc2b36ba897e8119ff8944 Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Aug 19 2022 13:04:00 +0000
Subject: [PATCH 5/6] Fail on undefined environment variables


---

diff --git a/jp_validator.sh b/jp_validator.sh
index 7e996bc..59eb4af 100755
--- a/jp_validator.sh
+++ b/jp_validator.sh
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-set -e
+set -eu
 
 mkdir -p "${CONFIG_BIN_DIR}"
 

From 98f71d0699c9a6fff2ff4be3af7f6f142c4a3380 Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Aug 19 2022 13:04:00 +0000
Subject: [PATCH 6/6] Don't run podman in interactive mode


---

diff --git a/jp_validator.sh b/jp_validator.sh
index 59eb4af..adf3cdc 100755
--- a/jp_validator.sh
+++ b/jp_validator.sh
@@ -6,10 +6,10 @@ mkdir -p "${CONFIG_BIN_DIR}"
 
 # /mnt/envroot required by SymlinkConfig
 
-podman run --privileged\
+exec podman run --privileged\
  --mount type=bind,source="${TEST_ARTIFACTS}",target='/mnt/test_artifacts/',readonly\
  --mount type=bind,source="${CONFIG_SRC_DIR}",target='/mnt/config/src',readonly\
  --mount type=bind,source="${CONFIG_BIN_DIR}",target='/mnt/config/bin'\
  --mount type=bind,source='/',target='/mnt/envroot',readonly\
- -it "${JP_VALIDATOR_IMAGE}" ${@} '/mnt/test_artifacts/'\
+ "${JP_VALIDATOR_IMAGE}" ${@} '/mnt/test_artifacts/'\
 ;

