Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run tests in Travis CI #2

Open
wants to merge 4 commits into
base: nm/4105/selftests
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: c
compiler:
- gcc

before_install: "sudo apt-get update && sudo apt-get install -y linux-libc-dev"

script:
- make && cd src && sudo make test_ci;

after_script:
- ls testlog/* | xargs -l1 cat;
5 changes: 5 additions & 0 deletions src/apps/vhost/vhost.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module(...,package.seeall)
local ffi = require("ffi")
local C = ffi.C

local lib = require("core.lib")
local freelist = require("core.freelist")
local memory = require("core.memory")
local buffer = require("core.buffer")
Expand All @@ -15,6 +16,10 @@ local packet = require("core.packet")
vring_size = C.VHOST_VRING_SIZE
uint64_t = ffi.typeof("uint64_t")

function is_tuntap_available()
return lib.can_write("/dev/net/tun")
end

function new (tapname)
local vhost = ffi.new("struct vhost")
local dev = { vhost = vhost,
Expand Down
5 changes: 5 additions & 0 deletions src/apps/vhost/vhost_apps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ function TapVhost:push ()
end

function selftest ()
if not vhost.is_tuntap_available() then
print("/dev/net/tun absent or not avaiable\nTest skipped")
os.exit(app.test_skipped_code)
end

local c = config.new()
config.app(c, "source", basic_apps.Source)
config.app(c, "tapvhost", TapVhost, "snabb%d")
Expand Down
4 changes: 2 additions & 2 deletions src/core/memory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function get_huge_page_size ()
local _,_,hugesize = meminfo:find("Hugepagesize: +([0-9]+) kB")
return hugesize
and tonumber(hugesize) * 1024
or 2048 -- A typical x86 system will have a Huge Page Size of 2048 kBytes
or base_page_size -- use base page size as default value
end

base_page_size = 4096
Expand Down Expand Up @@ -122,7 +122,7 @@ function set_use_physical_memory()
end

function set_default_allocator(use_hugetlb)
if use_hugetlb then
if use_hugetlb and lib.can_write("/proc/sys/vm/nr_hugepages") then
allocate_RAM = function(size)
for i =1, 3 do
local page = C.allocate_huge_page(size)
Expand Down