logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git
commit: dc097062f96b9b532cae969eed049b5e6bd4b9ce
parent 918aa6275a5478e825763321d1e44ab537d08d01
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Fri, 11 Feb 2022 19:46:07 +0100

test-bin/cat: Add tests on errors

Diffstat:

Mtest-bin/cat20++++++++++++++++++++
1 file changed, 20 insertions(+), 0 deletions(-)

diff --git a/test-bin/cat b/test-bin/cat @@ -29,6 +29,23 @@ nulldashinput_body() { atf_check ../bin/cat - </dev/null } +atf_test_case noperm +noperm_body() { + atf_check -s exit:1 -e 'inline:\nError opening ‘inputs/chmod_000’: Permission denied\n' ../bin/cat inputs/chmod_000 +} + +atf_test_case devfull +devfull_body() { + atf_check -s exit:1 -e 'inline:\nError writing: No space left on device\n' sh -c '../bin/cat inputs/all_bytes >/dev/full' + atf_check -s exit:1 -e 'inline:\nError writing: No space left on device\n' sh -c '../bin/cat <inputs/all_bytes >/dev/full' + atf_check -s exit:1 -e 'inline:\nError writing: No space left on device\n' sh -c '../bin/cat - <inputs/all_bytes >/dev/full' +} + +atf_test_case readslash +readslash_body() { + atf_check -s exit:1 -e 'inline:\nError reading ‘/’: Is a directory\n' ../bin/cat / +} + atf_init_test_cases() { cd "$(atf_get_srcdir)" atf_add_test_case allfile @@ -37,4 +54,7 @@ atf_init_test_cases() { atf_add_test_case nullfile atf_add_test_case nullinput atf_add_test_case nulldashinput + atf_add_test_case noperm + atf_add_test_case devfull + atf_add_test_case readslash }