remove a compilation warnings for libtest and test3
[tinycc.git] / tests / CMakeLists.txt
blobcf5caf8f9679341c6d12148633e87a6e629689d3
1 include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
3 set(TCC_CFLAGS -I${CMAKE_SOURCE_DIR} -I${CMAKE_SOURCE_DIR}/include -B${CMAKE_BINARY_DIR})
4 if(WIN32)
5   set(TCC_CFLAGS ${TCC_CFLAGS} -I${CMAKE_SOURCE_DIR}/win32/include)
6 else()
7   set(TCC_MATH_LDFLAGS -lm)
8   set(LIBTCC_EXTRA_LIBS dl)
9   set(LIBTCC_LDFLAGS -ldl -lm -Wl,-rpath=${CMAKE_BINARY_DIR})
10 endif()
12 add_executable(abitest-cc abitest.c)
13 target_link_libraries(abitest-cc libtcc ${LIBTCC_EXTRA_LIBS})
14 add_test(NAME abitest-cc WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND abitest-cc lib_path=${CMAKE_BINARY_DIR} include=${CMAKE_SOURCE_DIR}/include)
16 set(ABITEST_TCC abitest-tcc${CMAKE_EXECUTABLE_SUFFIX})
17 get_property(LIBTCC_LIB TARGET libtcc PROPERTY LOCATION)
18 add_custom_command(OUTPUT ${ABITEST_TCC} COMMAND tcc ${TCC_CFLAGS} -g ${CMAKE_CURRENT_SOURCE_DIR}/abitest.c ${LIBTCC_LDFLAGS} ${LIBTCC_LIB} -o ${ABITEST_TCC} DEPENDS tcc ${CMAKE_CURRENT_SOURCE_DIR}/abitest.c)
19 add_custom_target(abitest-tcc-exe ALL DEPENDS ${ABITEST_TCC})
21 add_test(NAME abitest-tcc WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${ABITEST_TCC} lib_path=${CMAKE_BINARY_DIR} include=${CMAKE_SOURCE_DIR}/include)
23 set(VLA_TEST vla_test${CMAKE_EXECUTABLE_SUFFIX})
24 add_custom_command(OUTPUT ${VLA_TEST} COMMAND tcc ${TCC_CFLAGS} -g ${CMAKE_CURRENT_SOURCE_DIR}/vla_test.c -o ${VLA_TEST} DEPENDS tcc ${CMAKE_CURRENT_SOURCE_DIR}/vla_test.c)
25 add_custom_target(vla_test-exe ALL DEPENDS ${VLA_TEST})
26 add_test(vla_test vla_test)
28 add_executable(tcctest-cc tcctest.c)
29 target_link_libraries(tcctest-cc libtcc)
30 set_target_properties(tcctest-cc PROPERTIES COMPILE_FLAGS -std=gnu99)
32 find_package(PythonInterp)
33 if(PYTHONINTERP_FOUND)
34   set(TCC_TEST_CFLAGS ${TCC_CFLAGS} -B${CMAKE_BINARY_DIR} -I${CMAKE_BINARY_DIR})
35   if(WIN32)
36     set(TCC_TEST_CFLAGS ${TCC_TEST_CFLAGS} -I${CMAKE_SOURCE_DIR}/win32/include/winapi)
37   endif()
38   set(TCC_TEST_SOURCE ${TCC_TEST_CFLAGS} ${TCC_MATH_LDFLAGS} -run ${CMAKE_CURRENT_SOURCE_DIR}/tcctest.c)
39   set(TCC_TEST_RUN ${TCC_TEST_CFLAGS} ${TCC_NATIVE_FLAGS} -DONE_SOURCE -run ${CMAKE_SOURCE_DIR}/tcc.c)
40   get_property(TCC TARGET tcc PROPERTY LOCATION)
41   get_property(TCCTESTCC TARGET tcctest-cc PROPERTY LOCATION)
42   set(TCCTEST_PY ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tcctest.py ${TCCTESTCC})
43   add_test(test1 ${TCCTEST_PY} ${TCC} ${TCC_TEST_SOURCE})
44   add_test(test2 ${TCCTEST_PY} ${TCC} ${TCC_TEST_RUN} ${TCC_TEST_SOURCE})
45   add_test(test3 ${TCCTEST_PY} ${TCC} ${TCC_TEST_RUN} ${TCC_TEST_RUN} ${TCC_TEST_SOURCE})
47   # Object + link output
48   set(TEST4 test4${CMAKE_EXECUTABLE_SUFFIX})
49   add_custom_command(OUTPUT test4.o COMMAND tcc ${TCC_TEST_CFLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/tcctest.c -c -o test4.o DEPENDS tcc ${CMAKE_CURRENT_SOURCE_DIR}/tcctest.c)
50   add_custom_command(OUTPUT ${TEST4} COMMAND tcc ${TCC_TEST_CFLAGS} test4.o -o ${TEST4} DEPENDS tcc test4.o)
51   add_custom_target(test4-exe ALL DEPENDS ${TEST4})
52   add_test(test4 ${TCCTEST_PY} ${CMAKE_CURRENT_BINARY_DIR}/${TEST4})
54   # Dynamic output
55   set(TEST5 test5${CMAKE_EXECUTABLE_SUFFIX})
56   add_custom_command(OUTPUT ${TEST5} COMMAND tcc ${TCC_TEST_CFLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/tcctest.c -o ${TEST5} DEPENDS tcc ${CMAKE_CURRENT_SOURCE_DIR}/tcctest.c)
57   add_custom_target(test5-exe ALL DEPENDS ${TEST5})
58   add_test(test5 ${TCCTEST_PY} ${CMAKE_CURRENT_BINARY_DIR}/${TEST5})
60   if(TCC_BCHECK)
61     # Dynamic output + bound check
62     set(TEST6 test6${CMAKE_EXECUTABLE_SUFFIX})
63     add_custom_command(OUTPUT ${TEST6} COMMAND tcc ${TCC_TEST_CFLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/tcctest.c -b -o ${TEST6} DEPENDS tcc ${CMAKE_CURRENT_SOURCE_DIR}/tcctest.c)
64     add_custom_target(test6-exe ALL DEPENDS ${TEST6})
65     add_test(test6 ${TCCTEST_PY} ${CMAKE_CURRENT_BINARY_DIR}/${TEST6})
66   endif()
68   if(0)
69     # Static output
70     set(TEST7 test7${CMAKE_EXECUTABLE_SUFFIX})
71     add_custom_command(OUTPUT ${TEST7} COMMAND tcc ${TCC_TEST_CFLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/tcctest.c -static -o ${TEST7} DEPENDS tcc ${CMAKE_CURRENT_SOURCE_DIR}/tcctest.c)
72     add_custom_target(test7-exe ALL DEPENDS ${TEST7})
73     add_test(test7 ${TCCTEST_PY} ${CMAKE_CURRENT_BINARY_DIR}/${TEST7})
74   endif()
75 endif()
77 set(MORETESTS
78  00_assignment
79  01_comment
80  02_printf
81  03_struct
82  04_for
83  05_array
84  06_case
85  07_function
86  08_while
87  09_do_while
88  10_pointer
89  11_precedence
90  12_hashdefine
91  13_integer_literals
92  14_if
93  15_recursion
94  16_nesting
95  17_enum
96  18_include
97  19_pointer_arithmetic
98  20_pointer_comparison
99  21_char_array
100  22_floating_point
101  23_type_coercion
102  24_math_library
103  25_quicksort
104  26_character_constants
105  27_sizeof
106  28_strings
107  29_array_address
108  31_args
109  32_led
110  33_ternary_op
111  35_sizeof
112  36_array_initialisers
113  37_sprintf
114  38_multiple_array_index
115  39_typedef
116  40_stdio
117  41_hashif
118  42_function_pointer
119  43_void_param
120  44_scoped_declarations
121  45_empty_for
122  47_switch_return
123  48_nested_break
124  49_bracket_evaluation
125  50_logical_second_arg
126  51_static
127  52_unnamed_enum
128  54_goto
129  55_lshift_type
131 if(WIN32)
132   list(REMOVE_ITEM MORETESTS 24_math_library)
133   list(REMOVE_ITEM MORETESTS 28_strings)
134 endif()
135 foreach(testfile ${MORETESTS})
136   add_test(NAME ${testfile} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests2
137            COMMAND tcc ${TCC_CFLAGS} ${TCC_MATH_LDFLAGS} -run ${testfile}.c - arg1 arg2 arg3 arg4 | ${DIFF} - ${testfile}.expect)
138 endforeach()