Switch unit tests to jerry-libc.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
@@ -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
@@ -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 (¤t_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 */
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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++)
|
||||
{
|
||||
|
||||
@@ -37,7 +37,7 @@ int
|
||||
main (int __attr_unused___ argc,
|
||||
char __attr_unused___ **argv)
|
||||
{
|
||||
TEST_RANDOMIZE ();
|
||||
TEST_INIT ();
|
||||
|
||||
mem_init ();
|
||||
|
||||
|
||||
@@ -213,7 +213,7 @@ int
|
||||
main (int __attr_unused___ argc,
|
||||
char __attr_unused___ **argv)
|
||||
{
|
||||
TEST_RANDOMIZE ();
|
||||
TEST_INIT ();
|
||||
|
||||
mem_init ();
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user