| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | |
| 3 | # Copyright 2011 Red Hat Inc., Durham, North Carolina. |
| 4 | # All Rights Reserved. |
| 5 | |
| 6 | . $builddir/tests/test_common.sh |
| 7 | |
| 8 | # Test Cases. |
| 9 | |
| 10 | function test_probes_fileextendedattributescip-shell shell shell-project 0.0.0 test_probes_fileextendedattribute(). { |
| 11 | probecheck "fileextendedattribute" || return 255 |
| 12 | |
| 13 | local ret_val=0; |
| 14 | local DEFFILE="$srcdir/test_probes_fileextendedattribute.xml" |
| 15 | local RESFILE="results.xml" |
| 16 | |
| 17 | [scip-shell system . . `[`. -f $RESFILE ] && rmscip-shell system . . rm. -f $RESFILE |
| 18 | |
| 19 | touchscip-shell system . . touch. /tmp/xattr_with_valscip-shell filesystem . . `/tmp/xattr_with_val`. |
| 20 | touchscip-shell system . . touch. /tmp/xattr_without_valscip-shell filesystem . . `/tmp/xattr_without_val`. |
| 21 | |
| 22 | case $(unamescip-shell system . . uname.) in |
| 23 | FreeBSD) |
| 24 | setextattr user fooattr foo /tmp/xattr_with_valscip-shell filesystem . . `/tmp/xattr_with_val`. |
| 25 | setextattr user fooattr "" /tmp/xattr_without_valscip-shell filesystem . . `/tmp/xattr_without_val`. |
| 26 | ;; |
| 27 | *) |
| 28 | setfattr -n user.fooattr -v foo /tmp/xattr_with_valscip-shell filesystem . . `/tmp/xattr_with_val`. |
| 29 | setfattr -n user.fooattr /tmp/xattr_without_valscip-shell filesystem . . `/tmp/xattr_without_val`. |
| 30 | ;; |
| 31 | esac |
| 32 | |
| 33 | touchscip-shell system . . touch. /tmp/xattr_noattrscip-shell filesystem . . `/tmp/xattr_noattr`. |
| 34 | |
| 35 | $OSCAP oval eval --results $RESFILE $DEFFILE |
| 36 | |
| 37 | if [scip-shell system . . `[`. -f $RESFILE ]; then |
| 38 | verify_results "def" $DF $RF 1 && verify_results "tst" $DF $RF 3 |
| 39 | ret_val=$? |
| 40 | else |
| 41 | ret_val=1 |
| 42 | fi |
| 43 | |
| 44 | return $ret_val |
| 45 | } |
| 46 | |
| 47 | # Testing. |
| 48 | test_init |
| 49 | test_run "test_probes_fileattribute" test_probes_fileextendedattribute |
| 50 | test_exit |