| Compilers play a very important role in the development of software.At the same time,more and more researchers are working on how to improve the reliability of compilers.If there are error in compilers,it will affect all programs compiled with the compiler.However,it is difficult to identify the errors of compilers.Therefore,when an error occurs in the compiler,it can cause programmers to make unconscious errors.The consequences are very serious.The most important part of testing a compiler is how to set up an oracle of test cases.But the cost of construction of a test case sets is huge.There are currently two methods for this problem: reference-based methods,and assertion-based methods.Because there are some drawbacks in both of two methods,a new method has been proposed in recent years—metamorphic testing.The metamorphic testing needs two or more test cases that have a metamorphic relationship,and a program to be tested to observe whether the output has a desired metamorphic relationship.The existing methods of testing compilers based on metamorphic testing mainly include deleting invalid codes,not performing statement block replacement,and equivalent module replacement.This paper proposes a new method of metamorphosis.The metamorphic relations we adopt are also equivalent relations.However,we construct the equivalence relation by means of variable value substitution,and deleting the code in the program after the substitution of variables,so as to generate the equivalent program group.First,this paper introduces the basic knowledge about compiler testing,metamorphic testing and compiler testing based on metamorphic testing.It also introduces the working principle of Csmith,the tool for generating source code in this paper.Second,this paper introduces DeCsmith's workflow.Csmith generated programs which are used by DeCsmith.and we change the source program into equivalent programs.The equivalent test programs are compiled into executables with the compiler under test.The executables are executed.Finally,the execution results are compared.And the paper introduces the principle and implementation of the metamorphic testing in DeCsmith.。The variable that the value is known is replaced with the value under its scope,and then compute how frequently a program's statements execute,delete the lines which are not be executed.The paper uses the interface provided by the clang tool to substitute variable and perform program-to-grammatical tree conversion.This paper uses a variable table to store the state and value of the variable,and replaces variables according to AST and variable tables.We use gcov to extract coverage information and prun unexecuted code.Finally,this article analyzes the results of using DeCsmith to test the compiler and illustrates the effectiveness of the tool.The research of this paper mainly proposes a new method of test case generation of metamorphic testing,and it also designs and implements an automatic generation tool for compiler's test cases based on Csmith,which provides some help for compiler testing. |