ATF-devel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

test case submission needs review (fwd)



I received the attached off list but can't figure out how to use it or 
test it.        

Can someone teach me how to test this?

I get:

$ atf-run                                                       
atf-run: ERROR: Cannot locate the t_gnuseq file

$ atf-run t_gnuseq.sh                                           
atf-run: ERROR: Cannot locate the t_gnuseq file

Or help review it so it can be improved?

Once ready maybe install to src/usr.bin/seq/tests/

Thanks
# Tests for behaviour exactly matching that of seq(1) as found
# in GNU coreutils 6.9

atf_test_case single_nonpositive_argument #also used by Plan 9 seq
single_nonpositive_argument_head() {
    atf_set "descr" "Checks that seq produces no output when" \
        "given a single argument that's either zero or negative"
}

single_nonpositive_argument_body() {
    rm expout;
    touch expout;

    atf_check "$SEQ -10" 0 expout null
    atf_check "$SEQ -1" 0 expout null
    atf_check "$SEQ -12.3" 0 expout null
    atf_check "$SEQ 0" 0 expout null
}

single_nonpositive_argument_cleanup() {
    rm expout;
}

atf_test_case single_positive_argument #also used by Plan 9 seq
single_positive_argument_head() {
    atf_set "descr" "Checks that seq produces a simple" \
        "1-stepped sequence given a single positive argument"
}

single_positive_argument_body() {
    rm expout;
    touch expout;

    echo 1 >expout
    
    atf_check "$SEQ 1" 0 expout null
    
    echo 2 >>expout
    echo 3 >>expout
    echo 4 >>expout
    echo 5 >>expout

    atf_check "$SEQ 5" 0 expout null
    atf_check "$SEQ 5.3" 0 expout null 
}


single_positive_argument_cleanup() {
    rm expout;
}

atf_test_case neg_second_arg #also used by Plan 9 seq
neg_second_arg_head() {
    atf_set "descr" "Checks that seq produces no output" \
        "when given a negative second argument."
}

neg_second_arg_body() { 
    rm expout;
    touch expout;
    
    atf_check "$SEQ 0 -1" 0 expout null
    atf_check "$SEQ 0 -5" 0 expout null
    atf_check "$SEQ 5 -4" 0 expout null
    atf_check "$SEQ -2.3 -8" 0 expout null
}


neg_second_arg_cleanup() {
    rm expout;
}

atf_test_case zero_last_incrementing
zero_last_incrementing_head() {
    atf_set "descr" "Checks that there is no output when" \
        "the last argument is zero, the first argument is" \
        "non-zero, but the step is positive."
}

zero_last_incrementing_body() {
    rm expout;
    touch expout;

    atf_check "$SEQ 4 32 0" 0 expout null
}

atf_test_case zero_last_zero_increment
zero_last_zero_increment_head() {
    atf_set "descr" "Checks that there is no output when" \
        "the last argument is zero, the first argument is" \
        "positive, and the step is zero"
}

zero_last_zero_increment_body() {
    rm expout;
    touch expout;

    atf_check "$SEQ 15 0 0" 0 expout null
}


# rewrite completely
atf_test_case zero_step_decrementing_fromzero
zero_step_decrementing_fromzero_head() {
    atf_set "descr" "Checks for 'correct' behaviour when" \
        "the step argument is zero and seq is given a " \
        "decreasing sequence starting at zero."
}

zero_step_decrementing_fromzero_body() {
    echo 0 > expout;

    atf_check "$SEQ 0 15 0" 0 expout null
}




atf_test_case zero_increment
zero_increment_head() {
    atf_set "descr" "Checks for 'correct' behaviour when" \
        "given an incrementing sequence with a zero step argument"
    atf_set "require.progs" "head"
}

zero_increment_body() {
    rm expout;
    touch expout;

    echo -15 > expout;
    echo -15 >> expout;
    echo -15 >> expout;
    echo -15 >> expout;
    echo -15 >> expout;
7
# 5 is presumed to be equal to infinity here.
    atf_check "$SEQ -15 0 -15 | head -n 5" 0 expout null 

    echo 3 > expout;
    echo 3 >> expout;
    echo 3 >> expout;
    echo 3 >> expout;
    echo 3 >> expout;

    atf_check "$SEQ 3 0 15 | head -n 5" 0 expout null
}

atf_test_case zero_decrement
zero_decrement_head() {
    atf_set "descr" "Checks for 'correct' behaviour when" \
        "given an decreasing sequence with a zero step argument"
}

zero_decrement_body() {
    rm expout;
    touch expout;

    atf_check "$SEQ 1 0 0" 0 expout null
    atf_check "$SEQ 0 0 -10" 0 expout null
}


atf_init_test_cases() {
    SEQ=`atf_config_get seq seq`;

    atf_add_test_case single_nonpositive_argument
    atf_add_test_case single_positive_argument
    atf_add_test_case neg_second_arg
    atf_add_test_case zero_last_incrementing
    atf_add_test_case zero_last_zero_increment
    atf_add_test_case zero_step_decrementing_fromzero
    atf_add_test_case zero_increment
    atf_add_test_case zero_decrement
}

Content-Type: application/X-atf-atffile; version="1"

prop: test-suite = "seq"

tp: t_gnuseq


Home | Main Index | Thread Index | Old Index