From 45d368863ae85aba4a3b3d2b89dc78527d354af0 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Tue, 22 Jun 2010 17:30:45 +0200 Subject: [PATCH 1/1] Add test for frsh_transaction_negotiate() --- frsh_api/Makefile.omk | 6 ++++-- frsh_api/frsh_transaction.c | 42 +++++++++++++++++++++++++++++++++++++ frsh_api/tests/trans_nego.c | 29 +++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 frsh_api/frsh_transaction.c diff --git a/frsh_api/Makefile.omk b/frsh_api/Makefile.omk index fa34f24..6736340 100644 --- a/frsh_api/Makefile.omk +++ b/frsh_api/Makefile.omk @@ -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 index 0000000..6909d83 --- /dev/null +++ b/frsh_api/frsh_transaction.c @@ -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 + * + * @brief Implementation of FRSH transaction negotiation. + */ + +#include +#include + + +int +frsh_transaction_negotiate(frsh_transaction_t *trans) +{ + return FRSH_ERR_NOT_IMPLEMENTED; +} + diff --git a/frsh_api/tests/trans_nego.c b/frsh_api/tests/trans_nego.c index df9a581..5b74f78 100644 --- a/frsh_api/tests/trans_nego.c +++ b/frsh_api/tests/trans_nego.c @@ -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(); } -- 2.39.2