]> rtime.felk.cvut.cz Git - frescor/frsh.git/commitdiff
Added some documentation + cleanup
authorMichal Sojka <sojkam1@fel.cvut.cz>
Sun, 14 Sep 2008 08:51:38 +0000 (10:51 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Sun, 14 Sep 2008 08:51:38 +0000 (10:51 +0200)
14 files changed:
Makefile.omk
contract.c [deleted file]
contract.h [deleted file]
contract_internal.h [deleted file]
forb_contract.c [new file with mode: 0644]
forb_contract.h [new file with mode: 0644]
forb_contract_idl.idl [moved from contract-idl.idl with 70% similarity]
forb_contract_internal.h [new file with mode: 0644]
frsh_contract.c
frsh_opaque_types.h
idl_native.h [new file with mode: 0644]
tests/Makefile [new file with mode: 0644]
tests/Makefile.omk [new file with mode: 0644]
tests/contract.c [new file with mode: 0644]

index 88ebbc640889483cf853219329f64a27373304c8..d443c94c5dd35bf096dd73cc8e7cfc1406212427 100644 (file)
@@ -1,12 +1,15 @@
 default_CONFIG = CONFIG_FRSH_FORB=y
 
 ifeq ($(CONFIG_FRSH_FORB),y)
+
+SUBDIRS=tests
+
 shared_LIBRARIES = frsh
 
-frsh_SOURCES = contract.c frsh_contract.c
-frsh_CLIENT_IDL = contract-idl.idl
+frsh_SOURCES = forb_contract.c frsh_contract.c
+frsh_CLIENT_IDL = forb_contract_idl.idl
 
-include_HEADERS = contract.h frsh_opaque_types.h
+include_HEADERS = forb_contract.h frsh_opaque_types.h idl_native.h
 
-include_GEN_HEADERS = contract-idl.h
+include_GEN_HEADERS = forb_contract_idl.h
 endif
diff --git a/contract.c b/contract.c
deleted file mode 100644 (file)
index 6611570..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-#include <contract.h>
-#include "contract_internal.h"
-#include <stdbool.h>
-#include <ul_list.h>
-#include <string.h>
-#include <frsh_error.h>
-
-
-struct contract *
-contract_new(void)
-{
-       struct contract *c;
-
-       c = malloc(sizeof(*c));
-       if (c) {
-               memset(c, 0, sizeof(*c));
-       }
-       return c;
-}
-
-void
-contract_destroy(struct contract *contract)
-{
-       /* TODO handle all other deallocations */
-       free(contract);
-}
-
-int
-contract_add_params(struct contract *contract,
-                   enum contract_part_type type,
-                   void *part_data)
-{
-       if (!TYPE_VALID(type) ||
-           contract->parts[type].state != CONTRACT_PART_EMPTY)
-               return FRSH_ERR_BAD_ARGUMENT;
-
-       contract->parts[type].u.data = part_data;
-       return 0;
-}
-
-int
-contract_del_params(struct contract *contract,
-                   enum contract_part_type type)
-{
-       if (TYPE_VALID(type)) {
-               switch (contract->parts[type].state) {
-                       case CONTRACT_PART_EMPTY:
-                               /* nothing to do */
-                               break;
-                       case CONTRACT_PART_DATA:
-                               free(contract->parts[type].u.data);
-                               contract->parts[type].state = CONTRACT_PART_EMPTY;
-                               break;
-                       case CONTRACT_PART_STREAM:
-                               /* TODO: stream_free(contract->parts[type].u.seq); */
-                               contract->parts[type].state = CONTRACT_PART_EMPTY;
-                               break;
-               }
-       }
-       return 0;
-}
-
-void *
-contract_get_params(struct contract *contract,
-                   enum contract_part_type type)
-{
-       if (contract &&
-           TYPE_VALID(type) &&
-           contract->parts[type].state == CONTRACT_PART_DATA) {
-               return contract->parts[type].u.data;
-       } else {
-               return NULL;
-       }
-}
-
-CORBA_boolean
-contract_serialize(CDR_Codec *codec, const struct contract *contract)
-{
-       CORBA_long l;
-       CORBA_long count;
-       CORBA_short s;
-       int i;
-       if (!contract)
-               return false;
-
-       l = contract->resource_id;
-       CORBA_long_serialize(codec, &l);
-       l = contract->resource_type;
-       CORBA_long_serialize(codec, &l);
-       /* TODO: Label */
-
-       count=0;
-       for (i=0; i<_FRSH_CONTRACT_NUM_PARAMS; i++) {
-               if (contract->parts[i].state != CONTRACT_PART_EMPTY)
-                       count++;
-       }
-
-       if (!CORBA_long_serialize(codec, &count))
-               goto err;
-       
-       for (i=0; i<_FRSH_CONTRACT_NUM_PARAMS; i++) {
-               if (contract->parts[i].state != CONTRACT_PART_EMPTY) {
-                       s = i;
-                       CORBA_short_serialize(codec, &s);
-                       
-               }
-       }
-       return CORBA_TRUE;
-err:
-       return CORBA_FALSE;
-}
-
diff --git a/contract.h b/contract.h
deleted file mode 100644 (file)
index f933f04..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef CONTRACT_H
-#define CONTRACT_H
-
-
-#include <forb/basic_types.h>
-#include <frsh_cpp_macros.h>
-#include <fosa_types.h>
-#include <frsh_core_types.h>
-#include <contract-idl.h>
-
-/*============================================================================*/
-
-/**
- * Incomplete declaration of contract type
- */
-struct contract;
-
-enum contract_part_type {
-       FRSH_CONTRACT_BASIC_PARAMS,
-       FRSH_CONTRACT_SPARE_CAPACITY,
-       _FRSH_CONTRACT_NUM_PARAMS
-};
-
-struct contract *
-contract_new(void);
-
-void
-contract_destroy(struct contract *contract);
-
-int
-contract_add_params(struct contract *contract,
-                   enum contract_part_type type,
-                   void *part_data);
-
-int
-contract_del_params(struct contract *contract,
-                   enum contract_part_type type);
-
-void *
-contract_get_params(struct contract *contract,
-                   enum contract_part_type type);
-
-CORBA_boolean
-contract_serialize(CDR_Codec *codec, const struct contract *contract);
-
-CORBA_boolean
-contract_deserialize(CDR_Codec *codec, struct contract **contract);
-
-
-#endif
diff --git a/contract_internal.h b/contract_internal.h
deleted file mode 100644 (file)
index fd851ae..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef CONTRACT_INTERNAL_H
-#define CONTRACT_INTERNAL_H
-
-enum contract_part_state {
-       CONTRACT_PART_EMPTY,
-       CONTRACT_PART_DATA,
-       CONTRACT_PART_STREAM
-};
-
-struct contract_part {
-       enum contract_part_state state;
-       union {
-               void *data; /**< Pointer to data according to part_type */
-               stream seq;
-       } u;
-};
-
-struct contract {
-       /** Processor Id or Network Id **/
-       frsh_resource_id_t   resource_id;
-
-       /** Whether processor or network **/
-       frsh_resource_type_t resource_type;
-
-       struct contract_part parts[_FRSH_CONTRACT_NUM_PARAMS];
-};
-
-#define TYPE_VALID(type)                       \
-       ((type) < _FRSH_CONTRACT_NUM_PARAMS &&  \
-        (type) >= 0)
-
-
-#endif
diff --git a/forb_contract.c b/forb_contract.c
new file mode 100644 (file)
index 0000000..d97badf
--- /dev/null
@@ -0,0 +1,124 @@
+/**
+ * @file   forb_contract.c
+ * @author Michal Sojka <sojkam1@fel.cvut.cz>
+ * 
+ * @brief  Functions for manipulating with forb-based contracts.
+ * 
+ * 
+ */
+#include <forb_contract.h>
+#include "forb_contract_internal.h"
+#include <stdbool.h>
+#include <ul_list.h>
+#include <string.h>
+#include <frsh_error.h>
+
+struct forb_contract *
+forb_contract_new(void)
+{
+       struct forb_contract *c;
+
+       c = malloc(sizeof(*c));
+       if (c) {
+               memset(c, 0, sizeof(*c));
+       }
+       return c;
+}
+
+void
+forb_contract_destroy(struct forb_contract *contract)
+{
+       enum forb_contract_params_type i;
+       for (i=0; i<_FORB_CONTRACT_NUM_PARAMS; i++) {
+               forb_contract_del_params(contract, i);
+       }
+
+       free(contract);
+}
+
+int
+forb_contract_add_params(struct forb_contract *contract,
+                        enum forb_contract_params_type type,
+                        void *params)
+{
+       if (!TYPE_VALID(type) ||
+           contract->params[type].state != FORB_CONTRACT_PARAM_EMPTY)
+               return FRSH_ERR_BAD_ARGUMENT;
+
+       contract->params[type].u.data = params;
+       return 0;
+}
+
+int
+forb_contract_del_params(struct forb_contract *contract,
+                        enum forb_contract_params_type type)
+{
+       if (TYPE_VALID(type)) {
+               switch (contract->params[type].state) {
+                       case FORB_CONTRACT_PARAM_EMPTY:
+                               /* nothing to do */
+                               break;
+                       case FORB_CONTRACT_PARAM_DATA:
+                               free(contract->params[type].u.data);
+                               contract->params[type].state = FORB_CONTRACT_PARAM_EMPTY;
+                               break;
+                       case FORB_CONTRACT_PARAM_STREAM:
+                               /* FIXME: IDL compiler should generate stream_free() */
+                               forb_free(contract->params[type].u.stream._buffer);
+                               contract->params[type].state = FORB_CONTRACT_PARAM_EMPTY;
+                               break;
+               }
+       }
+       return 0;
+}
+
+void *
+forb_contract_get_params(struct forb_contract *contract,
+                        enum forb_contract_params_type type)
+{
+       if (contract &&
+           TYPE_VALID(type) &&
+           contract->params[type].state == FORB_CONTRACT_PARAM_DATA) {
+               return contract->params[type].u.data;
+       } else {
+               return NULL;
+       }
+}
+
+CORBA_boolean
+forb_contract_serialize(CDR_Codec *codec, const struct forb_contract *contract)
+{
+       CORBA_long l;
+       CORBA_long count;
+       CORBA_short s;
+       enum forb_contract_params_type i;
+       if (!contract)
+               return false;
+
+       l = contract->resource_id;
+       CORBA_long_serialize(codec, &l);
+       l = contract->resource_type;
+       CORBA_long_serialize(codec, &l);
+       /* TODO: Label */
+
+       count=0;
+       for (i=0; i<_FORB_CONTRACT_NUM_PARAMS; i++) {
+               if (contract->params[i].state != FORB_CONTRACT_PARAM_EMPTY)
+                       count++;
+       }
+
+       if (!CORBA_long_serialize(codec, &count))
+               goto err;
+       
+       for (i=0; i<_FORB_CONTRACT_NUM_PARAMS; i++) {
+               if (contract->params[i].state != FORB_CONTRACT_PARAM_EMPTY) {
+                       s = i;
+                       CORBA_short_serialize(codec, &s);
+                       
+               }
+       }
+       return CORBA_TRUE;
+err:
+       return CORBA_FALSE;
+}
+
diff --git a/forb_contract.h b/forb_contract.h
new file mode 100644 (file)
index 0000000..748d33b
--- /dev/null
@@ -0,0 +1,138 @@
+/**
+ * @file   forb_contract.h
+ * @author Michal Sojka <sojkam1@fel.cvut.cz>
+ * 
+ * @brief  Public interface to forb-based contracts.
+ * 
+ * 
+ */
+#ifndef FORB_CONTRACT_H
+#define FORB_CONTRACT_H
+
+
+#include <forb/basic_types.h>
+#include <frsh_cpp_macros.h>
+#include <fosa_types.h>
+#include <frsh_core_types.h>
+#include <forb_contract_idl.h>
+
+/*============================================================================*/
+
+/**
+ * Data type for represenataion of contracts (imcomplete declaration).
+ */
+struct forb_contract;
+
+
+/**
+ * Identification of different types of contract parameters.
+ *
+ * All contract parameters should define their ID here. This is the
+ * only place, where the different parameters (e.g. for different
+ * kinds of resources) share a common source file. The declaration of
+ * params struture can occur at any place (.h or better .idl).
+ * 
+ */
+enum forb_contract_params_type {
+       FORB_CONTRACT_PARAMS_BASIC,
+       FORB_CONTRACT_PARAMS_TIMING_REQS,
+       FORB_CONTRACT_PARAMS_SPARE_CAPACITY,
+       _FORB_CONTRACT_NUM_PARAMS
+};
+
+struct forb_contract_params_desc {
+       size_t size;
+       CORBA_boolean (*serialize)(CDR_Codec *codec, const void *params);
+       CORBA_boolean (*deserialize)(CDR_Codec *codec, void **params);
+};
+
+/** 
+ * Allocates memory for a new contract.
+ * 
+ * @return 
+ */
+struct forb_contract *
+forb_contract_new(void);
+
+/** 
+ * Deallocates all memory occupied by a contract.
+ * 
+ * @param contract 
+ */
+void
+forb_contract_destroy(struct forb_contract *contract);
+
+/** 
+ * Adds parameters of a specific type to a contract.
+ * 
+ * @param contract Contract to which add the parameters.
+ * @param type Which type of parameters is being added.
+ * @param params Values of parameters to add (in most cases pointer to
+ * a structure defined in IDL).
+ * 
+ * @return Zero on success, FRSH_ERR_BAD_ARGUMENT if the contract
+ * already contains this @a type of parameters.
+ */
+int
+forb_contract_add_params(struct forb_contract *contract,
+                        enum forb_contract_params_type type,
+                        void *params);
+/** 
+ * Removes specific parameters from a contract and frees all memory
+ * occupied by these parameters.
+ * 
+ * @param contract 
+ * @param type Which type of parameters to remove.
+ * 
+ * @return 
+ */
+int
+forb_contract_del_params(struct forb_contract *contract,
+                        enum forb_contract_params_type type);
+
+/** 
+ * Return a specific type of contract parameters.
+ * 
+ * @param contract 
+ * @param type Which parameters to return.
+ * 
+ * @return Pointer to the requested parameters of NULL if the
+ * parameters was not added to the contract.
+ */
+void *
+forb_contract_get_params(struct forb_contract *contract,
+                        enum forb_contract_params_type type);
+
+CORBA_boolean
+forb_contract_serialize(CDR_Codec *codec, const struct forb_contract *contract);
+
+CORBA_boolean
+forb_contract_deserialize(CDR_Codec *codec, struct forb_contract **contract);
+
+#define FORB_CONTRACT_ACCESSOR(TYPE, type)                             \
+       static inline int                                               \
+       forb_contract_add_params_##type(struct forb_contract *contract, \
+                                       forb_contract_params_##type *params) \
+       {                                                               \
+               return forb_contract_add_params(contract,               \
+                                               FORB_CONTRACT_PARAMS_##TYPE, \
+                                               params);                \
+       }                                                               \
+       static inline forb_contract_params_##type *                     \
+       forb_contract_get_params_##type(struct forb_contract *contract) \
+       {                                                               \
+               return forb_contract_get_params(contract,               \
+                                               FORB_CONTRACT_PARAMS_##TYPE); \
+       }                                                               \
+       static inline int                                               \
+       forb_contract_del_params_##type(struct forb_contract *contract) \
+       {                                                               \
+               return forb_contract_del_params(contract,               \
+                                               FORB_CONTRACT_PARAMS_##TYPE); \
+       }
+
+FORB_CONTRACT_ACCESSOR(BASIC,           basic);
+FORB_CONTRACT_ACCESSOR(TIMING_REQS,    timing_reqs);
+FORB_CONTRACT_ACCESSOR(SPARE_CAPACITY,         spare_capacity);
+
+#endif
similarity index 70%
rename from contract-idl.idl
rename to forb_contract_idl.idl
index aacc96d22b3951f88c6f55116084a90e332863a4..7de3b0900cf50ac8e08a4289c3157572d2f6ada3 100644 (file)
@@ -8,16 +8,16 @@
  */
 
 typedef sequence<octet> stream;
-       
-module frsh {
-       struct timespec {
-               long tv_sec;
-               long tv_nsec;
-       };
 
-       // TODO: Try to use native types
-       typedef timespec fosa_rel_time_t;
-       typedef timespec fosa_abs_time_t;
+native fosa_rel_time_t;
+native fosa_abs_time_t;
+
+module forb {
+       enum frsh_workload_t {
+               FRSH_WT_BOUNDED,
+               FRSH_WT_INDETERMINATE,
+               FRSH_WT_SYNCHRONIZED
+       };
 
        enum frsh_contract_type_t {
                FRSH_CT_REGULAR,
@@ -25,7 +25,6 @@ module frsh {
                FRSH_CT_DUMMY
        };
 
-
        native contract_t;
        native contract_handle_t;
 
@@ -36,15 +35,11 @@ module frsh {
                /// modules. Any other module can add their own
                /// parameters.
                module params {
-
-                       /// IDs of all (even externally defined) parameters
-                       enum id {
-                               BASIC_PARAMS,
-                               SPARE_CAPACITY_PARAMS
-                       };
                        struct basic {
+                               // forb_contract_params_type == FORB_CONTRACT_PARAMS_BASIC
                                fosa_rel_time_t budget;
                                fosa_rel_time_t period;
+                               frsh_workload_t workload;
                                frsh_contract_type_t contract_type;
                        };
                        
@@ -53,6 +48,13 @@ module frsh {
                                fosa_rel_time_t stability_time;
                                granularity_t granularity;
                        };
+                       struct timing_reqs {
+                               boolean d_equals_t;
+                               fosa_rel_time_t deadline;
+                               // TODO: Signals
+                       };
+
                };
+               
        };
 };
diff --git a/forb_contract_internal.h b/forb_contract_internal.h
new file mode 100644 (file)
index 0000000..b38f8c9
--- /dev/null
@@ -0,0 +1,49 @@
+/**
+ * @file   forb_contract_internal.h
+ * @author Michal Sojka <sojkam1@fel.cvut.cz>
+ * 
+ * @brief  Internal interface to forb-based contracts.
+ *
+ * This header should only be included by files in frsh library.
+ * 
+ */
+#ifndef FORB_CONTRACT_INTERNAL_H
+#define FORB_CONTRACT_INTERNAL_H
+
+#include "forb_contract.h"
+
+enum forb_contract_param_state {
+       /** There are no such parameters inside contract.  */
+       FORB_CONTRACT_PARAM_EMPTY,
+       /** The contract contains the parameters in the deserialized
+        * form. */
+       FORB_CONTRACT_PARAM_DATA,
+       /** The contract contains the parameters in the serialized
+        * form (sequence of octets).*/
+       FORB_CONTRACT_PARAM_STREAM
+};
+
+struct forb_contract_params {
+       enum forb_contract_param_state state;
+       union {
+               void *data; /**< Pointer to data according to param_type */
+               stream stream;
+       } u;
+};
+
+struct forb_contract {
+       /** Processor Id or Network Id **/
+       frsh_resource_id_t   resource_id;
+
+       /** Whether processor or network **/
+       frsh_resource_type_t resource_type;
+
+       struct forb_contract_params params[_FORB_CONTRACT_NUM_PARAMS];
+};
+
+#define TYPE_VALID(type)                       \
+       ((type) < _FORB_CONTRACT_NUM_PARAMS &&  \
+        (type) >= 0)
+
+
+#endif
index 995901386810efe639f536aaa742d81605e4d6e5..e3a7036550907d927e29d935579aa0aea398c179 100644 (file)
@@ -1,5 +1,14 @@
-#include <contract.h>
-#include "contract_internal.h"
+/**
+ * @file   frsh_contract.c
+ * @author Michal Sojka <sojkam1@fel.cvut.cz>
+ * 
+ * @brief  Implementation of FRSH contract API on top of forb-based contracts.
+ * 
+ * 
+ */
+#include <forb_contract.h>
+#include "forb_contract_internal.h"
+#include <forb_contract_idl.h>
 #include <frsh_core.h>
 #include <frsh_error.h>
 
 int
 frsh_contract_init(frsh_contract_t *contract)
 {
-       struct contract *c;
+       struct forb_contract *c;
 
        if (!contract) {
                return FRSH_ERR_BAD_ARGUMENT;
        }
-       c = contract_new();
+       c = forb_contract_new();
        *contract = c;
        if (!c) {
                return FOSA_ENOMEM;
@@ -26,16 +35,46 @@ frsh_contract_init(frsh_contract_t *contract)
        return 0;
 }
 
+int frsh_contract_set_basic_params
+  (frsh_contract_t *contract,
+   const frsh_rel_time_t      *budget_min,
+   const frsh_rel_time_t      *period_max,
+   const frsh_workload_t      workload,
+   const frsh_contract_type_t contract_type)
+{
+       forb_contract_params_basic *b;
+       if (!contract ||
+           !*contract ||
+           !budget_min ||
+           !period_max) {
+               return FRSH_ERR_BAD_ARGUMENT;
+       }
+
+       b = malloc(sizeof(*b));
+       if (!b) {
+               /* We should return something else, but the FRSH API
+                * allows only this error. errno is set correctly. */
+               return FRSH_ERR_BAD_ARGUMENT;
+       }
+
+       b->budget = *budget_min;
+       b->period = *period_max;
+       b->workload = workload; /* FIXME: Handle type range */
+       b->contract_type = contract_type; /* FIXME: Handle type range */
+       return forb_contract_add_params_basic(*contract, b);
+}
+
 int frsh_contract_set_resource_and_label
   (frsh_contract_t *contract,
    const frsh_resource_type_t resource_type,
    const frsh_resource_id_t resource_id,
    const char *contract_label)
 {
-       struct contract *c = *contract;
-       if (!c)
+       struct forb_contract *c;
+       if (!contract || !*contract)
                return FRSH_ERR_BAD_ARGUMENT;
-       
+       c = *contract;
+
        c->resource_type = resource_type;
        c->resource_id = resource_id;
        /* contract_label is currently ignored */
@@ -51,4 +90,24 @@ int frsh_contract_set_timing_reqs
    const frsh_signal_t          deadline_miss_signal,
    const frsh_signal_info_t     deadline_miss_siginfo)
 {
+       forb_contract_params_timing_reqs *p;
+
+       if (!contract || !*contract)
+               return FRSH_ERR_BAD_ARGUMENT;
+
+       p = malloc(sizeof(*p));
+       if (!p) {
+               /* We should return something else, but the FRSH API
+                * allows only this error. errno is set correctly. */
+               return FRSH_ERR_BAD_ARGUMENT;
+       }
+       p->d_equals_t = d_equals_t;
+       if (!d_equals_t) {
+               if (deadline) {
+                       p->deadline = *deadline;
+               } else {
+                       return FRSH_ERR_BAD_ARGUMENT;
+               }
+       }
+       return forb_contract_add_params_timing_reqs(*contract, p);
 }
index 4c1c4cb2977e5f2be392959415b3c533ea0d0c23..769dc7e7d145f72d7cc9943067af45778935eb25 100644 (file)
@@ -70,7 +70,7 @@
 #ifndef _FRSH_OPAQUE_TYPES_H_
 #define _FRSH_OPAQUE_TYPES_H_
 
-#include <contract.h>
+#include <forb_contract.h>
 
 FRSH_CPP_BEGIN_DECLS
 
@@ -94,7 +94,7 @@ FRSH_CPP_BEGIN_DECLS
  **/
 
 /** frsh_contract_parameters_t **/
-#define FRSH_CONTRACT_T_OPAQUE struct contract *
+#define FRSH_CONTRACT_T_OPAQUE struct forb_contract *
 
 
 typedef int FRSH_SYNCHOBJ_HANDLE_T_OPAQUE;
diff --git a/idl_native.h b/idl_native.h
new file mode 100644 (file)
index 0000000..b261895
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef _IDL_NATIVE_H
+#define _IDL_NATIVE_H
+
+/* /\* FIXME: time.h should be included in fosa_opaque_types.h *\/ */
+/* #include <time.h>           /\* We need struct timespec *\/ */
+#include <fosa.h>
+
+#define fosa_rel_time_t_serialize(a,b) CORBA_FALSE
+#define fosa_rel_time_t_deserialize(a,b) CORBA_FALSE
+#define fosa_abs_time_t_serialize(a,b) CORBA_FALSE
+#define fosa_abs_time_t_deserialize(a,b) CORBA_FALSE
+
+#endif
diff --git a/tests/Makefile b/tests/Makefile
new file mode 100644 (file)
index 0000000..b22a357
--- /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/Makefile.omk b/tests/Makefile.omk
new file mode 100644 (file)
index 0000000..0715edc
--- /dev/null
@@ -0,0 +1,6 @@
+test_PROGRAMS:=$(basename $(notdir $(wildcard $(SOURCES_DIR)/*.c)))
+
+$(foreach t,$(test_PROGRAMS),\
+$(eval $(t)_SOURCES = $(t).c)\
+$(eval $(t)_LIBS = fosa m frsh utils rt forb)\
+)
diff --git a/tests/contract.c b/tests/contract.c
new file mode 100644 (file)
index 0000000..b0c2283
--- /dev/null
@@ -0,0 +1,10 @@
+#include <forb_contract.h>
+
+int main()
+{
+       struct forb_contract *c;
+
+       c = forb_contract_new();
+       
+       return 0;
+}