<commit_before>#!/bin/bash

. $builddir/tests/test_common.sh

set -e -o pipefail

probecheck "sysctl" || return 255

name=$(basename $0 .sh)

result=$(mktemp ${name}.res.out.XXXXXX)
stderr=$(mktemp ${name}.err.out.XXXXXX)
ourNames=$(mktemp ${name}.our.out.XXXXXX)
sysctlNames=$(mktemp ${name}.sysctl.out.XXXXXX)

echo "Result file: $result"
echo "Our names file: $ourNames"
echo "Sysctl names file: $sysctlNames"
echo "Errors file: $stderr"

$OSCAP oval eval --results $result $srcdir/test_sysctl_probe_all.oval.xml > /dev/null 2>$stderr

# sysctl has duplicities in output
# hide permission errors like: "sysctl: permission denied on key 'fs.protected_hardlinks'"
# kernel parameters might use "/" and "." separators interchangeably - normalizing
sysctl -aN --deprecated 2> /dev/null | tr "/" "." | sort -u > "$sysctlNames"

grep unix-sys:name "$result" | sed -E 's;.*>(.*)<.*;\1;g' | sort > "$ourNames"

diff "$sysctlNames" "$ourNames"

# remove oscap error message related to permissions from stderr
sed -i -E "/^E: probe_sysctl: Can't read sysctl value from /d" "$stderr"
[ ! -s $stderr ]

rm $stderr $result $ourNames $sysctlNames

<commit_msg>Update test of the verbose output for the new probe subsystem<commit_after>#!/bin/bash

. $builddir/tests/test_common.sh

set -e -o pipefail

probecheck "sysctl" || return 255

name=$(basename $0 .sh)

result=$(mktemp ${name}.res.out.XXXXXX)
stderr=$(mktemp ${name}.err.out.XXXXXX)
ourNames=$(mktemp ${name}.our.out.XXXXXX)
sysctlNames=$(mktemp ${name}.sysctl.out.XXXXXX)

echo "Result file: $result"
echo "Our names file: $ourNames"
echo "Sysctl names file: $sysctlNames"
echo "Errors file: $stderr"

$OSCAP oval eval --results $result $srcdir/test_sysctl_probe_all.oval.xml > /dev/null 2>$stderr

# sysctl has duplicities in output
# hide permission errors like: "sysctl: permission denied on key 'fs.protected_hardlinks'"
# kernel parameters might use "/" and "." separators interchangeably - normalizing
sysctl -aN --deprecated 2> /dev/null | tr "/" "." | sort -u > "$sysctlNames"

grep unix-sys:name "$result" | sed -E 's;.*>(.*)<.*;\1;g' | sort > "$ourNames"

diff "$sysctlNames" "$ourNames"

# remove oscap error message related to permissions from stderr
sed -i -E "/^E: oscap: +Can't read sysctl value from /d" "$stderr"
[ ! -s $stderr ]

rm $stderr $result $ourNames $sysctlNames


{'fraction_non_alphanumeric': 0.1594017094017094, 'fraction_numerical': 0.005982905982905983, 'mean_word_length': 4.613908872901678, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5207447', 'n_tokens_mistral': 842, 'n_tokens_neox': 811, 'n_words': 246}