Small enhancements of unit tests implementation style and fix of the tests' modules naming style.

- introducing TEST_RANDOMIZE macro for randomization of source data used in unit tests;
 - replacing assert with JERRY_ASSERT;
 - renaming test_* to test-*.

JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
Ruben Ayrapetyan 2015-06-11 18:30:00 +03:00
parent 013bce85fc
commit 57c6c377af
14 changed files with 194 additions and 229 deletions

View File

@ -421,7 +421,7 @@ project (Jerry CXX C ASM)
foreach(SOURCE_UNIT_TEST_MAIN ${SOURCE_UNIT_TEST_MAIN_MODULES})
get_filename_component(TARGET_NAME ${SOURCE_UNIT_TEST_MAIN} NAME_WE)
set(TARGET_NAME unit_${TARGET_NAME})
set(TARGET_NAME unit-${TARGET_NAME})
set(CORE_TARGET_NAME unittests.jerry-core)
set(FDLIBM_TARGET_NAME unittests.jerry-fdlibm${SUFFIX_THIRD_PARTY_LIB})

View File

@ -207,7 +207,7 @@ unittests: $(BUILD_DIR)/native
(echo "cppcheck run failed. See $(OUT_DIR)/$@/cppcheck.log for details."; exit 1;)
@ $(MAKE) -C $(BUILD_DIR)/native VERBOSE=1 $@ &>$(OUT_DIR)/$@/make.log || \
(echo "Build failed. See $(OUT_DIR)/$@/make.log for details."; exit 1;)
@ cp $(BUILD_DIR)/native/unit_test_* $(OUT_DIR)/$@
@ cp $(BUILD_DIR)/native/unit-test-* $(OUT_DIR)/$@
$(BUILD_ALL)_native: $(BUILD_DIRS_NATIVE)
@ mkdir -p $(OUT_DIR)/$@

View File

@ -1,63 +0,0 @@
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef COMMON_H
#define COMMON_H
#define NAME_TO_ID(op) (__op__idx_##op)
#define __OPCODE_SIZE(name, arg1, arg2, arg3) \
(uint8_t) (sizeof (__op_##name) + 1),
static uint8_t opcode_sizes[] =
{
OP_LIST (OPCODE_SIZE)
0
};
static bool opcodes_equal (const opcode_t *, opcode_t *, uint16_t) __attr_unused___;
static bool
opcodes_equal (const opcode_t *opcodes1, opcode_t *opcodes2, uint16_t size)
{
uint16_t i;
for (i = 0; i < size; i++)
{
uint8_t opcode_num1 = opcodes1[i].op_idx, opcode_num2 = opcodes2[i].op_idx;
uint8_t j;
if (opcode_num1 != opcode_num2)
{
return false;
}
if (opcode_num1 == NAME_TO_ID (nop) || opcode_num1 == NAME_TO_ID (ret))
{
return true;
}
for (j = 1; j < opcode_sizes[opcode_num1]; j++)
{
if (((uint8_t*)&opcodes1[i])[j] != ((uint8_t*)&opcodes2[i])[j])
{
return false;
}
}
}
return true;
}
#endif // COMMON_H

View File

@ -13,14 +13,11 @@
* limitations under the License.
*/
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "jerry.h"
#include "jerry-api.h"
#include "test-common.h"
const char *test_source = (
"this.t = 1; "
"function f () { "
@ -111,17 +108,17 @@ handler (const jerry_api_object_t *function_obj_p,
printf ("ok %p %p %p %d %p\n", function_obj_p, this_p, args_p, args_cnt, ret_val_p);
assert (args_cnt == 2);
JERRY_ASSERT (args_cnt == 2);
assert (args_p[0].type == JERRY_API_DATA_TYPE_STRING);
JERRY_ASSERT (args_p[0].type == JERRY_API_DATA_TYPE_STRING);
sz = jerry_api_string_to_char_buffer (args_p[0].v_string, NULL, 0);
assert (sz == -2);
JERRY_ASSERT (sz == -2);
sz = jerry_api_string_to_char_buffer (args_p[0].v_string, buffer, -sz);
assert (sz == 2);
assert (!strcmp (buffer, "1"));
JERRY_ASSERT (sz == 2);
JERRY_ASSERT (!strcmp (buffer, "1"));
assert (args_p[1].type == JERRY_API_DATA_TYPE_BOOLEAN);
assert (args_p[1].v_bool == true);
JERRY_ASSERT (args_p[1].type == JERRY_API_DATA_TYPE_BOOLEAN);
JERRY_ASSERT (args_p[1].v_bool == true);
test_api_init_api_value_string (ret_val_p, "string from handler");
@ -149,7 +146,7 @@ handler_throw_test (const jerry_api_object_t *function_obj_p,
static void
handler_construct_freecb (uintptr_t native_p)
{
assert (native_p == (uintptr_t) 0x0012345678abcdefull);
JERRY_ASSERT (native_p == (uintptr_t) 0x0012345678abcdefull);
printf ("ok object free callback\n");
test_api_is_free_callback_was_called = true;
@ -164,12 +161,12 @@ handler_construct (const jerry_api_object_t *function_obj_p,
{
printf ("ok construct %p %p %p %d %p\n", function_obj_p, this_p, args_p, args_cnt, ret_val_p);
assert (this_p != NULL);
assert (this_p->type == JERRY_API_DATA_TYPE_OBJECT);
JERRY_ASSERT (this_p != NULL);
JERRY_ASSERT (this_p->type == JERRY_API_DATA_TYPE_OBJECT);
assert (args_cnt == 1);
assert (args_p[0].type == JERRY_API_DATA_TYPE_BOOLEAN);
assert (args_p[0].v_bool == true);
JERRY_ASSERT (args_cnt == 1);
JERRY_ASSERT (args_p[0].type == JERRY_API_DATA_TYPE_BOOLEAN);
JERRY_ASSERT (args_p[0].v_bool == true);
jerry_api_set_object_field_value (this_p->v_object, "value_field", &args_p[0]);
@ -234,44 +231,44 @@ main (void)
char buffer[32];
is_ok = jerry_parse (test_source, strlen (test_source));
assert (is_ok);
JERRY_ASSERT (is_ok);
is_ok = (jerry_run () == JERRY_COMPLETION_CODE_OK);
assert (is_ok);
JERRY_ASSERT (is_ok);
global_obj_p = jerry_api_get_global ();
// Get global.t
is_ok = jerry_api_get_object_field_value (global_obj_p, "t", &val_t);
assert (is_ok
&& val_t.type == JERRY_API_DATA_TYPE_FLOAT64
&& val_t.v_float64 == 1.0);
JERRY_ASSERT (is_ok
&& val_t.type == JERRY_API_DATA_TYPE_FLOAT64
&& val_t.v_float64 == 1.0);
jerry_api_release_value (&val_t);
// Get global.foo
is_ok = jerry_api_get_object_field_value (global_obj_p, "foo", &val_foo);
assert (is_ok
&& val_foo.type == JERRY_API_DATA_TYPE_OBJECT);
JERRY_ASSERT (is_ok
&& val_foo.type == JERRY_API_DATA_TYPE_OBJECT);
// Call foo (4, 2)
test_api_init_api_value_float64 (&args[0], 4);
test_api_init_api_value_float64 (&args[1], 2);
is_ok = jerry_api_call_function (val_foo.v_object, NULL, &res, args, 2);
assert (is_ok
&& res.type == JERRY_API_DATA_TYPE_FLOAT64
&& res.v_float64 == 1.0);
JERRY_ASSERT (is_ok
&& res.type == JERRY_API_DATA_TYPE_FLOAT64
&& res.v_float64 == 1.0);
jerry_api_release_value (&res);
// Get global.bar
is_ok = jerry_api_get_object_field_value (global_obj_p, "bar", &val_bar);
assert (is_ok
&& val_bar.type == JERRY_API_DATA_TYPE_OBJECT);
JERRY_ASSERT (is_ok
&& val_bar.type == JERRY_API_DATA_TYPE_OBJECT);
// Call bar (4, 2)
is_ok = jerry_api_call_function (val_bar.v_object, NULL, &res, args, 2);
assert (is_ok
&& res.type == JERRY_API_DATA_TYPE_FLOAT64
&& res.v_float64 == 5.0);
JERRY_ASSERT (is_ok
&& res.type == JERRY_API_DATA_TYPE_FLOAT64
&& res.v_float64 == 5.0);
jerry_api_release_value (&res);
jerry_api_release_value (&val_bar);
@ -280,65 +277,65 @@ main (void)
is_ok = jerry_api_set_object_field_value (global_obj_p,
"t",
&args[0]);
assert (is_ok);
JERRY_ASSERT (is_ok);
jerry_api_release_value (&args[0]);
// Call foo (4, 2)
is_ok = jerry_api_call_function (val_foo.v_object, NULL, &res, args, 2);
assert (is_ok
&& res.type == JERRY_API_DATA_TYPE_STRING);
JERRY_ASSERT (is_ok
&& res.type == JERRY_API_DATA_TYPE_STRING);
sz = jerry_api_string_to_char_buffer (res.v_string, NULL, 0);
assert (sz == -5);
JERRY_ASSERT (sz == -5);
sz = jerry_api_string_to_char_buffer (res.v_string, buffer, -sz);
assert (sz == 5);
JERRY_ASSERT (sz == 5);
jerry_api_release_value (&res);
assert (!strcmp (buffer, "abcd"));
JERRY_ASSERT (!strcmp (buffer, "abcd"));
// Get global.A
is_ok = jerry_api_get_object_field_value (global_obj_p, "A", &val_A);
assert (is_ok
&& val_A.type == JERRY_API_DATA_TYPE_OBJECT);
JERRY_ASSERT (is_ok
&& val_A.type == JERRY_API_DATA_TYPE_OBJECT);
// Get A.prototype
is_ok = jerry_api_is_constructor (val_A.v_object);
assert (is_ok);
JERRY_ASSERT (is_ok);
is_ok = jerry_api_get_object_field_value (val_A.v_object,
"prototype",
&val_A_prototype);
assert (is_ok
&& val_A_prototype.type == JERRY_API_DATA_TYPE_OBJECT);
JERRY_ASSERT (is_ok
&& val_A_prototype.type == JERRY_API_DATA_TYPE_OBJECT);
jerry_api_release_value (&val_A);
// Set A.prototype.foo = global.foo
is_ok = jerry_api_set_object_field_value (val_A_prototype.v_object,
"foo",
&val_foo);
assert (is_ok);
JERRY_ASSERT (is_ok);
jerry_api_release_value (&val_A_prototype);
jerry_api_release_value (&val_foo);
// Get global.a
is_ok = jerry_api_get_object_field_value (global_obj_p, "a", &val_a);
assert (is_ok
&& val_a.type == JERRY_API_DATA_TYPE_OBJECT);
JERRY_ASSERT (is_ok
&& val_a.type == JERRY_API_DATA_TYPE_OBJECT);
// Get a.t
is_ok = jerry_api_get_object_field_value (val_a.v_object, "t", &res);
assert (is_ok
&& res.type == JERRY_API_DATA_TYPE_FLOAT64
&& res.v_float64 == 12.0);
JERRY_ASSERT (is_ok
&& res.type == JERRY_API_DATA_TYPE_FLOAT64
&& res.v_float64 == 12.0);
jerry_api_release_value (&res);
// Get a.foo
is_ok = jerry_api_get_object_field_value (val_a.v_object, "foo", &val_a_foo);
assert (is_ok
&& val_a_foo.type == JERRY_API_DATA_TYPE_OBJECT);
JERRY_ASSERT (is_ok
&& val_a_foo.type == JERRY_API_DATA_TYPE_OBJECT);
// Call a.foo ()
is_ok = jerry_api_call_function (val_a_foo.v_object, val_a.v_object, &res, NULL, 0);
assert (is_ok
&& res.type == JERRY_API_DATA_TYPE_FLOAT64
&& res.v_float64 == 12.0);
JERRY_ASSERT (is_ok
&& res.type == JERRY_API_DATA_TYPE_FLOAT64
&& res.v_float64 == 12.0);
jerry_api_release_value (&res);
jerry_api_release_value (&val_a_foo);
@ -346,95 +343,95 @@ main (void)
// Create native handler bound function object and set it to 'external' variable
external_func_p = jerry_api_create_external_function (handler);
assert (external_func_p != NULL
&& jerry_api_is_function (external_func_p)
&& jerry_api_is_constructor (external_func_p));
JERRY_ASSERT (external_func_p != NULL
&& jerry_api_is_function (external_func_p)
&& jerry_api_is_constructor (external_func_p));
test_api_init_api_value_object (&val_external, external_func_p);
is_ok = jerry_api_set_object_field_value (global_obj_p,
"external",
&val_external);
assert (is_ok);
JERRY_ASSERT (is_ok);
jerry_api_release_value (&val_external);
jerry_api_release_object (external_func_p);
// Call 'call_external' function that should call external function created above
is_ok = jerry_api_get_object_field_value (global_obj_p, "call_external", &val_call_external);
assert (is_ok
&& val_call_external.type == JERRY_API_DATA_TYPE_OBJECT);
JERRY_ASSERT (is_ok
&& val_call_external.type == JERRY_API_DATA_TYPE_OBJECT);
is_ok = jerry_api_call_function (val_call_external.v_object,
global_obj_p,
&res,
NULL, 0);
jerry_api_release_value (&val_call_external);
assert (is_ok
&& res.type == JERRY_API_DATA_TYPE_STRING);
JERRY_ASSERT (is_ok
&& res.type == JERRY_API_DATA_TYPE_STRING);
sz = jerry_api_string_to_char_buffer (res.v_string, NULL, 0);
assert (sz == -20);
JERRY_ASSERT (sz == -20);
sz = jerry_api_string_to_char_buffer (res.v_string, buffer, -sz);
assert (sz == 20);
JERRY_ASSERT (sz == 20);
jerry_api_release_value (&res);
assert (!strcmp (buffer, "string from handler"));
JERRY_ASSERT (!strcmp (buffer, "string from handler"));
// Create native handler bound function object and set it to 'external_construct' variable
external_construct_p = jerry_api_create_external_function (handler_construct);
assert (external_construct_p != NULL
&& jerry_api_is_function (external_construct_p)
&& jerry_api_is_constructor (external_construct_p));
JERRY_ASSERT (external_construct_p != NULL
&& jerry_api_is_function (external_construct_p)
&& jerry_api_is_constructor (external_construct_p));
test_api_init_api_value_object (&val_external_construct, external_construct_p);
is_ok = jerry_api_set_object_field_value (global_obj_p,
"external_construct",
&val_external_construct);
assert (is_ok);
JERRY_ASSERT (is_ok);
jerry_api_release_value (&val_external_construct);
jerry_api_release_object (external_construct_p);
// Call external function created above, as constructor
test_api_init_api_value_bool (&args[0], true);
is_ok = jerry_api_construct_object (external_construct_p, &res, args, 1);
assert (is_ok
&& res.type == JERRY_API_DATA_TYPE_OBJECT);
JERRY_ASSERT (is_ok
&& res.type == JERRY_API_DATA_TYPE_OBJECT);
is_ok = jerry_api_get_object_field_value (res.v_object,
"value_field",
&val_value_field);
// Get 'value_field' of constructed object
assert (is_ok
&& val_value_field.type == JERRY_API_DATA_TYPE_BOOLEAN
&& val_value_field.v_bool == true);
JERRY_ASSERT (is_ok
&& val_value_field.type == JERRY_API_DATA_TYPE_BOOLEAN
&& val_value_field.v_bool == true);
jerry_api_release_value (&val_value_field);
uintptr_t ptr;
is_ok = jerry_api_get_object_native_handle (res.v_object, &ptr);
assert (is_ok
&& ptr == (uintptr_t) 0x0012345678abcdefull);
JERRY_ASSERT (is_ok
&& ptr == (uintptr_t) 0x0012345678abcdefull);
jerry_api_release_value (&res);
// Test: Throwing exception from native handler.
throw_test_handler_p = jerry_api_create_external_function (handler_throw_test);
assert (throw_test_handler_p != NULL
&& jerry_api_is_function (throw_test_handler_p));
JERRY_ASSERT (throw_test_handler_p != NULL
&& jerry_api_is_function (throw_test_handler_p));
test_api_init_api_value_object (&val_t, throw_test_handler_p);
is_ok = jerry_api_set_object_field_value (global_obj_p,
"throw_test",
&val_t);
assert (is_ok);
JERRY_ASSERT (is_ok);
jerry_api_release_value (&val_t);
jerry_api_release_object (throw_test_handler_p);
is_ok = jerry_api_get_object_field_value (global_obj_p, "call_throw_test", &val_t);
assert (is_ok
&& val_t.type == JERRY_API_DATA_TYPE_OBJECT);
JERRY_ASSERT (is_ok
&& val_t.type == JERRY_API_DATA_TYPE_OBJECT);
is_ok = jerry_api_call_function (val_t.v_object,
global_obj_p,
&res,
NULL, 0);
assert (is_ok);
JERRY_ASSERT (is_ok);
jerry_api_release_value (&val_t);
jerry_api_release_value (&res);
@ -444,7 +441,7 @@ main (void)
jerry_cleanup ();
assert (test_api_is_free_callback_was_called);
JERRY_ASSERT (test_api_is_free_callback_was_called);
// External Magic String
jerry_init (JERRY_FLAG_SHOW_OPCODES);
@ -456,10 +453,10 @@ main (void)
const char *ms_code_src_p = "var global = {}; var console = [1]; var process = 1;";
is_ok = jerry_parse (ms_code_src_p, strlen (ms_code_src_p));
assert (is_ok);
JERRY_ASSERT (is_ok);
is_ok = (jerry_run () == JERRY_COMPLETION_CODE_OK);
assert (is_ok);
JERRY_ASSERT (is_ok);
jerry_cleanup ();

46
tests/unit/test-common.h Normal file
View File

@ -0,0 +1,46 @@
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef TEST_COMMON_H
#define TEST_COMMON_H
#include "jrt.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
using namespace std;
#define TEST_RANDOMIZE() \
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); \
\
srand (seed); \
} \
while (0)
#endif /* TEST_COMMON_H */

View File

@ -13,17 +13,9 @@
* limitations under the License.
*/
#include "jrt.h"
#include "mem-allocator.h"
extern "C"
{
extern void srand (unsigned int __seed);
extern int rand (void);
extern long int time (long int *__timer);
extern int printf (__const char *__restrict __format, ...);
extern void *memset (void *__s, int __c, size_t __n);
}
#include "test-common.h"
// Heap size is 32K
#define test_heap_size (32 * 1024)
@ -90,12 +82,9 @@ int
main (int __attr_unused___ argc,
char __attr_unused___ **argv)
{
mem_heap_init (test_native_heap, sizeof (test_native_heap));
TEST_RANDOMIZE ();
srand ((unsigned int) time (NULL));
int k = rand ();
printf ("seed=%d\n", k);
srand ((unsigned int) k);
mem_heap_init (test_native_heap, sizeof (test_native_heap));
mem_register_a_try_give_memory_back_callback (test_heap_give_some_memory_back);

View File

@ -16,17 +16,7 @@
#include "ecma-helpers.h"
#include "lit-literal.h"
extern "C"
{
extern void srand (unsigned int __seed);
extern int rand (void);
extern long int time (long int *__timer);
extern int printf (__const char *__restrict __format, ...);
extern void *memset (void *__s, int __c, size_t __n);
}
// Heap size is 32K
#define test_heap_size (32 * 1024)
#include "test-common.h"
// Iterations count
#define test_iters 64
@ -68,6 +58,8 @@ int
main (int __attr_unused___ argc,
char __attr_unused___ **argv)
{
TEST_RANDOMIZE ();
const ecma_char_t *ptrs[test_sub_iters];
ecma_number_t numbers[test_sub_iters];
ecma_char_t strings[test_sub_iters][max_characters_in_string + 1];
@ -76,10 +68,6 @@ main (int __attr_unused___ argc,
mem_init ();
lit_init ();
srand ((unsigned int) time (NULL));
int k = rand ();
printf ("seed=%d\n", k);
srand ((unsigned int) k);
for (uint32_t i = 0; i < test_iters; i++)
{

View File

@ -13,12 +13,10 @@
* limitations under the License.
*/
#include <math.h>
#include <string.h>
#include "ecma-globals.h"
#include "ecma-helpers.h"
#include "jrt.h"
#include "test-common.h"
/**
* Unit test's main function.

View File

@ -13,15 +13,55 @@
* limitations under the License.
*/
#include <string.h>
#include "jrt.h"
#include "mem-allocator.h"
#include "opcodes.h"
#include "common.h"
#include "parser.h"
#include "serializer.h"
#include "test-common.h"
#define NAME_TO_ID(op) (__op__idx_##op)
#define __OPCODE_SIZE(name, arg1, arg2, arg3) \
(uint8_t) (sizeof (__op_##name) + 1),
static uint8_t opcode_sizes[] =
{
OP_LIST (OPCODE_SIZE)
0
};
static bool
opcodes_equal (const opcode_t *opcodes1, opcode_t *opcodes2, uint16_t size)
{
uint16_t i;
for (i = 0; i < size; i++)
{
uint8_t opcode_num1 = opcodes1[i].op_idx, opcode_num2 = opcodes2[i].op_idx;
uint8_t j;
if (opcode_num1 != opcode_num2)
{
return false;
}
if (opcode_num1 == NAME_TO_ID (nop) || opcode_num1 == NAME_TO_ID (ret))
{
return true;
}
for (j = 1; j < opcode_sizes[opcode_num1]; j++)
{
if (((uint8_t*)&opcodes1[i])[j] != ((uint8_t*)&opcodes2[i])[j])
{
return false;
}
}
}
return true;
}
/**
* Unit test's main function.
*/

View File

@ -15,19 +15,11 @@
#define JERRY_MEM_POOL_INTERNAL
#include "jrt.h"
#include "mem-allocator.h"
#include "mem-pool.h"
#include "mem-poolman.h"
extern "C"
{
extern void srand (unsigned int __seed);
extern int rand (void);
extern long int time (long int *__timer);
extern int printf (__const char *__restrict __format, ...);
extern void *memset (void *__s, int __c, size_t __n);
}
#include "test-common.h"
// Iterations count
const uint32_t test_iters = 64;
@ -45,10 +37,7 @@ int
main (int __attr_unused___ argc,
char __attr_unused___ **argv)
{
srand ((unsigned int) time (NULL));
int k = rand ();
printf ("seed=%d\n", k);
srand ((unsigned int) k);
TEST_RANDOMIZE ();
for (uint32_t i = 0; i < test_iters; i++)
{

View File

@ -17,18 +17,14 @@
* Unit test for pool manager.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define JERRY_MEM_POOL_INTERNAL
#include "jrt.h"
#include "mem-allocator.h"
#include "mem-pool.h"
#include "mem-poolman.h"
#include "test-common.h"
// Iterations count
const uint32_t test_iters = 16384;
@ -41,12 +37,9 @@ int
main (int __attr_unused___ argc,
char __attr_unused___ **argv)
{
mem_init ();
TEST_RANDOMIZE ();
srand ((unsigned int) time (NULL));
unsigned int seed = (unsigned int) rand ();
printf ("seed=%u\n", seed);
srand (seed);
mem_init ();
for (uint32_t i = 0; i < test_iters; i++)
{

View File

@ -13,18 +13,10 @@
* limitations under the License.
*/
#include "jrt.h"
#include "mem-allocator.h"
#include "rcs-recordset.h"
extern "C"
{
extern void srand (unsigned int __seed);
extern int rand (void);
extern long int time (long int *__timer);
extern int printf (__const char *__restrict __format, ...);
extern void *memset (void *__s, int __c, size_t __n);
}
#include "test-common.h"
// Heap size is 32K
#define test_heap_size (32 * 1024)
@ -221,10 +213,7 @@ int
main (int __attr_unused___ argc,
char __attr_unused___ **argv)
{
srand ((unsigned int) time (NULL));
int k = rand ();
printf ("seed=%d\n", k);
srand ((unsigned int) k);
TEST_RANDOMIZE ();
mem_init ();

View File

@ -13,11 +13,10 @@
* limitations under the License.
*/
#include <math.h>
#include "ecma-globals.h"
#include "ecma-helpers.h"
#include "jrt.h"
#include "test-common.h"
/**
* Unit test's main function.

View File

@ -30,7 +30,7 @@ done
rm -f $DIR/unit_tests_run.log
UNITTESTS=$(ls $DIR/unit_*)
UNITTESTS=$(ls $DIR/unit-*)
for unit_test in $UNITTESTS;
do