Skip to content

Commit

Permalink
refs #27: Add stubs for IPv4 lookup element tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
achimnol committed Feb 24, 2016
1 parent 56c1188 commit a6a8d62
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compilelib.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,15 @@ def get_includes(srcfile, nba_include_dir):
)
return _find_deps_with_regex(srcfile, nba_include_dir, regexs)

_rx_required_local_obj_sig = re.compile(r'^#require\s*"(.+\.o)"')
_rx_required_obj_sig = re.compile(r'^#require\s*<(.+\.o)>')
def get_requires(srcfile, nba_src_dir):
'''
Gets a list of dependent object files from the given source file.
(e.g., #require <lib/xxx.o>)
'''
regexs = (
(_rx_required_local_obj_sig, True),
(_rx_required_obj_sig, False),
)
return _find_deps_with_regex(srcfile, nba_src_dir, regexs)
Expand Down
38 changes: 38 additions & 0 deletions tests/test_ipv4route.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <cstdint>
#include <cuda_runtime.h>
#include <nba/framework/datablock_shared.hh>
#include <gtest/gtest.h>
#include "../elements/ip/ip_route_core.hh"
#include "../elements/ip/IPlookup_kernel.hh"
#if 0
#require "../elements/ip/ip_route_core.o"
#require "../elements/ip/IPlookup_kernel.o"
#endif

using namespace std;
using namespace nba;

TEST(IPLookupTest, Loading) {
ipv4route::route_hash_t tables[33];
ipv4route::load_rib_from_file(tables, "configs/routing_info.txt");
size_t num_entries = 0;
for (int i = 0; i <= 32; i++) {
printf("table[%d] size: %lu\n", i, tables[i].size());
num_entries += tables[i].size();
}
EXPECT_EQ(282797, num_entries) << "All entries (lines) should exist.";

// Add extra 32 entries and check overflowing.
uint16_t *tbl24 = (uint16_t *) malloc(sizeof(uint16_t) * (ipv4route::get_TBL24_size() + 32));
uint16_t *tbllong = (uint16_t *) malloc(sizeof(uint16_t) * (ipv4route::get_TBLlong_size() + 32));
for (int i = 0; i < 32; i++)
tbl24[ipv4route::get_TBL24_size() + i] = i;
ipv4route::build_direct_fib(tables, tbl24, tbllong);
for (int i = 0; i < 32; i++)
EXPECT_EQ(i, tbl24[ipv4route::get_TBL24_size() + i]);
free(tbl24);
free(tbllong);
}


// vim: ts=8 sts=4 sw=4 et

0 comments on commit a6a8d62

Please sign in to comment.