tests: Create a core/ directory
I move all of the core tests into the core/ directory to keep them together. Gui unit tests will be put in new directories. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
40a99f7eda
commit
c88746d2da
|
@ -7,7 +7,7 @@ bin/
|
||||||
.sconsign.dblite
|
.sconsign.dblite
|
||||||
*.patch
|
*.patch
|
||||||
*.tar.gz
|
*.tar.gz
|
||||||
tests/*-core
|
tests/*/*-core
|
||||||
tests/*-lib
|
tests/*-lib
|
||||||
*.gcov
|
*.gcov
|
||||||
*.gcda
|
*.gcda
|
||||||
|
|
135
tests/Sconscript
135
tests/Sconscript
|
@ -2,99 +2,86 @@
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
Import("test_env")
|
Import("test_env")
|
||||||
tests = [
|
|
||||||
|
|
||||||
###
|
test_env.UsePackage("glib-2.0")
|
||||||
#
|
test_env.DEBUG = True
|
||||||
# (source.cpp, use collected lib_files?, [ other files ], [ other packages ])
|
|
||||||
#
|
|
||||||
|
|
||||||
("version.cpp", False, [], [ "glib-2.0" ]),
|
if test_env.Coverage == True:
|
||||||
("file.cpp", True, [], []),
|
test_env.Append( CCFLAGS = [ "--coverage" ] )
|
||||||
("database.cpp", True, [], []),
|
test_env.Append( LINKFLAGS = [ "-lgcov", "-coverage" ] )
|
||||||
("index.cpp", True, [], []),
|
|
||||||
("filter.cpp", True, [], []),
|
|
||||||
("idle.cpp", False, [ "idle.cpp" ], []),
|
|
||||||
("tags.cpp", True, [], [ "taglib" ]),
|
|
||||||
("random.cpp", False, [ "random.cpp" ], []),
|
|
||||||
("queue.cpp", True, [ "callback.cpp", "random.cpp" ], []),
|
|
||||||
("library.cpp", True, [ "idle.cpp" ], []),
|
|
||||||
("playlist.cpp", True, [], []),
|
|
||||||
("deck.cpp", True, [], []),
|
|
||||||
("driver.cpp", False, [ "driver.cpp" ], []),
|
|
||||||
("audio.cpp", True, [ "driver.cpp" ], []),
|
|
||||||
|
|
||||||
]
|
|
||||||
|
|
||||||
env = test_env
|
|
||||||
env.UsePackage("glib-2.0")
|
|
||||||
if env.Coverage == True:
|
|
||||||
env.Append( CCFLAGS = [ "--coverage" ] )
|
|
||||||
env.Append( LINKFLAGS = [ "-lgcov", "-coverage" ] )
|
|
||||||
check_depends = True
|
check_depends = True
|
||||||
|
|
||||||
for arg in sys.argv:
|
for arg in sys.argv:
|
||||||
if arg.find("tests") == 0 and len(arg) > 5:
|
if arg.find("tests/core") == 0 and len(arg) > 11:
|
||||||
check_depends = False
|
check_depends = False
|
||||||
break
|
break
|
||||||
|
|
||||||
def expand_files(extra_files):
|
|
||||||
res = []
|
|
||||||
for f in extra_files:
|
|
||||||
res += [ env.Object("%s-core" % f, "../core/%s" % f) ]
|
|
||||||
return res
|
|
||||||
|
|
||||||
def make_program(src, name, extra_files):
|
valgrind = "valgrind -q --leak-check=full --error-exitcode=42"
|
||||||
return env.Program("%s" % name, [ src ] + expand_files(extra_files))
|
gcov = "gcov -r tests/%s/*.gcda"
|
||||||
|
|
||||||
def make_test(src, name):
|
|
||||||
cmd = "./tests/%s | tee ./tests/%s.out" % (name, name)
|
|
||||||
if env.Valgrind == True:
|
|
||||||
cmd = "valgrind -q --leak-check=full --error-exitcode=42 %s" % cmd
|
|
||||||
|
|
||||||
test = Command("%s.out" % name, [], "set -o pipefail; %s" % cmd)
|
class OTest:
|
||||||
Alias("tests/%s" % name, test)
|
Prev = None
|
||||||
AlwaysBuild(test)
|
Env = test_env
|
||||||
return test
|
|
||||||
|
|
||||||
def prepare_test(name, src, extra_files):
|
def __init__(self, src, pkg = None):
|
||||||
exe = make_program(src, name, extra_files)
|
self.Name = src.rsplit(".")[0]
|
||||||
test = make_test(src, name)
|
self.Src = src
|
||||||
Depends(test, exe)
|
if pkg != None:
|
||||||
return test
|
test_env.UsePackage(pkg)
|
||||||
|
|
||||||
res = []
|
def get_program(self):
|
||||||
lib_files = []
|
return test_env.Program(self.Name, self.Src)
|
||||||
|
|
||||||
ignore = open(".gitignore", 'w')
|
def prepare(self, subdir):
|
||||||
for src, lib, extra, pkgs in tests:
|
prog = self.get_program()
|
||||||
name = "%s" % src.rsplit(".")[0]
|
|
||||||
|
|
||||||
if lib == True:
|
path = "./tests/%s/%s" % (subdir, self.Name)
|
||||||
lib_files += [ src ] + extra
|
cmd = "%s | tee %s.out" % (path, path)
|
||||||
extra = lib_files
|
if test_env.Valgrind == True:
|
||||||
|
cmd = "%s %s" % (valgrind, cmd)
|
||||||
|
test = Command("%s.out" % self.Name, [], "set -x pipefail; %s" % cmd)
|
||||||
|
|
||||||
for p in pkgs:
|
Depends(test, prog)
|
||||||
env.UsePackage(p)
|
if (check_depends == True) and (OTest.Prev != None):
|
||||||
|
Depends(test, OTest.Prev)
|
||||||
|
Alias("tests/%s" % subdir, test)
|
||||||
|
Alias("tests/%s/%s" % (subdir, self.Name), test)
|
||||||
|
AlwaysBuild(test)
|
||||||
|
OTest.Prev = test
|
||||||
|
return test
|
||||||
|
|
||||||
test = prepare_test(name, src, extra)
|
|
||||||
if (check_depends == True) and (len(res) > 0):
|
|
||||||
Depends(test, res[len(res) - 1])
|
|
||||||
|
|
||||||
res += [ test ]
|
class TestList:
|
||||||
ignore.write(name + "\n")
|
def __init__(self, subdir, tests):
|
||||||
ignore.close();
|
self.subdir = subdir
|
||||||
|
self.tests = tests
|
||||||
|
|
||||||
if env.Coverage == True:
|
f = open(".gitignore", "w")
|
||||||
cov = Command("ocarina.gcov", [], "gcov -r tests/*.gcda")
|
for t in tests:
|
||||||
Depends(cov, res[len(res) - 1])
|
f.write(t.Name + "\n")
|
||||||
res += [ cov ]
|
f.close()
|
||||||
|
|
||||||
if env.CppCheck == True:
|
def prepare(self):
|
||||||
check = Command("cpp.check", [], "cppcheck -q .")
|
res = []
|
||||||
Depends(check, res[len(res) - 1])
|
for t in self.tests:
|
||||||
res += [ check ]
|
res += [ t.prepare(self.subdir) ]
|
||||||
|
|
||||||
|
if test_env.Coverage == True:
|
||||||
|
res += [ Command("%s.gcov" % self.subdir, [], gcov % self.subdir) ]
|
||||||
|
Depends(res[len(res) - 1], res[len(res) - 2])
|
||||||
|
AlwaysBuild(res[len(res) - 1])
|
||||||
|
return res
|
||||||
|
|
||||||
|
Export("OTest", "TestList")
|
||||||
|
|
||||||
|
|
||||||
|
core = SConscript("core/Sconscript")
|
||||||
|
|
||||||
|
res = [ core ]
|
||||||
|
if test_env.CppCheck == True:
|
||||||
|
res += [ Command("cpp.check", [], "cppcheck -q --error-exitcode=42 .") ]
|
||||||
|
Depends(res[len(res) - 1], res[len(res) - 2])
|
||||||
|
|
||||||
Return("res")
|
Return("res")
|
||||||
|
|
||||||
##scripts = [ "library", "deck", "audio", "gui" ]
|
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
Import("OTest", "TestList")
|
||||||
|
|
||||||
|
|
||||||
|
class CoreTest(OTest):
|
||||||
|
Objs = []
|
||||||
|
|
||||||
|
def __init__(self, src, pkg = None, extra = None):
|
||||||
|
OTest.__init__(self, src, pkg)
|
||||||
|
if extra != None:
|
||||||
|
self.add_object(extra)
|
||||||
|
|
||||||
|
def add_object(self, obj):
|
||||||
|
path = "../../core/%s" % obj
|
||||||
|
CoreTest.Objs += [ OTest.Env.Object("%s-core" % obj, path) ]
|
||||||
|
|
||||||
|
def get_program(self):
|
||||||
|
self.add_object(self.Src)
|
||||||
|
return OTest.Env.Program(self.Name, [ self.Src ] + CoreTest.Objs)
|
||||||
|
|
||||||
|
|
||||||
|
res = TestList("core", [
|
||||||
|
|
||||||
|
OTest ("version.cpp"),
|
||||||
|
CoreTest("file.cpp"),
|
||||||
|
CoreTest("database.cpp"),
|
||||||
|
CoreTest("index.cpp"),
|
||||||
|
CoreTest("filter.cpp"),
|
||||||
|
CoreTest("idle.cpp"),
|
||||||
|
CoreTest("tags.cpp", "taglib"),
|
||||||
|
CoreTest("random.cpp"),
|
||||||
|
CoreTest("queue.cpp", extra = "callback.cpp"),
|
||||||
|
CoreTest("library.cpp"),
|
||||||
|
CoreTest("playlist.cpp"),
|
||||||
|
CoreTest("deck.cpp"),
|
||||||
|
CoreTest("driver.cpp"),
|
||||||
|
CoreTest("audio.cpp"),
|
||||||
|
|
||||||
|
]).prepare()
|
||||||
|
|
||||||
|
Return("res")
|
|
@ -4,7 +4,7 @@
|
||||||
#include <core/audio.h>
|
#include <core/audio.h>
|
||||||
#include <core/driver.h>
|
#include <core/driver.h>
|
||||||
#include <core/library.h>
|
#include <core/library.h>
|
||||||
#include "test.h"
|
#include <tests/test.h>
|
||||||
|
|
||||||
Track *TRACK_NULL = NULL;
|
Track *TRACK_NULL = NULL;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <core/database.h>
|
#include <core/database.h>
|
||||||
#include "test.h"
|
#include <tests/test.h>
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <core/callback.h>
|
#include <core/callback.h>
|
||||||
#include <core/deck.h>
|
#include <core/deck.h>
|
||||||
#include <core/library.h>
|
#include <core/library.h>
|
||||||
#include "test.h"
|
#include <tests/test.h>
|
||||||
|
|
||||||
static Queue *Q_NULL = NULL;
|
static Queue *Q_NULL = NULL;
|
||||||
static Track *TRACK_NULL = NULL;
|
static Track *TRACK_NULL = NULL;
|
|
@ -2,7 +2,7 @@
|
||||||
* Copyright 2014 (c) Anna Schumaker.
|
* Copyright 2014 (c) Anna Schumaker.
|
||||||
*/
|
*/
|
||||||
#include <core/driver.h>
|
#include <core/driver.h>
|
||||||
#include "test.h"
|
#include <tests/test.h>
|
||||||
|
|
||||||
static TestDriver *DRIVER_NULL = NULL;
|
static TestDriver *DRIVER_NULL = NULL;
|
||||||
static unsigned int eos_count = 0;
|
static unsigned int eos_count = 0;
|
|
@ -2,7 +2,7 @@
|
||||||
* Copyright 2014 (c) Anna Schumaker.
|
* Copyright 2014 (c) Anna Schumaker.
|
||||||
*/
|
*/
|
||||||
#include <core/file.h>
|
#include <core/file.h>
|
||||||
#include "test.h"
|
#include <tests/test.h>
|
||||||
|
|
||||||
|
|
||||||
static void test_filepath()
|
static void test_filepath()
|
|
@ -4,7 +4,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <core/filter.h>
|
#include <core/filter.h>
|
||||||
#include "test.h"
|
#include <tests/test.h>
|
||||||
|
|
||||||
static void do_test_lowercase(const std::string &text, const std::string &lc)
|
static void do_test_lowercase(const std::string &text, const std::string &lc)
|
||||||
{
|
{
|
|
@ -4,7 +4,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <core/idle.h>
|
#include <core/idle.h>
|
||||||
#include "test.h"
|
#include <tests/test.h>
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <core/index.h>
|
#include <core/index.h>
|
||||||
#include "test.h"
|
#include <tests/test.h>
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
#include <core/idle.h>
|
#include <core/idle.h>
|
||||||
#include <core/library.h>
|
#include <core/library.h>
|
||||||
#include "test.h"
|
#include <tests/test.h>
|
||||||
|
|
||||||
static Queue *Q_NULL = NULL;
|
static Queue *Q_NULL = NULL;
|
||||||
static Library *LIB_NULL = NULL;
|
static Library *LIB_NULL = NULL;
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
#include <core/library.h>
|
#include <core/library.h>
|
||||||
#include <core/playlist.h>
|
#include <core/playlist.h>
|
||||||
#include "test.h"
|
#include <tests/test.h>
|
||||||
|
|
||||||
static IndexEntry *IDX_NULL = NULL;
|
static IndexEntry *IDX_NULL = NULL;
|
||||||
static Queue *Q_NULL = NULL;
|
static Queue *Q_NULL = NULL;
|
|
@ -5,7 +5,7 @@
|
||||||
#include <core/queue.h>
|
#include <core/queue.h>
|
||||||
#include <core/random.h>
|
#include <core/random.h>
|
||||||
#include <core/tags.h>
|
#include <core/tags.h>
|
||||||
#include "test.h"
|
#include <tests/test.h>
|
||||||
|
|
||||||
|
|
||||||
unsigned int count_add = 0;
|
unsigned int count_add = 0;
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <core/random.h>
|
#include <core/random.h>
|
||||||
#include "test.h"
|
#include <tests/test.h>
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <core/tags.h>
|
#include <core/tags.h>
|
||||||
#include "test.h"
|
#include <tests/test.h>
|
||||||
|
|
||||||
static Library *LIB_NULL = NULL;
|
static Library *LIB_NULL = NULL;
|
||||||
static Track *TRACK_NULL = NULL;
|
static Track *TRACK_NULL = NULL;
|
|
@ -2,7 +2,7 @@
|
||||||
* Copyright 2013 (c) Anna Schumaker.
|
* Copyright 2013 (c) Anna Schumaker.
|
||||||
*/
|
*/
|
||||||
#include <core/version.h>
|
#include <core/version.h>
|
||||||
#include "test.h"
|
#include <tests/test.h>
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG
|
#ifdef CONFIG_DEBUG
|
||||||
const std::string expected = "6.1-debug";
|
const std::string expected = "6.1-debug";
|
Loading…
Reference in New Issue