From: Dmitry V. Levin Date: Thu, 25 Dec 2014 00:32:23 +0000 (+0000) Subject: tests: robustify unix domain socket decoding test X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f0ed167eccc5eb0d21a5488b4cba1ed3965ed1fa;p=platform%2Fupstream%2Fstrace.git tests: robustify unix domain socket decoding test Unix domain socket address family name is not universally decoded as AF_LOCAL, other names like AF_UNIX and AF_FILE are valid synonyms. Similarly, PF_UNIX and PF_FILE are valid synonyms for PF_LOCAL. Some test regexps have to be properly initialized before they could be used, so make sure they are initialized before use. --- diff --git a/tests/unix-yy-accept.awk b/tests/unix-yy-accept.awk index ad1d39ec..bafee898 100644 --- a/tests/unix-yy-accept.awk +++ b/tests/unix-yy-accept.awk @@ -2,50 +2,40 @@ BEGIN { lines = 8 fail = 0 - inode_listen = "?" - inode_accepted = "?" - inode_peer = "?" - r_i = "[1-9][0-9]*" - r_bind = "^bind\\(0, {sa_family=AF_LOCAL, sun_path=\"local-stream\"}, " r_i "\\) += 0$" - r_listen = "^/$" - r_getsockname = "^/$" - r_accept = "^/$" - r_close0 = "^/$" - r_close1 = "^/$" + r_bind = "^bind\\(0, {sa_family=AF_(LOCAL|UNIX|FILE), sun_path=\"local-stream\"}, 15\\) += 0$" } -NR == 1 && /^socket\(PF_LOCAL, SOCK_STREAM, 0\) += 0$/ {next} +NR == 1 && /^socket\(PF_(LOCAL|UNIX|FILE), SOCK_STREAM, 0\) += 0$/ {next} NR == 2 { if (match($0, r_bind, a)) { inode_listen = a[1] r_listen = "^listen\\(0, 5\\) += 0$" - r_getsockname = "^getsockname\\(0, {sa_family=AF_LOCAL, sun_path=\"local-stream\"}, \\[" r_i "\\]\\) += 0$" - r_accept = "^accept\\(0, {sa_family=AF_LOCAL, NULL}, \\[" r_i "\\]\\) += 1(" r_i "),\"local-stream\"\\]>" + r_getsockname = "^getsockname\\(0, {sa_family=AF_(LOCAL|UNIX|FILE), sun_path=\"local-stream\"}, \\[15\\]\\) += 0$" + r_accept = "^accept\\(0, {sa_family=AF_(LOCAL|UNIX|FILE), NULL}, \\[2\\]\\) += 1(" r_i "),\"local-stream\"\\]>" next } } -NR == 3 {if (match($0, r_listen)) next} +NR == 3 {if (r_listen != "" && match($0, r_listen)) next} -NR == 4 {if (match($0, r_getsockname)) next} +NR == 4 {if (r_getsockname != "" && match($0, r_getsockname)) next} NR == 5 { - if (match($0, r_accept, a)) { - inode_accepted = a[1] - inode_peer = a[2] - print inode_accepted - r_close0 = "^close\\(0\\) += 0$" - r_close1 = "^close\\(1\\) += 0$" + if (r_accept != "" && match($0, r_accept, a)) { + inode_accepted = a[2] + inode_peer = a[3] + r_close_listen = "^close\\(0\\) += 0$" + r_close_accepted = "^close\\(1\\) += 0$" next } } -NR == 6 {if (match($0, r_close0)) next} -NR == 7 {if (match($0, r_close1)) next} +NR == 6 {if (r_close_listen != "" && match($0, r_close_listen)) next} +NR == 7 {if (r_close_accepted != "" && match($0, r_close_accepted)) next} -NR == lines && /^\+\+\+ exited with 0 \+\+\+$/ {next} +NR == lines && $0 == "+++ exited with 0 +++" {next} { print "Line " NR " does not match: " $0 diff --git a/tests/unix-yy-connect.awk b/tests/unix-yy-connect.awk index 1b41315e..173d7211 100644 --- a/tests/unix-yy-connect.awk +++ b/tests/unix-yy-connect.awk @@ -2,26 +2,30 @@ BEGIN { lines = 5 fail = 0 - inode = "?" - r_i = "[1-9][0-9]*" - r_close0 = "^close\\(0\\) += 0$" - r_connect = "^connect\\(1, {sa_family=AF_LOCAL, sun_path=\"local-stream\"}, " r_i "\\) += 0$" - r_close1 = "^/$" + r_close_listen = "^close\\(0\\) += 0$" + r_connect = "^connect\\(1, {sa_family=AF_(LOCAL|UNIX|FILE), sun_path=\"local-stream\"}, 15\\) += 0$" } -NR == 1 && /^socket\(PF_LOCAL, SOCK_STREAM, 0\) += 1$/ {next} -NR == 2 {if (match($0, r_close0)) next} +NR == 1 && /^socket\(PF_(LOCAL|UNIX|FILE), SOCK_STREAM, 0\) += 1$/ {next} + +NR == 2 {if (match($0, r_close_listen)) next} + NR == 3 { if (match($0, r_connect, a)) { inode = a[1] - r_close1 = "^close\\(1" r_i "\\]>\\) += 0$" + r_close_connected = "^close\\(1" r_i "\\]>\\) += 0$" + next + } +} + +NR == 4 { + if (inode != "" && r_close_connected != "" && match($0, r_close_connected, a) && a[1] == inode) { next } } -NR == 4 {if (match($0, r_close1, a) && a[1] == inode) {next}} -NR == lines && /^\+\+\+ exited with 0 \+\+\+$/ {next} +NR == lines && $0 == "+++ exited with 0 +++" {next} { print "Line " NR " does not match: " $0