commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r5071 - gnuradio/branches/developers/gnychis/inband/us


From: gnychis
Subject: [Commit-gnuradio] r5071 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband
Date: Sun, 22 Apr 2007 13:18:55 -0600 (MDT)

Author: gnychis
Date: 2007-04-22 13:18:53 -0600 (Sun, 22 Apr 2007)
New Revision: 5071

Added:
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_packet_prims.cc
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_packet_prims.h
Modified:
   gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am
   gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband.cc
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/test_inband.cc
Log:
adding in tests for primitive packet creation and field setting methods


Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am    
    2007-04-22 06:59:25 UTC (rev 5070)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/Makefile.am    
    2007-04-22 19:18:53 UTC (rev 5071)
@@ -52,12 +52,14 @@
        usrp_server.h                   
 
 noinst_HEADERS =      \
-       qa_inband.h
+       qa_inband.h                                     \
+       qa_inband_packet_prims.h
 
 # Build the qa code in its own library
 
 libinband_qa_la_SOURCES =   \
-       qa_inband.cc
+       qa_inband.cc                                                    \
+       qa_inband_packet_prims.cc       
 
 # magic flags
 libinband_qa_la_LDFLAGS = $(NO_UNDEFINED) -avoid-version

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband.cc
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband.cc   
    2007-04-22 06:59:25 UTC (rev 5070)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband.cc   
    2007-04-22 19:18:53 UTC (rev 5071)
@@ -20,11 +20,14 @@
  */
 
 #include <qa_inband.h>
+#include <qa_inband_packet_prims.h>
 
 CppUnit::TestSuite *
 qa_inband::suite()
 {
   CppUnit::TestSuite   *s = new CppUnit::TestSuite("inband");
 
+  s->addTest (qa_inband_packet_prims::suite());
+
   return s;
 }

Added: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_packet_prims.cc
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_packet_prims.cc
                          (rev 0)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_packet_prims.cc
  2007-04-22 19:18:53 UTC (rev 5071)
@@ -0,0 +1,161 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio 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 this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <qa_inband_packet_prims.h>
+#include <cppunit/TestAssert.h>
+#include <stdio.h>
+#include <usrp_inband_usb_packet.h>             // will change on gigabit 
crossover
+
+typedef usrp_inband_usb_packet transport_pkt;
+
+void
+qa_inband_packet_prims::test_flags()
+{
+  transport_pkt pkt;
+
+  // Test each one of the flags while ensuring no other fields become set in 
the process
+  pkt.set_header(pkt.FL_START_OF_BURST,0,0,0);
+  CPPUNIT_ASSERT_EQUAL(1, pkt.start_of_burst());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.end_of_burst());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.overrun());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.underrun());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.dropped());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len());
+
+  pkt.set_header(pkt.FL_END_OF_BURST,0,0,0);
+  CPPUNIT_ASSERT_EQUAL(0, pkt.start_of_burst());
+  CPPUNIT_ASSERT_EQUAL(1, pkt.end_of_burst());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.overrun());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.underrun());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.dropped());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len());
+
+  pkt.set_header(pkt.FL_OVERRUN,0,0,0);
+  CPPUNIT_ASSERT_EQUAL(0, pkt.start_of_burst());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.end_of_burst());
+  CPPUNIT_ASSERT_EQUAL(1, pkt.overrun());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.underrun());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.dropped());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len());
+
+  pkt.set_header(pkt.FL_UNDERRUN,0,0,0);
+  CPPUNIT_ASSERT_EQUAL(0, pkt.start_of_burst());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.end_of_burst());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.overrun());
+  CPPUNIT_ASSERT_EQUAL(1, pkt.underrun());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.dropped());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len());
+
+  pkt.set_header(pkt.FL_DROPPED,0,0,0);
+  CPPUNIT_ASSERT_EQUAL(0, pkt.start_of_burst());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.end_of_burst());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.overrun());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.underrun());
+  CPPUNIT_ASSERT_EQUAL(1, pkt.dropped());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len());
+
+  // test of all fields set
+  pkt.set_header(
+    pkt.FL_START_OF_BURST |
+    pkt.FL_END_OF_BURST |
+    pkt.FL_UNDERRUN |
+    pkt.FL_OVERRUN |
+    pkt.FL_DROPPED 
+    ,0,0,0);
+  CPPUNIT_ASSERT_EQUAL(1, pkt.start_of_burst());
+  CPPUNIT_ASSERT_EQUAL(1, pkt.end_of_burst());
+  CPPUNIT_ASSERT_EQUAL(1, pkt.overrun());
+  CPPUNIT_ASSERT_EQUAL(1, pkt.underrun());
+  CPPUNIT_ASSERT_EQUAL(1, pkt.dropped());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len());
+
+
+}
+//////////////////////////////////////////////////////////////////////
+
+void
+qa_inband_packet_prims::test_fields()
+{
+  transport_pkt pkt;
+  void * payload;
+  
+  // test word0 field exclusiveness
+  //
+  // I want to test max values of each field to ensure field boundaries
+  // but these max values could change based on technology?  The
+  // max payload is returned by a private method so the code is not
+  // technology dependent
+  pkt.set_header(0,16,0,0);
+  CPPUNIT_ASSERT_EQUAL(16, pkt.chan());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len());
+
+  pkt.set_header(0,0,8,0);
+  CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
+  CPPUNIT_ASSERT_EQUAL(8, pkt.tag());
+  CPPUNIT_ASSERT_EQUAL(0,pkt.payload_len());
+
+  pkt.set_header(0,0,0,pkt.max_payload());  
+  CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
+  CPPUNIT_ASSERT_EQUAL(pkt.max_payload(), pkt.payload_len());
+
+  // test timestamp, shouldn't have to test other fields since
+  // setting the timestamp only has the ability to affect one word
+  pkt.set_timestamp(54);
+  CPPUNIT_ASSERT_EQUAL(uint32_t(54), pkt.timestamp());
+
+  // test the payload, ensure no other fields overwritten
+  //
+  // is there a better test for this?
+  pkt.set_header(0,0,0,0);
+  payload = malloc(pkt.payload_len());
+  memset(payload, 'f', pkt.payload_len());
+  memcpy(pkt.payload(), payload, pkt.payload_len());
+  CPPUNIT_ASSERT_EQUAL(0, memcmp(pkt.payload(), payload, pkt.payload_len()));
+  CPPUNIT_ASSERT_EQUAL(0, pkt.start_of_burst());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.end_of_burst());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.overrun());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.underrun());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.dropped());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.chan());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.tag());
+  CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len());
+  free(payload);
+
+}
+//////////////////////////////////////////////////////////////////////


Property changes on: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_packet_prims.cc
___________________________________________________________________
Name: svn:eol-style
   + native

Added: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_packet_prims.h
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_packet_prims.h
                           (rev 0)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_packet_prims.h
   2007-04-22 19:18:53 UTC (rev 5071)
@@ -0,0 +1,41 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio 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 this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef QA_INBAND_PACKET_PRIMS_H
+#define QA_INBAND_PACKET_PRIMS_H
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestCase.h>
+
+class qa_inband_packet_prims : public CppUnit::TestCase {
+
+  CPPUNIT_TEST_SUITE(qa_inband_packet_prims);
+  CPPUNIT_TEST(test_flags);
+  CPPUNIT_TEST(test_fields);
+  CPPUNIT_TEST_SUITE_END();
+
+ private:
+  void test_flags();
+  void test_fields();
+
+};
+
+#endif /* INCLUDED_QA_INBAND_USB_HEADERS_H */


Property changes on: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_packet_prims.h
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/test_inband.cc
===================================================================
--- 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/test_inband.cc 
    2007-04-22 06:59:25 UTC (rev 5070)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/test_inband.cc 
    2007-04-22 19:18:53 UTC (rev 5071)
@@ -28,7 +28,7 @@
   
   CppUnit::TextTestRunner      runner;
 
-//  runner.addTest(qa_inband::suite ());
+  runner.addTest(qa_inband::suite ());
   
   bool was_successful = runner.run("", false);
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]