1####################################################### 2# 3# Test filestat(linktarget) follows relative symlinks - redmine#7404 4# Also filestat(linktarget_shallow) should output the first relative symlink itself 5# 6####################################################### 7 8body common control 9{ 10 inputs => { "../../default.cf.sub" }; 11 bundlesequence => { default("$(this.promise_filename)") }; 12 version => "1.0"; 13} 14 15####################################################### 16 17bundle agent init 18{ 19 20 # Create chain of links first_link -> second_link -> final_target 21 22 commands: 23 "$(G.touch) $(G.testdir)/final_target"; 24 "$(G.ln) -s final_target $(G.testdir)/second_link"; 25 "$(G.ln) -s second_link $(G.testdir)/first_link"; 26 27 reports: 28 DEBUG:: 29 "Init: created chain of links first_link -> second_link -> final_target"; 30} 31 32 33####################################################### 34 35bundle agent test 36{ 37 meta: 38 # windows don't support symlinks 39 "test_skip_unsupported" string => "windows"; 40 41 vars: 42 "fields" slist => splitstring("linktarget,linktarget_shallow", ",", 999); 43 44 "stat[$(fields)]" string => filestat("$(G.testdir)/first_link", $(fields)); 45} 46 47 48####################################################### 49 50bundle agent check 51{ 52 vars: 53 "expected[linktarget_shallow]" string => "second_link"; 54 "expected[linktarget]" string => "$(G.testdir)/final_target"; 55 56 classes: 57 58 "test1_ok" expression => strcmp("$(test.stat[linktarget])", 59 "$(expected[linktarget])"); 60 "test2_ok" expression => strcmp("$(test.stat[linktarget_shallow])", 61 "$(expected[linktarget_shallow])"); 62 "ok" expression => "test1_ok.test2_ok"; 63 64 reports: 65 DEBUG:: 66 "linktarget : expected '$(expected[linktarget])' returned '$(test.stat[linktarget])'"; 67 "linktarget_shallow: expected '$(expected[linktarget_shallow])' returned '$(test.stat[linktarget_shallow])'"; 68 69 ok:: 70 "$(this.promise_filename) Pass"; 71 !ok:: 72 "$(this.promise_filename) FAIL"; 73} 74