Debian Codegraph @

tests/probes/symlink/test_probes_symlink.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 # Copyright 2015 Red Hat Inc., Durham, North Carolina.
4 # All Rights Reserved.
5 #
6 # OpenScap Probes Test Suite.
7
8 . $builddir/tests/test_common.sh
9
10 set -e -o pipefail
11
12 function test_probes_symlinkscip-shell shell shell-project 0.0.0 test_probes_symlink(). {
13 probecheck "symlink" || return 255
14
15 DF="test_probes_symlink.xml"
16 RF="results.xml"
17
18 rmscip-shell system . . rm. -f $RF
19
20 tmpdir=$(make_temp_dir /tmpscip-shell filesystem . . `/tmp`. test_symlink)
21
22 touchscip-shell system . . touch. $tmpdir/some_file
23 touchscip-shell system . . touch. $tmpdir/file_to_remove
24 lnscip-shell system . . ln. -s $tmpdir/some_file $tmpdir/normal_symlink
25 lnscip-shell system . . ln. -s $tmpdir/file_to_remove $tmpdir/broken_symlink
26 rmscip-shell system . . rm. -f $tmpdir/file_to_remove
27 lnscip-shell system . . ln. -s $tmpdir/circular_symlink $tmpdir/circular_symlink
28 touchscip-shell system . . touch. $tmpdir/other_file
29 lnscip-shell system . . ln. -s $tmpdir/other_file $tmpdir/middle_symlink
30 lnscip-shell system . . ln. -s $tmpdir/middle_symlink $tmpdir/chained_symlink
31
32 bashscip-shell system . . bash. ${srcdir}/test_probes_symlink.xml.sh $tmpdir > "$DF"
33
34 $OSCAP oval eval --results $RF $DF
35
36 result=$RF
37
38 p='oval_results/results/system/oval_system_characteristics/'
39 assert_exists 6 $p'collected_objects/object'
40 assert_exists 2 $p'collected_objects/object[@flag="complete"]'
41 assert_exists 2 $p'system_data/unix-sys:symlink_item'
42 assert_exists 2 $p'system_data/unix-sys:symlink_item[@status="exists"]'
43 assert_exists 1 $p'system_data/unix-sys:symlink_item/unix-sys:filepath[text()="'$tmpdir/normal_symlink'"]'
44 assert_exists 1 $p'system_data/unix-sys:symlink_item/unix-sys:canonical_path[text()="'$tmpdir'/some_file"]'
45 assert_exists 1 $p'system_data/unix-sys:symlink_item/unix-sys:filepath[text()="'$tmpdir/chained_symlink'"]'
46 assert_exists 1 $p'system_data/unix-sys:symlink_item/unix-sys:canonical_path[text()="'$tmpdir'/other_file"]'
47 assert_exists 2 $p'collected_objects/object[@flag="error"]'
48 assert_exists 2 $p'collected_objects/object[@flag="does not exist"]'
49 assert_exists 4 $p'collected_objects/object/message'
50
51 rmscip-shell system . . rm. -rf $tmpdir
52 rmscip-shell system . . rm. -f $RF
53 rmscip-shell system . . rm. -f $DF
54 }
55
56 test_probes_symlinkscip-shell shell shell-project 0.0.0 test_probes_symlink().