]> granicus.if.org Git - strace/blob - tests/uid.awk
Use printnum_int64 instead of print_loff_t
[strace] / tests / uid.awk
1 BEGIN {
2   r_uint = "(0|[1-9][0-9]*)"
3   regexp = "^getx?uid" suffix "\\(\\)[[:space:]]+= " r_uint "$"
4   expected = "getuid"
5   fail = 0
6 }
7
8 regexp == "" {
9   fail = 1
10   next
11 }
12
13 {
14   if (match($0, regexp, a)) {
15     if (expected == "getuid") {
16       uid = a[1]
17       expected = "setuid"
18       regexp = "^setuid" suffix "\\(" uid "\\)[[:space:]]+= 0$"
19     } else if (expected == "setuid") {
20       expected = "getresuid"
21       regexp = "^getresuid" suffix "\\(\\[" uid "\\], \\[" uid "\\], \\[" uid "\\]\\)[[:space:]]+= 0$"
22     } else if (expected == "getresuid") {
23       expected = "setreuid"
24       regexp = "^setreuid" suffix "\\(-1, -1\\)[[:space:]]+= 0$"
25     } else if (expected == "setreuid") {
26       expected = "setresuid"
27       regexp = "^setresuid" suffix "\\(" uid ", -1, -1\\)[[:space:]]+= 0$"
28     } else if (expected == "setresuid") {
29       expected = "fchown"
30       regexp = "^fchown" suffix "\\(1, -1, -1\\)[[:space:]]+= 0$"
31     } else if (expected == "fchown") {
32       expected = "1st getgroups"
33       regexp = "^getgroups" suffix "\\(0, NULL\\)[[:space:]]+= " r_uint "$"
34     } else if (expected == "1st getgroups") {
35       ngroups = a[1]
36       if (ngroups == "0")
37         list=""
38       else if (ngroups == "1")
39         list=r_uint
40       else
41         list=r_uint "(, " r_uint "){" (ngroups - 1) "}"
42       expected = "2nd getgroups"
43       regexp = "^getgroups" suffix "\\(" ngroups ", \\[" list "\\]\\)[[:space:]]+= " ngroups "$"
44     } else if (expected == "2nd getgroups") {
45       expected = "the last line"
46       regexp = "^\\+\\+\\+ exited with 0 \\+\\+\\+$"
47     } else if (expected == "the last line") {
48       expected = "nothing"
49       regexp = ""
50     }
51   }
52 }
53
54 END {
55   if (fail) {
56     print "Unexpected output after exit"
57     exit 1
58   }
59   if (regexp == "")
60     exit 0
61   print "error: " expected " doesn't match"
62   exit 1
63 }