#!/bin/bash shellfu import preupg shellfu import preupg_fupath shellfu import xcase shellfu import jat_dump #shellcheck disable=SC2034 PREUPG__RULE=xccdf_preupg_rule_api_logging_check assert_msg_like() { # # Assert log message matching $1 exists # preupg__get_messages > msgs jat__cmd grep "$1" msgs } xcase__enum() { # # Enumerate subtest ids # xcase__permute lang py sh \ | xcase__per fn log_debug log_info log_warning log_error \ | xcase__per debug true false } #shellcheck disable=SC2154 xcase__setup() { # # Prepare for subtest # local maybe_debug="" $debug && maybe_debug="--debug" echo "message$(head -c 1000 /dev/urandom | md5sum | head -c 7)" >t_message { echo "[MODULE]" echo "GROUP = api" echo "NAME = logging" echo "LANG = $lang" case $lang in sh) echo "CODE = $fn $( module.mdef preupg_fupath RHEL6_7 module.mdef PREUPG__UPATH="RHEL6_7/all-xccdf.xml" \ preupg__run1 $maybe_debug --skip-common } xcase__test() { # # Do the work # # set oracles # local o_severity="" local o_msgnum=0 local o_result=informational local o_not="" case $fn:$debug in log_debug:true) o_msgnum=1; o_severity=DEBUG ;; log_debug:false) o_msgnum=0; o_severity=DEBUG ;; log_info:*) o_msgnum=1; o_severity=INFO ;; log_warning:*) o_msgnum=1; o_severity=WARNING ;; log_error:*) o_msgnum=1; o_severity=ERROR ;; esac test "$o_msgnum" -eq 0 && o_not=-N # asserts # preupg__assert \ result "$o_result" \ msgn "$o_msgnum" \ $o_not msg.$o_severity "$(