1####################################################### 2# 3# Test getuid() 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 "dummy" string => "dummy"; 20} 21 22####################################################### 23 24bundle agent test 25{ 26 meta: 27 "test_skip_needs_work" string => "windows"; 28 29 30 vars: 31 any:: 32 "uid_root" int => getuid("root"); 33 "uid_daemon" int => getuid("daemon"); 34 !darwin:: 35 "uid_bin" int => getuid("bin"); 36 37 (linux.!archlinux.!SuSE.!redhat.!gentoo)|solaris|hpux|aix:: 38 "num_root" int => "0"; 39 "num_daemon" int => "1"; 40 "num_bin" int => "2"; 41 archlinux|SuSE|redhat|gentoo:: 42 "num_root" int => "0"; 43 "num_daemon" int => "2"; 44 "num_bin" int => "1"; 45 freebsd|openbsd:: 46 "num_root" int => "0"; 47 "num_daemon" int => "1"; 48 "num_bin" int => "3"; 49 darwin:: 50 "num_root" int => "0"; 51 "num_daemon" int => "1"; 52 53 !linux.!solaris.!hpux.!aix.!freebsd.!openbsd.!darwin:: 54 "num_root" string => "fixme"; 55 "num_daemon" string => "fixme"; 56 "num_bin" string => "fixme"; 57} 58 59 60####################################################### 61 62bundle agent check 63{ 64 classes: 65 darwin:: 66 "ok_bin" expression => "any"; 67 !darwin:: 68 "ok_bin" expression => strcmp("$(test.uid_bin)", "$(test.num_bin)"); 69 70 any:: 71 "ok" and => { 72 strcmp("$(test.uid_root)", "$(test.num_root)"), 73 strcmp("$(test.uid_daemon)", "$(test.num_daemon)"), 74 "ok_bin" 75 }; 76 77 reports: 78 DEBUG:: 79 "root is UID $(test.uid_root), expected $(test.num_root)"; 80 "daemon is UID $(test.uid_daemon), expected $(test.num_daemon)"; 81 "bin is UID $(test.uid_bin), expected $(test.num_bin)"; 82 ok:: 83 "$(this.promise_filename) Pass"; 84 !ok:: 85 "$(this.promise_filename) FAIL"; 86} 87 88