]> rtime.felk.cvut.cz Git - frescor/frsh.git/commitdiff
Add test for frsh_transaction_negotiate()
authorMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 22 Jun 2010 15:30:45 +0000 (17:30 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 22 Jun 2010 15:30:45 +0000 (17:30 +0200)
frsh_api/Makefile.omk
frsh_api/frsh_transaction.c [new file with mode: 0644]
frsh_api/tests/trans_nego.c

index fa34f242ded4f60537fc52de3fb244ad93b30bcf..6736340f858f8d81544ef3aa92c19476d374c6a7 100644 (file)
@@ -1,8 +1,10 @@
 SUBDIRS = tests
 
 shared_LIBRARIES = frsh
-frsh_SOURCES = frsh_contract.c frsh_vres.c frsh_synchobj.c frsh_core.c \
-               frsh_spare_capacity.c frsh_error.c frsh_thread.c frsh_sharedobj.c frsh_power.c frsh_feedback.c
+frsh_SOURCES = frsh_contract.c frsh_vres.c frsh_synchobj.c frsh_core.c \
+               frsh_spare_capacity.c frsh_error.c frsh_thread.c        \
+               frsh_sharedobj.c frsh_power.c frsh_feedback.c           \
+               frsh_transaction.c
 include_HEADERS = frsh_opaque_types.h frsh_forb.h
 frsh_LIBS = fcb_client forb contract synchobj sharedobj fra ulut fosa $(allocator-libs-y) $(platform-libs-y)
 
diff --git a/frsh_api/frsh_transaction.c b/frsh_api/frsh_transaction.c
new file mode 100644 (file)
index 0000000..6909d83
--- /dev/null
@@ -0,0 +1,42 @@
+/**************************************************************************/
+/* Copyright (C) 2010 Czech Technical University in Prague               */
+/*                                                                       */
+/*  This file is part of FRSH (FRescor ScHeduler)                        */
+/*                                                                       */
+/* FRSH is free software; you can redistribute it and/or modify it       */
+/* under terms of the GNU General Public License as published by the     */
+/* Free Software Foundation; either version 2, or (at your option) any   */
+/* later version.  FRSH is distributed in the hope that it will be       */
+/* useful, but WITHOUT ANY WARRANTY; without even the implied warranty   */
+/* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   */
+/* General Public License for more details. You should have received a   */
+/* copy of the GNU General Public License along with FRSH; see file      */
+/* COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,  */
+/* Cambridge, MA 02139, USA.                                             */
+/*                                                                       */
+/* As a special exception, including FRSH header files in a file,        */
+/* instantiating FRSH generics or templates, or linking other files      */
+/* with FRSH objects to produce an executable application, does not      */
+/* by itself cause the resulting executable application to be covered    */
+/* by the GNU General Public License. This exception does not            */
+/* however invalidate any other reasons why the executable file might be  */
+/* covered by the GNU Public License.                                    */
+/**************************************************************************/
+
+/**
+ * @file   frsh_transaction.c
+ * @author Michal Sojka <sojkam1@fel.cvut.cz>
+ * 
+ * @brief  Implementation of FRSH transaction negotiation.
+ */
+
+#include <frsh.h>
+#include <frsh_transaction.h>
+
+
+int
+frsh_transaction_negotiate(frsh_transaction_t *trans)
+{
+       return FRSH_ERR_NOT_IMPLEMENTED;
+}
+
index df9a5819fbaa4da704f2bdadc4fa3daad11674a5..5b74f782a01d599577793fbeeded783513a4d323 100644 (file)
@@ -4,9 +4,38 @@
 
 WVTEST_MAIN("transaction negotiation")
 {
+       frsh_contract_t contract[3];
+       const frsh_resource_id_t id[3] = { 255, 0, 1 };
+       frsh_contract_label_t label[3];
+       frsh_rel_time_t budget, period;
+       int i;
+       fres_transaction_t *t;
+       
        WVFRSH(frsh_init());
        WVFRSH(fra_dummy_init_and_activate_id(0));
        WVFRSH(fra_dummy_init_and_activate_id(1));
+
+       WVPASS(t = fres_transaction_new());
+
+       for (i = 0; i < 3; i++) {
+               WVFRSH(frsh_contract_init(&contract[i]));
+               sprintf(label[i], "contract%d", i);
+               WVFRSH(frsh_contract_set_resource_and_label(
+                              &contract[i],
+                              DUMMY_RESOURCE_TYPE, id[i],
+                              label[i]));
+
+               budget = fosa_msec_to_rel_time(10);
+               period = fosa_msec_to_rel_time(100);
+               WVFRSH(frsh_contract_set_basic_params(&contract[i],
+                                                     &budget,
+                                                     &period,
+                                                     FRSH_WT_BOUNDED,
+                                                     FRSH_CT_REGULAR));
+
+               WVPASS(fres_transaction_add_contract(t, contract[i]) > 0);
+       }
+       WVFRSH(frsh_transaction_negotiate(t));
        
        frsh_destroy();
 }