Imported Upstream version 3.2.2
[debian/gnuradio] / gcell / lib / runtime / qa_jd_queue.cc
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2007 Free Software Foundation, Inc.
4  * 
5  * This file is part of GNU Radio
6  * 
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  * 
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #include "qa_jd_queue.h"
23 #include <cppunit/TestAssert.h>
24 #include <gcell/gc_jd_queue.h>
25 #include <stdio.h>
26
27
28
29 static const int NJDS = 16;
30 static gc_jd_queue_t queue;
31 static gc_job_desc_t jds[NJDS];
32
33 // no brainer, single threaded basic checkout
34 void
35 qa_jd_queue::t1()
36 {
37   // N.B., queue allocated stuff doesn't obey ((aligned (N))) attributes
38   //const int NJDS = 8;
39   //gc_jd_queue_t queue;
40   //gc_job_desc_t jds[NJDS];
41
42   //printf("&queue   = %p\n", &queue);
43   //printf("&jds[0] = %p\n", &jds[0]);
44   //printf("&jds[1] = %p\n", &jds[1]);
45
46   CPPUNIT_ASSERT(((uintptr_t) &queue & 0x7f) == 0);
47   CPPUNIT_ASSERT(((uintptr_t) &jds[0] & 0x7f) == 0);
48   CPPUNIT_ASSERT(((uintptr_t) &jds[1] & 0x7f) == 0);
49
50   gc_jd_queue_init(&queue);
51
52   CPPUNIT_ASSERT(gc_jd_queue_dequeue(&queue) == 0);
53
54   gc_jd_queue_enqueue(&queue, &jds[0]);
55   CPPUNIT_ASSERT_EQUAL(&jds[0], gc_jd_queue_dequeue(&queue));
56
57   CPPUNIT_ASSERT(gc_jd_queue_dequeue(&queue) == 0);
58
59   for (int i = 0; i < NJDS; i++)
60     gc_jd_queue_enqueue(&queue, &jds[i]);
61
62   for (int i = 0; i < NJDS; i++)
63     CPPUNIT_ASSERT_EQUAL(&jds[i], gc_jd_queue_dequeue(&queue));
64
65   CPPUNIT_ASSERT(gc_jd_queue_dequeue(&queue) == 0);
66 }
67
68 // FIXME multithreaded (running on PPE)
69 void
70 qa_jd_queue::t2()
71 {
72 }
73
74 // FIXME multithreaded (running on PPE & SPE)
75 void
76 qa_jd_queue::t3()
77 {
78 }