Files
shadow/tests/libsubid/04_nss/test_range
Serge Hallyn d55367bb16 tests/: Support run_some from exported tarball
common/config.sh currently tries to find the top directory by looking
for .git.  There are also many places under tests/ where we use
hard-coded ../../.. to find things like ${TOP_DIR}/lib.

We don't actually ship the tests with 'make dist'.  So we will
be exporting tests/ as a separate tarball.  In particular, I want
to then import this in the debian package.  However, there it will
be under shadow.git/debian/tests, not shadow.git/tests.

To support this, accept the environment variable BUILD_BASE_DIR,
which should point to shadow.git.

An alternative would be to move the tests to their own git
tree.  However, keeping tests in separate git tree tends to
lead to repos getting out of sync.  And we'd still need to accept
something like BUILD_BASE_DIR.

Note there are a lot of tests under run-all, which I'm not converting
as they currently are not being run in CI, so I'm more likely to
break something.

Changelog:
  2024 05 26: Incorporate feedback from alejandro-colomar

Link: <https://salsa.debian.org/debian/shadow/-/merge_requests/21>
Link: <https://salsa.debian.org/debian/shadow/-/merge_requests/22>
Cc: Chris Hofstaedtler <zeha@debian.org>
Signed-off-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2024-06-26 23:59:07 +02:00

53 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
set -x
echo "starting check_range tests"
export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
touch /etc/nsswitch.conf
mount --bind ./nsswitch3.conf /etc/nsswitch.conf
cleanup1() {
umount /etc/nsswitch.conf
}
trap cleanup1 EXIT HUP INT TERM
${build_path}/src/check_subid_range user1 u 100000 65535
if [ $? -ne 0 ]; then
exit 1
fi
${build_path}/src/check_subid_range user2 u 100000 65535
if [ $? -eq 0 ]; then
exit 1
fi
${build_path}/src/check_subid_range unknown u 100000 65535
if [ $? -eq 0 ]; then
exit 1
fi
${build_path}/src/check_subid_range error u 100000 65535
if [ $? -eq 0 ]; then
exit 1
fi
${build_path}/src/check_subid_range user1 u 1000 65535
if [ $? -eq 0 ]; then
exit 1
fi
umount /etc/nsswitch.conf
mount --bind ./nsswitch1.conf /etc/nsswitch.conf
touch /etc/subuid /etc/subgid
mount --bind ./empty /etc/subuid
cleanup2() {
umount /etc/subuid
umount /etc/nsswitch.conf
}
trap cleanup2 EXIT HUP INT TERM
${build_path}/src/check_subid_range user1 u 100000 65535
if [ $? -eq 0 ]; then
exit 1
fi
echo "check_range tests complete"
exit 0