Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/praudit/tests/praudit_test.sh
- This file was added.
# | |||||
# Copyright (c) 2018 Aniket Pandey | |||||
# | |||||
# Redistribution and use in source and binary forms, with or without | |||||
# modification, are permitted provided that the following conditions | |||||
# are met: | |||||
# 1. Redistributions of source code must retain the above copyright | |||||
# notice, this list of conditions and the following disclaimer. | |||||
# 2. Redistributions in binary form must reproduce the above copyright | |||||
# notice, this list of conditions and the following disclaimer in the | |||||
# documentation and/or other materials provided with the distribution. | |||||
# | |||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | |||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
# SUCH DAMAGE. | |||||
# | |||||
# $FreeBSD$ | |||||
# | |||||
atf_test_case praudit_delim_comma | |||||
praudit_delim_comma_head() | |||||
{ | |||||
atf_set "descr" "Verify that comma delimiter is present with -d ',' cmd" | |||||
} | |||||
asomers: As these assertions are all independent, you should split them into separate test cases. | |||||
praudit_delim_comma_body() | |||||
{ | |||||
atf_check -o file:$(atf_get_srcdir)/del_comma \ | |||||
praudit -d "," $(atf_get_srcdir)/trail | |||||
Done Inline ActionsDon't assert that the exit status is 1. That's a bug. Fix the bug instead. asomers: Don't assert that the exit status is 1. That's a bug. Fix the bug instead. | |||||
} | |||||
atf_test_case praudit_delim_underscore | |||||
praudit_delim_underscore_head() | |||||
{ | |||||
atf_set "descr" "Verify that underscore delimiter is present with -d _" | |||||
} | |||||
praudit_delim_underscore_body() | |||||
{ | |||||
atf_check -o file:$(atf_get_srcdir)/del_underscore \ | |||||
praudit -d "_" $(atf_get_srcdir)/trail | |||||
} | |||||
atf_test_case praudit_no_args | |||||
praudit_no_args_head() | |||||
{ | |||||
atf_set "descr" "Verify that praudit outputs default form without " \ | |||||
"any arguments" | |||||
} | |||||
praudit_no_args_body() | |||||
{ | |||||
atf_check -o file:$(atf_get_srcdir)/no_args \ | |||||
praudit $(atf_get_srcdir)/trail | |||||
} | |||||
atf_test_case praudit_numeric_form | |||||
praudit_numeric_form_head() | |||||
{ | |||||
atf_set "descr" "Verify that praudit outputs the numeric form " \ | |||||
"with -n flag" | |||||
} | |||||
praudit_numeric_form_body() | |||||
{ | |||||
atf_check -o file:$(atf_get_srcdir)/numeric_form \ | |||||
praudit -n $(atf_get_srcdir)/trail | |||||
} | |||||
atf_test_case praudit_raw_form | |||||
praudit_raw_form_head() | |||||
{ | |||||
atf_set "descr" "Verify that praudit outputs the raw form with -r flag" | |||||
} | |||||
praudit_raw_form_body() | |||||
{ | |||||
atf_check -o file:$(atf_get_srcdir)/raw_form \ | |||||
praudit -r $(atf_get_srcdir)/trail | |||||
} | |||||
atf_test_case praudit_same_line | |||||
praudit_same_line_head() | |||||
{ | |||||
atf_set "descr" "Verify that praudit outputs the trail in the same " \ | |||||
"line with -l flag" | |||||
} | |||||
praudit_same_line_body() | |||||
{ | |||||
atf_check -o file:$(atf_get_srcdir)/same_line \ | |||||
praudit -l $(atf_get_srcdir)/trail | |||||
} | |||||
atf_test_case praudit_short_form | |||||
praudit_short_form_head() | |||||
{ | |||||
atf_set "descr" "Verify that praudit outputs the short form " \ | |||||
"with -s flag" | |||||
} | |||||
praudit_short_form_body() | |||||
{ | |||||
atf_check -o file:$(atf_get_srcdir)/short_form \ | |||||
praudit -s $(atf_get_srcdir)/trail | |||||
} | |||||
atf_test_case praudit_xml_form | |||||
praudit_xml_form_head() | |||||
{ | |||||
atf_set "descr" "Verify that praudit outputs the XML file with -x flag" | |||||
} | |||||
praudit_xml_form_body() | |||||
{ | |||||
atf_check -o file:$(atf_get_srcdir)/xml_form \ | |||||
praudit -x $(atf_get_srcdir)/trail | |||||
} | |||||
atf_test_case praudit_piped_through_tail | |||||
praudit_piped_through_tail_head() | |||||
{ | |||||
atf_set "descr" "Verify that stdout is empty on normal praudit " \ | |||||
"command but it prints out the last segment of " \ | |||||
"trail which is not corrupted, with -p flag on " \ | |||||
"piping through tail(1)" | |||||
} | |||||
praudit_piped_through_tail_body() | |||||
{ | |||||
# default -s exit:0 -o empty | |||||
atf_check praudit $(atf_get_srcdir)/corrupted | |||||
Not Done Inline ActionsIs it a requirement that praudit _can't_ work with a truncated record without -p? I don't think it is. So you should probably remove the first assertion. Also, could you somewhere include a textual description of the difference between the normal and the truncated records? asomers: Is it a requirement that praudit _can't_ work with a truncated record without `-p`? I don't… | |||||
Not Done Inline Actions@asomers I had added extra random texts in the trail (before correct audit record) and verified that aniketp: @asomers I had added extra random texts in the trail (before correct audit record) and verified… | |||||
atf_check -o file:$(atf_get_srcdir)/no_args \ | |||||
Not Done Inline ActionsI doesn't read from the end. It still reads from the front; but it syncs to the start of the first whole record before it does anything else. asomers: I doesn't read from the end. It still reads from the front; but it syncs to the start of the… | |||||
praudit -p $(atf_get_srcdir)/corrupted | |||||
} | |||||
atf_test_case praudit_raw_short_exclusive | |||||
praudit_raw_short_exclusive_head() | |||||
{ | |||||
atf_set "descr" "Verify that praudit outputs usage message on stderr " \ | |||||
"when both raw and short options are specified" | |||||
} | |||||
praudit_raw_short_exclusive_body() | |||||
{ | |||||
atf_check -s exit:1 -e match:"usage: praudit" \ | |||||
praudit -rs $(atf_get_srcdir)/trail | |||||
} | |||||
atf_init_test_cases() | |||||
{ | |||||
atf_add_test_case praudit_delim_comma | |||||
atf_add_test_case praudit_delim_underscore | |||||
atf_add_test_case praudit_no_args | |||||
atf_add_test_case praudit_numeric_form | |||||
atf_add_test_case praudit_raw_form | |||||
atf_add_test_case praudit_same_line | |||||
atf_add_test_case praudit_short_form | |||||
atf_add_test_case praudit_xml_form | |||||
atf_add_test_case praudit_piped_through_tail | |||||
atf_add_test_case praudit_raw_short_exclusive | |||||
} |
As these assertions are all independent, you should split them into separate test cases.