From 2c073468d85b51d9a727193c95c4c86587bdc20d Mon Sep 17 00:00:00 2001 From: Yegor Derevenets Date: Sat, 30 May 2015 21:03:49 +0200 Subject: [PATCH] Added test build target, fixed CMake warning https://github.com/aquynh/capstone/issues/376 --- CMakeLists.txt | 6 +++++- tests/Makefile | 2 +- tests/README | 2 +- tests/{test.c => test_basic.c} | 0 4 files changed, 7 insertions(+), 3 deletions(-) rename tests/{test.c => test_basic.c} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 97c3cb6dd..aa83e4dea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,8 @@ option(CAPSTONE_X86_REDUCE "x86 with reduce instruction sets to minimize library option(CAPSTONE_X86_ATT_DISABLE "Disable x86 AT&T syntax" OFF) option(CAPSTONE_OSXKERNEL_SUPPORT "Support to embed Capstone into OS X Kernel extensions" OFF) +enable_testing() + if (CAPSTONE_BUILD_DIET) add_definitions(-DCAPSTONE_DIET) endif () @@ -80,7 +82,7 @@ set(HEADERS_COMMON ) -set(TEST_SOURCES test.c test_detail.c test_skipdata.c test_iter.c test_customized_mnem.c) +set(TEST_SOURCES test_basic.c test_detail.c test_skipdata.c test_iter.c test_customized_mnem.c) ## architecture support if (CAPSTONE_ARM_SUPPORT) @@ -357,12 +359,14 @@ if (CAPSTONE_BUILD_TESTS) STRING(REGEX REPLACE ".c$" "" TBIN ${TSRC}) add_executable(${TBIN} "tests/${TSRC}") target_link_libraries(${TBIN} ${default-target}) + add_test(NAME "capstone_${TBIN}" COMMAND ${TBIN}) endforeach () if (CAPSTONE_ARM_SUPPORT) set(ARM_REGRESS_TEST test_arm_regression.c) STRING(REGEX REPLACE ".c$" "" ARM_REGRESS_BIN ${ARM_REGRESS_TEST}) add_executable(${ARM_REGRESS_BIN} "suite/arm/${ARM_REGRESS_TEST}") target_link_libraries(${ARM_REGRESS_BIN} ${default-target}) + add_test(NAME "capstone_${ARM_REGRESS_BIN}" COMMAND ${ARM_REGRESS_BIN}) endif() endif () diff --git a/tests/Makefile b/tests/Makefile index e2edd49af..e9d1ae2a4 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -64,7 +64,7 @@ endif .PHONY: all clean -SOURCES = test.c test_detail.c test_skipdata.c test_iter.c test_customized_mnem.c +SOURCES = test_basic.c test_detail.c test_skipdata.c test_iter.c test_customized_mnem.c ifneq (,$(findstring arm,$(CAPSTONE_ARCHS))) SOURCES += test_arm.c endif diff --git a/tests/README b/tests/README index 7f043ca9a..02960772a 100644 --- a/tests/README +++ b/tests/README @@ -1,6 +1,6 @@ This directory contains some test code to show how to use Capstone API. -- test.c +- test_basic.c This code shows the most simple form of API where we only want to get basic information out of disassembled instruction, such as address, mnemonic and operand string. diff --git a/tests/test.c b/tests/test_basic.c similarity index 100% rename from tests/test.c rename to tests/test_basic.c