1#- 2# SPDX-License-Identifier: BSD-2-Clause 3# 4# Copyright (c) 2024 Michal Scigocki <michal.os@hotmail.com> 5# 6 7. $(atf_get_srcdir)/syslogd_format_test_common.sh 8 9# Basic format tests 10# Single server, logging to local socket (inet disabled) 11setup_basic_format_test() 12{ 13 local format="$1" 14 local logfile="$2" 15 16 printf "user.debug\t${logfile}\n" > "${SYSLOGD_CONFIG}" 17 18 syslogd_start \ 19 -O "${format}" \ 20 -N \ 21 -ss 22 23 syslogd_log -p user.debug -t "${TAG}" \ 24 -h "${SYSLOGD_LOCAL_SOCKET}" \ 25 -H "${HOSTNAME}" "${MSG}" 26} 27 28atf_test_case "O_flag_bsd_basic" "cleanup" 29O_flag_bsd_basic_head() 30{ 31 atf_set descr "bsd format test on local syslog message" 32} 33O_flag_bsd_basic_body() 34{ 35 local format="bsd" 36 local logfile="${PWD}/O_flag_${format}_basic.log" 37 38 setup_basic_format_test "${format}" "${logfile}" 39 40 atf_check -s exit:0 -o match:"${REGEX_RFC3164_LOGFILE}" cat "${logfile}" 41} 42O_flag_bsd_basic_cleanup() 43{ 44 syslogd_stop 45} 46 47atf_test_case "O_flag_rfc3164_basic" "cleanup" 48O_flag_rfc3164_basic_head() 49{ 50 atf_set descr "rfc3164 format test on local syslog message" 51} 52O_flag_rfc3164_basic_body() 53{ 54 local format="rfc3164" 55 local logfile="${PWD}/O_flag_${format}_basic.log" 56 57 setup_basic_format_test "${format}" "${logfile}" 58 59 atf_check -s exit:0 -o match:"${REGEX_RFC3164_LOGFILE}" cat "${logfile}" 60} 61O_flag_rfc3164_basic_cleanup() 62{ 63 syslogd_stop 64} 65 66atf_test_case "O_flag_rfc3164strict_basic" "cleanup" 67O_flag_rfc3164strict_basic_head() 68{ 69 atf_set descr "rfc3164-strict format test on local syslog message" 70} 71O_flag_rfc3164strict_basic_body() 72{ 73 local format="rfc3164-strict" 74 local logfile="${PWD}/O_flag_${format}_basic.log" 75 76 setup_basic_format_test "${format}" "${logfile}" 77 78 atf_check -s exit:0 -o match:"${REGEX_RFC3164_LOGFILE}" cat "${logfile}" 79} 80O_flag_rfc3164strict_basic_cleanup() 81{ 82 syslogd_stop 83} 84 85atf_test_case "O_flag_syslog_basic" "cleanup" 86O_flag_syslog_basic_head() 87{ 88 atf_set descr "syslog format test on local syslog message" 89} 90O_flag_syslog_basic_body() 91{ 92 local format="syslog" 93 local logfile="${PWD}/O_flag_${format}_basic.log" 94 95 setup_basic_format_test "${format}" "${logfile}" 96 97 atf_check -s exit:0 -o match:"${REGEX_RFC5424_LOGFILE}" cat "${logfile}" 98} 99O_flag_syslog_basic_cleanup() 100{ 101 syslogd_stop 102} 103 104atf_test_case "O_flag_rfc5424_basic" "cleanup" 105O_flag_rfc5424_basic_head() 106{ 107 atf_set descr "rfc5424 format test on local syslog message" 108} 109O_flag_rfc5424_basic_body() 110{ 111 local format="rfc5424" 112 local logfile="${PWD}/O_flag_${format}_basic.log" 113 114 setup_basic_format_test "${format}" "${logfile}" 115 116 atf_check -s exit:0 -o match:"${REGEX_RFC5424_LOGFILE}" cat "${logfile}" 117} 118O_flag_rfc5424_basic_cleanup() 119{ 120 syslogd_stop 121} 122 123atf_init_test_cases() 124{ 125 atf_add_test_case "O_flag_bsd_basic" 126 atf_add_test_case "O_flag_rfc3164_basic" 127 atf_add_test_case "O_flag_rfc3164strict_basic" 128 atf_add_test_case "O_flag_syslog_basic" 129 atf_add_test_case "O_flag_rfc5424_basic" 130} 131