aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite.awk
blob: 27e35615d89778aaf25019afce50dbc3bae03db7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/awk -f

BEGIN {
  RS = "--\n"
  FS = ":\n"
}

function runtest(id, code, output,
                 failed)
{
  print code > "script.sh"
  print output > "output"

  failed = 0

  if (output == "ERR\n") {
    if (system("sh script.sh > /dev/null 2>&1") == 0)
      failed = 1
  } else if (system("[ \"$(sh script.sh)\" = \"$(cat output)\" ]") != 0) {
    failed = 1
  }

  if (failed)
    printf("test %s in file '%s' failed (for cppawk = %s)\n",
           id, FILENAME, ENVIRON["cppawk"])

  close("script.sh")
  close("output")
}

$1 {
  runtest($1, $2, $3)
}