Skip to content

Commit 68e4d6b

Browse files
author
Thomas Kiley
authored
Merge pull request diffblue#1457 from reuk/reuk/testing-utils
Add new testing-utils library
2 parents 99eb662 + aacd436 commit 68e4d6b

31 files changed

+75
-39
lines changed

unit/CMakeLists.txt

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED true)
33

44
file(GLOB_RECURSE sources "*.cpp")
55
file(GLOB_RECURSE headers "*.h")
6+
7+
file(GLOB_RECURSE testing_utils "testing-utils/*.cpp" "testing-utils/*.h")
8+
69
list(REMOVE_ITEM sources
710
# Used in executables
811
${CMAKE_CURRENT_SOURCE_DIR}/miniBDD.cpp
@@ -22,18 +25,23 @@ list(REMOVE_ITEM sources
2225
${CMAKE_CURRENT_SOURCE_DIR}/float_utils.cpp
2326
${CMAKE_CURRENT_SOURCE_DIR}/ieee_float.cpp
2427

28+
# Will be built into a separate library and linked
29+
${testing_utils}
30+
2531
# Intended to fail to compile
2632
${CMAKE_CURRENT_SOURCE_DIR}/util/expr_cast/expr_undefined_casts.cpp
2733
)
2834

35+
add_subdirectory(testing-utils)
36+
2937
add_executable(unit ${sources} ${headers})
3038
target_include_directories(unit
3139
PUBLIC
3240
${CBMC_BINARY_DIR}
3341
${CBMC_SOURCE_DIR}
3442
${CMAKE_CURRENT_SOURCE_DIR}
3543
)
36-
target_link_libraries(unit ansi-c solvers java_bytecode)
44+
target_link_libraries(unit testing-utils ansi-c solvers java_bytecode)
3745
add_test(
3846
NAME unit
3947
COMMAND $<TARGET_FILE:unit>

unit/Makefile

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
.PHONY: all cprover.dir test
22

33
# Source files for test utilities
4-
SRC = src/expr/require_expr.cpp \
5-
src/ansi-c/c_to_expr.cpp \
6-
src/java_bytecode/load_java_class.cpp \
7-
unit_tests.cpp \
4+
SRC = unit_tests.cpp \
85
catch_example.cpp \
96
util/expr_iterator.cpp \
107
util/optional.cpp \
@@ -42,6 +39,9 @@ include ../src/common
4239
cprover.dir:
4340
$(MAKE) $(MAKEARGS) -C ../src
4441

42+
testing-utils/testing-utils$(LIBEXT):
43+
$(MAKE) $(MAKEARGS) -C testing-utils
44+
4545
CPROVER_LIBS =../src/java_bytecode/java_bytecode$(LIBEXT) \
4646
../src/miniz/miniz$(OBJEXT) \
4747
../src/ansi-c/ansi-c$(LIBEXT) \
@@ -58,7 +58,7 @@ CPROVER_LIBS =../src/java_bytecode/java_bytecode$(LIBEXT) \
5858
../src/solvers/solvers$(LIBEXT) \
5959
# Empty last line
6060

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

6363
TESTS = unit_tests$(EXEEXT) \
6464
miniBDD$(EXEEXT) \

unit/analyses/ai/ai_simplify_lhs.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/// \file
1010
/// Unit tests for ai_domain_baset::ai_simplify_lhs
1111

12-
#include <catch.hpp>
12+
#include <testing-utils/catch.hpp>
1313

1414
#include <analyses/ai.h>
1515

unit/analyses/call_graph.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Module: Unit test for call graph generation
88

99
#include <iostream>
1010

11-
#include <catch.hpp>
11+
#include <testing-utils/catch.hpp>
1212

1313
#include <analyses/call_graph.h>
1414

unit/analyses/does_remove_const/does_expr_lose_const.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/// \file
1010
/// Does Remove Const Unit Tests
1111

12-
#include <catch.hpp>
12+
#include <testing-utils/catch.hpp>
1313

1414
#include <util/std_expr.h>
1515
#include <util/std_code.h>

unit/analyses/does_remove_const/does_type_preserve_const_correctness.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/// \file
1010
/// Does Remove Const Unit Tests
1111

12-
#include <catch.hpp>
12+
#include <testing-utils/catch.hpp>
1313

1414
#include <util/c_types.h>
1515
#include <util/namespace.h>

unit/analyses/does_remove_const/is_type_at_least_as_const_as.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/// \file
1010
/// Does Remove Const Unit Tests
1111

12-
#include <catch.hpp>
12+
#include <testing-utils/catch.hpp>
1313

1414
#include <util/c_types.h>
1515
#include <util/namespace.h>

unit/catch_example.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
\*******************************************************************/
88

9-
#include <catch.hpp>
9+
#include <testing-utils/catch.hpp>
1010

1111
unsigned int Factorial(unsigned int number)
1212
{

unit/java_bytecode/java_bytecode_convert_class/convert_abstract_class.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
\*******************************************************************/
88

9-
#include <catch.hpp>
9+
#include <testing-utils/catch.hpp>
1010

1111
#include <istream>
1212
#include <memory>
@@ -15,7 +15,7 @@
1515
#include <util/language.h>
1616
#include <util/message.h>
1717
#include <java_bytecode/java_bytecode_language.h>
18-
#include <src/java_bytecode/load_java_class.h>
18+
#include <testing-utils/load_java_class.h>
1919

2020
SCENARIO("java_bytecode_convert_abstract_class",
2121
"[core][java_bytecode][java_bytecode_convert_class]")

unit/java_bytecode/java_string_library_preprocess/convert_exprt_to_string_exprt.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
\*******************************************************************/
99

10-
#include <catch.hpp>
10+
#include <testing-utils/catch.hpp>
1111
#include <util/c_types.h>
1212
#include <util/expr.h>
1313
#include <util/std_code.h>

unit/miniBDD_new.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/// \file
1010
/// Unit tests for miniBDD
1111

12-
#include <catch.hpp>
12+
#include <testing-utils/catch.hpp>
1313

1414
#include <solvers/miniBDD/miniBDD.h>
1515
#include <solvers/flattening/boolbv.h>

unit/solvers/refinement/string_constraint_generator_valueof/calculate_max_string_length.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
\*******************************************************************/
99

10-
#include <catch.hpp>
10+
#include <testing-utils/catch.hpp>
1111

1212
#include <solvers/refinement/string_constraint_generator.h>
1313
#include <util/std_types.h>

unit/solvers/refinement/string_constraint_generator_valueof/get_numeric_value_from_character.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
\*******************************************************************/
99

10-
#include <catch.hpp>
10+
#include <testing-utils/catch.hpp>
1111

1212
#include <solvers/refinement/string_constraint_generator.h>
1313
#include <util/namespace.h>

unit/solvers/refinement/string_constraint_generator_valueof/is_digit_with_radix.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
\*******************************************************************/
99

10-
#include <catch.hpp>
10+
#include <testing-utils/catch.hpp>
1111

1212
#include <solvers/refinement/string_constraint_generator.h>
1313
#include <util/namespace.h>

unit/solvers/refinement/string_constraint_instantiation/instantiate_not_contains.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
\*******************************************************************/
88

9-
#include <catch.hpp>
9+
#include <testing-utils/catch.hpp>
1010

1111
#include <solvers/refinement/string_constraint_instantiation.h>
1212

unit/solvers/refinement/string_refinement/concretize_array.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
\*******************************************************************/
99

10-
#include <catch.hpp>
10+
#include <testing-utils/catch.hpp>
1111

1212
#include <util/arith_tools.h>
1313
#include <util/std_types.h>

unit/solvers/refinement/string_refinement/substitute_array_list.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
\*******************************************************************/
99

10-
#include <catch.hpp>
10+
#include <testing-utils/catch.hpp>
1111

1212
#include <util/arith_tools.h>
1313
#include <util/std_types.h>

unit/testing-utils/CMakeLists.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
file(GLOB_RECURSE sources "*.cpp" "*.h")
2+
add_library(testing-utils ${sources})
3+
target_link_libraries(testing-utils
4+
util
5+
java_bytecode
6+
)
7+
target_include_directories(testing-utils
8+
PUBLIC
9+
${CMAKE_CURRENT_SOURCE_DIR}/..
10+
)

unit/testing-utils/Makefile

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
SRC = \
2+
c_to_expr.cpp \
3+
load_java_class.cpp \
4+
require_expr.cpp \
5+
# Empty last line (please keep above list sorted!)
6+
7+
INCLUDES = -I .. -I . -I ../../src
8+
9+
include ../../src/config.inc
10+
include ../../src/common
11+
12+
CLEANFILES = testing-utils$(LIBEXT)
13+
14+
.PHONY: all
15+
all: testing-utils$(LIBEXT)
16+
17+
testing-utils$(LIBEXT): $(OBJ)
18+
$(LINKLIB)

unit/src/ansi-c/c_to_expr.cpp renamed to unit/testing-utils/c_to_expr.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
///
1313
#include "c_to_expr.h"
1414

15-
#include <catch.hpp>
15+
#include <testing-utils/catch.hpp>
1616

1717
c_to_exprt::c_to_exprt():
1818
message_handler(

unit/src/ansi-c/c_to_expr.h renamed to unit/testing-utils/c_to_expr.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
/// Utility for converting strings in to exprt, throwing a CATCH exception
1111
/// if this fails in any way.
1212

13-
#ifndef CPROVER_SRC_ANSI_C_C_TO_EXPR_H
14-
#define CPROVER_SRC_ANSI_C_C_TO_EXPR_H
13+
#ifndef CPROVER_TESTING_UTILS_C_TO_EXPR_H
14+
#define CPROVER_TESTING_UTILS_C_TO_EXPR_H
1515

1616
#include <memory>
1717

@@ -32,4 +32,4 @@ class c_to_exprt
3232
ansi_c_languaget language;
3333
};
3434

35-
#endif // CPROVER_SRC_ANSI_C_C_TO_EXPR_H
35+
#endif // CPROVER_TESTING_UTILS_C_TO_EXPR_H
File renamed without changes.

unit/src/java_bytecode/load_java_class.cpp renamed to unit/testing-utils/load_java_class.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
\*******************************************************************/
88

99
#include "load_java_class.h"
10-
#include <catch.hpp>
10+
#include <testing-utils/catch.hpp>
1111
#include <iostream>
1212

1313
#include <util/config.h>

unit/src/java_bytecode/load_java_class.h renamed to unit/testing-utils/load_java_class.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
/// Utility for loading and parsing a specified java class file, returning
1111
/// the symbol table generated by this.
1212

13-
#ifndef CPROVER_SRC_JAVA_BYTECODE_LOAD_JAVA_CLASS_H
14-
#define CPROVER_SRC_JAVA_BYTECODE_LOAD_JAVA_CLASS_H
13+
#ifndef CPROVER_TESTING_UTILS_LOAD_JAVA_CLASS_H
14+
#define CPROVER_TESTING_UTILS_LOAD_JAVA_CLASS_H
1515

1616
#include <util/symbol_table.h>
1717

1818
symbol_tablet load_java_class(
1919
const std::string &java_class_name,
2020
const std::string &class_path);
2121

22-
#endif // CPROVER_SRC_JAVA_BYTECODE_LOAD_JAVA_CLASS_H
22+
#endif // CPROVER_TESTING_UTILS_LOAD_JAVA_CLASS_H

unit/src/expr/require_expr.cpp renamed to unit/testing-utils/require_expr.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include "require_expr.h"
1616

17-
#include <catch.hpp>
17+
#include <testing-utils/catch.hpp>
1818
#include <util/arith_tools.h>
1919

2020
/// Verify a given exprt is an index_exprt with a a constant value equal to the

unit/src/expr/require_expr.h renamed to unit/testing-utils/require_expr.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
/// Also checks associated properties and returns a casted version of the
1313
/// expression.
1414

15-
#ifndef CPROVER_SRC_EXPR_REQUIRE_EXPR_H
16-
#define CPROVER_SRC_EXPR_REQUIRE_EXPR_H
15+
#ifndef CPROVER_TESTING_UTILS_REQUIRE_EXPR_H
16+
#define CPROVER_TESTING_UTILS_REQUIRE_EXPR_H
1717

1818
#include <util/std_expr.h>
1919

@@ -30,4 +30,4 @@ namespace require_expr
3030
const exprt &expr, const irep_idt &symbol_name);
3131
}
3232

33-
#endif // CPROVER_SRC_EXPR_REQUIRE_EXPR_H
33+
#endif // CPROVER_TESTING_UTILS_REQUIRE_EXPR_H

unit/unit_tests.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
\*******************************************************************/
88

99
#define CATCH_CONFIG_MAIN
10-
#include "catch.hpp"
10+
#include <testing-utils/catch.hpp>
1111
#include <util/irep.h>
1212

1313
// Debug printer for irept

unit/util/expr_cast/expr_cast.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/// \file
66
/// expr_dynamic_cast Unit Tests
77

8-
#include <catch.hpp>
8+
#include <testing-utils/catch.hpp>
99
#include <util/std_expr.h>
1010
#include <util/std_code.h>
1111
#include <util/std_types.h>

unit/util/expr_iterator.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
\*******************************************************************/
88

9-
#include <catch.hpp>
9+
#include <testing-utils/catch.hpp>
1010
#include <util/expr.h>
1111
#include <util/expr_iterator.h>
1212

unit/util/optional.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
\*******************************************************************/
88

9-
#include "catch.hpp"
9+
#include <testing-utils/catch.hpp>
1010
#include <util/optional.h>
1111

1212
TEST_CASE("Optional without a value", "[core][util][optional]")

unit/util/simplify_expr.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
\*******************************************************************/
88

9-
#include <catch.hpp>
9+
#include <testing-utils/catch.hpp>
1010

1111
#include <java_bytecode/java_types.h>
1212
#include <util/arith_tools.h>

0 commit comments

Comments
 (0)