]> rtime.felk.cvut.cz Git - omk.git/commitdiff
Added tests for vxWorks.
authorMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 23 Oct 2006 07:11:00 +0000 (07:11 +0000)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 23 Oct 2006 07:11:00 +0000 (07:11 +0000)
darcs-hash:20061023071110-f2ef6-3713a55f66ab0b514e82041356e8669503780f05.gz

tests/vxworks/rtp/Makefile [new file with mode: 0644]
tests/vxworks/rtp/Makefile.omk [new file with mode: 0644]
tests/vxworks/rtp/fibo2.c [new file with mode: 0644]
tests/vxworks/rtplib/Makefile [new file with mode: 0644]
tests/vxworks/rtplib/Makefile.omk [new file with mode: 0644]
tests/vxworks/rtplib/fibofnc.c [new file with mode: 0644]
tests/vxworks/rtplib/fibolib.h [new file with mode: 0644]
tests/vxworks/rtplib/fiboseries.c [new file with mode: 0644]

diff --git a/tests/vxworks/rtp/Makefile b/tests/vxworks/rtp/Makefile
new file mode 100644 (file)
index 0000000..f595272
--- /dev/null
@@ -0,0 +1,14 @@
+# 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
+
diff --git a/tests/vxworks/rtp/Makefile.omk b/tests/vxworks/rtp/Makefile.omk
new file mode 100644 (file)
index 0000000..795d36b
--- /dev/null
@@ -0,0 +1,4 @@
+bin_PROGRAMS = fibo2
+fibo2_SOURCES = fibo2.c
+fibo2_LIBS = fibo
+
diff --git a/tests/vxworks/rtp/fibo2.c b/tests/vxworks/rtp/fibo2.c
new file mode 100644 (file)
index 0000000..eacfc49
--- /dev/null
@@ -0,0 +1,36 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "fibolib.h"
+
+int
+main (int argc, char *argv[])
+{
+    int n;
+    int res;
+    char *p;
+    int *series;
+
+    if (argc >= 2) {
+       n = strtol (argv[1], &p, 0);
+       if ((p == argv[1]) || *p) {
+           fprintf (stderr, "The \"%s\" string is not a number\n", argv[1]);
+           return 1;
+       }
+    } else {
+       printf ("Input number: ");
+       scanf ("%d", &n);
+    }
+
+    res = fiboseries (&series, n);
+    if (res <= 0) {
+       fprintf (stderr, "fiboseries() failed for %d with code %d\n", n, res);
+       return 1;
+    }
+
+    /* Incorrect use of the function without prototype!!! */
+    fiboprint (series, n);
+
+    printf ("fibocalls=%d\n", fibocalls);
+
+    return 0;
+}
diff --git a/tests/vxworks/rtplib/Makefile b/tests/vxworks/rtplib/Makefile
new file mode 100644 (file)
index 0000000..f595272
--- /dev/null
@@ -0,0 +1,14 @@
+# 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
+
diff --git a/tests/vxworks/rtplib/Makefile.omk b/tests/vxworks/rtplib/Makefile.omk
new file mode 100644 (file)
index 0000000..c61fc04
--- /dev/null
@@ -0,0 +1,5 @@
+lib_LIBRARIES = fibo
+fibo_SOURCES = fibofnc.c fiboseries.c
+include_HEADERS = fibolib.h
+
+
diff --git a/tests/vxworks/rtplib/fibofnc.c b/tests/vxworks/rtplib/fibofnc.c
new file mode 100644 (file)
index 0000000..4a2fcbb
--- /dev/null
@@ -0,0 +1,15 @@
+#include "fibolib.h"
+
+int fibocalls;
+
+int
+fibofnc (int n)
+{
+    fibocalls++;
+
+    if (n <= 0)
+       return 0;
+    if (n == 1)
+       return 1;
+    return fibofnc (n - 1) + fibofnc (n - 2);
+}
diff --git a/tests/vxworks/rtplib/fibolib.h b/tests/vxworks/rtplib/fibolib.h
new file mode 100644 (file)
index 0000000..d3adfed
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef FIBOLIB_H
+#define FIBOLIB_H
+
+extern int fibocalls;
+
+int fibofnc (int n);
+
+int fiboseries (int **series, int n);
+
+#endif /*FIBOLIB_H */
diff --git a/tests/vxworks/rtplib/fiboseries.c b/tests/vxworks/rtplib/fiboseries.c
new file mode 100644 (file)
index 0000000..e12b326
--- /dev/null
@@ -0,0 +1,24 @@
+#include <stdlib.h>
+#include "fibolib.h"
+
+int
+fiboseries (int **series, int n)
+{
+    int *p;
+    int i;
+
+    if (n < 0)
+       return 0;
+
+    p = malloc (sizeof (int) * (n + 1));
+    *series = p;
+
+    if (!p)
+       return 0;
+
+    for (i = 0; i <= n; i++) {
+       p[i] = fibofnc (i);
+    }
+
+    return 1;
+}