1####################################################### 2# 3# Test that filesexist() can check for presence of files containing hashes 4# 5####################################################### 6 7body common control 8{ 9 inputs => { "../../default.cf.sub" }; 10 bundlesequence => { default("$(this.promise_filename)") }; 11 version => "1.0"; 12} 13 14####################################################### 15 16bundle agent init 17{ 18 vars: 19 "test_files" slist => { "example4567", "example123" }; 20 21 files: 22 "$(G.testdir)/$(test_files)" 23 create => "true"; 24} 25 26####################################################### 27 28bundle agent test 29{ 30 meta: 31 "description" -> { "CFE-2744" } 32 string => "Test that filesexist works as a collecting function"; 33 34 classes: 35 "filesexist_slist_identifier_ok" 36 expression => filesexist( "init.test_files" ), 37 scope => "namespace"; 38 39 "filesexist_slist_ref_ok" 40 expression => filesexist( @(init.test_files) ), 41 scope => "namespace"; 42 43 "filesexist_findfiles_ok" 44 expression => filesexist( findfiles( "$(G.testdir)/example*" ) ), 45 scope => "namespace"; 46 47 "filesexist_json_array_ok" 48 expression => filesexist( '[ "example4567", "example123" ]' ), 49 scope => "namespace"; 50} 51####################################################### 52 53bundle agent check 54{ 55 classes: 56 "ok" and => { "filesexist_slist_identifier_ok", "filesexist_slist_ref_ok", 57 "filesexist_findfiles_ok", "filesexist_json_array_ok" }; 58 59 reports: 60 DEBUG|EXTRA:: 61 "Test files: $(init.test_files)"; 62 63 "filesexist() doesn't work with an slist identifier" 64 if => not( "filesexist_slist_identifier_ok" ); 65 66 "filesexist() doesn't work with an slist reference" 67 if => not( "filesexist_slist_ref_ok" ); 68 69 "filesexist() doesn't work properly with a nested findfiles() call" 70 if => not( "filesexist_findfiles_ok" ); 71 72 "filesexist() doesn't work with a JSON array" 73 if => not( "filesexist_json_array_ok" ); 74 75 ok:: 76 "$(this.promise_filename) Pass"; 77 78 !ok:: 79 "$(this.promise_filename) FAIL"; 80} 81