diff options
author | David Kalnischkies <david@kalnischkies.de> | 2022-03-28 15:19:11 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2022-04-01 14:15:26 +0200 |
commit | f6438ea9e726a1c13ce8d90ac78cc272346ab0f8 (patch) | |
tree | 742ab3be95f07b0b488f31ad621af8dec513ae82 /test | |
parent | f0227a5d4c0a2576348417c658ee93bfa19dc6a0 (diff) |
Document tagfile-keys.h as internal to apt
The previous regime of the file was to sort it on insert, but that
changes the values in the generated enum, which is fine as long as we
only use it in libapt itself, but breaks on other users.
The header was always intended to be private to apt itself, so we just
document this here now and lay the ground work to have the file in the
future only appended to, so that it remains sufficiently ABI stable that
we can use it outside the library in our apt tools.
We also remove some fields apt is unlikely to need or only uses in
certain cases outside of any (speed) critical path to have enough room
to add more fields soon as currently we are limited to 128 fields max
and it would be sad if we use up that allowance entirely already.
Diffstat (limited to 'test')
-rwxr-xr-x | test/integration/test-apt-tagfile-fields-order | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/integration/test-apt-tagfile-fields-order b/test/integration/test-apt-tagfile-fields-order index 804d49c86..d7bf0d137 100755 --- a/test/integration/test-apt-tagfile-fields-order +++ b/test/integration/test-apt-tagfile-fields-order @@ -35,6 +35,37 @@ comparelsts() { fi } +grep -v '^#' "${SOURCEDIRECTORY}/apt-pkg/tagfile-keys.list" > tagfile-keys.list +# Hardcoding this is a bit silly, but it might help preventing issues… +msgtest 'File is append only: do not sort, remove or insert keys in' 'tagfile-keys.list' +testequal --nomsg 'Version' sed '73q;d' tagfile-keys.list + +msgtest 'List has fewer entries than pkgTagSection buckets' 'tagfile-keys.list' +ENTRIES_LIST="$(wc -l tagfile-keys.list | cut -d' ' -f 1)" +ENTRIES_BUCKET="$(grep -m 1 'AlphaIndexes\[' "${SOURCEDIRECTORY}/apt-pkg/tagfile.h" | sed -e 's#.*\[\([0-9]\+\)\].*#\1#')" +if test $ENTRIES_LIST -lt $ENTRIES_BUCKET; then + msgpass +else + echo + echo "List has $ENTRIES_LIST entries, but pkgTagSection can only store $ENTRIES_BUCKET as AlphaIndexes" + msgfail +fi + +msgtest 'Check for duplicates in' 'tagfile-keys.list' +sort tagfile-keys.list > apt.lst +testempty --nomsg uniq --repeated 'apt.lst' + +msgtest 'Check that apt knows all fields it orders' 'itself' +grep -v "// NO_KEY: " "${SOURCEDIRECTORY}/apt-pkg/tagfile-order.c" | sed -ne 's#^ "\(.*\)",.*$#\1#p' | sort -u > dpkg.lst +comparelsts + +msgtest 'Check tagfile-keys.list does not contain' 'obsoleted and internal fields' +grep "// NO_KEY: " "${SOURCEDIRECTORY}/apt-pkg/tagfile-order.c" | sed -ne 's#^ "\(.*\)",.*$#\1#p' > obsolete.lst +sed -n -e's#^ *// *"\(.*\)",.*$#\1#p' "${SOURCEDIRECTORY}/apt-pkg/tagfile-order.c" >> obsolete.lst +sort -u obsolete.lst > obsolete-sorted.lst +sort obsolete-sorted.lst tagfile-keys.list > obsolete-keys.lst +testempty --nomsg uniq --repeat 'obsolete-keys.lst' + msgtest 'Check that apt knows all fields dpkg orders in' 'Packages' dpkg_field_ordered_list 'CTRL_INDEX_PKG' > dpkg.lst sed -ne 's#^ "\(.*\)",.*$#\1#p' "${SOURCEDIRECTORY}/apt-pkg/tagfile-order.c" | sed -n '/^Package$/,/^Package$/ p' | head -n -1 | sort > apt.lst |