Skip to content

Add new testing-utils library #1457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED true)

file(GLOB_RECURSE sources "*.cpp")
file(GLOB_RECURSE headers "*.h")

file(GLOB_RECURSE testing_utils "testing-utils/*.cpp" "testing-utils/*.h")

list(REMOVE_ITEM sources
# Used in executables
${CMAKE_CURRENT_SOURCE_DIR}/miniBDD.cpp
Expand All @@ -22,18 +25,23 @@ list(REMOVE_ITEM sources
${CMAKE_CURRENT_SOURCE_DIR}/float_utils.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ieee_float.cpp

# Will be built into a separate library and linked
${testing_utils}

# Intended to fail to compile
${CMAKE_CURRENT_SOURCE_DIR}/util/expr_cast/expr_undefined_casts.cpp
)

add_subdirectory(testing-utils)

add_executable(unit ${sources} ${headers})
target_include_directories(unit
PUBLIC
${CBMC_BINARY_DIR}
${CBMC_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
target_link_libraries(unit ansi-c solvers java_bytecode)
target_link_libraries(unit testing-utils ansi-c solvers java_bytecode)
add_test(
NAME unit
COMMAND $<TARGET_FILE:unit>
Expand Down
10 changes: 5 additions & 5 deletions unit/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
.PHONY: all cprover.dir test

# Source files for test utilities
SRC = src/expr/require_expr.cpp \
src/ansi-c/c_to_expr.cpp \
src/java_bytecode/load_java_class.cpp \
unit_tests.cpp \
SRC = unit_tests.cpp \
catch_example.cpp \
util/expr_iterator.cpp \
util/optional.cpp \
Expand Down Expand Up @@ -42,6 +39,9 @@ include ../src/common
cprover.dir:
$(MAKE) $(MAKEARGS) -C ../src

testing-utils/testing-utils$(LIBEXT):
$(MAKE) $(MAKEARGS) -C testing-utils

CPROVER_LIBS =../src/java_bytecode/java_bytecode$(LIBEXT) \
../src/miniz/miniz$(OBJEXT) \
../src/ansi-c/ansi-c$(LIBEXT) \
Expand All @@ -58,7 +58,7 @@ CPROVER_LIBS =../src/java_bytecode/java_bytecode$(LIBEXT) \
../src/solvers/solvers$(LIBEXT) \
# Empty last line

OBJ += $(CPROVER_LIBS)
OBJ += $(CPROVER_LIBS) testing-utils/testing-utils$(LIBEXT)

TESTS = unit_tests$(EXEEXT) \
miniBDD$(EXEEXT) \
Expand Down
2 changes: 1 addition & 1 deletion unit/analyses/ai/ai_simplify_lhs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/// \file
/// Unit tests for ai_domain_baset::ai_simplify_lhs

#include <catch.hpp>
#include <testing-utils/catch.hpp>

#include <analyses/ai.h>

Expand Down
2 changes: 1 addition & 1 deletion unit/analyses/call_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Module: Unit test for call graph generation

#include <iostream>

#include <catch.hpp>
#include <testing-utils/catch.hpp>

#include <analyses/call_graph.h>

Expand Down
2 changes: 1 addition & 1 deletion unit/analyses/does_remove_const/does_expr_lose_const.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/// \file
/// Does Remove Const Unit Tests

#include <catch.hpp>
#include <testing-utils/catch.hpp>

#include <util/std_expr.h>
#include <util/std_code.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/// \file
/// Does Remove Const Unit Tests

#include <catch.hpp>
#include <testing-utils/catch.hpp>

#include <util/c_types.h>
#include <util/namespace.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/// \file
/// Does Remove Const Unit Tests

#include <catch.hpp>
#include <testing-utils/catch.hpp>

#include <util/c_types.h>
#include <util/namespace.h>
Expand Down
2 changes: 1 addition & 1 deletion unit/catch_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

\*******************************************************************/

#include <catch.hpp>
#include <testing-utils/catch.hpp>

unsigned int Factorial(unsigned int number)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

\*******************************************************************/

#include <catch.hpp>
#include <testing-utils/catch.hpp>

#include <istream>
#include <memory>
Expand All @@ -15,7 +15,7 @@
#include <util/language.h>
#include <util/message.h>
#include <java_bytecode/java_bytecode_language.h>
#include <src/java_bytecode/load_java_class.h>
#include <testing-utils/load_java_class.h>

SCENARIO("java_bytecode_convert_abstract_class",
"[core][java_bytecode][java_bytecode_convert_class]")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

\*******************************************************************/

#include <catch.hpp>
#include <testing-utils/catch.hpp>
#include <util/c_types.h>
#include <util/expr.h>
#include <util/std_code.h>
Expand Down
2 changes: 1 addition & 1 deletion unit/miniBDD_new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/// \file
/// Unit tests for miniBDD

#include <catch.hpp>
#include <testing-utils/catch.hpp>

#include <solvers/miniBDD/miniBDD.h>
#include <solvers/flattening/boolbv.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

\*******************************************************************/

#include <catch.hpp>
#include <testing-utils/catch.hpp>

#include <solvers/refinement/string_constraint_generator.h>
#include <util/std_types.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

\*******************************************************************/

#include <catch.hpp>
#include <testing-utils/catch.hpp>

#include <solvers/refinement/string_constraint_generator.h>
#include <util/namespace.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

\*******************************************************************/

#include <catch.hpp>
#include <testing-utils/catch.hpp>

#include <solvers/refinement/string_constraint_generator.h>
#include <util/namespace.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

\*******************************************************************/

#include <catch.hpp>
#include <testing-utils/catch.hpp>

#include <solvers/refinement/string_constraint_instantiation.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

\*******************************************************************/

#include <catch.hpp>
#include <testing-utils/catch.hpp>

#include <util/arith_tools.h>
#include <util/std_types.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

\*******************************************************************/

#include <catch.hpp>
#include <testing-utils/catch.hpp>

#include <util/arith_tools.h>
#include <util/std_types.h>
Expand Down
10 changes: 10 additions & 0 deletions unit/testing-utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
file(GLOB_RECURSE sources "*.cpp" "*.h")
add_library(testing-utils ${sources})
target_link_libraries(testing-utils
util
java_bytecode
)
target_include_directories(testing-utils
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/..
)
18 changes: 18 additions & 0 deletions unit/testing-utils/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
SRC = \
c_to_expr.cpp \
load_java_class.cpp \
require_expr.cpp \
# Empty last line (please keep above list sorted!)

INCLUDES = -I .. -I . -I ../../src

include ../../src/config.inc
include ../../src/common

CLEANFILES = testing-utils$(LIBEXT)

.PHONY: all
all: testing-utils$(LIBEXT)

testing-utils$(LIBEXT): $(OBJ)
$(LINKLIB)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
///
#include "c_to_expr.h"

#include <catch.hpp>
#include <testing-utils/catch.hpp>

c_to_exprt::c_to_exprt():
message_handler(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
/// Utility for converting strings in to exprt, throwing a CATCH exception
/// if this fails in any way.

#ifndef CPROVER_SRC_ANSI_C_C_TO_EXPR_H
#define CPROVER_SRC_ANSI_C_C_TO_EXPR_H
#ifndef CPROVER_TESTING_UTILS_C_TO_EXPR_H
#define CPROVER_TESTING_UTILS_C_TO_EXPR_H

#include <memory>

Expand All @@ -32,4 +32,4 @@ class c_to_exprt
ansi_c_languaget language;
};

#endif // CPROVER_SRC_ANSI_C_C_TO_EXPR_H
#endif // CPROVER_TESTING_UTILS_C_TO_EXPR_H
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
\*******************************************************************/

#include "load_java_class.h"
#include <catch.hpp>
#include <testing-utils/catch.hpp>
#include <iostream>

#include <util/config.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
/// Utility for loading and parsing a specified java class file, returning
/// the symbol table generated by this.

#ifndef CPROVER_SRC_JAVA_BYTECODE_LOAD_JAVA_CLASS_H
#define CPROVER_SRC_JAVA_BYTECODE_LOAD_JAVA_CLASS_H
#ifndef CPROVER_TESTING_UTILS_LOAD_JAVA_CLASS_H
#define CPROVER_TESTING_UTILS_LOAD_JAVA_CLASS_H

#include <util/symbol_table.h>

symbol_tablet load_java_class(
const std::string &java_class_name,
const std::string &class_path);

#endif // CPROVER_SRC_JAVA_BYTECODE_LOAD_JAVA_CLASS_H
#endif // CPROVER_TESTING_UTILS_LOAD_JAVA_CLASS_H
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include "require_expr.h"

#include <catch.hpp>
#include <testing-utils/catch.hpp>
#include <util/arith_tools.h>

/// Verify a given exprt is an index_exprt with a a constant value equal to the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
/// Also checks associated properties and returns a casted version of the
/// expression.

#ifndef CPROVER_SRC_EXPR_REQUIRE_EXPR_H
#define CPROVER_SRC_EXPR_REQUIRE_EXPR_H
#ifndef CPROVER_TESTING_UTILS_REQUIRE_EXPR_H
#define CPROVER_TESTING_UTILS_REQUIRE_EXPR_H

#include <util/std_expr.h>

Expand All @@ -30,4 +30,4 @@ namespace require_expr
const exprt &expr, const irep_idt &symbol_name);
}

#endif // CPROVER_SRC_EXPR_REQUIRE_EXPR_H
#endif // CPROVER_TESTING_UTILS_REQUIRE_EXPR_H
2 changes: 1 addition & 1 deletion unit/unit_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
\*******************************************************************/

#define CATCH_CONFIG_MAIN
#include "catch.hpp"
#include <testing-utils/catch.hpp>
#include <util/irep.h>

// Debug printer for irept
Expand Down
2 changes: 1 addition & 1 deletion unit/util/expr_cast/expr_cast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// \file
/// expr_dynamic_cast Unit Tests

#include <catch.hpp>
#include <testing-utils/catch.hpp>
#include <util/std_expr.h>
#include <util/std_code.h>
#include <util/std_types.h>
Expand Down
2 changes: 1 addition & 1 deletion unit/util/expr_iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

\*******************************************************************/

#include <catch.hpp>
#include <testing-utils/catch.hpp>
#include <util/expr.h>
#include <util/expr_iterator.h>

Expand Down
2 changes: 1 addition & 1 deletion unit/util/optional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

\*******************************************************************/

#include "catch.hpp"
#include <testing-utils/catch.hpp>
#include <util/optional.h>

TEST_CASE("Optional without a value", "[core][util][optional]")
Expand Down
2 changes: 1 addition & 1 deletion unit/util/simplify_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

\*******************************************************************/

#include <catch.hpp>
#include <testing-utils/catch.hpp>

#include <java_bytecode/java_types.h>
#include <util/arith_tools.h>
Expand Down