+
+listcurrentlistsdirectory() {
+ find rootdir/var/lib/apt/lists -maxdepth 1 -type d | while read line; do
+ stat --format '%U:%G:%a:%n' "$line"
+ done
+ find rootdir/var/lib/apt/lists -maxdepth 1 \! -type d | while read line; do
+ stat --format '%U:%G:%a:%s:%y:%n' "$line"
+ done
+}
+
+### The following tests are run by most test methods automatically to check
+### general things about commands executed without writing the test every time.
+
+aptautotest() {
+ local TESTCALL="$1"
+ local CMD="$2"
+ local FIRSTOPT="$3"
+ local AUTOTEST="aptautotest_$(basename "$CMD" | tr -d '-')_$(echo "$FIRSTOPT" | tr -d '-')"
+ if command -v $AUTOTEST >/dev/null; then
+ shift 3
+ # save and restore the *.output files from other tests
+ # as we might otherwise override them in these automatic tests
+ rm -rf ${TMPWORKINGDIRECTORY}/rootdir/tmp-before
+ mv ${TMPWORKINGDIRECTORY}/rootdir/tmp ${TMPWORKINGDIRECTORY}/rootdir/tmp-before
+ mkdir ${TMPWORKINGDIRECTORY}/rootdir/tmp
+ $AUTOTEST "$TESTCALL" "$@"
+ rm -rf ${TMPWORKINGDIRECTORY}/rootdir/tmp-aptautotest
+ mv ${TMPWORKINGDIRECTORY}/rootdir/tmp ${TMPWORKINGDIRECTORY}/rootdir/tmp-aptautotest
+ mv ${TMPWORKINGDIRECTORY}/rootdir/tmp-before ${TMPWORKINGDIRECTORY}/rootdir/tmp
+ fi
+}
+
+aptautotest_aptget_update() {
+ if ! test -d "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists"; then return; fi
+ # all copied files are properly chmodded
+ for file in $(find "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists" -maxdepth 1 -type f); do
+ testfilestats "$file" '%U:%G:%a' '=' "${USER}:${USER}:644"
+ done
+}
+aptautotest_apt_update() { aptautotest_aptget_update "$@"; }