Imported Upstream version 3.2.2
[debian/gnuradio] / gcell / lib / runtime / qa_jd_stack.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_stack.h"
23 #include <cppunit/TestAssert.h>
24 #include <gcell/gc_jd_stack.h>
25 #include <stdio.h>
26
27
28
29 static const int NJDS = 8;
30 static gc_jd_stack_t stack;
31 static gc_job_desc_t jds[NJDS];
32
33 // no brainer, single threaded basic checkout
34 void
35 qa_jd_stack::t1()
36 {
37   // N.B., stack allocated stuff doesn't obey ((aligned (N))) attributes
38   //const int NJDS = 8;
39   //gc_jd_stack_t stack;
40   //gc_job_desc_t jds[NJDS];
41
42   //printf("&stack   = %p\n", &stack);
43   //printf("&jds[0] = %p\n", &jds[0]);
44   //printf("&jds[1] = %p\n", &jds[1]);
45
46   CPPUNIT_ASSERT(((uintptr_t) &stack & 0x7f) == 0);
47   CPPUNIT_ASSERT(((uintptr_t) &jds[0] & 0x7f) == 0);
48   CPPUNIT_ASSERT(((uintptr_t) &jds[1] & 0x7f) == 0);
49
50   gc_jd_stack_init(&stack);
51
52   CPPUNIT_ASSERT(gc_jd_stack_pop(&stack) == 0);
53
54   for (int i = 0; i < NJDS; i++)
55     gc_jd_stack_push(&stack, &jds[i]);
56
57   for (int i = 0; i < NJDS; i++)
58     CPPUNIT_ASSERT_EQUAL(&jds[NJDS - i - 1], gc_jd_stack_pop(&stack));
59
60   CPPUNIT_ASSERT(gc_jd_stack_pop(&stack) == 0);
61 }
62
63 // FIXME multithreaded (running on PPE)
64 void
65 qa_jd_stack::t2()
66 {
67 }