Best Python code snippet using autotest_python
v8heapconst.py
Source:v8heapconst.py  
1# Copyright 2019 the V8 project authors. All rights reserved.2# Use of this source code is governed by a BSD-style license that can3# be found in the LICENSE file.4# This file is automatically generated by mkgrokdump and should not5# be modified manually.6# List of known V8 instance types.7INSTANCE_TYPES = {8  0: "INTERNALIZED_STRING_TYPE",9  2: "EXTERNAL_INTERNALIZED_STRING_TYPE",10  8: "ONE_BYTE_INTERNALIZED_STRING_TYPE",11  10: "EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE",12  18: "UNCACHED_EXTERNAL_INTERNALIZED_STRING_TYPE",13  26: "UNCACHED_EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE",14  32: "STRING_TYPE",15  33: "CONS_STRING_TYPE",16  34: "EXTERNAL_STRING_TYPE",17  35: "SLICED_STRING_TYPE",18  37: "THIN_STRING_TYPE",19  40: "ONE_BYTE_STRING_TYPE",20  41: "CONS_ONE_BYTE_STRING_TYPE",21  42: "EXTERNAL_ONE_BYTE_STRING_TYPE",22  43: "SLICED_ONE_BYTE_STRING_TYPE",23  45: "THIN_ONE_BYTE_STRING_TYPE",24  50: "UNCACHED_EXTERNAL_STRING_TYPE",25  58: "UNCACHED_EXTERNAL_ONE_BYTE_STRING_TYPE",26  64: "SYMBOL_TYPE",27  65: "BIG_INT_BASE_TYPE",28  66: "HEAP_NUMBER_TYPE",29  67: "ODDBALL_TYPE",30  68: "ABSTRACT_INTERNAL_CLASS_SUBCLASS1_TYPE",31  69: "ABSTRACT_INTERNAL_CLASS_SUBCLASS2_TYPE",32  70: "FOREIGN_TYPE",33  71: "PROMISE_FULFILL_REACTION_JOB_TASK_TYPE",34  72: "PROMISE_REJECT_REACTION_JOB_TASK_TYPE",35  73: "CALLABLE_TASK_TYPE",36  74: "CALLBACK_TASK_TYPE",37  75: "PROMISE_RESOLVE_THENABLE_JOB_TASK_TYPE",38  76: "LOAD_HANDLER_TYPE",39  77: "STORE_HANDLER_TYPE",40  78: "FUNCTION_TEMPLATE_INFO_TYPE",41  79: "OBJECT_TEMPLATE_INFO_TYPE",42  80: "ACCESS_CHECK_INFO_TYPE",43  81: "ACCESSOR_INFO_TYPE",44  82: "ACCESSOR_PAIR_TYPE",45  83: "ALIASED_ARGUMENTS_ENTRY_TYPE",46  84: "ALLOCATION_MEMENTO_TYPE",47  85: "ALLOCATION_SITE_TYPE",48  86: "ARRAY_BOILERPLATE_DESCRIPTION_TYPE",49  87: "ASM_WASM_DATA_TYPE",50  88: "ASYNC_GENERATOR_REQUEST_TYPE",51  89: "BREAK_POINT_TYPE",52  90: "BREAK_POINT_INFO_TYPE",53  91: "CACHED_TEMPLATE_OBJECT_TYPE",54  92: "CALL_HANDLER_INFO_TYPE",55  93: "CLASS_POSITIONS_TYPE",56  94: "DEBUG_INFO_TYPE",57  95: "ENUM_CACHE_TYPE",58  96: "FEEDBACK_CELL_TYPE",59  97: "FUNCTION_TEMPLATE_RARE_DATA_TYPE",60  98: "INTERCEPTOR_INFO_TYPE",61  99: "INTERPRETER_DATA_TYPE",62  100: "PROMISE_CAPABILITY_TYPE",63  101: "PROMISE_REACTION_TYPE",64  102: "PROPERTY_DESCRIPTOR_OBJECT_TYPE",65  103: "PROTOTYPE_INFO_TYPE",66  104: "SCRIPT_TYPE",67  105: "SOURCE_TEXT_MODULE_INFO_ENTRY_TYPE",68  106: "STACK_FRAME_INFO_TYPE",69  107: "STACK_TRACE_FRAME_TYPE",70  108: "TEMPLATE_OBJECT_DESCRIPTION_TYPE",71  109: "TUPLE2_TYPE",72  110: "WASM_CAPI_FUNCTION_DATA_TYPE",73  111: "WASM_DEBUG_INFO_TYPE",74  112: "WASM_EXCEPTION_TAG_TYPE",75  113: "WASM_EXPORTED_FUNCTION_DATA_TYPE",76  114: "WASM_INDIRECT_FUNCTION_TABLE_TYPE",77  115: "WASM_JS_FUNCTION_DATA_TYPE",78  116: "WASM_VALUE_TYPE",79  117: "FIXED_ARRAY_TYPE",80  118: "HASH_TABLE_TYPE",81  119: "EPHEMERON_HASH_TABLE_TYPE",82  120: "GLOBAL_DICTIONARY_TYPE",83  121: "NAME_DICTIONARY_TYPE",84  122: "NUMBER_DICTIONARY_TYPE",85  123: "ORDERED_HASH_MAP_TYPE",86  124: "ORDERED_HASH_SET_TYPE",87  125: "ORDERED_NAME_DICTIONARY_TYPE",88  126: "SIMPLE_NUMBER_DICTIONARY_TYPE",89  127: "STRING_TABLE_TYPE",90  128: "CLOSURE_FEEDBACK_CELL_ARRAY_TYPE",91  129: "OBJECT_BOILERPLATE_DESCRIPTION_TYPE",92  130: "SCOPE_INFO_TYPE",93  131: "SCRIPT_CONTEXT_TABLE_TYPE",94  132: "BYTE_ARRAY_TYPE",95  133: "BYTECODE_ARRAY_TYPE",96  134: "FIXED_DOUBLE_ARRAY_TYPE",97  135: "INTERNAL_CLASS_WITH_SMI_ELEMENTS_TYPE",98  136: "AWAIT_CONTEXT_TYPE",99  137: "BLOCK_CONTEXT_TYPE",100  138: "CATCH_CONTEXT_TYPE",101  139: "DEBUG_EVALUATE_CONTEXT_TYPE",102  140: "EVAL_CONTEXT_TYPE",103  141: "FUNCTION_CONTEXT_TYPE",104  142: "MODULE_CONTEXT_TYPE",105  143: "NATIVE_CONTEXT_TYPE",106  144: "SCRIPT_CONTEXT_TYPE",107  145: "WITH_CONTEXT_TYPE",108  146: "SMALL_ORDERED_HASH_MAP_TYPE",109  147: "SMALL_ORDERED_HASH_SET_TYPE",110  148: "SMALL_ORDERED_NAME_DICTIONARY_TYPE",111  149: "EXPORTED_SUB_CLASS_BASE_TYPE",112  150: "EXPORTED_SUB_CLASS_TYPE",113  151: "SOURCE_TEXT_MODULE_TYPE",114  152: "SYNTHETIC_MODULE_TYPE",115  153: "UNCOMPILED_DATA_WITH_PREPARSE_DATA_TYPE",116  154: "UNCOMPILED_DATA_WITHOUT_PREPARSE_DATA_TYPE",117  155: "WEAK_FIXED_ARRAY_TYPE",118  156: "TRANSITION_ARRAY_TYPE",119  157: "CELL_TYPE",120  158: "CODE_TYPE",121  159: "CODE_DATA_CONTAINER_TYPE",122  160: "COVERAGE_INFO_TYPE",123  161: "DESCRIPTOR_ARRAY_TYPE",124  162: "EMBEDDER_DATA_ARRAY_TYPE",125  163: "FEEDBACK_METADATA_TYPE",126  164: "FEEDBACK_VECTOR_TYPE",127  165: "FILLER_TYPE",128  166: "FREE_SPACE_TYPE",129  167: "INTERNAL_CLASS_TYPE",130  168: "INTERNAL_CLASS_WITH_STRUCT_ELEMENTS_TYPE",131  169: "MAP_TYPE",132  170: "PREPARSE_DATA_TYPE",133  171: "PROPERTY_ARRAY_TYPE",134  172: "PROPERTY_CELL_TYPE",135  173: "SHARED_FUNCTION_INFO_TYPE",136  174: "SMI_BOX_TYPE",137  175: "SMI_PAIR_TYPE",138  176: "SORT_STATE_TYPE",139  177: "WASM_ARRAY_TYPE",140  178: "WASM_STRUCT_TYPE",141  179: "WEAK_ARRAY_LIST_TYPE",142  180: "WEAK_CELL_TYPE",143  181: "JS_PROXY_TYPE",144  1057: "JS_OBJECT_TYPE",145  182: "JS_GLOBAL_OBJECT_TYPE",146  183: "JS_GLOBAL_PROXY_TYPE",147  184: "JS_MODULE_NAMESPACE_TYPE",148  1040: "JS_SPECIAL_API_OBJECT_TYPE",149  1041: "JS_PRIMITIVE_WRAPPER_TYPE",150  1042: "JS_MAP_KEY_ITERATOR_TYPE",151  1043: "JS_MAP_KEY_VALUE_ITERATOR_TYPE",152  1044: "JS_MAP_VALUE_ITERATOR_TYPE",153  1045: "JS_SET_KEY_VALUE_ITERATOR_TYPE",154  1046: "JS_SET_VALUE_ITERATOR_TYPE",155  1047: "JS_GENERATOR_OBJECT_TYPE",156  1048: "JS_ASYNC_FUNCTION_OBJECT_TYPE",157  1049: "JS_ASYNC_GENERATOR_OBJECT_TYPE",158  1050: "JS_DATA_VIEW_TYPE",159  1051: "JS_TYPED_ARRAY_TYPE",160  1052: "JS_MAP_TYPE",161  1053: "JS_SET_TYPE",162  1054: "JS_WEAK_MAP_TYPE",163  1055: "JS_WEAK_SET_TYPE",164  1056: "JS_API_OBJECT_TYPE",165  1058: "JS_AGGREGATE_ERROR_TYPE",166  1059: "JS_ARGUMENTS_OBJECT_TYPE",167  1060: "JS_ARRAY_TYPE",168  1061: "JS_ARRAY_BUFFER_TYPE",169  1062: "JS_ARRAY_ITERATOR_TYPE",170  1063: "JS_ASYNC_FROM_SYNC_ITERATOR_TYPE",171  1064: "JS_COLLATOR_TYPE",172  1065: "JS_CONTEXT_EXTENSION_OBJECT_TYPE",173  1066: "JS_DATE_TYPE",174  1067: "JS_DATE_TIME_FORMAT_TYPE",175  1068: "JS_DISPLAY_NAMES_TYPE",176  1069: "JS_ERROR_TYPE",177  1070: "JS_FINALIZATION_REGISTRY_TYPE",178  1071: "JS_LIST_FORMAT_TYPE",179  1072: "JS_LOCALE_TYPE",180  1073: "JS_MESSAGE_OBJECT_TYPE",181  1074: "JS_NUMBER_FORMAT_TYPE",182  1075: "JS_PLURAL_RULES_TYPE",183  1076: "JS_PROMISE_TYPE",184  1077: "JS_REG_EXP_TYPE",185  1078: "JS_REG_EXP_STRING_ITERATOR_TYPE",186  1079: "JS_RELATIVE_TIME_FORMAT_TYPE",187  1080: "JS_SEGMENT_ITERATOR_TYPE",188  1081: "JS_SEGMENTER_TYPE",189  1082: "JS_STRING_ITERATOR_TYPE",190  1083: "JS_V8_BREAK_ITERATOR_TYPE",191  1084: "JS_WEAK_REF_TYPE",192  1085: "WASM_EXCEPTION_OBJECT_TYPE",193  1086: "WASM_GLOBAL_OBJECT_TYPE",194  1087: "WASM_INSTANCE_OBJECT_TYPE",195  1088: "WASM_MEMORY_OBJECT_TYPE",196  1089: "WASM_MODULE_OBJECT_TYPE",197  1090: "WASM_TABLE_OBJECT_TYPE",198  1091: "JS_BOUND_FUNCTION_TYPE",199  1092: "JS_FUNCTION_TYPE",200}201# List of known V8 maps.202KNOWN_MAPS = {203  ("read_only_space", 0x00121): (166, "FreeSpaceMap"),204  ("read_only_space", 0x00149): (169, "MetaMap"),205  ("read_only_space", 0x0018d): (67, "NullMap"),206  ("read_only_space", 0x001c5): (161, "DescriptorArrayMap"),207  ("read_only_space", 0x001f5): (155, "WeakFixedArrayMap"),208  ("read_only_space", 0x0021d): (165, "OnePointerFillerMap"),209  ("read_only_space", 0x00245): (165, "TwoPointerFillerMap"),210  ("read_only_space", 0x00289): (67, "UninitializedMap"),211  ("read_only_space", 0x002cd): (8, "OneByteInternalizedStringMap"),212  ("read_only_space", 0x00329): (67, "UndefinedMap"),213  ("read_only_space", 0x0035d): (66, "HeapNumberMap"),214  ("read_only_space", 0x003a1): (67, "TheHoleMap"),215  ("read_only_space", 0x00401): (67, "BooleanMap"),216  ("read_only_space", 0x00489): (132, "ByteArrayMap"),217  ("read_only_space", 0x004b1): (117, "FixedArrayMap"),218  ("read_only_space", 0x004d9): (117, "FixedCOWArrayMap"),219  ("read_only_space", 0x00501): (118, "HashTableMap"),220  ("read_only_space", 0x00529): (64, "SymbolMap"),221  ("read_only_space", 0x00551): (40, "OneByteStringMap"),222  ("read_only_space", 0x00579): (130, "ScopeInfoMap"),223  ("read_only_space", 0x005a1): (173, "SharedFunctionInfoMap"),224  ("read_only_space", 0x005c9): (158, "CodeMap"),225  ("read_only_space", 0x005f1): (157, "CellMap"),226  ("read_only_space", 0x00619): (172, "GlobalPropertyCellMap"),227  ("read_only_space", 0x00641): (70, "ForeignMap"),228  ("read_only_space", 0x00669): (156, "TransitionArrayMap"),229  ("read_only_space", 0x00691): (45, "ThinOneByteStringMap"),230  ("read_only_space", 0x006b9): (164, "FeedbackVectorMap"),231  ("read_only_space", 0x0070d): (67, "ArgumentsMarkerMap"),232  ("read_only_space", 0x0076d): (67, "ExceptionMap"),233  ("read_only_space", 0x007c9): (67, "TerminationExceptionMap"),234  ("read_only_space", 0x00831): (67, "OptimizedOutMap"),235  ("read_only_space", 0x00891): (67, "StaleRegisterMap"),236  ("read_only_space", 0x008d5): (131, "ScriptContextTableMap"),237  ("read_only_space", 0x008fd): (128, "ClosureFeedbackCellArrayMap"),238  ("read_only_space", 0x00925): (163, "FeedbackMetadataArrayMap"),239  ("read_only_space", 0x0094d): (117, "ArrayListMap"),240  ("read_only_space", 0x00975): (65, "BigIntMap"),241  ("read_only_space", 0x0099d): (129, "ObjectBoilerplateDescriptionMap"),242  ("read_only_space", 0x009c5): (133, "BytecodeArrayMap"),243  ("read_only_space", 0x009ed): (159, "CodeDataContainerMap"),244  ("read_only_space", 0x00a15): (160, "CoverageInfoMap"),245  ("read_only_space", 0x00a3d): (134, "FixedDoubleArrayMap"),246  ("read_only_space", 0x00a65): (120, "GlobalDictionaryMap"),247  ("read_only_space", 0x00a8d): (96, "ManyClosuresCellMap"),248  ("read_only_space", 0x00ab5): (117, "ModuleInfoMap"),249  ("read_only_space", 0x00add): (121, "NameDictionaryMap"),250  ("read_only_space", 0x00b05): (96, "NoClosuresCellMap"),251  ("read_only_space", 0x00b2d): (122, "NumberDictionaryMap"),252  ("read_only_space", 0x00b55): (96, "OneClosureCellMap"),253  ("read_only_space", 0x00b7d): (123, "OrderedHashMapMap"),254  ("read_only_space", 0x00ba5): (124, "OrderedHashSetMap"),255  ("read_only_space", 0x00bcd): (125, "OrderedNameDictionaryMap"),256  ("read_only_space", 0x00bf5): (170, "PreparseDataMap"),257  ("read_only_space", 0x00c1d): (171, "PropertyArrayMap"),258  ("read_only_space", 0x00c45): (92, "SideEffectCallHandlerInfoMap"),259  ("read_only_space", 0x00c6d): (92, "SideEffectFreeCallHandlerInfoMap"),260  ("read_only_space", 0x00c95): (92, "NextCallSideEffectFreeCallHandlerInfoMap"),261  ("read_only_space", 0x00cbd): (126, "SimpleNumberDictionaryMap"),262  ("read_only_space", 0x00ce5): (117, "SloppyArgumentsElementsMap"),263  ("read_only_space", 0x00d0d): (146, "SmallOrderedHashMapMap"),264  ("read_only_space", 0x00d35): (147, "SmallOrderedHashSetMap"),265  ("read_only_space", 0x00d5d): (148, "SmallOrderedNameDictionaryMap"),266  ("read_only_space", 0x00d85): (151, "SourceTextModuleMap"),267  ("read_only_space", 0x00dad): (127, "StringTableMap"),268  ("read_only_space", 0x00dd5): (152, "SyntheticModuleMap"),269  ("read_only_space", 0x00dfd): (154, "UncompiledDataWithoutPreparseDataMap"),270  ("read_only_space", 0x00e25): (153, "UncompiledDataWithPreparseDataMap"),271  ("read_only_space", 0x00e4d): (179, "WeakArrayListMap"),272  ("read_only_space", 0x00e75): (119, "EphemeronHashTableMap"),273  ("read_only_space", 0x00e9d): (162, "EmbedderDataArrayMap"),274  ("read_only_space", 0x00ec5): (180, "WeakCellMap"),275  ("read_only_space", 0x00eed): (32, "StringMap"),276  ("read_only_space", 0x00f15): (41, "ConsOneByteStringMap"),277  ("read_only_space", 0x00f3d): (33, "ConsStringMap"),278  ("read_only_space", 0x00f65): (37, "ThinStringMap"),279  ("read_only_space", 0x00f8d): (35, "SlicedStringMap"),280  ("read_only_space", 0x00fb5): (43, "SlicedOneByteStringMap"),281  ("read_only_space", 0x00fdd): (34, "ExternalStringMap"),282  ("read_only_space", 0x01005): (42, "ExternalOneByteStringMap"),283  ("read_only_space", 0x0102d): (50, "UncachedExternalStringMap"),284  ("read_only_space", 0x01055): (0, "InternalizedStringMap"),285  ("read_only_space", 0x0107d): (2, "ExternalInternalizedStringMap"),286  ("read_only_space", 0x010a5): (10, "ExternalOneByteInternalizedStringMap"),287  ("read_only_space", 0x010cd): (18, "UncachedExternalInternalizedStringMap"),288  ("read_only_space", 0x010f5): (26, "UncachedExternalOneByteInternalizedStringMap"),289  ("read_only_space", 0x0111d): (58, "UncachedExternalOneByteStringMap"),290  ("read_only_space", 0x01145): (67, "SelfReferenceMarkerMap"),291  ("read_only_space", 0x01179): (95, "EnumCacheMap"),292  ("read_only_space", 0x011c9): (86, "ArrayBoilerplateDescriptionMap"),293  ("read_only_space", 0x012c5): (98, "InterceptorInfoMap"),294  ("read_only_space", 0x03335): (71, "PromiseFulfillReactionJobTaskMap"),295  ("read_only_space", 0x0335d): (72, "PromiseRejectReactionJobTaskMap"),296  ("read_only_space", 0x03385): (73, "CallableTaskMap"),297  ("read_only_space", 0x033ad): (74, "CallbackTaskMap"),298  ("read_only_space", 0x033d5): (75, "PromiseResolveThenableJobTaskMap"),299  ("read_only_space", 0x033fd): (78, "FunctionTemplateInfoMap"),300  ("read_only_space", 0x03425): (79, "ObjectTemplateInfoMap"),301  ("read_only_space", 0x0344d): (80, "AccessCheckInfoMap"),302  ("read_only_space", 0x03475): (81, "AccessorInfoMap"),303  ("read_only_space", 0x0349d): (82, "AccessorPairMap"),304  ("read_only_space", 0x034c5): (83, "AliasedArgumentsEntryMap"),305  ("read_only_space", 0x034ed): (84, "AllocationMementoMap"),306  ("read_only_space", 0x03515): (87, "AsmWasmDataMap"),307  ("read_only_space", 0x0353d): (88, "AsyncGeneratorRequestMap"),308  ("read_only_space", 0x03565): (89, "BreakPointMap"),309  ("read_only_space", 0x0358d): (90, "BreakPointInfoMap"),310  ("read_only_space", 0x035b5): (91, "CachedTemplateObjectMap"),311  ("read_only_space", 0x035dd): (93, "ClassPositionsMap"),312  ("read_only_space", 0x03605): (94, "DebugInfoMap"),313  ("read_only_space", 0x0362d): (97, "FunctionTemplateRareDataMap"),314  ("read_only_space", 0x03655): (99, "InterpreterDataMap"),315  ("read_only_space", 0x0367d): (100, "PromiseCapabilityMap"),316  ("read_only_space", 0x036a5): (101, "PromiseReactionMap"),317  ("read_only_space", 0x036cd): (102, "PropertyDescriptorObjectMap"),318  ("read_only_space", 0x036f5): (103, "PrototypeInfoMap"),319  ("read_only_space", 0x0371d): (104, "ScriptMap"),320  ("read_only_space", 0x03745): (105, "SourceTextModuleInfoEntryMap"),321  ("read_only_space", 0x0376d): (106, "StackFrameInfoMap"),322  ("read_only_space", 0x03795): (107, "StackTraceFrameMap"),323  ("read_only_space", 0x037bd): (108, "TemplateObjectDescriptionMap"),324  ("read_only_space", 0x037e5): (109, "Tuple2Map"),325  ("read_only_space", 0x0380d): (110, "WasmCapiFunctionDataMap"),326  ("read_only_space", 0x03835): (111, "WasmDebugInfoMap"),327  ("read_only_space", 0x0385d): (112, "WasmExceptionTagMap"),328  ("read_only_space", 0x03885): (113, "WasmExportedFunctionDataMap"),329  ("read_only_space", 0x038ad): (114, "WasmIndirectFunctionTableMap"),330  ("read_only_space", 0x038d5): (115, "WasmJSFunctionDataMap"),331  ("read_only_space", 0x038fd): (116, "WasmValueMap"),332  ("read_only_space", 0x03925): (167, "InternalClassMap"),333  ("read_only_space", 0x0394d): (175, "SmiPairMap"),334  ("read_only_space", 0x03975): (174, "SmiBoxMap"),335  ("read_only_space", 0x0399d): (149, "ExportedSubClassBaseMap"),336  ("read_only_space", 0x039c5): (150, "ExportedSubClassMap"),337  ("read_only_space", 0x039ed): (68, "AbstractInternalClassSubclass1Map"),338  ("read_only_space", 0x03a15): (69, "AbstractInternalClassSubclass2Map"),339  ("read_only_space", 0x03a3d): (135, "InternalClassWithSmiElementsMap"),340  ("read_only_space", 0x03a65): (168, "InternalClassWithStructElementsMap"),341  ("read_only_space", 0x03a8d): (176, "SortStateMap"),342  ("read_only_space", 0x03ab5): (85, "AllocationSiteWithWeakNextMap"),343  ("read_only_space", 0x03add): (85, "AllocationSiteWithoutWeakNextMap"),344  ("read_only_space", 0x03b05): (76, "LoadHandler1Map"),345  ("read_only_space", 0x03b2d): (76, "LoadHandler2Map"),346  ("read_only_space", 0x03b55): (76, "LoadHandler3Map"),347  ("read_only_space", 0x03b7d): (77, "StoreHandler0Map"),348  ("read_only_space", 0x03ba5): (77, "StoreHandler1Map"),349  ("read_only_space", 0x03bcd): (77, "StoreHandler2Map"),350  ("read_only_space", 0x03bf5): (77, "StoreHandler3Map"),351  ("map_space", 0x00121): (1057, "ExternalMap"),352  ("map_space", 0x00149): (1073, "JSMessageObjectMap"),353}354# List of known V8 objects.355KNOWN_OBJECTS = {356  ("read_only_space", 0x00171): "NullValue",357  ("read_only_space", 0x001b5): "EmptyDescriptorArray",358  ("read_only_space", 0x001ed): "EmptyWeakFixedArray",359  ("read_only_space", 0x0026d): "UninitializedValue",360  ("read_only_space", 0x0030d): "UndefinedValue",361  ("read_only_space", 0x00351): "NanValue",362  ("read_only_space", 0x00385): "TheHoleValue",363  ("read_only_space", 0x003d9): "HoleNanValue",364  ("read_only_space", 0x003e5): "TrueValue",365  ("read_only_space", 0x0044d): "FalseValue",366  ("read_only_space", 0x0047d): "empty_string",367  ("read_only_space", 0x006e1): "EmptyScopeInfo",368  ("read_only_space", 0x006e9): "EmptyFixedArray",369  ("read_only_space", 0x006f1): "ArgumentsMarker",370  ("read_only_space", 0x00751): "Exception",371  ("read_only_space", 0x007ad): "TerminationException",372  ("read_only_space", 0x00815): "OptimizedOut",373  ("read_only_space", 0x00875): "StaleRegister",374  ("read_only_space", 0x0116d): "EmptyEnumCache",375  ("read_only_space", 0x011a1): "EmptyPropertyArray",376  ("read_only_space", 0x011a9): "EmptyByteArray",377  ("read_only_space", 0x011b1): "EmptyObjectBoilerplateDescription",378  ("read_only_space", 0x011bd): "EmptyArrayBoilerplateDescription",379  ("read_only_space", 0x011f1): "EmptyClosureFeedbackCellArray",380  ("read_only_space", 0x011f9): "EmptySloppyArgumentsElements",381  ("read_only_space", 0x01209): "EmptySlowElementDictionary",382  ("read_only_space", 0x0122d): "EmptyOrderedHashMap",383  ("read_only_space", 0x01241): "EmptyOrderedHashSet",384  ("read_only_space", 0x01255): "EmptyFeedbackMetadata",385  ("read_only_space", 0x01261): "EmptyPropertyCell",386  ("read_only_space", 0x01275): "EmptyPropertyDictionary",387  ("read_only_space", 0x0129d): "NoOpInterceptorInfo",388  ("read_only_space", 0x012ed): "EmptyWeakArrayList",389  ("read_only_space", 0x012f9): "InfinityValue",390  ("read_only_space", 0x01305): "MinusZeroValue",391  ("read_only_space", 0x01311): "MinusInfinityValue",392  ("read_only_space", 0x0131d): "SelfReferenceMarker",393  ("read_only_space", 0x0135d): "OffHeapTrampolineRelocationInfo",394  ("read_only_space", 0x01369): "TrampolineTrivialCodeDataContainer",395  ("read_only_space", 0x01375): "TrampolinePromiseRejectionCodeDataContainer",396  ("read_only_space", 0x01381): "GlobalThisBindingScopeInfo",397  ("read_only_space", 0x013b9): "EmptyFunctionScopeInfo",398  ("read_only_space", 0x013e1): "NativeScopeInfo",399  ("read_only_space", 0x013fd): "HashSeed",400  ("old_space", 0x00121): "ArgumentsIteratorAccessor",401  ("old_space", 0x00165): "ArrayLengthAccessor",402  ("old_space", 0x001a9): "BoundFunctionLengthAccessor",403  ("old_space", 0x001ed): "BoundFunctionNameAccessor",404  ("old_space", 0x00231): "ErrorStackAccessor",405  ("old_space", 0x00275): "FunctionArgumentsAccessor",406  ("old_space", 0x002b9): "FunctionCallerAccessor",407  ("old_space", 0x002fd): "FunctionNameAccessor",408  ("old_space", 0x00341): "FunctionLengthAccessor",409  ("old_space", 0x00385): "FunctionPrototypeAccessor",410  ("old_space", 0x003c9): "RegExpResultIndicesAccessor",411  ("old_space", 0x0040d): "StringLengthAccessor",412  ("old_space", 0x00451): "InvalidPrototypeValidityCell",413  ("old_space", 0x00459): "EmptyScript",414  ("old_space", 0x00499): "ManyClosuresCell",415  ("old_space", 0x004a5): "ArrayConstructorProtector",416  ("old_space", 0x004b9): "NoElementsProtector",417  ("old_space", 0x004cd): "IsConcatSpreadableProtector",418  ("old_space", 0x004e1): "ArraySpeciesProtector",419  ("old_space", 0x004f5): "TypedArraySpeciesProtector",420  ("old_space", 0x00509): "PromiseSpeciesProtector",421  ("old_space", 0x0051d): "RegExpSpeciesProtector",422  ("old_space", 0x00531): "StringLengthProtector",423  ("old_space", 0x00545): "ArrayIteratorProtector",424  ("old_space", 0x00559): "ArrayBufferDetachingProtector",425  ("old_space", 0x0056d): "PromiseHookProtector",426  ("old_space", 0x00581): "PromiseResolveProtector",427  ("old_space", 0x00595): "MapIteratorProtector",428  ("old_space", 0x005a9): "PromiseThenProtector",429  ("old_space", 0x005bd): "SetIteratorProtector",430  ("old_space", 0x005d1): "StringIteratorProtector",431  ("old_space", 0x005e5): "SingleCharacterStringCache",432  ("old_space", 0x009ed): "StringSplitCache",433  ("old_space", 0x00df5): "RegExpMultipleCache",434  ("old_space", 0x011fd): "BuiltinsConstantsTable",435  ("old_space", 0x015a1): "AsyncFunctionAwaitRejectSharedFun",436  ("old_space", 0x015c9): "AsyncFunctionAwaitResolveSharedFun",437  ("old_space", 0x015f1): "AsyncGeneratorAwaitRejectSharedFun",438  ("old_space", 0x01619): "AsyncGeneratorAwaitResolveSharedFun",439  ("old_space", 0x01641): "AsyncGeneratorYieldResolveSharedFun",440  ("old_space", 0x01669): "AsyncGeneratorReturnResolveSharedFun",441  ("old_space", 0x01691): "AsyncGeneratorReturnClosedRejectSharedFun",442  ("old_space", 0x016b9): "AsyncGeneratorReturnClosedResolveSharedFun",443  ("old_space", 0x016e1): "AsyncIteratorValueUnwrapSharedFun",444  ("old_space", 0x01709): "PromiseAllResolveElementSharedFun",445  ("old_space", 0x01731): "PromiseAllSettledResolveElementSharedFun",446  ("old_space", 0x01759): "PromiseAllSettledRejectElementSharedFun",447  ("old_space", 0x01781): "PromiseAnyRejectElementSharedFun",448  ("old_space", 0x017a9): "PromiseCapabilityDefaultRejectSharedFun",449  ("old_space", 0x017d1): "PromiseCapabilityDefaultResolveSharedFun",450  ("old_space", 0x017f9): "PromiseCatchFinallySharedFun",451  ("old_space", 0x01821): "PromiseGetCapabilitiesExecutorSharedFun",452  ("old_space", 0x01849): "PromiseThenFinallySharedFun",453  ("old_space", 0x01871): "PromiseThrowerFinallySharedFun",454  ("old_space", 0x01899): "PromiseValueThunkFinallySharedFun",455  ("old_space", 0x018c1): "ProxyRevokeSharedFun",456}457# Lower 32 bits of first page addresses for various heap spaces.458HEAP_FIRST_PAGES = {459  0x08100000: "old_space",460  0x08140000: "map_space",461  0x08040000: "read_only_space",462}463# List of known V8 Frame Markers.464FRAME_MARKERS = (465  "ENTRY",466  "CONSTRUCT_ENTRY",467  "EXIT",468  "OPTIMIZED",469  "WASM",470  "WASM_TO_JS",471  "JS_TO_WASM",472  "WASM_DEBUG_BREAK",473  "C_WASM_ENTRY",474  "WASM_EXIT",475  "WASM_COMPILE_LAZY",476  "INTERPRETED",477  "STUB",478  "BUILTIN_CONTINUATION",479  "JAVA_SCRIPT_BUILTIN_CONTINUATION",480  "JAVA_SCRIPT_BUILTIN_CONTINUATION_WITH_CATCH",481  "INTERNAL",482  "CONSTRUCT",483  "ARGUMENTS_ADAPTOR",484  "BUILTIN",485  "BUILTIN_EXIT",486  "NATIVE",487)...test_read_only.py
Source:test_read_only.py  
1# Copyright (c) 2010-2019 openpyxl2from io import BytesIO3from zipfile import ZipFile4import pytest5from openpyxl.cell.read_only import EMPTY_CELL, ReadOnlyCell6from openpyxl.styles.styleable import StyleArray7@pytest.fixture8def DummyWorkbook():9    class Workbook:10        epoch = None11        _cell_styles = [StyleArray([0, 0, 0, 0, 0, 0, 0, 0, 0])]12        data_only = False13        def __init__(self):14            self.sheetnames = []15            self._archive = ZipFile(BytesIO(), "w")16            self._date_formats = set()17    return Workbook()18@pytest.fixture19def ReadOnlyWorksheet(DummyWorkbook, datadir):20    from .._read_only import ReadOnlyWorksheet21    datadir.chdir()22    wb = DummyWorkbook23    wb._archive.write("sheet_inline_strings.xml", "sheet1.xml")24    ws = ReadOnlyWorksheet(wb, "Sheet", "sheet1.xml", [])25    return ws26class TestReadOnlyWorksheet:27    def test_from_xml(self, ReadOnlyWorksheet):28        ws = ReadOnlyWorksheet29        cells = tuple(ws.iter_rows(min_row=1, min_col=1, max_row=1, max_col=1))30        assert len(cells) == 131        assert cells[0][0].value == "col1"32    @pytest.mark.parametrize("row, column",33                             [34                                 (2, 1),35                                 (3, 1),36                                 (5, 1),37                             ]38                             )39    def test_read_cell_from_empty_row(self, DummyWorkbook, ReadOnlyWorksheet, row, column):40        src = b"""<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">41        <sheetData>42          <row r="2" />43          <row r="4" />44        </sheetData>45        </worksheet>46        """47        wb = DummyWorkbook48        wb._archive.writestr("sheet1.xml", src)49        ws = ReadOnlyWorksheet50        ws._xml = BytesIO(src)51        cell = ws._get_cell(row, column)52        assert cell is EMPTY_CELL53    def test_empty_cell(self, ReadOnlyWorksheet):54        row = [55            {'column':4, 'value':None, 'row':1},56        ]57        ws = ReadOnlyWorksheet58        cells = ws._get_row(row, max_col=4, values_only=True)59        assert cells == (None, None, None, None)60    def test_pad_row_left(self, ReadOnlyWorksheet):61        row = [62            {'column':4, 'value':4,},63            {'column':8, 'value':8,},64        ]65        ws = ReadOnlyWorksheet66        cells = ws._get_row(row, max_col=4, values_only=True)67        assert cells == (None, None, None, 4)68    def test_pad_row(self, ReadOnlyWorksheet):69        row = [70            {'column':4, 'value':4,},71            {'column':8, 'value':8,},72        ]73        ws = ReadOnlyWorksheet74        cells = ws._get_row(row, min_col=4, max_col=8, values_only=True)75        assert cells == (4, None, None, None, 8)76    def test_pad_row_right(self, ReadOnlyWorksheet):77        row = [78            {'column':4, 'value':4},79            {'column':8, 'value':8},80        ]81        ws = ReadOnlyWorksheet82        cells = ws._get_row(row, min_col=6, max_col=10, values_only=True)83        assert cells == (None, None, 8, None, None)84    def test_pad_row_cells(self, ReadOnlyWorksheet):85        row = [86            {'column':4, 'value':4, 'row':2},87            {'column':8, 'value':8, 'row':2},88        ]89        ws = ReadOnlyWorksheet90        cells = ws._get_row(row, min_col=6, max_col=10)91        assert cells == (92            EMPTY_CELL, EMPTY_CELL,93            ReadOnlyCell(ws, 2, 8, 8, 'n', 0),94            EMPTY_CELL, EMPTY_CELL95        )96    def test_read_rows(self, ReadOnlyWorksheet):97        ws = ReadOnlyWorksheet98        rows = ws._cells_by_row(min_row=1, max_row=None, min_col=1, max_col=3, values_only=True)99        rows = list(ws.rows)100        assert len(rows) == 10101    def test_pad_rows_before(self, ReadOnlyWorksheet):102        ws = ReadOnlyWorksheet103        rows = ws._cells_by_row(min_row=8, max_row=10, min_col=1, max_col=3, values_only=True)104        assert list(rows) == [105            (None, None, None),106            (None, None, None),107            (7, 8, 9),108        ]109    def test_pad_rows_after(self, ReadOnlyWorksheet):110        ws = ReadOnlyWorksheet111        rows = ws._cells_by_row(min_row=4, max_row=6, min_col=1, max_col=3, values_only=True)112        assert list(rows) == [113            (7, 8, 9),114            (None, None, None),115            (None, None, None),116        ]117    def test_pad_rows_between(self, ReadOnlyWorksheet):118        ws = ReadOnlyWorksheet119        rows = ws._cells_by_row(min_row=4, max_row=None, min_col=1, max_col=3, values_only=True)120        assert list(rows) == [121            (7, 8, 9),122            (None, None, None),123            (None, None, None),124            (None, None, None),125            (None, None, None),126            (None, None, None),127            (7, 8, 9),128        ]129    def test_pad_rows_bounded(self, ReadOnlyWorksheet):130        ws = ReadOnlyWorksheet131        rows = ws._cells_by_row(min_row=8, max_row=15, min_col=1, max_col=3, values_only=True)132        assert list(rows) == [133            (None, None, None),134            (None, None, None),135            (7, 8, 9),136        ]137    def test_calculate_dimension(self, ReadOnlyWorksheet):138        ws = ReadOnlyWorksheet139        assert ws.calculate_dimension(True) == "A1:C10"140    def test_reset_dimensions(self, ReadOnlyWorksheet):141        ws = ReadOnlyWorksheet142        ws._max_row = 5143        ws._max_column = 10144        ws.reset_dimensions()145        assert ws.max_row is ws.max_column is None146    def test_cell(self, ReadOnlyWorksheet):147        ws = ReadOnlyWorksheet148        c = ws.cell(row=1, column=1)149        assert c.value == "col1"150    def test_iter(self, ReadOnlyWorksheet):151        ws = ReadOnlyWorksheet152        for row in ws:153            pass154        c = row[-1]...SELinuxNeverallowTestGen.py
Source:SELinuxNeverallowTestGen.py  
1#!/usr/bin/env python2import re3import sys4import SELinuxNeverallowTestFrame5usage = "Usage: ./SELinuxNeverallowTestGen.py <input policy file> <output cts java source>"6class NeverallowRule:7    statement = ''8    treble_only = False9    def __init__(self, statement):10        self.statement = statement11        self.treble_only = False12# extract_neverallow_rules - takes an intermediate policy file and pulls out the13# neverallow rules by taking all of the non-commented text between the 'neverallow'14# keyword and a terminating ';'15# returns: a list of rules16def extract_neverallow_rules(policy_file):17    with open(policy_file, 'r') as in_file:18        policy_str = in_file.read()19        # full-Treble only tests are inside sections delimited by BEGIN_TREBLE_ONLY20        # and END_TREBLE_ONLY comments.21        # uncomment TREBLE_ONLY section delimiter lines22        remaining = re.sub(23            r'^\s*#\s*(BEGIN_TREBLE_ONLY|END_TREBLE_ONLY)',24            r'\1',25            policy_str,26            flags = re.M)27        # remove comments28        remaining = re.sub(r'#.+?$', r'', remaining, flags = re.M)29        # match neverallow rules30        lines = re.findall(31            r'^\s*(neverallow\s.+?;|BEGIN_TREBLE_ONLY|END_TREBLE_ONLY)',32            remaining,33            flags = re.M |re.S)34        # extract neverallow rules from the remaining lines35        rules = list()36        treble_only_depth = 037        for line in lines:38            if line.startswith("BEGIN_TREBLE_ONLY"):39                treble_only_depth += 140                continue41            elif line.startswith("END_TREBLE_ONLY"):42                if treble_only_depth < 1:43                    exit("ERROR: END_TREBLE_ONLY outside of TREBLE_ONLY section")44                treble_only_depth -= 145                continue46            rule = NeverallowRule(line)47            rule.treble_only = (treble_only_depth > 0)48            rules.append(rule)49        if treble_only_depth != 0:50            exit("ERROR: end of input while inside TREBLE_ONLY section")51        return rules52# neverallow_rule_to_test - takes a neverallow statement and transforms it into53# the output necessary to form a cts unit test in a java source file.54# returns: a string representing a generic test method based on this rule.55def neverallow_rule_to_test(rule, test_num):56    squashed_neverallow = rule.statement.replace("\n", " ")57    method  = SELinuxNeverallowTestFrame.src_method58    method = method.replace("testNeverallowRules()",59        "testNeverallowRules" + str(test_num) + "()")60    method = method.replace("$NEVERALLOW_RULE_HERE$", squashed_neverallow)61    method = method.replace(62        "$FULL_TREBLE_ONLY_BOOL_HERE$",63        "true" if rule.treble_only else "false")64    return method65if __name__ == "__main__":66    # check usage67    if len(sys.argv) != 3:68        print usage69        exit(1)70    input_file = sys.argv[1]71    output_file = sys.argv[2]72    src_header = SELinuxNeverallowTestFrame.src_header73    src_body = SELinuxNeverallowTestFrame.src_body74    src_footer = SELinuxNeverallowTestFrame.src_footer75    # grab the neverallow rules from the policy file and transform into tests76    neverallow_rules = extract_neverallow_rules(input_file)77    i = 078    for rule in neverallow_rules:79        src_body += neverallow_rule_to_test(rule, i)80        i += 181    with open(output_file, 'w') as out_file:82        out_file.write(src_header)83        out_file.write(src_body)...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
