]> granicus.if.org Git - strace/commitdiff
tests: fix build with awk that does not support switch-case
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 9 Jan 2015 04:10:54 +0000 (04:10 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 9 Jan 2015 04:10:54 +0000 (04:10 +0000)
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

index e8d682483005f7f3322759ccceff477c3503d303..b93fa0052e243428389c1cf2378cc82add6f9406 100644 (file)
@@ -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 {