src.elv.sh@v0.21.0-dev.0.20240515223629-06979efb9a2a/pkg/mods/unix/rlimit_test.elvts (about) 1 //each:eval use unix 2 //each:mock-rlimit 3 4 /////////// 5 # reading # 6 /////////// 7 8 ~> put $unix:rlimits[cpu] 9 ▶ [&] 10 ~> put $unix:rlimits[nofile] 11 ▶ [&cur=(num 30) &max=(num 40)] 12 ~> has-key $unix:rlimits stack 13 ▶ $false 14 15 /////////// 16 # setting # 17 /////////// 18 19 ~> set unix:rlimits[cpu] = [&cur=3 &max=8] 20 put $cpu-cur $cpu-max 21 ▶ (num 3) 22 ▶ (num 8) 23 ~> set unix:rlimits[cpu] = [&cur=4] 24 put $cpu-cur $cpu-max 25 ▶ (num 4) 26 ▶ (num -1) 27 ~> set unix:rlimits[cpu] = [&] 28 put $cpu-cur $cpu-max 29 ▶ (num -1) 30 ▶ (num -1) 31 ~> set unix:rlimits[nofile] = [&] 32 Exception: setrlimit nofile: fake setrlimit error 33 [tty]:1:5-24: set unix:rlimits[nofile] = [&] 34 35 ////////////// 36 # bad values # 37 ////////////// 38 39 ## bad rlimits value ## 40 ~> set unix:rlimits = x 41 Exception: bad value: $unix:rlimits must be map, but is string 42 [tty]:1:5-16: set unix:rlimits = x 43 ~> set unix:rlimits = [&[]=[&]] 44 Exception: bad value: key of $unix:rlimits must be string, but is list 45 [tty]:1:5-16: set unix:rlimits = [&[]=[&]] 46 ~> set unix:rlimits = [&bad-resource=[&]] 47 Exception: bad value: key of $unix:rlimits must be valid resource key, but is bad-resource 48 [tty]:1:5-16: set unix:rlimits = [&bad-resource=[&]] 49 ~> set unix:rlimits = [&] 50 Exception: bad value: $unix:rlimits must be map containing all resource keys, but is [&] 51 [tty]:1:5-16: set unix:rlimits = [&] 52 53 ## bad map value ## 54 ~> set unix:rlimits[cpu] = x 55 Exception: bad value: rlimit value must be map, but is string 56 [tty]:1:5-21: set unix:rlimits[cpu] = x 57 ~> set unix:rlimits[cpu] = [&bad] 58 Exception: bad value: key of rlimit value must be cur or max, but is bad 59 [tty]:1:5-21: set unix:rlimits[cpu] = [&bad] 60 61 ## limit out of range (non-FreeBSD) ## 62 //only-on !freebsd 63 ~> set unix:rlimits[cpu] = [&cur=[]] 64 Exception: bad value: cur in rlimit value must be number between 0 and 18446744073709551615, but is [] 65 [tty]:1:5-21: set unix:rlimits[cpu] = [&cur=[]] 66 ~> set unix:rlimits[cpu] = [&cur=1 &max=[]] 67 Exception: bad value: max in rlimit value must be number between 0 and 18446744073709551615, but is [] 68 [tty]:1:5-21: set unix:rlimits[cpu] = [&cur=1 &max=[]] 69 70 ## limit out of range (FreeBSD) ## 71 //only-on freebsd 72 // FreeBSD uses int64 for the limit values, so the error message is different. 73 ~> set unix:rlimits[cpu] = [&cur=[]] 74 Exception: bad value: cur in rlimit value must be number between 0 and 9223372036854775807, but is [] 75 [tty]:1:5-21: set unix:rlimits[cpu] = [&cur=[]] 76 ~> set unix:rlimits[cpu] = [&cur=1 &max=[]] 77 Exception: bad value: max in rlimit value must be number between 0 and 9223372036854775807, but is [] 78 [tty]:1:5-21: set unix:rlimits[cpu] = [&cur=1 &max=[]]