Generate test sequences for code based on directed sequences of code and randomly selected instructions

By inserting random instructions into the directed sequence of the target processing system, a more comprehensive test sequence is generated, which solves the problem of insufficient testing in the existing technology and improves the accuracy and coverage of the test.

CN111090576BActive Publication Date: 2024-10-01ARM LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201910927051.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2018-10-23
Filing Date
2019-09-27
Publication Date
2024-10-01
Estimated Expiration
2039-09-27

AI Technical Summary

Technical Problem

Existing techniques may not fully cover all areas of microarchitectural components when testing a target processing system, especially subsequent entries and combinations of caches and buffers, resulting in less than thorough testing.

Method used

Ensure unpredictability and more comprehensive test coverage of microarchitectural components by generating test sequences based on directed sequence code, inserting randomly selected instructions to simulate more realistic processing.

Benefits of technology

Improves the thoroughness and accuracy of testing of target processing system microarchitectural components, ensuring effective testing of specific desired components while reducing the chance of fault detection due to specific test paths.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111090576B_ABST
    Figure CN111090576B_ABST
Patent Text Reader

Abstract

The present disclosure provides a method, apparatus, and computer program for generating a test sequence of code based on a directed sequence of code and randomly selected instructions. A method, apparatus, and computer program for generating a test sequence 108 of code is described, and the test sequence of code is to be run on a target processing system 106 for testing the target processing system. The test sequence of code is based on one or more directed sequences 102 of code, wherein the one or more directed sequences of code are predetermined sequences of one or more directed instructions for testing a predetermined portion of the target processing system. The method includes: for at least one of the one or more directed sequences of code, inserting randomly selected instructions at one or more insertion points in the directed sequence of code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present technology relates to testing of a target processing system. Background Art

[0002] In many systems, it is useful to be able to test the functional correctness of a processing system, particularly if the target processing system is to be used in a safety-critical environment. For example, testing of a target processing system may involve checking the functionality of various microarchitectural features of the processing system, such as registers, caches, translation lookaside buffers (TLBs), and memory management units (MMUs). Test sequences of code may be executed on the target processing system to test microarchitectural aspects of the target processing system. Summary of the invention

[0003] From a first example of the present technology, a method for generating a test sequence of code is provided, the test sequence of code to be run on a target processing system for testing the target processing system, wherein:

[0004] The test sequence of code is based on one or more directed sequences of code, wherein the one or more directed sequences of code are predetermined sequences of one or more directed instructions for testing a predetermined portion of a target processing system; and

[0005] The method includes: for at least one of the one or more directed sequences of code, inserting randomly selected instructions at one or more insertion points in the directed sequence of code.

[0006] From another example of the present technology, there is provided a computer program which, when executed on a computer, causes the computer to generate a test sequence to be run on a target processing system for testing code of the target processing system, wherein:

[0007] The test sequence of code is based on one or more directed sequences of code, wherein the one or more directed sequences of code are predetermined sequences of one or more directed instructions for testing a predetermined portion of a target processing system; and

[0008] A test sequence of code is generated by inserting randomly selected instructions at one or more insertion points in the directed sequence of code for at least one of the one or more directed sequences of code.

[0009] From another example of the present technology, there is provided a computer-readable storage medium storing the above-mentioned computer program. The storage medium may be a non-transitory storage medium.

[0010] From another example of the present technology, there is provided an apparatus including a test code generating circuit configured to execute the above method.

[0011] From another example of the present technology, a computer-readable storage medium storing a test sequence of a code generated by the method is provided. The storage medium may be a non-transitory storage medium. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] Other aspects, features and advantages of the present technology will become apparent from the following description of examples, which description is to be read in conjunction with the accompanying drawings, in which:

[0013] Figure 1 is a schematic diagram of a system on which the present technology may be implemented;

[0014] Figure 2 is a schematic diagram of an example of a target processing system that may be tested using a test sequence of codes;

[0015] Figure 3 and Figure 4 is a schematic diagram of an example of a portion of a test sequence of a code;

[0016] Figure 5 is a flow chart illustrating an example of a method of generating a test sequence for a code.

[0017] Figure 6 is a schematic diagram of a portion of a test sequence of the code; and

[0018] Figure 7 and Figure 8 is a flow chart illustrating an example of a method of generating a test sequence for a code. DETAILED DESCRIPTION

[0019] Before discussing the embodiments with reference to the accompanying drawings, the following description of exemplary embodiments and associated advantages is provided.

[0020] The target processing system can be tested in a variety of ways. For example, the target processing system can be tested by generating a directed sequence of code to be executed by the target processing system, which is a sequence of instructions intended to test specific architectures or micro-architecture features of the target processing system (e.g., data paths, registers, caches, TLBs, MMUs, memory controllers, out-of-order processing components (e.g., register renaming or reordering buffers, etc.)). The instructions of the directed sequence utilize one or more micro-architecture components of the target processing system, thereby allowing the functions of these components to be observed and compared with expected results. The directed sequence allows specific expected components to be tested; however, the disadvantage of this approach is that the test may not cover some areas of these components. For example, when running a directed sequence of code, only the first few entries of a specific buffer, register, or cache may be filled, and therefore subsequent entries may not be tested. This may also mean that certain combinations of buffers, registers, or cache entries may not be tested.

[0021] According to some examples, methods of the present technology involve generating a test sequence of code to be run on a target processing system based on a directed sequence of one or more codes, the directed sequence of one or more codes being a predetermined sequence of one or more directed instructions for testing a predetermined portion of the target processing system. The test sequence of code is generated by inserting randomly selected instructions into the directed sequence of code at one or more insertion points.

[0022] The test sequence of the generated code is a sequence of instructions generated according to the above method, and is designed to be run on a target processing circuit (target processing system) to test the microarchitecture components of the target processing system. Each insertion point in the directed sequence is before or after a given instruction in the directed sequence of code (although there is not necessarily an insertion point before or after every instruction, such as in the case where two or more instructions need to be executed sequentially), and the randomly selected instructions are selected according to some random parameters - please note that in this application, the word "random" is also intended to cover "pseudo-random" because in practice, it may be unreasonable to incur the cost of providing a true random number generator - a pseudo-random number generator is sufficient.

[0023] The test sequence of generating code based on one or more directed sequences and randomly selected instructions allows better testing of the micro-architecture components of the target processing system, because random instructions ensure more changes in parameters such as cache allocation, buffer occupancy, etc., so that the expected behavior in the actual processing process can be simulated more realistically. By inserting the randomly selected instructions into the directed sequence, the unpredictable (random) sequence of the micro-architecture components can be tested, such as the unpredictable arrangement of the cache / buffer entries of the instructions of the directed sequence. This reduces the possibility that some areas of some micro-architecture features will usually be missed by the test sequence of the code, and also changes the possible combination of the cache and buffer entries to be tested. In addition, different instruction patterns (for example, different random insertions) can be utilized to run the test multiple times, thereby reducing the chance of passing the test for the directed sequence, which is only because the test happens to occur to avoid detecting the corner situation where a fault occurs. Therefore, the target processing system is tested more thoroughly, while still ensuring that the micro-architecture components of specific expectations are tested.

[0024] In some examples, it is useful that the outcome of a directed sequence is not affected by randomly selected instructions.

[0025] For example, the randomly selected instructions may be selected from instructions that meet certain criteria (e.g., instructions that will not cause a fault, do not require specific alignment instructions, and will not cause a base register or program counter to be updated). If the result of executing the directed sequence of instructions is not the expected result, the tester may determine that there is a fault in the target processing system, which would be incorrect if the change in the result was caused by the insertion of the random instructions. Thus, ensuring that the randomly selected instructions do not affect the result of the directed sequence results in a more accurate test of the target processing system.

[0026] In some examples, at least one of the following items is selected based on at least one random number: an instruction type of the randomly selected instruction, a resource referenced by the randomly selected instruction, how many randomly selected instructions to insert, and an insertion point to insert the randomly selected instruction.

[0027] The at least one random number can be a random parameter generated according to any known technology, and it will be appreciated that the random number can be pseudo-random, as described above. The instruction type can include load / store instructions, arithmetic logic instructions, or any other type of instruction. Selecting one or more of the parameters listed above based on the random parameter further increases the unpredictability of the use of the micro-architecture components used during the test, further improving the thoroughness of the test while still testing the predetermined micro-architecture features detected by the directed sequence.

[0028] In some examples, for each insertion point in the directed sequence of code, m randomly selected instructions are inserted at the insertion point in the directed sequence of code, where m≥0.

[0029] Thus, following the above method produces a test sequence of code in which zero to m randomly selected instructions are inserted at each insertion point in the directed sequence, where there may be an insertion point after each instruction in the directed sequence, or there may be an insertion point after a group of two or more instructions. This results in a more thorough test of the target processing system.

[0030] In some examples, resources to be used by the randomly selected instructions are selected such that they are ensured to be different from resources used by instructions in the directed sequence of code.

[0031] This prevents randomly selected instructions from influencing the outcome of a directed sequence of code, improving the accuracy of the test in a similar manner to that described above.

[0032] In some examples, a resource to be used by the randomly selected instruction is selected based on at least one random number.

[0033] Therefore, the resources tested by the test sequence of the code are unpredictable, thereby improving the thoroughness of the test.A random number is a randomly generated or randomly selected number (or pseudo-random number).

[0034] In some examples, before beginning to insert randomly selected instructions into the directed sequence, a list of resources used by instructions in the directed sequence of code is generated.

[0035] This allows resources to be selected for a randomly selected instruction that will not conflict with those used by instructions in a directed sequence by consulting the generated list when selecting the resource. The list may be stored in a data storage location. A separate list may be generated for each directed sequence, or a single list may be generated for multiple directed sequences.

[0036] In some examples, a list of resources used by instructions in a directed sequence of code is maintained, and as each instruction in the directed sequence is encountered, the list of resources is updated to include the resource used by the instruction.

[0037] This is another technique for ensuring that resources selected for randomly selected instructions do not conflict with those used by instructions in the directed sequence. Maintaining such a list of resources "on the fly" as instructions are encountered or parsed allows the generation of a test sequence for a code to begin even before all instructions in the directed sequence of the code have been encountered. This improves the efficiency of generating test sequences.

[0038] In some examples, the resources used by the randomly selected instructions or instructions in the directed sequence of code include at least one of: a set of registers in the target processing system, and a set of memory locations in the target processing system.

[0039] In some examples, the randomly selected instructions are one of: a set of randomly generated instructions, and instructions randomly selected from a set of pre-programmed instructions.

[0040] The randomly generated instructions may be instructions generated according to any known technique, as long as they are generated based on at least one random parameter. The set of pre-programmed instructions may be instructions written by a programmer, or instructions written by a computer program or compiler.

[0041] In some examples, the instructions in the directed sequence of code are preprogrammed by one of: a programmer, a computer program, and a compiler.

[0042] The instructions in the directed sequence are written so that they test a specific desired set of microarchitectural structures within the target processing system.

[0043] In some examples, randomly selected instructions are inserted before or after a directed sequence of code.

[0044] This further increases the unpredictability of microarchitectural operating parameters (e.g., buffer occupancy, cache allocation, register pressure, etc.), thereby further improving the thoroughness of the testing.

[0045] In some examples, the insertion of randomly selected instructions is performed during execution of a test sequence of code.

[0046] In such examples, the insertion of randomly selected instructions is performed "on the fly" during execution of a test sequence by the target processing circuitry.

[0047] In some examples, a computer program is provided that, when executed on a computer, causes the computer to generate a test sequence of code to be run on a target processing system for testing the target processing system. The test sequence of code is based on one or more directed sequences of code, wherein the one or more directed sequences of code are predetermined sequences of one or more directed instructions for testing a predetermined portion of the target processing system, and the test sequence of code is generated by inserting randomly selected instructions at one or more insertion points in the directed sequence of code for at least one of the one or more directed sequences of code.

[0048] In some examples, a computer-readable storage medium for storing the above-described program is provided.

[0049] For example, the storage medium may be a flash drive, a CD or DVD or any other form of non-transitory storage.

[0050] In some examples, an apparatus is provided that includes a test code generation circuit arranged to perform the above method.

[0051] Certain embodiments will now be described with reference to the accompanying drawings.

[0052] Figure 1 is a schematic diagram of a system on which the present technology may be implemented. In particular, Figure 1 A test code generation circuit 100 is shown, which is configured to execute the test code generation method described in the present application.

[0053] The test code generation circuit 100 takes as input at least one directed sequence of code 102 and a set of random instructions 104, wherein the random instructions 104 are one of a set of randomly selected instructions and a set of candidate instructions that can be randomly selected by the test code generation circuit 100. The directed sequence of code 102 includes a sequence of pre-programmed instructions designed to test a predetermined selection of micro-architectural features (e.g., registers, caches, storage locations, etc.) of a target system 106, which is a processing circuit configured to execute instructions. The directed sequence of instructions 102 can be written by a programmer or generated by a computer program and read from a storage medium by the test code generation circuit 100. The random instructions 104 can be instructions selected from a predetermined set of instructions identified by the programmer, or they can instead be randomly generated instructions (wherein "random" should be considered to include "pseudo-random").

[0054] Based on these inputs, the test code generation circuit 100 is configured to generate a test sequence 108 to be executed on the target system 106 to test the code of the target system 106 , as will be explained in more detail below.

[0055] Figure 2 An example of a target data processing apparatus (target processing system) 106 having a processing pipeline including a plurality of pipeline stages is schematically shown. The pipeline includes a branch predictor 204 for predicting the outcome of a branch instruction and generating fetch addresses for a series of instructions to be fetched.

[0056] The pipeline also includes a fetch unit 206 that fetches instructions from an instruction cache 208 or other memory structures 232, 234. The fetch stage 206 fetches instructions identified by a fetch address, and the decode stage 210 decodes the fetched instructions to generate control information for controlling subsequent stages of the pipeline.

[0057] The rename stage 212 performs register renaming to map architectural register indicators identified by instructions to physical register indicators identifying registers 214 provided in the hardware. The issue stage 216 includes an issue queue that queues instructions waiting to be executed until the required operands for processing the instructions are available in registers 214, and selection circuitry for selecting instructions for execution by the execute stage 218. The execute stage 218 executes the instructions to perform the corresponding processing operations, and the write-back stage 220 writes the results of the executed instructions back to the registers 214.

[0058] The execution stage 218 may include a plurality of execution units, such as a branch unit 221 for evaluating whether a branch instruction has been correctly predicted, an ALU (arithmetic logic unit) 222 for performing arithmetic or logic operations, a floating point unit 224 for performing operations using floating point operands, and a load / store unit 226 for performing a load operation to load data from a memory system to a register 214 or performing a store operation to store data from a register 214 to a memory system. In this example, the memory system includes a level 1 instruction cache 208, a level 1 data cache 230, a level 2 cache 232 shared between data and instructions, and a main memory 234, but it should be understood that this is only one example of a possible memory hierarchy, and other implementations may have more levels of cache or different arrangements. A memory management unit (MMU) 235 for controlling address translation and / or memory protection may be used to control access to the memory. The load / store unit 226 may use the translation lookaside buffer 236 of the MMU 235 to map the virtual addresses generated by the pipeline to physical addresses identifying locations within the memory system. It should be appreciated that Figure 2 The pipeline shown in is only one example, and other examples may have different sets of pipeline stages or execution units. For example, an in-order processor may not have a rename stage 212.

[0059] The target processing system 106 includes several microarchitectural components that may be tested using the test sequences 108 of code generated by the test code generation circuitry 100. These components include registers 214, caches 208, 230, 232, TLB 236, MMU 235, and components in the memory system, such as coherent or incoherent interconnects, snoop filters, memory controllers, and buffers associated with any of these features.

[0060] Figure 3A schematic diagram of an instruction sequence 300 that can be run on a target processing system 106 to test the microarchitecture of the target processing system 106 is shown. The instruction sequence 300 includes a directed sequence 102 of code inserted into a randomly selected instruction sequence 302 (in Figure 4 ), which shows that the directed sequence of code 102 includes a pre-programmed sequence of instructions 402. Combining the directed sequence of instructions 102 with a set of randomly selected instructions allows testing a specific set of micro-architectural components of the target system 106, as well as randomly populating caches, buffers, and TLBs before executing the directed sequence, so that micro-architectural features can be better detected. However, by implementing the method of the present technology, further improvements can be made to the test code 300.

[0061] Figure 5 is a flow chart illustrating an example of such a method for generating an improved test sequence 108 of code to be executed on a target processing system 106 to test the target system 106. The test code generation method 500—which may be performed by the test code generation circuit 100—begins at step 502.

[0062] In step 504, the test code generation circuit 100 receives the directed sequence of code 102. The directed sequence of code 102 may be one of a plurality of directed sequences of code to be included in the test sequence of code 108, and thus, the test sequence of code 108 may be based on the plurality of directed sequences, or only on one directed sequence.

[0063] In step 506, a random plurality of instructions from the random set 104 of instructions are inserted into the directed sequence 102 of code and the insertion point. The random plurality of instructions are randomly selected from the random set 104 and the insertion point is a point between instructions 402 in the directed sequence 102 of code.

[0064] In step 508, it is determined whether there are any more directed sequences of code to be processed. If so, the method returns to step 504 and the next directed sequence of code is received. If not, the method continues to step 510, in which the test sequence 108 of code is output to be run on the target processing circuit.

[0065] Figure 6 The test code generation circuit 100 is based on Figure 5 , which is a schematic diagram of an example of a test sequence 108 of code generated by a test code generation method 500 .

[0066] The test sequence of code 108 includes instructions 402 of the directed sequence of code 102. After some or all of the instructions 402 of the directed sequence of code 102 are insertion points into which instructions 302 randomly selected from the set of random instructions 104 can be inserted. Thus, the test sequence of code 108 generated by the test code generation method 500 includes 0 to m randomly selected instructions 302 after each instruction 402 in the directed sequence 102, where m is greater than or equal to 0.

[0067] Therefore, if Figure 6 The illustrated test sequence of code 108 enables a predetermined set of micro-architectural components of the target system 106 to be more thoroughly tested by the instructions 402 in the directed sequence of code 102 by extending the processing power or resources used during execution of the test sequence 102 to create more realistic processing. Thus, for example, the test is more likely to reach the limits of cache or buffer capacity, resulting in a better test of how the system will respond to realistic processing scenarios.

[0068] Figure 7 An example of a test code generation method 500a according to the present technology is shown.

[0069] The method begins at step 702, where a directed sequence of code 102 is received. At step 704, the directed sequence 102 is parsed to identify resources used by instructions in the directed sequence 102. Although not shown in the figure, a list of resources used by the directed sequence of code 102 may also be generated at this step.

[0070] In step 706, determine whether the quantity i (initially set to be equal to the number of instructions in the directed sequence 102 of the code) is greater than zero. If i is not greater than zero, the method proceeds to step 722, as described below. On the other hand, if i is greater than zero, the method proceeds to step 708 instead, in which a random number n is selected based on a weight given by the user. It will be understood that the random number n is intended to cover a pseudo-random number. The user can specify a weight, such as a maximum number for n, a minimum number for n, or any other weight that will affect the possibility of selecting a certain n value (e.g., a lower n value can be selected with a greater probability than a higher n value). The selection of n can be performed based on one or more random parameters (e.g., a randomly generated number) and based on user-specified parameters.

[0071] At step 710, it is determined whether n is greater than zero. If n is not greater than zero, the method proceeds to step 718, which will be discussed later. However, if n is greater than zero, the method proceeds to step 712, in which an instruction is randomly selected from the set of instructions 104. In this example, the set of instructions from which the random instruction is selected is a user-defined set of instructions—for example, a user may specify a set of instructions that are non-faulty and will not cause an update to a base register or a program counter. However, it should be noted that in other examples, the set of instructions may alternatively be a set of randomly generated instructions.

[0072] In either example, a set of resources (e.g., registers and memory locations) to be used by the randomly selected instruction is selected in step 714. The selected resources are different from the resources used by the directed sequence—if a resource list was generated in parsing step 704, then resources not on that list are selected for the randomly selected instruction. Once the randomly selected instruction and set of resources are selected, the instruction is inserted into the test code 108.

[0073] In step 716, the value of n is decreased by 1, and the method returns to step 710 where it is determined whether n is greater than zero.

[0074] When n is less than or equal to zero, the method proceeds to step 718, where the directed sequence of instructions is inserted into the test. In another step 720, the value of i is decreased by 1, and the method returns to step 706 to determine whether i is greater than zero.

[0075] When i is equal to zero (note: the number of instructions in a directed sequence cannot be negative), the method proceeds to step 722, where it is determined whether there are any more directed sequences to be processed. If there are more directed sequences to be processed, the method returns to receiving step 702; if not, the method proceeds to step 724, where the test sequence of the code is output.

[0076] Now go to Figure 8 , the figure shows Figure 7 A modification 500b of the method for generating a test sequence for a code shown in FIG.

[0077] In this example, when the directed sequence 102 of code is received in step 801 , a list for recording resources used by instructions in the directed sequence is created, but the list is not populated at this time.

[0078] The remainder of method 500b follows Figure 7 The process proceeds except that for each instruction in the directed sequence, in step 802, the resource list is updated to include the resources used by the instruction.

[0079] It should be noted that Figure 7 Method 500a and Figure 8 The methods 500 b in FIG. 5 and FIG. 5 are both examples of the present technology, and both provide the advantage of increasing the testing efficiency and accuracy of the target processing system 106 .

[0080] Figure 5 , Figure 7 and Figure 8 The method 500 described in the figure may also be implemented in software in the form of a computer program—the program may be stored on a non-transitory computer-readable storage medium (e.g., a CD, DVD, or flash drive). The computer program may be executed by a computer and, when executed, causes the computer to perform the method 500 as described in the figure to generate a test sequence 108 of code to be run on the target processing system 106.

[0081] The test sequence of instructions generated by the above method may be stored on a storage medium for later installation on a target processing system, so that when the test sequence is executed on the target processing system, the target processing system may be tested.

[0082] In this application, the phrase "configured to..." is used to indicate that an element of a device has a configuration that can perform a defined operation. In this article, "configuration" refers to the arrangement or manner of interconnection of hardware or software. For example, a device may have dedicated hardware that provides the defined operation, or a processor or other processing device that can be programmed to perform the function. "Configured to" does not mean that the device elements need to be changed in any way to provide the defined operation.

[0083] Although illustrative embodiments of the present invention have been described in detail herein with reference to the accompanying drawings, it should be understood that the present invention is not limited to those precise embodiments and that various changes and modifications may be made therein by those skilled in the art without departing from the scope and spirit of the invention as defined by the appended claims.

Claims

1. A method for generating a test sequence of code to be run on a target processing system for testing the target processing system, wherein: The test sequence of code is based on one or more directed sequences of code, wherein the one or more directed sequences of code are predetermined sequences of one or more directed instructions for testing a predetermined portion of the target processing system; and The method comprises: for at least one of the directed sequences of the one or more codes: Inserting randomly selected instructions at one or more insertion points at intermediate positions within the directed sequence of the code, each insertion point being between two instructions of the directed sequence, and the randomly selected instructions referencing resources including at least one of the following: A set of registers in the target processing system; and a set of memory locations in the target processing system; At least one of the following is selected based on at least one random number: the instruction type of the randomly selected instruction; and registers and / or memory locations referenced by the randomly selected instructions; Wherein the registers and / or memory locations referenced by the randomly selected instruction are selected to be different from registers and / or memory locations used by instructions in the directed sequence of the code.

2. The method according to claim 1, wherein: The result of the directed sequence is not affected by the randomly selected instruction.

3. The method according to any one of claims 1 to 2, comprising: At least one of the following is selected based on at least one random number: How many randomly selected instructions to insert; as well as Insert the randomly selected instruction at an insertion point.

4. The method according to any one of claims 1 to 2, comprising: For each instruction in the directed sequence, it is determined whether an insertion point is allowed after the instruction.

5. The method according to any one of claims 1 to 2, comprising: For each insertion point in the directed sequence of the code, m randomly selected instructions are inserted at the insertion point in the directed sequence of the code, where m≥0.

6. The method according to claim 1, wherein: The register and / or memory location to be used by the randomly selected instruction is selected based on at least one random number.

7. The method according to any one of claims 1 to 2, comprising: Prior to commencing insertion of randomly selected instructions into the directed sequence of code, a list of resources used by the instructions in the directed sequence of code is generated.

8. The method according to any one of claims 1 to 2, comprising: maintaining a list of resources used by instructions in a directed sequence of said code; and As each instruction in the directed sequence of code is encountered, the resource list is updated to include resources used by the instruction.

9. The method according to any one of claims 1 to 2, wherein: The randomly selected instruction is one of the following: a randomly generated set of instructions; and An instruction randomly selected from a preprogrammed set of instructions.

10. The method according to any one of claims 1 to 2, wherein: The instructions in the directed sequence of the code are pre-programmed instructions generated by one of: Programmer; computer programs; and Compiler.

11. The method according to any one of claims 1 to 2, comprising: For at least one of the directed sequences, a randomly selected instruction is inserted before or after the directed sequence.

12. The method according to any one of claims 1 to 2, wherein: Inserting the randomly selected instructions is performed during a test sequence of executing the code.

13. A computer program product comprising a computer program which, when executed on a computer, causes the computer to generate a test sequence of codes to be run on a target processing system for testing the target processing system, wherein: The test sequence of code is based on one or more directed sequences of code, wherein the one or more directed sequences of code are predetermined sequences of one or more directed instructions for testing a predetermined portion of the target processing system; and The test sequence of the code is generated by performing the following operations on at least one of the directed sequences of the one or more codes: Inserting randomly selected instructions at one or more insertion points at intermediate positions within the directed sequence of the code, each insertion point being between two instructions of the directed sequence, and the randomly selected instructions referencing resources including at least one of the following: A set of registers in the target processing system; and a set of memory locations in the target processing system; At least one of the following is selected based on at least one random number: the instruction type of the randomly selected instruction; and registers and / or memory locations referenced by the randomly selected instructions; Wherein the registers and / or memory locations referenced by the randomly selected instruction are selected to be different from registers and / or memory locations used by instructions in the directed sequence of the code.

14. A computer-readable storage medium storing the computer program according to claim 13.

15. An apparatus for generating a test sequence of codes, comprising a test code generating circuit configured to execute the method according to any one of claims 1 to 12.

16. A computer-readable storage medium storing a test sequence of the code generated by the method according to any one of claims 1 to 12.