Skip to content

Commit

Permalink
Add Debian Testing to the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
harshula committed Mar 7, 2023
1 parent 16ae9cb commit 02cdf56
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 0 deletions.
97 changes: 97 additions & 0 deletions tests/resources/distros/debiantesting/bin/lsb_release
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/bin/sh

# SPDX-FileCopyrightText: 2021-2022 Gioele Barabucci
# SPDX-License-Identifier: ISC

set -eu

export LC_ALL="C.UTF-8"

help () {
cat <<-EOD
Usage: lsb_release [options]
Options:
-h, --help show this help message and exit
-v, --version show LSB modules this system supports
-i, --id show distributor ID
-d, --description show description of this distribution
-r, --release show release number of this distribution
-c, --codename show code name of this distribution
-a, --all show all of the above information
-s, --short show requested information in short format
EOD
exit
}

show_id=false
show_desc=false
show_release=false
show_codename=false
short_format=false

options=$(getopt --name lsb_release -o hvidrcas -l help,version,id,description,release,codename,all,short -- "$@") || exit 2
eval set -- "$options"
while [ $# -gt 0 ] ; do
case "$1" in
-h|--help) help ;;
-v|--version) ;;
-i|--id) show_id=true ;;
-d|--description) show_desc=true ;;
-r|--release) show_release=true ;;
-c|--codename) show_codename=true ;;
-a|--all) show_id=true ; show_desc=true ; show_release=true ; show_codename=true ;;
-s|--short) short_format=true ;;
*) break ;;
esac
shift
done

display_line () {
label="$1"
value="$2"

if $short_format ; then
printf "%s\n" "$value"
else
printf "%s:\t%s\n" "$label" "$value"
fi
}

# Load release info from standard identification data files
[ -f /usr/lib/os-release ] && os_release=/usr/lib/os-release
[ -f /etc/os-release ] && os_release=/etc/os-release
[ "${LSB_OS_RELEASE-x}" != "x" ] && [ -f "$LSB_OS_RELEASE" ] && os_release="$LSB_OS_RELEASE"
[ "${os_release-x}" != "x" ] && . "$os_release"

# Mimic the output of Debian's Python-based lsb_release
# Capitalize ID
: "${ID=}"
ID="$(printf "%s" "$ID" | cut -c1 | tr '[:lower:]' '[:upper:]')$(printf "%s" "$ID" | cut -c2-)"
# Use NAME if set and different from ID only in capitalization.
if [ "${NAME-x}" != "x" ] ; then
lower_case_id=$(printf "%s" "$ID" | tr '[:upper:]' '[:lower:]')
lower_case_name=$(printf "%s" "$NAME" | tr '[:upper:]' '[:lower:]')
if [ "${lower_case_id}" = "${lower_case_name}" ] ; then
ID="$NAME"
fi
fi

# Generate minimal standard-conform output (if stdout is a TTY).
[ -t 1 ] && echo "No LSB modules are available." >& 2

if $show_id ; then
display_line "Distributor ID" "${ID:-n/a}"
fi

if $show_desc ; then
display_line "Description" "${PRETTY_NAME:-n/a}"
fi

if $show_release ; then
display_line "Release" "${VERSION_ID:-n/a}"
fi

if $show_codename ; then
display_line "Codename" "${VERSION_CODENAME:-n/a}"
fi
1 change: 1 addition & 0 deletions tests/resources/distros/debiantesting/etc/debian_version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bookworm/sid
7 changes: 7 additions & 0 deletions tests/resources/distros/debiantesting/etc/os-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PRETTY_NAME="Debian GNU/Linux bookworm/sid"
NAME="Debian GNU/Linux"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
26 changes: 26 additions & 0 deletions tests/test_distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,18 @@ def test_debian10_os_release(self) -> None:
}
self._test_outcome(desired_outcome)

def test_debiantesting_os_release(self) -> None:
desired_outcome = {
"id": "debian",
"name": "Debian GNU/Linux",
"pretty_name": "Debian GNU/Linux bookworm/sid",
"version": "bookworm/sid",
"pretty_version": "bookworm/sid (bookworm)",
"best_version": "bookworm/sid",
"codename": "bookworm",
}
self._test_outcome(desired_outcome)

def test_fedora19_os_release(self) -> None:
desired_outcome = {
"id": "fedora",
Expand Down Expand Up @@ -1255,6 +1267,20 @@ def test_debian10_release(self) -> None:
self._test_outcome(desired_outcome)
self._test_non_existing_release_file()

def test_debiantesting_release(self) -> None:
desired_outcome = {
"id": "debian",
"name": "Debian GNU/Linux",
"pretty_name": "Debian GNU/Linux bookworm/sid",
"version": "bookworm/sid",
"pretty_version": "bookworm/sid (bookworm)",
"best_version": "bookworm/sid",
"codename": "bookworm",
"major_version": "",
}
self._test_outcome(desired_outcome)
self._test_non_existing_release_file()

def test_exherbo_release(self) -> None:
desired_outcome = {
"id": "exherbo",
Expand Down

0 comments on commit 02cdf56

Please sign in to comment.