#!/usr/bin/env bash # # Copyright 2011 Red Hat Inc., Durham, North Carolina. # All Rights Reserved. # # Authors: # Daniel Kopecek # Tomas Heinrich . $builddir/tests/test_common.sh function gen_tree { echo "Generating tree for traversal" >&2 mkdir -p $ROOT/{d1/{d11/d111,d12},d2/d21} touch $ROOT/{d1/{d11/{d111/f1111,f111,f112,f113},d12/f121,f11},d2/{d21/f211,f21}} } function oval_fts { echo "=== $1 ===" shift ./oval_fts_list "$@" | sort | tee ${tmpdir}/oval_fts_list.out | \ sed "s|${ROOT}/||" | tr '\n' ',' > ${tmpdir}/oval_fts_list.out2 if [ $? -ne 0 ]; then echo "oval_fts_list failed" return 2 fi shift 10 echo -e "expected result:\n$1\noval_fts_list.out2:" cat ${tmpdir}/oval_fts_list.out2 echo if [ "$(cat ${tmpdir}/oval_fts_list.out2 | openssl md5)" == \ "$(echo -n $1 | openssl md5)" ]; then return 0 else return 1 fi } set -e -o pipefail if [ -n "${CUSTOM_OSCAP+x}" ] ; then exit 255 fi name=$(basename $0 .sh) tmpdir=$(make_temp_dir /tmp ${name}) ROOT=${tmpdir}/ftsroot echo "Temp dir: ${tmpdir}." gen_tree $ROOT # The format for the arguments is as follows: # # # # # # # # When path is specified, filename must also be. Else, filepath can be # specified. The first case is equivalent to the following SEXPs: # # ((path :operation ) ) # ((filename :operation ) :recurse :recurse_direction :recurse_file_system )) # # Else with filepath: # # ---empty path expression--- # ---empty filename expression--- # ((filepath :operation ) ) # ((behaviors :max_depth :recurse :recurse_direction :recurse_file_system )) # # When both <*_operation_number> and <*_operation_argument> are empty, the # resulting SEXP is not add. When <*_operation_argument> is empty, the # resulting SEXP looks like: # ((* :operation <*_operation_number)) # For filename only, if is equal to the string # "EMPTY_STRING", the resulting SEXP looks like: # ((filename :operation ) '') # # In general the utilized values of operation_number are: # equals (5) - a comparison against a fixed string # pattern match (11) - a regex based comparison # and the value of the argument is then directly passed as a string. # # behaviors_recurse can be some combination of "symlinks" and "directories" # # behaviors_recurse_direction can either be none, down, or up # # behaviors_recurse_file_system is commonly used as all or local # # All of this is implemented in oval_fts_list.c. while read args; do [ -z "${args%%#*}" ] && continue eval oval_fts $args done <