dirname (918B)
- #!/usr/bin/env atf-sh
- # SPDX-FileCopyrightText: 2017-2022 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
- # SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
- atf_test_case noargs
- noargs_body() {
- atf_check -e "inline:usage: dirname string\n" -s exit:1 ../bin/dirname
- }
- atf_test_case one_slash
- one_slash_body() {
- atf_check -o "inline:/usr\n" ../bin/dirname "/usr/bin"
- }
- atf_test_case two_slash
- two_slash_body() {
- atf_check -o "inline:/usr\n" ../bin/dirname "/usr//bin"
- }
- atf_test_case two_dash
- two_dash_body() {
- atf_check -o "inline:/usr\n" ../bin/dirname -- "/usr//bin"
- }
- atf_test_case badarg
- badarg_body() {
- atf_check -s exit:1 -e "inline:usage: dirname string\n" ../bin/dirname -a "/usr//bin"
- }
- atf_init_test_cases() {
- cd "$(atf_get_srcdir)" || exit 1
- atf_add_test_case noargs
- atf_add_test_case badarg
- atf_add_test_case one_slash
- atf_add_test_case two_slash
- atf_add_test_case two_dash
- }