Turning on unit tests build and run during precommit.

This commit is contained in:
Ruben Ayrapetyan
2015-02-16 19:18:30 +03:00
parent d50cff78ac
commit 03c81e96e9
10 changed files with 101 additions and 101 deletions
+34 -35
View File
@@ -76,14 +76,15 @@ project (Jerry CXX C ASM)
set(MCU_SCRIPT_GENERATED_HEADER ${CMAKE_BINARY_DIR}/generated.h) set(MCU_SCRIPT_GENERATED_HEADER ${CMAKE_BINARY_DIR}/generated.h)
# Build modes # Build modes
set(BUILD_MODES DEBUG RELEASE)
# Debug # Debug
set(BUILD_MODE_PREFIX_DEBUG debug) set(BUILD_MODE_PREFIX_DEBUG debug)
# Release # Release
set(BUILD_MODE_PREFIX_RELEASE release) set(BUILD_MODE_PREFIX_RELEASE release)
# Unit tests
set(BUILD_MODE_PREFIX_UNITTESTS unittests)
# Modifiers # Modifiers
set(MODIFIERS set(MODIFIERS
COMPACT_PROFILE COMPACT_PROFILE
@@ -128,7 +129,7 @@ project (Jerry CXX C ASM)
# Compiler / Linker flags # Compiler / Linker flags
set(COMPILE_FLAGS_JERRY "-fno-builtin") set(COMPILE_FLAGS_JERRY "-fno-builtin")
set(LINKER_FLAGS_COMMON "-nostdlib") set(LINKER_FLAGS_COMMON "")
# Turn off stack protector # Turn off stack protector
set(COMPILE_FLAGS_JERRY "${COMPILE_FLAGS_JERRY} -fno-stack-protector") set(COMPILE_FLAGS_JERRY "${COMPILE_FLAGS_JERRY} -fno-stack-protector")
@@ -163,17 +164,20 @@ project (Jerry CXX C ASM)
set(LINKER_FLAGS_COMMON_MCU_STM32F4 "-T${CMAKE_SOURCE_DIR}/third-party/stm32f4.ld") set(LINKER_FLAGS_COMMON_MCU_STM32F4 "-T${CMAKE_SOURCE_DIR}/third-party/stm32f4.ld")
# Debug # Debug
set(FLAGS_COMMON_DEBUG "") set(FLAGS_COMMON_DEBUG "-nostdlib")
set(LINKER_FLAGS_COMMON_DEBUG "-nostdlib")
# Release # Release
set(FLAGS_COMMON_RELEASE "-Os -flto") set(FLAGS_COMMON_RELEASE "-Os -flto -nostdlib")
set(LINKER_FLAGS_COMMON_RELEASE "-nostdlib")
# Unit tests # Unit tests
set(FLAGS_UNIT_TEST "${FLAGS_COMMON_RELEASE}") set(FLAGS_COMMON_UNITTESTS "-O3 -flto -nodefaultlibs")
# Include directories # Include directories
set(INCLUDE_CORE # Core interface
${CMAKE_SOURCE_DIR}/core) set(INCLUDE_CORE_INTERFACE
${CMAKE_SOURCE_DIR}/core)
# Sources # Sources
# Platform-specific # Platform-specific
@@ -256,7 +260,7 @@ project (Jerry CXX C ASM)
set_property(TARGET ${TARGET_NAME} set_property(TARGET ${TARGET_NAME}
PROPERTY LINK_FLAGS "${COMPILE_FLAGS_JERRY} ${CXX_FLAGS_JERRY} ${FLAGS_COMMON_${BUILD_MODE}} ${LINKER_FLAGS_COMMON} ${LINKER_FLAGS_STATIC}") PROPERTY LINK_FLAGS "${COMPILE_FLAGS_JERRY} ${CXX_FLAGS_JERRY} ${FLAGS_COMMON_${BUILD_MODE}} ${LINKER_FLAGS_COMMON} ${LINKER_FLAGS_STATIC}")
target_compile_definitions(${TARGET_NAME} PRIVATE ${DEFINES_JERRY}) target_compile_definitions(${TARGET_NAME} PRIVATE ${DEFINES_JERRY})
target_include_directories(${TARGET_NAME} PRIVATE ${INCLUDE_CORE}) target_include_directories(${TARGET_NAME} PRIVATE ${INCLUDE_CORE_INTERFACE})
target_link_libraries(${TARGET_NAME} ${CORE_TARGET_NAME} ${LIBC_TARGET_NAME} imported_libgcc) target_link_libraries(${TARGET_NAME} ${CORE_TARGET_NAME} ${LIBC_TARGET_NAME} imported_libgcc)
if("${PLATFORM}" STREQUAL "MCU") if("${PLATFORM}" STREQUAL "MCU")
@@ -285,31 +289,26 @@ project (Jerry CXX C ASM)
endforeach() endforeach()
endfunction() endfunction()
foreach(BUILD_MODE ${BUILD_MODES}) declare_targets_for_build_mode(DEBUG)
declare_targets_for_build_mode(${BUILD_MODE}) declare_targets_for_build_mode(RELEASE)
endforeach()
# Unit tests declaration # Unit tests declaration
# --- add_custom_target(unittests) add_custom_target(unittests)
# ---
# --- add_library(unit_tests.lib STATIC ${SOURCE_CORE} ${SOURCE_JERRY_LIBC_LINUX}) foreach(SOURCE_UNIT_TEST_MAIN ${SOURCE_UNIT_TEST_MAIN_MODULES})
# --- target_compile_options(unit_tests.lib PRIVATE ${CXX_FLAGS_JERRY} ${CXX_FLAGS_COMMON_ARCH} ${CXX_FLAGS_UNIT_TEST}) get_filename_component(TARGET_NAME ${SOURCE_UNIT_TEST_MAIN} NAME_WE)
# --- target_compile_definitions(unit_tests.lib PRIVATE ${DEFINES_JERRY} ${DEFINES_UNIT_TEST}) set(TARGET_NAME unit_${TARGET_NAME})
# --- target_include_directories(unit_tests.lib PRIVATE ${INCLUDE_CORE} ${INCLUDE_UNIT_TEST})
# --- set(CORE_TARGET_NAME unittests.jerry-core)
# --- foreach(SOURCE_UNIT_TEST_MAIN ${SOURCE_UNIT_TEST_MAIN_MODULES})
# --- get_filename_component(TARGET_NAME ${SOURCE_UNIT_TEST_MAIN} NAME_WE) add_executable(${TARGET_NAME} ${SOURCE_UNIT_TEST_MAIN})
# --- set(TARGET_NAME unit_${TARGET_NAME}) set_property(TARGET ${TARGET_NAME}
# --- PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_JERRY} ${CXX_FLAGS_JERRY} ${FLAGS_UNIT_TEST}")
# --- add_executable(${TARGET_NAME} ${SOURCE_UNIT_TEST_MAIN}) set_property(TARGET ${TARGET_NAME}
# --- target_compile_options(${TARGET_NAME} PRIVATE PROPERTY LINK_FLAGS "${COMPILE_FLAGS_JERRY} ${CXX_FLAGS_JERRY} ${FLAGS_COMMON_UNITTESTS} ${LINKER_FLAGS_COMMON}")
# --- ${CXX_FLAGS_JERRY} target_compile_definitions(${TARGET_NAME} PRIVATE ${DEFINES_UNIT_TEST})
# --- ${CXX_FLAGS_COMMON_ARCH} target_include_directories(${TARGET_NAME} PRIVATE ${INCLUDE_CORE})
# --- ${CXX_FLAGS_UNIT_TEST}) target_link_libraries(${TARGET_NAME} ${CORE_TARGET_NAME} imported_libc imported_libgcc)
# --- set_property(TARGET ${TARGET_NAME} PROPERTY LINK_FLAGS "${LINKER_FLAGS_COMMON} ${LINKER_FLAGS_UNIT_TEST}")
# --- target_compile_definitions(${TARGET_NAME} PRIVATE ${DEFINES_JERRY} ${DEFINES_UNIT_TEST}) add_dependencies(unittests ${TARGET_NAME})
# --- target_include_directories(${TARGET_NAME} PRIVATE ${INCLUDE_CORE} ${INCLUDE_UNIT_TEST}) endforeach()
# --- target_link_libraries(${TARGET_NAME} unit_tests.lib imported_libc imported_libgcc)
# ---
# --- add_dependencies(unittests ${TARGET_NAME})
# --- endforeach()
+9 -11
View File
@@ -29,10 +29,8 @@
# For list of modifiers for PC target - see TARGET_PC_MODS, for MCU target - TARGET_MCU_MODS. # For list of modifiers for PC target - see TARGET_PC_MODS, for MCU target - TARGET_MCU_MODS.
# #
# Target action part (optional, after second dot): # Target action part (optional, after second dot):
# check - run cppcheck on src folder, unit and other tests
# flash - flash specified mcu target binary # flash - flash specified mcu target binary
# #
#
# Unit test target: unittests_run # Unit test target: unittests_run
# #
@@ -93,7 +91,7 @@ export SHELL=/bin/bash
BUILD_DIRS_STM32F4 := $(foreach _OPTIONS_COMBINATION,$(OPTIONS_COMBINATIONS),$(BUILD_DIR_PREFIX)$(_OPTIONS_COMBINATION)/stm32f4) BUILD_DIRS_STM32F4 := $(foreach _OPTIONS_COMBINATION,$(OPTIONS_COMBINATIONS),$(BUILD_DIR_PREFIX)$(_OPTIONS_COMBINATION)/stm32f4)
# All together # All together
BUILD_DIRS_ALL := $(BUILD_DIRS_NATIVE) $(BUILD_DIRS_STM32F3) $(BUILD_DIRS_STM32F4) BUILD_DIRS_ALL := $(BUILD_DIRS_NATIVE) $(BUILD_DIRS_STM32F3) $(BUILD_DIRS_STM32F4)
# Current # Current
BUILD_DIR := ./build/obj$(OPTIONS_STRING) BUILD_DIR := ./build/obj$(OPTIONS_STRING)
@@ -142,7 +140,7 @@ $(JERRY_STM32F4_TARGETS): $(BUILD_DIR)/stm32f4
@ cp $(BUILD_DIR)/stm32f4/$@ $(OUT_DIR)/$@/jerry @ cp $(BUILD_DIR)/stm32f4/$@ $(OUT_DIR)/$@/jerry
@ cp $(BUILD_DIR)/stm32f4/$@.bin $(OUT_DIR)/$@/jerry.bin @ cp $(BUILD_DIR)/stm32f4/$@.bin $(OUT_DIR)/$@/jerry.bin
build: $(JERRY_TARGETS) # unittests build: $(JERRY_TARGETS) unittests
$(FLASH_TARGETS): $(BUILD_DIR)/mcu $(FLASH_TARGETS): $(BUILD_DIR)/mcu
@$(MAKE) -C $(BUILD_DIR)/mcu VERBOSE=1 $@ 1>/dev/null @$(MAKE) -C $(BUILD_DIR)/mcu VERBOSE=1 $@ 1>/dev/null
@@ -167,10 +165,10 @@ precommit: clean
@ echo -e "\nBuilding...\n\n" @ echo -e "\nBuilding...\n\n"
@ $(MAKE) build @ $(MAKE) build
@ echo -e "\n================ Build completed successfully. Running precommit tests ================\n" @ echo -e "\n================ Build completed successfully. Running precommit tests ================\n"
@ #echo -e "All targets were built successfully. Starting unit tests' run.\n" @ echo -e "All targets were built successfully. Starting unit tests' run.\n"
@ #$(MAKE) unittests_run TESTS_OPTS="--silent" @ $(MAKE) unittests_run TESTS_OPTS="--silent"
@ #echo -e "Unit tests completed successfully. Starting parse-only testing.\n" @ echo -e "Unit tests completed successfully. Starting parse-only testing.\n"
@ #echo -e "All targets were built successfully. Starting parse-only testing.\n" @ echo -e "All targets were built successfully. Starting parse-only testing.\n"
@ # Parse-only testing @ # Parse-only testing
@ for path in "./tests/jerry" "./tests/benchmarks/jerry"; \ @ for path in "./tests/jerry" "./tests/benchmarks/jerry"; \
do \ do \
@@ -221,10 +219,10 @@ precommit: clean
done done
@ echo -e "Full testing completed successfully\n\n================\n\n" @ echo -e "Full testing completed successfully\n\n================\n\n"
#unittests_run: unittests unittests_run: unittests
# @$(MAKE) -s -f Makefile.mk TARGET=$@ $@ @$(MAKE) -s -f Makefile.mk TARGET=$@ $@
clean: clean:
@ rm -rf $(BUILD_DIRS_ALL) $(OUT_DIR) @ rm -rf $(BUILD_DIR_PREFIX)* $(OUT_DIR)
.PHONY: clean build unittests_run $(JERRY_TARGETS) $(FLASH_TARGETS) .PHONY: clean build unittests_run $(JERRY_TARGETS) $(FLASH_TARGETS)
+12 -3
View File
@@ -42,6 +42,9 @@ project (JerryCore CXX C ASM)
# Release # Release
set(DEFINES_JERRY_RELEASE JERRY_NDEBUG) set(DEFINES_JERRY_RELEASE JERRY_NDEBUG)
# Unit tests
set(DEFINES_JERRY_UNITTESTS )
# Modifiers # Modifiers
# Full profile # Full profile
set(DEFINES_FULL_PROFILE CONFIG_ECMA_NUMBER_TYPE=CONFIG_ECMA_NUMBER_FLOAT64) set(DEFINES_FULL_PROFILE CONFIG_ECMA_NUMBER_TYPE=CONFIG_ECMA_NUMBER_FLOAT64)
@@ -139,6 +142,11 @@ project (JerryCore CXX C ASM)
PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_JERRY} ${CXX_FLAGS_JERRY} ${FLAGS_COMMON_${BUILD_MODE}}") PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_JERRY} ${CXX_FLAGS_JERRY} ${FLAGS_COMMON_${BUILD_MODE}}")
target_compile_definitions(${TARGET_NAME}.jerry-core PRIVATE ${DEFINES_JERRY}) target_compile_definitions(${TARGET_NAME}.jerry-core PRIVATE ${DEFINES_JERRY})
target_include_directories(${TARGET_NAME}.jerry-core PRIVATE ${INCLUDE_CORE}) target_include_directories(${TARGET_NAME}.jerry-core PRIVATE ${INCLUDE_CORE})
if("${BUILD_MODE}" STREQUAL "UNITTESTS")
target_compile_definitions(${TARGET_NAME}.jerry-core INTERFACE ${DEFINES_JERRY})
target_include_directories(${TARGET_NAME}.jerry-core INTERFACE ${INCLUDE_CORE})
endif()
endfunction() endfunction()
foreach(MODIFIERS_LIST ${MODIFIERS_LISTS}) foreach(MODIFIERS_LIST ${MODIFIERS_LISTS})
@@ -148,6 +156,7 @@ project (JerryCore CXX C ASM)
endforeach() endforeach()
endfunction() endfunction()
foreach(BUILD_MODE ${BUILD_MODES}) declare_targets_for_build_mode(DEBUG)
declare_targets_for_build_mode(${BUILD_MODE}) declare_targets_for_build_mode(RELEASE)
endforeach() declare_targets_for_build_mode(UNITTESTS)
+2 -3
View File
@@ -146,6 +146,5 @@ set(COMPILE_FLAGS_LIBC "${COMPILE_FLAGS_JERRY} ${C_FLAGS_JERRY}")
endforeach() endforeach()
endfunction() endfunction()
foreach(BUILD_MODE ${BUILD_MODES}) declare_targets_for_build_mode(DEBUG)
declare_targets_for_build_mode(${BUILD_MODE}) declare_targets_for_build_mode(RELEASE)
endforeach()
+2 -3
View File
@@ -106,6 +106,5 @@ project (Jerry_Plugins CXX ASM)
endif() endif()
endfunction() endfunction()
foreach(BUILD_MODE ${BUILD_MODES}) declare_targets_for_build_mode(DEBUG)
declare_targets_for_build_mode(${BUILD_MODE}) declare_targets_for_build_mode(RELEASE)
endforeach()
+1 -2
View File
@@ -16,13 +16,12 @@
#ifndef COMMON_H #ifndef COMMON_H
#define COMMON_H #define COMMON_H
#include "jerry-libc.h"
#include "literal.h" #include "literal.h"
#define NAME_TO_ID(op) (__op__idx_##op) #define NAME_TO_ID(op) (__op__idx_##op)
#define __OPCODE_SIZE(name, arg1, arg2, arg3) \ #define __OPCODE_SIZE(name, arg1, arg2, arg3) \
sizeof (__op_##name) + 1, (uint8_t) (sizeof (__op_##name) + 1),
#define LP(s) create_literal_from_str_compute_len (s) #define LP(s) create_literal_from_str_compute_len (s)
#define NUM(s) create_literal_from_num (s) #define NUM(s) create_literal_from_num (s)
+14 -14
View File
@@ -13,12 +13,12 @@
* limitations under the License. * limitations under the License.
*/ */
#include <math.h>
#include <string.h>
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "jrt.h" #include "jrt.h"
#include "jerry-libc.h"
#include <math.h>
/** /**
* Unit test's main function. * Unit test's main function.
@@ -44,17 +44,17 @@ main( int __attr_unused___ argc,
const ecma_number_t nums[] = const ecma_number_t nums[] =
{ {
1.0, (ecma_number_t) 1.0,
0.5, (ecma_number_t) 0.5,
12345.0, (ecma_number_t) 12345.0,
12345.123, (ecma_number_t) 12345.123,
1.0e-45, (ecma_number_t) 1.0e-45,
-2.5e+38, (ecma_number_t) -2.5e+38,
NAN, (ecma_number_t) NAN,
INFINITY, (ecma_number_t) INFINITY,
-INFINITY, (ecma_number_t) -INFINITY,
+0.0, (ecma_number_t) +0.0,
-0.0 (ecma_number_t) -0.0
}; };
for (uint32_t i = 0; for (uint32_t i = 0;
+5 -8
View File
@@ -17,21 +17,18 @@
* Unit test for pool manager. * Unit test for pool manager.
*/ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define JERRY_MEM_POOL_INTERNAL #define JERRY_MEM_POOL_INTERNAL
#include "jrt.h" #include "jrt.h"
#include "jerry-libc.h"
#include "mem-allocator.h" #include "mem-allocator.h"
#include "mem-pool.h" #include "mem-pool.h"
#include "mem-poolman.h" #include "mem-poolman.h"
extern "C"
{
extern void srand (unsigned int __seed);
extern int rand (void);
extern long int time (long int *__timer);
}
// Iterations count // Iterations count
const uint32_t test_iters = 16384; const uint32_t test_iters = 16384;
+2 -1
View File
@@ -13,13 +13,14 @@
* limitations under the License. * limitations under the License.
*/ */
#include <string.h>
#include "jrt.h" #include "jrt.h"
#include "mem-allocator.h" #include "mem-allocator.h"
#include "opcodes.h" #include "opcodes.h"
#include "deserializer.h" #include "deserializer.h"
#include "common.h" #include "common.h"
#include "parser.h" #include "parser.h"
#include "jerry-libc.h"
/** /**
* Unit test's main function. * Unit test's main function.
+20 -21
View File
@@ -13,12 +13,11 @@
* limitations under the License. * limitations under the License.
*/ */
#include <math.h>
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "jrt.h" #include "jrt.h"
#include "jerry-libc.h"
#include <math.h>
/** /**
* Unit test's main function. * Unit test's main function.
@@ -51,24 +50,24 @@ main( int __attr_unused___ argc,
const ecma_number_t nums[] = const ecma_number_t nums[] =
{ {
1.0, (ecma_number_t) 1.0,
0.5, (ecma_number_t) 0.5,
12345.0, (ecma_number_t) 12345.0,
1.0e-45, (ecma_number_t) 1.0e-45,
-2.5e+38, (ecma_number_t) -2.5e+38,
-2.5e+38, (ecma_number_t) -2.5e+38,
NAN, (ecma_number_t) NAN,
NAN, (ecma_number_t) NAN,
NAN, (ecma_number_t) NAN,
NAN, (ecma_number_t) NAN,
NAN, (ecma_number_t) NAN,
NAN, (ecma_number_t) NAN,
NAN, (ecma_number_t) NAN,
NAN, (ecma_number_t) NAN,
INFINITY, (ecma_number_t) INFINITY,
-INFINITY, (ecma_number_t) -INFINITY,
+0.0, (ecma_number_t) +0.0,
-0.0 (ecma_number_t) -0.0
}; };
for (uint32_t i = 0; for (uint32_t i = 0;