Add 'make testparser' option to test parser only
This commit is contained in:
@@ -21,6 +21,7 @@ nbproject
|
||||
# Random Trash
|
||||
*~
|
||||
js.files
|
||||
jerry.error
|
||||
core
|
||||
vgcore.*
|
||||
**.orig
|
||||
|
||||
@@ -46,6 +46,7 @@ export TARGET_SYSTEMS = $(TARGET_PC_SYSTEMS) $(TARGET_MCU_SYSTEMS)
|
||||
# Target list
|
||||
export JERRY_TARGETS = $(foreach __MODE,$(TARGET_MODES),$(foreach __SYSTEM,$(TARGET_SYSTEMS),$(__MODE).$(__SYSTEM)))
|
||||
export TESTS_TARGET = unittests
|
||||
export PARSER_TESTS_TARGET = testparser
|
||||
export CHECK_TARGETS = $(foreach __TARGET,$(JERRY_TARGETS),$(__TARGET).check)
|
||||
export FLASH_TARGETS = $(foreach __TARGET,$(foreach __MODE,$(TARGET_MODES),$(foreach __SYSTEM,$(TARGET_MCU_SYSTEMS),$(__MODE).$(__SYSTEM))),$(__TARGET).flash)
|
||||
|
||||
@@ -56,7 +57,7 @@ export dwarf4
|
||||
|
||||
all: clean $(JERRY_TARGETS) $(TESTS_TARGET) $(CHECK_TARGETS)
|
||||
|
||||
$(JERRY_TARGETS) $(TESTS_TARGET) $(FLASH_TARGETS) $(CHECK_TARGETS):
|
||||
$(JERRY_TARGETS) $(TESTS_TARGET) $(PARSER_TESTS_TARGET) $(FLASH_TARGETS) $(CHECK_TARGETS):
|
||||
@echo $@
|
||||
@$(MAKE) -f Makefile.mak TARGET=$@ $@
|
||||
|
||||
|
||||
@@ -37,6 +37,11 @@ ifeq ($(TARGET_MODE),$(TESTS_TARGET))
|
||||
TARGET_SYSTEM = linux
|
||||
endif
|
||||
|
||||
# parse-only mode -> linux system
|
||||
ifeq ($(TARGET_MODE),$(PARSER_TESTS_TARGET))
|
||||
TARGET_SYSTEM = linux
|
||||
endif
|
||||
|
||||
#
|
||||
# Options setup
|
||||
#
|
||||
@@ -284,6 +289,13 @@ $(TESTS_TARGET):
|
||||
@ echo Done
|
||||
@ echo
|
||||
|
||||
$(PARSER_TESTS_TARGET): debug.$(TARGET_SYSTEM)
|
||||
@mkdir -p $(TARGET_DIR)/check
|
||||
@ echo "=== Running parser tests ==="
|
||||
@ if [ -f $(TARGET_DIR)/$(ENGINE_NAME) ]; then \
|
||||
./tools/jerry_test_parser.sh $(TARGET_DIR)/$(ENGINE_NAME) $(TARGET_DIR)/check; \
|
||||
fi
|
||||
|
||||
$(CHECK_TARGETS): $(TARGET_OF_ACTION)
|
||||
@ make unittests
|
||||
@ mkdir -p $(TARGET_DIR)/check
|
||||
|
||||
+33
-12
@@ -30,15 +30,15 @@
|
||||
#define MAX_STRINGS 100
|
||||
#define MAX_NUMS 25
|
||||
|
||||
static const OPCODE *opcodes;
|
||||
|
||||
static void
|
||||
jerry_run( const char *script_source,
|
||||
size_t script_source_size __unused)
|
||||
parser_run (const char *script_source, size_t script_source_size __unused)
|
||||
{
|
||||
const char *strings[MAX_STRINGS];
|
||||
int32_t nums[MAX_NUMS];
|
||||
uint8_t strings_num, nums_count;
|
||||
uint8_t offset;
|
||||
const OPCODE *opcodes;
|
||||
|
||||
mem_init();
|
||||
|
||||
@@ -65,7 +65,12 @@ jerry_run( const char *script_source,
|
||||
#ifdef __HOST
|
||||
serializer_print_opcodes ();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
jerry_run (const char *script_source, size_t script_source_size)
|
||||
{
|
||||
parser_run (script_source, script_source_size);
|
||||
init_int (opcodes);
|
||||
run_int ();
|
||||
} /* jerry_run */
|
||||
@@ -124,16 +129,26 @@ main (int argc __unused,
|
||||
char **argv __unused)
|
||||
{
|
||||
const char *file_name = NULL;
|
||||
bool parse_only = false;
|
||||
int i;
|
||||
|
||||
if (argc > 2)
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
jerry_exit (ERR_SEVERAL_FILES);
|
||||
if (!__strcmp ("--parse-only", argv[i]))
|
||||
{
|
||||
parse_only = true;
|
||||
}
|
||||
else if (file_name)
|
||||
{
|
||||
jerry_exit (ERR_SEVERAL_FILES);
|
||||
}
|
||||
else
|
||||
{
|
||||
file_name = argv[i];
|
||||
}
|
||||
}
|
||||
else if (argc == 2)
|
||||
{
|
||||
file_name = argv[1];
|
||||
}
|
||||
else
|
||||
|
||||
if (!file_name)
|
||||
{
|
||||
jerry_exit (ERR_NO_FILES);
|
||||
}
|
||||
@@ -141,8 +156,14 @@ main (int argc __unused,
|
||||
size_t source_size;
|
||||
const char *source_p = read_source( file_name, &source_size);
|
||||
|
||||
jerry_run( source_p,
|
||||
source_size);
|
||||
if (parse_only)
|
||||
{
|
||||
parser_run (source_p, source_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
jerry_run (source_p, source_size);
|
||||
}
|
||||
|
||||
mem_heap_print( false, false, true);
|
||||
|
||||
|
||||
Executable
+86
@@ -0,0 +1,86 @@
|
||||
# Copyright 2014 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.
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
TIMEOUT=3
|
||||
|
||||
START_DIR=`pwd`
|
||||
|
||||
ENGINE=$START_DIR/$1
|
||||
OUT_DIR=$2
|
||||
|
||||
|
||||
cd $OUT_DIR
|
||||
|
||||
JS_FILES=js.files
|
||||
JERRY_ERROR=jerry.error
|
||||
|
||||
rm -f $JS_FILES $JERRY_ERROR
|
||||
|
||||
find $START_DIR -name *.js -print > $JS_FILES
|
||||
total=$(cat $JS_FILES | wc -l)
|
||||
|
||||
tested=0
|
||||
failed=0
|
||||
passed=0
|
||||
|
||||
exec 2>/dev/null 3>/dev/stderr
|
||||
|
||||
echo " Passed / Failed / Tested / Total / Percent"
|
||||
|
||||
for test in `cat $JS_FILES`
|
||||
do
|
||||
percent=$(echo $tested*100/$total | bc)
|
||||
|
||||
( ulimit -t $TIMEOUT;
|
||||
${ENGINE} ${test} --parse-only > /dev/null;
|
||||
exit $? );
|
||||
status_code=$?
|
||||
|
||||
printf "\r\e[2K[ %6d / %6d / %6d / %5d / %3d%% ]" ${passed} ${failed} ${tested} ${total} ${percent}
|
||||
|
||||
if [ $status_code -ne 0 ]
|
||||
then
|
||||
echo "$status_code: ${test}" >> $JERRY_ERROR
|
||||
|
||||
failed=$((failed+1))
|
||||
else
|
||||
passed=$((passed+1))
|
||||
fi
|
||||
|
||||
tested=$((tested+1))
|
||||
done
|
||||
|
||||
exec 2>&3 2> /dev/null
|
||||
|
||||
printf "\r\e[2K[ %6d / %6d / %6d / %5d / %3d%% ]\n" ${passed} ${failed} ${tested} ${total} ${percent}
|
||||
|
||||
ratio=$(echo $passed*100/$total | bc)
|
||||
|
||||
echo ==========================
|
||||
echo "Number of tests passed: ${passed}"
|
||||
echo "Number of tests failed: ${failed}"
|
||||
echo --------------------------
|
||||
echo "Total number of tests: ${total}"
|
||||
echo "Passed: ${ratio}%"
|
||||
|
||||
if [ ${failed} -ne 0 ]
|
||||
then
|
||||
echo "See $JERRY_ERROR for details about failures"
|
||||
# FIXME: When all tests will pass
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user