Javascript V8 Testing Framework

Tags: v8, v8-testing

Introduction

Testing can improve quality of a product in great deal. v8 includes a number of tests as part of testing framework. A common approach of running test is to run following command after a build,

$ gmake check

run-tests.py Usage

Testing assembler etc.

Here is an exmaple how to test the assembler,

$ tools/run-tests.py --arch-and-mode=x64.debug cctest/test-assembler-x64

Here is an exmaple how to test the macro-assembler,

$ tools/run-tests.py --arch-and-mode=x64.debug cctest/test-macro-assembler-x64

run-tests.py Internals

These are 3 commands run by tools/run-tests.py

Command example for test RunRoundUint64ToFloat32:

out/x64.debug/cctest --random-seed=-369729308 test-run-machops/\
RunRoundUint64ToFloat32 --nohard-abort --nodead-code-elimination --nofold-\
constants --enable-slow-asserts --debug-code --verify-heap

out/x64.debug/cctest --random-seed=-369729308 --ignition-staging \
test-run-machops/RunRoundUint64ToFloat32 --nohard-abort --nodead-code-\
elimination --nofold-constants --enable-slow-asserts --debug-code \
--verify-heap
out/x64.debug/cctest --random-seed=-369729308 --turbo \
test-run-machops/RunRoundUint64ToFloat32 --nohard-abort --nodead-code-\
elimination --nofold-constants --enable-slow-asserts --debug-code \
--verify-heap

List of some available tests

tools/run-tests.py --arch-and-mode=x64.debug cctest/test-run-machops/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-run-load-store/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-run-native-calls/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-run-stackcheck/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/function-tester/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-basic-block-profiler/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-branch-combine/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-code-assembler/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-gap-resolver/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-graph-visualizer/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-instruction/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-js-constant-cache/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-js-context-specialization/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-js-typed-lowering/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-jump-threading/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-linkage/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-loop-analysis/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-loop-assignment-analysis/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-machine-operator-reducer/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-multiple-return/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-node/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-operator/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-representation-change/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-run-bytecode-graph-builder/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-run-calls-to-external-references/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-run-deopt/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-run-inlining/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-run-intrinsics/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-run-jsbranches/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-run-jscalls/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-run-jsexceptions/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-run-jsobjects/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-run-jsops/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-run-stubs/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-run-unwinding-info/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-run-unwinding-info/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-run-unwinding-info
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-run-variables/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-run-wasm-machops/*
tools/run-tests.py --arch-and-mode=x64.debug cctest/test-compiler/*

Enabling Tests on a New Platform

Fixing cctest.gyp

On a new platform/architecture /test/cctest/cctest.gyp needs to be modifed to include the test files,

['v8_target_arch=="NEW_ARCH64"', {
  'sources': [  ### gcmole(arch:NEW_ARCH64) ###
    'test-assembler-NEW_ARCH64.cc',
    'test-macro-assembler-NEW_ARCH64.cc',
    'test-code-stubs.cc',
    'test-disasm-NEW_ARCH64.cc'
  ],
}],

Fixing run-tests.py

On a new platform/architecture run-tests.py might complain like this,

Unknown architecture NEW_ARCH_64
Usage: run-tests.py [options] [tests]

TESTS: ['mjsunit', 'cctest', 'fuzzer', 'message', 'preparser', 'intl',
'unittests', 'inspector_protocol_parser_test']

Options:
  -h, --help            show this help message and exit
  --arch=ARCH           The architecture to run tests for, 'auto' or 'native'
                        for auto-detect: ['android_arm', 'android_arm64',
                        'android_ia32', 'android_x64', 'arm', 'ia32', 'x8

An one line addition in SUPPORTED_ARCHS in file tools/run-tests.py will fix this.

References

  1. Google V8 Testing

Comments