1# vim: set ts=8 sts=4 et sw=4 tw=99:
2# This Source Code Form is subject to the terms of the Mozilla Public
3# License, v. 2.0. If a copy of the MPL was not distributed with this
4# file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
6# ----------------------------------------------------------------------------
7# This script checks bytecode documentation in js/src/vm/Opcodes.h
8# ----------------------------------------------------------------------------
9
10from __future__ import absolute_import
11from __future__ import print_function
12
13import os
14import sys
15
16scriptname = os.path.basename(__file__)
17topsrcdir = os.path.dirname(os.path.dirname(__file__))
18
19
20def log_pass(text):
21    print("TEST-PASS | {} | {}".format(scriptname, text))
22
23
24def log_fail(text):
25    print("TEST-UNEXPECTED-FAIL | {} | {}".format(scriptname, text))
26
27
28def check_opcode():
29    sys.path.insert(0, os.path.join(topsrcdir, "js", "src", "vm"))
30    import jsopcode
31
32    try:
33        jsopcode.get_opcodes(topsrcdir)
34    except Exception as e:
35        log_fail(e.args[0])
36        return False
37
38    log_pass("ok")
39    return True
40
41
42def main():
43    if not check_opcode():
44        sys.exit(1)
45
46    sys.exit(0)
47
48
49if __name__ == "__main__":
50    main()
51