From f6438ea9e726a1c13ce8d90ac78cc272346ab0f8 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 28 Mar 2022 15:19:11 +0200 Subject: 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. --- test/integration/test-apt-tagfile-fields-order | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'test') 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 -- cgit v1.2.3-70-g09d2