1 //----------------------------------------------------------------------
2 // Copyright (C) 2006 - 2009 by the FRESCOR consortium:
4 // Universidad de Cantabria, SPAIN
5 // University of York, UK
6 // Scuola Superiore Sant'Anna, ITALY
7 // Kaiserslautern University, GERMANY
8 // Univ. Politecnica Valencia, SPAIN
9 // Czech Technical University in Prague, CZECH REPUBLIC
11 // Thales Communication S.A. FRANCE
12 // Visual Tools S.A. SPAIN
13 // Rapita Systems Ltd UK
16 // See http://www.frescor.org
18 // The FRESCOR project (FP6/2005/IST/5-034026) is funded
19 // in part by the European Union Sixth Framework Programme
20 // The European Union is not liable of any use that may be
24 // based on previous work (FSF) done in the FIRST project
26 // Copyright (C) 2005 Mälardalen University, SWEDEN
27 // Scuola Superiore S.Anna, ITALY
28 // Universidad de Cantabria, SPAIN
29 // University of York, UK
31 // This file is part of FNA (Frescor Network Adaptation)
33 // FNA is free software; you can redistribute it and/or modify it
34 // under terms of the GNU General Public License as published by the
35 // Free Software Foundation; either version 2, or (at your option) any
36 // later version. FNA is distributed in the hope that it will be
37 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
38 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
39 // General Public License for more details. You should have received a
40 // copy of the GNU General Public License along with FNA; see file
41 // COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,
42 // Cambridge, MA 02139, USA.
44 // As a special exception, including FNA header files in a file,
45 // instantiating FNA generics or templates, or linking other files
46 // with FNA objects to produce an executable application, does not
47 // by itself cause the resulting executable application to be covered
48 // by the GNU General Public License. This exception does not
49 // however invalidate any other reasons why the executable file might be
50 // covered by the GNU Public License.
51 // -----------------------------------------------------------------------
53 * @file test_frescan_bwres_robjs_wait.c
55 * @brief test for the basic behaviour of reply objects
62 * Daniel Sangorrin <daniel.sangorrin@unican.es>
66 * This file contains a basic test for the frescan_bwres_robjs module.
67 * The main thread allocates a reply object, creates a thread and waits
68 * on the reply object until the thread signals it.
72 * See the COPYING file in the FNA's root directory
76 #include <stdio.h> /* for printf */
77 #include <assert.h> /* for assert */
78 #include <unistd.h> /* for sleep */
79 #include "fosa_threads_and_signals.h" /* for fosa_thread_xxx */
80 #include "frescan_bwres_robjs.h"
84 static void *thread_code(void *arg);
89 frescan_bwres_robj_id_t id;
90 fosa_thread_attr_t th_attr;
93 printf("TEST REPLY OBJECTS\n");
95 err = fosa_thread_set_prio(fosa_thread_self(), CEILING - 1);
98 err = frescan_bwres_robjs_init(CEILING);
101 err = frescan_bwres_robjs_alloc(&id, CEILING);
104 err = fosa_thread_attr_init(&th_attr);
107 err = fosa_thread_attr_set_prio(&th_attr, CEILING - 1);
110 err = fosa_thread_create (&tid, &th_attr, thread_code, (void *) id);
113 err = fosa_thread_attr_destroy(&th_attr);
116 err = frescan_bwres_robjs_wait(id);
118 printf("signal received\n");
120 err = frescan_bwres_robjs_free(id);
123 printf("TEST [OK!]\n");
128 static void *thread_code(void *arg)
131 frescan_bwres_robj_id_t reply = (frescan_bwres_robj_id_t)arg;
133 printf("Thread executing\n");
136 printf("Thread signaling\n");
137 err = frescan_bwres_robjs_signal(reply);
140 printf("Thread terminating\n");