Switch unit tests to jerry-libc.

JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
Ruben Ayrapetyan
2015-06-15 22:10:10 +03:00
parent 6d6c913bdc
commit f115f731c3
12 changed files with 44 additions and 23 deletions
+6 -3
View File
@@ -234,7 +234,7 @@ project (Jerry CXX C ASM)
set(FLAGS_COMMON_RELEASE "-Os -nostdlib")
# Unit tests
set(FLAGS_COMMON_UNITTESTS "-O3 -nodefaultlibs")
set(FLAGS_COMMON_UNITTESTS "-O3 -nostdlib")
# Include directories
# Core interface
@@ -310,8 +310,9 @@ project (Jerry CXX C ASM)
add_subdirectory(plugins)
# Targets declaration
string(TOLOWER "${PLATFORM_EXT}" PLATFORM_L)
function(declare_targets_for_build_mode BUILD_MODE)
string(TOLOWER "${PLATFORM_EXT}" PLATFORM_L)
set(TARGET_NAME ${BUILD_MODE_PREFIX_${BUILD_MODE}}.${PLATFORM_L})
set(PLUGINS_TARGET_NAME ${BUILD_MODE_PREFIX_${BUILD_MODE}}.plugins.${PLATFORM_L}.lib)
set(LIBC_TARGET_NAME ${BUILD_MODE_PREFIX_${BUILD_MODE}}.jerry-libc.${PLATFORM_L}.lib)
@@ -424,6 +425,7 @@ project (Jerry CXX C ASM)
set(TARGET_NAME unit-${TARGET_NAME})
set(CORE_TARGET_NAME unittests.jerry-core)
set(LIBC_TARGET_NAME unittests.jerry-libc.${PLATFORM_L}.lib)
set(FDLIBM_TARGET_NAME unittests.jerry-fdlibm${SUFFIX_THIRD_PARTY_LIB})
add_executable(${TARGET_NAME} ${SOURCE_UNIT_TEST_MAIN})
@@ -432,7 +434,8 @@ project (Jerry CXX C ASM)
set_property(TARGET ${TARGET_NAME}
PROPERTY LINK_FLAGS "${COMPILE_FLAGS_JERRY} ${CXX_FLAGS_JERRY} ${FLAGS_COMMON_UNITTESTS} ${LINKER_FLAGS_COMMON}")
target_include_directories(${TARGET_NAME} PRIVATE ${INCLUDE_CORE_INTERFACE})
target_link_libraries(${TARGET_NAME} ${CORE_TARGET_NAME} ${FDLIBM_TARGET_NAME} ${PREFIX_IMPORTED_LIB}libc
target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${INCLUDE_LIBC_INTERFACE})
target_link_libraries(${TARGET_NAME} ${CORE_TARGET_NAME} ${LIBC_TARGET_NAME} ${FDLIBM_TARGET_NAME}
${PREFIX_IMPORTED_LIB}libgcc ${PREFIX_IMPORTED_LIB}libgcc_eh)
add_cppcheck_target(${TARGET_NAME})
+1
View File
@@ -139,3 +139,4 @@ set(COMPILE_FLAGS_LIBC "${COMPILE_FLAGS_JERRY} ${C_FLAGS_JERRY}")
declare_targets_for_build_mode(DEBUG)
declare_targets_for_build_mode(RELEASE)
declare_targets_for_build_mode(UNITTESTS)
+2
View File
@@ -218,6 +218,8 @@ const jerry_api_char_ptr_t magic_string_items[] =
int
main (void)
{
TEST_INIT ();
jerry_init (JERRY_FLAG_EMPTY);
bool is_ok;
+24 -15
View File
@@ -24,8 +24,6 @@
#include <string.h>
#include <sys/time.h>
using namespace std;
/**
* Verify that unit tests are built with all debug checks enabled
*/
@@ -33,21 +31,32 @@ using namespace std;
# error "defined (JERRY_NDEBUG) || defined (JERRY_DISABLE_HEAVY_DEBUG) in a unit test"
#endif /* JERRY_NDEBUG || JERRY_DISABLE_HEAVY_DEBUG */
#define TEST_RANDOMIZE() \
/**
* Test initialization statement that should be included
* at the beginning of main function in every unit test.
*/
#define TEST_INIT() \
do \
{ \
struct timeval current_time; \
gettimeofday (&current_time, NULL); \
\
time_t seconds = current_time.tv_sec; \
suseconds_t microseconds = current_time.tv_usec; \
\
uint32_t seed = (uint32_t) (seconds + microseconds); \
\
printf ("TEST_RANDOMIZE: seed is %u\n", seed); \
\
FILE *f_rnd = fopen ("/dev/urandom", "r"); \
\
if (f_rnd == NULL) \
{ \
return 1; \
} \
\
uint32_t seed; \
\
size_t bytes_read = fread (&seed, 1, sizeof (seed), f_rnd); \
\
fclose (f_rnd); \
\
if (bytes_read != sizeof (seed)) \
{ \
return 1; \
} \
\
srand (seed); \
} \
while (0)
} while (0)
#endif /* TEST_COMMON_H */
+1 -1
View File
@@ -82,7 +82,7 @@ int
main (int __attr_unused___ argc,
char __attr_unused___ **argv)
{
TEST_RANDOMIZE ();
TEST_INIT ();
mem_heap_init (test_native_heap, sizeof (test_native_heap));
+1 -1
View File
@@ -58,7 +58,7 @@ int
main (int __attr_unused___ argc,
char __attr_unused___ **argv)
{
TEST_RANDOMIZE ();
TEST_INIT ();
const ecma_char_t *ptrs[test_sub_iters];
ecma_number_t numbers[test_sub_iters];
+2
View File
@@ -25,6 +25,8 @@ int
main (int __attr_unused___ argc,
char __attr_unused___ **argv)
{
TEST_INIT ();
const ecma_char_t* zt_strings[] =
{
(const ecma_char_t*) "1",
+2
View File
@@ -69,6 +69,8 @@ int
main (int __attr_unused___ argc,
char __attr_unused___ **argv)
{
TEST_INIT ();
char program[] = "a=1;var a;";
bool is_ok;
+1 -1
View File
@@ -37,7 +37,7 @@ int
main (int __attr_unused___ argc,
char __attr_unused___ **argv)
{
TEST_RANDOMIZE ();
TEST_INIT ();
for (uint32_t i = 0; i < test_iters; i++)
{
+1 -1
View File
@@ -37,7 +37,7 @@ int
main (int __attr_unused___ argc,
char __attr_unused___ **argv)
{
TEST_RANDOMIZE ();
TEST_INIT ();
mem_init ();
+1 -1
View File
@@ -213,7 +213,7 @@ int
main (int __attr_unused___ argc,
char __attr_unused___ **argv)
{
TEST_RANDOMIZE ();
TEST_INIT ();
mem_init ();
+2
View File
@@ -25,6 +25,8 @@ int
main (int __attr_unused___ argc,
char __attr_unused___ **argv)
{
TEST_INIT ();
const ecma_char_t* zt_strings[] =
{
(const ecma_char_t*) "1",