logo

utils-std

Collection of commonly available Unix tools
commit: f66efb9d62357412cabf688c9fbe0ae852f460b6
parent ef4d85d5ef1b31c708c7192992ebb0869347b111
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Thu, 14 Mar 2024 01:21:19 +0100

test-cmd/df: new

Diffstat:

Mtest-cmd/Kyuafile1+
Atest-cmd/df24++++++++++++++++++++++++
2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/test-cmd/Kyuafile b/test-cmd/Kyuafile @@ -9,6 +9,7 @@ atf_test_program{name="base64", timeout=1} atf_test_program{name="basename", timeout=1} atf_test_program{name="cat", timeout=1} atf_test_program{name="date", timeout=1} +atf_test_program{name="df", timeout=1} atf_test_program{name="dirname", timeout=1} atf_test_program{name="echo", timeout=1} atf_test_program{name="env", timeout=1} diff --git a/test-cmd/df b/test-cmd/df @@ -0,0 +1,24 @@ +#!/usr/bin/env atf-sh +# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me> +# SPDX-License-Identifier: MPL-2.0 + +atf_test_case posix +posix_body() { + # stderr ignored because not all filesystems allow statvfs from a normal user. + # For example tracefs aka "/sys/kernel/debug/tracing" on Linux. + + atf_check -e ignore -o 'match:Filesystem *512-blocks *Used *Available *Capacity *Mounted on' sh -c '../cmd/df -P | head -1' + atf_check -e ignore -o 'match:Filesystem *1024-blocks *Used *Available *Capacity *Mounted on' sh -c '../cmd/df -Pk | head -1' + + atf_check -e ignore -o 'match:^[^ ]* *[0-9]* *[0-9]* *[0-9]* *[0-9]*% [^ ]$' sh -c '../cmd/df -P | sed -n 2,\$p' + atf_check -e ignore -o 'match:^[^ ]* *[0-9]* *[0-9]* *[0-9]* *[0-9]*% [^ ]$' sh -c '../cmd/df -Pk | sed -n 2,\$p' + + atf_check -e ignore -o 'match:^[^ ]* *[0-9]* *[0-9]* *[0-9]* *[0-9]*% [^ ]$' sh -c '../cmd/df -Pa | sed -n 2,\$p' + atf_check -e ignore -o 'match:^[^ ]* *[0-9]* *[0-9]* *[0-9]* *[0-9]*% [^ ]$' sh -c '../cmd/df -Pak | sed -n 2,\$p' +} + +atf_init_test_cases() { + cd "$(atf_get_srcdir)" || exit 1 + + atf_add_test_case posix +}