Skip to content

Commit

Permalink
Add a simple FILE_SIZE test.
Browse files Browse the repository at this point in the history
Ensures that counters for disk usage are correct.
  • Loading branch information
jperkin committed Jul 31, 2023
1 parent 3e42df8 commit 1bbf3dc
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ BATS_JOBS?= -j 1
PKGIN?= pkgin

SUITES= autoremove break-depends categories conflict empty
SUITES+= file-dl http-dl invalid order provreq
SUITES+= file-dl file-size http-dl invalid order provreq
SUITES+= install partial-upgrade upgrade
SUITES+= switch-repo

Expand Down
111 changes: 111 additions & 0 deletions suite/file-size.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/usr/bin/env bats
#
# Test FILE_SIZE, SIZE_PKG, etc. Other test suites ignore these values as it
# can be too much work to update them every time a minor change is made to the
# test. This one ensures they are accurate.
#
# In particular, "-F none" is specified to ensure compression is not used which
# will almost certainly change across different systems.
#

SUITE="file-size"

load common

setup_file()
{
BUILD_DATE="${BUILD_DATE_1}"
PACKAGES="${SUITE_WORKDIR}/repo1"
PKG_WORKDIR="${SUITE_WORKDIR}/pkg1"

create_pkg_buildinfo "file-size-1.0" \
"BUILD_DATE=${BUILD_DATE}" \
"CATEGORIES=cat" \
"PKGPATH=cat/file-size"
create_pkg_comment "file-size-1.0" "Package has a static FILE_SIZE"
create_pkg_file "file-size-1.0" "share/doc/file-size" \
"Some text to start with."
create_pkg "file-size-1.0" -F none

create_pkg_summary "${REPO_DATE_1}"

BUILD_DATE="${BUILD_DATE_2}"
PACKAGES="${SUITE_WORKDIR}/repo2"
PKG_WORKDIR="${SUITE_WORKDIR}/pkg2"

create_pkg_buildinfo "file-size-2.0" \
"BUILD_DATE=${BUILD_DATE}" \
"CATEGORIES=cat" \
"PKGPATH=cat/file-size"
create_pkg_comment "file-size-2.0" "Package has a static FILE_SIZE"
create_pkg_file "file-size-2.0" "share/doc/file-size" \
"Some more text, more than previously."
create_pkg "file-size-2.0" -F none

create_pkg_summary "${REPO_DATE_2}"

BUILD_DATE="${BUILD_DATE_3}"
PACKAGES="${SUITE_WORKDIR}/repo3"
PKG_WORKDIR="${SUITE_WORKDIR}/pkg3"

create_pkg_buildinfo "file-size-3.0" \
"BUILD_DATE=${BUILD_DATE}" \
"CATEGORIES=cat" \
"PKGPATH=cat/file-size"
create_pkg_comment "file-size-3.0" "Package has a static FILE_SIZE"
create_pkg_file "file-size-3.0" "share/doc/file-size" "Less text."
create_pkg "file-size-3.0" -F none

create_pkg_summary "${REPO_DATE_3}"

PACKAGES="${SUITE_WORKDIR}/packages"
ln -s repo1 ${SUITE_WORKDIR}/packages
start_httpd
}
teardown_file()
{
stop_httpd
}

@test "${SUITE} install first package using pkg_add" {
export PKG_PATH=${PACKAGES}/All
run pkg_add file-size
[ ${status} -eq 0 ]
[ -z "${output}" ]
}

@test "${SUITE} test first upgrade (increase)" {
run rm ${SUITE_WORKDIR}/packages
[ ${status} -eq 0 ]

run ln -s repo2 ${SUITE_WORKDIR}/packages
[ ${status} -eq 0 ]

if [ ${PKGIN_VERSION} -lt 001000 ]; then
run pkgin -fy update
[ ${status} -eq 0 ]
fi

run pkgin -y upgrade
[ ${status} -eq 0 ]

output_match "13K to download, 13B to install"
}

@test "${SUITE} test second upgrade (decrease)" {
run rm ${SUITE_WORKDIR}/packages
[ ${status} -eq 0 ]

run ln -s repo3 ${SUITE_WORKDIR}/packages
[ ${status} -eq 0 ]

if [ ${PKGIN_VERSION} -lt 001000 ]; then
run pkgin -fy update
[ ${status} -eq 0 ]
fi

run pkgin -y upgrade
[ ${status} -eq 0 ]

output_match "13K to download, -27B to install"
}

0 comments on commit 1bbf3dc

Please sign in to comment.