Download this file
| 1 | //go:build linux |
| 2 | |
| 3 | package host |
| 4 | |
| 5 | import ( |
| 6 | "strings" |
| 7 | "testing" |
| 8 | ) |
| 9 | |
| 10 | func TestGenerationGuardEdgeStart(t *testing.T) { |
| 11 | const start = "{ path=/opt/carlos/system/guard/carlos ; argv[]=/opt/carlos/system/guard/carlos system guard-exec edge ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=10 ; code=(null) ; status=0/0 }" |
| 12 | if !generationGuardEdgeStart("carlos-edge.service", start) { |
| 13 | t.Fatal("supported guard invocation refused") |
| 14 | } |
| 15 | for _, other := range []string{ |
| 16 | strings.Replace(start, "guard-exec edge", "guard-exec recover", 1), |
| 17 | strings.Replace(start, "guard-exec edge", "guard-exec edge extra", 1), |
| 18 | strings.Replace(start, "argv[]=/opt/carlos/system/guard/carlos", "argv[]=other", 1), |
| 19 | strings.Replace(start, "path=/opt/carlos/system/guard/carlos", "path=/opt/carlos/carlos", 1), |
| 20 | strings.Replace(start, "ignore_errors=no", "ignore_errors=yes", 1), |
| 21 | start + " " + start, |
| 22 | } { |
| 23 | if generationGuardEdgeStart("carlos-edge.service", other) { |
| 24 | t.Fatal("unsupported invocation accepted", other) |
| 25 | } |
| 26 | } |
| 27 | if generationGuardEdgeStart("another.service", start) { |
| 28 | t.Fatal("another unit accepted") |
| 29 | } |
| 30 | } |
| 31 | |