tests: Add a test for lib :: init()

This just checks that the deck was initialized.  To really be complete,
it should really check that ALL core libraries are initialized.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2014-06-14 20:43:20 -04:00
parent 5b3f8b13e0
commit f2575d9799
6 changed files with 61 additions and 2 deletions

2
.gitignore vendored
View File

@ -8,7 +8,7 @@ bin/
*.patch
*.tar.gz
tests/*/*-core
tests/*-lib
tests/*/*-lib
*.gcov
*.gcda
*.gcno

View File

@ -1,10 +1,12 @@
/*
* Copyright 2014 (c) Anna Schumaker.
*/
#include <string>
namespace lib
{
void init(int *, char ***);
const std::string share_file(const std::string &);
}

View File

@ -15,6 +15,9 @@ for arg in sys.argv:
if arg.find("tests/core") == 0 and len(arg) > 11:
check_depends = False
break
if arg.find("tests/lib") == 0 and len(arg) > 10:
check_depends = False
break
valgrind = "valgrind -q --leak-check=full --error-exitcode=42"
@ -78,8 +81,9 @@ Export("OTest", "TestList")
core = SConscript("core/Sconscript")
lib = SConscript("lib/Sconscript")
res = [ core ]
res = [ core, lib ]
if test_env.CppCheck == True:
res += [ Command("cpp.check", [], "cppcheck -q --error-exitcode=42 .") ]
Depends(res[len(res) - 1], res[len(res) - 2])

1
tests/lib/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
lib

30
tests/lib/Sconscript Normal file
View File

@ -0,0 +1,30 @@
#!/usr/bin/python
Import("OTest", "TestList")
core = []
for f in Glob("../../core/*.cpp"):
src = str(f).rsplit("/", 1)[1]
core += [ OTest.Env.Object("%s-core" % src, str(f)) ]
class LibTest(OTest):
Objs = core
def __init__(self, src):
OTest.__init__(self, src)
def get_program(self):
path = "../../lib/%s" % self.Src
LibTest.Objs += [ LibTest.Env.Object("%s-lib" % self.Src, path) ]
return OTest.Env.Program(self.Name, [ self.Src ] + LibTest.Objs)
res = TestList("lib", [
LibTest("lib.cpp"),
]).prepare()
Return("res")

22
tests/lib/lib.cpp Normal file
View File

@ -0,0 +1,22 @@
/*
* Copyright 2014 (c) Anna Schumaker.
*/
#include <core/deck.h>
#include <lib/lib.h>
#include <tests/test.h>
static void test_init(int argc, char **argv)
{
test_equal(deck :: get_queues().size(), (size_t)0);
test :: cp_data_dir();
lib :: init(&argc, &argv);
test_equal(deck :: get_queues().size(), (size_t)2);
}
int main(int argc, char **argv)
{
run_test("Lib Test", test_init, argc, argv);
return 0;
}