From e424667f472a2dcdaf29cfef7f1409cb0644e3de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwena=C3=ABl=20Delaval?= Date: Mon, 16 Jul 2012 01:03:37 +0200 Subject: [PATCH] Tests with ctest Configuration files and scripts to perform tests with ctest - ctest can be run into the test directory or the root - the script CTestScript.cmake allows ctest to perform the whole sequence update/configure/build/test and submit the result to cdash (http://cdash.inria.fr/CDash/index.php?project=Heptagon) - gen_ctests is used to generate the file test/CTestTestfile.cmake --- CTestConfig.cmake | 6 ++ CTestScript.cmake | 140 +++++++++++++++++++++++++++ CTestTestfile.cmake | 1 + test/CTestTestfile.cmake | 177 +++++++++++++++++++++++++++++++++++ test/gen_ctests | 19 ++++ test/scripts/compile_fail | 42 +++++++++ test/scripts/compile_gcc_run | 93 ++++++++++++++++++ test/scripts/compile_only | 34 +++++++ 8 files changed, 512 insertions(+) create mode 100644 CTestConfig.cmake create mode 100644 CTestScript.cmake create mode 100644 CTestTestfile.cmake create mode 100644 test/CTestTestfile.cmake create mode 100755 test/gen_ctests create mode 100755 test/scripts/compile_fail create mode 100755 test/scripts/compile_gcc_run create mode 100755 test/scripts/compile_only diff --git a/CTestConfig.cmake b/CTestConfig.cmake new file mode 100644 index 0000000..7f6dae7 --- /dev/null +++ b/CTestConfig.cmake @@ -0,0 +1,6 @@ +SET(CTEST_PROJECT_NAME "Heptagon") +SET(CTEST_NIGHTLY_START_TIME "20:00:00 EST") +SET(CTEST_DROP_METHOD "http") +SET(CTEST_DROP_SITE "cdash.inria.fr") +SET(CTEST_DROP_LOCATION "/CDash/submit.php?project=Heptagon") +SET(CTEST_DROP_SITE_CDASH TRUE) diff --git a/CTestScript.cmake b/CTestScript.cmake new file mode 100644 index 0000000..d7d41c2 --- /dev/null +++ b/CTestScript.cmake @@ -0,0 +1,140 @@ +# ----------------------------------------------------------- +# -- Get environment +# ----------------------------------------------------------- + +## -- Set hostname +## -------------------------- +find_program(HOSTNAME_CMD NAMES hostname) +exec_program(${HOSTNAME_CMD} ARGS OUTPUT_VARIABLE HOSTNAME) + +set(CTEST_SITE "${HOSTNAME}") + +## -- Set site / build name +## -------------------------- + +find_program(UNAME NAMES uname) +macro(getuname name flag) + exec_program("${UNAME}" ARGS "${flag}" OUTPUT_VARIABLE "${name}") +endmacro(getuname) + +getuname(osname -s) +getuname(osrel -r) +getuname(cpu -m) + +set(CTEST_BUILD_NAME "${osname}-${cpu}-prod") + +## -- SVN command +## ---------------- +find_program(CTEST_GIT_COMMAND NAMES git) + +## -- make command +## ----------------- +find_program(MAKE NAMES make) + +# ----------------------------------------------------------- +# -- build specific +# ----------------------------------------------------------- + +set(MODEL "Experimental") + +## -- DashBoard Root +set(CTEST_DASHBOARD_ROOT "$ENV{HOME}/automatedBuild") + +## -- SRC Dir +#set(CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}/src") +find_program(PWD_CMD NAMES pwd) +exec_program(${PWD_CMD} ARGS OUTPUT_VARIABLE CTEST_SOURCE_DIRECTORY) + + +## -- BIN Dir +set(CTEST_BINARY_DIRECTORY "${CTEST_SOURCE_DIRECTORY}/build-${CTEST_BUILD_NAME}") + +## -- Build options +#set(OPTION_BUILD "-j16") + +# ----------------------------------------------------------- +# -- commands +# ----------------------------------------------------------- + +## -- Checkout command +if(NOT EXISTS "${CTEST_SOURCE_DIRECTORY}") + set(CTEST_CHECKOUT_COMMAND "${CTEST_GIT_COMMAND} clone git+ssh://scm.gforge.inria.fr//gitroot/heptagon/heptagon.git ${CTEST_SOURCE_DIRECTORY}; ${CTEST_GIT_COMMAND} checkout decade") +endif(NOT EXISTS "${CTEST_SOURCE_DIRECTORY}") + +## -- Update Command +set(CTEST_UPDATE_COMMAND "${CTEST_GIT_COMMAND}") + +## -- Configure Command +set(CTEST_CONFIGURE_COMMAND "${CTEST_SOURCE_DIRECTORY}/configure") + +## -- Build Command +set(CTEST_BUILD_COMMAND "${MAKE} ${OPTION_BUILD}") + +# ----------------------------------------------------------- +# -- Configure CTest +# ----------------------------------------------------------- + +## -- CTest Config +#configure_file($ENV{HOME}/CTestConfiguration/CTestConfig.cmake ${CTEST_SOURCE_DIRECTORY}/CTestConfig.cmake) + +## -- CTest Custom +#configure_file($ENV{HOME}/CTestConfiguration/CTestCustom.cmake ${CTEST_BINARY_DIRECTORY}/CTestCustom.cmake) + +## -- CTest Testfile +#configure_file($ENV{HOME}/CTestConfiguration/CTestTestfile.cmake ${CTEST_BINARY_DIRECTORY}/CTestTestfile.cmake) + +## -- read CTestCustom.cmake file +#ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}") + +# ----------------------------------------------------------- +# -- Settings +# ----------------------------------------------------------- + +## -- Process timeout in seconds +set(CTEST_TIMEOUT "7200") + +## -- Set output to english +set( $ENV{LC_MESSAGES} "en_EN" ) + +# ----------------------------------------------------------- +# -- Run CTest +# ----------------------------------------------------------- + +## -- Start +message(" -- Start dashboard ${MODEL} - ${CTEST_BUILD_NAME} --") +ctest_start(${MODEL} TRACK ${MODEL}) + +## -- Update +message(" -- Update ${MODEL} - ${CTEST_BUILD_NAME} --") +ctest_update( SOURCE "${CTEST_SOURCE_DIRECTORY}" RETURN_VALUE res) + +## -- Run autoreconf +# message(" -- Autoreconf ${MODEL} - ${CTEST_BUILD_NAME} --") +# execute_process(COMMAND "/usr/bin/autoreconf" "-f" "-i" WORKING_DIRECTORY ${CTEST_SOURCE_DIRECTORY} RESULT_VARIABLE autoreconfResult +# OUTPUT_VARIABLE autoreconfLog ERROR_VARIABLE autoreconfLog) +# file(WRITE ${CTEST_BINARY_DIRECTORY}/Testing/autoreconf.log "${autoreconfLog}") + +## -- Configure +message(" -- Configure ${MODEL} - ${CTEST_BUILD_NAME} --") +ctest_configure(BUILD "${CSET_SOURCE_DIRECTORY}" RETURN_VALUE res) + +## -- BUILD +message(" -- Build ${MODEL} - ${CTEST_BUILD_NAME} --") +ctest_build( BUILD "${CTEST_SOURCE_DIRECTORY}" RETURN_VALUE res) + +## -- INSTALL +# message(" -- Install ${MODEL} - ${CTEST_BUILD_NAME} --") +# execute_process(COMMAND "${MAKE} install ${OPTION_BUILD}" WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} +# RESULT_VARIABLE makeInstallResult OUTPUT_VARIABLE makeInstallLog ERROR_VARIABLE makeInstallLog) +# file(WRITE ${CTEST_BINARY_DIRECTORY}/Testing/makeinstall.log "${makeInstallLog}") + +## -- TEST +message(" -- Test ${MODEL} - ${CTEST_BUILD_NAME} --") +ctest_test( BUILD "${CTEST_SOURCE_DIRECTORY}" RETURN_VALUE res) + + +## -- SUBMIT +message(" -- Submit ${MODEL} - ${CTEST_BUILD_NAME} --") +ctest_submit( RETURN_VALUE res) + +message(" -- Finished ${MODEL} - ${CTEST_BUILD_NAME} --") diff --git a/CTestTestfile.cmake b/CTestTestfile.cmake new file mode 100644 index 0000000..522bf8e --- /dev/null +++ b/CTestTestfile.cmake @@ -0,0 +1 @@ +SUBDIRS(test) diff --git a/test/CTestTestfile.cmake b/test/CTestTestfile.cmake new file mode 100644 index 0000000..4709c7e --- /dev/null +++ b/test/CTestTestfile.cmake @@ -0,0 +1,177 @@ +ADD_TEST(compile_fail_bad_array_power "scripts/compile_fail" "bad/bad_array_power.ept" "-memalloc") +ADD_TEST(compile_fail_bad_flatten "scripts/compile_fail" "bad/bad_flatten.ept" "-memalloc") +ADD_TEST(compile_fail_bad_merge1 "scripts/compile_fail" "bad/bad_merge1.ept" "-memalloc") +ADD_TEST(compile_fail_bad_merge2 "scripts/compile_fail" "bad/bad_merge2.ept" "-memalloc") +ADD_TEST(compile_fail_bad_merge3 "scripts/compile_fail" "bad/bad_merge3.ept" "-memalloc") +ADD_TEST(compile_fail_bad_param_ident "scripts/compile_fail" "bad/bad_param_ident.ept" "-memalloc") +ADD_TEST(compile_fail_causality "scripts/compile_fail" "bad/causality.ept" "-memalloc") +ADD_TEST(compile_fail_clock_annot "scripts/compile_fail" "bad/clock_annot.ept" "-memalloc") +ADD_TEST(compile_fail_clock_causality "scripts/compile_fail" "bad/clock_causality.ept" "-memalloc") +ADD_TEST(compile_fail_clock_dep "scripts/compile_fail" "bad/clock_dep.ept" "-memalloc") +ADD_TEST(compile_fail_clocking "scripts/compile_fail" "bad/clocking.ept" "-memalloc") +ADD_TEST(compile_fail_flatten "scripts/compile_fail" "bad/flatten.ept" "-memalloc") +ADD_TEST(compile_fail_linear_acc "scripts/compile_fail" "bad/linear_acc.ept" "-memalloc") +ADD_TEST(compile_fail_linear_autom "scripts/compile_fail" "bad/linear_autom.ept" "-memalloc") +ADD_TEST(compile_fail_linear_causality "scripts/compile_fail" "bad/linear_causality.ept" "-memalloc") +ADD_TEST(compile_fail_linear_fun "scripts/compile_fail" "bad/linear_fun.ept" "-memalloc") +ADD_TEST(compile_fail_linear_init "scripts/compile_fail" "bad/linear_init.ept" "-memalloc") +ADD_TEST(compile_fail_linear_map "scripts/compile_fail" "bad/linear_map.ept" "-memalloc") +ADD_TEST(compile_fail_linear_mapfold "scripts/compile_fail" "bad/linear_mapfold.ept" "-memalloc") +ADD_TEST(compile_fail_t10-initialization "scripts/compile_fail" "bad/t10-initialization.ept" "-memalloc") +ADD_TEST(compile_fail_t11-initialization "scripts/compile_fail" "bad/t11-initialization.ept" "-memalloc") +ADD_TEST(compile_fail_t1 "scripts/compile_fail" "bad/t1.ept" "-memalloc") +ADD_TEST(compile_fail_t2 "scripts/compile_fail" "bad/t2.ept" "-memalloc") +ADD_TEST(compile_fail_t3 "scripts/compile_fail" "bad/t3.ept" "-memalloc") +ADD_TEST(compile_fail_t4 "scripts/compile_fail" "bad/t4.ept" "-memalloc") +ADD_TEST(compile_fail_t5 "scripts/compile_fail" "bad/t5.ept" "-memalloc") +ADD_TEST(compile_fail_t6 "scripts/compile_fail" "bad/t6.ept" "-memalloc") +ADD_TEST(compile_fail_t7 "scripts/compile_fail" "bad/t7.ept" "-memalloc") +ADD_TEST(compile_fail_t8-causality "scripts/compile_fail" "bad/t8-causality.ept" "-memalloc") +ADD_TEST(compile_fail_t9-initialization "scripts/compile_fail" "bad/t9-initialization.ept" "-memalloc") +ADD_TEST(compile_fail_when_merge1 "scripts/compile_fail" "bad/when_merge1.ept" "-memalloc") +ADD_TEST(compile_only_alloc "scripts/compile_only" "good/alloc.ept") +ADD_TEST(compile_only_array1 "scripts/compile_only" "good/array1.ept") +ADD_TEST(compile_only_array2 "scripts/compile_only" "good/array2.ept") +ADD_TEST(compile_only_array_fill "scripts/compile_only" "good/array_fill.ept") +ADD_TEST(compile_only_array_iterators2 "scripts/compile_only" "good/array_iterators2.ept") +ADD_TEST(compile_only_array_iterators "scripts/compile_only" "good/array_iterators.ept") +ADD_TEST(compile_only_array_power "scripts/compile_only" "good/array_power.ept") +ADD_TEST(compile_only_auto2 "scripts/compile_only" "good/auto2.ept") +ADD_TEST(compile_only_auto "scripts/compile_only" "good/auto.ept") +ADD_TEST(compile_only_autohiera2 "scripts/compile_only" "good/autohiera2.ept") +ADD_TEST(compile_only_autohiera "scripts/compile_only" "good/autohiera.ept") +ADD_TEST(compile_only_bad_updown "scripts/compile_only" "good/bad_updown.ept") +ADD_TEST(compile_only_ckannot "scripts/compile_only" "good/ckannot.ept") +ADD_TEST(compile_only_clock_causality "scripts/compile_only" "good/clock_causality.ept") +ADD_TEST(compile_only_clocks "scripts/compile_only" "good/clocks.ept") +ADD_TEST(compile_only_counter "scripts/compile_only" "good/counter.ept") +ADD_TEST(compile_only_current "scripts/compile_only" "good/current.ept") +ADD_TEST(compile_only_fbyfby2 "scripts/compile_only" "good/fbyfby2.ept") +ADD_TEST(compile_only_foldi "scripts/compile_only" "good/foldi.ept") +ADD_TEST(compile_only_format "scripts/compile_only" "good/format.ept") +ADD_TEST(compile_only_grosauto_clock "scripts/compile_only" "good/grosauto_clock.ept") +ADD_TEST(compile_only_hierarchie "scripts/compile_only" "good/hierarchie.ept") +ADD_TEST(compile_only_itfusion "scripts/compile_only" "good/itfusion.ept") +ADD_TEST(compile_only_linear_automata "scripts/compile_only" "good/linear_automata.ept") +ADD_TEST(compile_only_linear "scripts/compile_only" "good/linear.ept") +ADD_TEST(compile_only_linear_init "scripts/compile_only" "good/linear_init.ept") +ADD_TEST(compile_only_linear_split "scripts/compile_only" "good/linear_split.ept") +ADD_TEST(compile_only_linear_vars "scripts/compile_only" "good/linear_vars.ept") +ADD_TEST(compile_only_memalloc_clocks "scripts/compile_only" "good/memalloc_clocks.ept") +ADD_TEST(compile_only_memalloc_record "scripts/compile_only" "good/memalloc_record.ept") +ADD_TEST(compile_only_memalloc_simple "scripts/compile_only" "good/memalloc_simple.ept") +ADD_TEST(compile_only_name_clash "scripts/compile_only" "good/name_clash.ept") +ADD_TEST(compile_only_norm "scripts/compile_only" "good/norm.ept") +ADD_TEST(compile_only_or_keep "scripts/compile_only" "good/or_keep.ept") +ADD_TEST(compile_only_parametrize "scripts/compile_only" "good/parametrize.ept") +ADD_TEST(compile_only_pre_tuple "scripts/compile_only" "good/pre_tuple.ept") +ADD_TEST(compile_only_reinit "scripts/compile_only" "good/reinit.ept") +ADD_TEST(compile_only_sampling_stateful_output2 "scripts/compile_only" "good/sampling_stateful_output2.ept") +ADD_TEST(compile_only_sampling_stateful_output "scripts/compile_only" "good/sampling_stateful_output.ept") +ADD_TEST(compile_only_side_effet "scripts/compile_only" "good/side_effet.ept") +ADD_TEST(compile_only_statics2 "scripts/compile_only" "good/statics2.ept") +ADD_TEST(compile_only_statics "scripts/compile_only" "good/statics.ept") +ADD_TEST(compile_only_t10 "scripts/compile_only" "good/t10.ept") +ADD_TEST(compile_only_t11 "scripts/compile_only" "good/t11.ept") +ADD_TEST(compile_only_t12 "scripts/compile_only" "good/t12.ept") +ADD_TEST(compile_only_t13 "scripts/compile_only" "good/t13.ept") +ADD_TEST(compile_only_t14 "scripts/compile_only" "good/t14.ept") +ADD_TEST(compile_only_t15 "scripts/compile_only" "good/t15.ept") +ADD_TEST(compile_only_t16 "scripts/compile_only" "good/t16.ept") +ADD_TEST(compile_only_t17 "scripts/compile_only" "good/t17.ept") +ADD_TEST(compile_only_t18 "scripts/compile_only" "good/t18.ept") +ADD_TEST(compile_only_t19 "scripts/compile_only" "good/t19.ept") +ADD_TEST(compile_only_t1 "scripts/compile_only" "good/t1.ept") +ADD_TEST(compile_only_t2 "scripts/compile_only" "good/t2.ept") +ADD_TEST(compile_only_t2open "scripts/compile_only" "good/t2open.ept") +ADD_TEST(compile_only_t3 "scripts/compile_only" "good/t3.ept") +ADD_TEST(compile_only_t4 "scripts/compile_only" "good/t4.ept") +ADD_TEST(compile_only_t5 "scripts/compile_only" "good/t5.ept") +ADD_TEST(compile_only_t6 "scripts/compile_only" "good/t6.ept") +ADD_TEST(compile_only_t7 "scripts/compile_only" "good/t7.ept") +ADD_TEST(compile_only_t8 "scripts/compile_only" "good/t8.ept") +ADD_TEST(compile_only_t9 "scripts/compile_only" "good/t9.ept") +ADD_TEST(compile_only_t "scripts/compile_only" "good/t.ept") +ADD_TEST(compile_only_test "scripts/compile_only" "good/test.ept") +ADD_TEST(compile_only_threestates "scripts/compile_only" "good/threestates.ept") +ADD_TEST(compile_only_tt "scripts/compile_only" "good/tt.ept") +ADD_TEST(compile_only_tttt "scripts/compile_only" "good/tttt.ept") +ADD_TEST(compile_only_tuple_args "scripts/compile_only" "good/tuple_args.ept") +ADD_TEST(compile_only_type_alias "scripts/compile_only" "good/type_alias.ept") +ADD_TEST(compile_only_updown "scripts/compile_only" "good/updown.ept") +ADD_TEST(compile_only_when_merge1 "scripts/compile_only" "good/when_merge1.ept") +SET_TEST_PROPERTIES(compile_only_t2 PROPERTIES DEPENDS compiler_only_t1) +SET_TEST_PROPERTIES(compile_only_t2open PROPERTIES DEPENDS compiler_only_t1) +ADD_TEST(compile_gcc_run_alloc "scripts/compile_gcc_run" "good/alloc.ept") +ADD_TEST(compile_gcc_run_array1 "scripts/compile_gcc_run" "good/array1.ept") +ADD_TEST(compile_gcc_run_array2 "scripts/compile_gcc_run" "good/array2.ept") +ADD_TEST(compile_gcc_run_array_fill "scripts/compile_gcc_run" "good/array_fill.ept") +ADD_TEST(compile_gcc_run_array_iterators2 "scripts/compile_gcc_run" "good/array_iterators2.ept") +ADD_TEST(compile_gcc_run_array_iterators "scripts/compile_gcc_run" "good/array_iterators.ept") +ADD_TEST(compile_gcc_run_array_power "scripts/compile_gcc_run" "good/array_power.ept") +ADD_TEST(compile_gcc_run_auto2 "scripts/compile_gcc_run" "good/auto2.ept") +ADD_TEST(compile_gcc_run_auto "scripts/compile_gcc_run" "good/auto.ept") +ADD_TEST(compile_gcc_run_autohiera2 "scripts/compile_gcc_run" "good/autohiera2.ept") +ADD_TEST(compile_gcc_run_autohiera "scripts/compile_gcc_run" "good/autohiera.ept") +ADD_TEST(compile_gcc_run_bad_updown "scripts/compile_gcc_run" "good/bad_updown.ept") +ADD_TEST(compile_gcc_run_ckannot "scripts/compile_gcc_run" "good/ckannot.ept") +ADD_TEST(compile_gcc_run_clock_causality "scripts/compile_gcc_run" "good/clock_causality.ept") +ADD_TEST(compile_gcc_run_clocks "scripts/compile_gcc_run" "good/clocks.ept") +ADD_TEST(compile_gcc_run_counter "scripts/compile_gcc_run" "good/counter.ept") +ADD_TEST(compile_gcc_run_current "scripts/compile_gcc_run" "good/current.ept") +ADD_TEST(compile_gcc_run_fbyfby2 "scripts/compile_gcc_run" "good/fbyfby2.ept") +ADD_TEST(compile_gcc_run_foldi "scripts/compile_gcc_run" "good/foldi.ept") +ADD_TEST(compile_gcc_run_format "scripts/compile_gcc_run" "good/format.ept") +ADD_TEST(compile_gcc_run_grosauto_clock "scripts/compile_gcc_run" "good/grosauto_clock.ept") +ADD_TEST(compile_gcc_run_hierarchie "scripts/compile_gcc_run" "good/hierarchie.ept") +ADD_TEST(compile_gcc_run_itfusion "scripts/compile_gcc_run" "good/itfusion.ept") +ADD_TEST(compile_gcc_run_linear_automata "scripts/compile_gcc_run" "good/linear_automata.ept") +ADD_TEST(compile_gcc_run_linear "scripts/compile_gcc_run" "good/linear.ept") +ADD_TEST(compile_gcc_run_linear_init "scripts/compile_gcc_run" "good/linear_init.ept") +ADD_TEST(compile_gcc_run_linear_split "scripts/compile_gcc_run" "good/linear_split.ept") +ADD_TEST(compile_gcc_run_linear_vars "scripts/compile_gcc_run" "good/linear_vars.ept") +ADD_TEST(compile_gcc_run_memalloc_clocks "scripts/compile_gcc_run" "good/memalloc_clocks.ept") +ADD_TEST(compile_gcc_run_memalloc_record "scripts/compile_gcc_run" "good/memalloc_record.ept") +ADD_TEST(compile_gcc_run_memalloc_simple "scripts/compile_gcc_run" "good/memalloc_simple.ept") +ADD_TEST(compile_gcc_run_name_clash "scripts/compile_gcc_run" "good/name_clash.ept") +ADD_TEST(compile_gcc_run_norm "scripts/compile_gcc_run" "good/norm.ept") +ADD_TEST(compile_gcc_run_or_keep "scripts/compile_gcc_run" "good/or_keep.ept") +ADD_TEST(compile_gcc_run_parametrize "scripts/compile_gcc_run" "good/parametrize.ept") +ADD_TEST(compile_gcc_run_pre_tuple "scripts/compile_gcc_run" "good/pre_tuple.ept") +ADD_TEST(compile_gcc_run_reinit "scripts/compile_gcc_run" "good/reinit.ept") +ADD_TEST(compile_gcc_run_sampling_stateful_output2 "scripts/compile_gcc_run" "good/sampling_stateful_output2.ept") +ADD_TEST(compile_gcc_run_sampling_stateful_output "scripts/compile_gcc_run" "good/sampling_stateful_output.ept") +ADD_TEST(compile_gcc_run_side_effet "scripts/compile_gcc_run" "good/side_effet.ept") +ADD_TEST(compile_gcc_run_statics2 "scripts/compile_gcc_run" "good/statics2.ept") +ADD_TEST(compile_gcc_run_statics "scripts/compile_gcc_run" "good/statics.ept") +ADD_TEST(compile_gcc_run_t10 "scripts/compile_gcc_run" "good/t10.ept") +ADD_TEST(compile_gcc_run_t11 "scripts/compile_gcc_run" "good/t11.ept") +ADD_TEST(compile_gcc_run_t12 "scripts/compile_gcc_run" "good/t12.ept") +ADD_TEST(compile_gcc_run_t13 "scripts/compile_gcc_run" "good/t13.ept") +ADD_TEST(compile_gcc_run_t14 "scripts/compile_gcc_run" "good/t14.ept") +ADD_TEST(compile_gcc_run_t15 "scripts/compile_gcc_run" "good/t15.ept") +ADD_TEST(compile_gcc_run_t16 "scripts/compile_gcc_run" "good/t16.ept") +ADD_TEST(compile_gcc_run_t17 "scripts/compile_gcc_run" "good/t17.ept") +ADD_TEST(compile_gcc_run_t18 "scripts/compile_gcc_run" "good/t18.ept") +ADD_TEST(compile_gcc_run_t19 "scripts/compile_gcc_run" "good/t19.ept") +ADD_TEST(compile_gcc_run_t1 "scripts/compile_gcc_run" "good/t1.ept") +ADD_TEST(compile_gcc_run_t2 "scripts/compile_gcc_run" "good/t2.ept") +ADD_TEST(compile_gcc_run_t2open "scripts/compile_gcc_run" "good/t2open.ept") +ADD_TEST(compile_gcc_run_t3 "scripts/compile_gcc_run" "good/t3.ept") +ADD_TEST(compile_gcc_run_t4 "scripts/compile_gcc_run" "good/t4.ept") +ADD_TEST(compile_gcc_run_t5 "scripts/compile_gcc_run" "good/t5.ept") +ADD_TEST(compile_gcc_run_t6 "scripts/compile_gcc_run" "good/t6.ept") +ADD_TEST(compile_gcc_run_t7 "scripts/compile_gcc_run" "good/t7.ept") +ADD_TEST(compile_gcc_run_t8 "scripts/compile_gcc_run" "good/t8.ept") +ADD_TEST(compile_gcc_run_t9 "scripts/compile_gcc_run" "good/t9.ept") +ADD_TEST(compile_gcc_run_t "scripts/compile_gcc_run" "good/t.ept") +ADD_TEST(compile_gcc_run_test "scripts/compile_gcc_run" "good/test.ept") +ADD_TEST(compile_gcc_run_threestates "scripts/compile_gcc_run" "good/threestates.ept") +ADD_TEST(compile_gcc_run_tt "scripts/compile_gcc_run" "good/tt.ept") +ADD_TEST(compile_gcc_run_tttt "scripts/compile_gcc_run" "good/tttt.ept") +ADD_TEST(compile_gcc_run_tuple_args "scripts/compile_gcc_run" "good/tuple_args.ept") +ADD_TEST(compile_gcc_run_type_alias "scripts/compile_gcc_run" "good/type_alias.ept") +ADD_TEST(compile_gcc_run_updown "scripts/compile_gcc_run" "good/updown.ept") +ADD_TEST(compile_gcc_run_when_merge1 "scripts/compile_gcc_run" "good/when_merge1.ept") +SET_TEST_PROPERTIES(compile_gcc_run_t2 PROPERTIES DEPENDS compiler_gcc_run_t1) +SET_TEST_PROPERTIES(compile_gcc_run_t2open PROPERTIES DEPENDS compiler_gcc_run_t1) diff --git a/test/gen_ctests b/test/gen_ctests new file mode 100755 index 0000000..89f5833 --- /dev/null +++ b/test/gen_ctests @@ -0,0 +1,19 @@ +#!/bin/bash + +for i in bad/*.ept; do + echo 'ADD_TEST(compile_fail_'`basename $i .ept` '"scripts/compile_fail"' '"'$i'" "-memalloc")' +done + +for i in good/*.ept; do + echo 'ADD_TEST(compile_only_'`basename $i .ept` '"scripts/compile_only"' '"'$i'")' +done + +echo 'SET_TEST_PROPERTIES(compile_only_t2 PROPERTIES DEPENDS compiler_only_t1)' +echo 'SET_TEST_PROPERTIES(compile_only_t2open PROPERTIES DEPENDS compiler_only_t1)' + +for i in good/*.ept; do + echo 'ADD_TEST(compile_gcc_run_'`basename $i .ept` '"scripts/compile_gcc_run"' '"'$i'")' +done + +echo 'SET_TEST_PROPERTIES(compile_gcc_run_t2 PROPERTIES DEPENDS compiler_gcc_run_t1)' +echo 'SET_TEST_PROPERTIES(compile_gcc_run_t2open PROPERTIES DEPENDS compiler_gcc_run_t1)' diff --git a/test/scripts/compile_fail b/test/scripts/compile_fail new file mode 100755 index 0000000..f1415be --- /dev/null +++ b/test/scripts/compile_fail @@ -0,0 +1,42 @@ +#!/bin/bash + +checkdir=_check_builds + +shopt -s nullglob + +# script de test + +COMPILER_DIR="../compiler" +if [ -x $COMPILER_DIR/heptc.native ]; +then + COMPILER=heptc.native +else + COMPILER=heptc.byte +fi + +HEPTC=../$COMPILER_DIR/$COMPILER + +progpath=$1 +shift +coption=$* + +cp $progpath $checkdir + +pushd $checkdir > /dev/null + +heptprog=`basename $progpath` + +echo $HEPTC $coption $heptprog +$HEPTC $coption $heptprog +res=$? +if [ $res = 0 ] ; then + echo "ERROR : compilation of $progpath should have failed" +fi + +popd $checkdir > /dev/null + +if [ $res = 0 ] ; then + exit 1 +else + exit 0 +fi diff --git a/test/scripts/compile_gcc_run b/test/scripts/compile_gcc_run new file mode 100755 index 0000000..0e0747c --- /dev/null +++ b/test/scripts/compile_gcc_run @@ -0,0 +1,93 @@ +#!/bin/bash + +checkdir=_check_builds + +shopt -s nullglob + +# script de test + +COMPILER_DIR="../compiler" +if [ -x $COMPILER_DIR/heptc.native ]; +then + COMPILER=heptc.native +else + COMPILER=heptc.byte +fi + +HEPTC=../$COMPILER_DIR/$COMPILER +CC="gcc -std=c99 -I ../../../lib/c" +LD="gcc" +NBSTEP=100 + + +progpath=$1 +shift +coption="-target c $*" + +# run the program: no by default +run=0 + +cp $progpath $checkdir + + +pushd $checkdir > /dev/null + +heptprog=`basename $progpath` +heptroot=`basename $heptprog .ept` + +assert_node=$(eval grep CHECK $heptprog | awk '{ print $3 }') + +if [ -n "$assert_node" ]; then + coption="$coption -assert $assert_node" + run=1 +fi + +if grep "node main()" $heptprog >/dev/null; then + coption="$coption -hepts -s main" + run=1 +fi + +# Special case: t2 and t2open needs t1 + +if [[ ($heptroot == "t2") || ($heptroot == "t2open") ]]; then + CC="$CC -I ../t1_c" + LD="$LD ../t1_c/[^_]*.o" +fi + +echo $HEPTC $coption $heptprog +if $HEPTC $coption $heptprog; then + pushd ${heptroot}_c > /dev/null + echo $CC -c *.c + if $CC -c *.c; then + if [[ $run == 1 ]]; then + echo $LD *.o -o main + if $LD *.o -o main; then + echo ./main $NBSTEP + if ./main $NBSTEP; then + echo "Test successful." + res=0 + else + echo "Run failed." + res=1 + fi + else + echo "Link edition failed." + res=1 + fi + else + echo "Test successful (C compilation only; no run)." + res=0 + fi + else + echo "Compilation of C target code failed" + res=1 + fi + popd >/dev/null +else + echo "Compilation of $heptprog failed" + res=1 +fi + +popd > /dev/null + +exit $res diff --git a/test/scripts/compile_only b/test/scripts/compile_only new file mode 100755 index 0000000..07f0270 --- /dev/null +++ b/test/scripts/compile_only @@ -0,0 +1,34 @@ +#!/bin/bash + +checkdir=_check_builds + +shopt -s nullglob + +# script de test + +COMPILER_DIR="../compiler" +if [ -x $COMPILER_DIR/heptc.native ]; +then + COMPILER=heptc.native +else + COMPILER=heptc.byte +fi + +HEPTC=../$COMPILER_DIR/$COMPILER + +progpath=$1 +shift +coption=$* + +cp $progpath $checkdir + +pushd $checkdir > /dev/null + +heptprog=`basename $progpath` +echo $HEPTC $coption $heptprog +$HEPTC $coption $heptprog +res=$? + +popd $checkdir > /dev/null + +exit $res