diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 83a7e7bd..9a5edc6f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -51,6 +51,11 @@ jobs: cd osbuild python3 -m unittest -v test.test_objectstore + - name: Run test_osrelease + run: | + cd osbuild + python3 -m unittest -v test.test_osrelease + rpm_build: name: "RPM build" needs: diff --git a/test/os-release/fedora30 b/test/os-release/fedora30 new file mode 100644 index 00000000..9f0d60b3 --- /dev/null +++ b/test/os-release/fedora30 @@ -0,0 +1,21 @@ +NAME=Fedora +VERSION="30 (Workstation Edition)" +ID=fedora +VERSION_ID=30 +VERSION_CODENAME="" +PLATFORM_ID="platform:f30" +PRETTY_NAME="Fedora 30 (Workstation Edition)" +ANSI_COLOR="0;34" +LOGO=fedora-logo-icon +CPE_NAME="cpe:/o:fedoraproject:fedora:30" +HOME_URL="https://fedoraproject.org/" +DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f30/system-administrators-guide/" +SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help" +BUG_REPORT_URL="https://bugzilla.redhat.com/" +REDHAT_BUGZILLA_PRODUCT="Fedora" +REDHAT_BUGZILLA_PRODUCT_VERSION=30 +REDHAT_SUPPORT_PRODUCT="Fedora" +REDHAT_SUPPORT_PRODUCT_VERSION=30 +PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy" +VARIANT="Workstation Edition" +VARIANT_ID=workstation diff --git a/test/os-release/fedora31 b/test/os-release/fedora31 new file mode 100644 index 00000000..72050278 --- /dev/null +++ b/test/os-release/fedora31 @@ -0,0 +1,21 @@ +NAME=Fedora +VERSION="31 (Workstation Edition)" +ID=fedora +VERSION_ID=31 +VERSION_CODENAME="" +PLATFORM_ID="platform:f31" +PRETTY_NAME="Fedora 31 (Workstation Edition)" +ANSI_COLOR="0;34" +LOGO=fedora-logo-icon +CPE_NAME="cpe:/o:fedoraproject:fedora:31" +HOME_URL="https://fedoraproject.org/" +DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f31/system-administrators-guide/" +SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help" +BUG_REPORT_URL="https://bugzilla.redhat.com/" +REDHAT_BUGZILLA_PRODUCT="Fedora" +REDHAT_BUGZILLA_PRODUCT_VERSION=31 +REDHAT_SUPPORT_PRODUCT="Fedora" +REDHAT_SUPPORT_PRODUCT_VERSION=31 +PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy" +VARIANT="Workstation Edition" +VARIANT_ID=workstation diff --git a/test/os-release/fedora32 b/test/os-release/fedora32 new file mode 100644 index 00000000..e8f9713d --- /dev/null +++ b/test/os-release/fedora32 @@ -0,0 +1,21 @@ +NAME=Fedora +VERSION="32 (Workstation Edition)" +ID=fedora +VERSION_ID=32 +VERSION_CODENAME="" +PLATFORM_ID="platform:f32" +PRETTY_NAME="Fedora 32 (Workstation Edition)" +ANSI_COLOR="0;34" +LOGO=fedora-logo-icon +CPE_NAME="cpe:/o:fedoraproject:fedora:32" +HOME_URL="https://fedoraproject.org/" +DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/%{doc_version}/system-administrators-guide/" +SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help" +BUG_REPORT_URL="https://bugzilla.redhat.com/" +REDHAT_BUGZILLA_PRODUCT="Fedora" +REDHAT_BUGZILLA_PRODUCT_VERSION=32 +REDHAT_SUPPORT_PRODUCT="Fedora" +REDHAT_SUPPORT_PRODUCT_VERSION=32 +PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy" +VARIANT="Workstation Edition" +VARIANT_ID=workstation diff --git a/test/os-release/fedora33 b/test/os-release/fedora33 new file mode 100644 index 00000000..eb3d8d50 --- /dev/null +++ b/test/os-release/fedora33 @@ -0,0 +1,21 @@ +NAME=Fedora +VERSION="33 (Workstation Edition)" +ID=fedora +VERSION_ID=33 +VERSION_CODENAME="" +PLATFORM_ID="platform:f30" +PRETTY_NAME="Fedora 33 (Workstation Edition)" +ANSI_COLOR="0;34" +LOGO=fedora-logo-icon +CPE_NAME="cpe:/o:fedoraproject:fedora:33" +HOME_URL="https://fedoraproject.org/" +DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f30/system-administrators-guide/" +SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help" +BUG_REPORT_URL="https://bugzilla.redhat.com/" +REDHAT_BUGZILLA_PRODUCT="Fedora" +REDHAT_BUGZILLA_PRODUCT_VERSION=33 +REDHAT_SUPPORT_PRODUCT="Fedora" +REDHAT_SUPPORT_PRODUCT_VERSION=33 +PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy" +VARIANT="Workstation Edition" +VARIANT_ID=workstation diff --git a/test/os-release/rhel81 b/test/os-release/rhel81 new file mode 100644 index 00000000..216c1d22 --- /dev/null +++ b/test/os-release/rhel81 @@ -0,0 +1,16 @@ +NAME="Red Hat Enterprise Linux" +VERSION="8.1 (Ootpa)" +ID="rhel" +ID_LIKE="fedora" +VERSION_ID="8.1" +PLATFORM_ID="platform:el8" +PRETTY_NAME="Red Hat Enterprise Linux 8.1 (Ootpa)" +ANSI_COLOR="0;31" +CPE_NAME="cpe:/o:redhat:enterprise_linux:8.1:GA" +HOME_URL="https://www.redhat.com/" +BUG_REPORT_URL="https://bugzilla.redhat.com/" + +REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8" +REDHAT_BUGZILLA_PRODUCT_VERSION=8.1 +REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux" +REDHAT_SUPPORT_PRODUCT_VERSION="8.1" diff --git a/test/os-release/rhel82 b/test/os-release/rhel82 new file mode 100644 index 00000000..30542561 --- /dev/null +++ b/test/os-release/rhel82 @@ -0,0 +1,16 @@ +NAME="Red Hat Enterprise Linux" +VERSION="8.2 (Ootpa)" +ID="rhel" +ID_LIKE="fedora" +VERSION_ID="8.2" +PLATFORM_ID="platform:el8" +PRETTY_NAME="Red Hat Enterprise Linux 8.2 Beta (Ootpa)" +ANSI_COLOR="0;31" +CPE_NAME="cpe:/o:redhat:enterprise_linux:8.2:beta" +HOME_URL="https://www.redhat.com/" +BUG_REPORT_URL="https://bugzilla.redhat.com/" + +REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8" +REDHAT_BUGZILLA_PRODUCT_VERSION=8.2 +REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux" +REDHAT_SUPPORT_PRODUCT_VERSION="8.2 Beta" diff --git a/test/os-release/ubuntu1804 b/test/os-release/ubuntu1804 new file mode 100644 index 00000000..dc5a5c2a --- /dev/null +++ b/test/os-release/ubuntu1804 @@ -0,0 +1,12 @@ +NAME="Ubuntu" +VERSION="18.04.3 LTS (Bionic Beaver)" +ID=ubuntu +ID_LIKE=debian +PRETTY_NAME="Ubuntu 18.04.3 LTS" +VERSION_ID="18.04" +HOME_URL="https://www.ubuntu.com/" +SUPPORT_URL="https://help.ubuntu.com/" +BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" +PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" +VERSION_CODENAME=bionic +UBUNTU_CODENAME=bionic diff --git a/test/test_osrelease.py b/test/test_osrelease.py new file mode 100644 index 00000000..1c8578cd --- /dev/null +++ b/test/test_osrelease.py @@ -0,0 +1,17 @@ +import os +import unittest + +import osbuild + +class TestOSRelease(unittest.TestCase): + def test_non_existant(self): + self.assertRaises(FileNotFoundError, osbuild.pipeline.detect_os, "💩") + + def test_detect_os(self): + """Test host os detection. test/os-release contains the os-release files + for all supported runners. + """ + for entry in os.scandir("test/os-release"): + with self.subTest(entry.name): + self.assertEqual(osbuild.pipeline.detect_os(entry.path), entry.name) +