[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r5610 - gnuradio/branches/developers/gnychis/inband/us
From: |
gnychis |
Subject: |
[Commit-gnuradio] r5610 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband |
Date: |
Sat, 2 Jun 2007 15:58:11 -0600 (MDT) |
Author: gnychis
Date: 2007-06-02 15:58:11 -0600 (Sat, 02 Jun 2007)
New Revision: 5610
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.h
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h
Log:
Beginning severe cleaning of test code.
Breaking down the test code in to smaller more specific segments.
Changed 'basic' tests to open/close tests and nothing more, ripped the TX
testing out in to its own set of tests.
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
2007-06-02 20:20:54 UTC (rev 5609)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.cc
2007-06-02 21:58:11 UTC (rev 5610)
@@ -445,8 +445,115 @@
//
----------------------------------------------------------------------------------------------
-class qa_basic_top : public mb_mblock
+class qa_open_close_top : public mb_mblock
{
+ mb_port_sptr d_cs;
+
+ long d_max_capacity;
+
+ long d_nmsg_to_recv;
+ long d_nmsg_recvd;
+
+ public:
+ qa_open_close_top(mb_runtime *runtime, const std::string &instance_name,
pmt_t user_arg);
+ ~qa_open_close_top();
+ void initial_transition();
+ void handle_message(mb_message_sptr msg);
+
+ protected:
+ void check_cs(mb_message_sptr msg);
+ void run_tests();
+};
+
+qa_open_close_top::qa_open_close_top(mb_runtime *runtime, const std::string
&instance_name, pmt_t user_arg)
+ : mb_mblock(runtime, instance_name, user_arg)
+{
+
+ d_nmsg_to_recv=7;
+ d_nmsg_recvd=0;
+
+ d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL);
+
+ // Use the stub with the usrp_server
+ pmt_t usrp_server_dict = pmt_make_dict();
+ pmt_dict_set(usrp_server_dict, pmt_intern("usrp-interface"),
pmt_intern("usrp_usb_interface_stub"));
+
+ // Test the TX side
+ define_component("server", "usrp_server", pmt_list1(usrp_server_dict));
+ connect("self", "cs", "server", "cs");
+}
+
+qa_open_close_top::~qa_open_close_top(){}
+
+void
+qa_open_close_top::initial_transition()
+{
+ run_tests();
+}
+
+void
+qa_open_close_top::run_tests()
+{
+ std::cout << "[qa_open_close_top] Starting tests\n";
+
+ // A close before an open should fail
+ d_cs->send(s_cmd_close, pmt_list1(PMT_F));
+
+ // Perform an open, and a second open which should fail
+ d_cs->send(s_cmd_open, pmt_list2(PMT_T, pmt_from_long(0)));
+ d_cs->send(s_cmd_open, pmt_list2(PMT_F, pmt_from_long(0)));
+
+ // A close should now be successful since the interface is open
+ d_cs->send(s_cmd_close, pmt_list1(PMT_T));
+
+ // But, a second close should fail
+ d_cs->send(s_cmd_close, pmt_list1(PMT_F));
+
+ // Just to be thorough, try an open and close again
+ d_cs->send(s_cmd_open, pmt_list2(PMT_T, pmt_from_long(0)));
+ d_cs->send(s_cmd_close, pmt_list1(PMT_T));
+
+}
+
+
+void
+qa_open_close_top::handle_message(mb_message_sptr msg)
+{
+ pmt_t data = msg->data();
+
+ if (pmt_eq(msg->port_id(), d_cs->port_symbol())) {
+ check_cs(msg);
+ }
+
+ d_nmsg_recvd++;
+
+ if(d_nmsg_to_recv == d_nmsg_recvd)
+ shutdown_all(PMT_T);
+}
+
+void
+qa_open_close_top::check_cs(mb_message_sptr msg)
+{
+ pmt_t data = msg->data();
+
+ pmt_t expected_result = pmt_nth(0, data);
+ pmt_t result = pmt_nth(1, data);
+
+ if(!pmt_eqv(expected_result, result)) {
+ std::cout << "[qa_open_close_top] FAILED check_cs... Got: " << result << "
Expected: " << expected_result << " for event " << msg->signal() << "\n";
+ shutdown_all(PMT_F);
+ } else {
+ std::cout << "[qa_open_close_top] Received expected CS response for
message (" << msg->signal() << ")\n";
+ }
+
+}
+
+REGISTER_MBLOCK_CLASS(qa_open_close_top);
+
+//
----------------------------------------------------------------------------------------------
+
+class qa_tx_top : public mb_mblock
+{
mb_port_sptr d_tx;
mb_port_sptr d_rx;
mb_port_sptr d_cs;
@@ -461,8 +568,8 @@
long d_nmsg_recvd;
public:
- qa_basic_top(mb_runtime *runtime, const std::string &instance_name, pmt_t
user_arg);
- ~qa_basic_top();
+ qa_tx_top(mb_runtime *runtime, const std::string &instance_name, pmt_t
user_arg);
+ ~qa_tx_top();
void initial_transition();
void handle_message(mb_message_sptr msg);
@@ -474,11 +581,11 @@
void run_tests();
};
-qa_basic_top::qa_basic_top(mb_runtime *runtime, const std::string
&instance_name, pmt_t user_arg)
+qa_tx_top::qa_tx_top(mb_runtime *runtime, const std::string &instance_name,
pmt_t user_arg)
: mb_mblock(runtime, instance_name, user_arg)
{
- d_nmsg_to_recv=14;
+ d_nmsg_to_recv=12;
d_nmsg_recvd=0;
d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL);
@@ -496,54 +603,52 @@
connect("self", "cs", "server", "cs");
}
-qa_basic_top::~qa_basic_top(){}
+qa_tx_top::~qa_tx_top(){}
void
-qa_basic_top::initial_transition()
+qa_tx_top::initial_transition()
{
run_tests();
}
void
-qa_basic_top::run_tests()
+qa_tx_top::run_tests()
{
- std::cout << "[qa_basic_top] Starting tests\n";
+ std::cout << "[qa_tx_top] Starting tests\n";
- // Should not be able to allocate an RX or TX until opened
- d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_F, pmt_from_long(1)));
- d_rx->send(s_cmd_allocate_channel, pmt_list2(PMT_F, pmt_from_long(1)));
-
// A transmit before an open should fail
d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(PMT_F, pmt_from_long(0),
pmt_make_u32vector(transport_pkt::max_payload()/4, 0), pmt_from_long(0)));
// Open, and now try an xmit again which should be successful
d_cs->send(s_cmd_open, pmt_list2(PMT_T, pmt_from_long(0)));
+
+ // Try to transmit on a channel that we have no allocation for
+ d_tx->send(s_cmd_xmit_raw_frame,
pmt_list4(pmt_from_long(usrp_server::PERMISSION_DENIED), pmt_from_long(0),
pmt_make_u32vector(transport_pkt::max_payload()/4, 0), pmt_from_long(0)));
+
+ // Get a channel allocation and send on it, we assume 0 (FIXME) until
'defer' is implemented for simplicity
d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(1)));
- d_rx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(1)));
-
- // To simplify the test case, we know that the returned channels are 0, when
we have defer implemented we can avoid this easier
d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(PMT_T, pmt_from_long(0),
pmt_make_u32vector(transport_pkt::max_payload()/4, 0), pmt_from_long(0)));
// Close should be successful
d_cs->send(s_cmd_close, pmt_list1(PMT_T));
- // After closing, a new allocate and transmit raw frame should fail again.
It should also be deferred
- d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_F, pmt_from_long(1)));
- d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(PMT_F, pmt_from_long(d_tx_chan),
pmt_make_u32vector(transport_pkt::max_payload()/4, 0), pmt_from_long(0)));
+ // After closing, a new transmit raw frame should fail again
+ d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(PMT_F, pmt_from_long(0),
pmt_make_u32vector(transport_pkt::max_payload()/4, 0), pmt_from_long(0)));
- // Reopen and retry
+ // Reopen and retry before getting an allocation, the first xmit should
fail, after we allocate it should work again
d_cs->send(s_cmd_open, pmt_list2(PMT_T, pmt_from_long(0)));
- d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(PMT_T, pmt_from_long(d_tx_chan),
pmt_make_u32vector(transport_pkt::max_payload()/4, 0), pmt_from_long(0)));
+ d_tx->send(s_cmd_xmit_raw_frame,
pmt_list4(pmt_from_long(usrp_server::PERMISSION_DENIED), pmt_from_long(0),
pmt_make_u32vector(transport_pkt::max_payload()/4, 0), pmt_from_long(0)));
+ d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(1)));
+ d_tx->send(s_cmd_xmit_raw_frame, pmt_list4(PMT_T, pmt_from_long(0),
pmt_make_u32vector(transport_pkt::max_payload()/4, 0), pmt_from_long(0)));
- // A final close which should be successful, with a failing close (can't
close it twice)
+ // A final close which should be successful
d_cs->send(s_cmd_close, pmt_list1(PMT_T));
- d_cs->send(s_cmd_close, pmt_list1(PMT_F));
}
void
-qa_basic_top::handle_message(mb_message_sptr msg)
+qa_tx_top::handle_message(mb_message_sptr msg)
{
pmt_t data = msg->data();
@@ -568,7 +673,7 @@
}
void
-qa_basic_top::check_deallocation(mb_message_sptr msg)
+qa_tx_top::check_deallocation(mb_message_sptr msg)
{
pmt_t data = msg->data();
@@ -576,15 +681,15 @@
pmt_t result = pmt_nth(1, data);
if(!pmt_eqv(expected_result, result)) {
- std::cout << "[qa_basic_top] FAILED check_deallocation... Got: " << result
<< " Expected: " << expected_result << "\n";
+ std::cout << "[qa_tx_top] FAILED check_deallocation... Got: " << result <<
" Expected: " << expected_result << "\n";
shutdown_all(PMT_F);
} else {
- std::cout << "[qa_basic_top] Received expected deallocation response for
message\n";
+ std::cout << "[qa_tx_top] Received expected deallocation response for
message\n";
}
}
void
-qa_basic_top::check_allocation(mb_message_sptr msg)
+qa_tx_top::check_allocation(mb_message_sptr msg)
{
pmt_t data = msg->data();
@@ -593,10 +698,10 @@
pmt_t channel = pmt_nth(2, data);
if(!pmt_eqv(expected_result, result)) {
- std::cout << "[qa_basic_top] FAILED check_allocation... Got: " << result
<< " Expected: " << expected_result << " for event " << msg->signal() << ")\n";
+ std::cout << "[qa_tx_top] FAILED check_allocation... Got: " << result << "
Expected: " << expected_result << " for event " << msg->signal() << ")\n";
shutdown_all(PMT_F);
} else {
- std::cout << "[qa_basic_top] Received expected allocation response for
message\n";
+ std::cout << "[qa_tx_top] Received expected allocation response for
message\n";
}
if(pmt_eqv(result, PMT_T)) {
@@ -609,7 +714,7 @@
}
void
-qa_basic_top::check_xmit(mb_message_sptr msg)
+qa_tx_top::check_xmit(mb_message_sptr msg)
{
pmt_t data = msg->data();
@@ -617,15 +722,15 @@
pmt_t result = pmt_nth(1, data);
if(!pmt_eqv(expected_result, result)) {
- std::cout << "[qa_basic_top] FAILED check_xmit... Got: " << result << "
Expected: " << expected_result << " for event " << msg->signal() << ")\n";
+ std::cout << "[qa_tx_top] FAILED check_xmit... Got: " << result << "
Expected: " << expected_result << " for event " << msg->signal() << ")\n";
shutdown_all(PMT_F);
} else {
- std::cout << "[qa_basic_top] Received expected xmit response for
message\n";
+ std::cout << "[qa_tx_top] Received expected xmit response for message\n";
}
}
void
-qa_basic_top::check_cs(mb_message_sptr msg)
+qa_tx_top::check_cs(mb_message_sptr msg)
{
pmt_t data = msg->data();
@@ -633,28 +738,29 @@
pmt_t result = pmt_nth(1, data);
if(!pmt_eqv(expected_result, result)) {
- std::cout << "[qa_basic_top] FAILED check_cs... Got: " << result << "
Expected: " << expected_result << " for event " << msg->signal() << "\n";
+ std::cout << "[qa_tx_top] FAILED check_cs... Got: " << result << "
Expected: " << expected_result << " for event " << msg->signal() << "\n";
shutdown_all(PMT_F);
} else {
- std::cout << "[qa_basic_top] Received expected CS response for message ("
<< msg->signal() << ")\n";
+ std::cout << "[qa_tx_top] Received expected CS response for message (" <<
msg->signal() << ")\n";
}
}
-REGISTER_MBLOCK_CLASS(qa_basic_top);
+REGISTER_MBLOCK_CLASS(qa_tx_top);
+
//
----------------------------------------------------------------------------------------------
void
-qa_inband_usrp_server::test_basics()
+qa_inband_usrp_server::test_open_close()
{
mb_runtime_sptr rt = mb_make_runtime();
pmt_t result = PMT_T;
std::cout << "\n\n----------------------------\n";
- std::cout << " RUNNING BASIC TESTS \n";
+ std::cout << " RUNNING OPEN/CLOSE TESTS \n";
- rt->run("top", "qa_basic_top", PMT_F, &result);
+ rt->run("top", "qa_open_close_top", PMT_F, &result);
CPPUNIT_ASSERT(pmt_equal(PMT_T, result));
}
@@ -686,3 +792,17 @@
CPPUNIT_ASSERT(pmt_equal(PMT_T, result));
}
+
+void
+qa_inband_usrp_server::test_tx()
+{
+ mb_runtime_sptr rt = mb_make_runtime();
+ pmt_t result = PMT_T;
+
+ std::cout << "\n\n-----------------\n";
+ std::cout << " RUNNING TX TESTS \n";
+
+ rt->run("top", "qa_tx_top", PMT_F, &result);
+
+ CPPUNIT_ASSERT(pmt_equal(PMT_T, result));
+}
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.h
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.h
2007-06-02 20:20:54 UTC (rev 5609)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/qa_inband_usrp_server.h
2007-06-02 21:58:11 UTC (rev 5610)
@@ -28,15 +28,17 @@
class qa_inband_usrp_server : public CppUnit::TestCase {
CPPUNIT_TEST_SUITE(qa_inband_usrp_server);
- CPPUNIT_TEST(test_basics);
+ CPPUNIT_TEST(test_open_close);
CPPUNIT_TEST(test_chan_allocation);
CPPUNIT_TEST(test_chan_deallocation);
+ CPPUNIT_TEST(test_tx);
CPPUNIT_TEST_SUITE_END();
private:
void test_chan_allocation();
void test_chan_deallocation();
- void test_basics();
+ void test_open_close();
+ void test_tx();
};
#endif /* INCLUDED_QA_INBAND_USRP_SERVER_H */
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
2007-06-02 20:20:54 UTC (rev 5609)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
2007-06-02 21:58:11 UTC (rev 5610)
@@ -127,6 +127,13 @@
// Initialize capacity on each channel to 0 and to no owner
// Also initialize the USRP standard tx/rx pointers to NULL
+ reset_channels();
+
+}
+
+void
+usrp_server::reset_channels()
+{
for(int chan=0; chan < d_ntx_chan; chan++) {
d_chaninfo_tx[chan].assigned_capacity = 0;
d_chaninfo_tx[chan].owner = PMT_NIL;
@@ -135,7 +142,6 @@
d_chaninfo_rx[chan].assigned_capacity = 0;
d_chaninfo_rx[chan].owner = PMT_NIL;
}
-
}
usrp_server::~usrp_server()
@@ -199,6 +205,7 @@
if(pmt_eqv(status,PMT_T)) {
d_opened = false;
d_defer = false;
+ reset_channels();
recall_defer_queue();
}
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h
2007-06-02 20:20:54 UTC (rev 5609)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h
2007-06-02 21:58:11 UTC (rev 5610)
@@ -84,6 +84,7 @@
int tx_port_index(pmt_t port_id);
long current_capacity_allocation();
void recall_defer_queue();
+ void reset_channels();
};
#endif /* INCLUDED_USRP_SERVER_H */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r5610 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband,
gnychis <=