mirror of
https://github.com/opnsense/src.git
synced 2026-06-13 02:30:51 -04:00
cp: Improve to_root test case.
Since the bug we're testing involved path name construction, we don't
need to be root to test it; we can simply check the error message.
Fixes: 537fbf70f1
Sponsored by: Klara, Inc.
Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D50628
This commit is contained in:
parent
6d3d1fc3a3
commit
81df032813
1 changed files with 9 additions and 8 deletions
|
|
@ -573,22 +573,23 @@ dstmode_body()
|
|||
atf_test_case to_root cleanup
|
||||
to_root_head()
|
||||
{
|
||||
atf_set "require.user" "root"
|
||||
atf_set "require.user" "unprivileged"
|
||||
}
|
||||
to_root_body()
|
||||
{
|
||||
dst="$(atf_get ident).$$"
|
||||
dst="test.$(atf_get ident).$$"
|
||||
echo "$dst" >dst
|
||||
echo "foo" >"$dst"
|
||||
atf_check cp "$dst" /
|
||||
atf_check cmp -s "$dst" "/$dst"
|
||||
atf_check rm "/$dst"
|
||||
atf_check cp "$dst" //
|
||||
atf_check cmp -s "$dst" "/$dst"
|
||||
atf_check -s not-exit:0 \
|
||||
-e match:"^cp: /$dst: (Permission|Read-only)" \
|
||||
cp "$dst" /
|
||||
atf_check -s not-exit:0 \
|
||||
-e match:"^cp: /$dst: (Permission|Read-only)" \
|
||||
cp "$dst" //
|
||||
}
|
||||
to_root_cleanup()
|
||||
{
|
||||
(dst=$(cat dst) && [ -n "/$dst" ] && [ -f "/$dst" ] && rm "/$dst") || true
|
||||
(dst=$(cat dst) && rm "/$dst") 2>/dev/null || true
|
||||
}
|
||||
|
||||
atf_init_test_cases()
|
||||
|
|
|
|||
Loading…
Reference in a new issue