Dmitry V. Levin | 1da7c95 | 2014-12-13 18:24:13 +0000 | [diff] [blame] | 1 | BEGIN { |
Dmitry V. Levin | c55bfb0 | 2014-12-15 23:44:31 +0000 | [diff] [blame^] | 2 | r_uint = "(0|[1-9][0-9]*)" |
| 3 | regexp = "^getuid" suffix "\\(\\)[[:space:]]+= " r_uint "$" |
| 4 | expected = "getuid" |
Dmitry V. Levin | 1da7c95 | 2014-12-13 18:24:13 +0000 | [diff] [blame] | 5 | fail = 0 |
Dmitry V. Levin | 1da7c95 | 2014-12-13 18:24:13 +0000 | [diff] [blame] | 6 | } |
| 7 | |
Dmitry V. Levin | c55bfb0 | 2014-12-15 23:44:31 +0000 | [diff] [blame^] | 8 | regexp == "" { |
Dmitry V. Levin | 1da7c95 | 2014-12-13 18:24:13 +0000 | [diff] [blame] | 9 | fail = 1 |
| 10 | next |
| 11 | } |
| 12 | |
Dmitry V. Levin | 1da7c95 | 2014-12-13 18:24:13 +0000 | [diff] [blame] | 13 | { |
Dmitry V. Levin | c55bfb0 | 2014-12-15 23:44:31 +0000 | [diff] [blame^] | 14 | if (match($0, regexp, a)) { |
| 15 | switch (expected) { |
| 16 | case "getuid": |
| 17 | uid = a[1] |
| 18 | expected = "setuid" |
| 19 | regexp = "^setuid" suffix "\\(" uid "\\)[[:space:]]+= 0$" |
| 20 | next |
| 21 | case "setuid": |
| 22 | expected = "getresuid" |
| 23 | regexp = "^getresuid" suffix "\\(\\[" uid "\\], \\[" uid "\\], \\[" uid "\\]\\)[[:space:]]+= 0$" |
| 24 | next |
| 25 | case "getresuid": |
| 26 | expected = "setreuid" |
| 27 | regexp = "^setreuid" suffix "\\(-1, -1\\)[[:space:]]+= 0$" |
| 28 | next |
| 29 | case "setreuid": |
| 30 | expected = "setresuid" |
| 31 | regexp = "^setresuid" suffix "\\(-1, " uid ", -1\\)[[:space:]]+= 0$" |
| 32 | next |
| 33 | case "setresuid": |
| 34 | expected = "chown" |
| 35 | regexp = "^chown" suffix "\\(\".\", -1, -1\\)[[:space:]]+= 0$" |
| 36 | next |
| 37 | case "chown": |
| 38 | expected = "the last line" |
| 39 | regexp = "^\\+\\+\\+ exited with 0 \\+\\+\\+$" |
| 40 | next |
| 41 | case "the last line": |
| 42 | expected = "nothing" |
| 43 | regexp = "" |
| 44 | next |
| 45 | } |
Dmitry V. Levin | 1da7c95 | 2014-12-13 18:24:13 +0000 | [diff] [blame] | 46 | } |
| 47 | next |
| 48 | } |
| 49 | |
| 50 | END { |
| 51 | if (fail) { |
| 52 | print "Unexpected output after exit" |
| 53 | exit 1 |
| 54 | } |
Dmitry V. Levin | c55bfb0 | 2014-12-15 23:44:31 +0000 | [diff] [blame^] | 55 | if (regexp == "") |
Dmitry V. Levin | 1da7c95 | 2014-12-13 18:24:13 +0000 | [diff] [blame] | 56 | exit 0 |
Dmitry V. Levin | c55bfb0 | 2014-12-15 23:44:31 +0000 | [diff] [blame^] | 57 | print "error: " expected " doesn't match" |
Dmitry V. Levin | 1da7c95 | 2014-12-13 18:24:13 +0000 | [diff] [blame] | 58 | exit 1 |
| 59 | } |