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 |
Dmitry V. Levin | c929771 | 2015-01-25 00:04:20 +0000 | [diff] [blame] | 11 | d_name_1 = "d_name=\"\\.\"" |
| 12 | d_name_2 = "d_name=\"\\.\\.\"" |
| 13 | d_name_3 = "d_name=\"(A\\\\n){127}Z\"" |
| 14 | d_type_dir = "d_type=DT_DIR" |
| 15 | d_type_reg = "d_type=DT_REG" |
Dmitry V. Levin | 68d6424 | 2014-09-10 00:07:32 +0000 | [diff] [blame] | 16 | |
Dmitry V. Levin | c929771 | 2015-01-25 00:04:20 +0000 | [diff] [blame] | 17 | dirent_1 = "\\{" d_ino ", " d_off ", " d_reclen ", " d_name_1 ", " d_type_dir "\\}" |
| 18 | dirent_2 = "\\{" d_ino ", " d_off ", " d_reclen ", " d_name_2 ", " d_type_dir "\\}" |
| 19 | dirent_3 = "\\{" d_ino ", " d_off ", " d_reclen ", " d_name_3 ", " d_type_reg "\\}" |
Dmitry V. Levin | 68d6424 | 2014-09-10 00:07:32 +0000 | [diff] [blame] | 20 | |
Dmitry V. Levin | c929771 | 2015-01-25 00:04:20 +0000 | [diff] [blame] | 21 | dirent64_1 = "\\{" d_ino ", " d_off ", " d_reclen ", " d_type_dir ", " d_name_1 "\\}" |
| 22 | dirent64_2 = "\\{" d_ino ", " d_off ", " d_reclen ", " d_type_dir ", " d_name_2 "\\}" |
| 23 | dirent64_3 = "\\{" d_ino ", " d_off ", " d_reclen ", " d_type_reg ", " d_name_3 "\\}" |
| 24 | |
| 25 | dents = "\\{(" dirent_1 " " dirent_2 "|" dirent_2 " " dirent_1 ") " dirent_3 "\\}" |
| 26 | dents64 = "\\{(" dirent64_1 " " dirent64_2 "|" dirent64_2 " " dirent64_1 ") " dirent64_3 "\\}" |
| 27 | |
| 28 | getdents = "^getdents\\(" i ", " dents ", " len "\\) += " len "$" |
| 29 | getdents64 = "^getdents64\\(" i ", " dents64 ", " len "\\) += " len "$" |
Dmitry V. Levin | 68d6424 | 2014-09-10 00:07:32 +0000 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | NR == 1 {if (match($0, getdents) || match($0, getdents64)) next} |
| 33 | |
| 34 | NR == 2 && /^getdents(64)?\([0-9]+, \{\}, [1-9][0-9]+\) += 0$/ {next} |
| 35 | |
| 36 | NR == lines && /^\+\+\+ exited with 0 \+\+\+$/ {next} |
| 37 | |
| 38 | { |
| 39 | print "Line " NR " does not match: " $0 |
| 40 | fail=1 |
| 41 | } |
| 42 | |
| 43 | END { |
| 44 | if (NR != lines) { |
| 45 | print "Expected " lines " lines, found " NR " line(s)." |
| 46 | print "" |
| 47 | exit 1 |
| 48 | } |
| 49 | if (fail) { |
| 50 | print "" |
| 51 | exit 1 |
| 52 | } |
| 53 | } |