summaryrefslogtreecommitdiff
path: root/cpp/test/FreezeScript/dbmap/run.py
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2004-01-16 21:55:44 +0000
committerMark Spruiell <mes@zeroc.com>2004-01-16 21:55:44 +0000
commit190d61216f1f91517705c11fbcb7fd53a51b6b53 (patch)
tree348f8e6382ff2e5125134a2ea6279bef4712314f /cpp/test/FreezeScript/dbmap/run.py
parenttemporary workaround (diff)
downloadice-190d61216f1f91517705c11fbcb7fd53a51b6b53.tar.bz2
ice-190d61216f1f91517705c11fbcb7fd53a51b6b53.tar.xz
ice-190d61216f1f91517705c11fbcb7fd53a51b6b53.zip
adding FreezeScript tests
Diffstat (limited to 'cpp/test/FreezeScript/dbmap/run.py')
-rwxr-xr-xcpp/test/FreezeScript/dbmap/run.py115
1 files changed, 115 insertions, 0 deletions
diff --git a/cpp/test/FreezeScript/dbmap/run.py b/cpp/test/FreezeScript/dbmap/run.py
new file mode 100755
index 00000000000..1869f93273a
--- /dev/null
+++ b/cpp/test/FreezeScript/dbmap/run.py
@@ -0,0 +1,115 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003
+# ZeroC, Inc.
+# Billerica, MA, USA
+#
+# All Rights Reserved.
+#
+# Ice is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License version 2 as published by
+# the Free Software Foundation.
+#
+# **********************************************************************
+
+import os, sys, re, shutil
+
+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!"
+
+sys.path.append(os.path.join(toplevel, "config"))
+import TestUtil
+
+directory = os.path.join(toplevel, "test", "FreezeScript", "dbmap")
+transformdb = os.path.join(toplevel, "bin", "transformdb")
+
+dbdir = os.path.join(directory, "db")
+TestUtil.cleanDbDir(dbdir)
+
+init_dbdir = os.path.join(directory, "db_init")
+if os.path.exists(init_dbdir):
+ shutil.rmtree(init_dbdir)
+os.mkdir(init_dbdir)
+
+check_dbdir = os.path.join(directory, "db_check")
+if os.path.exists(check_dbdir):
+ shutil.rmtree(check_dbdir)
+os.mkdir(check_dbdir)
+
+tmp_dbdir = os.path.join(directory, "db_tmp")
+if os.path.exists(tmp_dbdir):
+ shutil.rmtree(tmp_dbdir)
+os.mkdir(tmp_dbdir)
+
+regex1 = re.compile(r"_old\.ice$", re.IGNORECASE)
+files = []
+for file in os.listdir(os.path.join(directory, "fail")):
+ if(regex1.search(file)):
+ files.append(file)
+
+regex2 = re.compile(r"^.*transf(ormdb|~1)(\.exe)?", re.IGNORECASE)
+
+print "testing error detection... ",
+sys.stdout.flush()
+
+files.sort()
+for oldfile in files:
+
+ newfile = oldfile.replace("old", "new")
+
+ if oldfile.find("19") == 0:
+ value = "::C"
+ else:
+ value = "int"
+
+ command = transformdb + " --old " + os.path.join(directory, "fail", oldfile) + " --new " + os.path.join(directory, "fail", newfile) + " -o tmp.xml --key string --value " + value
+
+ stdin, stdout, stderr = os.popen3(command)
+ lines1 = stderr.readlines()
+ lines2 = open(os.path.join(directory, "fail", oldfile.replace("_old.ice", ".err")), "r").readlines()
+ if len(lines1) != len(lines2):
+ print "failed! (1)"
+ sys.exit(1)
+
+ i = 0
+ while i < len(lines1):
+ line1 = regex2.sub("", lines1[i]).strip()
+ line2 = regex2.sub("", lines2[i]).strip()
+ if line1 != line2:
+ print "failed! (2)"
+ print "line1 = " + line1
+ print "line2 = " + line2
+ # sys.exit(1)
+ i = i + 1
+
+print "ok"
+
+print "testing default transformations... ",
+sys.stdout.flush()
+
+makedb = os.path.join(directory, "makedb") + " " + directory
+os.system(makedb)
+
+testold = os.path.join(directory, "TestOld.ice")
+testnew = os.path.join(directory, "TestNew.ice")
+initxml = os.path.join(directory, "init.xml")
+checkxml = os.path.join(directory, "check.xml")
+
+command = transformdb + " --old " + testold + " --new " + testold + " -f " + initxml + " " + dbdir + " default.db " + init_dbdir
+os.system(command)
+
+command = transformdb + " --old " + testold + " --new " + testnew + " --key int --value ::S " + init_dbdir + " default.db " + check_dbdir
+stdin, stdout, stderr = os.popen3(command)
+
+stderr.readlines()
+command = transformdb + " --old " + testnew + " --new " + testnew + " -f " + checkxml + " " + check_dbdir + " default.db " + tmp_dbdir
+os.system(command)
+
+print "ok"
+
+sys.exit(0)