Check in files.
This commit is contained in:
parent
942928aa05
commit
9ffa5aecb8
8 changed files with 203 additions and 20 deletions
54
cmake_modules/FindCheck.cmake
Normal file
54
cmake_modules/FindCheck.cmake
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
# - Try to find the CHECK libraries
|
||||||
|
# Once done this will define
|
||||||
|
#
|
||||||
|
# CHECK_FOUND - system has check
|
||||||
|
# CHECK_INCLUDE_DIRS - the check include directory
|
||||||
|
# CHECK_LIBRARIES - check library
|
||||||
|
#
|
||||||
|
# Copyright (c) 2007 Daniel Gollub <gollub@b1-systems.de>
|
||||||
|
# Copyright (c) 2007-2009 Bjoern Ricks <bjoern.ricks@gmail.com>
|
||||||
|
#
|
||||||
|
# Redistribution and use is allowed according to the terms of the New
|
||||||
|
# BSD license.
|
||||||
|
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||||
|
|
||||||
|
|
||||||
|
INCLUDE( FindPkgConfig )
|
||||||
|
|
||||||
|
IF ( Check_FIND_REQUIRED )
|
||||||
|
SET( _pkgconfig_REQUIRED "REQUIRED" )
|
||||||
|
ELSE( Check_FIND_REQUIRED )
|
||||||
|
SET( _pkgconfig_REQUIRED "" )
|
||||||
|
ENDIF ( Check_FIND_REQUIRED )
|
||||||
|
|
||||||
|
IF ( CHECK_MIN_VERSION )
|
||||||
|
PKG_SEARCH_MODULE( CHECK ${_pkgconfig_REQUIRED} check>=${CHECK_MIN_VERSION} )
|
||||||
|
ELSE ( CHECK_MIN_VERSION )
|
||||||
|
PKG_SEARCH_MODULE( CHECK ${_pkgconfig_REQUIRED} check )
|
||||||
|
ENDIF ( CHECK_MIN_VERSION )
|
||||||
|
|
||||||
|
# Look for CHECK include dir and libraries
|
||||||
|
IF( NOT CHECK_FOUND AND NOT PKG_CONFIG_FOUND )
|
||||||
|
|
||||||
|
FIND_PATH( CHECK_INCLUDE_DIRS check.h )
|
||||||
|
|
||||||
|
FIND_LIBRARY( CHECK_LIBRARIES NAMES check )
|
||||||
|
|
||||||
|
IF ( CHECK_INCLUDE_DIRS AND CHECK_LIBRARIES )
|
||||||
|
SET( CHECK_FOUND 1 )
|
||||||
|
IF ( NOT Check_FIND_QUIETLY )
|
||||||
|
MESSAGE ( STATUS "Found CHECK: ${CHECK_LIBRARIES}" )
|
||||||
|
ENDIF ( NOT Check_FIND_QUIETLY )
|
||||||
|
ELSE ( CHECK_INCLUDE_DIRS AND CHECK_LIBRARIES )
|
||||||
|
IF ( Check_FIND_REQUIRED )
|
||||||
|
MESSAGE( FATAL_ERROR "Could NOT find CHECK" )
|
||||||
|
ELSE ( Check_FIND_REQUIRED )
|
||||||
|
IF ( NOT Check_FIND_QUIETLY )
|
||||||
|
MESSAGE( STATUS "Could NOT find CHECK" )
|
||||||
|
ENDIF ( NOT Check_FIND_QUIETLY )
|
||||||
|
ENDIF ( Check_FIND_REQUIRED )
|
||||||
|
ENDIF ( CHECK_INCLUDE_DIRS AND CHECK_LIBRARIES )
|
||||||
|
ENDIF( NOT CHECK_FOUND AND NOT PKG_CONFIG_FOUND )
|
||||||
|
|
||||||
|
# Hide advanced variables from CMake GUIs
|
||||||
|
MARK_AS_ADVANCED( CHECK_INCLUDE_DIRS CHECK_LIBRARIES )
|
37
cmake_modules/FindJudy.cmake
Normal file
37
cmake_modules/FindJudy.cmake
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
# Copyright (C) 2007-2009 LuaDist.
|
||||||
|
# Created by Peter Kapec <kapecp@gmail.com>
|
||||||
|
# Redistribution and use of this file is allowed according to the terms of the MIT license.
|
||||||
|
# For details see the COPYRIGHT file distributed with LuaDist.
|
||||||
|
# Note:
|
||||||
|
# Searching headers and libraries is very simple and is NOT as powerful as scripts
|
||||||
|
# distributed with CMake, because LuaDist defines directories to search for.
|
||||||
|
# Everyone is encouraged to contact the author with improvements. Maybe this file
|
||||||
|
# becomes part of CMake distribution sometimes.
|
||||||
|
|
||||||
|
# - Find judy
|
||||||
|
# Find the native Judy headers and libraries.
|
||||||
|
#
|
||||||
|
# Judy_INCLUDE_DIRS - where to find judy.h, etc.
|
||||||
|
# Judy_LIBRARIES - List of libraries when using judy.
|
||||||
|
# Judy_FOUND - True if judy found.
|
||||||
|
|
||||||
|
# Look for the header file.
|
||||||
|
FIND_PATH(Judy_INCLUDE_DIR NAMES Judy.h)
|
||||||
|
|
||||||
|
# Look for the library.
|
||||||
|
FIND_LIBRARY(Judy_LIBRARY NAMES judy)
|
||||||
|
|
||||||
|
# Handle the QUIETLY and REQUIRED arguments and set Judy_FOUND to TRUE if all listed variables are TRUE.
|
||||||
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Judy DEFAULT_MSG Judy_LIBRARY Judy_INCLUDE_DIR)
|
||||||
|
|
||||||
|
# Copy the results to the output variables.
|
||||||
|
IF(Judy_FOUND)
|
||||||
|
SET(Judy_LIBRARIES ${Judy_LIBRARY})
|
||||||
|
SET(Judy_INCLUDE_DIRS ${Judy_INCLUDE_DIR})
|
||||||
|
ELSE(Judy_FOUND)
|
||||||
|
SET(Judy_LIBRARIES)
|
||||||
|
SET(Judy_INCLUDE_DIRS)
|
||||||
|
ENDIF(Judy_FOUND)
|
||||||
|
|
||||||
|
MARK_AS_ADVANCED(Judy_INCLUDE_DIRS Judy_LIBRARIES)
|
37
cmake_modules/FindPCRE.cmake
Normal file
37
cmake_modules/FindPCRE.cmake
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
# Copyright (C) 2007-2009 LuaDist.
|
||||||
|
# Created by Peter Kapec <kapecp@gmail.com>
|
||||||
|
# Redistribution and use of this file is allowed according to the terms of the MIT license.
|
||||||
|
# For details see the COPYRIGHT file distributed with LuaDist.
|
||||||
|
# Note:
|
||||||
|
# Searching headers and libraries is very simple and is NOT as powerful as scripts
|
||||||
|
# distributed with CMake, because LuaDist defines directories to search for.
|
||||||
|
# Everyone is encouraged to contact the author with improvements. Maybe this file
|
||||||
|
# becomes part of CMake distribution sometimes.
|
||||||
|
|
||||||
|
# - Find pcre
|
||||||
|
# Find the native PCRE headers and libraries.
|
||||||
|
#
|
||||||
|
# PCRE_INCLUDE_DIRS - where to find pcre.h, etc.
|
||||||
|
# PCRE_LIBRARIES - List of libraries when using pcre.
|
||||||
|
# PCRE_FOUND - True if pcre found.
|
||||||
|
|
||||||
|
# Look for the header file.
|
||||||
|
FIND_PATH(PCRE_INCLUDE_DIR NAMES pcre.h)
|
||||||
|
|
||||||
|
# Look for the library.
|
||||||
|
FIND_LIBRARY(PCRE_LIBRARY NAMES pcre)
|
||||||
|
|
||||||
|
# Handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if all listed variables are TRUE.
|
||||||
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_INCLUDE_DIR)
|
||||||
|
|
||||||
|
# Copy the results to the output variables.
|
||||||
|
IF(PCRE_FOUND)
|
||||||
|
SET(PCRE_LIBRARIES ${PCRE_LIBRARY})
|
||||||
|
SET(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR})
|
||||||
|
ELSE(PCRE_FOUND)
|
||||||
|
SET(PCRE_LIBRARIES)
|
||||||
|
SET(PCRE_INCLUDE_DIRS)
|
||||||
|
ENDIF(PCRE_FOUND)
|
||||||
|
|
||||||
|
MARK_AS_ADVANCED(PCRE_INCLUDE_DIRS PCRE_LIBRARIES)
|
20
configure.ac
20
configure.ac
|
@ -1,20 +0,0 @@
|
||||||
# -*- Autoconf -*-
|
|
||||||
# Process this file with autoconf to produce a configure script.
|
|
||||||
|
|
||||||
AC_PREREQ([2.69])
|
|
||||||
AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
|
|
||||||
AC_CONFIG_SRCDIR([config.h.in])
|
|
||||||
AC_CONFIG_HEADERS([config.h])
|
|
||||||
|
|
||||||
# Checks for programs.
|
|
||||||
AC_PROG_CC
|
|
||||||
|
|
||||||
# Checks for libraries.
|
|
||||||
|
|
||||||
# Checks for header files.
|
|
||||||
|
|
||||||
# Checks for typedefs, structures, and compiler characteristics.
|
|
||||||
|
|
||||||
# Checks for library functions.
|
|
||||||
|
|
||||||
AC_OUTPUT
|
|
17
main.c
Normal file
17
main.c
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <pcre.h>
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
typedef struct _Node {
|
||||||
|
char ** patterns;
|
||||||
|
} Node;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void compile() {
|
||||||
|
|
||||||
|
}
|
6
main.h
Normal file
6
main.h
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#ifndef MAIN_H
|
||||||
|
#define MAIN_H
|
||||||
|
|
||||||
|
void compile();
|
||||||
|
|
||||||
|
#endif
|
24
tests/CMakeLists.txt
Normal file
24
tests/CMakeLists.txt
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# set(TEST_LIBS ${TEST_LIBS} ${CHECK_LIBRARIES} judy libr2)
|
||||||
|
# set(TEST_LIBS ${TEST_LIBS} ${CHECK_LIBRARIES} judy libr2)
|
||||||
|
find_package(Check REQUIRED)
|
||||||
|
find_package(PCRE REQUIRED)
|
||||||
|
find_package(Judy REQUIRED)
|
||||||
|
|
||||||
|
if (NOT CHECK_FOUND)
|
||||||
|
message(STATUS "Skipping unit tests, Check library not found!")
|
||||||
|
else (NOT CHECK_FOUND)
|
||||||
|
set(TEST_LIBS ${LIBS} ${CHECK_LIBRARIES} ${PCRE_LIBRARIES} ${Judy_LIBRARIES} libr2)
|
||||||
|
|
||||||
|
include_directories(${CHECK_INCLUDE_DIRS})
|
||||||
|
# include_directories("${PROJECT_SOURCE_DIR}/include/r2")
|
||||||
|
add_executable(test_tree test_tree.c)
|
||||||
|
target_link_libraries(test_tree ${TEST_LIBS})
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
TARGET test_tree POST_BUILD
|
||||||
|
COMMENT "Running unit tests"
|
||||||
|
COMMAND test_tree
|
||||||
|
)
|
||||||
|
endif (NOT CHECK_FOUND)
|
||||||
|
|
||||||
|
|
28
tests/test_tree.c
Normal file
28
tests/test_tree.c
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <check.h>
|
||||||
|
|
||||||
|
START_TEST (test_tree)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
|
||||||
|
Suite* str_suite (void) {
|
||||||
|
Suite *suite = suite_create("test_tree");
|
||||||
|
/*
|
||||||
|
TCase *tcase = tcase_create("case");
|
||||||
|
tcase_add_test(tcase, test_tree);
|
||||||
|
suite_add_tcase(suite, tcase);
|
||||||
|
*/
|
||||||
|
return suite;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main (int argc, char *argv[]) {
|
||||||
|
int number_failed;
|
||||||
|
Suite *suite = str_suite();
|
||||||
|
SRunner *runner = srunner_create(suite);
|
||||||
|
srunner_run_all(runner, CK_NORMAL);
|
||||||
|
number_failed = srunner_ntests_failed(runner);
|
||||||
|
srunner_free(runner);
|
||||||
|
return number_failed;
|
||||||
|
}
|
Loading…
Reference in a new issue