|
| 1 | +####################################################### |
| 2 | +# |
| 3 | +# Test getgroups() variable args |
| 4 | +# |
| 5 | +####################################################### |
| 6 | + |
| 7 | +body common control |
| 8 | +{ |
| 9 | + inputs => { "../../default.cf.sub" }; |
| 10 | + bundlesequence => { default("$(this.promise_filename)") }; |
| 11 | + version => "1.0"; |
| 12 | +} |
| 13 | +bundle agent test |
| 14 | +{ |
| 15 | + meta: |
| 16 | + "description" |
| 17 | + string => "Test whether the contents of /etc/group is correct when fetching all groups with getgroups()"; |
| 18 | + |
| 19 | + "test_skip_unsupported" |
| 20 | + string => "windows"; |
| 21 | + vars: |
| 22 | + "group_entries" slist => splitstring(string_trim(readfile("/etc/group")), "\n", 999); |
| 23 | + |
| 24 | + "name_list" |
| 25 | + slist => maplist( |
| 26 | + nth(splitstring("$(this)", ":", 1), 0), |
| 27 | + "@(group_entries)" |
| 28 | + ); |
| 29 | + "actual_groups_content" |
| 30 | + string => join(" ", sort("@(name_list)", "lex")); |
| 31 | + |
| 32 | + "groups1" slist => getgroups(); |
| 33 | + "groups2" slist => getgroups("",""); |
| 34 | + |
| 35 | + "retrieved_groups_content_1" |
| 36 | + string => join(" ", sort("@(groups1)", "lex")); |
| 37 | + "retrieved_groups_content_2" |
| 38 | + string => join(" ", sort("@(groups2)", "lex")); |
| 39 | + |
| 40 | +} |
| 41 | + |
| 42 | +bundle agent check |
| 43 | +{ |
| 44 | + |
| 45 | + classes: |
| 46 | + "ok" |
| 47 | + expression => and( |
| 48 | + strcmp("$(test.actual_groups_content)", "$(test.retrieved_groups_content_1)"), |
| 49 | + strcmp("$(test.actual_groups_content)", "$(test.retrieved_groups_content_2)") |
| 50 | + ); |
| 51 | + |
| 52 | + reports: |
| 53 | + ok:: |
| 54 | + "$(this.promise_filename) Pass"; |
| 55 | + |
| 56 | + !ok:: |
| 57 | + "$(this.promise_filename) FAIL"; |
| 58 | +} |
0 commit comments