EvoSuite / evosuite

EvoSuite - automated generation of JUnit test suites for Java classes
http://www.evosuite.org
GNU Lesser General Public License v3.0
832 stars 341 forks source link

Evosuite-1.1.0.jar crashes when generating test cases for a large class. #376

Open zzctmac opened 3 years ago

zzctmac commented 3 years ago

Context

My device is a MacBook. To generate test cases for com.soops.CEN4010.JMCA.JParser.JavaParser in jmca project, evosuite-1.1.0.jar crashes.

Steps to Reproduce

Please break down here below all the needed steps to reproduce the issue. [If possible, please upload an example of the project you are generating tests for.]

  1. Download SF-110 here, and goto 19-jmca dir.
  2. java -jar evosuite-1.1.0.jar -class com.soops.CEN4010.JMCA.JParser.JavaParser -Dsearch_budget=60 -mem 4000
  3. exit with an exception *java.lang.ClassNotFoundException: Class too large: com/soops/CEN4010/JMCA/JParser/JavaParser.

EvoSuite Arguments

Please provide the whole EvoSuite commmand you executed (if relevant)

java -jar evosuite-1.1.0.jar -class com.soops.CEN4010.JMCA.JParser.JavaParser -Dsearch_budget=60 -mem 4000

Current Result

Please describe here below the current result you got (if relevant) [if relevant, include a screenshot]

 * EvoSuite 1.1.0
* Going to generate test cases for class: com.soops.CEN4010.JMCA.JParser.JavaParser
* Starting Client-0
* Properties loaded from /Users/noname/Downloads/SF110-20130704/19_jmca/evosuite-files/evosuite.properties
* Connecting to master process on port 3352
* Analyzing classpath:
* Inheritance tree loaded from evosuite-files/inheritance.xml.gz
* Error while initializing target class: **Class too large: com/soops/CEN4010/JMCA/JParser/JavaParser**
[MASTER] 11:27:38.732 [logback-2] ERROR TestSuiteGenerator - Problem for com.soops.CEN4010.JMCA.JParser.JavaParser. Full stack:
java.lang.ClassNotFoundException: Class too large: com/soops/CEN4010/JMCA/JParser/JavaParser
    at org.evosuite.instrumentation.InstrumentingClassLoader.instrumentClass(InstrumentingClassLoader.java:164)
    at org.evosuite.instrumentation.InstrumentingClassLoader.loadClass(InstrumentingClassLoader.java:132)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.evosuite.testcase.statements.MethodStatement$1.execute(MethodStatement.java:261)
    at org.evosuite.testcase.statements.AbstractStatement.exceptionHandler(AbstractStatement.java:172)
    at org.evosuite.testcase.statements.MethodStatement.execute(MethodStatement.java:224)
    at org.evosuite.testcase.execution.TestRunnable.executeStatements(TestRunnable.java:295)
    at org.evosuite.testcase.execution.TestRunnable.call(TestRunnable.java:201)
    at org.evosuite.testcase.execution.TestRunnable.call(TestRunnable.java:54)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.evosuite.shaded.org.objectweb.asm.ClassTooLargeException: Class too large: com/soops/CEN4010/JMCA/JParser/JavaParser
    at org.evosuite.shaded.org.objectweb.asm.ClassWriter.toByteArray(ClassWriter.java:599)
    at org.evosuite.instrumentation.BytecodeInstrumentation.transformBytes(BytecodeInstrumentation.java:297)
    at org.evosuite.instrumentation.InstrumentingClassLoader.getTransformedBytes(InstrumentingClassLoader.java:141)
    at org.evosuite.instrumentation.InstrumentingClassLoader.instrumentClass(InstrumentingClassLoader.java:155)
    ... 17 common frames omitted

Expected result

Please describe here below what should be the expected behaviour (if relevant) normal exiting with a test suite.

Additional info

Please add any information of interest here below I believe that this problem is related to the line. This line will catch an exception whose msg contains "Method code too large" or "Class file too large", but not "Class too large". Hence, I add "Class too large" and evosuite-1.1.0.jar can generate test cases but something else happens:

* EvoSuite 1.1.1-SNAPSHOT
* Going to generate test cases for class: com.soops.CEN4010.JMCA.JParser.JavaParser
* Starting Client-0
* Properties loaded from /Users/noname/Downloads/SF110-20130704/19_jmca/evosuite-files/evosuite.properties
* Connecting to master process on port 13368
* Analyzing classpath:
* Inheritance tree loaded from evosuite-files/inheritance.xml.gz
* Instrumentation exceeds Java's 64K limit per method in target class
* Attempting re-instrumentation without mutation
* Deactivating EvoSuite statistics because of instrumentation problem
[MASTER] 11:30:32.016 [logback-1] WARN  InheritanceTree - Class not in inheritance graph: java.util.function.Consumer
[MASTER] 11:30:32.018 [logback-1] WARN  InheritanceTree - Class not in inheritance graph: java.util.function.Predicate
[MASTER] 11:30:32.019 [logback-1] WARN  InheritanceTree - Class not in inheritance graph: java.util.function.UnaryOperator
[MASTER] 11:30:32.055 [logback-1] WARN  InheritanceTree - Class not in inheritance graph: java.util.function.Function
* Finished analyzing classpath
* Deactivating assertion minimization because mutation instrumentation does not work
* Generating tests for class com.soops.CEN4010.JMCA.JParser.JavaParser
* Test criteria:
  - Line Coverage
  - Branch Coverage
  - Exception
  - Method-Output Coverage
  - Top-Level Method Coverage
  - No-Exception Top-Level Method Coverage
  - Context Branch Coverage
* Total number of test goals for DYNAMOSA: 21093
* Using seed 1629862224794
* Starting evolution
[Progress:>                             0%] [Cov:>                                  0%]* Initial Number of Goals in DynaMOSA = 2618 / 21093
[Progress:==============================100%] [Cov:===============>                   43%]
* Search finished after 61s and 34 generations, 9895 statements, best individual has fitness: 14879.0
* Minimizing test suite
[MASTER] 11:32:34.739 [logback-1] WARN  TestSuiteMinimizer - Minimization timeout. Roll back to original test suite
* Going to analyze the coverage criteria
* Coverage analysis for criterion LINE
* Coverage of criterion LINE: 44%
* Total number of goals: 4940
* Number of covered goals: 2166
* Coverage analysis for criterion BRANCH
* Coverage of criterion BRANCH: 28%
* Total number of goals: 7938
* Number of covered goals: 2200
* Coverage analysis for criterion EXCEPTION
* Coverage of criterion EXCEPTION: 100%
* Total number of goals: 157
* Number of covered goals: 157
* Coverage analysis for criterion OUTPUT
* Coverage of criterion OUTPUT: 33%
* Total number of goals: 9
* Number of covered goals: 3
* Coverage analysis for criterion METHOD
* Coverage of criterion METHOD: 95%
* Total number of goals: 134
* Number of covered goals: 127
* Coverage analysis for criterion METHODNOEXCEPTION
* Coverage of criterion METHODNOEXCEPTION: 39%
* Total number of goals: 134
* Number of covered goals: 52
* Coverage analysis for criterion CBRANCH
* Coverage of criterion CBRANCH: 25%
* Total number of goals: 7938
* Number of covered goals: 1970
* Generated 365 tests with total length 3446
* Resulting test suite's coverage: 43% (average coverage for all fitness functions)
* Generating assertions
* Compiling and checking tests
* Writing tests to file
* Writing JUnit test case 'JavaParser_ESTest' to evosuite-tests
* Done!

[MASTER] 11:33:54.023 [logback-2] ERROR ClientNodeImpl - Error when generating tests for: com.soops.CEN4010.JMCA.JParser.JavaParser with seed 1629862224794. Configuration id : null
java.rmi.MarshalException: error marshalling arguments; nested exception is:
    java.net.SocketException: Broken pipe (Write failed)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:159)
    at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:235)
    at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:180)
    at com.sun.proxy.$Proxy7.evosuite_collectTestGenerationResult(Unknown Source)
    at org.evosuite.rmi.service.ClientNodeImpl.lambda$startNewSearch$0(ClientNodeImpl.java:154)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.SocketException: Broken pipe (Write failed)
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:155)
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
    at java.io.BufferedOutputStream.write(BufferedOutputStream.java:126)
    at java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1877)
    at java.io.ObjectOutputStream$BlockDataOutputStream.writeByte(ObjectOutputStream.java:1915)
    at java.io.ObjectOutputStream.writeFatalException(ObjectOutputStream.java:1576)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:351)
    at sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:292)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:154)
    ... 9 common frames omitted
* Computation finished
[MASTER] 11:33:54.134 [main] ERROR SearchStatistics - No statistics has been saved because EvoSuite failed to generate any test case
[MASTER] 11:33:54.240 [main] ERROR TestGeneration - failed to write statistics data