From d9ceeb88cafbfadc0d7b80cad66ae85749af9ece Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Mon, 23 Oct 2006 07:11:00 +0000 Subject: [PATCH] Added tests for vxWorks. darcs-hash:20061023071110-f2ef6-3713a55f66ab0b514e82041356e8669503780f05.gz --- tests/vxworks/rtp/Makefile | 14 ++++++++++++ tests/vxworks/rtp/Makefile.omk | 4 ++++ tests/vxworks/rtp/fibo2.c | 36 +++++++++++++++++++++++++++++++ tests/vxworks/rtplib/Makefile | 14 ++++++++++++ tests/vxworks/rtplib/Makefile.omk | 5 +++++ tests/vxworks/rtplib/fibofnc.c | 15 +++++++++++++ tests/vxworks/rtplib/fibolib.h | 10 +++++++++ tests/vxworks/rtplib/fiboseries.c | 24 +++++++++++++++++++++ 8 files changed, 122 insertions(+) create mode 100644 tests/vxworks/rtp/Makefile create mode 100644 tests/vxworks/rtp/Makefile.omk create mode 100644 tests/vxworks/rtp/fibo2.c create mode 100644 tests/vxworks/rtplib/Makefile create mode 100644 tests/vxworks/rtplib/Makefile.omk create mode 100644 tests/vxworks/rtplib/fibofnc.c create mode 100644 tests/vxworks/rtplib/fibolib.h create mode 100644 tests/vxworks/rtplib/fiboseries.c diff --git a/tests/vxworks/rtp/Makefile b/tests/vxworks/rtp/Makefile new file mode 100644 index 0000000..f595272 --- /dev/null +++ b/tests/vxworks/rtp/Makefile @@ -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 index 0000000..795d36b --- /dev/null +++ b/tests/vxworks/rtp/Makefile.omk @@ -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 index 0000000..eacfc49 --- /dev/null +++ b/tests/vxworks/rtp/fibo2.c @@ -0,0 +1,36 @@ +#include +#include +#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 index 0000000..f595272 --- /dev/null +++ b/tests/vxworks/rtplib/Makefile @@ -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 index 0000000..c61fc04 --- /dev/null +++ b/tests/vxworks/rtplib/Makefile.omk @@ -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 index 0000000..4a2fcbb --- /dev/null +++ b/tests/vxworks/rtplib/fibofnc.c @@ -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 index 0000000..d3adfed --- /dev/null +++ b/tests/vxworks/rtplib/fibolib.h @@ -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 index 0000000..e12b326 --- /dev/null +++ b/tests/vxworks/rtplib/fiboseries.c @@ -0,0 +1,24 @@ +#include +#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; +} -- 2.39.2