1####################################################### 2# 3# Test GLOB_BRACE with findfiles() 4# 5####################################################### 6 7body common control 8{ 9 inputs => { "../../default.cf.sub" }; 10 bundlesequence => { default("$(this.promise_filename)") }; 11 version => "1.0"; 12} 13 14bundle common findfiles 15{ 16 vars: 17 # * in filenames not allowed on win 18 windows:: 19 "names" slist => { "a", "bc", "d/e/f", "g/h/i/j", "klm/nop/qrs" }; 20 !windows:: 21 "names" slist => { "a", "bc", "d/e/f", "g/h/i/j", "klm/nop/qrs", "tu/*" }; 22} 23 24####################################################### 25 26bundle agent init 27{ 28 files: 29 "$(G.testdir)/$(findfiles.names)" 30 create => "true"; 31 32 reports: 33 DEBUG:: 34 "Created $(G.testdir)/$(findfiles.names)"; 35} 36 37 38####################################################### 39 40bundle agent test 41{ 42 meta: 43 "description" -> { "CFE-3292" } 44 string => "Test that findfiles() works as expected."; 45 46 #"test_suppress_fail" string => "windows", 47 # meta => { "redmine4730" }; 48 # This test should be merged with findfiles.cf when it's fixed. 49 # In order to soft-fail it as requested, I had to strip it to a separate-test 50 "test_soft_fail" string => "any", 51 meta => { "CFE-3292" }; 52 53 vars: 54 "patterns[GLOB_BRACE]" string => "$(G.testdir)/{a,bc}"; 55 56 "pnames" slist => getindices("patterns"); 57 58 "found[$(pnames)]" slist => findfiles("$(patterns[$(pnames)])"); 59 "found_string[$(pnames)]" string => join(",", "found[$(pnames)]"); 60 61 62 reports: 63 DEBUG:: 64 "findfiles pattern $(pnames) '$(patterns[$(pnames)])' => '$(found_string[$(pnames)])'"; 65} 66 67 68####################################################### 69 70bundle agent check 71{ 72 vars: 73 "expected[GLOB_BRACE]" string => "$(G.testdir)/a,$(G.testdir)/bc"; 74 75 "expects" slist => getindices("expected"); 76 77 "fstring" slist => getindices("test.found_string"); 78 79 "joint_condition" string => join(".", "expects"); 80 81 classes: 82 "$(expects)" expression => strcmp("$(test.found_string[$(expects)])", "$(expected[$(expects)])"); 83 "ok" expression => "$(joint_condition)"; 84 85 reports: 86 DEBUG:: 87 "pattern $(expects) matches as expected: '$(expected[$(expects)])'" 88 if => "$(expects)"; 89 90 "pattern $(expects) does NOT match expected: '$(test.found_string[$(expects)])' != '$(expected[$(expects)])'" 91 if => "!$(expects)"; 92 93 ok:: 94 "$(this.promise_filename) Pass"; 95 !ok:: 96 "$(this.promise_filename) FAIL"; 97} 98