mirror of https://github.com/mgba-emu/mgba.git
Test: Restructure test suite into multiple executables
This commit is contained in:
parent
66d5106e0b
commit
bb6728558d
1
CHANGES
1
CHANGES
|
@ -40,6 +40,7 @@ Misc:
|
|||
- Qt: Don't rebuild library view if style hasn't changed
|
||||
- Qt: Redo GameController into multiple classes
|
||||
- SDL: Fix 2.0.5 build on macOS under some circumstances
|
||||
- Test: Restructure test suite into multiple executables
|
||||
|
||||
0.6.0: (2017-07-16)
|
||||
Features:
|
||||
|
|
|
@ -861,10 +861,16 @@ if(BUILD_SUITE)
|
|||
include_directories(AFTER ${CMOCKA_INCLUDE_DIRS})
|
||||
link_directories(${CMOCKA_LIBRARY_DIRS})
|
||||
|
||||
add_executable(${BINARY_NAME}-suite ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/test/suite-main.c ${TEST_SRC})
|
||||
target_link_libraries(${BINARY_NAME}-suite ${BINARY_NAME} ${PLATFORM_LIBRARY} cmocka)
|
||||
set_target_properties(${BINARY_NAME}-suite PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")
|
||||
add_test(${BINARY_NAME}-suite ${BINARY_NAME}-suite)
|
||||
foreach(TEST IN LISTS TEST_SRC)
|
||||
string(REPLACE "${CMAKE_SOURCE_DIR}/src/" "" TEST_NAME "${TEST}")
|
||||
string(REPLACE "/" "-" TEST_NAME "${TEST_NAME}")
|
||||
string(REPLACE "-test" "" TEST_NAME "${TEST_NAME}")
|
||||
string(REPLACE ".c" "" TEST_NAME "${TEST_NAME}")
|
||||
add_executable(test-${TEST_NAME} ${TEST})
|
||||
target_link_libraries(test-${TEST_NAME} ${BINARY_NAME} ${PLATFORM_LIBRARY} cmocka)
|
||||
set_target_properties(test-${TEST_NAME} PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")
|
||||
add_test(${TEST_NAME} test-${TEST_NAME})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(BUILD_EXAMPLE)
|
||||
|
|
|
@ -34,9 +34,3 @@ M_TEST_SUITE_DEFINE(mCore,
|
|||
#endif
|
||||
cmocka_unit_test(findNullVF),
|
||||
cmocka_unit_test(findEmpty))
|
||||
|
||||
int TestRunCore(void) {
|
||||
int failures = 0;
|
||||
failures += M_TEST_SUITE_RUN(mCore);
|
||||
return failures;
|
||||
}
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
/* Copyright (c) 2013-2016 Jeffrey Pfau
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#include "util/test/suite.h"
|
||||
|
||||
M_TEST_SUITE_DECLARE(GBCore);
|
||||
M_TEST_SUITE_DECLARE(GBMBC);
|
||||
M_TEST_SUITE_DECLARE(GBMemory);
|
||||
M_TEST_SUITE_DECLARE(GBRTC);
|
||||
|
||||
int TestRunGB(void) {
|
||||
int failures = 0;
|
||||
failures += M_TEST_SUITE_RUN(GBCore);
|
||||
failures += M_TEST_SUITE_RUN(GBMBC);
|
||||
failures += M_TEST_SUITE_RUN(GBMemory);
|
||||
failures += M_TEST_SUITE_RUN(GBRTC);
|
||||
return failures;
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
/* Copyright (c) 2013-2016 Jeffrey Pfau
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#ifndef TEST_GB_H
|
||||
#define TEST_GB_H
|
||||
#include <mgba-util/common.h>
|
||||
|
||||
int TestRunGB(void);
|
||||
|
||||
#endif
|
|
@ -1,14 +0,0 @@
|
|||
/* Copyright (c) 2013-2016 Jeffrey Pfau
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#include "util/test/suite.h"
|
||||
|
||||
M_TEST_SUITE_DECLARE(GBACore);
|
||||
|
||||
int TestRunGBA(void) {
|
||||
int failures = 0;
|
||||
failures += M_TEST_SUITE_RUN(GBACore);
|
||||
return failures;
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
/* Copyright (c) 2013-2016 Jeffrey Pfau
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#ifndef TEST_GBA_H
|
||||
#define TEST_GBA_H
|
||||
#include <mgba-util/common.h>
|
||||
|
||||
int TestRunGBA(void);
|
||||
|
||||
#endif
|
|
@ -1,27 +0,0 @@
|
|||
/* Copyright (c) 2013-2016 Jeffrey Pfau
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#include "util/test/suite.h"
|
||||
|
||||
#include "util/test/util.h"
|
||||
#include "core/test/core.h"
|
||||
#ifdef M_CORE_GBA
|
||||
#include "gba/test/gba.h"
|
||||
#endif
|
||||
#ifdef M_CORE_GB
|
||||
#include "gb/test/gb.h"
|
||||
#endif
|
||||
|
||||
int main() {
|
||||
int failures = TestRunUtil();
|
||||
failures += TestRunCore();
|
||||
#ifdef M_CORE_GBA
|
||||
failures += TestRunGBA();
|
||||
#endif
|
||||
#ifdef M_CORE_GB
|
||||
failures += TestRunGB();
|
||||
#endif
|
||||
return failures != 0;
|
||||
}
|
|
@ -12,14 +12,12 @@
|
|||
|
||||
#define M_TEST_DEFINE(NAME) static void NAME (void **state ATTRIBUTE_UNUSED)
|
||||
|
||||
#define M_TEST_SUITE(NAME) _testSuite_ ## NAME
|
||||
#define M_TEST_SUITE_RUN(NAME) (printf("\nRunning suite %s\n", # NAME), M_TEST_SUITE(NAME)())
|
||||
#define M_TEST_SUITE_DEFINE(NAME, ...) M_TEST_SUITE_DEFINE_EX(NAME, NULL, NULL, __VA_ARGS__)
|
||||
#define M_TEST_SUITE_DEFINE_SETUP(NAME, ...) M_TEST_SUITE_DEFINE_EX(NAME, _testSuite_setup_ ## NAME, NULL, __VA_ARGS__)
|
||||
#define M_TEST_SUITE_DEFINE_TEARDOWN(NAME, ...) M_TEST_SUITE_DEFINE_EX(NAME, NULL, _testSuite_teardown_ ## NAME, __VA_ARGS__)
|
||||
#define M_TEST_SUITE_DEFINE_SETUP_TEARDOWN(NAME, ...) M_TEST_SUITE_DEFINE_EX(NAME, _testSuite_setup_ ## NAME, _testSuite_teardown_ ## NAME, __VA_ARGS__)
|
||||
#define M_TEST_SUITE_DEFINE_EX(NAME, SETUP, TEARDOWN, ...) \
|
||||
int M_TEST_SUITE(NAME) (void) { \
|
||||
int main(void) { \
|
||||
const static struct CMUnitTest tests[] = { \
|
||||
__VA_ARGS__ \
|
||||
}; \
|
||||
|
@ -29,6 +27,4 @@
|
|||
#define M_TEST_SUITE_SETUP(NAME) static int _testSuite_setup_ ## NAME (void **state ATTRIBUTE_UNUSED)
|
||||
#define M_TEST_SUITE_TEARDOWN(NAME) static int _testSuite_teardown_ ## NAME (void **state ATTRIBUTE_UNUSED)
|
||||
|
||||
#define M_TEST_SUITE_DECLARE(NAME) extern int M_TEST_SUITE(NAME) (void)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
/* Copyright (c) 2013-2016 Jeffrey Pfau
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#include "util/test/suite.h"
|
||||
|
||||
M_TEST_SUITE_DECLARE(TextCodec);
|
||||
M_TEST_SUITE_DECLARE(VFS);
|
||||
|
||||
int TestRunUtil(void) {
|
||||
int failures = 0;
|
||||
failures += M_TEST_SUITE_RUN(TextCodec);
|
||||
failures += M_TEST_SUITE_RUN(VFS);
|
||||
return failures;
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
/* Copyright (c) 2013-2016 Jeffrey Pfau
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#ifndef TEST_UTIL_H
|
||||
#define TEST_UTIL_H
|
||||
#include <mgba-util/common.h>
|
||||
|
||||
int TestRunUtil(void);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue