]> rtime.felk.cvut.cz Git - omk.git/commitdiff
First (still non-working) version of test framework.
authorMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 16 Oct 2006 10:58:00 +0000 (10:58 +0000)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 16 Oct 2006 10:58:00 +0000 (10:58 +0000)
darcs-hash:20061016105804-f2ef6-d2c1345ff3ed88c130865f5c5e31a9de3f2a2d5b.gz

tests/Makefile [new file with mode: 0644]
tests/README.tests [new file with mode: 0644]
tests/functions.sh [new file with mode: 0644]
tests/programs/Makefile [new file with mode: 0644]
tests/programs/Makefile.omk [new file with mode: 0644]
tests/programs/rules [new file with mode: 0644]
tests/programs/test.c [new file with mode: 0644]
tests/runtests.py [new file with mode: 0755]

diff --git a/tests/Makefile b/tests/Makefile
new file mode 100644 (file)
index 0000000..9115bc8
--- /dev/null
@@ -0,0 +1,3 @@
+
+all:
+       python runtests.py
\ No newline at end of file
diff --git a/tests/README.tests b/tests/README.tests
new file mode 100644 (file)
index 0000000..5b156d7
--- /dev/null
@@ -0,0 +1,46 @@
+Description of Testcases for OMK
+================================
+
+Each test resides in a separate directory. The directories can be
+nested. There is no difference between the tests in diffrent levels of
+directory structure.
+
+Structure of a Testcase
+-----------------------
+
+A directory contain the testcase if it contains at least one of these
+files: Makefile.test, run_test.
+
+Definition of a Testcase:
+
+* Makefile.test: testcase commands in the form of makefile. The test is
+  run by "make -f Makefile.test". If the exit status is zero, the
+  testcase is considered as passed, otherwise as failed.
+
+* run_test: executable file that runs the test(s). The exit status has
+  the same meaning as in the case of Makefile.test.
+
+* rules: Specifies the rules this testcase applies to. The syntax of
+  this files is describes in section Rules description.
+
+Output of testcase:
+
+Besides exit status, the testcases can produce the folowing output.
+
+* FIXME: chybove hlaseni - soubor error nebo stderr?
+
+Rules Description
+-----------------
+
+The rules file contains one or more lines. Each line represents a set
+of zero or more rules. The set of rules to be applied to this testcase
+is union of these sets.
+
+Each line can contain:
+
+* <rule name> - This selects rules of this name
+
+* all: - this selects all rules
+
+* snip:<snippet name> - this selects all the rules, which are composed
+  of the given snippet.
diff --git a/tests/functions.sh b/tests/functions.sh
new file mode 100644 (file)
index 0000000..3d7da51
--- /dev/null
@@ -0,0 +1,2 @@
+# -*-sh-*-
+
diff --git a/tests/programs/Makefile b/tests/programs/Makefile
new file mode 100644 (file)
index 0000000..aa6b442
--- /dev/null
@@ -0,0 +1,16 @@
+# Generic directory or leaf node makefile for OCERA make framework
+
+ifndef MAKERULES_DIR
+MAKERULES_DIR := $(shell ( old_pwd="" ;  while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" == `pwd`  ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
+endif
+
+ifeq ($(MAKERULES_DIR),)
+all : default
+.DEFAULT::
+       @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+else   
+include $(MAKERULES_DIR)/Makefile.rules
+endif
+
+print_vars:
+       echo $(COMPILED_DIR)
\ No newline at end of file
diff --git a/tests/programs/Makefile.omk b/tests/programs/Makefile.omk
new file mode 100644 (file)
index 0000000..dd0139e
--- /dev/null
@@ -0,0 +1,3 @@
+bin_PROGRAMS = test
+
+test_SOURCES = test.c
\ No newline at end of file
diff --git a/tests/programs/rules b/tests/programs/rules
new file mode 100644 (file)
index 0000000..baa6044
--- /dev/null
@@ -0,0 +1 @@
+all
\ No newline at end of file
diff --git a/tests/programs/test.c b/tests/programs/test.c
new file mode 100644 (file)
index 0000000..4be4888
--- /dev/null
@@ -0,0 +1,4 @@
+int main()
+{
+        return 0;
+}
diff --git a/tests/runtests.py b/tests/runtests.py
new file mode 100755 (executable)
index 0000000..0055cde
--- /dev/null
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+
+import os.path
+import sys
+import re
+
+sys.path.append("..")
+import rulesdef
+
+class TestCase:
+    def __init__(self, directory):
+        self.directory = directory
+        self._whichRules()
+
+    def _whichRules(self):
+        self.rules = []
+        try:
+            f = open(os.path.join(self.directory, 'rules'))
+        except IOError:
+            self.rules = rulesdef.rules.keys()
+            return
+        for line in f:
+            colonDef = re.search('([^:]*):(.*)', line)
+            if colonDef:
+                print colonDef.groups()
+                #todo s[nip[pet]]:...
+            elif re.search('^all', line):
+                self.rules = rulesdef.rules.keys()
+            else:
+                #todo rule name
+                print "Neco jineho: ", line
+        
+
+    def run(self):
+        print "Testing rules: ",
+        for rules in self.rules:
+            print rules,
+            self._copyRules(rules)
+            self._doRun()
+        print
+
+    def _copyRules(self, rules):
+        pass
+    
+    def _doRun(self):
+        pass
+
+x = TestCase("programs")
+x.run()
+x = TestCase("none")
+x.run()
+x = TestCase("colon")
+x.run()