Dmitry V. Levin | 68d6424 | 2014-09-10 00:07:32 +0000 | [diff] [blame] | 1 | BEGIN { |
| 2 | lines = 3 |
| 3 | fail = 0 |
| 4 | |
| 5 | i = "[0-9]+" |
| 6 | len = "[1-9]" i |
| 7 | |
| 8 | d_ino = "d_ino=" i |
| 9 | d_off = "d_off=" i |
| 10 | d_reclen = "d_reclen=" len |
| 11 | d_name1 = "d_name=\"\\.\"" |
| 12 | d_name2 = "d_name=\"\\.\\.\"" |
| 13 | d_type = "d_type=DT_DIR" |
| 14 | |
| 15 | d1_1 = "{" d_ino ", " d_off ", " d_reclen ", " d_name1 ", " d_type "}" |
| 16 | d1_2 = "{" d_ino ", " d_off ", " d_reclen ", " d_name2 ", " d_type "}" |
| 17 | d2_1 = "{" d_ino ", " d_off ", " d_reclen ", " d_type ", " d_name1 "}" |
| 18 | d2_2 = "{" d_ino ", " d_off ", " d_reclen ", " d_type ", " d_name2 "}" |
| 19 | |
| 20 | getdents = "^getdents\\(" i ", {(" d1_1 " " d1_2 "|" d1_2 " " d1_1 ")}, " len "\\) += " len "$" |
| 21 | getdents64 = "^getdents64\\(" i ", {(" d2_1 " " d2_2 "|" d2_2 " " d2_1 ")}, " len "\\) += " len "$" |
| 22 | } |
| 23 | |
| 24 | NR == 1 {if (match($0, getdents) || match($0, getdents64)) next} |
| 25 | |
| 26 | NR == 2 && /^getdents(64)?\([0-9]+, \{\}, [1-9][0-9]+\) += 0$/ {next} |
| 27 | |
| 28 | NR == lines && /^\+\+\+ exited with 0 \+\+\+$/ {next} |
| 29 | |
| 30 | { |
| 31 | print "Line " NR " does not match: " $0 |
| 32 | fail=1 |
| 33 | } |
| 34 | |
| 35 | END { |
| 36 | if (NR != lines) { |
| 37 | print "Expected " lines " lines, found " NR " line(s)." |
| 38 | print "" |
| 39 | exit 1 |
| 40 | } |
| 41 | if (fail) { |
| 42 | print "" |
| 43 | exit 1 |
| 44 | } |
| 45 | } |