Skip to content

Commit b6742ca

Browse files
Move Java unit tests
1 parent e247458 commit b6742ca

File tree

336 files changed

+281
-111
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

336 files changed

+281
-111
lines changed

jbmc/unit/CMakeLists.txt

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
file(GLOB_RECURSE sources "*.cpp" "*.h")
2+
list(APPEND sources ${CBMC_SOURCE_DIR}/../unit/unit_tests.cpp)
3+
4+
file(GLOB_RECURSE java-testing_utils "java-testing-utils/*.cpp" "java-testing-utils/*.h")
5+
6+
list(REMOVE_ITEM sources
7+
# Don't build
8+
${CMAKE_CURRENT_SOURCE_DIR}/sharing_map.cpp
9+
${CMAKE_CURRENT_SOURCE_DIR}/elf_reader.cpp
10+
${CMAKE_CURRENT_SOURCE_DIR}/smt2_parser.cpp
11+
${CMAKE_CURRENT_SOURCE_DIR}/json.cpp
12+
${CMAKE_CURRENT_SOURCE_DIR}/cpp_parser.cpp
13+
${CMAKE_CURRENT_SOURCE_DIR}/osx_fat_reader.cpp
14+
${CMAKE_CURRENT_SOURCE_DIR}/unicode.cpp
15+
${CMAKE_CURRENT_SOURCE_DIR}/wp.cpp
16+
${CMAKE_CURRENT_SOURCE_DIR}/cpp_scanner.cpp
17+
${CMAKE_CURRENT_SOURCE_DIR}/float_utils.cpp
18+
${CMAKE_CURRENT_SOURCE_DIR}/ieee_float.cpp
19+
20+
# Will be built into a separate library and linked
21+
${java-testing_utils}
22+
23+
# Intended to fail to compile
24+
${CMAKE_CURRENT_SOURCE_DIR}/util/expr_cast/expr_undefined_casts.cpp
25+
)
26+
27+
add_subdirectory(java-testing-utils)
28+
29+
add_executable(java-unit ${sources})
30+
target_include_directories(java-unit
31+
PUBLIC
32+
${CBMC_BINARY_DIR}
33+
${CBMC_SOURCE_DIR}
34+
${CBMC_SOURCE_DIR}/../unit
35+
${CMAKE_CURRENT_SOURCE_DIR}
36+
)
37+
target_link_libraries(java-unit
38+
java-testing-utils
39+
testing-utils
40+
ansi-c
41+
solvers
42+
goto-programs
43+
goto-instrument-lib
44+
cbmc-lib
45+
)
46+
47+
add_test(
48+
NAME java-unit
49+
COMMAND $<TARGET_FILE:java-unit>
50+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
51+
)
52+
set_tests_properties(java-unit PROPERTIES LABELS "CORE;CBMC")

jbmc/unit/Makefile

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
.PHONY: all cprover.dir jprover.dir testing-utils.dir java-testing-utils.dir test
2+
3+
# Source files for test utilities
4+
SRC = $(CPROVER_DIR)/unit/unit_tests.cpp \
5+
# Empty last line
6+
7+
# Test source files
8+
SRC += java_bytecode/goto-programs/class_hierarchy_output.cpp \
9+
java_bytecode/goto-programs/class_hierarchy_graph.cpp \
10+
java_bytecode/goto-programs/remove_virtual_functions_without_fallback.cpp \
11+
java_bytecode/java_bytecode_convert_class/convert_abstract_class.cpp \
12+
java_bytecode/java_bytecode_convert_method/convert_invoke_dynamic.cpp \
13+
java_bytecode/java_bytecode_parse_generics/parse_generic_class.cpp \
14+
java_bytecode/java_object_factory/gen_nondet_string_init.cpp \
15+
java_bytecode/java_bytecode_parse_lambdas/java_bytecode_parse_lambda_method_table.cpp \
16+
java_bytecode/java_bytecode_parse_lambdas/java_bytecode_convert_class_lambda_method_handles.cpp \
17+
java_bytecode/java_string_library_preprocess/convert_exprt_to_string_exprt.cpp \
18+
java_bytecode/java_types/erase_type_arguments.cpp \
19+
java_bytecode/java_types/generic_type_index.cpp \
20+
java_bytecode/java_types/java_generic_symbol_type.cpp \
21+
java_bytecode/java_types/java_type_from_string.cpp \
22+
java_bytecode/java_utils_test.cpp \
23+
java_bytecode/inherited_static_fields/inherited_static_fields.cpp \
24+
pointer-analysis/custom_value_set_analysis.cpp \
25+
solvers/refinement/string_constraint_instantiation/instantiate_not_contains.cpp \
26+
solvers/refinement/string_refinement/dependency_graph.cpp \
27+
solvers/refinement/string_refinement/string_symbol_resolution.cpp \
28+
util/expr_iterator.cpp \
29+
util/has_subtype.cpp \
30+
util/parameter_indices.cpp \
31+
util/simplify_expr.cpp \
32+
java_bytecode/java_virtual_functions/virtual_functions.cpp \
33+
java_bytecode/java_bytecode_parse_generics/parse_generic_superclasses.cpp \
34+
# Empty last line
35+
36+
INCLUDES= -I ../src/ -I. -I $(CPROVER_DIR)/src -I $(CPROVER_DIR)/unit
37+
38+
include ../src/config.inc
39+
include $(CPROVER_DIR)/src/config.inc
40+
include $(CPROVER_DIR)/src/common
41+
42+
cprover.dir:
43+
$(MAKE) $(MAKEARGS) -C $(CPROVER_DIR)/src
44+
45+
jprover.dir:
46+
$(MAKE) $(MAKEARGS) -C ../src
47+
48+
cprover-testing-utils.dir:
49+
$(MAKE) $(MAKEARGS) -C $(CPROVER_DIR)/unit/testing-utils
50+
51+
java-testing-utils.dir:
52+
$(MAKE) $(MAKEARGS) -C java-testing-utils
53+
54+
# We need to link bmc.o to the unit test, so here's everything it depends on...
55+
BMC_DEPS =$(CPROVER_DIR)/src/cbmc/all_properties$(OBJEXT) \
56+
$(CPROVER_DIR)/src/cbmc/bmc$(OBJEXT) \
57+
$(CPROVER_DIR)/src/cbmc/bmc_cover$(OBJEXT) \
58+
$(CPROVER_DIR)/src/cbmc/bv_cbmc$(OBJEXT) \
59+
$(CPROVER_DIR)/src/cbmc/cbmc_dimacs$(OBJEXT) \
60+
$(CPROVER_DIR)/src/cbmc/cbmc_languages$(OBJEXT) \
61+
$(CPROVER_DIR)/src/cbmc/cbmc_parse_options$(OBJEXT) \
62+
$(CPROVER_DIR)/src/cbmc/cbmc_solvers$(OBJEXT) \
63+
$(CPROVER_DIR)/src/cbmc/counterexample_beautification$(OBJEXT) \
64+
$(CPROVER_DIR)/src/cbmc/fault_localization$(OBJEXT) \
65+
$(CPROVER_DIR)/src/cbmc/show_vcc$(OBJEXT) \
66+
$(CPROVER_DIR)/src/cbmc/symex_bmc$(OBJEXT) \
67+
$(CPROVER_DIR)/src/cbmc/symex_coverage$(OBJEXT) \
68+
$(CPROVER_DIR)/src/cbmc/xml_interface$(OBJEXT) \
69+
$(CPROVER_DIR)/src/jsil/expr2jsil$(OBJEXT) \
70+
$(CPROVER_DIR)/src/jsil/jsil_convert$(OBJEXT) \
71+
$(CPROVER_DIR)/src/jsil/jsil_entry_point$(OBJEXT) \
72+
$(CPROVER_DIR)/src/jsil/jsil_internal_additions$(OBJEXT) \
73+
$(CPROVER_DIR)/src/jsil/jsil_language$(OBJEXT) \
74+
$(CPROVER_DIR)/src/jsil/jsil_lex.yy$(OBJEXT) \
75+
$(CPROVER_DIR)/src/jsil/jsil_parser$(OBJEXT) \
76+
$(CPROVER_DIR)/src/jsil/jsil_parse_tree$(OBJEXT) \
77+
$(CPROVER_DIR)/src/jsil/jsil_typecheck$(OBJEXT) \
78+
$(CPROVER_DIR)/src/jsil/jsil_types$(OBJEXT) \
79+
$(CPROVER_DIR)/src/jsil/jsil_y.tab$(OBJEXT) \
80+
# Empty last line
81+
82+
CPROVER_LIBS =../src/java_bytecode/java_bytecode$(LIBEXT) \
83+
../src/miniz/miniz$(OBJEXT) \
84+
$(CPROVER_DIR)/src/ansi-c/ansi-c$(LIBEXT) \
85+
$(CPROVER_DIR)/src/cpp/cpp$(LIBEXT) \
86+
$(CPROVER_DIR)/src/json/json$(LIBEXT) \
87+
$(CPROVER_DIR)/src/linking/linking$(LIBEXT) \
88+
$(CPROVER_DIR)/src/util/util$(LIBEXT) \
89+
$(CPROVER_DIR)/src/big-int/big-int$(LIBEXT) \
90+
$(CPROVER_DIR)/src/goto-programs/goto-programs$(LIBEXT) \
91+
$(CPROVER_DIR)/src/goto-instrument/goto-instrument$(LIBEXT) \
92+
$(CPROVER_DIR)/src/pointer-analysis/pointer-analysis$(LIBEXT) \
93+
$(CPROVER_DIR)/src/langapi/langapi$(LIBEXT) \
94+
$(CPROVER_DIR)/src/assembler/assembler$(LIBEXT) \
95+
$(CPROVER_DIR)/src/analyses/analyses$(LIBEXT) \
96+
$(CPROVER_DIR)/src/solvers/solvers$(LIBEXT) \
97+
$(BMC_DEPS) \
98+
# Empty last line
99+
100+
OBJ += $(CPROVER_LIBS) \
101+
$(CPROVER_DIR)/unit/testing-utils/testing-utils$(LIBEXT) \
102+
java-testing-utils/java-testing-utils$(LIBEXT)
103+
104+
TESTS = unit_tests$(EXEEXT) \
105+
# Empty last line
106+
107+
CLEANFILES = $(TESTS)
108+
109+
all: cprover.dir cprover-testing-utils.dir jprover.dir java-testing-utils.dir
110+
$(MAKE) $(MAKEARGS) $(TESTS)
111+
112+
test: all
113+
$(foreach test,$(TESTS), (echo Running: $(test); ./$(test)) &&) true
114+
115+
116+
###############################################################################
117+
118+
unit_tests$(EXEEXT): $(OBJ)
119+
$(LINKBIN)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
file(GLOB_RECURSE sources "*.cpp" "*.h")
2+
add_library(java-testing-utils ${sources})
3+
target_link_libraries(java-testing-utils
4+
util
5+
java_bytecode
6+
)
7+
target_include_directories(java-testing-utils
8+
PUBLIC
9+
${CMAKE_CURRENT_SOURCE_DIR}/..
10+
${CBMC_SOURCE_DIR}/../unit
11+
)

jbmc/unit/java-testing-utils/Makefile

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

unit/testing-utils/load_java_class.cpp renamed to jbmc/unit/java-testing-utils/load_java_class.cpp

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

99
#include "load_java_class.h"
10-
#include "free_form_cmdline.h"
10+
11+
#include <testing-utils/free_form_cmdline.h>
1112
#include <testing-utils/catch.hpp>
1213
#include <iostream>
1314

unit/testing-utils/require_goto_statements.cpp renamed to jbmc/unit/java-testing-utils/require_goto_statements.cpp

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

99
#include "require_goto_statements.h"
10-
#include "catch.hpp"
10+
11+
#include <testing-utils/catch.hpp>
1112

1213
#include <algorithm>
1314
#include <util/expr_iterator.h>

unit/testing-utils/require_parse_tree.h renamed to jbmc/unit/java-testing-utils/require_parse_tree.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
#define CPROVER_JAVA_TESTING_UTILS_REQUIRE_PARSE_TREE_H
1414

1515
#include <java_bytecode/java_bytecode_parse_tree.h>
16-
#include "catch.hpp"
16+
17+
#include <testing-utils/catch.hpp>
1718

1819
// NOLINTNEXTLINE(readability/namespace)
1920
namespace require_parse_tree

unit/java_bytecode/ci_lazy_methods/lazy_load_lambdas.cpp renamed to jbmc/unit/java_bytecode/ci_lazy_methods/lazy_load_lambdas.cpp

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

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

1313
SCENARIO(

unit/goto-programs/class_hierarchy_graph.cpp renamed to jbmc/unit/java_bytecode/goto-programs/class_hierarchy_graph.cpp

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

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

1212
#include <goto-programs/class_hierarchy.h>
1313

@@ -31,7 +31,7 @@ SCENARIO(
3131
"[core][goto-programs][class_hierarchy_graph]")
3232
{
3333
symbol_tablet symbol_table =
34-
load_java_class("HierarchyTest", "goto-programs/");
34+
load_java_class("HierarchyTest", "./java_bytecode/goto-programs/");
3535
class_hierarchy_grapht hierarchy;
3636
hierarchy.populate(symbol_table);
3737

unit/goto-programs/class_hierarchy_output.cpp renamed to jbmc/unit/java_bytecode/goto-programs/class_hierarchy_output.cpp

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

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

1212
#include <goto-programs/class_hierarchy.h>
1313

@@ -40,7 +40,7 @@ SCENARIO(
4040
"[core][goto-programs][class_hierarchy]")
4141
{
4242
symbol_tablet symbol_table =
43-
load_java_class("HierarchyTest", "goto-programs/");
43+
load_java_class("HierarchyTest", "./java_bytecode/goto-programs/");
4444
class_hierarchyt hierarchy;
4545

4646
std::stringstream output_stream;

unit/goto-programs/remove_virtual_functions_without_fallback.cpp renamed to jbmc/unit/java_bytecode/goto-programs/remove_virtual_functions_without_fallback.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
\*******************************************************************/
99

1010
#include <testing-utils/catch.hpp>
11-
#include <testing-utils/load_java_class.h>
11+
#include <java-testing-utils/load_java_class.h>
1212

1313
#include <util/simplify_expr.h>
1414
#include <goto-programs/remove_virtual_functions.h>
@@ -114,8 +114,8 @@ SCENARIO(
114114
"Remove virtual functions without a fallback function",
115115
"[core][goto-programs][remove_virtual_functions]")
116116
{
117-
symbol_tablet symbol_table =
118-
load_java_class("VirtualFunctionsTestParent", "goto-programs/");
117+
symbol_tablet symbol_table = load_java_class(
118+
"VirtualFunctionsTestParent", "./java_bytecode/goto-programs/");
119119
namespacet ns(symbol_table);
120120

121121
goto_programt test_program;

unit/goto-programs/goto_program_generics/generic_bases_test.cpp renamed to jbmc/unit/java_bytecode/goto_program_generics/generic_bases_test.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
77
\*******************************************************************/
88
#include <testing-utils/catch.hpp>
9-
#include <testing-utils/load_java_class.h>
10-
#include <testing-utils/require_goto_statements.h>
9+
#include <java-testing-utils/load_java_class.h>
10+
#include <java-testing-utils/require_goto_statements.h>
1111
#include <util/config.h>
12-
#include <testing-utils/require_type.h>
12+
#include <java-testing-utils/require_type.h>
1313
#include <testing-utils/require_symbol.h>
1414

1515
// NOTE: To inspect these tests at any point, use expr2java.
@@ -27,7 +27,7 @@ SCENARIO(
2727
{
2828
const symbol_tablet &symbol_table = load_java_class(
2929
"SuperclassInst",
30-
"./goto-programs/goto_program_generics",
30+
"./java_bytecode/goto_program_generics",
3131
"SuperclassInst.foo");
3232

3333
WHEN("The method input argument is created in the entry point function")
@@ -68,7 +68,7 @@ SCENARIO(
6868
{
6969
const symbol_tablet &symbol_table = load_java_class(
7070
"SuperclassInst2",
71-
"./goto-programs/goto_program_generics",
71+
"./java_bytecode/goto_program_generics",
7272
"SuperclassInst2.foo");
7373

7474
WHEN("The method input argument is created in the entry point function")
@@ -99,7 +99,7 @@ SCENARIO(
9999
{
100100
const symbol_tablet &symbol_table = load_java_class(
101101
"SuperclassInst3",
102-
"./goto-programs/goto_program_generics",
102+
"./java_bytecode/goto_program_generics",
103103
"SuperclassInst3.foo");
104104

105105
WHEN("The method input argument is created in the entry point function")
@@ -142,7 +142,7 @@ SCENARIO(
142142
{
143143
const symbol_tablet &symbol_table = load_java_class(
144144
"SuperclassUninstTest",
145-
"./goto-programs/goto_program_generics",
145+
"./java_bytecode/goto_program_generics",
146146
"SuperclassUninstTest.foo");
147147

148148
WHEN("The method input argument is created in the entry point function")
@@ -187,7 +187,7 @@ SCENARIO(
187187
{
188188
const symbol_tablet &symbol_table = load_java_class(
189189
"SuperclassMixedTest",
190-
"./goto-programs/goto_program_generics",
190+
"./java_bytecode/goto_program_generics",
191191
"SuperclassMixedTest.foo");
192192

193193
WHEN("The method input argument is created in the entry point function")
@@ -240,7 +240,7 @@ SCENARIO(
240240
{
241241
const symbol_tablet &symbol_table = load_java_class(
242242
"SuperclassInnerInst",
243-
"./goto-programs/goto_program_generics",
243+
"./java_bytecode/goto_program_generics",
244244
"SuperclassInnerInst.foo");
245245

246246
WHEN("The method input argument is created in the entry point function")
@@ -309,7 +309,7 @@ SCENARIO(
309309
{
310310
const symbol_tablet &symbol_table = load_java_class(
311311
"SuperclassInnerUninstTest",
312-
"./goto-programs/goto_program_generics",
312+
"./java_bytecode/goto_program_generics",
313313
"SuperclassInnerUninstTest.foo");
314314

315315
WHEN("The method input argument is created in the entry point function")
@@ -425,7 +425,7 @@ SCENARIO(
425425
{
426426
const symbol_tablet &symbol_table = load_java_class(
427427
"SuperclassUnsupported",
428-
"./goto-programs/goto_program_generics",
428+
"./java_bytecode/goto_program_generics",
429429
"SuperclassUnsupported.foo");
430430

431431
THEN("The struct for UnsupportedWrapper1 is complete and non-generic")
@@ -474,7 +474,7 @@ SCENARIO(
474474
{
475475
const symbol_tablet &symbol_table = load_java_class(
476476
"SuperclassOpaque",
477-
"./goto-programs/goto_program_generics",
477+
"./java_bytecode/goto_program_generics",
478478
"SuperclassOpaque.foo");
479479

480480
THEN("The struct for OpaqueWrapper is incomplete and not-generic")

0 commit comments

Comments
 (0)