2 * @file test_frescan_bwres_robjs_wait.c
4 * @brief test for the basic behaviour of reply objects
11 * Daniel Sangorrin <daniel.sangorrin@unican.es>
15 * This file contains a basic test for the frescan_bwres_robjs module.
16 * The main thread allocates a reply object, creates a thread and waits
17 * on the reply object until the thread signals it.
21 * See the COPYING file in the FNA's root directory
25 #include <stdio.h> /* for printf */
26 #include <assert.h> /* for assert */
27 #include <unistd.h> /* for sleep */
28 #include "fosa_threads_and_signals.h" /* for fosa_thread_xxx */
29 #include "frescan_bwres_robjs.h"
33 static void *thread_code(void *arg);
38 frescan_bwres_robj_id_t id;
39 fosa_thread_attr_t th_attr;
42 printf("TEST REPLY OBJECTS\n");
44 err = fosa_thread_set_prio(fosa_thread_self(), CEILING - 1);
47 err = frescan_bwres_robjs_init(CEILING);
50 err = frescan_bwres_robjs_alloc(&id, CEILING);
53 err = fosa_thread_attr_init(&th_attr);
56 err = fosa_thread_attr_set_prio(&th_attr, CEILING - 1);
59 err = fosa_thread_create (&tid, &th_attr, thread_code, (void *) id);
62 err = fosa_thread_attr_destroy(&th_attr);
65 err = frescan_bwres_robjs_wait(id);
67 printf("signal received\n");
69 err = frescan_bwres_robjs_free(id);
72 printf("TEST [OK!]\n");
77 static void *thread_code(void *arg)
80 frescan_bwres_robj_id_t reply = (frescan_bwres_robj_id_t)arg;
82 printf("Thread executing\n");
85 printf("Thread signaling\n");
86 err = frescan_bwres_robjs_signal(reply);
89 printf("Thread terminating\n");