summaryrefslogtreecommitdiff
path: root/cpp/test/Slice/errorDetection/run.py
blob: f2cdc75dfe062171e50eb4c2fe058ca336f1d453 (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python
# **********************************************************************
#
# Copyright (c) 2001
# MutableRealms, Inc.
# Huntsville, AL, USA
#
# All Rights Reserved
#
# **********************************************************************

import os, sys, re

for toplevel in [".", "..", "../..", "../../..", "../../../.."]:
    toplevel = os.path.normpath(toplevel)
    if os.path.exists(os.path.join(toplevel, "config", "TestUtil.py")):
        break
else:
    raise "can't find toplevel directory!"

directory = os.path.join(toplevel, "test", "Slice", "errorDetection")
slice2cpp = os.path.join(toplevel, "bin", "slice2cpp")

regex1 = re.compile(r".ice$", re.IGNORECASE)
files = []
for file in os.listdir(directory):
    if(regex1.search(file)):
        files.append(file)

files.sort()
for file in files:

    print file + "...",

    command = slice2cpp + " " + os.path.join(directory, file);
    stdin, stdout, stderr = os.popen3(command)
    lines1 = stdout.readlines()
    lines2 = open(os.path.join(directory, regex1.sub(".err", file)), "r").readlines()
    if len(lines1) != len(lines2):
        print "failed!"
        sys.exit(1)
    
    regex2 = re.compile(r"^.*(?=" + file + ")")
    i = 0
    while i < len(lines1):
        line1 = regex2.sub("", lines1[i]).strip()
        line2 = regex2.sub("", lines2[i]).strip()
        if line1 != line2:
            print "failed!"
            sys.exit(1)
        i = i + 1
    else:
        print "ok"

sys.exit(0)