From 08b6397d13580fd82450a43f3a65237041679421 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Fri, 9 Jan 2015 04:10:54 +0000 Subject: [PATCH] tests: fix build with awk that does not support switch-case The switch-case statement is a gawk-specific feature which is not necessarily available, let's use traditional if-else statements instead. * tests/uid.awk: Rewrite without switch-case statements. --- tests/uid.awk | 80 ++++++++++++++++++++++----------------------------- 1 file changed, 35 insertions(+), 45 deletions(-) diff --git a/tests/uid.awk b/tests/uid.awk index e8d68248..b93fa005 100644 --- a/tests/uid.awk +++ b/tests/uid.awk @@ -12,53 +12,43 @@ regexp == "" { { if (match($0, regexp, a)) { - switch (expected) { - case "getuid": - uid = a[1] - expected = "setuid" - regexp = "^setuid" suffix "\\(" uid "\\)[[:space:]]+= 0$" - next - case "setuid": - expected = "getresuid" - regexp = "^getresuid" suffix "\\(\\[" uid "\\], \\[" uid "\\], \\[" uid "\\]\\)[[:space:]]+= 0$" - next - case "getresuid": - expected = "setreuid" - regexp = "^setreuid" suffix "\\(-1, -1\\)[[:space:]]+= 0$" - next - case "setreuid": - expected = "setresuid" - regexp = "^setresuid" suffix "\\(-1, " uid ", -1\\)[[:space:]]+= 0$" - next - case "setresuid": - expected = "chown" - regexp = "^chown" suffix "\\(\".\", -1, -1\\)[[:space:]]+= 0$" - next - case "chown": - expected = "1st getgroups" - regexp = "^getgroups" suffix "\\(0, NULL\\)[[:space:]]+= " r_uint "$" - next - case "1st getgroups": - ngroups = a[1] - switch (ngroups) { - case "0": list=""; break - case "1": list=r_uint; break - default: list=r_uint "(, " r_uint "){" (ngroups - 1) "}" - } - expected = "2nd getgroups" - regexp = "^getgroups" suffix "\\(" ngroups ", \\[" list "\\]\\)[[:space:]]+= " ngroups "$" - next - case "2nd getgroups": - expected = "the last line" - regexp = "^\\+\\+\\+ exited with 0 \\+\\+\\+$" - next - case "the last line": - expected = "nothing" - regexp = "" - next + if (expected == "getuid") { + uid = a[1] + expected = "setuid" + regexp = "^setuid" suffix "\\(" uid "\\)[[:space:]]+= 0$" + } else if (expected == "setuid") { + expected = "getresuid" + regexp = "^getresuid" suffix "\\(\\[" uid "\\], \\[" uid "\\], \\[" uid "\\]\\)[[:space:]]+= 0$" + } else if (expected == "getresuid") { + expected = "setreuid" + regexp = "^setreuid" suffix "\\(-1, -1\\)[[:space:]]+= 0$" + } else if (expected == "setreuid") { + expected = "setresuid" + regexp = "^setresuid" suffix "\\(-1, " uid ", -1\\)[[:space:]]+= 0$" + } else if (expected == "setresuid") { + expected = "chown" + regexp = "^chown" suffix "\\(\".\", -1, -1\\)[[:space:]]+= 0$" + } else if (expected == "chown") { + expected = "1st getgroups" + regexp = "^getgroups" suffix "\\(0, NULL\\)[[:space:]]+= " r_uint "$" + } else if (expected == "1st getgroups") { + ngroups = a[1] + if (ngroups == "0") + list="" + else if (ngroups == "1") + list=r_uint + else + list=r_uint "(, " r_uint "){" (ngroups - 1) "}" + expected = "2nd getgroups" + regexp = "^getgroups" suffix "\\(" ngroups ", \\[" list "\\]\\)[[:space:]]+= " ngroups "$" + } else if (expected == "2nd getgroups") { + expected = "the last line" + regexp = "^\\+\\+\\+ exited with 0 \\+\\+\\+$" + } else if (expected == "the last line") { + expected = "nothing" + regexp = "" } } - next } END { -- 2.40.0