diff --git a/test/testsuite/ouroboros/eh_test/RT0024-rt-eh-NativeCodeCheckExceptionTest/NativeCodeCheckExceptionTest.java b/test/testsuite/ouroboros/eh_test/RT0024-rt-eh-NativeCodeCheckExceptionTest/NativeCodeCheckExceptionTest.java index 65593b8e69b8a4e1f531e56a3019b362e3ae70b2..70f67980077ebf750a8bde3bd3d12cb4292f7d8f 100644 --- a/test/testsuite/ouroboros/eh_test/RT0024-rt-eh-NativeCodeCheckExceptionTest/NativeCodeCheckExceptionTest.java +++ b/test/testsuite/ouroboros/eh_test/RT0024-rt-eh-NativeCodeCheckExceptionTest/NativeCodeCheckExceptionTest.java @@ -87,4 +87,4 @@ public class NativeCodeCheckExceptionTest extends Exception { // DEPENDENCE: jniNativeCodeCheckExceptionTest.cpp // EXEC:%maple NativeCodeCheckExceptionTest.java jniNativeCodeCheckExceptionTest.cpp %build_option -o %n.so // EXEC:%run %n.so NativeCodeCheckExceptionTest %run_option | compare %f -// ASSERT: scan-full ------>CheckPoint:CcanContinue\n \ No newline at end of file +// ASSERT: scan-full ------>CheckPoint:CcanContinue\n diff --git a/test/testsuite/ouroboros/rc_test/RC0001-rc-function-Cycle_a_00180/Cycle_a_00180.java b/test/testsuite/ouroboros/rc_test/RC0001-rc-function-Cycle_a_00180/Cycle_a_00180.java new file mode 100755 index 0000000000000000000000000000000000000000..5b5bde86abd6693f96a8d614ac547ef3a78bff5e --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0001-rc-function-Cycle_a_00180/Cycle_a_00180.java @@ -0,0 +1,239 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00180.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00180 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00180.java + *- @ExecuteClass: Cycle_a_00180 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2 A8; + * A2 depend A3 ; A3 depend A4; A4 depend A5 ; A5 depend A6; A6 depend A1 ; + * A8 depend A9 ; A9 depend A7; A7 depend A4 + * A1.a=101 A2.a=102 A3.a=103 ... A9.a=109 + * RC-Testing_Result=(101+102+108)+(102+103)+(103+104)+(104+105)+(105+106)+(106+101)+(107+104)+(108+109)+(109+107)=1994 + * + */ + +class Cycle_a_00180_A1 { + Cycle_a_00180_A2 a2_0; + Cycle_a_00180_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A1(String strObjectName) { + a2_0 = null; + a8_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a8_0.a; + } +} + +class Cycle_a_00180_A2 { + Cycle_a_00180_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00180_A3 { + Cycle_a_00180_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } +} + +class Cycle_a_00180_A4 { + Cycle_a_00180_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } +} + +class Cycle_a_00180_A5 { + Cycle_a_00180_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } +} + +class Cycle_a_00180_A6 { + Cycle_a_00180_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A6(String strObjectName) { + a1_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } +} + +class Cycle_a_00180_A7 { + Cycle_a_00180_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A7(String strObjectName) { + a4_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } +} + +class Cycle_a_00180_A8 { + Cycle_a_00180_A9 a9_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A8(String strObjectName) { + a9_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a9_0.a; + } +} + +class Cycle_a_00180_A9 { + Cycle_a_00180_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A9(String strObjectName) { + a7_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } +} + +public class Cycle_a_00180 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00180_A1 a1_main = new Cycle_a_00180_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00180_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00180_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00180_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = new Cycle_a_00180_A5("a5_0"); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_a_00180_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_main; + a1_main.a8_0 = new Cycle_a_00180_A8("a8_0"); + a1_main.a8_0.a9_0 = new Cycle_a_00180_A9("a9_0"); + a1_main.a8_0.a9_0.a7_0 = new Cycle_a_00180_A7("a7_0"); + a1_main.a8_0.a9_0.a7_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a5_0.add(); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a1_main.a8_0.add(); + a1_main.a8_0.a9_0.add(); + a1_main.a8_0.a9_0.a7_0.add(); + + + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a5_0.sum + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a1_main.a8_0.sum + a1_main.a8_0.a9_0.sum + a1_main.a8_0.a9_0.a7_0.sum; + if (result == 1994) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0002-rc-function-Cycle_a_00190/Cycle_a_00190.java b/test/testsuite/ouroboros/rc_test/RC0002-rc-function-Cycle_a_00190/Cycle_a_00190.java new file mode 100755 index 0000000000000000000000000000000000000000..65697255f4635a24579455584dba1e1392550c21 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0002-rc-function-Cycle_a_00190/Cycle_a_00190.java @@ -0,0 +1,262 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00190.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00190 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00190.java + *- @ExecuteClass: Cycle_a_00190 + *- @ExecuteArgs: + *- @Remark: + A1 depend A2; A10 depend A8 ; + * A2 depend A3 ; A3 depend A4; A4 depend A5 ; A5 depend A6; A6 depend A1 A10 ; + * A8 depend A9 ; A9 depend A7; A7 depend A5 + * A1.a=101 A2.a=102 A3.a=103 ... A9.a=109 + * RC-Testing_Result=(101+102)+(102+103)+(103+104)+(104+105)+(105+106)+(106+101+110)+(107+105)+(108+109)+(109+107)+(110+108)=2215 + * + */ + +class Cycle_a_00190_A1 { + Cycle_a_00190_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00190_A2 { + Cycle_a_00190_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00190_A3 { + Cycle_a_00190_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } +} + +class Cycle_a_00190_A4 { + Cycle_a_00190_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } +} + +class Cycle_a_00190_A5 { + Cycle_a_00190_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } +} + +class Cycle_a_00190_A6 { + Cycle_a_00190_A1 a1_0; + Cycle_a_00190_A10 a10_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A6(String strObjectName) { + a1_0 = null; + a10_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a10_0.a; + } +} + +class Cycle_a_00190_A7 { + Cycle_a_00190_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A7(String strObjectName) { + a5_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } +} + +class Cycle_a_00190_A8 { + Cycle_a_00190_A9 a9_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A8(String strObjectName) { + a9_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a9_0.a; + } +} + +class Cycle_a_00190_A9 { + Cycle_a_00190_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A9(String strObjectName) { + a7_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } +} + +class Cycle_a_00190_A10 { + Cycle_a_00190_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A10(String strObjectName) { + a8_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + + void add() { + sum = a + a8_0.a; + } +} + +public class Cycle_a_00190 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00190_A1 a1_main = new Cycle_a_00190_A1("a1_main"); + Cycle_a_00190_A10 a10_main = new Cycle_a_00190_A10("a10_main"); + a1_main.a2_0 = new Cycle_a_00190_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00190_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00190_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = new Cycle_a_00190_A5("a5_0"); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_a_00190_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.a10_0 = a10_main; + + a10_main.a8_0 = new Cycle_a_00190_A8("a8_0"); + a10_main.a8_0.a9_0 = new Cycle_a_00190_A9("a9_0"); + a10_main.a8_0.a9_0.a7_0 = new Cycle_a_00190_A7("a7_0"); + a10_main.a8_0.a9_0.a7_0.a5_0 = a1_main.a2_0.a3_0.a4_0.a5_0; + + a1_main.add(); + a10_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a5_0.add(); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a10_main.a8_0.add(); + a10_main.a8_0.a9_0.add(); + a10_main.a8_0.a9_0.a7_0.add(); + + + int result = a1_main.sum + a10_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a5_0.sum + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a10_main.a8_0.sum + a10_main.a8_0.a9_0.sum + a10_main.a8_0.a9_0.a7_0.sum; + if (result == 2215) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0003-rc-function-Cycle_a_00200/Cycle_a_00200.java b/test/testsuite/ouroboros/rc_test/RC0003-rc-function-Cycle_a_00200/Cycle_a_00200.java new file mode 100755 index 0000000000000000000000000000000000000000..561c8c5296dcf5380106b50130b6b633006bd6c9 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0003-rc-function-Cycle_a_00200/Cycle_a_00200.java @@ -0,0 +1,200 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00200.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00200 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00200.java + *- @ExecuteClass: Cycle_a_00200 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2; A4 depend A3 ; + * A2 depend A3 A6 A7; A3 depend A1 A5; A5 depend A4; A6 depend A7 ; + * A1.a=101 A2.a=102 A3.a=103 ... A9.a=109 + * RC-Testing_Result=(101+102+106+107)+(102+103)+(103+101+105)+(104+103)+(105+104)+(106+107)+(107+107)=1773 + * + */ + +class Cycle_a_00200_A1 { + Cycle_a_00200_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00200_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00200_A2 { + Cycle_a_00200_A3 a3_0; + Cycle_a_00200_A6 a6_0; + Cycle_a_00200_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00200_A2(String strObjectName) { + a3_0 = null; + a6_0 = null; + a7_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a6_0.a + a7_0.a; + } +} + +class Cycle_a_00200_A3 { + Cycle_a_00200_A1 a1_0; + Cycle_a_00200_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00200_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } +} + +class Cycle_a_00200_A4 { + Cycle_a_00200_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00200_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00200_A5 { + Cycle_a_00200_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00200_A5(String strObjectName) { + a4_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } +} + +class Cycle_a_00200_A6 { + Cycle_a_00200_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00200_A6(String strObjectName) { + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } +} + +class Cycle_a_00200_A7 { + int a; + int sum; + String strObjectName; + + Cycle_a_00200_A7(String strObjectName) { + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + + +public class Cycle_a_00200 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00200_A1 a1_main = new Cycle_a_00200_A1("a1_main"); + Cycle_a_00200_A4 a4_main = new Cycle_a_00200_A4("a4_main"); + a1_main.a2_0 = new Cycle_a_00200_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00200_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00200_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a4_0 = a4_main; + a4_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a6_0 = new Cycle_a_00200_A6("a6_0"); + a1_main.a2_0.a6_0.a7_0 = new Cycle_a_00200_A7("a7_0"); + a1_main.a2_0.a7_0 = a1_main.a2_0.a6_0.a7_0; + + a1_main.add(); + a4_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a6_0.add(); + a1_main.a2_0.a6_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a1_main.a2_0.a6_0.sum + a1_main.a2_0.a6_0.a7_0.sum; + if (result == 1773) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0004-rc-function-Cycle_a_00210/Cycle_a_00210.java b/test/testsuite/ouroboros/rc_test/RC0004-rc-function-Cycle_a_00210/Cycle_a_00210.java new file mode 100755 index 0000000000000000000000000000000000000000..1343e3e72a23fc6082c225a5d78f86b39fbc249f --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0004-rc-function-Cycle_a_00210/Cycle_a_00210.java @@ -0,0 +1,200 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00210.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Cycle_a_00210 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00210.java + *- @ExecuteClass: Cycle_a_00210 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2; A4 depend A3 ; + * A2 depend A3; A3 depend A1 A5 A6; A5 depend A4; A6 depend A7 ; A7 depend A3; + * A1.a=101 A2.a=102 A3.a=103 ... A9.a=109 + * RC-Testing_Result=(101+102)+(102+103)+(103+101+105+106)+(104+103)+(105+104)+(106+107)+(107+103)=1662 + * + */ + +class Cycle_a_00210_A1 { + Cycle_a_00210_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00210_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00210_A2 { + Cycle_a_00210_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00210_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00210_A3 { + Cycle_a_00210_A1 a1_0; + Cycle_a_00210_A5 a5_0; + Cycle_a_00210_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00210_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a6_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a + a6_0.a; + } +} + +class Cycle_a_00210_A4 { + Cycle_a_00210_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00210_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00210_A5 { + Cycle_a_00210_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00210_A5(String strObjectName) { + a4_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } +} + +class Cycle_a_00210_A6 { + Cycle_a_00210_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00210_A6(String strObjectName) { + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } +} + +class Cycle_a_00210_A7 { + Cycle_a_00210_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00210_A7(String strObjectName) { + a3_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + + +public class Cycle_a_00210 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00210_A1 a1_main = new Cycle_a_00210_A1("a1_main"); + Cycle_a_00210_A4 a4_main = new Cycle_a_00210_A4("a4_main"); + a1_main.a2_0 = new Cycle_a_00210_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00210_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00210_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a4_0 = a4_main; + a4_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a6_0 = new Cycle_a_00210_A6("a6_0"); + a1_main.a2_0.a3_0.a6_0.a7_0 = new Cycle_a_00210_A7("a7_0"); + a1_main.a2_0.a3_0.a6_0.a7_0.a3_0 = a1_main.a2_0.a3_0; + + a1_main.add(); + a4_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a6_0.add(); + a1_main.a2_0.a3_0.a6_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a1_main.a2_0.a3_0.a6_0.sum + a1_main.a2_0.a3_0.a6_0.a7_0.sum; + if (result == 1662) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0005-rc-function-Cycle_a_00220/Cycle_a_00220.java b/test/testsuite/ouroboros/rc_test/RC0005-rc-function-Cycle_a_00220/Cycle_a_00220.java new file mode 100755 index 0000000000000000000000000000000000000000..86d0b151c0317934dbf337e4d6d0b26b67fe3046 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0005-rc-function-Cycle_a_00220/Cycle_a_00220.java @@ -0,0 +1,202 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00220.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00220 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00220.java + *- @ExecuteClass: Cycle_a_00220 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2; A5 depend A4 A7; + * A2 depend A3; A3 depend A1 A5; A4 depend A3 ; A6 depend A5 A7 ; + * A1.a=101 A2.a=102 A3.a=103 ... A9.a=109 + * RC-Testing_Result=(101+102)+(102+103)+(103+101+105)+(104+103)+(105+104+107)+(106+105+107)+(107+107)=1772 + * + */ + +class Cycle_a_00220_A1 { + Cycle_a_00220_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00220_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00220_A2 { + Cycle_a_00220_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00220_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00220_A3 { + Cycle_a_00220_A1 a1_0; + Cycle_a_00220_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00220_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } +} + +class Cycle_a_00220_A4 { + Cycle_a_00220_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00220_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00220_A5 { + Cycle_a_00220_A4 a4_0; + Cycle_a_00220_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00220_A5(String strObjectName) { + a4_0 = null; + a7_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a4_0.a + a7_0.a; + } +} + +class Cycle_a_00220_A6 { + Cycle_a_00220_A5 a5_0; + Cycle_a_00220_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00220_A6(String strObjectName) { + a5_0 = null; + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a5_0.a + a7_0.a; + } +} + +class Cycle_a_00220_A7 { + int a; + int sum; + String strObjectName; + + Cycle_a_00220_A7(String strObjectName) { + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + + +public class Cycle_a_00220 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00220_A1 a1_main = new Cycle_a_00220_A1("a1_main"); + Cycle_a_00220_A4 a4_main = new Cycle_a_00220_A4("a4_main"); + Cycle_a_00220_A6 a6_main = new Cycle_a_00220_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00220_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00220_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00220_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a4_0 = a4_main; + a4_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a5_0.a7_0 = new Cycle_a_00220_A7("a7_0"); + a6_main.a7_0 = a1_main.a2_0.a3_0.a5_0.a7_0; + a6_main.a5_0 = a1_main.a2_0.a3_0.a5_0; + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a7_0.sum; + if (result == 1772) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0006-rc-function-Cycle_a_00230/Cycle_a_00230.java b/test/testsuite/ouroboros/rc_test/RC0006-rc-function-Cycle_a_00230/Cycle_a_00230.java new file mode 100755 index 0000000000000000000000000000000000000000..6f576ee69ef102ba434aa825bff280bfe1de3a1b --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0006-rc-function-Cycle_a_00230/Cycle_a_00230.java @@ -0,0 +1,200 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00230.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Cycle_a_00230 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00230.java + *- @ExecuteClass: Cycle_a_00230 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2; A5 depend A3 A6 A7; + * A2 depend A3; A3 depend A1 A4; A4 depend A5 ; A6 depend A7 ; + * A1.a=101 A2.a=102 A3.a=103 ... A9.a=109 + * RC-Testing_Result=(101+102)+(102+103)+(103+101+104)+(104+105)+(105+103+106+107)+(106+107)+(107+107)=1773 + * + */ + +class Cycle_a_00230_A1 { + Cycle_a_00230_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00230_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00230_A2 { + Cycle_a_00230_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00230_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00230_A3 { + Cycle_a_00230_A1 a1_0; + Cycle_a_00230_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00230_A3(String strObjectName) { + a1_0 = null; + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a4_0.a; + } +} + +class Cycle_a_00230_A4 { + Cycle_a_00230_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00230_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } +} + +class Cycle_a_00230_A5 { + Cycle_a_00230_A3 a3_0; + Cycle_a_00230_A6 a6_0; + Cycle_a_00230_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00230_A5(String strObjectName) { + a3_0 = null; + a6_0 = null; + a7_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a6_0.a + a7_0.a; + } +} + +class Cycle_a_00230_A6 { + Cycle_a_00230_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00230_A6(String strObjectName) { + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } +} + +class Cycle_a_00230_A7 { + int a; + int sum; + String strObjectName; + + Cycle_a_00230_A7(String strObjectName) { + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + + +public class Cycle_a_00230 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00230_A1 a1_main = new Cycle_a_00230_A1("a1_main"); + Cycle_a_00230_A5 a5_main = new Cycle_a_00230_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00230_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00230_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00230_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = a5_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a7_0 = new Cycle_a_00230_A7("a7_0"); + a5_main.a6_0 = new Cycle_a_00230_A6("a6_0"); + a5_main.a6_0.a7_0 = a5_main.a7_0; + + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a5_main.a7_0.add(); + a5_main.a6_0.add(); + + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a5_main.a6_0.sum + a5_main.a7_0.sum; + if (result == 1773) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0007-rc-function-Cycle_a_00240/Cycle_a_00240.java b/test/testsuite/ouroboros/rc_test/RC0007-rc-function-Cycle_a_00240/Cycle_a_00240.java new file mode 100755 index 0000000000000000000000000000000000000000..5492ec692cd69e2aba897b0339cec032f694b603 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0007-rc-function-Cycle_a_00240/Cycle_a_00240.java @@ -0,0 +1,201 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00240.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00240 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00240.java + *- @ExecuteClass: Cycle_a_00240 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2 A6; A5 depend A3; + * A2 depend A3; A3 depend A1 A4; A4 depend A5 ; A6 depend A7 ; A7 depend A1; + * A1.a=101 A2.a=102 A3.a=103 ... A9.a=109 + * RC-Testing_Result=(101+102+106)+(102+103)+(103+101+104)+(104+105)+(105+103)+(106+107)+(107+101)=1660 + * + */ + +class Cycle_a_00240_A1 { + Cycle_a_00240_A2 a2_0; + Cycle_a_00240_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00240_A1(String strObjectName) { + a2_0 = null; + a6_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a6_0.a; + } +} + +class Cycle_a_00240_A2 { + Cycle_a_00240_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00240_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00240_A3 { + Cycle_a_00240_A1 a1_0; + Cycle_a_00240_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00240_A3(String strObjectName) { + a1_0 = null; + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a4_0.a; + } +} + +class Cycle_a_00240_A4 { + Cycle_a_00240_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00240_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } +} + +class Cycle_a_00240_A5 { + Cycle_a_00240_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00240_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00240_A6 { + Cycle_a_00240_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00240_A6(String strObjectName) { + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } +} + +class Cycle_a_00240_A7 { + Cycle_a_00240_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00240_A7(String strObjectName) { + a1_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } +} + + +public class Cycle_a_00240 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00240_A1 a1_main = new Cycle_a_00240_A1("a1_main"); + Cycle_a_00240_A5 a5_main = new Cycle_a_00240_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00240_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00240_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00240_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = a5_main; + a1_main.a6_0 = new Cycle_a_00240_A6("a6_0"); + a1_main.a6_0.a7_0 = new Cycle_a_00240_A7("a7_0"); + a1_main.a6_0.a7_0.a1_0 = a1_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a6_0.add(); + a1_main.a6_0.a7_0.add(); + + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a6_0.sum + a1_main.a6_0.a7_0.sum; + if (result == 1660) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0008-rc-function-Cycle_a_00250/Cycle_a_00250.java b/test/testsuite/ouroboros/rc_test/RC0008-rc-function-Cycle_a_00250/Cycle_a_00250.java new file mode 100755 index 0000000000000000000000000000000000000000..dc5c8ca193683b30d83cca5c14460672f9eed15c --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0008-rc-function-Cycle_a_00250/Cycle_a_00250.java @@ -0,0 +1,159 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00250.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00250 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00250.java + *- @ExecuteClass: Cycle_a_00250 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2; A6 depend A3 + * A2 depend A3; A3 depend A1 A2 A5; A5 depend A6; + * A1.a=101 A2.a=102 A3.a=103 ... A9.a=109 + * RC-Testing_Result=(101+102)+(102+101+103)+(103+101+105)+(105+106)+(106+103)=1238 + * + */ + +class Cycle_a_00250_A1 { + Cycle_a_00250_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00250_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00250_A2 { + Cycle_a_00250_A1 a1_0; + Cycle_a_00250_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00250_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } +} + +class Cycle_a_00250_A3 { + Cycle_a_00250_A1 a1_0; + Cycle_a_00250_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00250_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } +} + + +class Cycle_a_00250_A5 { + Cycle_a_00250_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00250_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } +} + +class Cycle_a_00250_A6 { + Cycle_a_00250_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00250_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + + +public class Cycle_a_00250 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00250_A1 a1_main = new Cycle_a_00250_A1("a1_main"); + Cycle_a_00250_A6 a6_main = new Cycle_a_00250_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00250_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00250_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00250_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + if (result == 1238) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0009-rc-function-Cycle_a_00260/Cycle_a_00260.java b/test/testsuite/ouroboros/rc_test/RC0009-rc-function-Cycle_a_00260/Cycle_a_00260.java new file mode 100755 index 0000000000000000000000000000000000000000..865035522317ae89e59c4de212c5921ab88e72fc --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0009-rc-function-Cycle_a_00260/Cycle_a_00260.java @@ -0,0 +1,160 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00260.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00260 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00260.java + *- @ExecuteClass: Cycle_a_00260 + *- @ExecuteArgs: + *- @Remark: + ** A1 depend A2; A6 depend A3 + * A2 depend A3; A3 depend A1 A2 A5; A5 depend A6; + * A1.a=101 A2.a=102 A3.a=103 ... A9.a=109 + * RC-Testing_Result=(101+102)+(102+103)+(103+101+102+105)+(105+106)+(106+103)=1239 + * + */ + +class Cycle_a_00260_A1 { + Cycle_a_00260_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00260_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00260_A2 { + Cycle_a_00260_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00260_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00260_A3 { + Cycle_a_00260_A1 a1_0; + Cycle_a_00260_A2 a2_0; + Cycle_a_00260_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00260_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a2_0.a + a5_0.a; + } +} + + +class Cycle_a_00260_A5 { + Cycle_a_00260_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00260_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } +} + +class Cycle_a_00260_A6 { + Cycle_a_00260_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00260_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + + +public class Cycle_a_00260 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00260_A1 a1_main = new Cycle_a_00260_A1("a1_main"); + Cycle_a_00260_A6 a6_main = new Cycle_a_00260_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00260_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00260_A3("a3_0"); + a1_main.a2_0.a3_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00260_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + if (result == 1239) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0010-rc-function-Cycle_a_00270/Cycle_a_00270.java b/test/testsuite/ouroboros/rc_test/RC0010-rc-function-Cycle_a_00270/Cycle_a_00270.java new file mode 100755 index 0000000000000000000000000000000000000000..6385c40184d4b76b44af4ecaf1f70c372ab6e923 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0010-rc-function-Cycle_a_00270/Cycle_a_00270.java @@ -0,0 +1,160 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00270.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Cycle_a_00270 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00270.java + *- @ExecuteClass: Cycle_a_00270 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2 A3; A6 depend A3 + * A2 depend A3; A3 depend A1 A5; A5 depend A6; + * A1.a=101 A2.a=102 A3.a=103 ... A9.a=109 + * RC-Testing_Result=(101+102+103)+(102+103)+(103+101+105)+(105+106)+(106+103)=1240 + * + */ + +class Cycle_a_00270_A1 { + Cycle_a_00270_A2 a2_0; + Cycle_a_00270_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00270_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } +} + +class Cycle_a_00270_A2 { + Cycle_a_00270_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00270_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00270_A3 { + Cycle_a_00270_A1 a1_0; + Cycle_a_00270_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00270_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } +} + + +class Cycle_a_00270_A5 { + Cycle_a_00270_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00270_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } +} + +class Cycle_a_00270_A6 { + Cycle_a_00270_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00270_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + + +public class Cycle_a_00270 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00270_A1 a1_main = new Cycle_a_00270_A1("a1_main"); + Cycle_a_00270_A6 a6_main = new Cycle_a_00270_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00270_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00270_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00270_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + if (result == 1240) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0011-rc-function-Cycle_a_00280/Cycle_a_00280.java b/test/testsuite/ouroboros/rc_test/RC0011-rc-function-Cycle_a_00280/Cycle_a_00280.java new file mode 100755 index 0000000000000000000000000000000000000000..f94953c16db10870dff66b0cf48fd74939cd36e9 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0011-rc-function-Cycle_a_00280/Cycle_a_00280.java @@ -0,0 +1,165 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00280.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00280 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00280.java + *- @ExecuteClass: Cycle_a_00280 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2 A3; A6 depend A3 + * A2 depend A1 A3; A3 depend A1 A5; A5 depend A6; + * A1.a=101 A2.a=102 A3.a=103 ... A9.a=109 + * RC-Testing_Result=(101+102+103)+(102+101+103)+(103+101+102+105)+(105+106)+(106+103)=1443 + * + */ + +class Cycle_a_00280_A1 { + Cycle_a_00280_A2 a2_0; + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00280_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } +} + +class Cycle_a_00280_A2 { + Cycle_a_00280_A1 a1_0; + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00280_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } +} + +class Cycle_a_00280_A3 { + Cycle_a_00280_A1 a1_0; + Cycle_a_00280_A2 a2_0; + Cycle_a_00280_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00280_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a2_0.a + a5_0.a; + } +} + + +class Cycle_a_00280_A5 { + Cycle_a_00280_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00280_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } +} + +class Cycle_a_00280_A6 { + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00280_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + + +public class Cycle_a_00280 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00280_A1 a1_main = new Cycle_a_00280_A1("a1_main"); + Cycle_a_00280_A6 a6_main = new Cycle_a_00280_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00280_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00280_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00280_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a3_0 = a1_main.a2_0.a3_0; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + if (result == 1443) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0012-rc-function-Cycle_a_00290/Cycle_a_00290.java b/test/testsuite/ouroboros/rc_test/RC0012-rc-function-Cycle_a_00290/Cycle_a_00290.java new file mode 100755 index 0000000000000000000000000000000000000000..d74999f3b7b8aae2d6eb562d57ef477ed127cc33 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0012-rc-function-Cycle_a_00290/Cycle_a_00290.java @@ -0,0 +1,182 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00290.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Cycle_a_00290 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00290.java + *- @ExecuteClass: Cycle_a_00290 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2; A5 depend A3 + * A2 depend A3; A3 depend A1 A4 A6; A4 depend A5 ;A6 depend A2; + * A1.a=101 A2.a=102 A3.a=103 ... A9.a=109 + * RC-Testing_Result=(101+102)+(102+103)+(103+101+104+106)+(104+105)+(105+103)+(106+102)=1447 + * + */ + +class Cycle_a_00290_A1 { + Cycle_a_00290_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00290_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00290_A2 { + Cycle_a_00290_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00290_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00290_A3 { + Cycle_a_00290_A1 a1_0; + Cycle_a_00290_A4 a4_0; + Cycle_a_00290_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00290_A3(String strObjectName) { + a1_0 = null; + a4_0 = null; + a6_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a4_0.a + a6_0.a; + } +} + + +class Cycle_a_00290_A4 { + Cycle_a_00290_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00290_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } +} + +class Cycle_a_00290_A5 { + Cycle_a_00290_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00290_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00290_A6 { + Cycle_a_00290_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00290_A6(String strObjectName) { + a2_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + + +public class Cycle_a_00290 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00290_A1 a1_main = new Cycle_a_00290_A1("a1_main"); + Cycle_a_00290_A5 a5_main = new Cycle_a_00290_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00290_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00290_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00290_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = a5_main; + a1_main.a2_0.a3_0.a6_0 = new Cycle_a_00290_A6("a6_0"); + a1_main.a2_0.a3_0.a6_0.a2_0 = a1_main.a2_0; + a5_main.a3_0 = a1_main.a2_0.a3_0; + + + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a6_0.add(); + + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a6_0.sum; + + if (result == 1447) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0013-rc-function-Cycle_a_00300/Cycle_a_00300.java b/test/testsuite/ouroboros/rc_test/RC0013-rc-function-Cycle_a_00300/Cycle_a_00300.java new file mode 100755 index 0000000000000000000000000000000000000000..c05f8c94f74945a2901e16b70528b67b093d071f --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0013-rc-function-Cycle_a_00300/Cycle_a_00300.java @@ -0,0 +1,182 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00300.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Cycle_a_00300 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00300.java + *- @ExecuteClass: Cycle_a_00300 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2; A5 depend A3 + * A2 depend A3; A3 depend A1 A4; A4 depend A5 A6 ;A6 depend A3 ; + * A1.a=101 A2.a=102 A3.a=103 ... A9.a=109 + * RC-Testing_Result=(101+102)+(102+103)+(103+101+104)+(104+105+106)+(105+103)+(106+103)=1448 + * + */ + +class Cycle_a_00300_A1 { + Cycle_a_00300_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00300_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00300_A2 { + Cycle_a_00300_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00300_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00300_A3 { + Cycle_a_00300_A1 a1_0; + Cycle_a_00300_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00300_A3(String strObjectName) { + a1_0 = null; + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a4_0.a; + } +} + + +class Cycle_a_00300_A4 { + Cycle_a_00300_A5 a5_0; + Cycle_a_00300_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00300_A4(String strObjectName) { + a5_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a + a6_0.a; + } +} + +class Cycle_a_00300_A5 { + Cycle_a_00300_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00300_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00300_A6 { + Cycle_a_00300_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00300_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + + +public class Cycle_a_00300 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00300_A1 a1_main = new Cycle_a_00300_A1("a1_main"); + Cycle_a_00300_A5 a5_main = new Cycle_a_00300_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00300_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00300_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00300_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = a5_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a3_0.a4_0.a6_0 = new Cycle_a_00300_A6("a6_0"); + a5_main.a3_0.a4_0.a6_0.a3_0 = a1_main.a2_0.a3_0; + a5_main.a3_0.a4_0.a5_0 = a5_main; + + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); + + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a6_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1448) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0014-rc-function-Cycle_a_00310/Cycle_a_00310.java b/test/testsuite/ouroboros/rc_test/RC0014-rc-function-Cycle_a_00310/Cycle_a_00310.java new file mode 100755 index 0000000000000000000000000000000000000000..b99babf7b4a4cf378f0cf8c50e0ad3184f3f84a5 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0014-rc-function-Cycle_a_00310/Cycle_a_00310.java @@ -0,0 +1,186 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00310.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00310 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00310.java + *- @ExecuteClass: Cycle_a_00310 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2 A4; A4 depend A6 ; A6 depend A1 A3 + * A2 depend A3; A3 depend A1 A5; A5 depend A6 ; + * A1.a=101 A2.a=102 A3.a=103 ... A9.a=109 + * RC-Testing_Result=(101+102+104)+(102+103)+(103+101+105)+(104+106)+(105+106)+(106+101+103)=1552 + * + */ + +class Cycle_a_00310_A1 { + Cycle_a_00310_A2 a2_0; + Cycle_a_00310_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00310_A1(String strObjectName) { + a2_0 = null; + a4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a4_0.a; + } +} + +class Cycle_a_00310_A2 { + Cycle_a_00310_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00310_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00310_A3 { + Cycle_a_00310_A1 a1_0; + Cycle_a_00310_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00310_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } +} + + +class Cycle_a_00310_A4 { + Cycle_a_00310_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00310_A4(String strObjectName) { + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } +} + +class Cycle_a_00310_A5 { + Cycle_a_00310_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00310_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } +} + +class Cycle_a_00310_A6 { + Cycle_a_00310_A1 a1_0; + Cycle_a_00310_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00310_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } +} + + +public class Cycle_a_00310 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00310_A1 a1_main = new Cycle_a_00310_A1("a1_main"); + Cycle_a_00310_A4 a4_main = new Cycle_a_00310_A4("a4_main"); + Cycle_a_00310_A6 a6_main = new Cycle_a_00310_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00310_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00310_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00310_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a4_0 = a4_main; + a6_main.a1_0 = a1_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a6_main.a3_0.a5_0 = a1_main.a2_0.a3_0.a5_0; + a4_main.a6_0 = a6_main; + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + + if (result == 1552) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0015-rc-function-Cycle_a_00320/Cycle_a_00320.java b/test/testsuite/ouroboros/rc_test/RC0015-rc-function-Cycle_a_00320/Cycle_a_00320.java new file mode 100755 index 0000000000000000000000000000000000000000..40d7819445e80c2c4eb10148a81ecf297930d276 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0015-rc-function-Cycle_a_00320/Cycle_a_00320.java @@ -0,0 +1,185 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00320.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00320 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00320.java + *- @ExecuteClass: Cycle_a_00320 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2 ; A4 depend A5 ; A6 depend A1 A3 A4; A6 depend A1 A3 A4; + * A2 depend A3; A3 depend A1 A5; A5 depend A6 ; + * A1.a=101 A2.a=102 A3.a=103 ... A9.a=109 + * RC-Testing_Result=(101+102)+(102+103)+(103+101+105)+(104+105)+(105+106)+(106+101+103+104)=1551 + * + */ + +class Cycle_a_00320_A1 { + Cycle_a_00320_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00320_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00320_A2 { + Cycle_a_00320_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00320_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00320_A3 { + Cycle_a_00320_A1 a1_0; + Cycle_a_00320_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00320_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } +} + + +class Cycle_a_00320_A4 { + Cycle_a_00320_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00320_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } +} + +class Cycle_a_00320_A5 { + Cycle_a_00320_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00320_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } +} + +class Cycle_a_00320_A6 { + Cycle_a_00320_A1 a1_0; + Cycle_a_00320_A3 a3_0; + Cycle_a_00320_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00320_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } +} + + +public class Cycle_a_00320 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00320_A1 a1_main = new Cycle_a_00320_A1("a1_main"); + Cycle_a_00320_A4 a4_main = new Cycle_a_00320_A4("a4_main"); + Cycle_a_00320_A6 a6_main = new Cycle_a_00320_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00320_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00320_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00320_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a4_main.a5_0 = a1_main.a2_0.a3_0.a5_0; + a6_main.a4_0 = a4_main; + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + + if (result == 1551) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0016-rc-function-Cycle_a_00330/Cycle_a_00330.java b/test/testsuite/ouroboros/rc_test/RC0016-rc-function-Cycle_a_00330/Cycle_a_00330.java new file mode 100755 index 0000000000000000000000000000000000000000..5ce6670e3524ffe87ce396116255dd3e28b08b53 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0016-rc-function-Cycle_a_00330/Cycle_a_00330.java @@ -0,0 +1,234 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00330.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00330 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00330.java + *- @ExecuteClass: Cycle_a_00330 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2 ; A4 depend A1 ; A6 depend A1 A3; + * A2 depend A3 A4; A3 depend A1 A5 A8; A5 depend A6 A8; + * A7 depend A3 ; A8 depend A7; + * A1.a=101 A2.a=102 A3.a=103 ... A9.a=109 + * RC-Testing_Result=(101+102)+(102+103+104)+(103+101+105)+(104+101)+(105+106+108)+(106+101+103)+(107+103)+(108+107)=2080 + * + */ + +class Cycle_a_00330_A1 { + Cycle_a_00330_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00330_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00330_A2 { + Cycle_a_00330_A3 a3_0; + Cycle_a_00330_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00330_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } +} + +class Cycle_a_00330_A3 { + Cycle_a_00330_A1 a1_0; + Cycle_a_00330_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00330_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } +} + + +class Cycle_a_00330_A4 { + Cycle_a_00330_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00330_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } +} + +class Cycle_a_00330_A5 { + Cycle_a_00330_A6 a6_0; + Cycle_a_00330_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00330_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a + a8_0.a; + } +} + +class Cycle_a_00330_A6 { + Cycle_a_00330_A1 a1_0; + Cycle_a_00330_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00330_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } +} + + +class Cycle_a_00330_A7 { + Cycle_a_00330_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00330_A7(String strObjectName) { + a3_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_a_00330_A8 { + Cycle_a_00330_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00330_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } +} + + +public class Cycle_a_00330 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00330_A1 a1_main = new Cycle_a_00330_A1("a1_main"); + Cycle_a_00330_A4 a4_main = new Cycle_a_00330_A4("a4_main"); + Cycle_a_00330_A6 a6_main = new Cycle_a_00330_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00330_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00330_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00330_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00330_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00330_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a3_0 = a1_main.a2_0.a3_0; + a6_main.a1_0 = a1_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum; + + if (result == 2080) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0017-rc-function-Cycle_a_00340/Cycle_a_00340.java b/test/testsuite/ouroboros/rc_test/RC0017-rc-function-Cycle_a_00340/Cycle_a_00340.java new file mode 100755 index 0000000000000000000000000000000000000000..edc5d5ff97e149f03f97d9cc968ce0f913c56c18 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0017-rc-function-Cycle_a_00340/Cycle_a_00340.java @@ -0,0 +1,234 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00340.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00340 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00340.java + *- @ExecuteClass: Cycle_a_00340 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2 ; A4 depend A1 ; A6 depend A1 A3; + * A2 depend A3 A4; A3 depend A1 A5 A8; A5 depend A6; + * A7 depend A2 ; A8 depend A7; + * A1.a=101 A2.a=102 A3.a=103 ... A9.a=109 + * RC-Testing_Result=(101+102)+(102+103+104)+(103+101+105+108)+(104+101)+(105+106)+(106+101+103)+(107+102)+(108+107)=2079 + * + */ + +class Cycle_a_00340_A1 { + Cycle_a_00340_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00340_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00340_A2 { + Cycle_a_00340_A3 a3_0; + Cycle_a_00340_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00340_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } +} + +class Cycle_a_00340_A3 { + Cycle_a_00340_A1 a1_0; + Cycle_a_00340_A5 a5_0; + Cycle_a_00340_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00340_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a8_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a + a8_0.a; + } +} + + +class Cycle_a_00340_A4 { + Cycle_a_00340_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00340_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } +} + +class Cycle_a_00340_A5 { + Cycle_a_00340_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00340_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } +} + +class Cycle_a_00340_A6 { + Cycle_a_00340_A1 a1_0; + Cycle_a_00340_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00340_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } +} + + +class Cycle_a_00340_A7 { + Cycle_a_00340_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00340_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_a_00340_A8 { + Cycle_a_00340_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00340_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } +} + + +public class Cycle_a_00340 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00340_A1 a1_main = new Cycle_a_00340_A1("a1_main"); + Cycle_a_00340_A4 a4_main = new Cycle_a_00340_A4("a4_main"); + Cycle_a_00340_A6 a6_main = new Cycle_a_00340_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00340_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00340_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00340_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a2_0.a3_0.a8_0 = new Cycle_a_00340_A8("a8_0"); + a1_main.a2_0.a3_0.a8_0.a7_0 = new Cycle_a_00340_A7("a7_0"); + a1_main.a2_0.a3_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a6_main.a1_0 = a1_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a8_0.add(); + a1_main.a2_0.a3_0.a8_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a8_0.a7_0.sum + a6_main.a3_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2079) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0018-rc-function-Cycle_a_00350/Cycle_a_00350.java b/test/testsuite/ouroboros/rc_test/RC0018-rc-function-Cycle_a_00350/Cycle_a_00350.java new file mode 100644 index 0000000000000000000000000000000000000000..22262a56e76ce5016666154593061fe36b261039 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0018-rc-function-Cycle_a_00350/Cycle_a_00350.java @@ -0,0 +1,216 @@ +/* + * -@TestCaseID:maple/runtime/rc/function/Cycle_a_00350.java + * -@TestCaseName:MyselfClassName + * -@RequirementID:SR-10620538 + * -@RequirementName:[运行时需求]支持自动内存管理 + * -@Title/Destination: Cycle_a_00350 in RC测试-Cycle-01 + * -@Condition: no + * -#c1 + * -@Brief:functionTest + * -#step1 + * -@Expect:ExpectResult\nExpectResult\n + * -@Priority: High + * -@Source: Cycle_a_00350.java + * -@ExecuteClass: Cycle_a_00350 + * -@ExecuteArgs: + * -@Remark: + * A1 depend A2 ; A4 depend A1 ; A6 depend A1 A3; + * A2 depend A3 A4; A3 depend A1 A5; A5 depend A6 A8; + * A7 depend A2 ; A8 depend A7; + * A1.a=101 A2.a=102 A3.a=103 ... A9.a=109 + * RC-Testing_Result=(101+102)+(102+103+104)+(103+101+105)+(104+101)+(105+106+108)+(106+101+103)+(107+102)+(108+107)=2079 + */ + +class Cycle_a_00350_A1 { + Cycle_a_00350_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00350_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00350_A2 { + Cycle_a_00350_A3 a3_0; + Cycle_a_00350_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00350_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } +} + +class Cycle_a_00350_A3 { + Cycle_a_00350_A1 a1_0; + Cycle_a_00350_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00350_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } +} + +class Cycle_a_00350_A4 { + Cycle_a_00350_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00350_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a1_0.a; + } +} + +class Cycle_a_00350_A5 { + Cycle_a_00350_A6 a6_0; + Cycle_a_00350_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00350_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a6_0.a + a8_0.a; + } +} + +class Cycle_a_00350_A6 { + Cycle_a_00350_A1 a1_0; + Cycle_a_00350_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00350_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } +} + +class Cycle_a_00350_A7 { + Cycle_a_00350_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00350_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00350_A8 { + Cycle_a_00350_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00350_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a7_0.a; + } +} + +public class Cycle_a_00350 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00350_A1 a1_main = new Cycle_a_00350_A1("a1_main"); + Cycle_a_00350_A4 a4_main = new Cycle_a_00350_A4("a4_main"); + Cycle_a_00350_A6 a6_main = new Cycle_a_00350_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00350_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00350_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00350_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00350_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00350_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum; + if (result == 2079) { + System.out.println("ExpectResult"); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0019-rc-function-Cycle_a_00360/Cycle_a_00360.java b/test/testsuite/ouroboros/rc_test/RC0019-rc-function-Cycle_a_00360/Cycle_a_00360.java new file mode 100755 index 0000000000000000000000000000000000000000..51b9a5e9549b8f6668f6a9f3c0b1258d716c30b8 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0019-rc-function-Cycle_a_00360/Cycle_a_00360.java @@ -0,0 +1,261 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00360.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00360 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00360.java + *- @ExecuteClass: Cycle_a_00360 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2 ; A4 depend A1 ; A6 depend A1 A3; + * A2 depend A3 A4; A3 depend A1 A5; A5 depend A6 A8 A9; + * A7 depend A2 ; A8 depend A7; + * A9 depend A2 ; + * A1.a=101 A2.a=102 A3.a=103 ... A9.a=109 + * RC-Testing_Result=(101+102)+(102+103+104)+(103+101+105)+(104+101)+(105+106+108+109)+(106+101+103)+(107+102)+(108+107)+(109+102)=2399 + * + */ + +class Cycle_a_00360_A1 { + Cycle_a_00360_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00360_A2 { + Cycle_a_00360_A3 a3_0; + Cycle_a_00360_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } +} + +class Cycle_a_00360_A3 { + Cycle_a_00360_A1 a1_0; + Cycle_a_00360_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } +} + + +class Cycle_a_00360_A4 { + Cycle_a_00360_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } +} + +class Cycle_a_00360_A5 { + Cycle_a_00360_A6 a6_0; + Cycle_a_00360_A8 a8_0; + Cycle_a_00360_A9 a9_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a9_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a + a8_0.a + a9_0.a; + } +} + +class Cycle_a_00360_A6 { + Cycle_a_00360_A1 a1_0; + Cycle_a_00360_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } +} + + +class Cycle_a_00360_A7 { + Cycle_a_00360_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_a_00360_A8 { + Cycle_a_00360_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } +} + + +class Cycle_a_00360_A9 { + Cycle_a_00360_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A9(String strObjectName) { + a2_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + + +public class Cycle_a_00360 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00360_A1 a1_main = new Cycle_a_00360_A1("a1_main"); + Cycle_a_00360_A4 a4_main = new Cycle_a_00360_A4("a4_main"); + Cycle_a_00360_A6 a6_main = new Cycle_a_00360_A6("a6_main"); + Cycle_a_00360_A9 a9_main = new Cycle_a_00360_A9("a9_main"); + a1_main.a2_0 = new Cycle_a_00360_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00360_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00360_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00360_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00360_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a5_0.a9_0 = a9_main; + a9_main.a2_0 = a1_main.a2_0; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a9_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a9_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2399) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0020-rc-function-Cycle_a_00370/Cycle_a_00370.java b/test/testsuite/ouroboros/rc_test/RC0020-rc-function-Cycle_a_00370/Cycle_a_00370.java new file mode 100755 index 0000000000000000000000000000000000000000..50ec8ada6e7513d0e030f01d88f35d15f04861f3 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0020-rc-function-Cycle_a_00370/Cycle_a_00370.java @@ -0,0 +1,281 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00370.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00370 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00370.java + *- @ExecuteClass: Cycle_a_00370 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2 ; A4 depend A1 ; A6 depend A1 A3; + * A2 depend A3 A4; A3 depend A1 A5 A10; A5 depend A6 A8 + * A7 depend A2 ; A8 depend A7; + * A8 depend A6 ; A10 depend A9; + * A1.a=101 A2.a=102 A3.a=103 ... A9.a=109 A10.a=1001 + * RC-Testing_Result=(101+102)+(102+103+104)+(103+101+105+110)+(104+101)+(105+106+108)+(106+101+103)+(107+102)+(108+107)+(109+106)+(110+109)=2623 + * + */ + +class Cycle_a_00370_A1 { + Cycle_a_00370_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00370_A2 { + Cycle_a_00370_A3 a3_0; + Cycle_a_00370_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } +} + +class Cycle_a_00370_A3 { + Cycle_a_00370_A1 a1_0; + Cycle_a_00370_A5 a5_0; + Cycle_a_00370_A10 a10_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a10_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a + a10_0.a; + } +} + + +class Cycle_a_00370_A4 { + Cycle_a_00370_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } +} + +class Cycle_a_00370_A5 { + Cycle_a_00370_A6 a6_0; + Cycle_a_00370_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a + a8_0.a; + } +} + +class Cycle_a_00370_A6 { + Cycle_a_00370_A1 a1_0; + Cycle_a_00370_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } +} + + +class Cycle_a_00370_A7 { + Cycle_a_00370_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_a_00370_A8 { + Cycle_a_00370_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } +} + + +class Cycle_a_00370_A9 { + Cycle_a_00370_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A9(String strObjectName) { + a6_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } +} + +class Cycle_a_00370_A10 { + Cycle_a_00370_A9 a9_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A10(String strObjectName) { + a9_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + + void add() { + sum = a + a9_0.a; + } +} + +public class Cycle_a_00370 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00370_A1 a1_main = new Cycle_a_00370_A1("a1_main"); + Cycle_a_00370_A4 a4_main = new Cycle_a_00370_A4("a4_main"); + Cycle_a_00370_A6 a6_main = new Cycle_a_00370_A6("a6_main"); + Cycle_a_00370_A9 a9_main = new Cycle_a_00370_A9("a9_main"); + a1_main.a2_0 = new Cycle_a_00370_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00370_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00370_A5("a5_0"); + a1_main.a2_0.a3_0.a10_0 = new Cycle_a_00370_A10("a10_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00370_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00370_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a10_0.a9_0 = a9_main; + a9_main.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a9_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a10_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a9_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum + a6_main.a3_0.a10_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2623) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0021-rc-function-Cycle_a_00380/Cycle_a_00380.java b/test/testsuite/ouroboros/rc_test/RC0021-rc-function-Cycle_a_00380/Cycle_a_00380.java new file mode 100755 index 0000000000000000000000000000000000000000..a864e5e0b307d55729ae9bb2a961555450c6e868 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0021-rc-function-Cycle_a_00380/Cycle_a_00380.java @@ -0,0 +1,116 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00380.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00380 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00380.java + *- @ExecuteClass: Cycle_a_00380 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2 A3; A2 depend A1 A3; A3 depend A1 + * A1.a=101 A2.a=102 A3.a=103 + * RC-Testing_Result=(101+102)+(102+101+103)+(103++101+102)=815 + * + */ + +class Cycle_a_00380_A1 { + Cycle_a_00380_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00380_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00380_A2 { + Cycle_a_00380_A1 a1_0; + Cycle_a_00380_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00380_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } +} + +class Cycle_a_00380_A3 { + Cycle_a_00380_A1 a1_0; + Cycle_a_00380_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00380_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a2_0.a; + } +} + + +public class Cycle_a_00380 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00380_A1 a1_main = new Cycle_a_00380_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00380_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00380_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a2_0 = a1_main.a2_0; + + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 815) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0022-rc-function-Cycle_a_00390/Cycle_a_00390.java b/test/testsuite/ouroboros/rc_test/RC0022-rc-function-Cycle_a_00390/Cycle_a_00390.java new file mode 100755 index 0000000000000000000000000000000000000000..f012de3c7864214305385c036fd0cc65dd2c8857 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0022-rc-function-Cycle_a_00390/Cycle_a_00390.java @@ -0,0 +1,119 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00390.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00390 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00390.java + *- @ExecuteClass: Cycle_a_00390 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2 A3; A2 depend A1 A3; A3 depend A1 A2 + * A1.a=101 A2.a=102 A3.a=103 + * RC-Testing_Result=(101+102+103)+(102+101+103)+(103+101+102)=918 + * + */ + +class Cycle_a_00390_A1 { + Cycle_a_00390_A2 a2_0; + Cycle_a_00390_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00390_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } +} + +class Cycle_a_00390_A2 { + Cycle_a_00390_A1 a1_0; + Cycle_a_00390_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00390_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } +} + +class Cycle_a_00390_A3 { + Cycle_a_00390_A1 a1_0; + Cycle_a_00390_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00390_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a2_0.a; + } +} + + +public class Cycle_a_00390 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00390_A1 a1_main = new Cycle_a_00390_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00390_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00390_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 918) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0023-rc-function-Cycle_a_00400/Cycle_a_00400.java b/test/testsuite/ouroboros/rc_test/RC0023-rc-function-Cycle_a_00400/Cycle_a_00400.java new file mode 100755 index 0000000000000000000000000000000000000000..3c61b62e1d2aba65a60ab1fcf4f760593fb35ec7 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0023-rc-function-Cycle_a_00400/Cycle_a_00400.java @@ -0,0 +1,134 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00400.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00400 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00400.java + *- @ExecuteClass: Cycle_a_00400 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2 A4; A2 depend A3; A3 depend A1 ; A4 depend A3 + * A1.a=101 A2.a=102 A3.a=103 ... A6.a=106 A7.a=107 + * RC-Testing_Result=(101+102+104)+(102+103)+(103+101)+(104+103)=923 + * + */ + +class Cycle_a_00400_A1 { + Cycle_a_00400_A2 a2_0; + Cycle_a_00400_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00400_A1(String strObjectName) { + a2_0 = null; + a4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a4_0.a; + } +} + +class Cycle_a_00400_A2 { + Cycle_a_00400_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00400_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00400_A3 { + Cycle_a_00400_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00400_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_a_00400_A4 { + Cycle_a_00400_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00400_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + + +public class Cycle_a_00400 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00400_A1 a1_main = new Cycle_a_00400_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00400_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00400_A3("a3_0"); + a1_main.a4_0 = new Cycle_a_00400_A4("a4_0"); + a1_main.a4_0.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a1_0 = a1_main; + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a4_0.add(); + + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 923) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0024-rc-function-Cycle_a_00410/Cycle_a_00410.java b/test/testsuite/ouroboros/rc_test/RC0024-rc-function-Cycle_a_00410/Cycle_a_00410.java new file mode 100755 index 0000000000000000000000000000000000000000..93800e692c3fcbd447263a7a8b036f7e85edc5a7 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0024-rc-function-Cycle_a_00410/Cycle_a_00410.java @@ -0,0 +1,134 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00410.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00410 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00410.java + *- @ExecuteClass: Cycle_a_00410 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2 ; A2 depend A3 A4; A3 depend A1 ; A4 depend A1 + * A1.a=101 A2.a=102 A3.a=103 ... A6.a=106 A7.a=107 + * RC-Testing_Result=(101+102)+(102++103+104)+(103+101)+(104+101)=921 + * + */ + +class Cycle_a_00410_A1 { + Cycle_a_00410_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00410_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00410_A2 { + Cycle_a_00410_A3 a3_0; + Cycle_a_00410_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00410_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } +} + +class Cycle_a_00410_A3 { + Cycle_a_00410_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00410_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_a_00410_A4 { + Cycle_a_00410_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00410_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } +} + + +public class Cycle_a_00410 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00410_A1 a1_main = new Cycle_a_00410_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00410_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00410_A3("a3_0"); + a1_main.a2_0.a4_0 = new Cycle_a_00410_A4("a4_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a4_0.a1_0 = a1_main; + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a4_0.add(); + + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 921) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0025-rc-function-Cycle_a_00420/Cycle_a_00420.java b/test/testsuite/ouroboros/rc_test/RC0025-rc-function-Cycle_a_00420/Cycle_a_00420.java new file mode 100755 index 0000000000000000000000000000000000000000..8abf6ef7ec1d0c80afc14ba8cf2ccf97c18345b6 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0025-rc-function-Cycle_a_00420/Cycle_a_00420.java @@ -0,0 +1,133 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00420.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00420 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00420.java + *- @ExecuteClass: Cycle_a_00420 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2 A3 ; A2 depend A3 ; A3 depend A4 ; A4 depend A1 + * A1.a=101 A2.a=102 A3.a=103 ... A6.a=106 A7.a=107 + * RC-Testing_Result=(101+102+103)+(102+103)+(103+104)+(104+101)=923 + * + */ + +class Cycle_a_00420_A1 { + Cycle_a_00420_A2 a2_0; + Cycle_a_00420_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00420_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } +} + +class Cycle_a_00420_A2 { + Cycle_a_00420_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00420_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00420_A3 { + Cycle_a_00420_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00420_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } +} + + +class Cycle_a_00420_A4 { + Cycle_a_00420_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00420_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } +} + + +public class Cycle_a_00420 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00420_A1 a1_main = new Cycle_a_00420_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00420_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00420_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00420_A4("a4_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum; + if (result == 923) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0026-rc-function-Cycle_a_00430/Cycle_a_00430.java b/test/testsuite/ouroboros/rc_test/RC0026-rc-function-Cycle_a_00430/Cycle_a_00430.java new file mode 100755 index 0000000000000000000000000000000000000000..bc0f7df4fd601f9524576e45298a13987f1c1c87 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0026-rc-function-Cycle_a_00430/Cycle_a_00430.java @@ -0,0 +1,141 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00430.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00430 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00430.java + *- @ExecuteClass: Cycle_a_00430 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2 ; A2 depend A1 A3 A4 ; A3 depend A1 ; A4 depend A1 A2 + * A1.a=101 A2.a=102 A3.a=103 ... A4.a=104 + * RC-Testing_Result=(101+102)+(102+101+103+104)+(103+101)+(104+101+102)=1124 + * + */ + +class Cycle_a_00430_A1 { + Cycle_a_00430_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00430_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00430_A2 { + Cycle_a_00430_A1 a1_0; + Cycle_a_00430_A3 a3_0; + Cycle_a_00430_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00430_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } +} + +class Cycle_a_00430_A3 { + Cycle_a_00430_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00430_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_a_00430_A4 { + Cycle_a_00430_A1 a1_0; + Cycle_a_00430_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00430_A4(String strObjectName) { + a2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a2_0.a; + } +} + + +public class Cycle_a_00430 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00430_A1 a1_main = new Cycle_a_00430_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00430_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00430_A3("a3_0"); + a1_main.a2_0.a4_0 = new Cycle_a_00430_A4("a4_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a4_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a4_0.a1_0 = a1_main; + + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a4_0.add(); + + + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1124) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0027-rc-function-Cycle_a_00440/Cycle_a_00440.java b/test/testsuite/ouroboros/rc_test/RC0027-rc-function-Cycle_a_00440/Cycle_a_00440.java new file mode 100755 index 0000000000000000000000000000000000000000..b52e4748b5cf9c8681aff568add13e28aa155e0f --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0027-rc-function-Cycle_a_00440/Cycle_a_00440.java @@ -0,0 +1,134 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00440.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00440 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00440.java + *- @ExecuteClass: Cycle_a_00440 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2 ; A2 depend A1 A3 A4 ; A3 depend A1 ; A4 depend A2 + * A1.a=101 A2.a=102 A3.a=103 ... A4.a=104 + * RC-Testing_Result=(101+102)+(102+101+103+104)+(103+101)+(104+102)=1023 + * + */ + +class Cycle_a_00440_A1 { + Cycle_a_00440_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00440_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00440_A2 { + Cycle_a_00440_A1 a1_0; + Cycle_a_00440_A3 a3_0; + Cycle_a_00440_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00440_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } +} + +class Cycle_a_00440_A3 { + Cycle_a_00440_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00440_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_a_00440_A4 { + Cycle_a_00440_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00440_A4(String strObjectName) { + a2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + + +public class Cycle_a_00440 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00440_A1 a1_main = new Cycle_a_00440_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00440_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00440_A3("a3_0"); + a1_main.a2_0.a4_0 = new Cycle_a_00440_A4("a4_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a4_0.a2_0 = a1_main.a2_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a4_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a4_0.sum; + if (result == 1023) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0028-rc-function-Cycle_a_00450/Cycle_a_00450.java b/test/testsuite/ouroboros/rc_test/RC0028-rc-function-Cycle_a_00450/Cycle_a_00450.java new file mode 100755 index 0000000000000000000000000000000000000000..a6c2ffd2a075de3ffb57e92b493ae0ce17612400 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0028-rc-function-Cycle_a_00450/Cycle_a_00450.java @@ -0,0 +1,181 @@ + +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00450.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00450 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00450.java + *- @ExecuteClass: Cycle_a_00450 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2 ; A2 depend A3 ; A3 depend A1 A5 ; A5 depend A6 A7 + * A6 depend A3 ; A7 depend A2 + * A1.a=101 A2.a=102 A3.a=103 ... A6.a=106 A7.a=107 + * RC-Testing_Result=(101+102)+(102+103)+(103+101+105)+(105+106+107)+(106+103)+(107+102)=1453 + * + */ + +class Cycle_a_00450_A1 { + Cycle_a_00450_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00450_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00450_A2 { + Cycle_a_00450_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00450_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00450_A3 { + Cycle_a_00450_A1 a1_0; + Cycle_a_00450_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00450_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } +} + + +class Cycle_a_00450_A5 { + Cycle_a_00450_A6 a6_0; + Cycle_a_00450_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00450_A5(String strObjectName) { + a6_0 = null; + a7_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a + a7_0.a; + } +} + +class Cycle_a_00450_A6 { + Cycle_a_00450_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00450_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00450_A7 { + Cycle_a_00450_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00450_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + + +public class Cycle_a_00450 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00450_A1 a1_main = new Cycle_a_00450_A1("a1_main"); + Cycle_a_00450_A6 a6_main = new Cycle_a_00450_A6("a6_main"); + Cycle_a_00450_A7 a7_main = new Cycle_a_00450_A7("a7_main"); + a1_main.a2_0 = new Cycle_a_00450_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00450_A3("a3_0"); + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00450_A5("a5_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a5_0.a7_0 = a7_main; + a7_main.a2_0 = a1_main.a2_0; + + a1_main.add(); + a6_main.add(); + a7_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + int result = a1_main.sum + a6_main.sum + a7_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + if (result == 1453) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0029-rc-function-Cycle_a_00460/Cycle_a_00460.java b/test/testsuite/ouroboros/rc_test/RC0029-rc-function-Cycle_a_00460/Cycle_a_00460.java new file mode 100755 index 0000000000000000000000000000000000000000..588f747bef6252f74cf3c9ed836d2c56d877edae --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0029-rc-function-Cycle_a_00460/Cycle_a_00460.java @@ -0,0 +1,186 @@ + +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00460.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00460 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00460.java + *- @ExecuteClass: Cycle_a_00460 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2 A4 ; A2 depend A3 ; A3 depend A4 ; A4 depend A1 A6 + * A5 depend A3 ; A6 depend A1 A5 + * A1.a=101 A2.a=102 A3.a=103 ... A6.a=106 + * RC-Testing_Result=(101+102+104)+(102+103)+(103+104)+(104+106+101)+(105+103)+(106+105+101)=1550 + * + */ + +class Cycle_a_00460_A1 { + Cycle_a_00460_A2 a2_0; + Cycle_a_00460_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00460_A1(String strObjectName) { + a2_0 = null; + a4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a4_0.a; + } +} + +class Cycle_a_00460_A2 { + Cycle_a_00460_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00460_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00460_A3 { + Cycle_a_00460_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00460_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } +} + + +class Cycle_a_00460_A4 { + Cycle_a_00460_A1 a1_0; + Cycle_a_00460_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00460_A4(String strObjectName) { + a1_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a6_0.a; + } +} + +class Cycle_a_00460_A5 { + Cycle_a_00460_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00460_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00460_A6 { + Cycle_a_00460_A1 a1_0; + Cycle_a_00460_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00460_A6(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } +} + + +public class Cycle_a_00460 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00460_A1 a1_main = new Cycle_a_00460_A1("a1_main"); + Cycle_a_00460_A5 a5_main = new Cycle_a_00460_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00460_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00460_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00460_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.a2_0.a3_0.a4_0.a6_0 = new Cycle_a_00460_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a1_main.a2_0.a3_0.a4_0.a6_0.a1_0 = a1_main; + + a5_main.a3_0 = a1_main.a2_0.a3_0; + + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); + + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a6_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1550) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0030-rc-function-Cycle_a_00470/Cycle_a_00470.java b/test/testsuite/ouroboros/rc_test/RC0030-rc-function-Cycle_a_00470/Cycle_a_00470.java new file mode 100755 index 0000000000000000000000000000000000000000..d2dc8a220f174d60b6101677ec1011e6d1315c04 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0030-rc-function-Cycle_a_00470/Cycle_a_00470.java @@ -0,0 +1,181 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00470.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00470 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00470.java + *- @ExecuteClass: Cycle_a_00470 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2 ; A2 depend A3 ; A3 depend A4 ; A4 depend A1 A6 + * A5 depend A3 A1 ; A6 depend A5 + * A1.a=101 A2.a=102 A3.a=103 ... A6.a=106 + * RC-Testing_Result=(101+102)+(102+103)+(103+104)+(104+106+101)+(105+103+101)+(106+105)=1446 + * + */ + +class Cycle_a_00470_A1 { + Cycle_a_00470_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00470_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00470_A2 { + Cycle_a_00470_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00470_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00470_A3 { + Cycle_a_00470_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00470_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } +} + + +class Cycle_a_00470_A4 { + Cycle_a_00470_A1 a1_0; + Cycle_a_00470_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00470_A4(String strObjectName) { + a1_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a6_0.a; + } +} + +class Cycle_a_00470_A5 { + Cycle_a_00470_A1 a1_0; + Cycle_a_00470_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00470_A5(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } +} + +class Cycle_a_00470_A6 { + Cycle_a_00470_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00470_A6(String strObjectName) { + a5_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } +} + + +public class Cycle_a_00470 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00470_A1 a1_main = new Cycle_a_00470_A1("a1_main"); + Cycle_a_00470_A5 a5_main = new Cycle_a_00470_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00470_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00470_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00470_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0.a6_0 = new Cycle_a_00470_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a1_0 = a1_main; + + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); + + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a6_0.sum; + if (result == 1446) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0031-rc-function-Cycle_a_00480/Cycle_a_00480.java b/test/testsuite/ouroboros/rc_test/RC0031-rc-function-Cycle_a_00480/Cycle_a_00480.java new file mode 100755 index 0000000000000000000000000000000000000000..395546c619d09fbc77bfbe9630d12230fbdc3e6e --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0031-rc-function-Cycle_a_00480/Cycle_a_00480.java @@ -0,0 +1,185 @@ + +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00480.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00480 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00480.java + *- @ExecuteClass: Cycle_a_00480 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2 ; A2 depend A3 ; A3 depend A4 ; A4 depend A1 A6 + * A5 depend A3 ; A6 depend A1 A4 A5 + * A1.a=101 A2.a=102 A3.a=103 ... A6.a=106 + * RC-Testing_Result=(101+102)+(102+103)+(103+104)+(104+106+101)+(105+103)+(106+101+104+105)=1550 + * + */ + +class Cycle_a_00480_A1 { + Cycle_a_00480_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00480_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00480_A2 { + Cycle_a_00480_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00480_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00480_A3 { + Cycle_a_00480_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00480_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } +} + + +class Cycle_a_00480_A4 { + Cycle_a_00480_A1 a1_0; + Cycle_a_00480_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00480_A4(String strObjectName) { + a1_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a6_0.a; + } +} + +class Cycle_a_00480_A5 { + Cycle_a_00480_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00480_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00480_A6 { + Cycle_a_00480_A1 a1_0; + Cycle_a_00480_A4 a4_0; + Cycle_a_00480_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00480_A6(String strObjectName) { + a1_0 = null; + a4_0 = null; + a5_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a4_0.a + a5_0.a; + } +} + +public class Cycle_a_00480 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00480_A1 a1_main = new Cycle_a_00480_A1("a1_main"); + Cycle_a_00480_A5 a5_main = new Cycle_a_00480_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00480_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00480_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00480_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0.a6_0 = new Cycle_a_00480_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a1_main.a2_0.a3_0.a4_0.a6_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.a2_0.a3_0.a4_0.a6_0.a1_0 = a1_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a3_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a1_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); + a5_main.a3_0.add(); + a5_main.a3_0.a4_0.add(); + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a6_0.sum; + if (result == 1550) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0032-rc-function-Cycle_a_00490/Cycle_a_00490.java b/test/testsuite/ouroboros/rc_test/RC0032-rc-function-Cycle_a_00490/Cycle_a_00490.java new file mode 100755 index 0000000000000000000000000000000000000000..2e9edeeb75fe61b50d8bb3bafb871f4c80f5771c --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0032-rc-function-Cycle_a_00490/Cycle_a_00490.java @@ -0,0 +1,255 @@ + +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00490.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00490 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00490.java + *- @ExecuteClass: Cycle_a_00490 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2 ; A2 depend A3 ; A3 depend A1 + * A4 depend A5 ; A5 depend A6 ; A6 depend A4 + * A8 depend A7 A5 ; A7 depend A9 ; A9 depend A8 + * A1.a=101 A2.a=102 A3.a=103 ... A9.a=109 + * RC-Testing_Result=(101+102)+(102+103)+(103+101)+(104+105)+(105+106)+(106+104+103)+(107+109)+(108+107+105)+(109+108)=2098 + * + */ + +class Cycle_a_00490_A1 { + Cycle_a_00490_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00490_A2 { + Cycle_a_00490_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00490_A3 { + Cycle_a_00490_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_a_00490_A4 { + Cycle_a_00490_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } +} + +class Cycle_a_00490_A5 { + Cycle_a_00490_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } +} + +class Cycle_a_00490_A6 { + Cycle_a_00490_A3 a3_0; + Cycle_a_00490_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A6(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } +} + + +class Cycle_a_00490_A7 { + Cycle_a_00490_A9 a9_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A7(String strObjectName) { + a9_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a9_0.a; + } +} + + +class Cycle_a_00490_A8 { + Cycle_a_00490_A5 a5_0; + Cycle_a_00490_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A8(String strObjectName) { + a5_0 = null; + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a + a5_0.a; + } +} + + +class Cycle_a_00490_A9 { + Cycle_a_00490_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A9(String strObjectName) { + a8_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + + void add() { + sum = a + a8_0.a; + } +} + + +public class Cycle_a_00490 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00490_A1 a1_main = new Cycle_a_00490_A1("a1_main"); + Cycle_a_00490_A4 a4_main = new Cycle_a_00490_A4("a4_main"); + Cycle_a_00490_A7 a7_main = new Cycle_a_00490_A7("a7_main"); + a1_main.a2_0 = new Cycle_a_00490_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00490_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + + a4_main.a5_0 = new Cycle_a_00490_A5("a5_0"); + a4_main.a5_0.a6_0 = new Cycle_a_00490_A6("a6_0"); + a4_main.a5_0.a6_0.a4_0 = a4_main; + a4_main.a5_0.a6_0.a3_0 = a1_main.a2_0.a3_0; + a4_main.a5_0.a6_0.a3_0.a1_0 = a1_main; + a7_main.a9_0 = new Cycle_a_00490_A9("a9_0"); + a7_main.a9_0.a8_0 = new Cycle_a_00490_A8("a8_0"); + a7_main.a9_0.a8_0.a7_0 = a7_main; + a7_main.a9_0.a8_0.a5_0 = a4_main.a5_0; + a1_main.add(); + a4_main.add(); + a7_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a1_0.add(); + a4_main.a5_0.add(); + a4_main.a5_0.a6_0.add(); + a4_main.a5_0.a6_0.a4_0.add(); + a4_main.a5_0.a6_0.a3_0.add(); + a4_main.a5_0.a6_0.a3_0.a1_0.add(); + a7_main.a9_0.add(); + a7_main.a9_0.a8_0.add(); + a7_main.a9_0.a8_0.a7_0.add(); + a7_main.a9_0.a8_0.a5_0.add(); + int result = a1_main.sum + a4_main.sum + a7_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a4_main.a5_0.sum + a4_main.a5_0.a6_0.sum + a7_main.a9_0.sum + a7_main.a9_0.a8_0.sum; + if (result == 2098) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0033-rc-function-Cycle_a_00500/Cycle_a_00500.java b/test/testsuite/ouroboros/rc_test/RC0033-rc-function-Cycle_a_00500/Cycle_a_00500.java new file mode 100755 index 0000000000000000000000000000000000000000..a6248ae780140cfffcfcb16e6d85c07c9a1b5a7f --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0033-rc-function-Cycle_a_00500/Cycle_a_00500.java @@ -0,0 +1,258 @@ + +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_00500.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00500 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_00500.java + *- @ExecuteClass: Cycle_a_00500 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2 ; A2 depend A3 ; A3 depend A1 + * A4 depend A5 ; A5 depend A6 ; A6 depend A4 ; A4 depend A1 + * A5 depend A8 ; A8 depend A7 ; A7 depend A9 ; A9 depend A8 + * A1.a=101 A2.a=102 A3.a=103 ... A9.a=109 + * RC-Testing_Result=(101+102)+(102+103)+(103+101)+(104+101+105)+(106+104)+(105+106+108)+(107+109)+(108+107)+(109+108)=2099 + * + */ + +class Cycle_a_00500_A1 { + Cycle_a_00500_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00500_A2 { + Cycle_a_00500_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_00500_A3 { + Cycle_a_00500_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_a_00500_A4 { + Cycle_a_00500_A1 a1_0; + Cycle_a_00500_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A4(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } +} + +class Cycle_a_00500_A5 { + Cycle_a_00500_A6 a6_0; + Cycle_a_00500_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a + a8_0.a; + } +} + +class Cycle_a_00500_A6 { + Cycle_a_00500_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A6(String strObjectName) { + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } +} + + +class Cycle_a_00500_A7 { + Cycle_a_00500_A9 a9_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A7(String strObjectName) { + a9_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a9_0.a; + } +} + + +class Cycle_a_00500_A8 { + Cycle_a_00500_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } +} + + +class Cycle_a_00500_A9 { + Cycle_a_00500_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A9(String strObjectName) { + a8_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + + void add() { + sum = a + a8_0.a; + } +} + + +public class Cycle_a_00500 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00500_A1 a1_main = new Cycle_a_00500_A1("a1_main"); + Cycle_a_00500_A4 a4_main = new Cycle_a_00500_A4("a4_main"); + Cycle_a_00500_A7 a7_main = new Cycle_a_00500_A7("a7_main"); + a1_main.a2_0 = new Cycle_a_00500_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00500_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + + a4_main.a1_0 = a1_main; + a4_main.a5_0 = new Cycle_a_00500_A5("a5_0"); + a4_main.a5_0.a6_0 = new Cycle_a_00500_A6("a6_0"); + a4_main.a5_0.a6_0.a4_0 = a4_main; + + a4_main.a5_0.a8_0 = new Cycle_a_00500_A8("a8_0"); + a4_main.a5_0.a8_0.a7_0 = a7_main; + + a7_main.a9_0 = new Cycle_a_00500_A9("a9_0"); + a7_main.a9_0.a8_0 = new Cycle_a_00500_A8("a8_0"); + a7_main.a9_0.a8_0.a7_0 = a7_main; + + a1_main.add(); + a4_main.add(); + a7_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a1_0.add(); + a4_main.a1_0.add(); + a4_main.a5_0.add(); + a4_main.a5_0.a6_0.add(); + a4_main.a5_0.a6_0.a4_0.add(); + a4_main.a5_0.a8_0.add(); + a4_main.a5_0.a8_0.a7_0.add(); + a7_main.a9_0.add(); + a7_main.a9_0.a8_0.add(); + a7_main.a9_0.a8_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a7_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a4_main.a5_0.sum + a4_main.a5_0.a6_0.sum + a7_main.a9_0.sum + a7_main.a9_0.a8_0.sum; + if (result == 2099) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0034-rc-function-Cycle_a_10010/Cycle_a_10010.java b/test/testsuite/ouroboros/rc_test/RC0034-rc-function-Cycle_a_10010/Cycle_a_10010.java new file mode 100755 index 0000000000000000000000000000000000000000..93b07b77a752c0194e7308d5170602a9ca168bc5 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0034-rc-function-Cycle_a_10010/Cycle_a_10010.java @@ -0,0 +1,379 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_10010.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_10010 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_10010.java + *- @ExecuteClass: Cycle_a_10010 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_a_10010_A1 { + Cycle_a_10010_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_10010_A2 { + Cycle_a_10010_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_10010_A3 { + Cycle_a_10010_A1 a1_0; + Cycle_a_10010_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } +} + +class Cycle_a_10010_A4 { + Cycle_a_10010_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_a_10010_A5 { + Cycle_a_10010_A4 a4_0; + Cycle_a_10010_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_A5(String strObjectName) { + a4_0 = null; + a7_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a4_0.a + a7_0.a; + } +} + +class Cycle_a_10010_A6 { + Cycle_a_10010_A5 a5_0; + Cycle_a_10010_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_A6(String strObjectName) { + a5_0 = null; + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a5_0.a + a7_0.a; + } +} + +class Cycle_a_10010_A7 { + int a; + int sum; + String strObjectName; + + Cycle_a_10010_A7(String strObjectName) { + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Cycle_a_10010_2A1 { + Cycle_a_10010_2A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_2A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_10010_2A2 { + Cycle_a_10010_2A3 a3_0; + Cycle_a_10010_2A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_2A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } +} + +class Cycle_a_10010_2A3 { + Cycle_a_10010_2A1 a1_0; + Cycle_a_10010_2A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_2A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } +} + + +class Cycle_a_10010_2A4 { + Cycle_a_10010_2A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_2A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } +} + +class Cycle_a_10010_2A5 { + Cycle_a_10010_2A6 a6_0; + Cycle_a_10010_2A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_2A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a + a8_0.a; + } +} + +class Cycle_a_10010_2A6 { + Cycle_a_10010_2A1 a1_0; + Cycle_a_10010_2A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_2A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } +} + + +class Cycle_a_10010_2A7 { + Cycle_a_10010_2A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_2A7(String strObjectName) { + a3_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_a_10010_2A8 { + Cycle_a_10010_2A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_2A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } +} + + +public class Cycle_a_10010 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_10010_A1 a1_main = new Cycle_a_10010_A1("a1_main"); + Cycle_a_10010_A4 a4_main = new Cycle_a_10010_A4("a4_main"); + Cycle_a_10010_A6 a6_main = new Cycle_a_10010_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_10010_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_10010_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_10010_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a4_0 = a4_main; + a4_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a5_0.a7_0 = new Cycle_a_10010_A7("a7_0"); + a6_main.a7_0 = a1_main.a2_0.a3_0.a5_0.a7_0; + a6_main.a5_0 = a1_main.a2_0.a3_0.a5_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a7_0.sum; + Cycle_a_10010_2A1 a1_2main = new Cycle_a_10010_2A1("a1_2main"); + Cycle_a_10010_2A4 a4_2main = new Cycle_a_10010_2A4("a4_2main"); + Cycle_a_10010_2A6 a6_2main = new Cycle_a_10010_2A6("a6_2main"); + a1_2main.a2_0 = new Cycle_a_10010_2A2("a2_0"); + a1_2main.a2_0.a3_0 = new Cycle_a_10010_2A3("a3_0"); + a1_2main.a2_0.a4_0 = a4_2main; + a4_2main.a1_0 = a1_2main; + a1_2main.a2_0.a3_0.a1_0 = a1_2main; + a1_2main.a2_0.a3_0.a5_0 = new Cycle_a_10010_2A5("a5_0"); + a1_2main.a2_0.a3_0.a5_0.a6_0 = a6_2main; + a1_2main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_10010_2A8("a8_0"); + a1_2main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_10010_2A7("a7_0"); + a1_2main.a2_0.a3_0.a5_0.a8_0.a7_0.a3_0 = a1_2main.a2_0.a3_0; + a6_2main.a1_0 = a1_2main; + a6_2main.a3_0 = a1_2main.a2_0.a3_0; + a1_2main.add(); + a4_2main.add(); + a6_2main.add(); + a1_2main.a2_0.add(); + a1_2main.a2_0.a3_0.add(); + a1_2main.a2_0.a3_0.a5_0.add(); + a1_2main.a2_0.a3_0.a5_0.a8_0.add(); + a1_2main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + int result2 = a1_2main.sum + a4_2main.sum + a6_2main.sum + a1_2main.a2_0.sum + a1_2main.a2_0.a3_0.sum + a1_2main.a2_0.a3_0.a5_0.sum + a6_2main.a3_0.a5_0.a8_0.a7_0.sum + a6_2main.a3_0.a5_0.a8_0.sum; + result += result2; + if (result == 3852) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0035-rc-function-Cycle_a_10020/Cycle_a_10020.java b/test/testsuite/ouroboros/rc_test/RC0035-rc-function-Cycle_a_10020/Cycle_a_10020.java new file mode 100755 index 0000000000000000000000000000000000000000..db8f23bd696a4200c05b8ab9a9c83652bb48ebba --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0035-rc-function-Cycle_a_10020/Cycle_a_10020.java @@ -0,0 +1,343 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_a_10020.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_10020 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_a_10020.java + *- @ExecuteClass: Cycle_a_10020 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_a_10020_A1 { + Cycle_a_10020_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_10020_A2 { + Cycle_a_10020_A3 a3_0; + Cycle_a_10020_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } +} + +class Cycle_a_10020_A3 { + Cycle_a_10020_A1 a1_0; + Cycle_a_10020_A5 a5_0; + Cycle_a_10020_A10 a10_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a10_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a + a10_0.a; + } +} + + +class Cycle_a_10020_A4 { + Cycle_a_10020_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } +} + +class Cycle_a_10020_A5 { + Cycle_a_10020_A6 a6_0; + Cycle_a_10020_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a + a8_0.a; + } +} + +class Cycle_a_10020_A6 { + Cycle_a_10020_A1 a1_0; + Cycle_a_10020_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } +} + + +class Cycle_a_10020_A7 { + Cycle_a_10020_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_a_10020_A8 { + Cycle_a_10020_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } +} + + +class Cycle_a_10020_A9 { + Cycle_a_10020_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A9(String strObjectName) { + a6_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } +} + +class Cycle_a_10020_A10 { + Cycle_a_10020_A9 a9_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A10(String strObjectName) { + a9_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + + void add() { + sum = a + a9_0.a; + } +} + +class Cycle_a_10020_2A1 { + Cycle_a_10020_2A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_2A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_10020_2A2 { + Cycle_a_10020_2A1 a1_0; + Cycle_a_10020_2A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_2A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } +} + +class Cycle_a_10020_2A3 { + Cycle_a_10020_2A1 a1_0; + Cycle_a_10020_2A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_2A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a2_0.a; + } +} + + +public class Cycle_a_10020 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_10020_A1 a1_main = new Cycle_a_10020_A1("a1_main"); + Cycle_a_10020_A4 a4_main = new Cycle_a_10020_A4("a4_main"); + Cycle_a_10020_A6 a6_main = new Cycle_a_10020_A6("a6_main"); + Cycle_a_10020_A9 a9_main = new Cycle_a_10020_A9("a9_main"); + a1_main.a2_0 = new Cycle_a_10020_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_10020_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_10020_A5("a5_0"); + a1_main.a2_0.a3_0.a10_0 = new Cycle_a_10020_A10("a10_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_10020_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_10020_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a10_0.a9_0 = a9_main; + a9_main.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a9_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a10_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a9_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum + a6_main.a3_0.a10_0.sum; + //System.out.println("RC-Testing_Result="+result); + Cycle_a_10020_2A1 a1_2main = new Cycle_a_10020_2A1("a1_2main"); + a1_2main.a2_0 = new Cycle_a_10020_2A2("a2_0"); + a1_2main.a2_0.a1_0 = a1_2main; + a1_2main.a2_0.a3_0 = new Cycle_a_10020_2A3("a3_0"); + a1_2main.a2_0.a3_0.a1_0 = a1_2main; + a1_2main.a2_0.a3_0.a2_0 = a1_2main.a2_0; + a1_2main.add(); + a1_2main.a2_0.add(); + a1_2main.a2_0.a3_0.add(); + int result2 = a1_2main.sum + a1_2main.a2_0.sum + a1_2main.a2_0.a3_0.sum; + //System.out.println("RC-Testing_Result="+result); + result += result2; + if (result == (2623 + 815)) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0036-rc-function-Cycle_B_1_00010/Cycle_B_1_00010.java b/test/testsuite/ouroboros/rc_test/RC0036-rc-function-Cycle_B_1_00010/Cycle_B_1_00010.java new file mode 100755 index 0000000000000000000000000000000000000000..a9b82c481b9b238626a0587c9d769b302e8f7b25 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0036-rc-function-Cycle_B_1_00010/Cycle_B_1_00010.java @@ -0,0 +1,55 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_1_00010.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_1_00010 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_1_00010.java + *- @ExecuteClass: Cycle_B_1_00010 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_1_00010_A1 { + Cycle_B_1_00010_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00010_A1() { + a1_0 = null; + a = 123; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + +public class Cycle_B_1_00010 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00010_A1 a1_0 = new Cycle_B_1_00010_A1(); + a1_0.a1_0 = a1_0; + a1_0.add(); + int nsum = a1_0.sum; + if (nsum == 246) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0037-rc-function-Cycle_B_1_00020/Cycle_B_1_00020.java b/test/testsuite/ouroboros/rc_test/RC0037-rc-function-Cycle_B_1_00020/Cycle_B_1_00020.java new file mode 100755 index 0000000000000000000000000000000000000000..48009185b9c65f6f873b8fda0ad3078721232e31 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0037-rc-function-Cycle_B_1_00020/Cycle_B_1_00020.java @@ -0,0 +1,77 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_1_00020.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Cycle_B_1_00020 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_1_00020.java + *- @ExecuteClass: Cycle_B_1_00020 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_1_00020_A1 { + Cycle_B_1_00020_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00020_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_1_00020_A2 { + Cycle_B_1_00020_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00020_A2() { + a1_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +public class Cycle_B_1_00020 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00020_A1 a1_0 = new Cycle_B_1_00020_A1(); + a1_0.a2_0 = new Cycle_B_1_00020_A2(); + a1_0.a2_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + + int nsum = (a1_0.sum + a1_0.a2_0.sum); + + if (nsum == 6) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0038-rc-function-Cycle_B_1_00030/Cycle_B_1_00030.java b/test/testsuite/ouroboros/rc_test/RC0038-rc-function-Cycle_B_1_00030/Cycle_B_1_00030.java new file mode 100755 index 0000000000000000000000000000000000000000..ec52068283fa89dbdbe29032ff780f2830caacef --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0038-rc-function-Cycle_B_1_00030/Cycle_B_1_00030.java @@ -0,0 +1,94 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_1_00030.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Cycle_B_1_00030 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_1_00030.java + *- @ExecuteClass: Cycle_B_1_00030 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_1_00030_A1 { + Cycle_B_1_00030_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00030_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_1_00030_A2 { + Cycle_B_1_00030_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00030_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_1_00030_A3 { + Cycle_B_1_00030_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00030_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + +public class Cycle_B_1_00030 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00030_A1 a1_0 = new Cycle_B_1_00030_A1(); + a1_0.a2_0 = new Cycle_B_1_00030_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00030_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + + if (nsum == 12) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0039-rc-function-Cycle_B_1_00040/Cycle_B_1_00040.java b/test/testsuite/ouroboros/rc_test/RC0039-rc-function-Cycle_B_1_00040/Cycle_B_1_00040.java new file mode 100755 index 0000000000000000000000000000000000000000..3496675ebca4bef4d85e9823043e6fc45ea0729b --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0039-rc-function-Cycle_B_1_00040/Cycle_B_1_00040.java @@ -0,0 +1,115 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_1_00040.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Cycle_B_1_00040 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_1_00040.java + *- @ExecuteClass: Cycle_B_1_00040 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_1_00040_A1 { + Cycle_B_1_00040_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00040_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_1_00040_A2 { + Cycle_B_1_00040_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00040_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_1_00040_A3 { + Cycle_B_1_00040_A1 a1_0; + Cycle_B_1_00040_A4 a4_0; + int a; + int sum; + + Cycle_B_1_00040_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_1_00040_A4 { + + int a; + int sum; + + Cycle_B_1_00040_A4() { + a = 4; + sum = 0; + } + + void add() { + sum = a + 5; + } +} + + +public class Cycle_B_1_00040 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00040_A1 a1_0 = new Cycle_B_1_00040_A1(); + a1_0.a2_0 = new Cycle_B_1_00040_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00040_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_1_00040_A4(); + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum; + + if (nsum == 21) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0040-rc-function-Cycle_B_1_00050/Cycle_B_1_00050.java b/test/testsuite/ouroboros/rc_test/RC0040-rc-function-Cycle_B_1_00050/Cycle_B_1_00050.java new file mode 100755 index 0000000000000000000000000000000000000000..9b4304ccf8c5bbf1618a685cac54754ad8fbc445 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0040-rc-function-Cycle_B_1_00050/Cycle_B_1_00050.java @@ -0,0 +1,134 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_1_00050.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_1_00050 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_1_00050.java + *- @ExecuteClass: Cycle_B_1_00050 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_1_00050_A1 { + Cycle_B_1_00050_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00050_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_1_00050_A2 { + Cycle_B_1_00050_A3 a3_0; + Cycle_B_1_00050_A4 a4_0; + Cycle_B_1_00050_A5 a5_0; + int a; + int sum; + + Cycle_B_1_00050_A2() { + a3_0 = null; + a4_0 = null; + a5_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_1_00050_A3 { + Cycle_B_1_00050_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00050_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_1_00050_A4 { + + int a; + int sum; + + Cycle_B_1_00050_A4() { + a = 4; + sum = 0; + } + + void add() { + sum = a + 5; + } +} + + +class Cycle_B_1_00050_A5 { + + int a; + int sum; + + Cycle_B_1_00050_A5() { + a = 6; + sum = 0; + } + + void add() { + sum = a + 7; + } +} + +public class Cycle_B_1_00050 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00050_A1 a1_0 = new Cycle_B_1_00050_A1(); + a1_0.a2_0 = new Cycle_B_1_00050_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00050_A3(); + a1_0.a2_0.a4_0 = new Cycle_B_1_00050_A4(); + a1_0.a2_0.a5_0 = new Cycle_B_1_00050_A5(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + a1_0.a2_0.a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum + a1_0.a2_0.a5_0.sum; + //System.out.println(nsum); + if (nsum == 34) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0041-rc-function-Cycle_B_1_00060/Cycle_B_1_00060.java b/test/testsuite/ouroboros/rc_test/RC0041-rc-function-Cycle_B_1_00060/Cycle_B_1_00060.java new file mode 100755 index 0000000000000000000000000000000000000000..f5687c59ed36427ece9807a8edaf08903a9ca0b1 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0041-rc-function-Cycle_B_1_00060/Cycle_B_1_00060.java @@ -0,0 +1,114 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_1_00060.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_1_00060 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_1_00060.java + *- @ExecuteClass: Cycle_B_1_00060 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_1_00060_A1 { + Cycle_B_1_00060_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00060_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_1_00060_A2 { + Cycle_B_1_00060_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00060_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_1_00060_A3 { + Cycle_B_1_00060_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00060_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_1_00060_A4 { + Cycle_B_1_00060_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00060_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + +public class Cycle_B_1_00060 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00060_A1 a1_0 = new Cycle_B_1_00060_A1(); + a1_0.a2_0 = new Cycle_B_1_00060_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00060_A3(); + Cycle_B_1_00060_A4 a4_0 = new Cycle_B_1_00060_A4(); + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum; + + if (nsum == 19) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0042-rc-function-Cycle_B_1_00070/Cycle_B_1_00070.java b/test/testsuite/ouroboros/rc_test/RC0042-rc-function-Cycle_B_1_00070/Cycle_B_1_00070.java new file mode 100755 index 0000000000000000000000000000000000000000..fa1c5e797e1ee9510dea8db4f1c73a4125ff6765 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0042-rc-function-Cycle_B_1_00070/Cycle_B_1_00070.java @@ -0,0 +1,114 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_1_00070.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Cycle_B_1_00070 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_1_00070.java + *- @ExecuteClass: Cycle_B_1_00070 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_1_00070_A1 { + Cycle_B_1_00070_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00070_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_1_00070_A2 { + Cycle_B_1_00070_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00070_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_1_00070_A3 { + Cycle_B_1_00070_A1 a1_0; + Cycle_B_1_00070_A4 a4_0; + int a; + int sum; + + Cycle_B_1_00070_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_1_00070_A4 { + int a; + int sum; + + Cycle_B_1_00070_A4() { + a = 4; + sum = 0; + } + + void add() { + sum = a + 5; + } +} + +public class Cycle_B_1_00070 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00070_A1 a1_0 = new Cycle_B_1_00070_A1(); + a1_0.a2_0 = new Cycle_B_1_00070_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00070_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_1_00070_A4(); + + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum; + + if (nsum == 21) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0043-rc-function-Cycle_B_1_00080/Cycle_B_1_00080.java b/test/testsuite/ouroboros/rc_test/RC0043-rc-function-Cycle_B_1_00080/Cycle_B_1_00080.java new file mode 100755 index 0000000000000000000000000000000000000000..328a501183772debbd3f93faa5c4ab9fbe0d44ba --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0043-rc-function-Cycle_B_1_00080/Cycle_B_1_00080.java @@ -0,0 +1,132 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_1_00080.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_1_00080 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_1_00080.java + *- @ExecuteClass: Cycle_B_1_00080 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_1_00080_A1 { + Cycle_B_1_00080_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00080_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_1_00080_A2 { + Cycle_B_1_00080_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00080_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_1_00080_A3 { + Cycle_B_1_00080_A1 a1_0; + Cycle_B_1_00080_A4 a4_0; + Cycle_B_1_00080_A5 a5_0; + int a; + int sum; + + Cycle_B_1_00080_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + a4_0.add(); + a5_0.add(); + sum = a + a1_0.a + a4_0.sum + a5_0.sum; + } +} + + +class Cycle_B_1_00080_A4 { + int a; + int sum; + + Cycle_B_1_00080_A4() { + a = 4; + sum = 0; + } + + void add() { + sum = a + 5; + } +} + + +class Cycle_B_1_00080_A5 { + int a; + int sum; + + Cycle_B_1_00080_A5() { + a = 6; + sum = 0; + } + + void add() { + sum = a + 7; + } +} + +public class Cycle_B_1_00080 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00080_A1 a1_0 = new Cycle_B_1_00080_A1(); + a1_0.a2_0 = new Cycle_B_1_00080_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00080_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_1_00080_A4(); + a1_0.a2_0.a3_0.a5_0 = new Cycle_B_1_00080_A5(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a5_0.sum; + //System.out.println(nsum); + if (nsum == 56) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0044-rc-function-Cycle_B_1_00090/Cycle_B_1_00090.java b/test/testsuite/ouroboros/rc_test/RC0044-rc-function-Cycle_B_1_00090/Cycle_B_1_00090.java new file mode 100755 index 0000000000000000000000000000000000000000..630236cb331544e8016b691a2c186a1e4cf5732e --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0044-rc-function-Cycle_B_1_00090/Cycle_B_1_00090.java @@ -0,0 +1,134 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_1_00090.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Cycle_B_1_00090 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_1_00090.java + *- @ExecuteClass: Cycle_B_1_00090 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_1_00090_A1 { + Cycle_B_1_00090_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00090_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_1_00090_A2 { + Cycle_B_1_00090_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00090_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_1_00090_A3 { + Cycle_B_1_00090_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00090_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_1_00090_A4 { + Cycle_B_1_00090_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00090_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_1_00090_A5 { + Cycle_B_1_00090_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00090_A5() { + a2_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + +public class Cycle_B_1_00090 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00090_A1 a1_0 = new Cycle_B_1_00090_A1(); + a1_0.a2_0 = new Cycle_B_1_00090_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00090_A3(); + Cycle_B_1_00090_A4 a4_0 = new Cycle_B_1_00090_A4(); + Cycle_B_1_00090_A5 a5_0 = new Cycle_B_1_00090_A5(); + a4_0.a2_0 = a1_0.a2_0; + a5_0.a2_0 = a1_0.a2_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum; + //System.out.println(nsum); + if (nsum == 25) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0045-rc-function-Cycle_B_1_00100/Cycle_B_1_00100.java b/test/testsuite/ouroboros/rc_test/RC0045-rc-function-Cycle_B_1_00100/Cycle_B_1_00100.java new file mode 100755 index 0000000000000000000000000000000000000000..08b9418c34fd377c19c0fa649dc4ff8dcd0bc1b7 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0045-rc-function-Cycle_B_1_00100/Cycle_B_1_00100.java @@ -0,0 +1,136 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_1_00100.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_1_00100 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_1_00100.java + *- @ExecuteClass: Cycle_B_1_00100 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_1_00100_A1 { + Cycle_B_1_00100_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00100_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_1_00100_A2 { + Cycle_B_1_00100_A3 a3_0; + Cycle_B_1_00100_A4 a4_0; + int a; + int sum; + + Cycle_B_1_00100_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_1_00100_A3 { + Cycle_B_1_00100_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00100_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_1_00100_A4 { + + int a; + int sum; + Cycle_B_1_00100_A5 a5_0; + + Cycle_B_1_00100_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + a5_0.add(); + sum = a + a5_0.sum; + } +} + +class Cycle_B_1_00100_A5 { + + int a; + int sum; + + Cycle_B_1_00100_A5() { + a = 5; + sum = 0; + } + + void add() { + sum = a + 6; + } +} + + +public class Cycle_B_1_00100 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00100_A1 a1_0 = new Cycle_B_1_00100_A1(); + a1_0.a2_0 = new Cycle_B_1_00100_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00100_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a4_0 = new Cycle_B_1_00100_A4(); + a1_0.a2_0.a4_0.a5_0 = new Cycle_B_1_00100_A5(); + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + a1_0.a2_0.a4_0.a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum + a1_0.a2_0.a4_0.a5_0.sum; + ; + //System.out.println(nsum); + if (nsum == 38) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0046-rc-function-Cycle_B_1_00110/Cycle_B_1_00110.java b/test/testsuite/ouroboros/rc_test/RC0046-rc-function-Cycle_B_1_00110/Cycle_B_1_00110.java new file mode 100755 index 0000000000000000000000000000000000000000..9e5370325ff9b496438917b05de95ea79c5a1691 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0046-rc-function-Cycle_B_1_00110/Cycle_B_1_00110.java @@ -0,0 +1,132 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_1_00110.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_1_00110 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_1_00110.java + *- @ExecuteClass: Cycle_B_1_00110 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_1_00110_A1 { + Cycle_B_1_00110_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00110_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_1_00110_A2 { + Cycle_B_1_00110_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00110_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_1_00110_A3 { + Cycle_B_1_00110_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00110_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_1_00110_A4 { + Cycle_B_1_00110_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00110_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_B_1_00110_A5 { + Cycle_B_1_00110_A4 a4_0; + int a; + int sum; + + Cycle_B_1_00110_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } +} + +public class Cycle_B_1_00110 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00110_A1 a1_0 = new Cycle_B_1_00110_A1(); + a1_0.a2_0 = new Cycle_B_1_00110_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00110_A3(); + Cycle_B_1_00110_A5 a5_0 = new Cycle_B_1_00110_A5(); + a5_0.a4_0 = new Cycle_B_1_00110_A4(); + a5_0.a4_0.a2_0 = a1_0.a2_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a5_0.a4_0.add(); + a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a5_0.a4_0.sum + a5_0.sum; + //System.out.println(nsum); + if (nsum == 27) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0047-rc-function-Cycle_B_1_00120/Cycle_B_1_00120.java b/test/testsuite/ouroboros/rc_test/RC0047-rc-function-Cycle_B_1_00120/Cycle_B_1_00120.java new file mode 100755 index 0000000000000000000000000000000000000000..75e264f414cba2b01a4bf2108954b38e3d2a3b43 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0047-rc-function-Cycle_B_1_00120/Cycle_B_1_00120.java @@ -0,0 +1,131 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_1_00120.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_1_00120 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_1_00120.java + *- @ExecuteClass: Cycle_B_1_00120 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_1_00120_A1 { + Cycle_B_1_00120_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00120_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_1_00120_A2 { + Cycle_B_1_00120_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00120_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_1_00120_A3 { + Cycle_B_1_00120_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00120_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_1_00120_A4 { + Cycle_B_1_00120_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00120_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_B_1_00120_A5 { + Cycle_B_1_00120_A4 a4_0; + int a; + int sum; + + Cycle_B_1_00120_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } +} + +public class Cycle_B_1_00120 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00120_A1 a1_0 = new Cycle_B_1_00120_A1(); + a1_0.a2_0 = new Cycle_B_1_00120_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00120_A3(); + Cycle_B_1_00120_A5 a5_0 = new Cycle_B_1_00120_A5(); + a5_0.a4_0 = new Cycle_B_1_00120_A4(); + a5_0.a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a5_0.a4_0.add(); + a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a5_0.a4_0.sum + a5_0.sum; + if (nsum == 28) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0048-rc-function-Cycle_B_1_00130/Cycle_B_1_00130.java b/test/testsuite/ouroboros/rc_test/RC0048-rc-function-Cycle_B_1_00130/Cycle_B_1_00130.java new file mode 100755 index 0000000000000000000000000000000000000000..da8026909c08afda4475a92965a3b1f1cf5faa1c --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0048-rc-function-Cycle_B_1_00130/Cycle_B_1_00130.java @@ -0,0 +1,96 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_1_00130.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Cycle_B_1_00130 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_1_00130.java + *- @ExecuteClass: Cycle_B_1_00130 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_1_00130_A1 { + Cycle_B_1_00130_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00130_A1() { + a3_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_1_00130_A2 { + Cycle_B_1_00130_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00130_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_1_00130_A3 { + Cycle_B_1_00130_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00130_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + +public class Cycle_B_1_00130 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00130_A1 a1_0 = new Cycle_B_1_00130_A1(); + Cycle_B_1_00130_A2 a2_0 = new Cycle_B_1_00130_A2(); + Cycle_B_1_00130_A3 a3_0 = new Cycle_B_1_00130_A3(); + a1_0.a3_0 = a3_0; + a2_0.a3_0 = a3_0; + a3_0.a1_0 = a1_0; + a1_0.add(); + a2_0.add(); + a3_0.add(); + int nsum = (a1_0.sum + a2_0.sum + a3_0.sum); + //System.out.println(nsum); + if (nsum == 13) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0049-rc-function-Cycle_B_1_00140/Cycle_B_1_00140.java b/test/testsuite/ouroboros/rc_test/RC0049-rc-function-Cycle_B_1_00140/Cycle_B_1_00140.java new file mode 100755 index 0000000000000000000000000000000000000000..32ddd6ec4bc9579243ef769ef361349047d41d14 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0049-rc-function-Cycle_B_1_00140/Cycle_B_1_00140.java @@ -0,0 +1,114 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_1_00140.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_1_00140 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_1_00140.java + *- @ExecuteClass: Cycle_B_1_00140 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_1_00140_A1 { + Cycle_B_1_00140_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00140_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_1_00140_A2 { + Cycle_B_1_00140_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00140_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_1_00140_A3 { + Cycle_B_1_00140_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00140_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_1_00140_A4 { + Cycle_B_1_00140_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00140_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + +public class Cycle_B_1_00140 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00140_A1 a1_0 = new Cycle_B_1_00140_A1(); + a1_0.a2_0 = new Cycle_B_1_00140_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00140_A3(); + Cycle_B_1_00140_A4 a4_0 = new Cycle_B_1_00140_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + if (nsum == 12) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0050-rc-function-Cycle_B_1_00150/Cycle_B_1_00150.java b/test/testsuite/ouroboros/rc_test/RC0050-rc-function-Cycle_B_1_00150/Cycle_B_1_00150.java new file mode 100755 index 0000000000000000000000000000000000000000..1829366c3c536f740f140d9d1fa9f833f6f8ce34 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0050-rc-function-Cycle_B_1_00150/Cycle_B_1_00150.java @@ -0,0 +1,136 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_1_00150.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Cycle_B_1_00150 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_1_00150.java + *- @ExecuteClass: Cycle_B_1_00150 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_1_00150_A1 { + Cycle_B_1_00150_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00150_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_1_00150_A2 { + Cycle_B_1_00150_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00150_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_1_00150_A3 { + Cycle_B_1_00150_A1 a1_0; + Cycle_B_1_00150_A4 a4_0; + int a; + int sum; + + Cycle_B_1_00150_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_1_00150_A4 { + + int a; + int sum; + Cycle_B_1_00150_A5 a5_0; + + Cycle_B_1_00150_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + a5_0.add(); + sum = a + a5_0.sum; + } +} + +class Cycle_B_1_00150_A5 { + + int a; + int sum; + + Cycle_B_1_00150_A5() { + a = 5; + sum = 0; + } + + void add() { + sum = a + 6; + } +} + + +public class Cycle_B_1_00150 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00150_A1 a1_0 = new Cycle_B_1_00150_A1(); + a1_0.a2_0 = new Cycle_B_1_00150_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00150_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_1_00150_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_1_00150_A5(); + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum; + ; + //System.out.println(nsum); + if (nsum == 38) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0051-rc-function-Cycle_B_1_00160/Cycle_B_1_00160.java b/test/testsuite/ouroboros/rc_test/RC0051-rc-function-Cycle_B_1_00160/Cycle_B_1_00160.java new file mode 100755 index 0000000000000000000000000000000000000000..69645dae64241dfc4b38d97dccaf2f74208ec657 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0051-rc-function-Cycle_B_1_00160/Cycle_B_1_00160.java @@ -0,0 +1,114 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_1_00160.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Cycle_B_1_00160 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_1_00160.java + *- @ExecuteClass: Cycle_B_1_00160 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_1_00160_A1 { + Cycle_B_1_00160_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00160_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_1_00160_A2 { + Cycle_B_1_00160_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00160_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_1_00160_A3 { + Cycle_B_1_00160_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00160_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + +class Cycle_B_1_00160_A4 { + Cycle_B_1_00160_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00160_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +public class Cycle_B_1_00160 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00160_A1 a1_0 = new Cycle_B_1_00160_A1(); + a1_0.a2_0 = new Cycle_B_1_00160_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00160_A3(); + Cycle_B_1_00160_A4 a4_0 = new Cycle_B_1_00160_A4(); + a4_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + if (nsum == 17) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0052-rc-function-Cycle_B_1_00170/Cycle_B_1_00170.java b/test/testsuite/ouroboros/rc_test/RC0052-rc-function-Cycle_B_1_00170/Cycle_B_1_00170.java new file mode 100755 index 0000000000000000000000000000000000000000..2f5dfd64293451d3434dd80d187e9170f51a7ce7 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0052-rc-function-Cycle_B_1_00170/Cycle_B_1_00170.java @@ -0,0 +1,134 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_1_00170.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_1_00170 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_1_00170.java + *- @ExecuteClass: Cycle_B_1_00170 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_1_00170_A1 { + Cycle_B_1_00170_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00170_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_1_00170_A2 { + Cycle_B_1_00170_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00170_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_1_00170_A3 { + Cycle_B_1_00170_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00170_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + +class Cycle_B_1_00170_A4 { + Cycle_B_1_00170_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00170_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_1_00170_A5 { + Cycle_B_1_00170_A4 a4_0; + int a; + int sum; + + Cycle_B_1_00170_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } +} + + +public class Cycle_B_1_00170 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00170_A1 a1_0 = new Cycle_B_1_00170_A1(); + a1_0.a2_0 = new Cycle_B_1_00170_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00170_A3(); + Cycle_B_1_00170_A4 a4_0 = new Cycle_B_1_00170_A4(); + Cycle_B_1_00170_A5 a5_0 = new Cycle_B_1_00170_A5(); + a5_0.a4_0 = a4_0; + a4_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + //System.out.println(nsum); + if (nsum == 26) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0053-rc-function-Cycle_B_1_00180/Cycle_B_1_00180.java b/test/testsuite/ouroboros/rc_test/RC0053-rc-function-Cycle_B_1_00180/Cycle_B_1_00180.java new file mode 100755 index 0000000000000000000000000000000000000000..850078bd9e45a7a0d642ea99c248e4038bbc5dbd --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0053-rc-function-Cycle_B_1_00180/Cycle_B_1_00180.java @@ -0,0 +1,133 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_1_00180.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Cycle_B_1_00180 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_1_00180.java + *- @ExecuteClass: Cycle_B_1_00180 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_1_00180_A1 { + Cycle_B_1_00180_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00180_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_1_00180_A2 { + Cycle_B_1_00180_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00180_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_1_00180_A3 { + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00180_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + +class Cycle_B_1_00180_A4 { + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00180_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_1_00180_A5 { + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00180_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + +public class Cycle_B_1_00180 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00180_A1 a1_0 = new Cycle_B_1_00180_A1(); + a1_0.a2_0 = new Cycle_B_1_00180_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00180_A3(); + Cycle_B_1_00180_A4 a4_0 = new Cycle_B_1_00180_A4(); + Cycle_B_1_00180_A5 a5_0 = new Cycle_B_1_00180_A5(); + a4_0.a1_0 = a1_0; + a5_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + //System.out.println(nsum); + if (nsum == 23) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0054-rc-function-Cycle_B_1_00190/Cycle_B_1_00190.java b/test/testsuite/ouroboros/rc_test/RC0054-rc-function-Cycle_B_1_00190/Cycle_B_1_00190.java new file mode 100755 index 0000000000000000000000000000000000000000..c5d843b01b5f3f68c9aa1c2dcb65a2bd742516fa --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0054-rc-function-Cycle_B_1_00190/Cycle_B_1_00190.java @@ -0,0 +1,115 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_1_00190.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Cycle_B_1_00190 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_1_00190.java + *- @ExecuteClass: Cycle_B_1_00190 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_1_00190_A1 { + Cycle_B_1_00190_A2 a2_0; + Cycle_B_1_00190_A4 a4_0; + int a; + int sum; + + Cycle_B_1_00190_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_1_00190_A2 { + Cycle_B_1_00190_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00190_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_1_00190_A3 { + Cycle_B_1_00190_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00190_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_1_00190_A4 { + int a; + int sum; + + Cycle_B_1_00190_A4() { + a = 4; + sum = 0; + } + + void add() { + sum = a + 5; + } +} + + +public class Cycle_B_1_00190 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00190_A1 a1_0 = new Cycle_B_1_00190_A1(); + a1_0.a2_0 = new Cycle_B_1_00190_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00190_A3(); + Cycle_B_1_00190_A4 a4_0 = new Cycle_B_1_00190_A4(); + a1_0.a4_0 = a4_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + if (nsum == 21) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0055-rc-function-Cycle_B_1_00200/Cycle_B_1_00200.java b/test/testsuite/ouroboros/rc_test/RC0055-rc-function-Cycle_B_1_00200/Cycle_B_1_00200.java new file mode 100755 index 0000000000000000000000000000000000000000..839eda1a17dff0a7617177ef1dee842a3e848403 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0055-rc-function-Cycle_B_1_00200/Cycle_B_1_00200.java @@ -0,0 +1,135 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_1_00200.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Cycle_B_1_00200 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_1_00200.java + *- @ExecuteClass: Cycle_B_1_00200 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_1_00200_A1 { + Cycle_B_1_00200_A2 a2_0; + Cycle_B_1_00200_A4 a4_0; + Cycle_B_1_00200_A5 a5_0; + int a; + int sum; + + Cycle_B_1_00200_A1() { + a2_0 = null; + a4_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_1_00200_A2 { + Cycle_B_1_00200_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00200_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_1_00200_A3 { + Cycle_B_1_00200_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00200_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_1_00200_A4 { + int a; + int sum; + + Cycle_B_1_00200_A4() { + a = 5; + sum = 0; + } + + void add() { + sum = a + 6; + } +} + + +class Cycle_B_1_00200_A5 { + int a; + int sum; + + Cycle_B_1_00200_A5() { + a = 7; + sum = 0; + } + + void add() { + sum = a + 8; + } +} + + +public class Cycle_B_1_00200 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00200_A1 a1_0 = new Cycle_B_1_00200_A1(); + a1_0.a2_0 = new Cycle_B_1_00200_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00200_A3(); + Cycle_B_1_00200_A4 a4_0 = new Cycle_B_1_00200_A4(); + Cycle_B_1_00200_A5 a5_0 = new Cycle_B_1_00200_A5(); + a1_0.a4_0 = a4_0; + a1_0.a5_0 = a5_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + //System.out.println(nsum); + if (nsum == 38) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0056-rc-function-Cycle_B_1_10010/Cycle_B_1_10010.java b/test/testsuite/ouroboros/rc_test/RC0056-rc-function-Cycle_B_1_10010/Cycle_B_1_10010.java new file mode 100755 index 0000000000000000000000000000000000000000..d9a99f9ae3cc6391deafa2c11370deef599f7a3d --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0056-rc-function-Cycle_B_1_10010/Cycle_B_1_10010.java @@ -0,0 +1,154 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_1_10010.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_1_10010 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_1_10010.java + *- @ExecuteClass: Cycle_B_1_10010 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_1_10010_A1 { + Cycle_B_1_10010_A2 a2_0; + int a; + int sum; + + Cycle_B_1_10010_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_1_10010_A2 { + Cycle_B_1_10010_A3 a3_0; + int a; + int sum; + + Cycle_B_1_10010_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_1_10010_A3 { + Cycle_B_1_10010_A1 a1_0; + int a; + int sum; + + Cycle_B_1_10010_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + +class Cycle_B_1_10010_2A1 { + Cycle_B_1_10010_2A2 a2_0; + int a; + int sum; + + Cycle_B_1_10010_2A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_1_10010_2A2 { + Cycle_B_1_10010_2A3 a3_0; + int a; + int sum; + + Cycle_B_1_10010_2A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_1_10010_2A3 { + Cycle_B_1_10010_2A1 a1_0; + int a; + int sum; + + Cycle_B_1_10010_2A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +public class Cycle_B_1_10010 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_1_10010_A1 a1_0 = new Cycle_B_1_10010_A1(); + a1_0.a2_0 = new Cycle_B_1_10010_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_10010_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + Cycle_B_1_10010_2A1 a1_10 = new Cycle_B_1_10010_2A1(); + a1_10.a2_0 = new Cycle_B_1_10010_2A2(); + a1_10.a2_0.a3_0 = new Cycle_B_1_10010_2A3(); + a1_10.a2_0.a3_0.a1_0 = a1_10; + a1_10.add(); + a1_10.a2_0.add(); + a1_10.a2_0.a3_0.add(); + int nsum2 = (a1_10.sum + a1_10.a2_0.sum + a1_10.a2_0.a3_0.sum); + //System.out.println(nsum); + nsum += nsum2; + if (nsum == 24) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0057-rc-function-Cycle_B_1_10020/Cycle_B_1_10020.java b/test/testsuite/ouroboros/rc_test/RC0057-rc-function-Cycle_B_1_10020/Cycle_B_1_10020.java new file mode 100755 index 0000000000000000000000000000000000000000..ba52fa649ffa9344a2e9ce8f349d31926c84b94b --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0057-rc-function-Cycle_B_1_10020/Cycle_B_1_10020.java @@ -0,0 +1,229 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_1_10020.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_1_10020 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_1_10020.java + *- @ExecuteClass: Cycle_B_1_10020 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_1_10020_A1 { + Cycle_B_1_10020_A2 a2_0; + int a; + int sum; + + Cycle_B_1_10020_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_1_10020_A2 { + Cycle_B_1_10020_A3 a3_0; + int a; + int sum; + + Cycle_B_1_10020_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_1_10020_A3 { + Cycle_B_1_10020_A1 a1_0; + int a; + int sum; + + Cycle_B_1_10020_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + +class Cycle_B_1_10020_A4 { + Cycle_B_1_10020_A1 a1_0; + int a; + int sum; + + Cycle_B_1_10020_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_1_10020_A5 { + Cycle_B_1_10020_A1 a1_0; + int a; + int sum; + + Cycle_B_1_10020_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + +class Cycle_B_1_10020_2A1 { + Cycle_B_1_10020_2A2 a2_0; + Cycle_B_1_10020_2A4 a4_0; + Cycle_B_1_10020_2A5 a5_0; + int a; + int sum; + + Cycle_B_1_10020_2A1() { + a2_0 = null; + a4_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_1_10020_2A2 { + Cycle_B_1_10020_2A3 a3_0; + int a; + int sum; + + Cycle_B_1_10020_2A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_1_10020_2A3 { + Cycle_B_1_10020_2A1 a1_0; + int a; + int sum; + + Cycle_B_1_10020_2A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + +class Cycle_B_1_10020_2A4 { + int a; + int sum; + + Cycle_B_1_10020_2A4() { + a = 5; + sum = 0; + } + + void add() { + sum = a + 6; + } +} + + +class Cycle_B_1_10020_2A5 { + int a; + int sum; + + Cycle_B_1_10020_2A5() { + a = 7; + sum = 0; + } + + void add() { + sum = a + 8; + } +} + + +public class Cycle_B_1_10020 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_1_10020_A1 a1_0 = new Cycle_B_1_10020_A1(); + a1_0.a2_0 = new Cycle_B_1_10020_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_10020_A3(); + Cycle_B_1_10020_A4 a4_0 = new Cycle_B_1_10020_A4(); + Cycle_B_1_10020_A5 a5_0 = new Cycle_B_1_10020_A5(); + a4_0.a1_0 = a1_0; + a5_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + Cycle_B_1_10020_2A1 a1_20 = new Cycle_B_1_10020_2A1(); + a1_20.a2_0 = new Cycle_B_1_10020_2A2(); + a1_20.a2_0.a3_0 = new Cycle_B_1_10020_2A3(); + Cycle_B_1_10020_2A4 a4_20 = new Cycle_B_1_10020_2A4(); + Cycle_B_1_10020_2A5 a5_20 = new Cycle_B_1_10020_2A5(); + a1_20.a4_0 = a4_20; + a1_20.a5_0 = a5_20; + a1_20.a2_0.a3_0.a1_0 = a1_20; + a1_20.add(); + a1_20.a2_0.add(); + a1_20.a2_0.a3_0.add(); + a4_20.add(); + a5_20.add(); + int nsum1 = (a1_20.sum + a1_20.a2_0.sum + a1_20.a2_0.a3_0.sum + a4_20.sum + a5_20.sum); + nsum += nsum1; + if (nsum == 61) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0058-rc-function-Cycle_B_2_00010/Cycle_B_2_00010.java b/test/testsuite/ouroboros/rc_test/RC0058-rc-function-Cycle_B_2_00010/Cycle_B_2_00010.java new file mode 100755 index 0000000000000000000000000000000000000000..b2e333b3e9868b43540db22103c8069dcdb88391 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0058-rc-function-Cycle_B_2_00010/Cycle_B_2_00010.java @@ -0,0 +1,116 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_2_00010.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_2_00010 in RC测试-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_2_00010.java + *- @ExecuteClass: Cycle_B_2_00010 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_2_00010_A1 { + Cycle_B_2_00010_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00010_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_2_00010_A2 { + Cycle_B_2_00010_A3 a3_0; + Cycle_B_2_00010_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00010_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00010_A3 { + Cycle_B_2_00010_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00010_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_2_00010_A4 { + Cycle_B_2_00010_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00010_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + +public class Cycle_B_2_00010 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00010_A1 a1_0 = new Cycle_B_2_00010_A1(); + a1_0.a2_0 = new Cycle_B_2_00010_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00010_A3(); + a1_0.a2_0.a4_0 = new Cycle_B_2_00010_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a4_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum); + //System.out.println(nsum); + if (nsum == 18) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0059-rc-function-Cycle_B_2_00020/Cycle_B_2_00020.java b/test/testsuite/ouroboros/rc_test/RC0059-rc-function-Cycle_B_2_00020/Cycle_B_2_00020.java new file mode 100755 index 0000000000000000000000000000000000000000..83bd9ab925d2c24733ad7799356f9dd88cb05601 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0059-rc-function-Cycle_B_2_00020/Cycle_B_2_00020.java @@ -0,0 +1,118 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_2_00020.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_2_00020 in RC测试-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_2_00020.java + *- @ExecuteClass: Cycle_B_2_00020 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_2_00020_A1 { + Cycle_B_2_00020_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00020_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_2_00020_A2 { + Cycle_B_2_00020_A3 a3_0; + Cycle_B_2_00020_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00020_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00020_A3 { + Cycle_B_2_00020_A1 a1_0; + Cycle_B_2_00020_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00020_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_2_00020_A4 { + Cycle_B_2_00020_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00020_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + +public class Cycle_B_2_00020 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00020_A1 a1_0 = new Cycle_B_2_00020_A1(); + a1_0.a2_0 = new Cycle_B_2_00020_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00020_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00020_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum); + //System.out.println(nsum); + if (nsum == 19) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0060-rc-function-Cycle_B_2_00030/Cycle_B_2_00030.java b/test/testsuite/ouroboros/rc_test/RC0060-rc-function-Cycle_B_2_00030/Cycle_B_2_00030.java new file mode 100755 index 0000000000000000000000000000000000000000..824b932eb57e5957a6ad685fe4c649f77912c8ee --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0060-rc-function-Cycle_B_2_00030/Cycle_B_2_00030.java @@ -0,0 +1,118 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_2_00030.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Cycle_B_2_00030 in RC测试-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_2_00030.java + *- @ExecuteClass: Cycle_B_2_00030 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_2_00030_A1 { + Cycle_B_2_00030_A2 a2_0; + Cycle_B_2_00030_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00030_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_2_00030_A2 { + Cycle_B_2_00030_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00030_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00030_A3 { + Cycle_B_2_00030_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00030_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_2_00030_A4 { + Cycle_B_2_00030_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00030_A4() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +public class Cycle_B_2_00030 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00030_A1 a1_0 = new Cycle_B_2_00030_A1(); + a1_0.a2_0 = new Cycle_B_2_00030_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00030_A3(); + Cycle_B_2_00030_A4 a4_0 = new Cycle_B_2_00030_A4(); + a4_0.a1_0 = a1_0; + a1_0.a4_0 = a4_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + if (nsum == 16) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0061-rc-function-Cycle_B_2_00040/Cycle_B_2_00040.java b/test/testsuite/ouroboros/rc_test/RC0061-rc-function-Cycle_B_2_00040/Cycle_B_2_00040.java new file mode 100755 index 0000000000000000000000000000000000000000..4b7ff9c964dab0f227734730b29d823b47266820 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0061-rc-function-Cycle_B_2_00040/Cycle_B_2_00040.java @@ -0,0 +1,119 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_2_00040.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_2_00040 in RC测试-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_2_00040.java + *- @ExecuteClass: Cycle_B_2_00040 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_2_00040_A1 { + Cycle_B_2_00040_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00040_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_2_00040_A2 { + Cycle_B_2_00040_A3 a3_0; + Cycle_B_2_00040_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00040_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00040_A3 { + Cycle_B_2_00040_A1 a1_0; + Cycle_B_2_00040_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00040_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_2_00040_A4 { + Cycle_B_2_00040_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00040_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + +public class Cycle_B_2_00040 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00040_A1 a1_0 = new Cycle_B_2_00040_A1(); + a1_0.a2_0 = new Cycle_B_2_00040_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00040_A3(); + Cycle_B_2_00040_A4 a4_0 = new Cycle_B_2_00040_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a4_0 = a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + if (nsum == 19) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0062-rc-function-Cycle_B_2_00050/Cycle_B_2_00050.java b/test/testsuite/ouroboros/rc_test/RC0062-rc-function-Cycle_B_2_00050/Cycle_B_2_00050.java new file mode 100755 index 0000000000000000000000000000000000000000..edb2568cda6b03f075cc74a46674316ec444d8b9 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0062-rc-function-Cycle_B_2_00050/Cycle_B_2_00050.java @@ -0,0 +1,139 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_2_00050.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_2_00050 in RC测试-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_2_00050.java + *- @ExecuteClass: Cycle_B_2_00050 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_2_00050_A1 { + Cycle_B_2_00050_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00050_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_2_00050_A2 { + Cycle_B_2_00050_A3 a3_0; + Cycle_B_2_00050_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00050_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00050_A3 { + Cycle_B_2_00050_A1 a1_0; + Cycle_B_2_00050_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00050_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_2_00050_A4 { + Cycle_B_2_00050_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00050_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00050_A5 { + Cycle_B_2_00050_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00050_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } +} + +public class Cycle_B_2_00050 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00050_A1 a1_0 = new Cycle_B_2_00050_A1(); + a1_0.a2_0 = new Cycle_B_2_00050_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00050_A3(); + Cycle_B_2_00050_A4 a4_0 = new Cycle_B_2_00050_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a4_0.a3_0.a5_0 = new Cycle_B_2_00050_A5(); + a1_0.a2_0.a3_0.a5_0 = a4_0.a3_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a4_0.a3_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a4_0.a3_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 28) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0063-rc-function-Cycle_B_2_00060/Cycle_B_2_00060.java b/test/testsuite/ouroboros/rc_test/RC0063-rc-function-Cycle_B_2_00060/Cycle_B_2_00060.java new file mode 100755 index 0000000000000000000000000000000000000000..74278f97b11271c2000dd8f0722a692e81b32ef2 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0063-rc-function-Cycle_B_2_00060/Cycle_B_2_00060.java @@ -0,0 +1,142 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_2_00060.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_2_00060 in RC测试-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_2_00060.java + *- @ExecuteClass: Cycle_B_2_00060 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_2_00060_A1 { + Cycle_B_2_00060_A2 a2_0; + Cycle_B_2_00060_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00060_A1() { + a2_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_2_00060_A2 { + Cycle_B_2_00060_A3 a3_0; + Cycle_B_2_00060_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00060_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00060_A3 { + Cycle_B_2_00060_A1 a1_0; + Cycle_B_2_00060_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00060_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_2_00060_A4 { + Cycle_B_2_00060_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00060_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00060_A5 { + Cycle_B_2_00060_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00060_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } +} + +public class Cycle_B_2_00060 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00060_A1 a1_0 = new Cycle_B_2_00060_A1(); + a1_0.a2_0 = new Cycle_B_2_00060_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00060_A3(); + Cycle_B_2_00060_A4 a4_0 = new Cycle_B_2_00060_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a4_0.a3_0.a5_0 = new Cycle_B_2_00060_A5(); + a1_0.a2_0.a3_0.a5_0 = a4_0.a3_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.a5_0 = a4_0.a3_0.a5_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a4_0.a3_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a4_0.a3_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 28) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0064-rc-function-Cycle_B_2_00070/Cycle_B_2_00070.java b/test/testsuite/ouroboros/rc_test/RC0064-rc-function-Cycle_B_2_00070/Cycle_B_2_00070.java new file mode 100755 index 0000000000000000000000000000000000000000..5c7cf64e5b10818750488b1d7aab40c1fad92b8a --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0064-rc-function-Cycle_B_2_00070/Cycle_B_2_00070.java @@ -0,0 +1,159 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_2_00070.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_2_00070 in RC测试-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_2_00070.java + *- @ExecuteClass: Cycle_B_2_00070 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_2_00070_A1 { + Cycle_B_2_00070_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00070_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_2_00070_A2 { + Cycle_B_2_00070_A3 a3_0; + Cycle_B_2_00070_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00070_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00070_A3 { + Cycle_B_2_00070_A1 a1_0; + Cycle_B_2_00070_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00070_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_2_00070_A4 { + Cycle_B_2_00070_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00070_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00070_A5 { + Cycle_B_2_00070_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00070_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } +} + + +class Cycle_B_2_00070_A6 { + Cycle_B_2_00070_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00070_A6() { + a3_0 = null; + a = 6; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + +public class Cycle_B_2_00070 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00070_A1 a1_0 = new Cycle_B_2_00070_A1(); + a1_0.a2_0 = new Cycle_B_2_00070_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00070_A3(); + Cycle_B_2_00070_A4 a4_0 = new Cycle_B_2_00070_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a4_0.a3_0.a5_0 = new Cycle_B_2_00070_A5(); + Cycle_B_2_00070_A6 a6_0 = new Cycle_B_2_00070_A6(); + a6_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a5_0 = a4_0.a3_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a6_0.add(); + a4_0.a3_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a4_0.a3_0.a5_0.sum + a6_0.sum); + //System.out.println(nsum); + if (nsum == 37) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0065-rc-function-Cycle_B_2_00080/Cycle_B_2_00080.java b/test/testsuite/ouroboros/rc_test/RC0065-rc-function-Cycle_B_2_00080/Cycle_B_2_00080.java new file mode 100755 index 0000000000000000000000000000000000000000..c987538d14c053a87d5537f60c50e253b5e646c2 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0065-rc-function-Cycle_B_2_00080/Cycle_B_2_00080.java @@ -0,0 +1,145 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_2_00080.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_2_00080 in RC测试-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_2_00080.java + *- @ExecuteClass: Cycle_B_2_00080 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_2_00080_A1 { + Cycle_B_2_00080_A2 a2_0; + Cycle_B_2_00080_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00080_A1() { + a2_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_2_00080_A2 { + Cycle_B_2_00080_A3 a3_0; + Cycle_B_2_00080_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00080_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00080_A3 { + Cycle_B_2_00080_A1 a1_0; + Cycle_B_2_00080_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00080_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_2_00080_A4 { + Cycle_B_2_00080_A3 a3_0; + Cycle_B_2_00080_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00080_A4() { + a3_0 = null; + a2_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00080_A5 { + Cycle_B_2_00080_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00080_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } +} + +public class Cycle_B_2_00080 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00080_A1 a1_0 = new Cycle_B_2_00080_A1(); + a1_0.a2_0 = new Cycle_B_2_00080_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00080_A3(); + Cycle_B_2_00080_A4 a4_0 = new Cycle_B_2_00080_A4(); + a4_0.a2_0 = a1_0.a2_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a4_0.a3_0.a5_0 = new Cycle_B_2_00080_A5(); + a1_0.a2_0.a3_0.a5_0 = a4_0.a3_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.a5_0 = a4_0.a3_0.a5_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a4_0.a3_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a4_0.a3_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 28) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0066-rc-function-Cycle_B_2_00090/Cycle_B_2_00090.java b/test/testsuite/ouroboros/rc_test/RC0066-rc-function-Cycle_B_2_00090/Cycle_B_2_00090.java new file mode 100755 index 0000000000000000000000000000000000000000..f393feabe7e0a75b2cf65e87be5ada7f64eb35a9 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0066-rc-function-Cycle_B_2_00090/Cycle_B_2_00090.java @@ -0,0 +1,98 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_2_00090.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_2_00090 in RC测试-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_2_00090.java + *- @ExecuteClass: Cycle_B_2_00090 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_2_00090_A1 { + Cycle_B_2_00090_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00090_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_2_00090_A2 { + Cycle_B_2_00090_A1 a1_0; + Cycle_B_2_00090_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00090_A2() { + a1_0 = null; + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_2_00090_A3 { + Cycle_B_2_00090_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00090_A3() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + +public class Cycle_B_2_00090 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00090_A1 a1_0 = new Cycle_B_2_00090_A1(); + Cycle_B_2_00090_A3 a3_0 = new Cycle_B_2_00090_A3(); + a1_0.a2_0 = new Cycle_B_2_00090_A2(); + a1_0.a2_0.a1_0 = a1_0; + a3_0.a2_0 = a1_0.a2_0; + a3_0.a2_0.a3_0 = a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a3_0.sum); + //System.out.println(nsum); + if (nsum == 9) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0067-rc-function-Cycle_B_2_00100/Cycle_B_2_00100.java b/test/testsuite/ouroboros/rc_test/RC0067-rc-function-Cycle_B_2_00100/Cycle_B_2_00100.java new file mode 100755 index 0000000000000000000000000000000000000000..eb23210859903c5968aecacfe6a345718e69876f --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0067-rc-function-Cycle_B_2_00100/Cycle_B_2_00100.java @@ -0,0 +1,134 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_2_00100.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_2_00100 in RC测试-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_2_00100.java + *- @ExecuteClass: Cycle_B_2_00100 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_2_00100_A1 { + Cycle_B_2_00100_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00100_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_2_00100_A2 { + Cycle_B_2_00100_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00100_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00100_A3 { + Cycle_B_2_00100_A1 a1_0; + Cycle_B_2_00100_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00100_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_2_00100_A4 { + Cycle_B_2_00100_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00100_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } +} + +class Cycle_B_2_00100_A5 { + Cycle_B_2_00100_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00100_A5() { + a3_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + +public class Cycle_B_2_00100 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00100_A1 a1_0 = new Cycle_B_2_00100_A1(); + a1_0.a2_0 = new Cycle_B_2_00100_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00100_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00100_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00100_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 29) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0068-rc-function-Cycle_B_2_00110/Cycle_B_2_00110.java b/test/testsuite/ouroboros/rc_test/RC0068-rc-function-Cycle_B_2_00110/Cycle_B_2_00110.java new file mode 100755 index 0000000000000000000000000000000000000000..56dd69ff8739ff9ef893b0151ba540b47025124d --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0068-rc-function-Cycle_B_2_00110/Cycle_B_2_00110.java @@ -0,0 +1,134 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_2_00110.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Cycle_B_2_00110 in RC测试-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_2_00110.java + *- @ExecuteClass: Cycle_B_2_00110 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_2_00110_A1 { + Cycle_B_2_00110_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00110_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_2_00110_A2 { + Cycle_B_2_00110_A3 a3_0; + Cycle_B_2_00110_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00110_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00110_A3 { + Cycle_B_2_00110_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00110_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_2_00110_A4 { + Cycle_B_2_00110_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00110_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } +} + +class Cycle_B_2_00110_A5 { + Cycle_B_2_00110_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00110_A5() { + a2_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + +public class Cycle_B_2_00110 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00110_A1 a1_0 = new Cycle_B_2_00110_A1(); + a1_0.a2_0 = new Cycle_B_2_00110_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00110_A3(); + a1_0.a2_0.a4_0 = new Cycle_B_2_00110_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a4_0.a5_0 = new Cycle_B_2_00110_A5(); + a1_0.a2_0.a4_0.a5_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + a1_0.a2_0.a4_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum + a1_0.a2_0.a4_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 28) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0069-rc-function-Cycle_B_2_00120/Cycle_B_2_00120.java b/test/testsuite/ouroboros/rc_test/RC0069-rc-function-Cycle_B_2_00120/Cycle_B_2_00120.java new file mode 100755 index 0000000000000000000000000000000000000000..5ea199dc6bea3191384672ab13a592de6223f350 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0069-rc-function-Cycle_B_2_00120/Cycle_B_2_00120.java @@ -0,0 +1,134 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_2_00120.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_2_00120 in RC测试-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_2_00120.java + *- @ExecuteClass: Cycle_B_2_00120 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_2_00120_A1 { + Cycle_B_2_00120_A2 a2_0; + Cycle_B_2_00120_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00120_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_2_00120_A2 { + Cycle_B_2_00120_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00120_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00120_A3 { + Cycle_B_2_00120_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00120_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_2_00120_A4 { + Cycle_B_2_00120_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00120_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } +} + +class Cycle_B_2_00120_A5 { + Cycle_B_2_00120_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00120_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + +public class Cycle_B_2_00120 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00120_A1 a1_0 = new Cycle_B_2_00120_A1(); + a1_0.a2_0 = new Cycle_B_2_00120_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00120_A3(); + a1_0.a4_0 = new Cycle_B_2_00120_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a4_0.a5_0 = new Cycle_B_2_00120_A5(); + a1_0.a4_0.a5_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a4_0.add(); + a1_0.a4_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a4_0.sum + a1_0.a4_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 27) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0070-rc-function-Cycle_B_2_00130/Cycle_B_2_00130.java b/test/testsuite/ouroboros/rc_test/RC0070-rc-function-Cycle_B_2_00130/Cycle_B_2_00130.java new file mode 100755 index 0000000000000000000000000000000000000000..0ac4b05b04fed29d4b8e9ca3eaba64e29def3554 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0070-rc-function-Cycle_B_2_00130/Cycle_B_2_00130.java @@ -0,0 +1,155 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_2_00130.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_2_00130 in RC测试-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_2_00130.java + *- @ExecuteClass: Cycle_B_2_00130 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_2_00130_A1 { + Cycle_B_2_00130_A2 a2_0; + Cycle_B_2_00130_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00130_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_2_00130_A2 { + Cycle_B_2_00130_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00130_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00130_A3 { + Cycle_B_2_00130_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00130_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } +} + + +class Cycle_B_2_00130_A4 { + Cycle_B_2_00130_A1 a1_0; + Cycle_B_2_00130_A6 a6_0; + int a; + int sum; + + Cycle_B_2_00130_A4() { + a1_0 = null; + a6_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a + a6_0.a; + } +} + +class Cycle_B_2_00130_A5 { + Cycle_B_2_00130_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00130_A5() { + a3_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_B_2_00130_A6 { + Cycle_B_2_00130_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00130_A6() { + a5_0 = null; + a = 6; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } +} + +public class Cycle_B_2_00130 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00130_A1 a1_0 = new Cycle_B_2_00130_A1(); + a1_0.a2_0 = new Cycle_B_2_00130_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00130_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00130_A4(); + a1_0.a2_0.a3_0.a4_0.a1_0 = a1_0; + Cycle_B_2_00130_A5 a5_0 = new Cycle_B_2_00130_A5(); + a1_0.a2_0.a3_0.a4_0.a6_0 = new Cycle_B_2_00130_A6(); + a1_0.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_0; + a5_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a6_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a5_0.sum + a1_0.a2_0.a3_0.a4_0.a6_0.sum); + //System.out.println(nsum); + if (nsum == 45) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0071-rc-function-Cycle_B_2_00140/Cycle_B_2_00140.java b/test/testsuite/ouroboros/rc_test/RC0071-rc-function-Cycle_B_2_00140/Cycle_B_2_00140.java new file mode 100755 index 0000000000000000000000000000000000000000..3d88ca3eb64de5fd575eb308cac8d11086eb9334 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0071-rc-function-Cycle_B_2_00140/Cycle_B_2_00140.java @@ -0,0 +1,100 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_2_00140.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_2_00140 in RC测试-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_2_00140.java + *- @ExecuteClass: Cycle_B_2_00140 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_2_00140_A1 { + Cycle_B_2_00140_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00140_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_2_00140_A2 { + Cycle_B_2_00140_A3 a3_0; + Cycle_B_2_00140_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00140_A2() { + a3_0 = null; + a1_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a + a1_0.a; + } +} + + +class Cycle_B_2_00140_A3 { + Cycle_B_2_00140_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00140_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +public class Cycle_B_2_00140 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00140_A1 a1_0 = new Cycle_B_2_00140_A1(); + a1_0.a2_0 = new Cycle_B_2_00140_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00140_A3(); + a1_0.a2_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + if (nsum == 13) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0072-rc-function-Cycle_B_2_00150/Cycle_B_2_00150.java b/test/testsuite/ouroboros/rc_test/RC0072-rc-function-Cycle_B_2_00150/Cycle_B_2_00150.java new file mode 100755 index 0000000000000000000000000000000000000000..835bbeabe1f4b43a00847d0884d67db47c71bdd9 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0072-rc-function-Cycle_B_2_00150/Cycle_B_2_00150.java @@ -0,0 +1,98 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_2_00150.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_2_00150 in RC测试-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_2_00150.java + *- @ExecuteClass: Cycle_B_2_00150 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_2_00150_A1 { + Cycle_B_2_00150_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00150_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_2_00150_A2 { + Cycle_B_2_00150_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00150_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00150_A3 { + Cycle_B_2_00150_A1 a1_0; + Cycle_B_2_00150_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00150_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a + a2_0.a; + } +} + + +public class Cycle_B_2_00150 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00150_A1 a1_0 = new Cycle_B_2_00150_A1(); + a1_0.a2_0 = new Cycle_B_2_00150_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00150_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + if (nsum == 14) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0073-rc-function-Cycle_B_2_00160/Cycle_B_2_00160.java b/test/testsuite/ouroboros/rc_test/RC0073-rc-function-Cycle_B_2_00160/Cycle_B_2_00160.java new file mode 100755 index 0000000000000000000000000000000000000000..bb312b776d80198611c1a584d23f9b1903b368f6 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0073-rc-function-Cycle_B_2_00160/Cycle_B_2_00160.java @@ -0,0 +1,98 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_2_00160.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_2_00160 in RC测试-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_2_00160.java + *- @ExecuteClass: Cycle_B_2_00160 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_2_00160_A1 { + Cycle_B_2_00160_A2 a2_0; + Cycle_B_2_00160_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00160_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } +} + + +class Cycle_B_2_00160_A2 { + Cycle_B_2_00160_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00160_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00160_A3 { + Cycle_B_2_00160_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00160_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +public class Cycle_B_2_00160 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00160_A1 a1_0 = new Cycle_B_2_00160_A1(); + a1_0.a2_0 = new Cycle_B_2_00160_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00160_A3(); + a1_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + if (nsum == 15) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0074-rc-function-Cycle_B_2_00170/Cycle_B_2_00170.java b/test/testsuite/ouroboros/rc_test/RC0074-rc-function-Cycle_B_2_00170/Cycle_B_2_00170.java new file mode 100755 index 0000000000000000000000000000000000000000..b51dd237c180f3fb7261e325b325c7904e4aa274 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0074-rc-function-Cycle_B_2_00170/Cycle_B_2_00170.java @@ -0,0 +1,116 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_2_00170.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_2_00170 in RC测试-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_2_00170.java + *- @ExecuteClass: Cycle_B_2_00170 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_2_00170_A1 { + Cycle_B_2_00170_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00170_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_2_00170_A2 { + Cycle_B_2_00170_A3 a3_0; + Cycle_B_2_00170_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00170_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } +} + + +class Cycle_B_2_00170_A3 { + Cycle_B_2_00170_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00170_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_2_00170_A4 { + Cycle_B_2_00170_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00170_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +public class Cycle_B_2_00170 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00170_A1 a1_0 = new Cycle_B_2_00170_A1(); + a1_0.a2_0 = new Cycle_B_2_00170_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00170_A3(); + a1_0.a2_0.a4_0 = new Cycle_B_2_00170_A4(); + a1_0.a2_0.a4_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum); + //System.out.println(nsum); + if (nsum == 21) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0075-rc-function-Cycle_B_2_00180/Cycle_B_2_00180.java b/test/testsuite/ouroboros/rc_test/RC0075-rc-function-Cycle_B_2_00180/Cycle_B_2_00180.java new file mode 100755 index 0000000000000000000000000000000000000000..38877622234c8f756c2d6baf23a580d265cdd076 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0075-rc-function-Cycle_B_2_00180/Cycle_B_2_00180.java @@ -0,0 +1,117 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_2_00180.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_2_00180 in RC测试-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_2_00180.java + *- @ExecuteClass: Cycle_B_2_00180 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_2_00180_A1 { + Cycle_B_2_00180_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00180_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_2_00180_A2 { + Cycle_B_2_00180_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00180_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00180_A3 { + Cycle_B_2_00180_A1 a1_0; + Cycle_B_2_00180_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00180_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a + a4_0.a; + } +} + + +class Cycle_B_2_00180_A4 { + Cycle_B_2_00180_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00180_A4() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +public class Cycle_B_2_00180 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00180_A1 a1_0 = new Cycle_B_2_00180_A1(); + a1_0.a2_0 = new Cycle_B_2_00180_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00180_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00180_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum); + //System.out.println(nsum); + if (nsum == 15) + System.out.println("ExpectResult"); + } + + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0076-rc-function-Cycle_B_2_00190/Cycle_B_2_00190.java b/test/testsuite/ouroboros/rc_test/RC0076-rc-function-Cycle_B_2_00190/Cycle_B_2_00190.java new file mode 100755 index 0000000000000000000000000000000000000000..d4e157a7b22db87003530a27ff3af2fe76ae2dcf --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0076-rc-function-Cycle_B_2_00190/Cycle_B_2_00190.java @@ -0,0 +1,116 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_2_00190.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_2_00190 in RC测试-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_2_00190.java + *- @ExecuteClass: Cycle_B_2_00190 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_2_00190_A1 { + Cycle_B_2_00190_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00190_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_2_00190_A2 { + Cycle_B_2_00190_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00190_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00190_A3 { + Cycle_B_2_00190_A1 a1_0; + Cycle_B_2_00190_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00190_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } +} + + +class Cycle_B_2_00190_A4 { + Cycle_B_2_00190_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00190_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +public class Cycle_B_2_00190 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00190_A1 a1_0 = new Cycle_B_2_00190_A1(); + a1_0.a2_0 = new Cycle_B_2_00190_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00190_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00190_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum); + //System.out.println(nsum); + if (nsum == 15) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0077-rc-function-Cycle_B_2_00200/Cycle_B_2_00200.java b/test/testsuite/ouroboros/rc_test/RC0077-rc-function-Cycle_B_2_00200/Cycle_B_2_00200.java new file mode 100755 index 0000000000000000000000000000000000000000..94f7d680e530b2d1322b529fadc03c10b743a9d6 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0077-rc-function-Cycle_B_2_00200/Cycle_B_2_00200.java @@ -0,0 +1,117 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_2_00200.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_2_00200 in RC测试-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_2_00200.java + *- @ExecuteClass: Cycle_B_2_00200 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_2_00200_A1 { + Cycle_B_2_00200_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00200_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_2_00200_A2 { + Cycle_B_2_00200_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00200_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00200_A3 { + Cycle_B_2_00200_A1 a1_0; + Cycle_B_2_00200_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00200_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a4_0.a + a1_0.a; + } +} + + +class Cycle_B_2_00200_A4 { + Cycle_B_2_00200_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00200_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +public class Cycle_B_2_00200 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00200_A1 a1_0 = new Cycle_B_2_00200_A1(); + a1_0.a2_0 = new Cycle_B_2_00200_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00200_A3(); + Cycle_B_2_00200_A4 a4_0 = new Cycle_B_2_00200_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0 = a4_0; + a4_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + if (nsum == 16) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0078-rc-function-Cycle_B_2_00210/Cycle_B_2_00210.java b/test/testsuite/ouroboros/rc_test/RC0078-rc-function-Cycle_B_2_00210/Cycle_B_2_00210.java new file mode 100755 index 0000000000000000000000000000000000000000..2658f7c68b8eb2c3beddfd3eab8e991db80fd952 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0078-rc-function-Cycle_B_2_00210/Cycle_B_2_00210.java @@ -0,0 +1,211 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_2_00210.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_2_00210 in RC测试-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_2_00210.java + *- @ExecuteClass: Cycle_B_2_00210 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_2_00210_A1 { + Cycle_B_2_00210_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00210_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_2_00210_A2 { + Cycle_B_2_00210_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00210_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00210_A3 { + Cycle_B_2_00210_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00210_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } +} + + +class Cycle_B_2_00210_A4 { + Cycle_B_2_00210_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00210_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } +} + + +class Cycle_B_2_00210_A5 { + Cycle_B_2_00210_A6 a6_0; + int a; + int sum; + + Cycle_B_2_00210_A5() { + a6_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a6_0.a; + } +} + + +class Cycle_B_2_00210_A6 { + Cycle_B_2_00210_A1 a1_0; + Cycle_B_2_00210_A8 a8_0; + int a; + int sum; + + Cycle_B_2_00210_A6() { + a1_0 = null; + a8_0 = null; + a = 6; + sum = 0; + } + + void add() { + sum = a + a1_0.a + a8_0.a; + } +} + +class Cycle_B_2_00210_A8 { + Cycle_B_2_00210_A9 a9_0; + int a; + int sum; + + Cycle_B_2_00210_A8() { + a9_0 = null; + a = 7; + sum = 0; + } + + void add() { + sum = a + a9_0.a; + } +} + + +class Cycle_B_2_00210_A9 { + Cycle_B_2_00210_A7 a7_0; + int a; + int sum; + + Cycle_B_2_00210_A9() { + a7_0 = null; + a = 8; + sum = 0; + } + + void add() { + sum = a + a7_0.a; + } +} + + +class Cycle_B_2_00210_A7 { + Cycle_B_2_00210_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00210_A7() { + a4_0 = null; + a = 9; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } +} + + +public class Cycle_B_2_00210 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00210_A1 a1_0 = new Cycle_B_2_00210_A1(); + a1_0.a2_0 = new Cycle_B_2_00210_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00210_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00210_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00210_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_B_2_00210_A6(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0 = new Cycle_B_2_00210_A8(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0 = new Cycle_B_2_00210_A9(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.a7_0 = new Cycle_B_2_00210_A7(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.a7_0.a4_0 = a1_0.a2_0.a3_0.a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.a7_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.a7_0.sum); + //System.out.println(nsum); + if (nsum == 94) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0079-rc-function-Cycle_B_2_00220/Cycle_B_2_00220.java b/test/testsuite/ouroboros/rc_test/RC0079-rc-function-Cycle_B_2_00220/Cycle_B_2_00220.java new file mode 100755 index 0000000000000000000000000000000000000000..2fbef796987250ac367bea89c8f9d0ab4ee556a7 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0079-rc-function-Cycle_B_2_00220/Cycle_B_2_00220.java @@ -0,0 +1,211 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_2_00220.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_2_00220 in RC测试-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_2_00220.java + *- @ExecuteClass: Cycle_B_2_00220 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_2_00220_A1 { + Cycle_B_2_00220_A2 a2_0; + Cycle_B_2_00220_A8 a8_0; + int a; + int sum; + + Cycle_B_2_00220_A1() { + a2_0 = null; + a8_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a + a8_0.a; + } +} + + +class Cycle_B_2_00220_A2 { + Cycle_B_2_00220_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00220_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00220_A3 { + Cycle_B_2_00220_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00220_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } +} + + +class Cycle_B_2_00220_A4 { + Cycle_B_2_00220_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00220_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } +} + + +class Cycle_B_2_00220_A5 { + Cycle_B_2_00220_A6 a6_0; + int a; + int sum; + + Cycle_B_2_00220_A5() { + a6_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a6_0.a; + } +} + + +class Cycle_B_2_00220_A6 { + Cycle_B_2_00220_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00220_A6() { + a1_0 = null; + a = 6; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + +class Cycle_B_2_00220_A8 { + Cycle_B_2_00220_A9 a9_0; + int a; + int sum; + + Cycle_B_2_00220_A8() { + a9_0 = null; + a = 7; + sum = 0; + } + + void add() { + sum = a + a9_0.a; + } +} + + +class Cycle_B_2_00220_A9 { + Cycle_B_2_00220_A7 a7_0; + int a; + int sum; + + Cycle_B_2_00220_A9() { + a7_0 = null; + a = 8; + sum = 0; + } + + void add() { + sum = a + a7_0.a; + } +} + + +class Cycle_B_2_00220_A7 { + Cycle_B_2_00220_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00220_A7() { + a4_0 = null; + a = 9; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } +} + + +public class Cycle_B_2_00220 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00220_A1 a1_0 = new Cycle_B_2_00220_A1(); + a1_0.a2_0 = new Cycle_B_2_00220_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00220_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00220_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00220_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_B_2_00220_A6(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_0; + a1_0.a8_0 = new Cycle_B_2_00220_A8(); + a1_0.a8_0.a9_0 = new Cycle_B_2_00220_A9(); + a1_0.a8_0.a9_0.a7_0 = new Cycle_B_2_00220_A7(); + a1_0.a8_0.a9_0.a7_0.a4_0 = a1_0.a2_0.a3_0.a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a1_0.a8_0.add(); + a1_0.a8_0.a9_0.add(); + a1_0.a8_0.a9_0.a7_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a1_0.a8_0.sum + a1_0.a8_0.a9_0.sum + a1_0.a8_0.a9_0.a7_0.sum); + //System.out.println(nsum); + if (nsum == 94) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0080-rc-function-Cycle_B_2_00230/Cycle_B_2_00230.java b/test/testsuite/ouroboros/rc_test/RC0080-rc-function-Cycle_B_2_00230/Cycle_B_2_00230.java new file mode 100755 index 0000000000000000000000000000000000000000..5e6bbbd2c689df4de060638ca19b0fa9a0a0949a --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0080-rc-function-Cycle_B_2_00230/Cycle_B_2_00230.java @@ -0,0 +1,232 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_2_00230.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_2_00230 in RC测试-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_2_00230.java + *- @ExecuteClass: Cycle_B_2_00230 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_B_2_00230_A1 { + Cycle_B_2_00230_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00230_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_2_00230_A2 { + Cycle_B_2_00230_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00230_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00230_A3 { + Cycle_B_2_00230_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00230_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } +} + + +class Cycle_B_2_00230_A4 { + Cycle_B_2_00230_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00230_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } +} + + +class Cycle_B_2_00230_A5 { + Cycle_B_2_00230_A6 a6_0; + int a; + int sum; + + Cycle_B_2_00230_A5() { + a6_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a6_0.a; + } +} + + +class Cycle_B_2_00230_A6 { + Cycle_B_2_00230_A1 a1_0; + Cycle_B_2_00230_A10 a10_0; + int a; + int sum; + + Cycle_B_2_00230_A6() { + a1_0 = null; + a10_0 = null; + a = 6; + sum = 0; + } + + void add() { + sum = a + a1_0.a + a10_0.a; + } +} + +class Cycle_B_2_00230_A8 { + Cycle_B_2_00230_A9 a9_0; + int a; + int sum; + + Cycle_B_2_00230_A8() { + a9_0 = null; + a = 7; + sum = 0; + } + + void add() { + sum = a + a9_0.a; + } +} + + +class Cycle_B_2_00230_A9 { + Cycle_B_2_00230_A7 a7_0; + int a; + int sum; + + Cycle_B_2_00230_A9() { + a7_0 = null; + a = 8; + sum = 0; + } + + void add() { + sum = a + a7_0.a; + } +} + + +class Cycle_B_2_00230_A7 { + Cycle_B_2_00230_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00230_A7() { + a4_0 = null; + a = 9; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } +} + + +class Cycle_B_2_00230_A10 { + Cycle_B_2_00230_A8 a8_0; + int a; + int sum; + + Cycle_B_2_00230_A10() { + a8_0 = null; + a = 10; + sum = 0; + } + + void add() { + sum = a + a8_0.a; + } +} + + +public class Cycle_B_2_00230 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00230_A1 a1_0 = new Cycle_B_2_00230_A1(); + a1_0.a2_0 = new Cycle_B_2_00230_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00230_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00230_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00230_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_B_2_00230_A6(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_0; + + Cycle_B_2_00230_A10 a10_0 = new Cycle_B_2_00230_A10(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a10_0 = a10_0; + a10_0.a8_0 = new Cycle_B_2_00230_A8(); + a10_0.a8_0.a9_0 = new Cycle_B_2_00230_A9(); + a10_0.a8_0.a9_0.a7_0 = new Cycle_B_2_00230_A7(); + a10_0.a8_0.a9_0.a7_0.a4_0 = a1_0.a2_0.a3_0.a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a10_0.a8_0.add(); + a10_0.a8_0.a9_0.add(); + a10_0.a8_0.a9_0.a7_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a10_0.a8_0.sum + a10_0.a8_0.a9_0.sum + a10_0.a8_0.a9_0.a7_0.sum); + + //System.out.println(nsum); + if (nsum == 97) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0081-rc-function-Cycle_B_2_00240/Cycle_B_2_00240.java b/test/testsuite/ouroboros/rc_test/RC0081-rc-function-Cycle_B_2_00240/Cycle_B_2_00240.java new file mode 100755 index 0000000000000000000000000000000000000000..7b0414e37aa45515d55b08c700458330db88ddc6 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0081-rc-function-Cycle_B_2_00240/Cycle_B_2_00240.java @@ -0,0 +1,226 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Cycle_B_2_00240.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_2_00240 in RC测试-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_B_2_00240.java + *- @ExecuteClass: Cycle_B_2_00240 + *- @ExecuteArgs: + *- @Remark: + */ + +class Cycle_B_2_00240_A1 { + Cycle_B_2_00240_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_B_2_00240_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_B_2_00240_A2 { + Cycle_B_2_00240_A1 a1_0; + Cycle_B_2_00240_A3 a3_0; + Cycle_B_2_00240_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_B_2_00240_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } +} + +class Cycle_B_2_00240_A3 { + Cycle_B_2_00240_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_B_2_00240_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_2_00240_A4 { + Cycle_B_2_00240_A1 a1_0; + Cycle_B_2_00240_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_B_2_00240_A4(String strObjectName) { + a2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a2_0.a; + } +} + +class Cycle_B_2_00240_B1 { + Cycle_B_2_00240_A3 a3_0; + Cycle_B_2_00240_B2 b2_0; + Nocycle_B_2_00240_C2 c2_0; + + + int a; + int sum; + + Cycle_B_2_00240_B1() { + a3_0 = null; + b2_0 = null; + c2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a3_0.a + b2_0.a + c2_0.a; + } +} + + +class Cycle_B_2_00240_B2 { + Cycle_B_2_00240_B1 b1_0; + int a; + int sum; + + Cycle_B_2_00240_B2() { + b1_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + b1_0.a; + } +} + +class Nocycle_B_2_00240_C1 { + Nocycle_B_2_00240_C2 c2_0; + int a; + int sum; + String strObjectName; + + Nocycle_B_2_00240_C1(String strObjectName) { + c2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + // protected void finalize() throws java.lang.Throwable { +// System.out.println("RC-Testing_Destruction_A1_"+strObjectName); +// } + void add() { + sum = a + c2_0.a; + } +} + +class Nocycle_B_2_00240_C2 { + int a; + int sum; + String strObjectName; + + Nocycle_B_2_00240_C2(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + // protected void finalize() throws java.lang.Throwable { +// System.out.println("RC-Testing_Destruction_B1_"+strObjectName); +// } + void add() { + sum = a + a; + } +} + +public class Cycle_B_2_00240 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00240_A1 a1_main = new Cycle_B_2_00240_A1("a1_main"); + a1_main.a2_0 = new Cycle_B_2_00240_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_B_2_00240_A3("a3_0"); + a1_main.a2_0.a4_0 = new Cycle_B_2_00240_A4("a4_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a4_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a4_0.a1_0 = a1_main; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a4_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a4_0.sum; + + Cycle_B_2_00240_B1 b1_0 = new Cycle_B_2_00240_B1(); + b1_0.a3_0 = new Cycle_B_2_00240_A3("a3_b1"); + b1_0.b2_0 = new Cycle_B_2_00240_B2(); + b1_0.c2_0 = new Nocycle_B_2_00240_C2("c2_b1"); + b1_0.b2_0.b1_0 = b1_0; + b1_0.add(); + b1_0.b2_0.add(); + int nsum = (b1_0.sum + b1_0.b2_0.sum); + Nocycle_B_2_00240_C1 c1_main = new Nocycle_B_2_00240_C1("c1_main"); + c1_main.c2_0 = new Nocycle_B_2_00240_C2("c2_0"); + c1_main.add(); + c1_main.c2_0.add(); + int result2 = c1_main.sum + c1_main.c2_0.sum; + if (result == 1124 && nsum == 310 && result2 == 704) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0082-rc-function-Nocycle_a_00010/Nocycle_a_00010.java b/test/testsuite/ouroboros/rc_test/RC0082-rc-function-Nocycle_a_00010/Nocycle_a_00010.java new file mode 100755 index 0000000000000000000000000000000000000000..82eb2f8971ed2bc607d9b45ce53a76cc4617fc7d --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0082-rc-function-Nocycle_a_00010/Nocycle_a_00010.java @@ -0,0 +1,86 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Nocycle_a_00010.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_a_00010 in RC测试-No-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_a_00010.java + *- @ExecuteClass: Nocycle_a_00010 + *- @ExecuteArgs: + *- @Remark: + */ + +class Nocycle_a_00010_A1 { + Nocycle_a_00010_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00010_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + // protected void finalize() throws java.lang.Throwable { +// System.out.println("RC-Testing_Destruction_A1_"+strObjectName); +// } + void add() { + sum = a + b1_0.a; + } +} + +class Nocycle_a_00010_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00010_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + // protected void finalize() throws java.lang.Throwable { +// System.out.println("RC-Testing_Destruction_B1_"+strObjectName); +// } + void add() { + sum = a + a; + } +} + + +public class Nocycle_a_00010 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + + public static void rc_testcase_main_wrapper() { + Nocycle_a_00010_A1 a1_main = new Nocycle_a_00010_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00010_B1("b1_0"); + a1_main.add(); + a1_main.b1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 704) + System.out.println("ExpectResult"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0083-rc-function-Nocycle_a_00020/Nocycle_a_00020.java b/test/testsuite/ouroboros/rc_test/RC0083-rc-function-Nocycle_a_00020/Nocycle_a_00020.java new file mode 100755 index 0000000000000000000000000000000000000000..fb67867271bc28a0dd6cc658d2bdd14a9f28f629 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0083-rc-function-Nocycle_a_00020/Nocycle_a_00020.java @@ -0,0 +1,99 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Nocycle_a_00020.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_a_00020 in RC测试-No-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_a_00020.java + *- @ExecuteClass: Nocycle_a_00020 + *- @ExecuteArgs: + *- @Remark: + */ +class Nocycle_a_00020_A1 { + Nocycle_a_00020_B1 b1_0; + Nocycle_a_00020_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00020_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } +} + +class Nocycle_a_00020_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00020_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00020_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00020_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + + +public class Nocycle_a_00020 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + + private static void rc_testcase_main_wrapper() { + Nocycle_a_00020_A1 a1_main = new Nocycle_a_00020_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00020_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00020_B2("b2_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1310) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0084-rc-function-Nocycle_a_00030/Nocycle_a_00030.java b/test/testsuite/ouroboros/rc_test/RC0084-rc-function-Nocycle_a_00030/Nocycle_a_00030.java new file mode 100755 index 0000000000000000000000000000000000000000..da0819fc73966372a5036bfc266b94ed5f24a3e6 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0084-rc-function-Nocycle_a_00030/Nocycle_a_00030.java @@ -0,0 +1,119 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Nocycle_a_00030.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_a_00030 in RC测试-No-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_a_00030.java + *- @ExecuteClass: Nocycle_a_00030 + *- @ExecuteArgs: + *- @Remark: + */ +class Nocycle_a_00030_A1 { + Nocycle_a_00030_B1 b1_0; + Nocycle_a_00030_B2 b2_0; + Nocycle_a_00030_B3 b3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00030_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } +} + +class Nocycle_a_00030_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00030_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00030_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00030_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + + +class Nocycle_a_00030_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00030_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +public class Nocycle_a_00030 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Nocycle_a_00030_A1 a1_main = new Nocycle_a_00030_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00030_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00030_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00030_B3("b3_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum; + if (result == 1919) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0085-rc-function-Nocycle_a_00040/Nocycle_a_00040.java b/test/testsuite/ouroboros/rc_test/RC0085-rc-function-Nocycle_a_00040/Nocycle_a_00040.java new file mode 100755 index 0000000000000000000000000000000000000000..627938f3e5b60be61adc9e29707680a9fa3c1969 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0085-rc-function-Nocycle_a_00040/Nocycle_a_00040.java @@ -0,0 +1,266 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Nocycle_a_00040.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_a_00040 in RC测试-No-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_a_00040.java + *- @ExecuteClass: Nocycle_a_00040 + *- @ExecuteArgs: + *- @Remark: + */ +class Nocycle_a_00040_A1 { + Nocycle_a_00040_B1 b1_0; + Nocycle_a_00040_B2 b2_0; + Nocycle_a_00040_B3 b3_0; + Nocycle_a_00040_B4 b4_0; + Nocycle_a_00040_B5 b5_0; + Nocycle_a_00040_B6 b6_0; + Nocycle_a_00040_B7 b7_0; + Nocycle_a_00040_B8 b8_0; + Nocycle_a_00040_B9 b9_0; + Nocycle_a_00040_B10 b10_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + b5_0 = null; + b6_0 = null; + b7_0 = null; + b8_0 = null; + b9_0 = null; + b10_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a + b5_0.a + b6_0.a + b7_0.a + b8_0.a + b9_0.a + b10_0.a; + } +} + +class Nocycle_a_00040_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00040_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + + +class Nocycle_a_00040_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00040_B4 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00040_B5 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B5(String strObjectName) { + a = 205; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B5_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00040_B6 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B6(String strObjectName) { + a = 206; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B6_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00040_B7 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B7(String strObjectName) { + a = 207; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B7_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + + +class Nocycle_a_00040_B8 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B8(String strObjectName) { + a = 208; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B8_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00040_B9 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B9(String strObjectName) { + a = 209; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B9_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00040_B10 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B10(String strObjectName) { + a = 210; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B10_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +public class Nocycle_a_00040 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Nocycle_a_00040_A1 a1_main = new Nocycle_a_00040_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00040_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00040_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00040_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00040_B4("b4_0"); + a1_main.b5_0 = new Nocycle_a_00040_B5("b5_0"); + a1_main.b6_0 = new Nocycle_a_00040_B6("b6_0"); + a1_main.b7_0 = new Nocycle_a_00040_B7("b7_0"); + a1_main.b8_0 = new Nocycle_a_00040_B8("b8_0"); + a1_main.b9_0 = new Nocycle_a_00040_B9("b9_0"); + a1_main.b10_0 = new Nocycle_a_00040_B10("b10_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b5_0.add(); + a1_main.b6_0.add(); + a1_main.b7_0.add(); + a1_main.b8_0.add(); + a1_main.b9_0.add(); + a1_main.b10_0.add(); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b5_0.sum + a1_main.b6_0.sum + a1_main.b7_0.sum + a1_main.b8_0.sum + a1_main.b9_0.sum + a1_main.b10_0.sum; + if (result == 6266) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0086-rc-function-Nocycle_a_00050/Nocycle_a_00050.java b/test/testsuite/ouroboros/rc_test/RC0086-rc-function-Nocycle_a_00050/Nocycle_a_00050.java new file mode 100755 index 0000000000000000000000000000000000000000..7ff7443f456d591d26635ad677f57efac812f85d --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0086-rc-function-Nocycle_a_00050/Nocycle_a_00050.java @@ -0,0 +1,206 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Nocycle_a_00050.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_a_00050 in RC测试-No-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_a_00050.java + *- @ExecuteClass: Nocycle_a_00050 + *- @ExecuteArgs: + *- @Remark: + */ +class Nocycle_a_00050_A1 { + Nocycle_a_00050_B1 b1_0; + Nocycle_a_00050_B2 b2_0; + Nocycle_a_00050_B3 b3_0; + Nocycle_a_00050_B4 b4_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00050_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } +} + +class Nocycle_a_00050_B1 { + Nocycle_a_00050_C1 c1_0; + Nocycle_a_00050_C2 c2_0; + Nocycle_a_00050_C3 c3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00050_B1(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } +} + +class Nocycle_a_00050_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00050_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + + +class Nocycle_a_00050_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00050_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00050_B4 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00050_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00050_C1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00050_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00050_C2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00050_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00050_C3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00050_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +public class Nocycle_a_00050 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Nocycle_a_00050_A1 a1_main = new Nocycle_a_00050_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00050_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_a_00050_C1("c1_0"); + a1_main.b1_0.c2_0 = new Nocycle_a_00050_C2("c2_0"); + a1_main.b1_0.c3_0 = new Nocycle_a_00050_C3("c3_0"); + a1_main.b2_0 = new Nocycle_a_00050_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00050_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00050_B4("b4_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b1_0.c1_0.add(); + a1_main.b1_0.c2_0.add(); + a1_main.b1_0.c3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b1_0.c1_0.sum+a1_main.b1_0.c2_0.sum+a1_main.b1_0.c3_0.sum); + + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b1_0.c1_0.sum + a1_main.b1_0.c2_0.sum + a1_main.b1_0.c3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 5048) + System.out.println("ExpectResult"); + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0087-rc-function-Nocycle_a_00060/Nocycle_a_00060.java b/test/testsuite/ouroboros/rc_test/RC0087-rc-function-Nocycle_a_00060/Nocycle_a_00060.java new file mode 100755 index 0000000000000000000000000000000000000000..d1c1ec86d47e0e2c2d61518da58ba43c924972cb --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0087-rc-function-Nocycle_a_00060/Nocycle_a_00060.java @@ -0,0 +1,205 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Nocycle_a_00060.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_a_00060 in RC测试-No-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_a_00060.java + *- @ExecuteClass: Nocycle_a_00060 + *- @ExecuteArgs: + *- @Remark: + */ +class Nocycle_a_00060_A1 { + Nocycle_a_00060_B1 b1_0; + Nocycle_a_00060_B2 b2_0; + Nocycle_a_00060_B3 b3_0; + Nocycle_a_00060_B4 b4_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00060_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } +} + +class Nocycle_a_00060_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00060_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00060_B2 { + Nocycle_a_00060_C1 c1_0; + Nocycle_a_00060_C2 c2_0; + Nocycle_a_00060_C3 c3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00060_B2(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } +} + + +class Nocycle_a_00060_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00060_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00060_B4 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00060_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00060_C1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00060_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00060_C2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00060_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00060_C3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00060_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +public class Nocycle_a_00060 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Nocycle_a_00060_A1 a1_main = new Nocycle_a_00060_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00060_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00060_B2("b2_0"); + a1_main.b2_0.c1_0 = new Nocycle_a_00060_C1("c1_0"); + a1_main.b2_0.c2_0 = new Nocycle_a_00060_C2("c2_0"); + a1_main.b2_0.c3_0 = new Nocycle_a_00060_C3("c3_0"); + a1_main.b3_0 = new Nocycle_a_00060_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00060_B4("b4_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b2_0.c1_0.add(); + a1_main.b2_0.c2_0.add(); + a1_main.b2_0.c3_0.add(); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b2_0.c1_0.sum + a1_main.b2_0.c2_0.sum + a1_main.b2_0.c3_0.sum; + if (result == 5047) + System.out.println("ExpectResult"); + + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0088-rc-function-Nocycle_a_00070/Nocycle_a_00070.java b/test/testsuite/ouroboros/rc_test/RC0088-rc-function-Nocycle_a_00070/Nocycle_a_00070.java new file mode 100755 index 0000000000000000000000000000000000000000..2781bc13d273cbb190f5e174a3bdf65cfaa219b4 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0088-rc-function-Nocycle_a_00070/Nocycle_a_00070.java @@ -0,0 +1,211 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Nocycle_a_00070.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_a_00070 in RC测试-No-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_a_00070.java + *- @ExecuteClass: Nocycle_a_00070 + *- @ExecuteArgs: + *- @Remark: + */ +class Nocycle_a_00070_A1 { + Nocycle_a_00070_B1 b1_0; + Nocycle_a_00070_B2 b2_0; + Nocycle_a_00070_B3 b3_0; + Nocycle_a_00070_B4 b4_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00070_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } +} + +class Nocycle_a_00070_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00070_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + + +class Nocycle_a_00070_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00070_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + + +class Nocycle_a_00070_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00070_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + + +class Nocycle_a_00070_B4 { + Nocycle_a_00070_C1 c1_0; + Nocycle_a_00070_C2 c2_0; + Nocycle_a_00070_C3 c3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00070_B4(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } +} + + +class Nocycle_a_00070_C1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00070_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00070_C2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00070_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00070_C3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00070_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +public class Nocycle_a_00070 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + + } + + private static void rc_testcase_main_wrapper() { + Nocycle_a_00070_A1 a1_main = new Nocycle_a_00070_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00070_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00070_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00070_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00070_B4("b4_0"); + a1_main.b4_0.c1_0 = new Nocycle_a_00070_C1("c1_0"); + a1_main.b4_0.c2_0 = new Nocycle_a_00070_C2("c2_0"); + a1_main.b4_0.c3_0 = new Nocycle_a_00070_C3("c3_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b4_0.c1_0.add(); + a1_main.b4_0.c2_0.add(); + a1_main.b4_0.c3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b4_0.c1_0.sum+a1_main.b4_0.c2_0.sum+a1_main.b4_0.c3_0.sum); + + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b4_0.c1_0.sum + a1_main.b4_0.c2_0.sum + a1_main.b4_0.c3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 5045) + System.out.println("ExpectResult"); + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0089-rc-function-Nocycle_a_00080/Nocycle_a_00080.java b/test/testsuite/ouroboros/rc_test/RC0089-rc-function-Nocycle_a_00080/Nocycle_a_00080.java new file mode 100755 index 0000000000000000000000000000000000000000..cd83bc40b214777e7d7dd7386b377c9798e28d5d --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0089-rc-function-Nocycle_a_00080/Nocycle_a_00080.java @@ -0,0 +1,103 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Nocycle_a_00080.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_a_00080 in RC测试-No-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_a_00080.java + *- @ExecuteClass: Nocycle_a_00080 + *- @ExecuteArgs: + *- @Remark: + */ +class Nocycle_a_00080_A1 { + Nocycle_a_00080_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00080_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } +} + +class Nocycle_a_00080_B1 { + Nocycle_a_00080_C1 c1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00080_B1(String strObjectName) { + c1_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } +} + + +class Nocycle_a_00080_C1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00080_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + + +public class Nocycle_a_00080 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Nocycle_a_00080_A1 a1_main = new Nocycle_a_00080_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00080_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_a_00080_C1("c1_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b1_0.c1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b1_0.c1_0.sum); + + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b1_0.c1_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1406) + System.out.println("ExpectResult"); + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0090-rc-function-Nocycle_a_00090/Nocycle_a_00090.java b/test/testsuite/ouroboros/rc_test/RC0090-rc-function-Nocycle_a_00090/Nocycle_a_00090.java new file mode 100755 index 0000000000000000000000000000000000000000..3a1c45810431032a1653686cfcb3c2999782fb4a --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0090-rc-function-Nocycle_a_00090/Nocycle_a_00090.java @@ -0,0 +1,124 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Nocycle_a_00090.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_a_00090 in RC测试-No-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_a_00090.java + *- @ExecuteClass: Nocycle_a_00090 + *- @ExecuteArgs: + *- @Remark: + */ +class Nocycle_a_00090_A1 { + Nocycle_a_00090_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00090_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } +} + +class Nocycle_a_00090_B1 { + Nocycle_a_00090_C1 c1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00090_B1(String strObjectName) { + c1_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } +} + + +class Nocycle_a_00090_C1 { + Nocycle_a_00090_D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00090_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + d1_0.a; + } +} + +class Nocycle_a_00090_D1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00090_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + + +public class Nocycle_a_00090 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Nocycle_a_00090_A1 a1_main = new Nocycle_a_00090_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00090_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_a_00090_C1("c1_0"); + a1_main.b1_0.c1_0.d1_0 = new Nocycle_a_00090_D1("d1_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b1_0.c1_0.add(); + a1_main.b1_0.c1_0.d1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b1_0.c1_0.sum+a1_main.b1_0.c1_0.d1_0.sum); + + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b1_0.c1_0.sum + a1_main.b1_0.c1_0.d1_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2308) + System.out.println("ExpectResult"); + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0091-rc-function-Nocycle_a_00100/Nocycle_a_00100.java b/test/testsuite/ouroboros/rc_test/RC0091-rc-function-Nocycle_a_00100/Nocycle_a_00100.java new file mode 100755 index 0000000000000000000000000000000000000000..6dc5e15a90f516427ab34c0c32b8d988328cd728 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0091-rc-function-Nocycle_a_00100/Nocycle_a_00100.java @@ -0,0 +1,251 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Nocycle_a_00100.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_a_00100 in RC测试-No-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_a_00100.java + *- @ExecuteClass: Nocycle_a_00100 + *- @ExecuteArgs: + *- @Remark: + */ +class Nocycle_a_00100_A1 { + Nocycle_a_00100_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } +} + +class Nocycle_a_00100_B1 { + Nocycle_a_00100_C1 c1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_B1(String strObjectName) { + c1_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } +} + + +class Nocycle_a_00100_C1 { + Nocycle_a_00100_D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + d1_0.a; + } +} + +class Nocycle_a_00100_D1 { + Nocycle_a_00100_E1 e1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_D1(String strObjectName) { + e1_0 = null; + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + + void add() { + sum = a + e1_0.a; + } +} + +class Nocycle_a_00100_E1 { + Nocycle_a_00100_F1 f1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_E1(String strObjectName) { + f1_0 = null; + a = 501; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_E1_"+strObjectName); + } + + void add() { + sum = a + f1_0.a; + } +} + + +class Nocycle_a_00100_F1 { + Nocycle_a_00100_G1 g1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_F1(String strObjectName) { + g1_0 = null; + a = 601; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_F1_"+strObjectName); + } + + void add() { + sum = a + g1_0.a; + } +} + +class Nocycle_a_00100_G1 { + Nocycle_a_00100_H1 h1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_G1(String strObjectName) { + h1_0 = null; + a = 701; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_G1_"+strObjectName); + } + + void add() { + sum = a + h1_0.a; + } +} + + +class Nocycle_a_00100_H1 { + Nocycle_a_00100_I1 i1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_H1(String strObjectName) { + i1_0 = null; + a = 801; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_H1_"+strObjectName); + } + + void add() { + sum = a + i1_0.a; + } +} + + +class Nocycle_a_00100_I1 { + Nocycle_a_00100_J1 j1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_I1(String strObjectName) { + j1_0 = null; + a = 901; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_I1_"+strObjectName); + } + + void add() { + sum = a + j1_0.a; + } +} + +class Nocycle_a_00100_J1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_J1(String strObjectName) { + a = 1001; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_J1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + + +public class Nocycle_a_00100 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Nocycle_a_00100_A1 a1_main = new Nocycle_a_00100_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00100_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_a_00100_C1("c1_0"); + a1_main.b1_0.c1_0.d1_0 = new Nocycle_a_00100_D1("d1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0 = new Nocycle_a_00100_E1("e1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0 = new Nocycle_a_00100_F1("f1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0 = new Nocycle_a_00100_G1("g1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0 = new Nocycle_a_00100_H1("h1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0 = new Nocycle_a_00100_I1("i1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0 = new Nocycle_a_00100_J1("j1_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b1_0.c1_0.add(); + a1_main.b1_0.c1_0.d1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.add(); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b1_0.c1_0.sum + a1_main.b1_0.c1_0.d1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.sum; + + if (result == 11920) + System.out.println("ExpectResult"); + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0092-rc-function-Nocycle_a_00110/Nocycle_a_00110.java b/test/testsuite/ouroboros/rc_test/RC0092-rc-function-Nocycle_a_00110/Nocycle_a_00110.java new file mode 100755 index 0000000000000000000000000000000000000000..3e193ff2c6c96d88ff14759ef282efcd6f79f70f --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0092-rc-function-Nocycle_a_00110/Nocycle_a_00110.java @@ -0,0 +1,312 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Nocycle_a_00110.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_a_00110 in RC测试-No-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_a_00110.java + *- @ExecuteClass: Nocycle_a_00110 + *- @ExecuteArgs: + *- @Remark: + */ +class Nocycle_a_00110_A1 { + Nocycle_a_00110_B1 b1_0; + Nocycle_a_00110_B2 b2_0; + Nocycle_a_00110_B3 b3_0; + Nocycle_a_00110_B4 b4_0; + Nocycle_a_00110_D5 d5_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + d5_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a + d5_0.a; + } +} + +class Nocycle_a_00110_B1 { + Nocycle_a_00110_D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + d1_0.a; + } +} + + +class Nocycle_a_00110_B2 { + Nocycle_a_00110_C2 c2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_B2(String strObjectName) { + c2_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + c2_0.a; + } +} + + +class Nocycle_a_00110_B3 { + Nocycle_a_00110_C1 c1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } +} + + +class Nocycle_a_00110_B4 { + Nocycle_a_00110_C3 c3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_B4(String strObjectName) { + c3_0 = null; + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + + void add() { + sum = a + c3_0.a; + } +} + + +class Nocycle_a_00110_C1 { + Nocycle_a_00110_D2 d2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_C1(String strObjectName) { + d2_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + d2_0.a; + } +} + +class Nocycle_a_00110_C2 { + Nocycle_a_00110_D3 d3_0; + Nocycle_a_00110_D4 d4_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_C2(String strObjectName) { + d3_0 = null; + d4_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + d3_0.a + d4_0.a; + } +} + +class Nocycle_a_00110_C3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + + +class Nocycle_a_00110_D1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00110_D2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00110_D3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00110_D4 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_D4(String strObjectName) { + a = 404; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D4_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00110_D5 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_D5(String strObjectName) { + a = 405; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D5_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +public class Nocycle_a_00110 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Nocycle_a_00110_A1 a1_main = new Nocycle_a_00110_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00110_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00110_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00110_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00110_B4("b4_0"); + a1_main.b1_0.d1_0 = new Nocycle_a_00110_D1("d1_0"); + a1_main.b2_0.c2_0 = new Nocycle_a_00110_C2("c2_0"); + a1_main.b3_0.c1_0 = new Nocycle_a_00110_C1("c1_0"); + a1_main.b4_0.c3_0 = new Nocycle_a_00110_C3("c3_0"); + a1_main.b3_0.c1_0.d2_0 = new Nocycle_a_00110_D2("d2_0"); + a1_main.b2_0.c2_0.d3_0 = new Nocycle_a_00110_D3("d3_0"); + a1_main.b2_0.c2_0.d4_0 = new Nocycle_a_00110_D4("d4_0"); + a1_main.d5_0 = new Nocycle_a_00110_D5("d5_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b2_0.c2_0.add(); + a1_main.b3_0.c1_0.add(); + a1_main.b4_0.c3_0.add(); + a1_main.b1_0.d1_0.add(); + a1_main.b3_0.c1_0.d2_0.add(); + a1_main.b2_0.c2_0.d3_0.add(); + a1_main.b2_0.c2_0.d4_0.add(); + a1_main.d5_0.add(); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b2_0.c2_0.sum + a1_main.b3_0.c1_0.sum + a1_main.b4_0.c3_0.sum + a1_main.b1_0.d1_0.sum + a1_main.b3_0.c1_0.d2_0.sum + a1_main.b2_0.c2_0.d3_0.sum + a1_main.b2_0.c2_0.d4_0.sum + a1_main.d5_0.sum; + if (result == 9881) + System.out.println("ExpectResult"); + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0093-rc-function-Nocycle_a_00120/Nocycle_a_00120.java b/test/testsuite/ouroboros/rc_test/RC0093-rc-function-Nocycle_a_00120/Nocycle_a_00120.java new file mode 100644 index 0000000000000000000000000000000000000000..b2f040cc15f4c761a6f211ef2518146cce7bffb9 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0093-rc-function-Nocycle_a_00120/Nocycle_a_00120.java @@ -0,0 +1,91 @@ +/* + * -@TestCaseID:maple/runtime/rc/function/Nocycle_a_00120.java + * -@TestCaseName:MyselfClassName + * -@RequirementID:SR-10620538 + * -@RequirementName:[运行时需求]支持自动内存管理 + * -@Title/Destination: Nocycle_a_00120 in RC测试-No-Cycle-00.vsd. + * -@Condition: no + * -#c1 + * -@Brief:functionTest + * -#step1 + * -@Expect:ExpectResult\n + * -@Priority: High + * -@Source: Nocycle_a_00120.java + * -@ExecuteClass: Nocycle_a_00120 + * -@ExecuteArgs: + * -@Remark: + */ +class Nocycle_a_00120_A1 { + Nocycle_a_00120_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00120_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + b1_0.a; + } +} + +class Nocycle_a_00120_A2 { + Nocycle_a_00120_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00120_A2(String strObjectName) { + b1_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + b1_0.a; + } +} + +class Nocycle_a_00120_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00120_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a; + } +} + +public class Nocycle_a_00120 { + + public static void main(String[] args) { + Nocycle_a_00120_A1 a1_main = new Nocycle_a_00120_A1("a1_main"); + Nocycle_a_00120_A2 a2_main = new Nocycle_a_00120_A2("a2_main"); + a1_main.b1_0 = new Nocycle_a_00120_B1("b1_0"); + a2_main.b1_0 = new Nocycle_a_00120_B1("b1_0"); + a1_main.add(); + a2_main.add(); + a1_main.b1_0.add(); + a2_main.b1_0.add(); + + int result = a1_main.sum + a2_main.sum + a1_main.b1_0.sum; + if (result == 1007) { + System.out.println("ExpectResult"); + } + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0094-rc-function-Nocycle_a_00130/Nocycle_a_00130.java b/test/testsuite/ouroboros/rc_test/RC0094-rc-function-Nocycle_a_00130/Nocycle_a_00130.java new file mode 100755 index 0000000000000000000000000000000000000000..dd90174a3c0fe08d3bfc57ff23a4152305808e87 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0094-rc-function-Nocycle_a_00130/Nocycle_a_00130.java @@ -0,0 +1,290 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Nocycle_a_00130.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_a_00130 in RC测试-No-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_a_00130.java + *- @ExecuteClass: Nocycle_a_00130 + *- @ExecuteArgs: + *- @Remark: + */ +class Nocycle_a_00130_A1 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } +} + +class Nocycle_a_00130_A2 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A2(String strObjectName) { + b1_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } +} + + +class Nocycle_a_00130_A3 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A3(String strObjectName) { + b1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } +} + +class Nocycle_a_00130_A4 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A4(String strObjectName) { + b1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } +} + +class Nocycle_a_00130_A5 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A5(String strObjectName) { + b1_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } +} + + +class Nocycle_a_00130_A6 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A6(String strObjectName) { + b1_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } +} + +class Nocycle_a_00130_A7 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A7(String strObjectName) { + b1_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } +} + +class Nocycle_a_00130_A8 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A8(String strObjectName) { + b1_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } +} + +class Nocycle_a_00130_A9 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A9(String strObjectName) { + b1_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } +} + +class Nocycle_a_00130_A10 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A10(String strObjectName) { + b1_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } +} + + +class Nocycle_a_00130_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + + +public class Nocycle_a_00130 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Nocycle_a_00130_A1 a1_main = new Nocycle_a_00130_A1("a1_main"); + Nocycle_a_00130_A2 a2_main = new Nocycle_a_00130_A2("a2_main"); + Nocycle_a_00130_A3 a3_main = new Nocycle_a_00130_A3("a3_main"); + Nocycle_a_00130_A4 a4_main = new Nocycle_a_00130_A4("a4_main"); + Nocycle_a_00130_A5 a5_main = new Nocycle_a_00130_A5("a5_main"); + Nocycle_a_00130_A6 a6_main = new Nocycle_a_00130_A6("a6_main"); + Nocycle_a_00130_A7 a7_main = new Nocycle_a_00130_A7("a7_main"); + Nocycle_a_00130_A8 a8_main = new Nocycle_a_00130_A8("a8_main"); + Nocycle_a_00130_A9 a9_main = new Nocycle_a_00130_A9("a9_main"); + Nocycle_a_00130_A10 a10_main = new Nocycle_a_00130_A10("a10_main"); + a1_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a2_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a3_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a4_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a5_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a6_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a7_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a8_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a9_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a10_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a5_main.add(); + a6_main.add(); + a7_main.add(); + a8_main.add(); + a9_main.add(); + a10_main.add(); + a1_main.b1_0.add(); + a2_main.b1_0.add(); + a3_main.b1_0.add(); + a4_main.b1_0.add(); + a5_main.b1_0.add(); + a6_main.b1_0.add(); + a7_main.b1_0.add(); + a8_main.b1_0.add(); + a9_main.b1_0.add(); + a10_main.b1_0.add(); + + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a5_main.sum + a6_main.sum + a7_main.sum + a8_main.sum + a9_main.sum + a10_main.sum + a1_main.b1_0.sum; + + if (result == 3467) + System.out.println("ExpectResult"); + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0095-rc-function-Nocycle_a_00140/Nocycle_a_00140.java b/test/testsuite/ouroboros/rc_test/RC0095-rc-function-Nocycle_a_00140/Nocycle_a_00140.java new file mode 100755 index 0000000000000000000000000000000000000000..6a4997560280c56ad7721e024b442fad88799c59 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0095-rc-function-Nocycle_a_00140/Nocycle_a_00140.java @@ -0,0 +1,123 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Nocycle_a_00140.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_a_00140 in RC测试-No-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_a_00140.java + *- @ExecuteClass: Nocycle_a_00140 + *- @ExecuteArgs: + *- @Remark: + */ +class Nocycle_a_00140_A1 { + Nocycle_a_00140_B1 b1_0; + Nocycle_a_00140_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00140_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } +} + +class Nocycle_a_00140_A2 { + Nocycle_a_00140_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00140_A2(String strObjectName) { + b1_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } +} + + +class Nocycle_a_00140_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00140_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00140_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00140_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +public class Nocycle_a_00140 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Nocycle_a_00140_A1 a1_main = new Nocycle_a_00140_A1("a1_main"); + Nocycle_a_00140_A2 a2_main = new Nocycle_a_00140_A2("a2_main"); + a1_main.b1_0 = new Nocycle_a_00140_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00140_B2("b2_0"); + a2_main.b1_0 = new Nocycle_a_00140_B1("b1_0"); + a1_main.add(); + a2_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a2_main.b1_0.add(); + + int result = a1_main.sum + a2_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + if (result == 1613) + System.out.println("ExpectResult"); + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0096-rc-function-Nocycle_a_00150/Nocycle_a_00150.java b/test/testsuite/ouroboros/rc_test/RC0096-rc-function-Nocycle_a_00150/Nocycle_a_00150.java new file mode 100755 index 0000000000000000000000000000000000000000..2cc706ac4241003cf61216a0fdbf067eb835db8a --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0096-rc-function-Nocycle_a_00150/Nocycle_a_00150.java @@ -0,0 +1,126 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Nocycle_a_00150.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_a_00150 in RC测试-No-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_a_00150.java + *- @ExecuteClass: Nocycle_a_00150 + *- @ExecuteArgs: + *- @Remark: + */ +class Nocycle_a_00150_A1 { + Nocycle_a_00150_B1 b1_0; + Nocycle_a_00150_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00150_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } +} + +class Nocycle_a_00150_A2 { + Nocycle_a_00150_B1 b1_0; + Nocycle_a_00150_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00150_A2(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } +} + + +class Nocycle_a_00150_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00150_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00150_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00150_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +public class Nocycle_a_00150 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Nocycle_a_00150_A1 a1_main = new Nocycle_a_00150_A1("a1_main"); + Nocycle_a_00150_A2 a2_main = new Nocycle_a_00150_A2("a2_main"); + a1_main.b1_0 = new Nocycle_a_00150_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00150_B2("b2_0"); + a2_main.b1_0 = new Nocycle_a_00150_B1("b1_0"); + a2_main.b2_0 = new Nocycle_a_00150_B2("b2_0"); + a1_main.add(); + a2_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a2_main.b1_0.add(); + a2_main.b2_0.add(); + int result = a1_main.sum + a2_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + if (result == 1815) + System.out.println("ExpectResult"); + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0097-rc-function-Nocycle_a_00160/Nocycle_a_00160.java b/test/testsuite/ouroboros/rc_test/RC0097-rc-function-Nocycle_a_00160/Nocycle_a_00160.java new file mode 100755 index 0000000000000000000000000000000000000000..51244a47228af9cbf8d87610881886b98232c8dd --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0097-rc-function-Nocycle_a_00160/Nocycle_a_00160.java @@ -0,0 +1,183 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Nocycle_a_00160.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_a_00160 in RC测试-No-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_a_00160.java + *- @ExecuteClass: Nocycle_a_00160 + *- @ExecuteArgs: + *- @Remark: + */ +class Nocycle_a_00160_A1 { + Nocycle_a_00160_B1 b1_0; + Nocycle_a_00160_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00160_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } +} + +class Nocycle_a_00160_A2 { + Nocycle_a_00160_B1 b1_0; + Nocycle_a_00160_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00160_A2(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } +} + + +class Nocycle_a_00160_A3 { + Nocycle_a_00160_B1 b1_0; + Nocycle_a_00160_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00160_A3(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } +} + +class Nocycle_a_00160_A4 { + Nocycle_a_00160_B1 b1_0; + Nocycle_a_00160_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00160_A4(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } +} + + +class Nocycle_a_00160_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00160_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00160_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00160_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +public class Nocycle_a_00160 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Nocycle_a_00160_A1 a1_main = new Nocycle_a_00160_A1("a1_main"); + Nocycle_a_00160_A2 a2_main = new Nocycle_a_00160_A2("a2_main"); + Nocycle_a_00160_A3 a3_main = new Nocycle_a_00160_A3("a3_main"); + Nocycle_a_00160_A4 a4_main = new Nocycle_a_00160_A4("a4_main"); + a1_main.b1_0 = new Nocycle_a_00160_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00160_B2("b2_0"); + a2_main.b1_0 = new Nocycle_a_00160_B1("b1_0"); + a2_main.b2_0 = new Nocycle_a_00160_B2("b2_0"); + a3_main.b1_0 = new Nocycle_a_00160_B1("b1_0"); + a3_main.b2_0 = new Nocycle_a_00160_B2("b2_0"); + a4_main.b1_0 = new Nocycle_a_00160_B1("b1_0"); + a4_main.b2_0 = new Nocycle_a_00160_B2("b2_0"); + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a2_main.b1_0.add(); + a2_main.b2_0.add(); + a3_main.b1_0.add(); + a3_main.b2_0.add(); + a4_main.b1_0.add(); + a4_main.b2_0.add(); + + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + + if (result == 2828) + System.out.println("ExpectResult"); + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0098-rc-function-Nocycle_a_00170/Nocycle_a_00170.java b/test/testsuite/ouroboros/rc_test/RC0098-rc-function-Nocycle_a_00170/Nocycle_a_00170.java new file mode 100755 index 0000000000000000000000000000000000000000..d6f5b953ae230f5244e9c2af176dc8d09b42323e --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0098-rc-function-Nocycle_a_00170/Nocycle_a_00170.java @@ -0,0 +1,215 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Nocycle_a_00170.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_a_00170 in RC测试-No-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_a_00170.java + *- @ExecuteClass: Nocycle_a_00170 + *- @ExecuteArgs: + *- @Remark: + */ +class Nocycle_a_00170_A1 { + Nocycle_a_00170_B1 b1_0; + Nocycle_a_00170_B2 b2_0; + Nocycle_a_00170_B3 b3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00170_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } +} + +class Nocycle_a_00170_A2 { + Nocycle_a_00170_B1 b1_0; + Nocycle_a_00170_B2 b2_0; + Nocycle_a_00170_B3 b3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00170_A2(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } +} + + +class Nocycle_a_00170_A3 { + Nocycle_a_00170_B1 b1_0; + Nocycle_a_00170_B2 b2_0; + Nocycle_a_00170_B3 b3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00170_A3(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } +} + +class Nocycle_a_00170_A4 { + Nocycle_a_00170_B1 b1_0; + Nocycle_a_00170_B2 b2_0; + Nocycle_a_00170_B3 b3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00170_A4(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } +} + + +class Nocycle_a_00170_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00170_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00170_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00170_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00170_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00170_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +public class Nocycle_a_00170 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + + } + + private static void rc_testcase_main_wrapper() { + Nocycle_a_00170_A1 a1_main = new Nocycle_a_00170_A1("a1_main"); + Nocycle_a_00170_A2 a2_main = new Nocycle_a_00170_A2("a2_main"); + Nocycle_a_00170_A3 a3_main = new Nocycle_a_00170_A3("a3_main"); + Nocycle_a_00170_A4 a4_main = new Nocycle_a_00170_A4("a4_main"); + a1_main.b1_0 = new Nocycle_a_00170_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00170_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00170_B3("b3_0"); + a2_main.b1_0 = new Nocycle_a_00170_B1("b1_0"); + a2_main.b2_0 = new Nocycle_a_00170_B2("b2_0"); + a2_main.b3_0 = new Nocycle_a_00170_B3("b3_0"); + a3_main.b1_0 = new Nocycle_a_00170_B1("b1_0"); + a3_main.b2_0 = new Nocycle_a_00170_B2("b2_0"); + a3_main.b3_0 = new Nocycle_a_00170_B3("b3_0"); + a4_main.b1_0 = new Nocycle_a_00170_B1("b1_0"); + a4_main.b2_0 = new Nocycle_a_00170_B2("b2_0"); + a4_main.b3_0 = new Nocycle_a_00170_B3("b3_0"); + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a2_main.b1_0.add(); + a2_main.b2_0.add(); + a2_main.b3_0.add(); + a3_main.b1_0.add(); + a3_main.b2_0.add(); + a3_main.b3_0.add(); + a4_main.b1_0.add(); + a4_main.b2_0.add(); + a4_main.b3_0.add(); + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum; + if (result == 4046) + System.out.println("ExpectResult"); + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0099-rc-function-Nocycle_a_00180/Nocycle_a_00180.java b/test/testsuite/ouroboros/rc_test/RC0099-rc-function-Nocycle_a_00180/Nocycle_a_00180.java new file mode 100755 index 0000000000000000000000000000000000000000..a1e203f074a352da31aabdacde58ac3f015cf295 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0099-rc-function-Nocycle_a_00180/Nocycle_a_00180.java @@ -0,0 +1,348 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Nocycle_a_00180.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_a_00180 in RC测试-No-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_a_00180.java + *- @ExecuteClass: Nocycle_a_00180 + *- @ExecuteArgs: + *- @Remark: + */ +class Nocycle_a_00180_A1 { + Nocycle_a_00180_B1 b1_0; + Nocycle_a_00180_D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + d1_0.a; + } +} + + +class Nocycle_a_00180_A2 { + Nocycle_a_00180_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b2_0.a; + } +} + + +class Nocycle_a_00180_A3 { + Nocycle_a_00180_B2 b2_0; + Nocycle_a_00180_C2 c2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + b2_0.a + c2_0.a; + } +} + +class Nocycle_a_00180_A4 { + Nocycle_a_00180_B3 b3_0; + Nocycle_a_00180_C2 c2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + b3_0.a + c2_0.a; + } +} + + +class Nocycle_a_00180_B1 { + Nocycle_a_00180_D2 d2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + d2_0.a; + } +} + + +class Nocycle_a_00180_B2 { + Nocycle_a_00180_C1 c1_0; + Nocycle_a_00180_D1 d1_0; + Nocycle_a_00180_D2 d2_0; + Nocycle_a_00180_D3 d3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } +} + + +class Nocycle_a_00180_B3 { + Nocycle_a_00180_C1 c1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } +} + + +class Nocycle_a_00180_C1 { + Nocycle_a_00180_D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + d1_0.a; + } +} + +class Nocycle_a_00180_C2 { + Nocycle_a_00180_D2 d2_0; + Nocycle_a_00180_D3 d3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + d2_0.a + d3_0.a; + } +} + + +class Nocycle_a_00180_D1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00180_D2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00180_D3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + + +public class Nocycle_a_00180 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + + } + + private static void rc_testcase_main_wrapper() { + Nocycle_a_00180_A1 a1_main = new Nocycle_a_00180_A1("a1_main"); + Nocycle_a_00180_A2 a2_main = new Nocycle_a_00180_A2("a2_main"); + Nocycle_a_00180_A3 a3_main = new Nocycle_a_00180_A3("a3_main"); + Nocycle_a_00180_A4 a4_main = new Nocycle_a_00180_A4("a4_main"); + a1_main.b1_0 = new Nocycle_a_00180_B1("b1_0"); + a1_main.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a1_main.b1_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + + a2_main.b2_0 = new Nocycle_a_00180_B2("b2_0"); + a2_main.b2_0.c1_0 = new Nocycle_a_00180_C1("c1_0"); + a2_main.b2_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a2_main.b2_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a2_main.b2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + + a3_main.b2_0 = new Nocycle_a_00180_B2("b2_0"); + a3_main.b2_0.c1_0 = new Nocycle_a_00180_C1("c1_0"); + a3_main.b2_0.c1_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a3_main.b2_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a3_main.b2_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a3_main.b2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + + a3_main.c2_0 = new Nocycle_a_00180_C2("c2_0"); + a3_main.c2_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a3_main.c2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + + a4_main.b3_0 = new Nocycle_a_00180_B3("b3_0"); + a4_main.b3_0.c1_0 = new Nocycle_a_00180_C1("c1_0"); + a4_main.b3_0.c1_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a4_main.c2_0 = new Nocycle_a_00180_C2("c2_0"); + a4_main.c2_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a4_main.c2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main.b1_0.add(); + a1_main.d1_0.add(); + a1_main.b1_0.d2_0.add(); + + a2_main.b2_0.add(); + a2_main.b2_0.c1_0.add(); + a2_main.b2_0.d1_0.add(); + a2_main.b2_0.d2_0.add(); + a2_main.b2_0.d3_0.add(); + a2_main.b2_0.c1_0.d1_0.add(); + + a3_main.b2_0.add(); + a3_main.b2_0.c1_0.add(); + a3_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.d1_0.add(); + a3_main.b2_0.d2_0.add(); + a3_main.b2_0.d3_0.add(); + + a3_main.c2_0.add(); + a3_main.c2_0.d2_0.add(); + a3_main.c2_0.d3_0.add(); + + a4_main.b3_0.add(); + a4_main.b3_0.c1_0.add(); + a4_main.b3_0.c1_0.d1_0.add(); + a4_main.c2_0.add(); + a4_main.c2_0.d2_0.add(); + a4_main.c2_0.d3_0.add(); + + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main.b1_0.sum + a2_main.b2_0.sum + a4_main.b3_0.sum + a2_main.b2_0.c1_0.sum + a3_main.c2_0.sum + a1_main.d1_0.sum + a3_main.c2_0.d2_0.sum + a3_main.c2_0.d3_0.sum; + if (result == 9260) + System.out.println("ExpectResult"); + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0100-rc-function-Nocycle_a_2_00010/Nocycle_a_2_00010.java b/test/testsuite/ouroboros/rc_test/RC0100-rc-function-Nocycle_a_2_00010/Nocycle_a_2_00010.java new file mode 100755 index 0000000000000000000000000000000000000000..49937620a386086e8b481be03298a4861b191edd --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0100-rc-function-Nocycle_a_2_00010/Nocycle_a_2_00010.java @@ -0,0 +1,136 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Nocycle_a_2_00010.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_a_2_00010 in RC测试-No-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_a_2_00010.java + *- @ExecuteClass: Nocycle_a_2_00010 + *- @ExecuteArgs: + *- @Remark: + */ +class Nocycle_a_2_00010_A1 { + Nocycle_a_2_00010_B1 b1_0; + Nocycle_a_2_00010_B2 b2_0; + Nocycle_a_2_00010_B3 b3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00010_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } +} + +class Nocycle_a_2_00010_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00010_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_2_00010_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00010_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_2_00010_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00010_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_2_00010_A2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00010_A2(String strObjectName) { + a = 10; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +public class Nocycle_a_2_00010 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Nocycle_a_2_00010_A1 a1_main = new Nocycle_a_2_00010_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_2_00010_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_2_00010_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_2_00010_B3("b3_0"); + Nocycle_a_2_00010_A2 a2_main = new Nocycle_a_2_00010_A2("a2_main"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a2_main.add(); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a2_main.sum; + if (result == 1939) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0101-rc-function-Nocycle_a_2_00020/Nocycle_a_2_00020.java b/test/testsuite/ouroboros/rc_test/RC0101-rc-function-Nocycle_a_2_00020/Nocycle_a_2_00020.java new file mode 100755 index 0000000000000000000000000000000000000000..c700ed1433ccd7fce5dcec4065411bf00e6a0e3d --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0101-rc-function-Nocycle_a_2_00020/Nocycle_a_2_00020.java @@ -0,0 +1,726 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Nocycle_a_2_00020.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_a_2_00020 in RC测试-No-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_a_2_00020.java + *- @ExecuteClass: Nocycle_a_2_00020 + *- @ExecuteArgs: + *- @Remark: + */ +class Nocycle_a_2_00020_A1 { + Nocycle_a_2_00020_B1 b1_0; + Nocycle_a_2_00020_B2 b2_0; + Nocycle_a_2_00020_B3 b3_0; + Nocycle_a_2_00020_B4 b4_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } +} + +class Nocycle_a_2_00020_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + + +class Nocycle_a_2_00020_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + + +class Nocycle_a_2_00020_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + + +class Nocycle_a_2_00020_B4 { + Nocycle_a_2_00020_C1 c1_0; + Nocycle_a_2_00020_C2 c2_0; + Nocycle_a_2_00020_C3 c3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_B4(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } +} + + +class Nocycle_a_2_00020_C1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_2_00020_C2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_2_00020_C3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_2_00020_2A1 { + Nocycle_a_2_00020_2B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } +} + +class Nocycle_a_2_00020_2B1 { + Nocycle_a_2_00020_2C1 c1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2B1(String strObjectName) { + c1_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } +} + + +class Nocycle_a_2_00020_2C1 { + Nocycle_a_2_00020_2D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + d1_0.a; + } +} + +class Nocycle_a_2_00020_2D1 { + Nocycle_a_2_00020_2E1 e1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2D1(String strObjectName) { + e1_0 = null; + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + + void add() { + sum = a + e1_0.a; + } +} + +class Nocycle_a_2_00020_2E1 { + Nocycle_a_2_00020_2F1 f1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2E1(String strObjectName) { + f1_0 = null; + a = 501; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_E1_"+strObjectName); + } + + void add() { + sum = a + f1_0.a; + } +} + + +class Nocycle_a_2_00020_2F1 { + Nocycle_a_2_00020_2G1 g1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2F1(String strObjectName) { + g1_0 = null; + a = 601; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_F1_"+strObjectName); + } + + void add() { + sum = a + g1_0.a; + } +} + +class Nocycle_a_2_00020_2G1 { + Nocycle_a_2_00020_2H1 h1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2G1(String strObjectName) { + h1_0 = null; + a = 701; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_G1_"+strObjectName); + } + + void add() { + sum = a + h1_0.a; + } +} + + +class Nocycle_a_2_00020_2H1 { + Nocycle_a_2_00020_2I1 i1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2H1(String strObjectName) { + i1_0 = null; + a = 801; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_H1_"+strObjectName); + } + + void add() { + sum = a + i1_0.a; + } +} + + +class Nocycle_a_2_00020_2I1 { + Nocycle_a_2_00020_2J1 j1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2I1(String strObjectName) { + j1_0 = null; + a = 901; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_I1_"+strObjectName); + } + + void add() { + sum = a + j1_0.a; + } +} + +class Nocycle_a_2_00020_2J1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2J1(String strObjectName) { + a = 1001; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_J1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_2_00020_3A1 { + Nocycle_a_2_00020_3B1 b1_0; + Nocycle_a_2_00020_3D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + d1_0.a; + } +} + + +class Nocycle_a_2_00020_3A2 { + Nocycle_a_2_00020_3B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b2_0.a; + } +} + + +class Nocycle_a_2_00020_3A3 { + Nocycle_a_2_00020_3B2 b2_0; + Nocycle_a_2_00020_3C2 c2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + b2_0.a + c2_0.a; + } +} + +class Nocycle_a_2_00020_3A4 { + Nocycle_a_2_00020_3B3 b3_0; + Nocycle_a_2_00020_3C2 c2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + b3_0.a + c2_0.a; + } +} + + +class Nocycle_a_2_00020_3B1 { + Nocycle_a_2_00020_3D2 d2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + d2_0.a; + } +} + + +class Nocycle_a_2_00020_3B2 { + Nocycle_a_2_00020_3C1 c1_0; + Nocycle_a_2_00020_3D1 d1_0; + Nocycle_a_2_00020_3D2 d2_0; + Nocycle_a_2_00020_3D3 d3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } +} + + +class Nocycle_a_2_00020_3B3 { + Nocycle_a_2_00020_3C1 c1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } +} + + +class Nocycle_a_2_00020_3C1 { + Nocycle_a_2_00020_3D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + d1_0.a; + } +} + +class Nocycle_a_2_00020_3C2 { + Nocycle_a_2_00020_3D2 d2_0; + Nocycle_a_2_00020_3D3 d3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + d2_0.a + d3_0.a; + } +} + + +class Nocycle_a_2_00020_3D1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_2_00020_3D2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_2_00020_3D3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +public class Nocycle_a_2_00020 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Nocycle_a_2_00020_A1 a1_main = new Nocycle_a_2_00020_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_2_00020_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_2_00020_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_2_00020_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_2_00020_B4("b4_0"); + a1_main.b4_0.c1_0 = new Nocycle_a_2_00020_C1("c1_0"); + a1_main.b4_0.c2_0 = new Nocycle_a_2_00020_C2("c2_0"); + a1_main.b4_0.c3_0 = new Nocycle_a_2_00020_C3("c3_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b4_0.c1_0.add(); + a1_main.b4_0.c2_0.add(); + a1_main.b4_0.c3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b4_0.c1_0.sum+a1_main.b4_0.c2_0.sum+a1_main.b4_0.c3_0.sum); + + int result1 = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b4_0.c1_0.sum + a1_main.b4_0.c2_0.sum + a1_main.b4_0.c3_0.sum; + //System.out.println("RC-Testing_Result="+result1); + Nocycle_a_2_00020_2A1 a1_main2 = new Nocycle_a_2_00020_2A1("a1_main2"); + a1_main2.b1_0 = new Nocycle_a_2_00020_2B1("b1_0"); + a1_main2.b1_0.c1_0 = new Nocycle_a_2_00020_2C1("c1_0"); + a1_main2.b1_0.c1_0.d1_0 = new Nocycle_a_2_00020_2D1("d1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0 = new Nocycle_a_2_00020_2E1("e1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0 = new Nocycle_a_2_00020_2F1("f1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0 = new Nocycle_a_2_00020_2G1("g1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0 = new Nocycle_a_2_00020_2H1("h1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0 = new Nocycle_a_2_00020_2I1("i1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0 = new Nocycle_a_2_00020_2J1("j1_0"); + a1_main2.add(); + a1_main2.b1_0.add(); + a1_main2.b1_0.c1_0.add(); + a1_main2.b1_0.c1_0.d1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.add(); + + int result2 = a1_main2.sum + a1_main2.b1_0.sum + a1_main2.b1_0.c1_0.sum + a1_main2.b1_0.c1_0.d1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.sum; + Nocycle_a_2_00020_3A1 a1_main3 = new Nocycle_a_2_00020_3A1("a1_main3"); + Nocycle_a_2_00020_3A2 a2_main = new Nocycle_a_2_00020_3A2("a2_main"); + Nocycle_a_2_00020_3A3 a3_main = new Nocycle_a_2_00020_3A3("a3_main"); + Nocycle_a_2_00020_3A4 a4_main = new Nocycle_a_2_00020_3A4("a4_main"); + a1_main3.b1_0 = new Nocycle_a_2_00020_3B1("b1_0"); + a1_main3.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a1_main3.b1_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a2_main.b2_0 = new Nocycle_a_2_00020_3B2("b2_0"); + a2_main.b2_0.c1_0 = new Nocycle_a_2_00020_3C1("c1_0"); + a2_main.b2_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a2_main.b2_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a2_main.b2_0.d3_0 = new Nocycle_a_2_00020_3D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a3_main.b2_0 = new Nocycle_a_2_00020_3B2("b2_0"); + a3_main.b2_0.c1_0 = new Nocycle_a_2_00020_3C1("c1_0"); + a3_main.b2_0.c1_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a3_main.b2_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a3_main.b2_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a3_main.b2_0.d3_0 = new Nocycle_a_2_00020_3D3("d3_0"); + a3_main.c2_0 = new Nocycle_a_2_00020_3C2("c2_0"); + a3_main.c2_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a3_main.c2_0.d3_0 = new Nocycle_a_2_00020_3D3("d3_0"); + a4_main.b3_0 = new Nocycle_a_2_00020_3B3("b3_0"); + a4_main.b3_0.c1_0 = new Nocycle_a_2_00020_3C1("c1_0"); + a4_main.b3_0.c1_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a4_main.c2_0 = new Nocycle_a_2_00020_3C2("c2_0"); + a4_main.c2_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a4_main.c2_0.d3_0 = new Nocycle_a_2_00020_3D3("d3_0"); + a1_main3.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main3.b1_0.add(); + a1_main3.d1_0.add(); + a1_main3.b1_0.d2_0.add(); + a2_main.b2_0.add(); + a2_main.b2_0.c1_0.add(); + a2_main.b2_0.d1_0.add(); + a2_main.b2_0.d2_0.add(); + a2_main.b2_0.d3_0.add(); + a2_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.add(); + a3_main.b2_0.c1_0.add(); + a3_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.d1_0.add(); + a3_main.b2_0.d2_0.add(); + a3_main.b2_0.d3_0.add(); + a3_main.c2_0.add(); + a3_main.c2_0.d2_0.add(); + a3_main.c2_0.d3_0.add(); + a4_main.b3_0.add(); + a4_main.b3_0.c1_0.add(); + a4_main.b3_0.c1_0.d1_0.add(); + a4_main.c2_0.add(); + a4_main.c2_0.d2_0.add(); + a4_main.c2_0.d3_0.add(); + int result3 = a1_main3.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main3.b1_0.sum + a2_main.b2_0.sum + a4_main.b3_0.sum + a2_main.b2_0.c1_0.sum + a3_main.c2_0.sum + a1_main3.d1_0.sum + a3_main.c2_0.d2_0.sum + a3_main.c2_0.d3_0.sum; + + int result = result1 + result2 + result3; + if (result == 26225) + System.out.println("ExpectResult"); + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0102-rc-function-RC_basic/RC_basic.java b/test/testsuite/ouroboros/rc_test/RC0102-rc-function-RC_basic/RC_basic.java new file mode 100755 index 0000000000000000000000000000000000000000..9ba3364582dfd70a21212e886879e5f5fd8e2d25 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0102-rc-function-RC_basic/RC_basic.java @@ -0,0 +1,112 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_basic.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: test RC basic operation. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_basic.java + *- @ExecuteClass: RC_basic + *- @ExecuteArgs: + *- @Remark: + */ +public class RC_basic { + private Object obj; + private String[] str; + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + + public static void rc_testcase_main_wrapper() { + RC_basic rc = new RC_basic(); + rc.obj = new Object(); + rc.str = new String[10]; + Test1(); + Test2(); + Test3(); + Test4(rc); + Test5(rc); + Test6(rc); + Test7(rc); + Test8(); + Test9(); + Test10(); + } + + // simple new and recycle + static void Test1() { + RC_basic obj = new RC_basic(); + consume(obj); + } + + // new and return + static RC_basic Test2() { + RC_basic obj = new RC_basic(); + return obj; + } + + // new and consume and return + static Object Test3() { + RC_basic obj = new RC_basic(); + consume(obj); + return obj; + } + + // load and dec + static void Test4(RC_basic rc) { + Object obj = rc.obj; + consume(obj); + } + + // load and dec + static void Test5(RC_basic rc) { + consume(rc.obj); + } + + // load and return + static Object Test6(RC_basic rc) { + return rc.obj; + } + + // load consume and return + static Object Test7(RC_basic rc) { + Object o = rc.str; + consume(o); + return o; + } + + + // call and consume + static void Test8() { + RC_basic obj = Test2(); + consume(obj); + } + + // call consume and return + static Object Test9() { + RC_basic obj = Test2(); + consume(obj); + return obj; + } + + // call and not consume + static void Test10() { + Test2(); + } + + public static void consume(Object obj) { + //System.out.println("do noting"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0103-rc-function-RC_eh_01/RC_eh_01.java b/test/testsuite/ouroboros/rc_test/RC0103-rc-function-RC_eh_01/RC_eh_01.java new file mode 100755 index 0000000000000000000000000000000000000000..2298c7af4f3d8ef46cf9c1c077e7b0dcc81a2c50 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0103-rc-function-RC_eh_01/RC_eh_01.java @@ -0,0 +1,65 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_eh_01.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: test eh for RC. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_eh_01.java + *- @ExecuteClass: RC_eh_01 + *- @ExecuteArgs: + *- @Remark: + */ +import java.nio.charset.IllegalCharsetNameException; + +public class RC_eh_01 { + static int res = 0; + + public static void main(String argv[]) { + run1(); + System.out.println("ExpectResult"); + } + + public static void run1() { + + try { + new RC_eh_01().run2(); + } catch (IllegalArgumentException e) { + RC_eh_01.res = 1; + + } + + } + + public void run2() { + Foo f1 = new Foo(1); + Foo f2 = new Foo(2); + run3(); + int result=f1.i+f2.i; + + } + + public static void run3() { + try { + Integer.parseInt("123#456"); + } catch (IllegalCharsetNameException e) { + RC_eh_01.res = 3; + + } + } + + class Foo{ + public int i; + public Foo(int i){ + this.i=i; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0104-rc-function-RC_Finalize_01/RC_Finalize_01.java b/test/testsuite/ouroboros/rc_test/RC0104-rc-function-RC_Finalize_01/RC_Finalize_01.java new file mode 100755 index 0000000000000000000000000000000000000000..a98110ecbf514ff4d4a0709d312c0c7462c30a08 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0104-rc-function-RC_Finalize_01/RC_Finalize_01.java @@ -0,0 +1,78 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Finalize_01.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: test Finalizer for RC . + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Finalize_01.java + *- @ExecuteClass: RC_Finalize_01 + *- @ExecuteArgs: + *- @Remark: + */ +class C { + static A a; +} + +class A { + B b; + + public A(B b) { + + this.b = b; + + } + + @Override + public void finalize() throws Throwable { + super.finalize(); +// System.out.println("A finalize"); + + C.a = this; + + } + +} + + +class B { + int num1; + int num2; + + public B(int num1, int num2) { + this.num1 = num1; + this.num2 = num2; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); +// System.out.println("B finalize"); + } + + public int sum() { + return num1 + num2; + } + +} + +public class RC_Finalize_01 { + + public static void main(String[] args) throws Exception { + A a = new A(new B(12, 18)); + a = null; + //System.gc(); + + Thread.sleep(5000); + System.out.println("ExpectResult"); +} +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0105-rc-function-RC_flow/RC_flow.java b/test/testsuite/ouroboros/rc_test/RC0105-rc-function-RC_flow/RC_flow.java new file mode 100755 index 0000000000000000000000000000000000000000..f5389eb040d1db4b43d69e422736f0f8b9b63e6f --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0105-rc-function-RC_flow/RC_flow.java @@ -0,0 +1,72 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_flow.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: test RC basic operation in For flow. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_flow.java + *- @ExecuteClass: RC_flow + *- @ExecuteArgs: + *- @Remark: + */ +public class RC_flow { + private Object obj; + private byte[] b; + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + + public static void rc_testcase_main_wrapper() { + TestFlow1(21); + TestFlow2(30); + TestFlow3(56); + } + + static Object TestFlow1(int num) { + Object rc = null; + for (int i = 1; i < num; i++) { + if ((i % 5) == 0) { + rc = new RC_flow(); + } + } + return rc; + } + + static Object TestFlow2(int num) { + Object rc = null; + for (int i = 1; i < num; i++) { + if ((i % 5) == 0) { + rc = Test2(); + } + } + return rc; + } + + static void TestFlow3(int num) { + Object rc = null; + for (int i = 1; i < num; i++) { + if ((i % 5) == 0) { + rc = Test2(); + } + } + + } + + static RC_flow Test2() { + RC_flow obj = new RC_flow(); + return obj; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0106-rc-function-RC_multest/RC_multest.java b/test/testsuite/ouroboros/rc_test/RC0106-rc-function-RC_multest/RC_multest.java new file mode 100755 index 0000000000000000000000000000000000000000..dba189cb20aa49c158b96f7e3d380361aacff743 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0106-rc-function-RC_multest/RC_multest.java @@ -0,0 +1,206 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_multest.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: test RC basic operation in For flow. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_multest.java + *- @ExecuteClass: RC_multest + *- @ExecuteArgs: + *- @Remark: + */ +public class RC_multest { + static Foo f; + private Object obj; + private byte[] b; + + { + f = new Bar(); + } + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + + private static void rc_testcase_main_wrapper() { + TestSimple(); + TestParam(); + TestFlow(); + f = null; + } + + static void TestSimple() { + RC_multest rc = new RC_multest(); + rc.obj = new Object(); + rc.b = new byte[10]; + Test1(); + Test2(); + Test3(); + Test4(rc); + Test5(rc); + Test6(rc); + Test7(rc); + Test8(); + Test9(); + Test10(); + } + + static void TestParam() { + RC_multest rc = new RC_multest(); + rc.obj = new Object(); + rc.b = new byte[10]; + TestParam1(rc); + TestParam2(rc); + TestParam3(rc); + } + + static void TestFlow() { + TestFlow1(21); + TestFlow2(30); + } + + // simple new and recycle + static void Test1() { + RC_multest obj = new RC_multest(); + consume(obj); + } + + // new and return + static RC_multest Test2() { + RC_multest obj = new RC_multest(); + return obj; + } + + // new and consume and return + static Object Test3() { + RC_multest obj = new RC_multest(); + consume(obj); + return obj; + } + + // load and dec + static void Test4(RC_multest rc) { + Object obj = rc.obj; + consume(obj); + } + + // load and dec + static void Test5(RC_multest rc) { + consume(rc.obj); + } + + // load and return + static Object Test6(RC_multest rc) { + return rc.obj; + } + + // load consume and return + static Object Test7(RC_multest rc) { + Object o = rc.b; + consume(o); + return o; + } + + // call and consume + static void Test8() { + RC_multest obj = Test2(); + consume(obj); + } + + // call consume and return + static Object Test9() { + RC_multest obj = Test2(); + consume(obj); + return obj; + } + + // call and not consume + static void Test10() { + Test2(); + } + + // parameter related + // 1. parameter is returned + // 2. parameter is redefined + // 3. parameter is redefined conditionally + static Object TestParam1(RC_multest rc) { + consume(rc); + return rc; + } + + static Object TestParam2(RC_multest rc) { + consume(rc); + rc = Test2(); + return rc; + } + + static Object TestParam3(RC_multest rc) { + consume(rc); + if (rc.b != null) { + rc = Test2(); + } + return rc; + } + + static Object TestParam4() { + RC_multest rc = new RC_multest(); + consume_return(rc); + return rc; + } + + // object field store + + // local variable + // 1. local varaible is redefined in if/loop + static Object TestFlow1(int num) { + Object rc = null; + for (int i = 1; i < num; i++) { + if ((i % 5) == 0) { + rc = new RC_multest(); + } + } + return rc; + } + + static Object TestFlow2(int num) { + Object rc = null; + for (int i = 1; i < num; i++) { + if ((i % 5) == 0) { + rc = Test2(); + } + } + return rc; + } + + // class info + // exception + static Object consume_return(Object obj) { + return obj; + } + + static void consume(Object obj) { + f.consume(obj); + } +} + +class Foo { + void consume(Object obj) { + } +} + +class Bar extends Foo { + void consume(Object obj) { + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0107-rc-function-RC_Dec-Cycle_aDec_00010/Cycle_aDec_00010.java b/test/testsuite/ouroboros/rc_test/RC0107-rc-function-RC_Dec-Cycle_aDec_00010/Cycle_aDec_00010.java new file mode 100755 index 0000000000000000000000000000000000000000..6fc54172712ee9e87703f58d6e62f11717b538e1 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0107-rc-function-RC_Dec-Cycle_aDec_00010/Cycle_aDec_00010.java @@ -0,0 +1,184 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Dec/ Cycle_aDec_00010.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_aDec_00010 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source:Cycle_aDec_00010.java + *- @ExecuteClass:Cycle_aDec_00010 + *- @ExecuteArgs: + *- @Remark: + * + */ + +class Cycle_aDec_00010_A1 { + Cycle_aDec_00010_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_aDec_00010_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_aDec_00010_A2 { + Cycle_aDec_00010_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_aDec_00010_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_aDec_00010_A3 { + Cycle_aDec_00010_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_aDec_00010_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } +} + + +class Cycle_aDec_00010_A4 { + Cycle_aDec_00010_A1 a1_0; + Cycle_aDec_00010_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_aDec_00010_A4(String strObjectName) { + a1_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a6_0.a; + } +} + +class Cycle_aDec_00010_A5 { + Cycle_aDec_00010_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_aDec_00010_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_aDec_00010_A6 { + Cycle_aDec_00010_A1 a1_0; + Cycle_aDec_00010_A4 a4_0; + Cycle_aDec_00010_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_aDec_00010_A6(String strObjectName) { + a1_0 = null; + a4_0 = null; + a5_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a4_0.a + a5_0.a; + } +} + + +public class Cycle_aDec_00010 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void Modify(Cycle_aDec_00010_A1 a1_main) { + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a1_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); + } + + private static void rc_testcase_main_wrapper() { + Cycle_aDec_00010_A1 a1_main = new Cycle_aDec_00010_A1("a1_main"); + Cycle_aDec_00010_A5 a5_main = new Cycle_aDec_00010_A5("a5_main"); + a1_main.a2_0 = new Cycle_aDec_00010_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_aDec_00010_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_aDec_00010_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0.a6_0 = new Cycle_aDec_00010_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a1_main.a2_0.a3_0.a4_0.a6_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.a2_0.a3_0.a4_0.a6_0.a1_0 = a1_main; + Modify(a1_main); + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a3_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.a2_0 = null; + int result = a1_main.sum + a5_main.sum + a5_main.a3_0.sum + a5_main.a3_0.a4_0.sum + a5_main.a3_0.a4_0.a6_0.sum; + if (result == 1137) + System.out.println("ExpectResult"); + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0108-rc-function-RC_Dec-Cycle_aDec_00020/Cycle_aDec_00020.java b/test/testsuite/ouroboros/rc_test/RC0108-rc-function-RC_Dec-Cycle_aDec_00020/Cycle_aDec_00020.java new file mode 100755 index 0000000000000000000000000000000000000000..eee9ffdf18f579043c41c368f43b849cddad7427 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0108-rc-function-RC_Dec-Cycle_aDec_00020/Cycle_aDec_00020.java @@ -0,0 +1,185 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Dec/ Cycle_aDec_00020.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_aDec_00020 in RC测试-Cycle-01 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_aDec_00020.java + *- @ExecuteClass: Cycle_aDec_00020 + *- @ExecuteArgs: + *- @Remark: + * + */ + +class Cycle_aDec_00020_A1 { + Cycle_aDec_00020_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_aDec_00020_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Cycle_aDec_00020_A2 { + Cycle_aDec_00020_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_aDec_00020_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_aDec_00020_A3 { + Cycle_aDec_00020_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_aDec_00020_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } +} + + +class Cycle_aDec_00020_A4 { + Cycle_aDec_00020_A1 a1_0; + Cycle_aDec_00020_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_aDec_00020_A4(String strObjectName) { + a1_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a6_0.a; + } +} + +class Cycle_aDec_00020_A5 { + Cycle_aDec_00020_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_aDec_00020_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + +class Cycle_aDec_00020_A6 { + Cycle_aDec_00020_A1 a1_0; + Cycle_aDec_00020_A4 a4_0; + Cycle_aDec_00020_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_aDec_00020_A6(String strObjectName) { + a1_0 = null; + a4_0 = null; + a5_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a4_0.a + a5_0.a; + } +} + + +public class Cycle_aDec_00020 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + + } + + private static void Modify(Cycle_aDec_00020_A1 a1_main) { + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a1_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); + } + + private static void rc_testcase_main_wrapper() { + Cycle_aDec_00020_A1 a1_main = new Cycle_aDec_00020_A1("a1_main"); + Cycle_aDec_00020_A5 a5_main = new Cycle_aDec_00020_A5("a5_main"); + a1_main.a2_0 = new Cycle_aDec_00020_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_aDec_00020_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_aDec_00020_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0.a6_0 = new Cycle_aDec_00020_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a1_main.a2_0.a3_0.a4_0.a6_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.a2_0.a3_0.a4_0.a6_0.a1_0 = a1_main; + Modify(a1_main); + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a3_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.a2_0 = null; + a5_main = null; + a1_main.add(); + int result = a1_main.sum; + if (result == 202) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0109-rc-function-RC_Dec-Cycle_BDec_00010/Cycle_BDec_00010.java b/test/testsuite/ouroboros/rc_test/RC0109-rc-function-RC_Dec-Cycle_BDec_00010/Cycle_BDec_00010.java new file mode 100755 index 0000000000000000000000000000000000000000..11c529682ab8434a8d1f1611bd2e521d51ddc91d --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0109-rc-function-RC_Dec-Cycle_BDec_00010/Cycle_BDec_00010.java @@ -0,0 +1,85 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Dec/Cycle_BDec_00010.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_BDec_00010 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_BDec_00010.java + *- @ExecuteClass: Cycle_BDec_00010 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_BDec_00010_A1 { + Cycle_BDec_00010_A2 a2_0; + int a; + int sum; + + Cycle_BDec_00010_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_BDec_00010_A2 { + Cycle_BDec_00010_A1 a1_0; + int a; + int sum; + + Cycle_BDec_00010_A2() { + a1_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +public class Cycle_BDec_00010 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static boolean ModifyA1(Cycle_BDec_00010_A1 a1_0) { + a1_0.add(); + a1_0.a2_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum); + //System.out.println(nsum); + if (nsum == 6) + return true; + else + return false; + + } + + public static void rc_testcase_main_wrapper() { + Cycle_BDec_00010_A1 a1_0 = new Cycle_BDec_00010_A1(); + a1_0.a2_0 = new Cycle_BDec_00010_A2(); + a1_0.a2_0.a1_0 = a1_0; + boolean ret = ModifyA1(a1_0); + a1_0 = null; + if (ret == true && a1_0 == null) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0110-rc-function-RC_Dec-Cycle_BDec_00020/Cycle_BDec_00020.java b/test/testsuite/ouroboros/rc_test/RC0110-rc-function-RC_Dec-Cycle_BDec_00020/Cycle_BDec_00020.java new file mode 100755 index 0000000000000000000000000000000000000000..f656baaa86e44719e985990b845eac54505acea4 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0110-rc-function-RC_Dec-Cycle_BDec_00020/Cycle_BDec_00020.java @@ -0,0 +1,139 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Dec/Cycle_BDec_00020.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_BDec_00020 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_BDec_00020.java + *- @ExecuteClass: Cycle_BDec_00020 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_BDec_00020_A1 { + Cycle_BDec_00020_A2 a2_0; + int a; + int sum; + + Cycle_BDec_00020_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_BDec_00020_A2 { + Cycle_BDec_00020_A3 a3_0; + Cycle_BDec_00020_A4 a4_0; + int a; + int sum; + + Cycle_BDec_00020_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_BDec_00020_A3 { + Cycle_BDec_00020_A1 a1_0; + int a; + int sum; + + Cycle_BDec_00020_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_BDec_00020_A4 { + + int a; + int sum; + Cycle_BDec_00020_A5 a5_0; + + Cycle_BDec_00020_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + a5_0.add(); + sum = a + a5_0.sum; + } +} + +class Cycle_BDec_00020_A5 { + + int a; + int sum; + + Cycle_BDec_00020_A5() { + a = 5; + sum = 0; + } + + void add() { + sum = a + 6; + } +} + + +public class Cycle_BDec_00020 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void ModifyA1(Cycle_BDec_00020_A1 a1) { + a1.add(); + a1.a2_0.add(); + a1.a2_0.a3_0.add(); + } + + public static void rc_testcase_main_wrapper() { + Cycle_BDec_00020_A1 a1_0 = new Cycle_BDec_00020_A1(); + a1_0.a2_0 = new Cycle_BDec_00020_A2(); + a1_0.a2_0.a3_0 = new Cycle_BDec_00020_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a4_0 = new Cycle_BDec_00020_A4(); + a1_0.a2_0.a4_0.a5_0 = new Cycle_BDec_00020_A5(); + ModifyA1(a1_0); + a1_0.a2_0.a4_0 = null; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int result = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum; + if (result == 12) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0111-rc-function-RC_Dec-Cycle_BDec_00030/Cycle_BDec_00030.java b/test/testsuite/ouroboros/rc_test/RC0111-rc-function-RC_Dec-Cycle_BDec_00030/Cycle_BDec_00030.java new file mode 100755 index 0000000000000000000000000000000000000000..60c1dd663bf07afbd06fba8def925be6bd4e6d9f --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0111-rc-function-RC_Dec-Cycle_BDec_00030/Cycle_BDec_00030.java @@ -0,0 +1,123 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Dec/Cycle_BDec_00030.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_BDec_00030 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_BDec_00030.java + *- @ExecuteClass: Cycle_BDec_00030 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_BDec_00030_A1 { + Cycle_BDec_00030_A2 a2_0; + int a; + int sum; + + Cycle_BDec_00030_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_BDec_00030_A2 { + Cycle_BDec_00030_A3 a3_0; + Cycle_BDec_00030_A4 a4_0; + int a; + int sum; + + Cycle_BDec_00030_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_BDec_00030_A3 { + Cycle_BDec_00030_A1 a1_0; + Cycle_BDec_00030_A4 a4_0; + int a; + int sum; + + Cycle_BDec_00030_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } +} + + +class Cycle_BDec_00030_A4 { + Cycle_BDec_00030_A3 a3_0; + int a; + int sum; + + Cycle_BDec_00030_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + +public class Cycle_BDec_00030 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void ModifyA1(Cycle_BDec_00030_A1 a1) { + a1 = null; + a1 = new Cycle_BDec_00030_A1(); + } + + private static void rc_testcase_main_wrapper() { + Cycle_BDec_00030_A1 a1_0 = new Cycle_BDec_00030_A1(); + a1_0.a2_0 = new Cycle_BDec_00030_A2(); + a1_0.a2_0.a3_0 = new Cycle_BDec_00030_A3(); + Cycle_BDec_00030_A4 a4_0 = new Cycle_BDec_00030_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a4_0 = a4_0; + ModifyA1(a1_0); + a1_0 = null; + a4_0.add(); + a4_0.a3_0.add(); + int nsum = (a4_0.a3_0.sum + a4_0.sum); + if (nsum == 14) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0112-rc-function-RC_Dec-Cycle_BDec_00040/Cycle_BDec_00040.java b/test/testsuite/ouroboros/rc_test/RC0112-rc-function-RC_Dec-Cycle_BDec_00040/Cycle_BDec_00040.java new file mode 100755 index 0000000000000000000000000000000000000000..c05c771f784b543ff71186dc5761c873f047be1c --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0112-rc-function-RC_Dec-Cycle_BDec_00040/Cycle_BDec_00040.java @@ -0,0 +1,121 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Dec/Cycle_BDec_00040.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_BDec_00040 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Cycle_BDec_00040.java + *- @ExecuteClass: Cycle_BDec_00040 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_BDec_00040_A1 { + Cycle_BDec_00040_A2 a2_0; + int a; + int sum; + + Cycle_BDec_00040_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_BDec_00040_A2 { + Cycle_BDec_00040_A3 a3_0; + Cycle_BDec_00040_A4 a4_0; + int a; + int sum; + + Cycle_BDec_00040_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_BDec_00040_A3 { + Cycle_BDec_00040_A1 a1_0; + Cycle_BDec_00040_A4 a4_0; + int a; + int sum; + + Cycle_BDec_00040_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_BDec_00040_A4 { + Cycle_BDec_00040_A3 a3_0; + int a; + int sum; + + Cycle_BDec_00040_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + +public class Cycle_BDec_00040 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + + private static void modifyA1(Cycle_BDec_00040_A1 a1) { + a1.add(); + a1.a2_0.add(); + a1.a2_0.a3_0.add(); + a1.a2_0.a3_0.a4_0.add(); + } + + private static void rc_testcase_main_wrapper() { + Cycle_BDec_00040_A1 a1_0 = new Cycle_BDec_00040_A1(); + a1_0.a2_0 = new Cycle_BDec_00040_A2(); + a1_0.a2_0.a3_0 = new Cycle_BDec_00040_A3(); + Cycle_BDec_00040_A4 a4_0 = new Cycle_BDec_00040_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a4_0 = a4_0; + modifyA1(a1_0); + a1_0 = null; + a4_0 = null; + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0113-rc-function-RC_Dec-Cycle_BDec_00050/Cycle_BDec_00050.java b/test/testsuite/ouroboros/rc_test/RC0113-rc-function-RC_Dec-Cycle_BDec_00050/Cycle_BDec_00050.java new file mode 100755 index 0000000000000000000000000000000000000000..1be5e3fc79edece09b8a4686fe3a9839a6ac2766 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0113-rc-function-RC_Dec-Cycle_BDec_00050/Cycle_BDec_00050.java @@ -0,0 +1,127 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Dec/Cycle_BDec_00050.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_BDec_00050 in RC测试-Cycle-00.vsd + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Cycle_BDec_00050.java + *- @ExecuteClass: Cycle_BDec_00050 + *- @ExecuteArgs: + *- @Remark: + */ +class Cycle_BDec_00050_A1 { + Cycle_BDec_00050_A2 a2_0; + int a; + int sum; + + Cycle_BDec_00050_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_BDec_00050_A2 { + Cycle_BDec_00050_A3 a3_0; + Cycle_BDec_00050_A4 a4_0; + int a; + int sum; + + Cycle_BDec_00050_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_BDec_00050_A3 { + Cycle_BDec_00050_A1 a1_0; + Cycle_BDec_00050_A4 a4_0; + int a; + int sum; + + Cycle_BDec_00050_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_BDec_00050_A4 { + Cycle_BDec_00050_A3 a3_0; + int a; + int sum; + + Cycle_BDec_00050_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + +public class Cycle_BDec_00050 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + + } + + private static void modifyA1(Cycle_BDec_00050_A1 a1) { + a1.add(); + a1.a2_0.add(); + a1.a2_0.a3_0.add(); + a1.a2_0.a3_0.a4_0.add(); + } + + private static void rc_testcase_main_wrapper() { + Cycle_BDec_00050_A1 a1_0 = new Cycle_BDec_00050_A1(); + a1_0.a2_0 = new Cycle_BDec_00050_A2(); + a1_0.a2_0.a3_0 = new Cycle_BDec_00050_A3(); + Cycle_BDec_00050_A4 a4_0 = new Cycle_BDec_00050_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a4_0 = a4_0; + modifyA1(a1_0); + //cancel inline by for flow + int sum=0; + for(int i=0;i<100;i++) + sum +=i; + a1_0.a2_0.a3_0.a1_0 = null; + a4_0.a3_0 = null; + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0114-rc-function-RC_Dec-Nocycle_aDec_00010/Nocycle_aDec_00010.java b/test/testsuite/ouroboros/rc_test/RC0114-rc-function-RC_Dec-Nocycle_aDec_00010/Nocycle_aDec_00010.java new file mode 100755 index 0000000000000000000000000000000000000000..d248ffde4e4caab87912966a8cf18ac487687d13 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0114-rc-function-RC_Dec-Nocycle_aDec_00010/Nocycle_aDec_00010.java @@ -0,0 +1,217 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Dec/Nocycle_aDec_00010.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_aDec_00010 in RC测试-No-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_aDec_00010.java + *- @ExecuteClass: Nocycle_aDec_00010 + *- @ExecuteArgs: + *- @Remark: + */ + + +class Nocycle_aDec_00010_A1 { + Nocycle_aDec_00010_B1 b1_0; + Nocycle_aDec_00010_B2 b2_0; + Nocycle_aDec_00010_B3 b3_0; + Nocycle_aDec_00010_B4 b4_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00010_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } +} + +class Nocycle_aDec_00010_B1 { + Nocycle_aDec_00010_C1 c1_0; + Nocycle_aDec_00010_C2 c2_0; + Nocycle_aDec_00010_C3 c3_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00010_B1(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } +} + +class Nocycle_aDec_00010_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00010_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + + +class Nocycle_aDec_00010_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00010_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_aDec_00010_B4 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00010_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_aDec_00010_C1 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00010_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_aDec_00010_C2 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00010_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_aDec_00010_C3 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00010_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +public class Nocycle_aDec_00010 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Nocycle_aDec_00010_A1 a1_main = new Nocycle_aDec_00010_A1("a1_main"); + a1_main.b1_0 = new Nocycle_aDec_00010_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_aDec_00010_C1("c1_0"); + a1_main.b1_0.c2_0 = new Nocycle_aDec_00010_C2("c2_0"); + a1_main.b1_0.c3_0 = new Nocycle_aDec_00010_C3("c3_0"); + a1_main.b2_0 = new Nocycle_aDec_00010_B2("b2_0"); + a1_main.b3_0 = new Nocycle_aDec_00010_B3("b3_0"); + a1_main.b4_0 = new Nocycle_aDec_00010_B4("b4_0"); + Nocycle_aDec_00010_A1 a1_copy = modifyA1(a1_main); + a1_main = null; + a1_copy.add(); + a1_copy.b1_0.add(); + a1_copy.b2_0.add(); + a1_copy.b3_0.add(); + a1_copy.b4_0.add(); + a1_copy.b1_0.c1_0.add(); + a1_copy.b1_0.c2_0.add(); + a1_copy.b1_0.c3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_copy.sum+a1_copy.b1_0.sum+a1_copy.b2_0.sum+a1_copy.b3_0.sum+a1_copy.b4_0.sum+a1_copy.b1_0.c1_0.sum+a1_copy.b1_0.c2_0.sum+a1_copy.b1_0.c3_0.sum); + + int result = a1_copy.sum + a1_copy.b1_0.sum + a1_copy.b2_0.sum + a1_copy.b3_0.sum + a1_copy.b4_0.sum + a1_copy.b1_0.c1_0.sum + a1_copy.b1_0.c2_0.sum + a1_copy.b1_0.c3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 5049) + System.out.println("ExpectResult"); + } + + public static Nocycle_aDec_00010_A1 modifyA1(Nocycle_aDec_00010_A1 a1) { + a1.a = 102; + return a1; + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0115-rc-function-RC_Dec-Nocycle_aDec_00020/Nocycle_aDec_00020.java b/test/testsuite/ouroboros/rc_test/RC0115-rc-function-RC_Dec-Nocycle_aDec_00020/Nocycle_aDec_00020.java new file mode 100755 index 0000000000000000000000000000000000000000..29d164dc261c5875bf69eebe587bc5f6f94a41f7 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0115-rc-function-RC_Dec-Nocycle_aDec_00020/Nocycle_aDec_00020.java @@ -0,0 +1,210 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Dec/Nocycle_aDec_00020.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_aDec_00020 in RC测试-No-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_aDec_00020.java + *- @ExecuteClass: Nocycle_aDec_00020 + *- @ExecuteArgs: + *- @Remark: + */ + +class Nocycle_aDec_00020_A1 { + Nocycle_aDec_00020_B1 b1_0; + Nocycle_aDec_00020_B2 b2_0; + Nocycle_aDec_00020_B3 b3_0; + Nocycle_aDec_00020_B4 b4_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00020_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b2_0.a + b3_0.a + b4_0.a; + } +} + +class Nocycle_aDec_00020_B1 { + Nocycle_aDec_00020_C1 c1_0; + Nocycle_aDec_00020_C2 c2_0; + Nocycle_aDec_00020_C3 c3_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00020_B1(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } +} + +class Nocycle_aDec_00020_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00020_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + + } +} + + +class Nocycle_aDec_00020_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00020_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + + } +} + +class Nocycle_aDec_00020_B4 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00020_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + + void add() { + sum = a + a; + + } +} + +class Nocycle_aDec_00020_C1 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00020_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a; + } +} + +class Nocycle_aDec_00020_C2 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00020_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_aDec_00020_C3 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00020_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +public class Nocycle_aDec_00020 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Nocycle_aDec_00020_A1 a1_main = new Nocycle_aDec_00020_A1("a1_main"); + a1_main.b1_0 = new Nocycle_aDec_00020_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_aDec_00020_C1("c1_0"); + a1_main.b1_0.c2_0 = new Nocycle_aDec_00020_C2("c2_0"); + a1_main.b1_0.c3_0 = new Nocycle_aDec_00020_C3("c3_0"); + a1_main.b2_0 = new Nocycle_aDec_00020_B2("b2_0"); + a1_main.b3_0 = new Nocycle_aDec_00020_B3("b3_0"); + a1_main.b4_0 = new Nocycle_aDec_00020_B4("b4_0"); + modifyB1(a1_main.b1_0); + a1_main.b1_0 = null; + a1_main.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + int result = a1_main.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum; + + if (result == 1928) + System.out.println("ExpectResult"); + } + + public static void modifyB1(Nocycle_aDec_00020_B1 b1) { + b1.a = 202; + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0116-rc-function-RC_Dec-Nocycle_aDec_00030/Nocycle_aDec_00030.java b/test/testsuite/ouroboros/rc_test/RC0116-rc-function-RC_Dec-Nocycle_aDec_00030/Nocycle_aDec_00030.java new file mode 100755 index 0000000000000000000000000000000000000000..06e46656d16acacd39d47f71f117a5717c4fa11f --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0116-rc-function-RC_Dec-Nocycle_aDec_00030/Nocycle_aDec_00030.java @@ -0,0 +1,213 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Dec/Nocycle_aDec_00030.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_aDec_00030 in RC测试-No-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_aDec_00030.java + *- @ExecuteClass: Nocycle_aDec_00030 + *- @ExecuteArgs: + *- @Remark: + */ + +class Nocycle_aDec_00030_A1 { + Nocycle_aDec_00030_B1 b1_0; + Nocycle_aDec_00030_B2 b2_0; + Nocycle_aDec_00030_B3 b3_0; + Nocycle_aDec_00030_B4 b4_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00030_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } +} + +class Nocycle_aDec_00030_B1 { + Nocycle_aDec_00030_C1 c1_0; + Nocycle_aDec_00030_C2 c2_0; + Nocycle_aDec_00030_C3 c3_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00030_B1(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + c2_0.a; + } +} + +class Nocycle_aDec_00030_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00030_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + + } +} + + +class Nocycle_aDec_00030_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00030_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + + } +} + +class Nocycle_aDec_00030_B4 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00030_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + + void add() { + sum = a + a; + + } +} + +class Nocycle_aDec_00030_C1 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00030_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a; + } +} + +class Nocycle_aDec_00030_C2 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00030_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_aDec_00030_C3 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00030_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +public class Nocycle_aDec_00030 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Nocycle_aDec_00030_A1 a1_main = new Nocycle_aDec_00030_A1("a1_main"); + a1_main.b1_0 = new Nocycle_aDec_00030_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_aDec_00030_C1("c1_0"); + a1_main.b1_0.c2_0 = new Nocycle_aDec_00030_C2("c2_0"); + a1_main.b1_0.c3_0 = new Nocycle_aDec_00030_C3("c3_0"); + a1_main.b2_0 = new Nocycle_aDec_00030_B2("b2_0"); + a1_main.b3_0 = new Nocycle_aDec_00030_B3("b3_0"); + a1_main.b4_0 = new Nocycle_aDec_00030_B4("b4_0"); + modifyC3(a1_main.b1_0.c3_0); + a1_main.b1_0.c3_0 = null; + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b1_0.c1_0.add(); + a1_main.b1_0.c2_0.add(); + + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b1_0.c1_0.sum + a1_main.b1_0.c2_0.sum; + if (result == 4139) + System.out.println("ExpectResult"); + } + + public static void modifyC3(Nocycle_aDec_00030_C3 c3) { + c3.a += 1; + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0117-rc-function-RC_Dec-Nocycle_aDec_00040/Nocycle_aDec_00040.java b/test/testsuite/ouroboros/rc_test/RC0117-rc-function-RC_Dec-Nocycle_aDec_00040/Nocycle_aDec_00040.java new file mode 100755 index 0000000000000000000000000000000000000000..ff374a5da29fcf438e198fbe79aa78cce94f71c7 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0117-rc-function-RC_Dec-Nocycle_aDec_00040/Nocycle_aDec_00040.java @@ -0,0 +1,355 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Dec/Nocycle_aDec_00040.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_aDec_00040 in RC测试-No-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_aDec_00040.java + *- @ExecuteClass: Nocycle_aDec_00040 + *- @ExecuteArgs: + *- @Remark: + */ + + +class Nocycle_aDec_00040_A1 { + Nocycle_aDec_00040_B1 b1_0; + Nocycle_aDec_00040_D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00040_A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + d1_0.a; + } +} + + +class Nocycle_aDec_00040_A2 { + Nocycle_aDec_00040_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00040_A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b2_0.a; + } +} + + +class Nocycle_aDec_00040_A3 { + Nocycle_aDec_00040_B2 b2_0; + Nocycle_aDec_00040_C2 c2_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00040_A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + b2_0.a + c2_0.a; + } +} + +class Nocycle_aDec_00040_A4 { + Nocycle_aDec_00040_B3 b3_0; + Nocycle_aDec_00040_C2 c2_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00040_A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + b3_0.a + c2_0.a; + } +} + + +class Nocycle_aDec_00040_B1 { + Nocycle_aDec_00040_D2 d2_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00040_B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + d2_0.a; + } +} + + +class Nocycle_aDec_00040_B2 { + Nocycle_aDec_00040_C1 c1_0; + Nocycle_aDec_00040_D1 d1_0; + Nocycle_aDec_00040_D2 d2_0; + Nocycle_aDec_00040_D3 d3_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00040_B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } +} + + +class Nocycle_aDec_00040_B3 { + Nocycle_aDec_00040_C1 c1_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00040_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } +} + + +class Nocycle_aDec_00040_C1 { + Nocycle_aDec_00040_D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00040_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + d1_0.a; + } +} + +class Nocycle_aDec_00040_C2 { + Nocycle_aDec_00040_D2 d2_0; + Nocycle_aDec_00040_D3 d3_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00040_C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + d2_0.a + d3_0.a; + } +} + + +class Nocycle_aDec_00040_D1 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00040_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_aDec_00040_D2 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00040_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_aDec_00040_D3 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00040_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + + +public class Nocycle_aDec_00040 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Nocycle_aDec_00040_A1 a1_main = new Nocycle_aDec_00040_A1("a1_main"); + Nocycle_aDec_00040_A2 a2_main = new Nocycle_aDec_00040_A2("a2_main"); + Nocycle_aDec_00040_A3 a3_main = new Nocycle_aDec_00040_A3("a3_main"); + Nocycle_aDec_00040_A4 a4_main = new Nocycle_aDec_00040_A4("a4_main"); + a1_main.b1_0 = new Nocycle_aDec_00040_B1("b1_0"); + a1_main.d1_0 = new Nocycle_aDec_00040_D1("d1_0"); + a1_main.b1_0.d2_0 = new Nocycle_aDec_00040_D2("d2_0"); + + a2_main.b2_0 = new Nocycle_aDec_00040_B2("b2_0"); + a2_main.b2_0.c1_0 = new Nocycle_aDec_00040_C1("c1_0"); + a2_main.b2_0.d1_0 = a1_main.d1_0; + a2_main.b2_0.d2_0 = new Nocycle_aDec_00040_D2("d2_0"); + a2_main.b2_0.d3_0 = new Nocycle_aDec_00040_D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = a1_main.d1_0; + + a3_main.b2_0 = a2_main.b2_0; + a3_main.b2_0.c1_0 = a2_main.b2_0.c1_0; + a3_main.b2_0.c1_0.d1_0 = a2_main.b2_0.c1_0.d1_0; + a3_main.b2_0.d1_0 = a2_main.b2_0.d1_0; + a3_main.b2_0.d2_0 = a2_main.b2_0.d2_0; + a3_main.b2_0.d3_0 = a2_main.b2_0.d3_0; + + a3_main.c2_0 = new Nocycle_aDec_00040_C2("c2_0"); + a3_main.c2_0.d2_0 = a2_main.b2_0.d2_0; + a3_main.c2_0.d3_0 = new Nocycle_aDec_00040_D3("d3_0"); + + a4_main.b3_0 = new Nocycle_aDec_00040_B3("b3_0"); + a4_main.b3_0.c1_0 = a3_main.b2_0.c1_0; + a4_main.b3_0.c1_0.d1_0 = a3_main.b2_0.c1_0.d1_0; + a4_main.c2_0 = a3_main.c2_0; + a4_main.c2_0.d2_0 = a3_main.c2_0.d2_0; + a4_main.c2_0.d3_0 = a3_main.c2_0.d3_0; + modifyA1(a1_main); + a1_main = null; + a2_main.add(); + a3_main.add(); + a4_main.add(); + + a2_main.b2_0.add(); + a2_main.b2_0.c1_0.add(); + a2_main.b2_0.d1_0.add(); + a2_main.b2_0.d2_0.add(); + a2_main.b2_0.d3_0.add(); + a2_main.b2_0.c1_0.d1_0.add(); + + a3_main.b2_0.add(); + a3_main.b2_0.c1_0.add(); + a3_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.d1_0.add(); + a3_main.b2_0.d2_0.add(); + a3_main.b2_0.d3_0.add(); + + a3_main.c2_0.add(); + a3_main.c2_0.d2_0.add(); + a3_main.c2_0.d3_0.add(); + + a4_main.b3_0.add(); + a4_main.b3_0.c1_0.add(); + a4_main.b3_0.c1_0.d1_0.add(); + a4_main.c2_0.add(); + a4_main.c2_0.d2_0.add(); + a4_main.c2_0.d3_0.add(); + + + int result = a2_main.sum + a3_main.sum + a4_main.sum + a2_main.b2_0.sum + a4_main.b3_0.sum + a2_main.b2_0.c1_0.sum + a3_main.c2_0.sum + a4_main.b3_0.c1_0.d1_0.sum + a3_main.c2_0.d2_0.sum + a3_main.c2_0.d3_0.sum; + if (result == 7954) + System.out.println("ExpectResult"); + } + + private static void modifyA1(Nocycle_aDec_00040_A1 a1) { + a1.a += 1; + a1.add(); + a1.b1_0.add(); + a1.d1_0.add(); + a1.b1_0.d2_0.add(); + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0118-rc-function-RC_Dec-Nocycle_aDec_00050/Nocycle_aDec_00050.java b/test/testsuite/ouroboros/rc_test/RC0118-rc-function-RC_Dec-Nocycle_aDec_00050/Nocycle_aDec_00050.java new file mode 100755 index 0000000000000000000000000000000000000000..d842594998d5b71fc1b6c4318f16e1b7b6ccea4c --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0118-rc-function-RC_Dec-Nocycle_aDec_00050/Nocycle_aDec_00050.java @@ -0,0 +1,349 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Dec/Nocycle_aDec_00050.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_aDec_00050 in RC测试-No-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_aDec_00050.java + *- @ExecuteClass: Nocycle_aDec_00050 + *- @ExecuteArgs: + *- @Remark: + */ + +class Nocycle_aDec_00050_A1 { + Nocycle_aDec_00050_B1 b1_0; + Nocycle_aDec_00050_D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00050_A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + d1_0.a; + } +} + + +class Nocycle_aDec_00050_A2 { + Nocycle_aDec_00050_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00050_A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + + +class Nocycle_aDec_00050_A3 { + Nocycle_aDec_00050_B2 b2_0; + Nocycle_aDec_00050_C2 c2_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00050_A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + c2_0.a; + } +} + +class Nocycle_aDec_00050_A4 { + Nocycle_aDec_00050_B3 b3_0; + Nocycle_aDec_00050_C2 c2_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00050_A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + b3_0.a + c2_0.a; + } +} + + +class Nocycle_aDec_00050_B1 { + Nocycle_aDec_00050_D2 d2_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00050_B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + d2_0.a; + } +} + + +class Nocycle_aDec_00050_B2 { + Nocycle_aDec_00050_C1 c1_0; + Nocycle_aDec_00050_D1 d1_0; + Nocycle_aDec_00050_D2 d2_0; + Nocycle_aDec_00050_D3 d3_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00050_B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } +} + + +class Nocycle_aDec_00050_B3 { + Nocycle_aDec_00050_C1 c1_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00050_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } +} + + +class Nocycle_aDec_00050_C1 { + Nocycle_aDec_00050_D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00050_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + d1_0.a; + } +} + +class Nocycle_aDec_00050_C2 { + Nocycle_aDec_00050_D2 d2_0; + Nocycle_aDec_00050_D3 d3_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00050_C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + d2_0.a + d3_0.a; + } +} + + +class Nocycle_aDec_00050_D1 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00050_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_aDec_00050_D2 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00050_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_aDec_00050_D3 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00050_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + + +public class Nocycle_aDec_00050 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Nocycle_aDec_00050_A1 a1_main = new Nocycle_aDec_00050_A1("a1_main"); + Nocycle_aDec_00050_A2 a2_main = new Nocycle_aDec_00050_A2("a2_main"); + Nocycle_aDec_00050_A3 a3_main = new Nocycle_aDec_00050_A3("a3_main"); + Nocycle_aDec_00050_A4 a4_main = new Nocycle_aDec_00050_A4("a4_main"); + a1_main.b1_0 = new Nocycle_aDec_00050_B1("b1_0"); + a1_main.d1_0 = new Nocycle_aDec_00050_D1("d1_0"); + a1_main.b1_0.d2_0 = new Nocycle_aDec_00050_D2("d2_0"); + + a2_main.b2_0 = new Nocycle_aDec_00050_B2("b2_0"); + a2_main.b2_0.c1_0 = new Nocycle_aDec_00050_C1("c1_0"); + a2_main.b2_0.d1_0 = a1_main.d1_0; + a2_main.b2_0.d2_0 = new Nocycle_aDec_00050_D2("d2_0"); + a2_main.b2_0.d3_0 = new Nocycle_aDec_00050_D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = a1_main.d1_0; + + a3_main.b2_0 = a2_main.b2_0; + a3_main.b2_0.c1_0 = a2_main.b2_0.c1_0; + a3_main.b2_0.c1_0.d1_0 = a2_main.b2_0.c1_0.d1_0; + a3_main.b2_0.d1_0 = a2_main.b2_0.d1_0; + a3_main.b2_0.d2_0 = a2_main.b2_0.d2_0; + a3_main.b2_0.d3_0 = a2_main.b2_0.d3_0; + + a3_main.c2_0 = new Nocycle_aDec_00050_C2("c2_0"); + a3_main.c2_0.d2_0 = a2_main.b2_0.d2_0; + a3_main.c2_0.d3_0 = new Nocycle_aDec_00050_D3("d3_0"); + + a4_main.b3_0 = new Nocycle_aDec_00050_B3("b3_0"); + a4_main.b3_0.c1_0 = a3_main.b2_0.c1_0; + a4_main.b3_0.c1_0.d1_0 = a3_main.b2_0.c1_0.d1_0; + a4_main.c2_0 = a3_main.c2_0; + a4_main.c2_0.d2_0 = a3_main.c2_0.d2_0; + a4_main.c2_0.d3_0 = a3_main.c2_0.d3_0; + modifyB2(a2_main.b2_0); + a2_main.b2_0 = null; + a3_main.b2_0 = null; + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main.b1_0.add(); + a1_main.d1_0.add(); + a1_main.b1_0.d2_0.add(); + + + a3_main.c2_0.add(); + a3_main.c2_0.d2_0.add(); + a3_main.c2_0.d3_0.add(); + + a4_main.b3_0.add(); + a4_main.b3_0.c1_0.add(); + a4_main.b3_0.c1_0.d1_0.add(); + a4_main.c2_0.add(); + a4_main.c2_0.d2_0.add(); + a4_main.c2_0.d3_0.add(); + + + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main.b1_0.sum + a4_main.b3_0.sum + a4_main.b3_0.c1_0.sum + a3_main.c2_0.sum + a1_main.d1_0.sum + a3_main.c2_0.d2_0.sum + a3_main.c2_0.d3_0.sum; + + if (result == 7249) + System.out.println("ExpectResult"); + } + + private static void modifyB2(Nocycle_aDec_00050_B2 b2) { + b2.a += 1; + b2.add(); + b2.c1_0.add(); + b2.d1_0.add(); + b2.d2_0.add(); + b2.d3_0.add(); + b2.c1_0.d1_0.add(); + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0119-rc-function-RC_Dec-Nocycle_aDec_00060/Nocycle_aDec_00060.java b/test/testsuite/ouroboros/rc_test/RC0119-rc-function-RC_Dec-Nocycle_aDec_00060/Nocycle_aDec_00060.java new file mode 100755 index 0000000000000000000000000000000000000000..b44691101e233e454020f29957a35977f79d83d6 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0119-rc-function-RC_Dec-Nocycle_aDec_00060/Nocycle_aDec_00060.java @@ -0,0 +1,361 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Dec/Nocycle_aDec_00060.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_aDec_00060 in RC测试-No-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_aDec_00060.java + *- @ExecuteClass: Nocycle_aDec_00060 + *- @ExecuteArgs: + *- @Remark: + */ + + +class Nocycle_aDec_00060_A1 { + Nocycle_aDec_00060_B1 b1_0; + Nocycle_aDec_00060_D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00060_A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + d1_0.a; + } +} + + +class Nocycle_aDec_00060_A2 { + Nocycle_aDec_00060_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00060_A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b2_0.a; + } +} + + +class Nocycle_aDec_00060_A3 { + Nocycle_aDec_00060_B2 b2_0; + Nocycle_aDec_00060_C2 c2_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00060_A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + b2_0.a + c2_0.a; + } +} + +class Nocycle_aDec_00060_A4 { + Nocycle_aDec_00060_B3 b3_0; + Nocycle_aDec_00060_C2 c2_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00060_A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + b3_0.a + c2_0.a; + } +} + + +class Nocycle_aDec_00060_B1 { + Nocycle_aDec_00060_D2 d2_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00060_B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + d2_0.a; + } +} + + +class Nocycle_aDec_00060_B2 { + Nocycle_aDec_00060_C1 c1_0; + Nocycle_aDec_00060_D1 d1_0; + Nocycle_aDec_00060_D2 d2_0; + Nocycle_aDec_00060_D3 d3_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00060_B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } +} + + +class Nocycle_aDec_00060_B3 { + Nocycle_aDec_00060_C1 c1_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00060_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } +} + + +class Nocycle_aDec_00060_C1 { + Nocycle_aDec_00060_D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00060_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + d1_0.a; + } +} + +class Nocycle_aDec_00060_C2 { + Nocycle_aDec_00060_D2 d2_0; + Nocycle_aDec_00060_D3 d3_0; + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00060_C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + d2_0.a + d3_0.a; + } +} + + +class Nocycle_aDec_00060_D1 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00060_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_aDec_00060_D2 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00060_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_aDec_00060_D3 { + int a; + int sum; + String strObjectName; + + Nocycle_aDec_00060_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + + +public class Nocycle_aDec_00060 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + Nocycle_aDec_00060_A1 a1_main = new Nocycle_aDec_00060_A1("a1_main"); + Nocycle_aDec_00060_A2 a2_main = new Nocycle_aDec_00060_A2("a2_main"); + Nocycle_aDec_00060_A3 a3_main = new Nocycle_aDec_00060_A3("a3_main"); + Nocycle_aDec_00060_A4 a4_main = new Nocycle_aDec_00060_A4("a4_main"); + a1_main.b1_0 = new Nocycle_aDec_00060_B1("b1_0"); + a1_main.d1_0 = new Nocycle_aDec_00060_D1("d1_0"); + a1_main.b1_0.d2_0 = new Nocycle_aDec_00060_D2("d2_0"); + + a2_main.b2_0 = new Nocycle_aDec_00060_B2("b2_0"); + a2_main.b2_0.c1_0 = new Nocycle_aDec_00060_C1("c1_0"); + a2_main.b2_0.d1_0 = a1_main.d1_0; + a2_main.b2_0.d2_0 = new Nocycle_aDec_00060_D2("d2_0"); + a2_main.b2_0.d3_0 = new Nocycle_aDec_00060_D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = a1_main.d1_0; + + a3_main.b2_0 = a2_main.b2_0; + a3_main.b2_0.c1_0 = a2_main.b2_0.c1_0; + a3_main.b2_0.c1_0.d1_0 = a2_main.b2_0.c1_0.d1_0; + a3_main.b2_0.d1_0 = a2_main.b2_0.d1_0; + a3_main.b2_0.d2_0 = a2_main.b2_0.d2_0; + a3_main.b2_0.d3_0 = a2_main.b2_0.d3_0; + + a3_main.c2_0 = new Nocycle_aDec_00060_C2("c2_0"); + a3_main.c2_0.d2_0 = a2_main.b2_0.d2_0; + a3_main.c2_0.d3_0 = new Nocycle_aDec_00060_D3("d3_0"); + + a4_main.b3_0 = new Nocycle_aDec_00060_B3("b3_0"); + a4_main.b3_0.c1_0 = a3_main.b2_0.c1_0; + a4_main.b3_0.c1_0.d1_0 = a3_main.b2_0.c1_0.d1_0; + a4_main.c2_0 = a3_main.c2_0; + a4_main.c2_0.d2_0 = a3_main.c2_0.d2_0; + a4_main.c2_0.d3_0 = a3_main.c2_0.d3_0; + ModifyA1(a1_main); + ModifyA2(a2_main); + ModifyA3(a3_main); + a4_main.add(); + a4_main.b3_0.add(); + a4_main.b3_0.c1_0.add(); + a4_main.b3_0.c1_0.d1_0.add(); + a4_main.c2_0.add(); + a4_main.c2_0.d2_0.add(); + a4_main.c2_0.d3_0.add(); + + + int result = a4_main.sum + a4_main.b3_0.sum + a4_main.b3_0.c1_0.sum + a4_main.c2_0.sum + a4_main.b3_0.c1_0.d1_0.sum + a4_main.c2_0.d2_0.sum + a4_main.c2_0.d3_0.sum; + + if (result == 5334) + System.out.println("ExpectResult"); + } + + private static void ModifyA1(Nocycle_aDec_00060_A1 a1) { + a1.a += 1; + a1.add(); + a1.b1_0.add(); + a1.d1_0.add(); + a1.b1_0.d2_0.add(); + } + + private static void ModifyA2(Nocycle_aDec_00060_A2 a2) { + a2.a += 1; + a2.add(); + a2.b2_0.add(); + a2.b2_0.c1_0.add(); + a2.b2_0.d1_0.add(); + a2.b2_0.d2_0.add(); + a2.b2_0.d3_0.add(); + a2.b2_0.c1_0.d1_0.add(); + } + + private static void ModifyA3(Nocycle_aDec_00060_A3 a3) { + a3.a += 1; + a3.add(); + a3.b2_0.add(); + a3.b2_0.c1_0.add(); + a3.b2_0.c1_0.d1_0.add(); + a3.b2_0.d1_0.add(); + a3.b2_0.d2_0.add(); + a3.b2_0.d3_0.add(); + a3.c2_0.add(); + a3.c2_0.d2_0.add(); + a3.c2_0.d3_0.add(); + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0120-rc-function-RC_Thread01-Cycle_am_00180/Cycle_am_00180.java b/test/testsuite/ouroboros/rc_test/RC0120-rc-function-RC_Thread01-Cycle_am_00180/Cycle_am_00180.java new file mode 100755 index 0000000000000000000000000000000000000000..a30a5168fd453f9d06cc6b31cff916022c50ef9a --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0120-rc-function-RC_Thread01-Cycle_am_00180/Cycle_am_00180.java @@ -0,0 +1,277 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00180.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00180 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00180.java + *- @ExecuteClass: Cycle_am_00180 + *- @ExecuteArgs: + *- @Remark: + * A1 depend A2 A8; + * A2 depend A3 ; A3 depend A4; A4 depend A5 ; A5 depend A6; A6 depend A1 ; + * A8 depend A9 ; A9 depend A7; A7 depend A4 + * A1.a=101 A2.a=102 A3.a=103 ... A9.a=109 + * RC-Testing_Result=(101+102+108)+(102+103)+(103+104)+(104+105)+(105+106)+(106+101)+(107+104)+(108+109)+(109+107)=1994 + * + */ +class ThreadRc_Cycle_am_00180 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00180_A1 a1_main = new Cycle_a_00180_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00180_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00180_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00180_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = new Cycle_a_00180_A5("a5_0"); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_a_00180_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_main; + a1_main.a8_0 = new Cycle_a_00180_A8("a8_0"); + a1_main.a8_0.a9_0 = new Cycle_a_00180_A9("a9_0"); + a1_main.a8_0.a9_0.a7_0 = new Cycle_a_00180_A7("a7_0"); + a1_main.a8_0.a9_0.a7_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a5_0.add(); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a1_main.a8_0.add(); + a1_main.a8_0.a9_0.add(); + a1_main.a8_0.a9_0.a7_0.add(); + + + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a5_0.sum + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a1_main.a8_0.sum + a1_main.a8_0.a9_0.sum + a1_main.a8_0.a9_0.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1994) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00180_A1 { + Cycle_a_00180_A2 a2_0; + Cycle_a_00180_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A1(String strObjectName) { + a2_0 = null; + a8_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a8_0.a; + } + } + + class Cycle_a_00180_A2 { + Cycle_a_00180_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00180_A3 { + Cycle_a_00180_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_a_00180_A4 { + Cycle_a_00180_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_a_00180_A5 { + Cycle_a_00180_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00180_A6 { + Cycle_a_00180_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A6(String strObjectName) { + a1_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_00180_A7 { + Cycle_a_00180_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A7(String strObjectName) { + a4_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_a_00180_A8 { + Cycle_a_00180_A9 a9_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A8(String strObjectName) { + a9_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a9_0.a; + } + } + + class Cycle_a_00180_A9 { + Cycle_a_00180_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A9(String strObjectName) { + a7_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } +} + + +public class Cycle_am_00180 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00180 A1_Cycle_am_00180 = new ThreadRc_Cycle_am_00180(); + ThreadRc_Cycle_am_00180 A2_Cycle_am_00180 = new ThreadRc_Cycle_am_00180(); + ThreadRc_Cycle_am_00180 A3_Cycle_am_00180 = new ThreadRc_Cycle_am_00180(); + ThreadRc_Cycle_am_00180 A4_Cycle_am_00180 = new ThreadRc_Cycle_am_00180(); + ThreadRc_Cycle_am_00180 A5_Cycle_am_00180 = new ThreadRc_Cycle_am_00180(); + ThreadRc_Cycle_am_00180 A6_Cycle_am_00180 = new ThreadRc_Cycle_am_00180(); + + A1_Cycle_am_00180.start(); + A2_Cycle_am_00180.start(); + A3_Cycle_am_00180.start(); + A4_Cycle_am_00180.start(); + A5_Cycle_am_00180.start(); + A6_Cycle_am_00180.start(); + + try { + A1_Cycle_am_00180.join(); + A2_Cycle_am_00180.join(); + A3_Cycle_am_00180.join(); + A4_Cycle_am_00180.join(); + A5_Cycle_am_00180.join(); + A6_Cycle_am_00180.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00180.check() && A2_Cycle_am_00180.check() && A3_Cycle_am_00180.check() && A4_Cycle_am_00180.check() && A5_Cycle_am_00180.check() && A6_Cycle_am_00180.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0121-rc-function-RC_Thread01-Cycle_am_00190/Cycle_am_00190.java b/test/testsuite/ouroboros/rc_test/RC0121-rc-function-RC_Thread01-Cycle_am_00190/Cycle_am_00190.java new file mode 100755 index 0000000000000000000000000000000000000000..b101c9685daa3f5e2f12de9a24103c80028ff06e --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0121-rc-function-RC_Thread01-Cycle_am_00190/Cycle_am_00190.java @@ -0,0 +1,294 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00190.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00190 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00190.java + *- @ExecuteClass: Cycle_am_00190 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_am_00190 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00190_A1 a1_main = new Cycle_a_00190_A1("a1_main"); + Cycle_a_00190_A10 a10_main = new Cycle_a_00190_A10("a10_main"); + a1_main.a2_0 = new Cycle_a_00190_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00190_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00190_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = new Cycle_a_00190_A5("a5_0"); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_a_00190_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.a10_0 = a10_main; + + a10_main.a8_0 = new Cycle_a_00190_A8("a8_0"); + a10_main.a8_0.a9_0 = new Cycle_a_00190_A9("a9_0"); + a10_main.a8_0.a9_0.a7_0 = new Cycle_a_00190_A7("a7_0"); + a10_main.a8_0.a9_0.a7_0.a5_0 = a1_main.a2_0.a3_0.a4_0.a5_0; + + a1_main.add(); + a10_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a5_0.add(); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a10_main.a8_0.add(); + a10_main.a8_0.a9_0.add(); + a10_main.a8_0.a9_0.a7_0.add(); + + + int result = a1_main.sum + a10_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a5_0.sum + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a10_main.a8_0.sum + a10_main.a8_0.a9_0.sum + a10_main.a8_0.a9_0.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 2215) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00190_A1 { + Cycle_a_00190_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00190_A2 { + Cycle_a_00190_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00190_A3 { + Cycle_a_00190_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_a_00190_A4 { + Cycle_a_00190_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_a_00190_A5 { + Cycle_a_00190_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00190_A6 { + Cycle_a_00190_A1 a1_0; + Cycle_a_00190_A10 a10_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A6(String strObjectName) { + a1_0 = null; + a10_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a10_0.a; + } + } + + class Cycle_a_00190_A7 { + Cycle_a_00190_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A7(String strObjectName) { + a5_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_a_00190_A8 { + Cycle_a_00190_A9 a9_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A8(String strObjectName) { + a9_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a9_0.a; + } + } + + class Cycle_a_00190_A9 { + Cycle_a_00190_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A9(String strObjectName) { + a7_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_a_00190_A10 { + Cycle_a_00190_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A10(String strObjectName) { + a8_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + + void add() { + sum = a + a8_0.a; + } + } +} + + +public class Cycle_am_00190 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00190 A1_Cycle_am_00190 = new ThreadRc_Cycle_am_00190(); + ThreadRc_Cycle_am_00190 A2_Cycle_am_00190 = new ThreadRc_Cycle_am_00190(); + ThreadRc_Cycle_am_00190 A3_Cycle_am_00190 = new ThreadRc_Cycle_am_00190(); + ThreadRc_Cycle_am_00190 A4_Cycle_am_00190 = new ThreadRc_Cycle_am_00190(); + ThreadRc_Cycle_am_00190 A5_Cycle_am_00190 = new ThreadRc_Cycle_am_00190(); + ThreadRc_Cycle_am_00190 A6_Cycle_am_00190 = new ThreadRc_Cycle_am_00190(); + + A1_Cycle_am_00190.start(); + A2_Cycle_am_00190.start(); + A3_Cycle_am_00190.start(); + A4_Cycle_am_00190.start(); + A5_Cycle_am_00190.start(); + A6_Cycle_am_00190.start(); + + try { + A1_Cycle_am_00190.join(); + A2_Cycle_am_00190.join(); + A3_Cycle_am_00190.join(); + A4_Cycle_am_00190.join(); + A5_Cycle_am_00190.join(); + A6_Cycle_am_00190.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00190.check() && A2_Cycle_am_00190.check() && A3_Cycle_am_00190.check() && A4_Cycle_am_00190.check() && A5_Cycle_am_00190.check() && A6_Cycle_am_00190.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0122-rc-function-RC_Thread01-Cycle_am_00200/Cycle_am_00200.java b/test/testsuite/ouroboros/rc_test/RC0122-rc-function-RC_Thread01-Cycle_am_00200/Cycle_am_00200.java new file mode 100755 index 0000000000000000000000000000000000000000..9193c3e232fa9f693ab0e97763d680492844dfc4 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0122-rc-function-RC_Thread01-Cycle_am_00200/Cycle_am_00200.java @@ -0,0 +1,232 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00200.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00200 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00200.java + *- @ExecuteClass: Cycle_am_00200 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_am_00200 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00200_A1 a1_main = new Cycle_a_00200_A1("a1_main"); + Cycle_a_00200_A4 a4_main = new Cycle_a_00200_A4("a4_main"); + a1_main.a2_0 = new Cycle_a_00200_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00200_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00200_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a4_0 = a4_main; + a4_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a6_0 = new Cycle_a_00200_A6("a6_0"); + a1_main.a2_0.a6_0.a7_0 = new Cycle_a_00200_A7("a7_0"); + a1_main.a2_0.a7_0 = a1_main.a2_0.a6_0.a7_0; + + a1_main.add(); + a4_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a6_0.add(); + a1_main.a2_0.a6_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a1_main.a2_0.a6_0.sum + a1_main.a2_0.a6_0.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1773) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00200_A1 { + Cycle_a_00200_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00200_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00200_A2 { + Cycle_a_00200_A3 a3_0; + Cycle_a_00200_A6 a6_0; + Cycle_a_00200_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00200_A2(String strObjectName) { + a3_0 = null; + a6_0 = null; + a7_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a6_0.a + a7_0.a; + } + } + + class Cycle_a_00200_A3 { + Cycle_a_00200_A1 a1_0; + Cycle_a_00200_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00200_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_00200_A4 { + Cycle_a_00200_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00200_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00200_A5 { + Cycle_a_00200_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00200_A5(String strObjectName) { + a4_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_a_00200_A6 { + Cycle_a_00200_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00200_A6(String strObjectName) { + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_a_00200_A7 { + int a; + int sum; + String strObjectName; + + Cycle_a_00200_A7(String strObjectName) { + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + + +public class Cycle_am_00200 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00200 A1_Cycle_am_00200 = new ThreadRc_Cycle_am_00200(); + ThreadRc_Cycle_am_00200 A2_Cycle_am_00200 = new ThreadRc_Cycle_am_00200(); + ThreadRc_Cycle_am_00200 A3_Cycle_am_00200 = new ThreadRc_Cycle_am_00200(); + ThreadRc_Cycle_am_00200 A4_Cycle_am_00200 = new ThreadRc_Cycle_am_00200(); + ThreadRc_Cycle_am_00200 A5_Cycle_am_00200 = new ThreadRc_Cycle_am_00200(); + ThreadRc_Cycle_am_00200 A6_Cycle_am_00200 = new ThreadRc_Cycle_am_00200(); + + A1_Cycle_am_00200.start(); + A2_Cycle_am_00200.start(); + A3_Cycle_am_00200.start(); + A4_Cycle_am_00200.start(); + A5_Cycle_am_00200.start(); + A6_Cycle_am_00200.start(); + + try { + A1_Cycle_am_00200.join(); + A2_Cycle_am_00200.join(); + A3_Cycle_am_00200.join(); + A4_Cycle_am_00200.join(); + A5_Cycle_am_00200.join(); + A6_Cycle_am_00200.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00200.check() && A2_Cycle_am_00200.check() && A3_Cycle_am_00200.check() && A4_Cycle_am_00200.check() && A5_Cycle_am_00200.check() && A6_Cycle_am_00200.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0123-rc-function-RC_Thread01-Cycle_am_00210/Cycle_am_00210.java b/test/testsuite/ouroboros/rc_test/RC0123-rc-function-RC_Thread01-Cycle_am_00210/Cycle_am_00210.java new file mode 100755 index 0000000000000000000000000000000000000000..c8541619f91cf8ae0c1adc2bb5be029b12b55d26 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0123-rc-function-RC_Thread01-Cycle_am_00210/Cycle_am_00210.java @@ -0,0 +1,233 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00210.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00210 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00210.java + *- @ExecuteClass: Cycle_am_00210 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_am_00210 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00210_A1 a1_main = new Cycle_a_00210_A1("a1_main"); + Cycle_a_00210_A4 a4_main = new Cycle_a_00210_A4("a4_main"); + a1_main.a2_0 = new Cycle_a_00210_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00210_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00210_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a4_0 = a4_main; + a4_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a6_0 = new Cycle_a_00210_A6("a6_0"); + a1_main.a2_0.a3_0.a6_0.a7_0 = new Cycle_a_00210_A7("a7_0"); + a1_main.a2_0.a3_0.a6_0.a7_0.a3_0 = a1_main.a2_0.a3_0; + + a1_main.add(); + a4_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a6_0.add(); + a1_main.a2_0.a3_0.a6_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a1_main.a2_0.a3_0.a6_0.sum + a1_main.a2_0.a3_0.a6_0.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1662) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00210_A1 { + Cycle_a_00210_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00210_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00210_A2 { + Cycle_a_00210_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00210_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00210_A3 { + Cycle_a_00210_A1 a1_0; + Cycle_a_00210_A5 a5_0; + Cycle_a_00210_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00210_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a6_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a + a6_0.a; + } + } + + class Cycle_a_00210_A4 { + Cycle_a_00210_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00210_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00210_A5 { + Cycle_a_00210_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00210_A5(String strObjectName) { + a4_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_a_00210_A6 { + Cycle_a_00210_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00210_A6(String strObjectName) { + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_a_00210_A7 { + Cycle_a_00210_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00210_A7(String strObjectName) { + a3_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } +} + + +public class Cycle_am_00210 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00210 A1_Cycle_am_00210 = new ThreadRc_Cycle_am_00210(); + ThreadRc_Cycle_am_00210 A2_Cycle_am_00210 = new ThreadRc_Cycle_am_00210(); + ThreadRc_Cycle_am_00210 A3_Cycle_am_00210 = new ThreadRc_Cycle_am_00210(); + ThreadRc_Cycle_am_00210 A4_Cycle_am_00210 = new ThreadRc_Cycle_am_00210(); + ThreadRc_Cycle_am_00210 A5_Cycle_am_00210 = new ThreadRc_Cycle_am_00210(); + ThreadRc_Cycle_am_00210 A6_Cycle_am_00210 = new ThreadRc_Cycle_am_00210(); + + A1_Cycle_am_00210.start(); + A2_Cycle_am_00210.start(); + A3_Cycle_am_00210.start(); + A4_Cycle_am_00210.start(); + A5_Cycle_am_00210.start(); + A6_Cycle_am_00210.start(); + + try { + A1_Cycle_am_00210.join(); + A2_Cycle_am_00210.join(); + A3_Cycle_am_00210.join(); + A4_Cycle_am_00210.join(); + A5_Cycle_am_00210.join(); + A6_Cycle_am_00210.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00210.check() && A2_Cycle_am_00210.check() && A3_Cycle_am_00210.check() && A4_Cycle_am_00210.check() && A5_Cycle_am_00210.check() && A6_Cycle_am_00210.check()) + System.out.println("ExpectResult"); + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0124-rc-function-RC_Thread01-Cycle_am_00220/Cycle_am_00220.java b/test/testsuite/ouroboros/rc_test/RC0124-rc-function-RC_Thread01-Cycle_am_00220/Cycle_am_00220.java new file mode 100755 index 0000000000000000000000000000000000000000..acda6569c83b5c2bcedbe99092edae84c7f0f9c7 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0124-rc-function-RC_Thread01-Cycle_am_00220/Cycle_am_00220.java @@ -0,0 +1,234 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00220.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00220 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00220.java + *- @ExecuteClass: Cycle_am_00220 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00220 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00220_A1 a1_main = new Cycle_a_00220_A1("a1_main"); + Cycle_a_00220_A4 a4_main = new Cycle_a_00220_A4("a4_main"); + Cycle_a_00220_A6 a6_main = new Cycle_a_00220_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00220_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00220_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00220_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a4_0 = a4_main; + a4_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a5_0.a7_0 = new Cycle_a_00220_A7("a7_0"); + a6_main.a7_0 = a1_main.a2_0.a3_0.a5_0.a7_0; + a6_main.a5_0 = a1_main.a2_0.a3_0.a5_0; + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1772) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00220_A1 { + Cycle_a_00220_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00220_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00220_A2 { + Cycle_a_00220_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00220_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00220_A3 { + Cycle_a_00220_A1 a1_0; + Cycle_a_00220_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00220_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_00220_A4 { + Cycle_a_00220_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00220_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00220_A5 { + Cycle_a_00220_A4 a4_0; + Cycle_a_00220_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00220_A5(String strObjectName) { + a4_0 = null; + a7_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a4_0.a + a7_0.a; + } + } + + class Cycle_a_00220_A6 { + Cycle_a_00220_A5 a5_0; + Cycle_a_00220_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00220_A6(String strObjectName) { + a5_0 = null; + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a5_0.a + a7_0.a; + } + } + + class Cycle_a_00220_A7 { + int a; + int sum; + String strObjectName; + + Cycle_a_00220_A7(String strObjectName) { + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + + +public class Cycle_am_00220 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00220 A1_Cycle_am_00220 = new ThreadRc_Cycle_am_00220(); + ThreadRc_Cycle_am_00220 A2_Cycle_am_00220 = new ThreadRc_Cycle_am_00220(); + ThreadRc_Cycle_am_00220 A3_Cycle_am_00220 = new ThreadRc_Cycle_am_00220(); + ThreadRc_Cycle_am_00220 A4_Cycle_am_00220 = new ThreadRc_Cycle_am_00220(); + ThreadRc_Cycle_am_00220 A5_Cycle_am_00220 = new ThreadRc_Cycle_am_00220(); + ThreadRc_Cycle_am_00220 A6_Cycle_am_00220 = new ThreadRc_Cycle_am_00220(); + + A1_Cycle_am_00220.start(); + A2_Cycle_am_00220.start(); + A3_Cycle_am_00220.start(); + A4_Cycle_am_00220.start(); + A5_Cycle_am_00220.start(); + A6_Cycle_am_00220.start(); + + try { + A1_Cycle_am_00220.join(); + A2_Cycle_am_00220.join(); + A3_Cycle_am_00220.join(); + A4_Cycle_am_00220.join(); + A5_Cycle_am_00220.join(); + A6_Cycle_am_00220.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00220.check() && A2_Cycle_am_00220.check() && A3_Cycle_am_00220.check() && A4_Cycle_am_00220.check() && A5_Cycle_am_00220.check() && A6_Cycle_am_00220.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0125-rc-function-RC_Thread01-Cycle_am_00230/Cycle_am_00230.java b/test/testsuite/ouroboros/rc_test/RC0125-rc-function-RC_Thread01-Cycle_am_00230/Cycle_am_00230.java new file mode 100755 index 0000000000000000000000000000000000000000..a55f1e1d663c0b9ac90dc0c9bcf4649cd87b6e93 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0125-rc-function-RC_Thread01-Cycle_am_00230/Cycle_am_00230.java @@ -0,0 +1,233 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00230.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00230 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00230.java + *- @ExecuteClass: Cycle_am_00230 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00230 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00230_A1 a1_main = new Cycle_a_00230_A1("a1_main"); + Cycle_a_00230_A5 a5_main = new Cycle_a_00230_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00230_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00230_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00230_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = a5_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a7_0 = new Cycle_a_00230_A7("a7_0"); + a5_main.a6_0 = new Cycle_a_00230_A6("a6_0"); + a5_main.a6_0.a7_0 = a5_main.a7_0; + + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a5_main.a7_0.add(); + a5_main.a6_0.add(); + + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a5_main.a6_0.sum + a5_main.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1773) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00230_A1 { + Cycle_a_00230_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00230_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00230_A2 { + Cycle_a_00230_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00230_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00230_A3 { + Cycle_a_00230_A1 a1_0; + Cycle_a_00230_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00230_A3(String strObjectName) { + a1_0 = null; + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a4_0.a; + } + } + + class Cycle_a_00230_A4 { + Cycle_a_00230_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00230_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_a_00230_A5 { + Cycle_a_00230_A3 a3_0; + Cycle_a_00230_A6 a6_0; + Cycle_a_00230_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00230_A5(String strObjectName) { + a3_0 = null; + a6_0 = null; + a7_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a6_0.a + a7_0.a; + } + } + + class Cycle_a_00230_A6 { + Cycle_a_00230_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00230_A6(String strObjectName) { + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_a_00230_A7 { + int a; + int sum; + String strObjectName; + + Cycle_a_00230_A7(String strObjectName) { + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + + +public class Cycle_am_00230 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00230 A1_Cycle_am_00230 = new ThreadRc_Cycle_am_00230(); + ThreadRc_Cycle_am_00230 A2_Cycle_am_00230 = new ThreadRc_Cycle_am_00230(); + ThreadRc_Cycle_am_00230 A3_Cycle_am_00230 = new ThreadRc_Cycle_am_00230(); + ThreadRc_Cycle_am_00230 A4_Cycle_am_00230 = new ThreadRc_Cycle_am_00230(); + ThreadRc_Cycle_am_00230 A5_Cycle_am_00230 = new ThreadRc_Cycle_am_00230(); + ThreadRc_Cycle_am_00230 A6_Cycle_am_00230 = new ThreadRc_Cycle_am_00230(); + + A1_Cycle_am_00230.start(); + A2_Cycle_am_00230.start(); + A3_Cycle_am_00230.start(); + A4_Cycle_am_00230.start(); + A5_Cycle_am_00230.start(); + A6_Cycle_am_00230.start(); + + try { + A1_Cycle_am_00230.join(); + A2_Cycle_am_00230.join(); + A3_Cycle_am_00230.join(); + A4_Cycle_am_00230.join(); + A5_Cycle_am_00230.join(); + A6_Cycle_am_00230.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00230.check() && A2_Cycle_am_00230.check() && A3_Cycle_am_00230.check() && A4_Cycle_am_00230.check() && A5_Cycle_am_00230.check() && A6_Cycle_am_00230.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0126-rc-function-RC_Thread01-Cycle_am_00240/Cycle_am_00240.java b/test/testsuite/ouroboros/rc_test/RC0126-rc-function-RC_Thread01-Cycle_am_00240/Cycle_am_00240.java new file mode 100755 index 0000000000000000000000000000000000000000..0655c4aaa1f10952886a6f969146b15a6891c1bc --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0126-rc-function-RC_Thread01-Cycle_am_00240/Cycle_am_00240.java @@ -0,0 +1,233 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00240.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00240 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00240.java + *- @ExecuteClass: Cycle_am_00240 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00240 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00240_A1 a1_main = new Cycle_a_00240_A1("a1_main"); + Cycle_a_00240_A5 a5_main = new Cycle_a_00240_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00240_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00240_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00240_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = a5_main; + a1_main.a6_0 = new Cycle_a_00240_A6("a6_0"); + a1_main.a6_0.a7_0 = new Cycle_a_00240_A7("a7_0"); + a1_main.a6_0.a7_0.a1_0 = a1_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a6_0.add(); + a1_main.a6_0.a7_0.add(); + + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a6_0.sum + a1_main.a6_0.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1660) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00240_A1 { + Cycle_a_00240_A2 a2_0; + Cycle_a_00240_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00240_A1(String strObjectName) { + a2_0 = null; + a6_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a6_0.a; + } + } + + class Cycle_a_00240_A2 { + Cycle_a_00240_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00240_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00240_A3 { + Cycle_a_00240_A1 a1_0; + Cycle_a_00240_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00240_A3(String strObjectName) { + a1_0 = null; + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a4_0.a; + } + } + + class Cycle_a_00240_A4 { + Cycle_a_00240_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00240_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_a_00240_A5 { + Cycle_a_00240_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00240_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00240_A6 { + Cycle_a_00240_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00240_A6(String strObjectName) { + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_a_00240_A7 { + Cycle_a_00240_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00240_A7(String strObjectName) { + a1_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } +} + + +public class Cycle_am_00240 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00240 A1_Cycle_am_00240 = new ThreadRc_Cycle_am_00240(); + ThreadRc_Cycle_am_00240 A2_Cycle_am_00240 = new ThreadRc_Cycle_am_00240(); + ThreadRc_Cycle_am_00240 A3_Cycle_am_00240 = new ThreadRc_Cycle_am_00240(); + ThreadRc_Cycle_am_00240 A4_Cycle_am_00240 = new ThreadRc_Cycle_am_00240(); + ThreadRc_Cycle_am_00240 A5_Cycle_am_00240 = new ThreadRc_Cycle_am_00240(); + ThreadRc_Cycle_am_00240 A6_Cycle_am_00240 = new ThreadRc_Cycle_am_00240(); + + A1_Cycle_am_00240.start(); + A2_Cycle_am_00240.start(); + A3_Cycle_am_00240.start(); + A4_Cycle_am_00240.start(); + A5_Cycle_am_00240.start(); + A6_Cycle_am_00240.start(); + + try { + A1_Cycle_am_00240.join(); + A2_Cycle_am_00240.join(); + A3_Cycle_am_00240.join(); + A4_Cycle_am_00240.join(); + A5_Cycle_am_00240.join(); + A6_Cycle_am_00240.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00240.check() && A2_Cycle_am_00240.check() && A3_Cycle_am_00240.check() && A4_Cycle_am_00240.check() && A5_Cycle_am_00240.check() && A6_Cycle_am_00240.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0127-rc-function-RC_Thread01-Cycle_am_00250/Cycle_am_00250.java b/test/testsuite/ouroboros/rc_test/RC0127-rc-function-RC_Thread01-Cycle_am_00250/Cycle_am_00250.java new file mode 100755 index 0000000000000000000000000000000000000000..2b835e3ee5859b6ba73785549567ee4c76887f07 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0127-rc-function-RC_Thread01-Cycle_am_00250/Cycle_am_00250.java @@ -0,0 +1,191 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00250.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00250 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00250.java + *- @ExecuteClass: Cycle_am_00250 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00250 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00250_A1 a1_main = new Cycle_a_00250_A1("a1_main"); + Cycle_a_00250_A6 a6_main = new Cycle_a_00250_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00250_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00250_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00250_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1238) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00250_A1 { + Cycle_a_00250_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00250_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00250_A2 { + Cycle_a_00250_A1 a1_0; + Cycle_a_00250_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00250_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_00250_A3 { + Cycle_a_00250_A1 a1_0; + Cycle_a_00250_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00250_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_00250_A5 { + Cycle_a_00250_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00250_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00250_A6 { + Cycle_a_00250_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00250_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } +} + + +public class Cycle_am_00250 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00250 A1_Cycle_am_00250 = new ThreadRc_Cycle_am_00250(); + ThreadRc_Cycle_am_00250 A2_Cycle_am_00250 = new ThreadRc_Cycle_am_00250(); + ThreadRc_Cycle_am_00250 A3_Cycle_am_00250 = new ThreadRc_Cycle_am_00250(); + ThreadRc_Cycle_am_00250 A4_Cycle_am_00250 = new ThreadRc_Cycle_am_00250(); + ThreadRc_Cycle_am_00250 A5_Cycle_am_00250 = new ThreadRc_Cycle_am_00250(); + ThreadRc_Cycle_am_00250 A6_Cycle_am_00250 = new ThreadRc_Cycle_am_00250(); + + A1_Cycle_am_00250.start(); + A2_Cycle_am_00250.start(); + A3_Cycle_am_00250.start(); + A4_Cycle_am_00250.start(); + A5_Cycle_am_00250.start(); + A6_Cycle_am_00250.start(); + + try { + A1_Cycle_am_00250.join(); + A2_Cycle_am_00250.join(); + A3_Cycle_am_00250.join(); + A4_Cycle_am_00250.join(); + A5_Cycle_am_00250.join(); + A6_Cycle_am_00250.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00250.check() && A2_Cycle_am_00250.check() && A3_Cycle_am_00250.check() && A4_Cycle_am_00250.check() && A5_Cycle_am_00250.check() && A6_Cycle_am_00250.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0128-rc-function-RC_Thread01-Cycle_am_00260/Cycle_am_00260.java b/test/testsuite/ouroboros/rc_test/RC0128-rc-function-RC_Thread01-Cycle_am_00260/Cycle_am_00260.java new file mode 100755 index 0000000000000000000000000000000000000000..687c680d4355a764edf1922a6967dd8239036647 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0128-rc-function-RC_Thread01-Cycle_am_00260/Cycle_am_00260.java @@ -0,0 +1,191 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00260.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00260 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00260.java + *- @ExecuteClass: Cycle_am_00260 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00260 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00260_A1 a1_main = new Cycle_a_00260_A1("a1_main"); + Cycle_a_00260_A6 a6_main = new Cycle_a_00260_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00260_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00260_A3("a3_0"); + a1_main.a2_0.a3_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00260_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1239) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00260_A1 { + Cycle_a_00260_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00260_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00260_A2 { + Cycle_a_00260_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00260_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00260_A3 { + Cycle_a_00260_A1 a1_0; + Cycle_a_00260_A2 a2_0; + Cycle_a_00260_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00260_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a2_0.a + a5_0.a; + } + } + + class Cycle_a_00260_A5 { + Cycle_a_00260_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00260_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00260_A6 { + Cycle_a_00260_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00260_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } +} + + +public class Cycle_am_00260 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00260 A1_Cycle_am_00260 = new ThreadRc_Cycle_am_00260(); + ThreadRc_Cycle_am_00260 A2_Cycle_am_00260 = new ThreadRc_Cycle_am_00260(); + ThreadRc_Cycle_am_00260 A3_Cycle_am_00260 = new ThreadRc_Cycle_am_00260(); + ThreadRc_Cycle_am_00260 A4_Cycle_am_00260 = new ThreadRc_Cycle_am_00260(); + ThreadRc_Cycle_am_00260 A5_Cycle_am_00260 = new ThreadRc_Cycle_am_00260(); + ThreadRc_Cycle_am_00260 A6_Cycle_am_00260 = new ThreadRc_Cycle_am_00260(); + + A1_Cycle_am_00260.start(); + A2_Cycle_am_00260.start(); + A3_Cycle_am_00260.start(); + A4_Cycle_am_00260.start(); + A5_Cycle_am_00260.start(); + A6_Cycle_am_00260.start(); + + try { + A1_Cycle_am_00260.join(); + A2_Cycle_am_00260.join(); + A3_Cycle_am_00260.join(); + A4_Cycle_am_00260.join(); + A5_Cycle_am_00260.join(); + A6_Cycle_am_00260.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00260.check() && A2_Cycle_am_00260.check() && A3_Cycle_am_00260.check() && A4_Cycle_am_00260.check() && A5_Cycle_am_00260.check() && A6_Cycle_am_00260.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0129-rc-function-RC_Thread01-Cycle_am_00270/Cycle_am_00270.java b/test/testsuite/ouroboros/rc_test/RC0129-rc-function-RC_Thread01-Cycle_am_00270/Cycle_am_00270.java new file mode 100755 index 0000000000000000000000000000000000000000..12d6acfeb6500a908f6c01e49173aa180d43ba4c --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0129-rc-function-RC_Thread01-Cycle_am_00270/Cycle_am_00270.java @@ -0,0 +1,191 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00270.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00270 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00270.java + *- @ExecuteClass: Cycle_am_00270 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00270 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00270_A1 a1_main = new Cycle_a_00270_A1("a1_main"); + Cycle_a_00270_A6 a6_main = new Cycle_a_00270_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00270_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00270_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00270_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1240) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00270_A1 { + Cycle_a_00270_A2 a2_0; + Cycle_a_00270_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00270_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } + } + + class Cycle_a_00270_A2 { + Cycle_a_00270_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00270_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00270_A3 { + Cycle_a_00270_A1 a1_0; + Cycle_a_00270_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00270_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_00270_A5 { + Cycle_a_00270_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00270_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00270_A6 { + Cycle_a_00270_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00270_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } +} + + +public class Cycle_am_00270 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00270 A1_Cycle_am_00270 = new ThreadRc_Cycle_am_00270(); + ThreadRc_Cycle_am_00270 A2_Cycle_am_00270 = new ThreadRc_Cycle_am_00270(); + ThreadRc_Cycle_am_00270 A3_Cycle_am_00270 = new ThreadRc_Cycle_am_00270(); + ThreadRc_Cycle_am_00270 A4_Cycle_am_00270 = new ThreadRc_Cycle_am_00270(); + ThreadRc_Cycle_am_00270 A5_Cycle_am_00270 = new ThreadRc_Cycle_am_00270(); + ThreadRc_Cycle_am_00270 A6_Cycle_am_00270 = new ThreadRc_Cycle_am_00270(); + + A1_Cycle_am_00270.start(); + A2_Cycle_am_00270.start(); + A3_Cycle_am_00270.start(); + A4_Cycle_am_00270.start(); + A5_Cycle_am_00270.start(); + A6_Cycle_am_00270.start(); + + try { + A1_Cycle_am_00270.join(); + A2_Cycle_am_00270.join(); + A3_Cycle_am_00270.join(); + A4_Cycle_am_00270.join(); + A5_Cycle_am_00270.join(); + A6_Cycle_am_00270.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00270.check() && A2_Cycle_am_00270.check() && A3_Cycle_am_00270.check() && A4_Cycle_am_00270.check() && A5_Cycle_am_00270.check() && A6_Cycle_am_00270.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0130-rc-function-RC_Thread01-Cycle_am_00280/Cycle_am_00280.java b/test/testsuite/ouroboros/rc_test/RC0130-rc-function-RC_Thread01-Cycle_am_00280/Cycle_am_00280.java new file mode 100755 index 0000000000000000000000000000000000000000..9ff12978d6889d8f2a13bc9d97ce20891a1bf5a8 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0130-rc-function-RC_Thread01-Cycle_am_00280/Cycle_am_00280.java @@ -0,0 +1,197 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00280.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00280 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00280.java + *- @ExecuteClass: Cycle_am_00280 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00280 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00280_A1 a1_main = new Cycle_a_00280_A1("a1_main"); + Cycle_a_00280_A6 a6_main = new Cycle_a_00280_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00280_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00280_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00280_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a3_0 = a1_main.a2_0.a3_0; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1443) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00280_A1 { + Cycle_a_00280_A2 a2_0; + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00280_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } + } + + class Cycle_a_00280_A2 { + Cycle_a_00280_A1 a1_0; + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00280_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_00280_A3 { + Cycle_a_00280_A1 a1_0; + Cycle_a_00280_A2 a2_0; + Cycle_a_00280_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00280_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a2_0.a + a5_0.a; + } + } + + class Cycle_a_00280_A5 { + Cycle_a_00280_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00280_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00280_A6 { + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00280_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } +} + + +public class Cycle_am_00280 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00280 A1_Cycle_am_00280 = new ThreadRc_Cycle_am_00280(); + ThreadRc_Cycle_am_00280 A2_Cycle_am_00280 = new ThreadRc_Cycle_am_00280(); + ThreadRc_Cycle_am_00280 A3_Cycle_am_00280 = new ThreadRc_Cycle_am_00280(); + ThreadRc_Cycle_am_00280 A4_Cycle_am_00280 = new ThreadRc_Cycle_am_00280(); + ThreadRc_Cycle_am_00280 A5_Cycle_am_00280 = new ThreadRc_Cycle_am_00280(); + ThreadRc_Cycle_am_00280 A6_Cycle_am_00280 = new ThreadRc_Cycle_am_00280(); + + A1_Cycle_am_00280.start(); + A2_Cycle_am_00280.start(); + A3_Cycle_am_00280.start(); + A4_Cycle_am_00280.start(); + A5_Cycle_am_00280.start(); + A6_Cycle_am_00280.start(); + + try { + A1_Cycle_am_00280.join(); + A2_Cycle_am_00280.join(); + A3_Cycle_am_00280.join(); + A4_Cycle_am_00280.join(); + A5_Cycle_am_00280.join(); + A6_Cycle_am_00280.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00280.check() && A2_Cycle_am_00280.check() && A3_Cycle_am_00280.check() && A4_Cycle_am_00280.check() && A5_Cycle_am_00280.check() && A6_Cycle_am_00280.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0131-rc-function-RC_Thread01-Cycle_am_00290/Cycle_am_00290.java b/test/testsuite/ouroboros/rc_test/RC0131-rc-function-RC_Thread01-Cycle_am_00290/Cycle_am_00290.java new file mode 100755 index 0000000000000000000000000000000000000000..14b12409925064cf725338e7384f251bc30f9619 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0131-rc-function-RC_Thread01-Cycle_am_00290/Cycle_am_00290.java @@ -0,0 +1,213 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00290.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00290 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00290.java + *- @ExecuteClass: Cycle_am_00290 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00290 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00290_A1 a1_main = new Cycle_a_00290_A1("a1_main"); + Cycle_a_00290_A5 a5_main = new Cycle_a_00290_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00290_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00290_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00290_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = a5_main; + a1_main.a2_0.a3_0.a6_0 = new Cycle_a_00290_A6("a6_0"); + a1_main.a2_0.a3_0.a6_0.a2_0 = a1_main.a2_0; + a5_main.a3_0 = a1_main.a2_0.a3_0; + + + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a6_0.add(); + + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a6_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1447) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00290_A1 { + Cycle_a_00290_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00290_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00290_A2 { + Cycle_a_00290_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00290_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00290_A3 { + Cycle_a_00290_A1 a1_0; + Cycle_a_00290_A4 a4_0; + Cycle_a_00290_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00290_A3(String strObjectName) { + a1_0 = null; + a4_0 = null; + a6_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a4_0.a + a6_0.a; + } + } + + class Cycle_a_00290_A4 { + Cycle_a_00290_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00290_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_a_00290_A5 { + Cycle_a_00290_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00290_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00290_A6 { + Cycle_a_00290_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00290_A6(String strObjectName) { + a2_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } +} + + +public class Cycle_am_00290 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00290 A1_Cycle_am_00290 = new ThreadRc_Cycle_am_00290(); + ThreadRc_Cycle_am_00290 A2_Cycle_am_00290 = new ThreadRc_Cycle_am_00290(); + ThreadRc_Cycle_am_00290 A3_Cycle_am_00290 = new ThreadRc_Cycle_am_00290(); + ThreadRc_Cycle_am_00290 A4_Cycle_am_00290 = new ThreadRc_Cycle_am_00290(); + ThreadRc_Cycle_am_00290 A5_Cycle_am_00290 = new ThreadRc_Cycle_am_00290(); + ThreadRc_Cycle_am_00290 A6_Cycle_am_00290 = new ThreadRc_Cycle_am_00290(); + + A1_Cycle_am_00290.start(); + A2_Cycle_am_00290.start(); + A3_Cycle_am_00290.start(); + A4_Cycle_am_00290.start(); + A5_Cycle_am_00290.start(); + A6_Cycle_am_00290.start(); + + try { + A1_Cycle_am_00290.join(); + A2_Cycle_am_00290.join(); + A3_Cycle_am_00290.join(); + A4_Cycle_am_00290.join(); + A5_Cycle_am_00290.join(); + A6_Cycle_am_00290.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00290.check() && A2_Cycle_am_00290.check() && A3_Cycle_am_00290.check() && A4_Cycle_am_00290.check() && A5_Cycle_am_00290.check() && A6_Cycle_am_00290.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0132-rc-function-RC_Thread01-Cycle_am_00300/Cycle_am_00300.java b/test/testsuite/ouroboros/rc_test/RC0132-rc-function-RC_Thread01-Cycle_am_00300/Cycle_am_00300.java new file mode 100755 index 0000000000000000000000000000000000000000..497eeb849c2330f1ca90404c5f4bb7740fc48376 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0132-rc-function-RC_Thread01-Cycle_am_00300/Cycle_am_00300.java @@ -0,0 +1,213 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00300.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00300 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00300.java + *- @ExecuteClass: Cycle_am_00300 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00300 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00300_A1 a1_main = new Cycle_a_00300_A1("a1_main"); + Cycle_a_00300_A5 a5_main = new Cycle_a_00300_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00300_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00300_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00300_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = a5_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a3_0.a4_0.a6_0 = new Cycle_a_00300_A6("a6_0"); + a5_main.a3_0.a4_0.a6_0.a3_0 = a1_main.a2_0.a3_0; + a5_main.a3_0.a4_0.a5_0 = a5_main; + + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); + + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a6_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1448) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00300_A1 { + Cycle_a_00300_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00300_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00300_A2 { + Cycle_a_00300_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00300_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00300_A3 { + Cycle_a_00300_A1 a1_0; + Cycle_a_00300_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00300_A3(String strObjectName) { + a1_0 = null; + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a4_0.a; + } + } + + class Cycle_a_00300_A4 { + Cycle_a_00300_A5 a5_0; + Cycle_a_00300_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00300_A4(String strObjectName) { + a5_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a + a6_0.a; + } + } + + class Cycle_a_00300_A5 { + Cycle_a_00300_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00300_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00300_A6 { + Cycle_a_00300_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00300_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } +} + + +public class Cycle_am_00300 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00300 A1_Cycle_am_00300 = new ThreadRc_Cycle_am_00300(); + ThreadRc_Cycle_am_00300 A2_Cycle_am_00300 = new ThreadRc_Cycle_am_00300(); + ThreadRc_Cycle_am_00300 A3_Cycle_am_00300 = new ThreadRc_Cycle_am_00300(); + ThreadRc_Cycle_am_00300 A4_Cycle_am_00300 = new ThreadRc_Cycle_am_00300(); + ThreadRc_Cycle_am_00300 A5_Cycle_am_00300 = new ThreadRc_Cycle_am_00300(); + ThreadRc_Cycle_am_00300 A6_Cycle_am_00300 = new ThreadRc_Cycle_am_00300(); + + A1_Cycle_am_00300.start(); + A2_Cycle_am_00300.start(); + A3_Cycle_am_00300.start(); + A4_Cycle_am_00300.start(); + A5_Cycle_am_00300.start(); + A6_Cycle_am_00300.start(); + + try { + A1_Cycle_am_00300.join(); + A2_Cycle_am_00300.join(); + A3_Cycle_am_00300.join(); + A4_Cycle_am_00300.join(); + A5_Cycle_am_00300.join(); + A6_Cycle_am_00300.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00300.check() && A2_Cycle_am_00300.check() && A3_Cycle_am_00300.check() && A4_Cycle_am_00300.check() && A5_Cycle_am_00300.check() && A6_Cycle_am_00300.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0133-rc-function-RC_Thread01-Cycle_am_00310/Cycle_am_00310.java b/test/testsuite/ouroboros/rc_test/RC0133-rc-function-RC_Thread01-Cycle_am_00310/Cycle_am_00310.java new file mode 100755 index 0000000000000000000000000000000000000000..01b19489468c6ac2af2e8385a92c1a9be5cc3109 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0133-rc-function-RC_Thread01-Cycle_am_00310/Cycle_am_00310.java @@ -0,0 +1,217 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00310.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00310 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00310.java + *- @ExecuteClass: Cycle_am_00310 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00310 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00310_A1 a1_main = new Cycle_a_00310_A1("a1_main"); + Cycle_a_00310_A4 a4_main = new Cycle_a_00310_A4("a4_main"); + Cycle_a_00310_A6 a6_main = new Cycle_a_00310_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00310_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00310_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00310_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a4_0 = a4_main; + a6_main.a1_0 = a1_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a6_main.a3_0.a5_0 = a1_main.a2_0.a3_0.a5_0; + a4_main.a6_0 = a6_main; + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1552) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00310_A1 { + Cycle_a_00310_A2 a2_0; + Cycle_a_00310_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00310_A1(String strObjectName) { + a2_0 = null; + a4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a4_0.a; + } + } + + class Cycle_a_00310_A2 { + Cycle_a_00310_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00310_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00310_A3 { + Cycle_a_00310_A1 a1_0; + Cycle_a_00310_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00310_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_00310_A4 { + Cycle_a_00310_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00310_A4(String strObjectName) { + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00310_A5 { + Cycle_a_00310_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00310_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00310_A6 { + Cycle_a_00310_A1 a1_0; + Cycle_a_00310_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00310_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } +} + + +public class Cycle_am_00310 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00310 A1_Cycle_am_00310 = new ThreadRc_Cycle_am_00310(); + ThreadRc_Cycle_am_00310 A2_Cycle_am_00310 = new ThreadRc_Cycle_am_00310(); + ThreadRc_Cycle_am_00310 A3_Cycle_am_00310 = new ThreadRc_Cycle_am_00310(); + ThreadRc_Cycle_am_00310 A4_Cycle_am_00310 = new ThreadRc_Cycle_am_00310(); + ThreadRc_Cycle_am_00310 A5_Cycle_am_00310 = new ThreadRc_Cycle_am_00310(); + ThreadRc_Cycle_am_00310 A6_Cycle_am_00310 = new ThreadRc_Cycle_am_00310(); + + A1_Cycle_am_00310.start(); + A2_Cycle_am_00310.start(); + A3_Cycle_am_00310.start(); + A4_Cycle_am_00310.start(); + A5_Cycle_am_00310.start(); + A6_Cycle_am_00310.start(); + + try { + A1_Cycle_am_00310.join(); + A2_Cycle_am_00310.join(); + A3_Cycle_am_00310.join(); + A4_Cycle_am_00310.join(); + A5_Cycle_am_00310.join(); + A6_Cycle_am_00310.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00310.check() && A2_Cycle_am_00310.check() && A3_Cycle_am_00310.check() && A4_Cycle_am_00310.check() && A5_Cycle_am_00310.check() && A6_Cycle_am_00310.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0134-rc-function-RC_Thread01-Cycle_am_00320/Cycle_am_00320.java b/test/testsuite/ouroboros/rc_test/RC0134-rc-function-RC_Thread01-Cycle_am_00320/Cycle_am_00320.java new file mode 100755 index 0000000000000000000000000000000000000000..3629b60330da9137c64036bd05ad10ae23a3c598 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0134-rc-function-RC_Thread01-Cycle_am_00320/Cycle_am_00320.java @@ -0,0 +1,216 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00320.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00320 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00320.java + *- @ExecuteClass: Cycle_am_00320 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00320 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00320_A1 a1_main = new Cycle_a_00320_A1("a1_main"); + Cycle_a_00320_A4 a4_main = new Cycle_a_00320_A4("a4_main"); + Cycle_a_00320_A6 a6_main = new Cycle_a_00320_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00320_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00320_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00320_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a4_main.a5_0 = a1_main.a2_0.a3_0.a5_0; + a6_main.a4_0 = a4_main; + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1551) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00320_A1 { + Cycle_a_00320_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00320_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00320_A2 { + Cycle_a_00320_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00320_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00320_A3 { + Cycle_a_00320_A1 a1_0; + Cycle_a_00320_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00320_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_00320_A4 { + Cycle_a_00320_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00320_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_a_00320_A5 { + Cycle_a_00320_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00320_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00320_A6 { + Cycle_a_00320_A1 a1_0; + Cycle_a_00320_A3 a3_0; + Cycle_a_00320_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00320_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } + } +} + + +public class Cycle_am_00320 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00320 A1_Cycle_am_00320 = new ThreadRc_Cycle_am_00320(); + ThreadRc_Cycle_am_00320 A2_Cycle_am_00320 = new ThreadRc_Cycle_am_00320(); + ThreadRc_Cycle_am_00320 A3_Cycle_am_00320 = new ThreadRc_Cycle_am_00320(); + ThreadRc_Cycle_am_00320 A4_Cycle_am_00320 = new ThreadRc_Cycle_am_00320(); + ThreadRc_Cycle_am_00320 A5_Cycle_am_00320 = new ThreadRc_Cycle_am_00320(); + ThreadRc_Cycle_am_00320 A6_Cycle_am_00320 = new ThreadRc_Cycle_am_00320(); + + A1_Cycle_am_00320.start(); + A2_Cycle_am_00320.start(); + A3_Cycle_am_00320.start(); + A4_Cycle_am_00320.start(); + A5_Cycle_am_00320.start(); + A6_Cycle_am_00320.start(); + + try { + A1_Cycle_am_00320.join(); + A2_Cycle_am_00320.join(); + A3_Cycle_am_00320.join(); + A4_Cycle_am_00320.join(); + A5_Cycle_am_00320.join(); + A6_Cycle_am_00320.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00320.check() && A2_Cycle_am_00320.check() && A3_Cycle_am_00320.check() && A4_Cycle_am_00320.check() && A5_Cycle_am_00320.check() && A6_Cycle_am_00320.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0135-rc-function-RC_Thread01-Cycle_am_00330/Cycle_am_00330.java b/test/testsuite/ouroboros/rc_test/RC0135-rc-function-RC_Thread01-Cycle_am_00330/Cycle_am_00330.java new file mode 100755 index 0000000000000000000000000000000000000000..cdb16c29b171151613466e42cd777cdef74d25d6 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0135-rc-function-RC_Thread01-Cycle_am_00330/Cycle_am_00330.java @@ -0,0 +1,263 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00330.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00330 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00330.java + *- @ExecuteClass: Cycle_am_00330 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00330 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00330_A1 a1_main = new Cycle_a_00330_A1("a1_main"); + Cycle_a_00330_A4 a4_main = new Cycle_a_00330_A4("a4_main"); + Cycle_a_00330_A6 a6_main = new Cycle_a_00330_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00330_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00330_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00330_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00330_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00330_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a3_0 = a1_main.a2_0.a3_0; + a6_main.a1_0 = a1_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 2080) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00330_A1 { + Cycle_a_00330_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00330_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00330_A2 { + Cycle_a_00330_A3 a3_0; + Cycle_a_00330_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00330_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + + class Cycle_a_00330_A3 { + Cycle_a_00330_A1 a1_0; + Cycle_a_00330_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00330_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_00330_A4 { + Cycle_a_00330_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00330_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_00330_A5 { + Cycle_a_00330_A6 a6_0; + Cycle_a_00330_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00330_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + + class Cycle_a_00330_A6 { + Cycle_a_00330_A1 a1_0; + Cycle_a_00330_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00330_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_00330_A7 { + Cycle_a_00330_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00330_A7(String strObjectName) { + a3_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00330_A8 { + Cycle_a_00330_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00330_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } +} + + +public class Cycle_am_00330 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00330 A1_Cycle_am_00330 = new ThreadRc_Cycle_am_00330(); + ThreadRc_Cycle_am_00330 A2_Cycle_am_00330 = new ThreadRc_Cycle_am_00330(); + ThreadRc_Cycle_am_00330 A3_Cycle_am_00330 = new ThreadRc_Cycle_am_00330(); + ThreadRc_Cycle_am_00330 A4_Cycle_am_00330 = new ThreadRc_Cycle_am_00330(); + ThreadRc_Cycle_am_00330 A5_Cycle_am_00330 = new ThreadRc_Cycle_am_00330(); + ThreadRc_Cycle_am_00330 A6_Cycle_am_00330 = new ThreadRc_Cycle_am_00330(); + + A1_Cycle_am_00330.start(); + A2_Cycle_am_00330.start(); + A3_Cycle_am_00330.start(); + A4_Cycle_am_00330.start(); + A5_Cycle_am_00330.start(); + A6_Cycle_am_00330.start(); + + try { + A1_Cycle_am_00330.join(); + A2_Cycle_am_00330.join(); + A3_Cycle_am_00330.join(); + A4_Cycle_am_00330.join(); + A5_Cycle_am_00330.join(); + A6_Cycle_am_00330.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00330.check() && A2_Cycle_am_00330.check() && A3_Cycle_am_00330.check() && A4_Cycle_am_00330.check() && A5_Cycle_am_00330.check() && A6_Cycle_am_00330.check()) + System.out.println("ExpectResult"); + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0136-rc-function-RC_Thread01-Cycle_am_00340/Cycle_am_00340.java b/test/testsuite/ouroboros/rc_test/RC0136-rc-function-RC_Thread01-Cycle_am_00340/Cycle_am_00340.java new file mode 100755 index 0000000000000000000000000000000000000000..ed3368d97ca842d077c75b767f10a7d02cad6374 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0136-rc-function-RC_Thread01-Cycle_am_00340/Cycle_am_00340.java @@ -0,0 +1,262 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00340.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00340 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00340.java + *- @ExecuteClass: Cycle_am_00340 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00340 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00340_A1 a1_main = new Cycle_a_00340_A1("a1_main"); + Cycle_a_00340_A4 a4_main = new Cycle_a_00340_A4("a4_main"); + Cycle_a_00340_A6 a6_main = new Cycle_a_00340_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00340_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00340_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00340_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a2_0.a3_0.a8_0 = new Cycle_a_00340_A8("a8_0"); + a1_main.a2_0.a3_0.a8_0.a7_0 = new Cycle_a_00340_A7("a7_0"); + a1_main.a2_0.a3_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a6_main.a1_0 = a1_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a8_0.add(); + a1_main.a2_0.a3_0.a8_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a8_0.a7_0.sum + a6_main.a3_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 2079) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00340_A1 { + Cycle_a_00340_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00340_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00340_A2 { + Cycle_a_00340_A3 a3_0; + Cycle_a_00340_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00340_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + + class Cycle_a_00340_A3 { + Cycle_a_00340_A1 a1_0; + Cycle_a_00340_A5 a5_0; + Cycle_a_00340_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00340_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a8_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a + a8_0.a; + } + } + + class Cycle_a_00340_A4 { + Cycle_a_00340_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00340_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_00340_A5 { + Cycle_a_00340_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00340_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00340_A6 { + Cycle_a_00340_A1 a1_0; + Cycle_a_00340_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00340_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_00340_A7 { + Cycle_a_00340_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00340_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00340_A8 { + Cycle_a_00340_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00340_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } +} + + +public class Cycle_am_00340 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00340 A1_Cycle_am_00340 = new ThreadRc_Cycle_am_00340(); + ThreadRc_Cycle_am_00340 A2_Cycle_am_00340 = new ThreadRc_Cycle_am_00340(); + ThreadRc_Cycle_am_00340 A3_Cycle_am_00340 = new ThreadRc_Cycle_am_00340(); + ThreadRc_Cycle_am_00340 A4_Cycle_am_00340 = new ThreadRc_Cycle_am_00340(); + ThreadRc_Cycle_am_00340 A5_Cycle_am_00340 = new ThreadRc_Cycle_am_00340(); + ThreadRc_Cycle_am_00340 A6_Cycle_am_00340 = new ThreadRc_Cycle_am_00340(); + + A1_Cycle_am_00340.start(); + A2_Cycle_am_00340.start(); + A3_Cycle_am_00340.start(); + A4_Cycle_am_00340.start(); + A5_Cycle_am_00340.start(); + A6_Cycle_am_00340.start(); + + try { + A1_Cycle_am_00340.join(); + A2_Cycle_am_00340.join(); + A3_Cycle_am_00340.join(); + A4_Cycle_am_00340.join(); + A5_Cycle_am_00340.join(); + A6_Cycle_am_00340.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00340.check() && A2_Cycle_am_00340.check() && A3_Cycle_am_00340.check() && A4_Cycle_am_00340.check() && A5_Cycle_am_00340.check() && A6_Cycle_am_00340.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0137-rc-function-RC_Thread01-Cycle_am_00350/Cycle_am_00350.java b/test/testsuite/ouroboros/rc_test/RC0137-rc-function-RC_Thread01-Cycle_am_00350/Cycle_am_00350.java new file mode 100755 index 0000000000000000000000000000000000000000..4142c871a91a26d90c763dacaf01da9f66c10474 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0137-rc-function-RC_Thread01-Cycle_am_00350/Cycle_am_00350.java @@ -0,0 +1,262 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00350.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00350 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00350.java + *- @ExecuteClass: Cycle_am_00350 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00350 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00350_A1 a1_main = new Cycle_a_00350_A1("a1_main"); + Cycle_a_00350_A4 a4_main = new Cycle_a_00350_A4("a4_main"); + Cycle_a_00350_A6 a6_main = new Cycle_a_00350_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00350_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00350_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00350_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00350_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00350_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 2079) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00350_A1 { + Cycle_a_00350_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00350_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00350_A2 { + Cycle_a_00350_A3 a3_0; + Cycle_a_00350_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00350_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + + class Cycle_a_00350_A3 { + Cycle_a_00350_A1 a1_0; + Cycle_a_00350_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00350_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_00350_A4 { + Cycle_a_00350_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00350_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_00350_A5 { + Cycle_a_00350_A6 a6_0; + Cycle_a_00350_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00350_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + + class Cycle_a_00350_A6 { + Cycle_a_00350_A1 a1_0; + Cycle_a_00350_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00350_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_00350_A7 { + Cycle_a_00350_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00350_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00350_A8 { + Cycle_a_00350_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00350_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } +} + + +public class Cycle_am_00350 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00350 A1_Cycle_am_00350 = new ThreadRc_Cycle_am_00350(); + ThreadRc_Cycle_am_00350 A2_Cycle_am_00350 = new ThreadRc_Cycle_am_00350(); + ThreadRc_Cycle_am_00350 A3_Cycle_am_00350 = new ThreadRc_Cycle_am_00350(); + ThreadRc_Cycle_am_00350 A4_Cycle_am_00350 = new ThreadRc_Cycle_am_00350(); + ThreadRc_Cycle_am_00350 A5_Cycle_am_00350 = new ThreadRc_Cycle_am_00350(); + ThreadRc_Cycle_am_00350 A6_Cycle_am_00350 = new ThreadRc_Cycle_am_00350(); + + A1_Cycle_am_00350.start(); + A2_Cycle_am_00350.start(); + A3_Cycle_am_00350.start(); + A4_Cycle_am_00350.start(); + A5_Cycle_am_00350.start(); + A6_Cycle_am_00350.start(); + + try { + A1_Cycle_am_00350.join(); + A2_Cycle_am_00350.join(); + A3_Cycle_am_00350.join(); + A4_Cycle_am_00350.join(); + A5_Cycle_am_00350.join(); + A6_Cycle_am_00350.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00350.check() && A2_Cycle_am_00350.check() && A3_Cycle_am_00350.check() && A4_Cycle_am_00350.check() && A5_Cycle_am_00350.check() && A6_Cycle_am_00350.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0138-rc-function-RC_Thread01-Cycle_am_00360/Cycle_am_00360.java b/test/testsuite/ouroboros/rc_test/RC0138-rc-function-RC_Thread01-Cycle_am_00360/Cycle_am_00360.java new file mode 100755 index 0000000000000000000000000000000000000000..dc03f905a4389776c53d440b4f06b1030caf89e5 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0138-rc-function-RC_Thread01-Cycle_am_00360/Cycle_am_00360.java @@ -0,0 +1,287 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00360.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00360 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00360.java + *- @ExecuteClass: Cycle_am_00360 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00360 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00360_A1 a1_main = new Cycle_a_00360_A1("a1_main"); + Cycle_a_00360_A4 a4_main = new Cycle_a_00360_A4("a4_main"); + Cycle_a_00360_A6 a6_main = new Cycle_a_00360_A6("a6_main"); + Cycle_a_00360_A9 a9_main = new Cycle_a_00360_A9("a9_main"); + a1_main.a2_0 = new Cycle_a_00360_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00360_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00360_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00360_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00360_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a5_0.a9_0 = a9_main; + a9_main.a2_0 = a1_main.a2_0; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a9_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a9_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 2399) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00360_A1 { + Cycle_a_00360_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00360_A2 { + Cycle_a_00360_A3 a3_0; + Cycle_a_00360_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + + class Cycle_a_00360_A3 { + Cycle_a_00360_A1 a1_0; + Cycle_a_00360_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_00360_A4 { + Cycle_a_00360_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_00360_A5 { + Cycle_a_00360_A6 a6_0; + Cycle_a_00360_A8 a8_0; + Cycle_a_00360_A9 a9_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a9_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a + a8_0.a + a9_0.a; + } + } + + class Cycle_a_00360_A6 { + Cycle_a_00360_A1 a1_0; + Cycle_a_00360_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_00360_A7 { + Cycle_a_00360_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00360_A8 { + Cycle_a_00360_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_a_00360_A9 { + Cycle_a_00360_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A9(String strObjectName) { + a2_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } +} + + +public class Cycle_am_00360 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00360 A1_Cycle_am_00360 = new ThreadRc_Cycle_am_00360(); + ThreadRc_Cycle_am_00360 A2_Cycle_am_00360 = new ThreadRc_Cycle_am_00360(); + ThreadRc_Cycle_am_00360 A3_Cycle_am_00360 = new ThreadRc_Cycle_am_00360(); + ThreadRc_Cycle_am_00360 A4_Cycle_am_00360 = new ThreadRc_Cycle_am_00360(); + ThreadRc_Cycle_am_00360 A5_Cycle_am_00360 = new ThreadRc_Cycle_am_00360(); + ThreadRc_Cycle_am_00360 A6_Cycle_am_00360 = new ThreadRc_Cycle_am_00360(); + + A1_Cycle_am_00360.start(); + A2_Cycle_am_00360.start(); + A3_Cycle_am_00360.start(); + A4_Cycle_am_00360.start(); + A5_Cycle_am_00360.start(); + A6_Cycle_am_00360.start(); + + try { + A1_Cycle_am_00360.join(); + A2_Cycle_am_00360.join(); + A3_Cycle_am_00360.join(); + A4_Cycle_am_00360.join(); + A5_Cycle_am_00360.join(); + A6_Cycle_am_00360.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00360.check() && A2_Cycle_am_00360.check() && A3_Cycle_am_00360.check() && A4_Cycle_am_00360.check() && A5_Cycle_am_00360.check() && A6_Cycle_am_00360.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0139-rc-function-RC_Thread01-Cycle_am_00370/Cycle_am_00370.java b/test/testsuite/ouroboros/rc_test/RC0139-rc-function-RC_Thread01-Cycle_am_00370/Cycle_am_00370.java new file mode 100755 index 0000000000000000000000000000000000000000..a552fcfc1b76549105bbd769ce76a8cf8907d505 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0139-rc-function-RC_Thread01-Cycle_am_00370/Cycle_am_00370.java @@ -0,0 +1,308 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00370.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00370 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00370.java + *- @ExecuteClass: Cycle_am_00370 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00370 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00370_A1 a1_main = new Cycle_a_00370_A1("a1_main"); + Cycle_a_00370_A4 a4_main = new Cycle_a_00370_A4("a4_main"); + Cycle_a_00370_A6 a6_main = new Cycle_a_00370_A6("a6_main"); + Cycle_a_00370_A9 a9_main = new Cycle_a_00370_A9("a9_main"); + a1_main.a2_0 = new Cycle_a_00370_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00370_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00370_A5("a5_0"); + a1_main.a2_0.a3_0.a10_0 = new Cycle_a_00370_A10("a10_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00370_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00370_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a10_0.a9_0 = a9_main; + a9_main.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a9_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a10_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a9_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum + a6_main.a3_0.a10_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 2623) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00370_A1 { + Cycle_a_00370_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00370_A2 { + Cycle_a_00370_A3 a3_0; + Cycle_a_00370_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + + class Cycle_a_00370_A3 { + Cycle_a_00370_A1 a1_0; + Cycle_a_00370_A5 a5_0; + Cycle_a_00370_A10 a10_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a10_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a + a10_0.a; + } + } + + class Cycle_a_00370_A4 { + Cycle_a_00370_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_00370_A5 { + Cycle_a_00370_A6 a6_0; + Cycle_a_00370_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + + class Cycle_a_00370_A6 { + Cycle_a_00370_A1 a1_0; + Cycle_a_00370_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_00370_A7 { + Cycle_a_00370_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00370_A8 { + Cycle_a_00370_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_a_00370_A9 { + Cycle_a_00370_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A9(String strObjectName) { + a6_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00370_A10 { + Cycle_a_00370_A9 a9_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A10(String strObjectName) { + a9_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + + void add() { + sum = a + a9_0.a; + } + } +} + + +public class Cycle_am_00370 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00370 A1_Cycle_am_00370 = new ThreadRc_Cycle_am_00370(); + ThreadRc_Cycle_am_00370 A2_Cycle_am_00370 = new ThreadRc_Cycle_am_00370(); + ThreadRc_Cycle_am_00370 A3_Cycle_am_00370 = new ThreadRc_Cycle_am_00370(); + ThreadRc_Cycle_am_00370 A4_Cycle_am_00370 = new ThreadRc_Cycle_am_00370(); + ThreadRc_Cycle_am_00370 A5_Cycle_am_00370 = new ThreadRc_Cycle_am_00370(); + ThreadRc_Cycle_am_00370 A6_Cycle_am_00370 = new ThreadRc_Cycle_am_00370(); + + A1_Cycle_am_00370.start(); + A2_Cycle_am_00370.start(); + A3_Cycle_am_00370.start(); + A4_Cycle_am_00370.start(); + A5_Cycle_am_00370.start(); + A6_Cycle_am_00370.start(); + + try { + A1_Cycle_am_00370.join(); + A2_Cycle_am_00370.join(); + A3_Cycle_am_00370.join(); + A4_Cycle_am_00370.join(); + A5_Cycle_am_00370.join(); + A6_Cycle_am_00370.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00370.check() && A2_Cycle_am_00370.check() && A3_Cycle_am_00370.check() && A4_Cycle_am_00370.check() && A5_Cycle_am_00370.check() && A6_Cycle_am_00370.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0140-rc-function-RC_Thread01-Cycle_am_00380/Cycle_am_00380.java b/test/testsuite/ouroboros/rc_test/RC0140-rc-function-RC_Thread01-Cycle_am_00380/Cycle_am_00380.java new file mode 100755 index 0000000000000000000000000000000000000000..1331ac418749b697eba7b62e48b70348de0a6ef6 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0140-rc-function-RC_Thread01-Cycle_am_00380/Cycle_am_00380.java @@ -0,0 +1,150 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00380.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00380 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00380.java + *- @ExecuteClass: Cycle_am_00380 + *- @ExecuteArgs: + *- @Remark: + */ + + +class ThreadRc_Cycle_am_00380 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00380_A1 a1_main = new Cycle_a_00380_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00380_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00380_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a2_0 = a1_main.a2_0; + + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 815) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00380_A1 { + Cycle_a_00380_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00380_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00380_A2 { + Cycle_a_00380_A1 a1_0; + Cycle_a_00380_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00380_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_00380_A3 { + Cycle_a_00380_A1 a1_0; + Cycle_a_00380_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00380_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a2_0.a; + } + } +} + + +public class Cycle_am_00380 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00380 A1_Cycle_am_00380 = new ThreadRc_Cycle_am_00380(); + ThreadRc_Cycle_am_00380 A2_Cycle_am_00380 = new ThreadRc_Cycle_am_00380(); + ThreadRc_Cycle_am_00380 A3_Cycle_am_00380 = new ThreadRc_Cycle_am_00380(); + ThreadRc_Cycle_am_00380 A4_Cycle_am_00380 = new ThreadRc_Cycle_am_00380(); + ThreadRc_Cycle_am_00380 A5_Cycle_am_00380 = new ThreadRc_Cycle_am_00380(); + ThreadRc_Cycle_am_00380 A6_Cycle_am_00380 = new ThreadRc_Cycle_am_00380(); + + A1_Cycle_am_00380.start(); + A2_Cycle_am_00380.start(); + A3_Cycle_am_00380.start(); + A4_Cycle_am_00380.start(); + A5_Cycle_am_00380.start(); + A6_Cycle_am_00380.start(); + + try { + A1_Cycle_am_00380.join(); + A2_Cycle_am_00380.join(); + A3_Cycle_am_00380.join(); + A4_Cycle_am_00380.join(); + A5_Cycle_am_00380.join(); + A6_Cycle_am_00380.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00380.check() && A2_Cycle_am_00380.check() && A3_Cycle_am_00380.check() && A4_Cycle_am_00380.check() && A5_Cycle_am_00380.check() && A6_Cycle_am_00380.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0141-rc-function-RC_Thread01-Cycle_am_00390/Cycle_am_00390.java b/test/testsuite/ouroboros/rc_test/RC0141-rc-function-RC_Thread01-Cycle_am_00390/Cycle_am_00390.java new file mode 100755 index 0000000000000000000000000000000000000000..66c88cf1184de036ffbdbdcbba23af191fe636ac --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0141-rc-function-RC_Thread01-Cycle_am_00390/Cycle_am_00390.java @@ -0,0 +1,152 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00390.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00390 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00390.java + *- @ExecuteClass: Cycle_am_00390 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00390 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00390_A1 a1_main = new Cycle_a_00390_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00390_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00390_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 918) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00390_A1 { + Cycle_a_00390_A2 a2_0; + Cycle_a_00390_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00390_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } + } + + class Cycle_a_00390_A2 { + Cycle_a_00390_A1 a1_0; + Cycle_a_00390_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00390_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_00390_A3 { + Cycle_a_00390_A1 a1_0; + Cycle_a_00390_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00390_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a2_0.a; + } + } +} + + +public class Cycle_am_00390 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00390 A1_Cycle_am_00390 = new ThreadRc_Cycle_am_00390(); + ThreadRc_Cycle_am_00390 A2_Cycle_am_00390 = new ThreadRc_Cycle_am_00390(); + ThreadRc_Cycle_am_00390 A3_Cycle_am_00390 = new ThreadRc_Cycle_am_00390(); + ThreadRc_Cycle_am_00390 A4_Cycle_am_00390 = new ThreadRc_Cycle_am_00390(); + ThreadRc_Cycle_am_00390 A5_Cycle_am_00390 = new ThreadRc_Cycle_am_00390(); + ThreadRc_Cycle_am_00390 A6_Cycle_am_00390 = new ThreadRc_Cycle_am_00390(); + + A1_Cycle_am_00390.start(); + A2_Cycle_am_00390.start(); + A3_Cycle_am_00390.start(); + A4_Cycle_am_00390.start(); + A5_Cycle_am_00390.start(); + A6_Cycle_am_00390.start(); + + try { + A1_Cycle_am_00390.join(); + A2_Cycle_am_00390.join(); + A3_Cycle_am_00390.join(); + A4_Cycle_am_00390.join(); + A5_Cycle_am_00390.join(); + A6_Cycle_am_00390.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00390.check() && A2_Cycle_am_00390.check() && A3_Cycle_am_00390.check() && A4_Cycle_am_00390.check() && A5_Cycle_am_00390.check() && A6_Cycle_am_00390.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0142-rc-function-RC_Thread01-Cycle_am_00400/Cycle_am_00400.java b/test/testsuite/ouroboros/rc_test/RC0142-rc-function-RC_Thread01-Cycle_am_00400/Cycle_am_00400.java new file mode 100755 index 0000000000000000000000000000000000000000..d0f6c883b0ecf1ab95b050d8490caf52763a2edd --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0142-rc-function-RC_Thread01-Cycle_am_00400/Cycle_am_00400.java @@ -0,0 +1,166 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00400.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00400 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00400.java + *- @ExecuteClass: Cycle_am_00400 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00400 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00400_A1 a1_main = new Cycle_a_00400_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00400_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00400_A3("a3_0"); + a1_main.a4_0 = new Cycle_a_00400_A4("a4_0"); + a1_main.a4_0.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a1_0 = a1_main; + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a4_0.add(); + + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 923) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00400_A1 { + Cycle_a_00400_A2 a2_0; + Cycle_a_00400_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00400_A1(String strObjectName) { + a2_0 = null; + a4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a4_0.a; + } + } + + class Cycle_a_00400_A2 { + Cycle_a_00400_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00400_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00400_A3 { + Cycle_a_00400_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00400_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_00400_A4 { + Cycle_a_00400_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00400_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } +} + + +public class Cycle_am_00400 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00400 A1_Cycle_am_00400 = new ThreadRc_Cycle_am_00400(); + ThreadRc_Cycle_am_00400 A2_Cycle_am_00400 = new ThreadRc_Cycle_am_00400(); + ThreadRc_Cycle_am_00400 A3_Cycle_am_00400 = new ThreadRc_Cycle_am_00400(); + ThreadRc_Cycle_am_00400 A4_Cycle_am_00400 = new ThreadRc_Cycle_am_00400(); + ThreadRc_Cycle_am_00400 A5_Cycle_am_00400 = new ThreadRc_Cycle_am_00400(); + ThreadRc_Cycle_am_00400 A6_Cycle_am_00400 = new ThreadRc_Cycle_am_00400(); + + A1_Cycle_am_00400.start(); + A2_Cycle_am_00400.start(); + A3_Cycle_am_00400.start(); + A4_Cycle_am_00400.start(); + A5_Cycle_am_00400.start(); + A6_Cycle_am_00400.start(); + + try { + A1_Cycle_am_00400.join(); + A2_Cycle_am_00400.join(); + A3_Cycle_am_00400.join(); + A4_Cycle_am_00400.join(); + A5_Cycle_am_00400.join(); + A6_Cycle_am_00400.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00400.check() && A2_Cycle_am_00400.check() && A3_Cycle_am_00400.check() && A4_Cycle_am_00400.check() && A5_Cycle_am_00400.check() && A6_Cycle_am_00400.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0143-rc-function-RC_Thread01-Cycle_am_00410/Cycle_am_00410.java b/test/testsuite/ouroboros/rc_test/RC0143-rc-function-RC_Thread01-Cycle_am_00410/Cycle_am_00410.java new file mode 100755 index 0000000000000000000000000000000000000000..dca5510f3ad2327271c25c264706b0cfe50ff4cd --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0143-rc-function-RC_Thread01-Cycle_am_00410/Cycle_am_00410.java @@ -0,0 +1,166 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00410.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00410 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00410.java + *- @ExecuteClass: Cycle_am_00410 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00410 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00410_A1 a1_main = new Cycle_a_00410_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00410_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00410_A3("a3_0"); + a1_main.a2_0.a4_0 = new Cycle_a_00410_A4("a4_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a4_0.a1_0 = a1_main; + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a4_0.add(); + + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 921) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00410_A1 { + Cycle_a_00410_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00410_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00410_A2 { + Cycle_a_00410_A3 a3_0; + Cycle_a_00410_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00410_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + + class Cycle_a_00410_A3 { + Cycle_a_00410_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00410_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_00410_A4 { + Cycle_a_00410_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00410_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } +} + + +public class Cycle_am_00410 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00410 A1_Cycle_am_00410 = new ThreadRc_Cycle_am_00410(); + ThreadRc_Cycle_am_00410 A2_Cycle_am_00410 = new ThreadRc_Cycle_am_00410(); + ThreadRc_Cycle_am_00410 A3_Cycle_am_00410 = new ThreadRc_Cycle_am_00410(); + ThreadRc_Cycle_am_00410 A4_Cycle_am_00410 = new ThreadRc_Cycle_am_00410(); + ThreadRc_Cycle_am_00410 A5_Cycle_am_00410 = new ThreadRc_Cycle_am_00410(); + ThreadRc_Cycle_am_00410 A6_Cycle_am_00410 = new ThreadRc_Cycle_am_00410(); + + A1_Cycle_am_00410.start(); + A2_Cycle_am_00410.start(); + A3_Cycle_am_00410.start(); + A4_Cycle_am_00410.start(); + A5_Cycle_am_00410.start(); + A6_Cycle_am_00410.start(); + + try { + A1_Cycle_am_00410.join(); + A2_Cycle_am_00410.join(); + A3_Cycle_am_00410.join(); + A4_Cycle_am_00410.join(); + A5_Cycle_am_00410.join(); + A6_Cycle_am_00410.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00410.check() && A2_Cycle_am_00410.check() && A3_Cycle_am_00410.check() && A4_Cycle_am_00410.check() && A5_Cycle_am_00410.check() && A6_Cycle_am_00410.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0144-rc-function-RC_Thread01-Cycle_am_00420/Cycle_am_00420.java b/test/testsuite/ouroboros/rc_test/RC0144-rc-function-RC_Thread01-Cycle_am_00420/Cycle_am_00420.java new file mode 100755 index 0000000000000000000000000000000000000000..4b79fa116eb313a948c2a2956a927b37f8612801 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0144-rc-function-RC_Thread01-Cycle_am_00420/Cycle_am_00420.java @@ -0,0 +1,167 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00420.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00420 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00420.java + *- @ExecuteClass: Cycle_am_00420 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00420 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00420_A1 a1_main = new Cycle_a_00420_A1("a1_main"); +// Cycle_a_00420_A4 a4_main = new Cycle_a_00420_A4("a4_main"); + a1_main.a2_0 = new Cycle_a_00420_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00420_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00420_A4("a4_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 923) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00420_A1 { + Cycle_a_00420_A2 a2_0; + Cycle_a_00420_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00420_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } + } + + class Cycle_a_00420_A2 { + Cycle_a_00420_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00420_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00420_A3 { + Cycle_a_00420_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00420_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_a_00420_A4 { + Cycle_a_00420_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00420_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } +} + + +public class Cycle_am_00420 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00420 A1_Cycle_am_00420 = new ThreadRc_Cycle_am_00420(); + ThreadRc_Cycle_am_00420 A2_Cycle_am_00420 = new ThreadRc_Cycle_am_00420(); + ThreadRc_Cycle_am_00420 A3_Cycle_am_00420 = new ThreadRc_Cycle_am_00420(); + ThreadRc_Cycle_am_00420 A4_Cycle_am_00420 = new ThreadRc_Cycle_am_00420(); + ThreadRc_Cycle_am_00420 A5_Cycle_am_00420 = new ThreadRc_Cycle_am_00420(); + ThreadRc_Cycle_am_00420 A6_Cycle_am_00420 = new ThreadRc_Cycle_am_00420(); + + A1_Cycle_am_00420.start(); + A2_Cycle_am_00420.start(); + A3_Cycle_am_00420.start(); + A4_Cycle_am_00420.start(); + A5_Cycle_am_00420.start(); + A6_Cycle_am_00420.start(); + + try { + A1_Cycle_am_00420.join(); + A2_Cycle_am_00420.join(); + A3_Cycle_am_00420.join(); + A4_Cycle_am_00420.join(); + A5_Cycle_am_00420.join(); + A6_Cycle_am_00420.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00420.check() && A2_Cycle_am_00420.check() && A3_Cycle_am_00420.check() && A4_Cycle_am_00420.check() && A5_Cycle_am_00420.check() && A6_Cycle_am_00420.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0145-rc-function-RC_Thread01-Cycle_am_00430/Cycle_am_00430.java b/test/testsuite/ouroboros/rc_test/RC0145-rc-function-RC_Thread01-Cycle_am_00430/Cycle_am_00430.java new file mode 100755 index 0000000000000000000000000000000000000000..0a37067358c00d0e43569b83ca4097144fc7e4b1 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0145-rc-function-RC_Thread01-Cycle_am_00430/Cycle_am_00430.java @@ -0,0 +1,173 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00430.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00430 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00430.java + *- @ExecuteClass: Cycle_am_00430 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00430 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00430_A1 a1_main = new Cycle_a_00430_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00430_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00430_A3("a3_0"); + a1_main.a2_0.a4_0 = new Cycle_a_00430_A4("a4_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a4_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a4_0.a1_0 = a1_main; + + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a4_0.add(); + + + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1124) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00430_A1 { + Cycle_a_00430_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00430_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00430_A2 { + Cycle_a_00430_A1 a1_0; + Cycle_a_00430_A3 a3_0; + Cycle_a_00430_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00430_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } + } + + class Cycle_a_00430_A3 { + Cycle_a_00430_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00430_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_00430_A4 { + Cycle_a_00430_A1 a1_0; + Cycle_a_00430_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00430_A4(String strObjectName) { + a2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a2_0.a; + } + } +} + + +public class Cycle_am_00430 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00430 A1_Cycle_am_00430 = new ThreadRc_Cycle_am_00430(); + ThreadRc_Cycle_am_00430 A2_Cycle_am_00430 = new ThreadRc_Cycle_am_00430(); + ThreadRc_Cycle_am_00430 A3_Cycle_am_00430 = new ThreadRc_Cycle_am_00430(); + ThreadRc_Cycle_am_00430 A4_Cycle_am_00430 = new ThreadRc_Cycle_am_00430(); + ThreadRc_Cycle_am_00430 A5_Cycle_am_00430 = new ThreadRc_Cycle_am_00430(); + ThreadRc_Cycle_am_00430 A6_Cycle_am_00430 = new ThreadRc_Cycle_am_00430(); + + A1_Cycle_am_00430.start(); + A2_Cycle_am_00430.start(); + A3_Cycle_am_00430.start(); + A4_Cycle_am_00430.start(); + A5_Cycle_am_00430.start(); + A6_Cycle_am_00430.start(); + + try { + A1_Cycle_am_00430.join(); + A2_Cycle_am_00430.join(); + A3_Cycle_am_00430.join(); + A4_Cycle_am_00430.join(); + A5_Cycle_am_00430.join(); + A6_Cycle_am_00430.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00430.check() && A2_Cycle_am_00430.check() && A3_Cycle_am_00430.check() && A4_Cycle_am_00430.check() && A5_Cycle_am_00430.check() && A6_Cycle_am_00430.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0146-rc-function-RC_Thread01-Cycle_am_00440/Cycle_am_00440.java b/test/testsuite/ouroboros/rc_test/RC0146-rc-function-RC_Thread01-Cycle_am_00440/Cycle_am_00440.java new file mode 100755 index 0000000000000000000000000000000000000000..f74db05d90312047785f81860b64dc4de3e6fb88 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0146-rc-function-RC_Thread01-Cycle_am_00440/Cycle_am_00440.java @@ -0,0 +1,171 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00440.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00440 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00440.java + *- @ExecuteClass: Cycle_am_00440 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00440 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00440_A1 a1_main = new Cycle_a_00440_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00440_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00440_A3("a3_0"); + a1_main.a2_0.a4_0 = new Cycle_a_00440_A4("a4_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a4_0.a2_0 = a1_main.a2_0; + + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a4_0.add(); + + + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1023) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00440_A1 { + Cycle_a_00440_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00440_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00440_A2 { + Cycle_a_00440_A1 a1_0; + Cycle_a_00440_A3 a3_0; + Cycle_a_00440_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00440_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } + } + + class Cycle_a_00440_A3 { + Cycle_a_00440_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00440_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_00440_A4 { + Cycle_a_00440_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00440_A4(String strObjectName) { + a2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } +} + + +public class Cycle_am_00440 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00440 A1_Cycle_am_00440 = new ThreadRc_Cycle_am_00440(); + ThreadRc_Cycle_am_00440 A2_Cycle_am_00440 = new ThreadRc_Cycle_am_00440(); + ThreadRc_Cycle_am_00440 A3_Cycle_am_00440 = new ThreadRc_Cycle_am_00440(); + ThreadRc_Cycle_am_00440 A4_Cycle_am_00440 = new ThreadRc_Cycle_am_00440(); + ThreadRc_Cycle_am_00440 A5_Cycle_am_00440 = new ThreadRc_Cycle_am_00440(); + ThreadRc_Cycle_am_00440 A6_Cycle_am_00440 = new ThreadRc_Cycle_am_00440(); + + A1_Cycle_am_00440.start(); + A2_Cycle_am_00440.start(); + A3_Cycle_am_00440.start(); + A4_Cycle_am_00440.start(); + A5_Cycle_am_00440.start(); + A6_Cycle_am_00440.start(); + + try { + A1_Cycle_am_00440.join(); + A2_Cycle_am_00440.join(); + A3_Cycle_am_00440.join(); + A4_Cycle_am_00440.join(); + A5_Cycle_am_00440.join(); + A6_Cycle_am_00440.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00440.check() && A2_Cycle_am_00440.check() && A3_Cycle_am_00440.check() && A4_Cycle_am_00440.check() && A5_Cycle_am_00440.check() && A6_Cycle_am_00440.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0147-rc-function-RC_Thread01-Cycle_am_00450/Cycle_am_00450.java b/test/testsuite/ouroboros/rc_test/RC0147-rc-function-RC_Thread01-Cycle_am_00450/Cycle_am_00450.java new file mode 100755 index 0000000000000000000000000000000000000000..c9ec7af7ca9c301e5b426b03c075f5fb31f72576 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0147-rc-function-RC_Thread01-Cycle_am_00450/Cycle_am_00450.java @@ -0,0 +1,214 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00450.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00450 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00450.java + *- @ExecuteClass: Cycle_am_00450 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00450 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00450_A1 a1_main = new Cycle_a_00450_A1("a1_main"); + Cycle_a_00450_A6 a6_main = new Cycle_a_00450_A6("a6_main"); + Cycle_a_00450_A7 a7_main = new Cycle_a_00450_A7("a7_main"); + a1_main.a2_0 = new Cycle_a_00450_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00450_A3("a3_0"); + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00450_A5("a5_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a5_0.a7_0 = a7_main; + a7_main.a2_0 = a1_main.a2_0; + + a1_main.add(); + a6_main.add(); + a7_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + + + int result = a1_main.sum + a6_main.sum + a7_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1453) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00450_A1 { + Cycle_a_00450_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00450_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00450_A2 { + Cycle_a_00450_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00450_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00450_A3 { + Cycle_a_00450_A1 a1_0; + Cycle_a_00450_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00450_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_00450_A5 { + Cycle_a_00450_A6 a6_0; + Cycle_a_00450_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00450_A5(String strObjectName) { + a6_0 = null; + a7_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a + a7_0.a; + } + } + + class Cycle_a_00450_A6 { + Cycle_a_00450_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00450_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00450_A7 { + Cycle_a_00450_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00450_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } +} + + +public class Cycle_am_00450 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00450 A1_Cycle_am_00450 = new ThreadRc_Cycle_am_00450(); + ThreadRc_Cycle_am_00450 A2_Cycle_am_00450 = new ThreadRc_Cycle_am_00450(); + ThreadRc_Cycle_am_00450 A3_Cycle_am_00450 = new ThreadRc_Cycle_am_00450(); + ThreadRc_Cycle_am_00450 A4_Cycle_am_00450 = new ThreadRc_Cycle_am_00450(); + ThreadRc_Cycle_am_00450 A5_Cycle_am_00450 = new ThreadRc_Cycle_am_00450(); + ThreadRc_Cycle_am_00450 A6_Cycle_am_00450 = new ThreadRc_Cycle_am_00450(); + + A1_Cycle_am_00450.start(); + A2_Cycle_am_00450.start(); + A3_Cycle_am_00450.start(); + A4_Cycle_am_00450.start(); + A5_Cycle_am_00450.start(); + A6_Cycle_am_00450.start(); + + try { + A1_Cycle_am_00450.join(); + A2_Cycle_am_00450.join(); + A3_Cycle_am_00450.join(); + A4_Cycle_am_00450.join(); + A5_Cycle_am_00450.join(); + A6_Cycle_am_00450.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00450.check() && A2_Cycle_am_00450.check() && A3_Cycle_am_00450.check() && A4_Cycle_am_00450.check() && A5_Cycle_am_00450.check() && A6_Cycle_am_00450.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0148-rc-function-RC_Thread01-Cycle_am_00460/Cycle_am_00460.java b/test/testsuite/ouroboros/rc_test/RC0148-rc-function-RC_Thread01-Cycle_am_00460/Cycle_am_00460.java new file mode 100755 index 0000000000000000000000000000000000000000..9efc3047dbba5046e2c28de871e48b8ee3436cb9 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0148-rc-function-RC_Thread01-Cycle_am_00460/Cycle_am_00460.java @@ -0,0 +1,217 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00460.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00460 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00460.java + *- @ExecuteClass: Cycle_am_00460 + *- @ExecuteArgs: + *- @Remark: + */ + + +class ThreadRc_Cycle_am_00460 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00460_A1 a1_main = new Cycle_a_00460_A1("a1_main"); + Cycle_a_00460_A5 a5_main = new Cycle_a_00460_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00460_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00460_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00460_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.a2_0.a3_0.a4_0.a6_0 = new Cycle_a_00460_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a1_main.a2_0.a3_0.a4_0.a6_0.a1_0 = a1_main; + + a5_main.a3_0 = a1_main.a2_0.a3_0; + + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); + + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a6_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1550) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00460_A1 { + Cycle_a_00460_A2 a2_0; + Cycle_a_00460_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00460_A1(String strObjectName) { + a2_0 = null; + a4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a4_0.a; + } + } + + class Cycle_a_00460_A2 { + Cycle_a_00460_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00460_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00460_A3 { + Cycle_a_00460_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00460_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_a_00460_A4 { + Cycle_a_00460_A1 a1_0; + Cycle_a_00460_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00460_A4(String strObjectName) { + a1_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a6_0.a; + } + } + + class Cycle_a_00460_A5 { + Cycle_a_00460_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00460_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00460_A6 { + Cycle_a_00460_A1 a1_0; + Cycle_a_00460_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00460_A6(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } +} + + +public class Cycle_am_00460 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00460 A1_Cycle_am_00460 = new ThreadRc_Cycle_am_00460(); + ThreadRc_Cycle_am_00460 A2_Cycle_am_00460 = new ThreadRc_Cycle_am_00460(); + ThreadRc_Cycle_am_00460 A3_Cycle_am_00460 = new ThreadRc_Cycle_am_00460(); + ThreadRc_Cycle_am_00460 A4_Cycle_am_00460 = new ThreadRc_Cycle_am_00460(); + ThreadRc_Cycle_am_00460 A5_Cycle_am_00460 = new ThreadRc_Cycle_am_00460(); + ThreadRc_Cycle_am_00460 A6_Cycle_am_00460 = new ThreadRc_Cycle_am_00460(); + + A1_Cycle_am_00460.start(); + A2_Cycle_am_00460.start(); + A3_Cycle_am_00460.start(); + A4_Cycle_am_00460.start(); + A5_Cycle_am_00460.start(); + A6_Cycle_am_00460.start(); + + try { + A1_Cycle_am_00460.join(); + A2_Cycle_am_00460.join(); + A3_Cycle_am_00460.join(); + A4_Cycle_am_00460.join(); + A5_Cycle_am_00460.join(); + A6_Cycle_am_00460.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00460.check() && A2_Cycle_am_00460.check() && A3_Cycle_am_00460.check() && A4_Cycle_am_00460.check() && A5_Cycle_am_00460.check() && A6_Cycle_am_00460.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0149-rc-function-RC_Thread01-Cycle_am_00470/Cycle_am_00470.java b/test/testsuite/ouroboros/rc_test/RC0149-rc-function-RC_Thread01-Cycle_am_00470/Cycle_am_00470.java new file mode 100755 index 0000000000000000000000000000000000000000..faae3f89d9a26005e00fb10e69d08cc8794c2125 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0149-rc-function-RC_Thread01-Cycle_am_00470/Cycle_am_00470.java @@ -0,0 +1,213 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00470.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00470 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00470.java + *- @ExecuteClass: Cycle_am_00470 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00470 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00470_A1 a1_main = new Cycle_a_00470_A1("a1_main"); + Cycle_a_00470_A5 a5_main = new Cycle_a_00470_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00470_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00470_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00470_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0.a6_0 = new Cycle_a_00470_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a1_0 = a1_main; + + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); + + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a6_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1446) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00470_A1 { + Cycle_a_00470_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00470_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00470_A2 { + Cycle_a_00470_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00470_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00470_A3 { + Cycle_a_00470_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00470_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_a_00470_A4 { + Cycle_a_00470_A1 a1_0; + Cycle_a_00470_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00470_A4(String strObjectName) { + a1_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a6_0.a; + } + } + + class Cycle_a_00470_A5 { + Cycle_a_00470_A1 a1_0; + Cycle_a_00470_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00470_A5(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_00470_A6 { + Cycle_a_00470_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00470_A6(String strObjectName) { + a5_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } + } +} + + +public class Cycle_am_00470 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00470 A1_Cycle_am_00470 = new ThreadRc_Cycle_am_00470(); + ThreadRc_Cycle_am_00470 A2_Cycle_am_00470 = new ThreadRc_Cycle_am_00470(); + ThreadRc_Cycle_am_00470 A3_Cycle_am_00470 = new ThreadRc_Cycle_am_00470(); + ThreadRc_Cycle_am_00470 A4_Cycle_am_00470 = new ThreadRc_Cycle_am_00470(); + ThreadRc_Cycle_am_00470 A5_Cycle_am_00470 = new ThreadRc_Cycle_am_00470(); + ThreadRc_Cycle_am_00470 A6_Cycle_am_00470 = new ThreadRc_Cycle_am_00470(); + + A1_Cycle_am_00470.start(); + A2_Cycle_am_00470.start(); + A3_Cycle_am_00470.start(); + A4_Cycle_am_00470.start(); + A5_Cycle_am_00470.start(); + A6_Cycle_am_00470.start(); + + try { + A1_Cycle_am_00470.join(); + A2_Cycle_am_00470.join(); + A3_Cycle_am_00470.join(); + A4_Cycle_am_00470.join(); + A5_Cycle_am_00470.join(); + A6_Cycle_am_00470.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00470.check() && A2_Cycle_am_00470.check() && A3_Cycle_am_00470.check() && A4_Cycle_am_00470.check() && A5_Cycle_am_00470.check() && A6_Cycle_am_00470.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0150-rc-function-RC_Thread01-Cycle_am_00480/Cycle_am_00480.java b/test/testsuite/ouroboros/rc_test/RC0150-rc-function-RC_Thread01-Cycle_am_00480/Cycle_am_00480.java new file mode 100755 index 0000000000000000000000000000000000000000..286f5a54e0e3506d01fc4aea9e433e133d9d4d8c --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0150-rc-function-RC_Thread01-Cycle_am_00480/Cycle_am_00480.java @@ -0,0 +1,236 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00480.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00480 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00480.java + *- @ExecuteClass: Cycle_am_00480 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00480 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00480_A1 a1_main = new Cycle_a_00480_A1("a1_main"); + Cycle_a_00480_A5 a5_main = new Cycle_a_00480_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00480_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00480_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00480_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0.a6_0 = new Cycle_a_00480_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a1_main.a2_0.a3_0.a4_0.a6_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.a2_0.a3_0.a4_0.a6_0.a1_0 = a1_main; + + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a3_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + + + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a1_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); +// a1_main.a2_0.a3_0.a4_0.a6_0.a5_0.add(); +// a1_main.a2_0.a3_0.a4_0.a6_0.a4_0.add(); +// a1_main.a2_0.a3_0.a4_0.a6_0.a1_0.add(); + + a5_main.a3_0.add(); + a5_main.a3_0.a4_0.add(); + +// System.out.println("a1_main.sum:"+a1_main.sum); +// System.out.println("a4_main.sum:"+a5_main.sum); +// System.out.println("a1_main.a2_0.sum:"+a1_main.a2_0.sum); +// System.out.println("a1_main.a2_0.a3_0.sum:"+a1_main.a2_0.a3_0.sum); +// System.out.println("a1_main.a2_0.a3_0.a4_0.sum:"+a1_main.a2_0.a3_0.a4_0.sum); +// System.out.println("a1_main.a2_0.a3_0.a4_0.a6_0.sum:"+a1_main.a2_0.a3_0.a4_0.a6_0.sum); +// System.out.println("a1_main.a2_0.a3_0.a4_0.a6_0.a4_0.sum:"+a1_main.a2_0.a3_0.a4_0.a6_0.a4_0.sum); + + +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a5_main.sum+a1_main.a2_0.sum+a1_main.a2_0.a3_0.sum+a1_main.a2_0.a3_0.a4_0.sum+a1_main.a2_0.a3_0.a4_0.a6_0.sum); + + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a6_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1550) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00480_A1 { + Cycle_a_00480_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00480_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00480_A2 { + Cycle_a_00480_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00480_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00480_A3 { + Cycle_a_00480_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00480_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_a_00480_A4 { + Cycle_a_00480_A1 a1_0; + Cycle_a_00480_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00480_A4(String strObjectName) { + a1_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a6_0.a; + } + } + + class Cycle_a_00480_A5 { + Cycle_a_00480_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00480_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00480_A6 { + Cycle_a_00480_A1 a1_0; + Cycle_a_00480_A4 a4_0; + Cycle_a_00480_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00480_A6(String strObjectName) { + a1_0 = null; + a4_0 = null; + a5_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a4_0.a + a5_0.a; + } + } +} + + +public class Cycle_am_00480 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00480 A1_Cycle_am_00480 = new ThreadRc_Cycle_am_00480(); + ThreadRc_Cycle_am_00480 A2_Cycle_am_00480 = new ThreadRc_Cycle_am_00480(); + ThreadRc_Cycle_am_00480 A3_Cycle_am_00480 = new ThreadRc_Cycle_am_00480(); + ThreadRc_Cycle_am_00480 A4_Cycle_am_00480 = new ThreadRc_Cycle_am_00480(); + ThreadRc_Cycle_am_00480 A5_Cycle_am_00480 = new ThreadRc_Cycle_am_00480(); + ThreadRc_Cycle_am_00480 A6_Cycle_am_00480 = new ThreadRc_Cycle_am_00480(); + + A1_Cycle_am_00480.start(); + A2_Cycle_am_00480.start(); + A3_Cycle_am_00480.start(); + A4_Cycle_am_00480.start(); + A5_Cycle_am_00480.start(); + A6_Cycle_am_00480.start(); + + try { + A1_Cycle_am_00480.join(); + A2_Cycle_am_00480.join(); + A3_Cycle_am_00480.join(); + A4_Cycle_am_00480.join(); + A5_Cycle_am_00480.join(); + A6_Cycle_am_00480.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00480.check() && A2_Cycle_am_00480.check() && A3_Cycle_am_00480.check() && A4_Cycle_am_00480.check() && A5_Cycle_am_00480.check() && A6_Cycle_am_00480.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0151-rc-function-RC_Thread01-Cycle_am_00490/Cycle_am_00490.java b/test/testsuite/ouroboros/rc_test/RC0151-rc-function-RC_Thread01-Cycle_am_00490/Cycle_am_00490.java new file mode 100755 index 0000000000000000000000000000000000000000..d157064df25df94d58f6f15a9ce4d61d3dd450c3 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0151-rc-function-RC_Thread01-Cycle_am_00490/Cycle_am_00490.java @@ -0,0 +1,302 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00490.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00490 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\nExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00490.java + *- @ExecuteClass: Cycle_am_00490 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_am_00490 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00490_A1 a1_main = new Cycle_a_00490_A1("a1_main"); + Cycle_a_00490_A4 a4_main = new Cycle_a_00490_A4("a4_main"); + Cycle_a_00490_A7 a7_main = new Cycle_a_00490_A7("a7_main"); + a1_main.a2_0 = new Cycle_a_00490_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00490_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + + a4_main.a5_0 = new Cycle_a_00490_A5("a5_0"); + a4_main.a5_0.a6_0 = new Cycle_a_00490_A6("a6_0"); + a4_main.a5_0.a6_0.a4_0 = a4_main; +// a4_main.a5_0.a6_0.a3_0 = new Cycle_a_00490_A3("a3_0"); + a4_main.a5_0.a6_0.a3_0 = a1_main.a2_0.a3_0; + a4_main.a5_0.a6_0.a3_0.a1_0 = a1_main; + + a7_main.a9_0 = new Cycle_a_00490_A9("a9_0"); + a7_main.a9_0.a8_0 = new Cycle_a_00490_A8("a8_0"); + a7_main.a9_0.a8_0.a7_0 = a7_main; + a7_main.a9_0.a8_0.a5_0 = a4_main.a5_0; + + a1_main.add(); + a4_main.add(); + a7_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a1_0.add(); + a4_main.a5_0.add(); + a4_main.a5_0.a6_0.add(); + a4_main.a5_0.a6_0.a4_0.add(); + a4_main.a5_0.a6_0.a3_0.add(); + a4_main.a5_0.a6_0.a3_0.a1_0.add(); + + a7_main.a9_0.add(); + a7_main.a9_0.a8_0.add(); + a7_main.a9_0.a8_0.a7_0.add(); + a7_main.a9_0.a8_0.a5_0.add(); +// +// System.out.println("a1_main.sum:"+a1_main.sum); +// System.out.println("a4_main.sum:"+a4_main.sum); +// System.out.println("a7_main.sum:"+a7_main.sum); +// System.out.println("a1_main.a2_0.sum:"+a1_main.a2_0.sum); +// System.out.println("a1_main.a2_0.a3_0.sum:"+a1_main.a2_0.a3_0.sum); +// System.out.println("a4_main.a5_0.sum:"+a4_main.a5_0.sum); +// System.out.println("a4_main.a5_0.a6_0.sum:"+a4_main.a5_0.a6_0.sum); +// System.out.println("a7_main.a9_0.sum:"+a7_main.a9_0.sum); +// System.out.println("a7_main.a9_0.a8_0.sum:"+a7_main.a9_0.a8_0.sum); + + +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a4_main.sum+a7_main.sum+a1_main.a2_0.sum+a1_main.a2_0.a3_0.sum+a4_main.a5_0.sum+a4_main.a5_0.a6_0.sum+a7_main.a9_0.sum+a7_main.a9_0.a8_0.sum); + + int result = a1_main.sum + a4_main.sum + a7_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a4_main.a5_0.sum + a4_main.a5_0.a6_0.sum + a7_main.a9_0.sum + a7_main.a9_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 2098) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00490_A1 { + Cycle_a_00490_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00490_A2 { + Cycle_a_00490_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00490_A3 { + Cycle_a_00490_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_00490_A4 { + Cycle_a_00490_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_a_00490_A5 { + Cycle_a_00490_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00490_A6 { + Cycle_a_00490_A3 a3_0; + Cycle_a_00490_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A6(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + + class Cycle_a_00490_A7 { + Cycle_a_00490_A9 a9_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A7(String strObjectName) { + a9_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a9_0.a; + } + } + + class Cycle_a_00490_A8 { + Cycle_a_00490_A5 a5_0; + Cycle_a_00490_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A8(String strObjectName) { + a5_0 = null; + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a + a5_0.a; + } + } + + class Cycle_a_00490_A9 { + Cycle_a_00490_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A9(String strObjectName) { + a8_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + + void add() { + sum = a + a8_0.a; + } + } +} + + +public class Cycle_am_00490 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00490 A1_Cycle_am_00490 = new ThreadRc_Cycle_am_00490(); + ThreadRc_Cycle_am_00490 A2_Cycle_am_00490 = new ThreadRc_Cycle_am_00490(); + ThreadRc_Cycle_am_00490 A3_Cycle_am_00490 = new ThreadRc_Cycle_am_00490(); + ThreadRc_Cycle_am_00490 A4_Cycle_am_00490 = new ThreadRc_Cycle_am_00490(); + ThreadRc_Cycle_am_00490 A5_Cycle_am_00490 = new ThreadRc_Cycle_am_00490(); + ThreadRc_Cycle_am_00490 A6_Cycle_am_00490 = new ThreadRc_Cycle_am_00490(); + + A1_Cycle_am_00490.start(); + A2_Cycle_am_00490.start(); + A3_Cycle_am_00490.start(); + A4_Cycle_am_00490.start(); + A5_Cycle_am_00490.start(); + A6_Cycle_am_00490.start(); + + try { + A1_Cycle_am_00490.join(); + A2_Cycle_am_00490.join(); + A3_Cycle_am_00490.join(); + A4_Cycle_am_00490.join(); + A5_Cycle_am_00490.join(); + A6_Cycle_am_00490.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00490.check() && A2_Cycle_am_00490.check() && A3_Cycle_am_00490.check() && A4_Cycle_am_00490.check() && A5_Cycle_am_00490.check() && A6_Cycle_am_00490.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\nExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0152-rc-function-RC_Thread01-Cycle_am_00500/Cycle_am_00500.java b/test/testsuite/ouroboros/rc_test/RC0152-rc-function-RC_Thread01-Cycle_am_00500/Cycle_am_00500.java new file mode 100755 index 0000000000000000000000000000000000000000..a04cbd6afd954b84d68f5bd5a4fd51f2e5771912 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0152-rc-function-RC_Thread01-Cycle_am_00500/Cycle_am_00500.java @@ -0,0 +1,303 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00500.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_00500 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\nExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00500.java + *- @ExecuteClass: Cycle_am_00500 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_am_00500 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00500_A1 a1_main = new Cycle_a_00500_A1("a1_main"); + Cycle_a_00500_A4 a4_main = new Cycle_a_00500_A4("a4_main"); + Cycle_a_00500_A7 a7_main = new Cycle_a_00500_A7("a7_main"); + a1_main.a2_0 = new Cycle_a_00500_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00500_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + + a4_main.a1_0 = a1_main; + a4_main.a5_0 = new Cycle_a_00500_A5("a5_0"); + a4_main.a5_0.a6_0 = new Cycle_a_00500_A6("a6_0"); + a4_main.a5_0.a6_0.a4_0 = a4_main; + + a4_main.a5_0.a8_0 = new Cycle_a_00500_A8("a8_0"); + a4_main.a5_0.a8_0.a7_0 = a7_main; + + a7_main.a9_0 = new Cycle_a_00500_A9("a9_0"); + a7_main.a9_0.a8_0 = new Cycle_a_00500_A8("a8_0"); + a7_main.a9_0.a8_0.a7_0 = a7_main; + + a1_main.add(); + a4_main.add(); + a7_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a1_0.add(); + a4_main.a1_0.add(); + a4_main.a5_0.add(); + a4_main.a5_0.a6_0.add(); + a4_main.a5_0.a6_0.a4_0.add(); + a4_main.a5_0.a8_0.add(); + a4_main.a5_0.a8_0.a7_0.add(); + a7_main.a9_0.add(); + a7_main.a9_0.a8_0.add(); + a7_main.a9_0.a8_0.a7_0.add(); + + +// System.out.println("a1_main.sum:"+a1_main.sum); +// System.out.println("a4_main.sum:"+a4_main.sum); +// System.out.println("a7_main.sum:"+a7_main.sum); +// System.out.println("a1_main.a2_0.sum:"+a1_main.a2_0.sum); +// System.out.println("a1_main.a2_0.a3_0.sum:"+a1_main.a2_0.a3_0.sum); +// System.out.println("a4_main.a5_0.sum:"+a4_main.a5_0.sum); +// System.out.println("a4_main.a5_0.a6_0.sum:"+a4_main.a5_0.a6_0.sum); +// System.out.println("a7_main.a9_0.sum:"+a7_main.a9_0.sum); +// System.out.println("a7_main.a9_0.a8_0.sum:"+a7_main.a9_0.a8_0.sum); + + +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a4_main.sum+a7_main.sum+a1_main.a2_0.sum+a1_main.a2_0.a3_0.sum+a4_main.a5_0.sum+a4_main.a5_0.a6_0.sum+a7_main.a9_0.sum+a7_main.a9_0.a8_0.sum); + + int result = a1_main.sum + a4_main.sum + a7_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a4_main.a5_0.sum + a4_main.a5_0.a6_0.sum + a7_main.a9_0.sum + a7_main.a9_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 2099) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00500_A1 { + Cycle_a_00500_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00500_A2 { + Cycle_a_00500_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00500_A3 { + Cycle_a_00500_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_00500_A4 { + Cycle_a_00500_A1 a1_0; + Cycle_a_00500_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A4(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_00500_A5 { + Cycle_a_00500_A6 a6_0; + Cycle_a_00500_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + + class Cycle_a_00500_A6 { + Cycle_a_00500_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A6(String strObjectName) { + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_a_00500_A7 { + Cycle_a_00500_A9 a9_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A7(String strObjectName) { + a9_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a9_0.a; + } + } + + class Cycle_a_00500_A8 { + Cycle_a_00500_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_a_00500_A9 { + Cycle_a_00500_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A9(String strObjectName) { + a8_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + + void add() { + sum = a + a8_0.a; + } + } +} + + +public class Cycle_am_00500 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00500 A1_Cycle_am_00500 = new ThreadRc_Cycle_am_00500(); + ThreadRc_Cycle_am_00500 A2_Cycle_am_00500 = new ThreadRc_Cycle_am_00500(); + ThreadRc_Cycle_am_00500 A3_Cycle_am_00500 = new ThreadRc_Cycle_am_00500(); + ThreadRc_Cycle_am_00500 A4_Cycle_am_00500 = new ThreadRc_Cycle_am_00500(); + ThreadRc_Cycle_am_00500 A5_Cycle_am_00500 = new ThreadRc_Cycle_am_00500(); + ThreadRc_Cycle_am_00500 A6_Cycle_am_00500 = new ThreadRc_Cycle_am_00500(); + + A1_Cycle_am_00500.start(); + A2_Cycle_am_00500.start(); + A3_Cycle_am_00500.start(); + A4_Cycle_am_00500.start(); + A5_Cycle_am_00500.start(); + A6_Cycle_am_00500.start(); + + try { + A1_Cycle_am_00500.join(); + A2_Cycle_am_00500.join(); + A3_Cycle_am_00500.join(); + A4_Cycle_am_00500.join(); + A5_Cycle_am_00500.join(); + A6_Cycle_am_00500.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00500.check() && A2_Cycle_am_00500.check() && A3_Cycle_am_00500.check() && A4_Cycle_am_00500.check() && A5_Cycle_am_00500.check() && A6_Cycle_am_00500.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\nExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0153-rc-function-RC_Thread01-Cycle_am_00510/Cycle_am_00510.java b/test/testsuite/ouroboros/rc_test/RC0153-rc-function-RC_Thread01-Cycle_am_00510/Cycle_am_00510.java new file mode 100755 index 0000000000000000000000000000000000000000..763fcea153be07c56eb6861d9fe322d4f1859db9 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0153-rc-function-RC_Thread01-Cycle_am_00510/Cycle_am_00510.java @@ -0,0 +1,5642 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_00510.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:make all Cycle_a_xx together to this Multi thread testcase for Performance Testing. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\nExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_00510.java + *- @ExecuteClass: Cycle_am_00510 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_am_00180B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00180_A1 a1_main = new Cycle_a_00180_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00180_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00180_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00180_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = new Cycle_a_00180_A5("a5_0"); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_a_00180_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_main; + a1_main.a8_0 = new Cycle_a_00180_A8("a8_0"); + a1_main.a8_0.a9_0 = new Cycle_a_00180_A9("a9_0"); + a1_main.a8_0.a9_0.a7_0 = new Cycle_a_00180_A7("a7_0"); + a1_main.a8_0.a9_0.a7_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a5_0.add(); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a1_main.a8_0.add(); + a1_main.a8_0.a9_0.add(); + a1_main.a8_0.a9_0.a7_0.add(); + + + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a5_0.sum + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a1_main.a8_0.sum + a1_main.a8_0.a9_0.sum + a1_main.a8_0.a9_0.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1994) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00180_A1 { + Cycle_a_00180_A2 a2_0; + Cycle_a_00180_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A1(String strObjectName) { + a2_0 = null; + a8_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a8_0.a; + } + } + + class Cycle_a_00180_A2 { + Cycle_a_00180_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00180_A3 { + Cycle_a_00180_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_a_00180_A4 { + Cycle_a_00180_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_a_00180_A5 { + Cycle_a_00180_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00180_A6 { + Cycle_a_00180_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A6(String strObjectName) { + a1_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_00180_A7 { + Cycle_a_00180_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A7(String strObjectName) { + a4_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_a_00180_A8 { + Cycle_a_00180_A9 a9_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A8(String strObjectName) { + a9_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a9_0.a; + } + } + + class Cycle_a_00180_A9 { + Cycle_a_00180_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00180_A9(String strObjectName) { + a7_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } +} + +class ThreadRc_Cycle_am_00190B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00190_A1 a1_main = new Cycle_a_00190_A1("a1_main"); + Cycle_a_00190_A10 a10_main = new Cycle_a_00190_A10("a10_main"); + a1_main.a2_0 = new Cycle_a_00190_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00190_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00190_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = new Cycle_a_00190_A5("a5_0"); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_a_00190_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.a10_0 = a10_main; + + a10_main.a8_0 = new Cycle_a_00190_A8("a8_0"); + a10_main.a8_0.a9_0 = new Cycle_a_00190_A9("a9_0"); + a10_main.a8_0.a9_0.a7_0 = new Cycle_a_00190_A7("a7_0"); + a10_main.a8_0.a9_0.a7_0.a5_0 = a1_main.a2_0.a3_0.a4_0.a5_0; + + a1_main.add(); + a10_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a5_0.add(); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a10_main.a8_0.add(); + a10_main.a8_0.a9_0.add(); + a10_main.a8_0.a9_0.a7_0.add(); + + + int result = a1_main.sum + a10_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a5_0.sum + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a10_main.a8_0.sum + a10_main.a8_0.a9_0.sum + a10_main.a8_0.a9_0.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 2215) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00190_A1 { + Cycle_a_00190_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00190_A2 { + Cycle_a_00190_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00190_A3 { + Cycle_a_00190_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_a_00190_A4 { + Cycle_a_00190_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_a_00190_A5 { + Cycle_a_00190_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00190_A6 { + Cycle_a_00190_A1 a1_0; + Cycle_a_00190_A10 a10_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A6(String strObjectName) { + a1_0 = null; + a10_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a10_0.a; + } + } + + class Cycle_a_00190_A7 { + Cycle_a_00190_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A7(String strObjectName) { + a5_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_a_00190_A8 { + Cycle_a_00190_A9 a9_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A8(String strObjectName) { + a9_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a9_0.a; + } + } + + class Cycle_a_00190_A9 { + Cycle_a_00190_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A9(String strObjectName) { + a7_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_a_00190_A10 { + Cycle_a_00190_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00190_A10(String strObjectName) { + a8_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + + void add() { + sum = a + a8_0.a; + } + } +} + +class ThreadRc_Cycle_am_00200B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00200_A1 a1_main = new Cycle_a_00200_A1("a1_main"); + Cycle_a_00200_A4 a4_main = new Cycle_a_00200_A4("a4_main"); + a1_main.a2_0 = new Cycle_a_00200_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00200_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00200_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a4_0 = a4_main; + a4_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a6_0 = new Cycle_a_00200_A6("a6_0"); + a1_main.a2_0.a6_0.a7_0 = new Cycle_a_00200_A7("a7_0"); + a1_main.a2_0.a7_0 = a1_main.a2_0.a6_0.a7_0; + + a1_main.add(); + a4_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a6_0.add(); + a1_main.a2_0.a6_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a1_main.a2_0.a6_0.sum + a1_main.a2_0.a6_0.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1773) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00200_A1 { + Cycle_a_00200_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00200_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00200_A2 { + Cycle_a_00200_A3 a3_0; + Cycle_a_00200_A6 a6_0; + Cycle_a_00200_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00200_A2(String strObjectName) { + a3_0 = null; + a6_0 = null; + a7_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a6_0.a + a7_0.a; + } + } + + class Cycle_a_00200_A3 { + Cycle_a_00200_A1 a1_0; + Cycle_a_00200_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00200_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_00200_A4 { + Cycle_a_00200_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00200_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00200_A5 { + Cycle_a_00200_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00200_A5(String strObjectName) { + a4_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_a_00200_A6 { + Cycle_a_00200_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00200_A6(String strObjectName) { + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_a_00200_A7 { + int a; + int sum; + String strObjectName; + + Cycle_a_00200_A7(String strObjectName) { + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +class ThreadRc_Cycle_am_00210B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00210_A1 a1_main = new Cycle_a_00210_A1("a1_main"); + Cycle_a_00210_A4 a4_main = new Cycle_a_00210_A4("a4_main"); + a1_main.a2_0 = new Cycle_a_00210_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00210_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00210_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a4_0 = a4_main; + a4_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a6_0 = new Cycle_a_00210_A6("a6_0"); + a1_main.a2_0.a3_0.a6_0.a7_0 = new Cycle_a_00210_A7("a7_0"); + a1_main.a2_0.a3_0.a6_0.a7_0.a3_0 = a1_main.a2_0.a3_0; + + a1_main.add(); + a4_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a6_0.add(); + a1_main.a2_0.a3_0.a6_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a1_main.a2_0.a3_0.a6_0.sum + a1_main.a2_0.a3_0.a6_0.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1662) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00210_A1 { + Cycle_a_00210_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00210_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00210_A2 { + Cycle_a_00210_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00210_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00210_A3 { + Cycle_a_00210_A1 a1_0; + Cycle_a_00210_A5 a5_0; + Cycle_a_00210_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00210_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a6_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a + a6_0.a; + } + } + + class Cycle_a_00210_A4 { + Cycle_a_00210_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00210_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00210_A5 { + Cycle_a_00210_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00210_A5(String strObjectName) { + a4_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_a_00210_A6 { + Cycle_a_00210_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00210_A6(String strObjectName) { + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_a_00210_A7 { + Cycle_a_00210_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00210_A7(String strObjectName) { + a3_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } +} + +class ThreadRc_Cycle_am_00220B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00220_A1 a1_main = new Cycle_a_00220_A1("a1_main"); + Cycle_a_00220_A4 a4_main = new Cycle_a_00220_A4("a4_main"); + Cycle_a_00220_A6 a6_main = new Cycle_a_00220_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00220_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00220_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00220_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a4_0 = a4_main; + a4_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a5_0.a7_0 = new Cycle_a_00220_A7("a7_0"); + a6_main.a7_0 = a1_main.a2_0.a3_0.a5_0.a7_0; + a6_main.a5_0 = a1_main.a2_0.a3_0.a5_0; + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1772) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00220_A1 { + Cycle_a_00220_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00220_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00220_A2 { + Cycle_a_00220_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00220_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00220_A3 { + Cycle_a_00220_A1 a1_0; + Cycle_a_00220_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00220_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_00220_A4 { + Cycle_a_00220_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00220_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00220_A5 { + Cycle_a_00220_A4 a4_0; + Cycle_a_00220_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00220_A5(String strObjectName) { + a4_0 = null; + a7_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a4_0.a + a7_0.a; + } + } + + class Cycle_a_00220_A6 { + Cycle_a_00220_A5 a5_0; + Cycle_a_00220_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00220_A6(String strObjectName) { + a5_0 = null; + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a5_0.a + a7_0.a; + } + } + + class Cycle_a_00220_A7 { + int a; + int sum; + String strObjectName; + + Cycle_a_00220_A7(String strObjectName) { + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +class ThreadRc_Cycle_am_00230B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00230_A1 a1_main = new Cycle_a_00230_A1("a1_main"); + Cycle_a_00230_A5 a5_main = new Cycle_a_00230_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00230_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00230_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00230_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = a5_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a7_0 = new Cycle_a_00230_A7("a7_0"); + a5_main.a6_0 = new Cycle_a_00230_A6("a6_0"); + a5_main.a6_0.a7_0 = a5_main.a7_0; + + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a5_main.a7_0.add(); + a5_main.a6_0.add(); + + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a5_main.a6_0.sum + a5_main.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1773) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00230_A1 { + Cycle_a_00230_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00230_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00230_A2 { + Cycle_a_00230_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00230_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00230_A3 { + Cycle_a_00230_A1 a1_0; + Cycle_a_00230_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00230_A3(String strObjectName) { + a1_0 = null; + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a4_0.a; + } + } + + class Cycle_a_00230_A4 { + Cycle_a_00230_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00230_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_a_00230_A5 { + Cycle_a_00230_A3 a3_0; + Cycle_a_00230_A6 a6_0; + Cycle_a_00230_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00230_A5(String strObjectName) { + a3_0 = null; + a6_0 = null; + a7_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a6_0.a + a7_0.a; + } + } + + class Cycle_a_00230_A6 { + Cycle_a_00230_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00230_A6(String strObjectName) { + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_a_00230_A7 { + int a; + int sum; + String strObjectName; + + Cycle_a_00230_A7(String strObjectName) { + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +class ThreadRc_Cycle_am_00240B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00240_A1 a1_main = new Cycle_a_00240_A1("a1_main"); + Cycle_a_00240_A5 a5_main = new Cycle_a_00240_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00240_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00240_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00240_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = a5_main; + a1_main.a6_0 = new Cycle_a_00240_A6("a6_0"); + a1_main.a6_0.a7_0 = new Cycle_a_00240_A7("a7_0"); + a1_main.a6_0.a7_0.a1_0 = a1_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a6_0.add(); + a1_main.a6_0.a7_0.add(); + + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a6_0.sum + a1_main.a6_0.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1660) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00240_A1 { + Cycle_a_00240_A2 a2_0; + Cycle_a_00240_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00240_A1(String strObjectName) { + a2_0 = null; + a6_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a6_0.a; + } + } + + class Cycle_a_00240_A2 { + Cycle_a_00240_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00240_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00240_A3 { + Cycle_a_00240_A1 a1_0; + Cycle_a_00240_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00240_A3(String strObjectName) { + a1_0 = null; + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a4_0.a; + } + } + + class Cycle_a_00240_A4 { + Cycle_a_00240_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00240_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_a_00240_A5 { + Cycle_a_00240_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00240_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00240_A6 { + Cycle_a_00240_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00240_A6(String strObjectName) { + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_a_00240_A7 { + Cycle_a_00240_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00240_A7(String strObjectName) { + a1_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } +} + +class ThreadRc_Cycle_am_00250B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00250_A1 a1_main = new Cycle_a_00250_A1("a1_main"); + Cycle_a_00250_A6 a6_main = new Cycle_a_00250_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00250_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00250_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00250_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1238) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00250_A1 { + Cycle_a_00250_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00250_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00250_A2 { + Cycle_a_00250_A1 a1_0; + Cycle_a_00250_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00250_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_00250_A3 { + Cycle_a_00250_A1 a1_0; + Cycle_a_00250_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00250_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_00250_A5 { + Cycle_a_00250_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00250_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00250_A6 { + Cycle_a_00250_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00250_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } +} + +class ThreadRc_Cycle_am_00260B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00260_A1 a1_main = new Cycle_a_00260_A1("a1_main"); + Cycle_a_00260_A6 a6_main = new Cycle_a_00260_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00260_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00260_A3("a3_0"); + a1_main.a2_0.a3_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00260_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1239) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00260_A1 { + Cycle_a_00260_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00260_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00260_A2 { + Cycle_a_00260_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00260_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00260_A3 { + Cycle_a_00260_A1 a1_0; + Cycle_a_00260_A2 a2_0; + Cycle_a_00260_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00260_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a2_0.a + a5_0.a; + } + } + + class Cycle_a_00260_A5 { + Cycle_a_00260_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00260_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00260_A6 { + Cycle_a_00260_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00260_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } +} + +class ThreadRc_Cycle_am_00270B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00270_A1 a1_main = new Cycle_a_00270_A1("a1_main"); + Cycle_a_00270_A6 a6_main = new Cycle_a_00270_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00270_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00270_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00270_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1240) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00270_A1 { + Cycle_a_00270_A2 a2_0; + Cycle_a_00270_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00270_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } + } + + class Cycle_a_00270_A2 { + Cycle_a_00270_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00270_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00270_A3 { + Cycle_a_00270_A1 a1_0; + Cycle_a_00270_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00270_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_00270_A5 { + Cycle_a_00270_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00270_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00270_A6 { + Cycle_a_00270_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00270_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } +} + +class ThreadRc_Cycle_am_00280B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00280_A1 a1_main = new Cycle_a_00280_A1("a1_main"); + Cycle_a_00280_A6 a6_main = new Cycle_a_00280_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00280_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00280_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00280_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a3_0 = a1_main.a2_0.a3_0; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1443) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00280_A1 { + Cycle_a_00280_A2 a2_0; + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00280_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } + } + + class Cycle_a_00280_A2 { + Cycle_a_00280_A1 a1_0; + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00280_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_00280_A3 { + Cycle_a_00280_A1 a1_0; + Cycle_a_00280_A2 a2_0; + Cycle_a_00280_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00280_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a2_0.a + a5_0.a; + } + } + + class Cycle_a_00280_A5 { + Cycle_a_00280_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00280_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00280_A6 { + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00280_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } +} + +class ThreadRc_Cycle_am_00290B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00290_A1 a1_main = new Cycle_a_00290_A1("a1_main"); + Cycle_a_00290_A5 a5_main = new Cycle_a_00290_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00290_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00290_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00290_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = a5_main; + a1_main.a2_0.a3_0.a6_0 = new Cycle_a_00290_A6("a6_0"); + a1_main.a2_0.a3_0.a6_0.a2_0 = a1_main.a2_0; + a5_main.a3_0 = a1_main.a2_0.a3_0; + + + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a6_0.add(); + + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a6_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1447) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00290_A1 { + Cycle_a_00290_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00290_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00290_A2 { + Cycle_a_00290_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00290_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00290_A3 { + Cycle_a_00290_A1 a1_0; + Cycle_a_00290_A4 a4_0; + Cycle_a_00290_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00290_A3(String strObjectName) { + a1_0 = null; + a4_0 = null; + a6_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a4_0.a + a6_0.a; + } + } + + class Cycle_a_00290_A4 { + Cycle_a_00290_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00290_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_a_00290_A5 { + Cycle_a_00290_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00290_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00290_A6 { + Cycle_a_00290_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00290_A6(String strObjectName) { + a2_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } +} + +class ThreadRc_Cycle_am_00300B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00300_A1 a1_main = new Cycle_a_00300_A1("a1_main"); + Cycle_a_00300_A5 a5_main = new Cycle_a_00300_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00300_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00300_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00300_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = a5_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a3_0.a4_0.a6_0 = new Cycle_a_00300_A6("a6_0"); + a5_main.a3_0.a4_0.a6_0.a3_0 = a1_main.a2_0.a3_0; + a5_main.a3_0.a4_0.a5_0 = a5_main; + + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); + + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a6_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1448) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00300_A1 { + Cycle_a_00300_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00300_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00300_A2 { + Cycle_a_00300_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00300_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00300_A3 { + Cycle_a_00300_A1 a1_0; + Cycle_a_00300_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00300_A3(String strObjectName) { + a1_0 = null; + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a4_0.a; + } + } + + class Cycle_a_00300_A4 { + Cycle_a_00300_A5 a5_0; + Cycle_a_00300_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00300_A4(String strObjectName) { + a5_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a + a6_0.a; + } + } + + class Cycle_a_00300_A5 { + Cycle_a_00300_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00300_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00300_A6 { + Cycle_a_00300_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00300_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } +} + +class ThreadRc_Cycle_am_00310B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00310_A1 a1_main = new Cycle_a_00310_A1("a1_main"); + Cycle_a_00310_A4 a4_main = new Cycle_a_00310_A4("a4_main"); + Cycle_a_00310_A6 a6_main = new Cycle_a_00310_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00310_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00310_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00310_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a4_0 = a4_main; + a6_main.a1_0 = a1_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a6_main.a3_0.a5_0 = a1_main.a2_0.a3_0.a5_0; + a4_main.a6_0 = a6_main; + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1552) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00310_A1 { + Cycle_a_00310_A2 a2_0; + Cycle_a_00310_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00310_A1(String strObjectName) { + a2_0 = null; + a4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a4_0.a; + } + } + + class Cycle_a_00310_A2 { + Cycle_a_00310_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00310_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00310_A3 { + Cycle_a_00310_A1 a1_0; + Cycle_a_00310_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00310_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_00310_A4 { + Cycle_a_00310_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00310_A4(String strObjectName) { + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00310_A5 { + Cycle_a_00310_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00310_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00310_A6 { + Cycle_a_00310_A1 a1_0; + Cycle_a_00310_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00310_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } +} + +class ThreadRc_Cycle_am_00320B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00320_A1 a1_main = new Cycle_a_00320_A1("a1_main"); + Cycle_a_00320_A4 a4_main = new Cycle_a_00320_A4("a4_main"); + Cycle_a_00320_A6 a6_main = new Cycle_a_00320_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00320_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00320_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00320_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a4_main.a5_0 = a1_main.a2_0.a3_0.a5_0; + a6_main.a4_0 = a4_main; + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1551) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00320_A1 { + Cycle_a_00320_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00320_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00320_A2 { + Cycle_a_00320_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00320_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00320_A3 { + Cycle_a_00320_A1 a1_0; + Cycle_a_00320_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00320_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_00320_A4 { + Cycle_a_00320_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00320_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_a_00320_A5 { + Cycle_a_00320_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00320_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00320_A6 { + Cycle_a_00320_A1 a1_0; + Cycle_a_00320_A3 a3_0; + Cycle_a_00320_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00320_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } + } +} + +class ThreadRc_Cycle_am_00330B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00330_A1 a1_main = new Cycle_a_00330_A1("a1_main"); + Cycle_a_00330_A4 a4_main = new Cycle_a_00330_A4("a4_main"); + Cycle_a_00330_A6 a6_main = new Cycle_a_00330_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00330_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00330_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00330_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00330_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00330_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a3_0 = a1_main.a2_0.a3_0; + a6_main.a1_0 = a1_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 2080) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00330_A1 { + Cycle_a_00330_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00330_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00330_A2 { + Cycle_a_00330_A3 a3_0; + Cycle_a_00330_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00330_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + + class Cycle_a_00330_A3 { + Cycle_a_00330_A1 a1_0; + Cycle_a_00330_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00330_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_00330_A4 { + Cycle_a_00330_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00330_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_00330_A5 { + Cycle_a_00330_A6 a6_0; + Cycle_a_00330_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00330_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + + class Cycle_a_00330_A6 { + Cycle_a_00330_A1 a1_0; + Cycle_a_00330_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00330_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_00330_A7 { + Cycle_a_00330_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00330_A7(String strObjectName) { + a3_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00330_A8 { + Cycle_a_00330_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00330_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } +} + +class ThreadRc_Cycle_am_00340B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00340_A1 a1_main = new Cycle_a_00340_A1("a1_main"); + Cycle_a_00340_A4 a4_main = new Cycle_a_00340_A4("a4_main"); + Cycle_a_00340_A6 a6_main = new Cycle_a_00340_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00340_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00340_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00340_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a2_0.a3_0.a8_0 = new Cycle_a_00340_A8("a8_0"); + a1_main.a2_0.a3_0.a8_0.a7_0 = new Cycle_a_00340_A7("a7_0"); + a1_main.a2_0.a3_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a6_main.a1_0 = a1_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a8_0.add(); + a1_main.a2_0.a3_0.a8_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a8_0.a7_0.sum + a6_main.a3_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 2079) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00340_A1 { + Cycle_a_00340_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00340_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00340_A2 { + Cycle_a_00340_A3 a3_0; + Cycle_a_00340_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00340_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + + class Cycle_a_00340_A3 { + Cycle_a_00340_A1 a1_0; + Cycle_a_00340_A5 a5_0; + Cycle_a_00340_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00340_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a8_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a + a8_0.a; + } + } + + class Cycle_a_00340_A4 { + Cycle_a_00340_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00340_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_00340_A5 { + Cycle_a_00340_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00340_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00340_A6 { + Cycle_a_00340_A1 a1_0; + Cycle_a_00340_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00340_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_00340_A7 { + Cycle_a_00340_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00340_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00340_A8 { + Cycle_a_00340_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00340_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } +} + +class ThreadRc_Cycle_am_00350B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00350_A1 a1_main = new Cycle_a_00350_A1("a1_main"); + Cycle_a_00350_A4 a4_main = new Cycle_a_00350_A4("a4_main"); + Cycle_a_00350_A6 a6_main = new Cycle_a_00350_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00350_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00350_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00350_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00350_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00350_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 2079) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00350_A1 { + Cycle_a_00350_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00350_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00350_A2 { + Cycle_a_00350_A3 a3_0; + Cycle_a_00350_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00350_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + + class Cycle_a_00350_A3 { + Cycle_a_00350_A1 a1_0; + Cycle_a_00350_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00350_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_00350_A4 { + Cycle_a_00350_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00350_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_00350_A5 { + Cycle_a_00350_A6 a6_0; + Cycle_a_00350_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00350_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + + class Cycle_a_00350_A6 { + Cycle_a_00350_A1 a1_0; + Cycle_a_00350_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00350_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_00350_A7 { + Cycle_a_00350_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00350_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00350_A8 { + Cycle_a_00350_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00350_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } +} + +class ThreadRc_Cycle_am_00360B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00360_A1 a1_main = new Cycle_a_00360_A1("a1_main"); + Cycle_a_00360_A4 a4_main = new Cycle_a_00360_A4("a4_main"); + Cycle_a_00360_A6 a6_main = new Cycle_a_00360_A6("a6_main"); + Cycle_a_00360_A9 a9_main = new Cycle_a_00360_A9("a9_main"); + a1_main.a2_0 = new Cycle_a_00360_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00360_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00360_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00360_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00360_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a5_0.a9_0 = a9_main; + a9_main.a2_0 = a1_main.a2_0; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a9_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a9_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 2399) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00360_A1 { + Cycle_a_00360_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00360_A2 { + Cycle_a_00360_A3 a3_0; + Cycle_a_00360_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + + class Cycle_a_00360_A3 { + Cycle_a_00360_A1 a1_0; + Cycle_a_00360_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_00360_A4 { + Cycle_a_00360_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_00360_A5 { + Cycle_a_00360_A6 a6_0; + Cycle_a_00360_A8 a8_0; + Cycle_a_00360_A9 a9_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a9_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a + a8_0.a + a9_0.a; + } + } + + class Cycle_a_00360_A6 { + Cycle_a_00360_A1 a1_0; + Cycle_a_00360_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_00360_A7 { + Cycle_a_00360_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00360_A8 { + Cycle_a_00360_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_a_00360_A9 { + Cycle_a_00360_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00360_A9(String strObjectName) { + a2_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } +} + +class ThreadRc_Cycle_am_00370B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00370_A1 a1_main = new Cycle_a_00370_A1("a1_main"); + Cycle_a_00370_A4 a4_main = new Cycle_a_00370_A4("a4_main"); + Cycle_a_00370_A6 a6_main = new Cycle_a_00370_A6("a6_main"); + Cycle_a_00370_A9 a9_main = new Cycle_a_00370_A9("a9_main"); + a1_main.a2_0 = new Cycle_a_00370_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00370_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00370_A5("a5_0"); + a1_main.a2_0.a3_0.a10_0 = new Cycle_a_00370_A10("a10_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00370_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00370_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a10_0.a9_0 = a9_main; + a9_main.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a9_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a10_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a9_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum + a6_main.a3_0.a10_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 2623) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00370_A1 { + Cycle_a_00370_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00370_A2 { + Cycle_a_00370_A3 a3_0; + Cycle_a_00370_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + + class Cycle_a_00370_A3 { + Cycle_a_00370_A1 a1_0; + Cycle_a_00370_A5 a5_0; + Cycle_a_00370_A10 a10_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a10_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a + a10_0.a; + } + } + + class Cycle_a_00370_A4 { + Cycle_a_00370_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_00370_A5 { + Cycle_a_00370_A6 a6_0; + Cycle_a_00370_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + + class Cycle_a_00370_A6 { + Cycle_a_00370_A1 a1_0; + Cycle_a_00370_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_00370_A7 { + Cycle_a_00370_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00370_A8 { + Cycle_a_00370_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_a_00370_A9 { + Cycle_a_00370_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A9(String strObjectName) { + a6_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00370_A10 { + Cycle_a_00370_A9 a9_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A10(String strObjectName) { + a9_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + + void add() { + sum = a + a9_0.a; + } + } +} + +class ThreadRc_Cycle_am_00380B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00380_A1 a1_main = new Cycle_a_00380_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00380_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00380_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a2_0 = a1_main.a2_0; + + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 815) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00380_A1 { + Cycle_a_00380_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00380_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00380_A2 { + Cycle_a_00380_A1 a1_0; + Cycle_a_00380_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00380_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_00380_A3 { + Cycle_a_00380_A1 a1_0; + Cycle_a_00380_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00380_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a2_0.a; + } + } +} + +class ThreadRc_Cycle_am_00390B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00390_A1 a1_main = new Cycle_a_00390_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00390_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00390_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 918) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00390_A1 { + Cycle_a_00390_A2 a2_0; + Cycle_a_00390_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00390_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } + } + + class Cycle_a_00390_A2 { + Cycle_a_00390_A1 a1_0; + Cycle_a_00390_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00390_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_00390_A3 { + Cycle_a_00390_A1 a1_0; + Cycle_a_00390_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00390_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a2_0.a; + } + } +} + +class ThreadRc_Cycle_am_00400B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00400_A1 a1_main = new Cycle_a_00400_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00400_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00400_A3("a3_0"); + a1_main.a4_0 = new Cycle_a_00400_A4("a4_0"); + a1_main.a4_0.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a1_0 = a1_main; + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a4_0.add(); + + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 923) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00400_A1 { + Cycle_a_00400_A2 a2_0; + Cycle_a_00400_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00400_A1(String strObjectName) { + a2_0 = null; + a4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a4_0.a; + } + } + + class Cycle_a_00400_A2 { + Cycle_a_00400_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00400_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00400_A3 { + Cycle_a_00400_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00400_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_00400_A4 { + Cycle_a_00400_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00400_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } +} + +class ThreadRc_Cycle_am_00410B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00410_A1 a1_main = new Cycle_a_00410_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00410_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00410_A3("a3_0"); + a1_main.a2_0.a4_0 = new Cycle_a_00410_A4("a4_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a4_0.a1_0 = a1_main; + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a4_0.add(); + + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 921) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00410_A1 { + Cycle_a_00410_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00410_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00410_A2 { + Cycle_a_00410_A3 a3_0; + Cycle_a_00410_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00410_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + + class Cycle_a_00410_A3 { + Cycle_a_00410_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00410_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_00410_A4 { + Cycle_a_00410_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00410_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } +} + +class ThreadRc_Cycle_am_00420B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00420_A1 a1_main = new Cycle_a_00420_A1("a1_main"); +// Cycle_a_00420_A4 a4_main = new Cycle_a_00420_A4("a4_main"); + a1_main.a2_0 = new Cycle_a_00420_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00420_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00420_A4("a4_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 923) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00420_A1 { + Cycle_a_00420_A2 a2_0; + Cycle_a_00420_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00420_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } + } + + class Cycle_a_00420_A2 { + Cycle_a_00420_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00420_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00420_A3 { + Cycle_a_00420_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00420_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_a_00420_A4 { + Cycle_a_00420_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00420_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } +} + +class ThreadRc_Cycle_am_00430B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00430_A1 a1_main = new Cycle_a_00430_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00430_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00430_A3("a3_0"); + a1_main.a2_0.a4_0 = new Cycle_a_00430_A4("a4_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a4_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a4_0.a1_0 = a1_main; + + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a4_0.add(); + + + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1124) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00430_A1 { + Cycle_a_00430_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00430_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00430_A2 { + Cycle_a_00430_A1 a1_0; + Cycle_a_00430_A3 a3_0; + Cycle_a_00430_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00430_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } + } + + class Cycle_a_00430_A3 { + Cycle_a_00430_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00430_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_00430_A4 { + Cycle_a_00430_A1 a1_0; + Cycle_a_00430_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00430_A4(String strObjectName) { + a2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a2_0.a; + } + } +} + +class ThreadRc_Cycle_am_00440B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00440_A1 a1_main = new Cycle_a_00440_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00440_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00440_A3("a3_0"); + a1_main.a2_0.a4_0 = new Cycle_a_00440_A4("a4_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a4_0.a2_0 = a1_main.a2_0; + + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a4_0.add(); + + + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1023) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00440_A1 { + Cycle_a_00440_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00440_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00440_A2 { + Cycle_a_00440_A1 a1_0; + Cycle_a_00440_A3 a3_0; + Cycle_a_00440_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00440_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } + } + + class Cycle_a_00440_A3 { + Cycle_a_00440_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00440_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_00440_A4 { + Cycle_a_00440_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00440_A4(String strObjectName) { + a2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } +} + +class ThreadRc_Cycle_am_00450B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00450_A1 a1_main = new Cycle_a_00450_A1("a1_main"); + Cycle_a_00450_A6 a6_main = new Cycle_a_00450_A6("a6_main"); + Cycle_a_00450_A7 a7_main = new Cycle_a_00450_A7("a7_main"); + a1_main.a2_0 = new Cycle_a_00450_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00450_A3("a3_0"); + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00450_A5("a5_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a5_0.a7_0 = a7_main; + a7_main.a2_0 = a1_main.a2_0; + + a1_main.add(); + a6_main.add(); + a7_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + + + int result = a1_main.sum + a6_main.sum + a7_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1453) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00450_A1 { + Cycle_a_00450_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00450_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00450_A2 { + Cycle_a_00450_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00450_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00450_A3 { + Cycle_a_00450_A1 a1_0; + Cycle_a_00450_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00450_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_00450_A5 { + Cycle_a_00450_A6 a6_0; + Cycle_a_00450_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00450_A5(String strObjectName) { + a6_0 = null; + a7_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a + a7_0.a; + } + } + + class Cycle_a_00450_A6 { + Cycle_a_00450_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00450_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00450_A7 { + Cycle_a_00450_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00450_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } +} + +class ThreadRc_Cycle_am_00460B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00460_A1 a1_main = new Cycle_a_00460_A1("a1_main"); + Cycle_a_00460_A5 a5_main = new Cycle_a_00460_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00460_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00460_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00460_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.a2_0.a3_0.a4_0.a6_0 = new Cycle_a_00460_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a1_main.a2_0.a3_0.a4_0.a6_0.a1_0 = a1_main; + + a5_main.a3_0 = a1_main.a2_0.a3_0; + + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); + + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a6_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1550) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00460_A1 { + Cycle_a_00460_A2 a2_0; + Cycle_a_00460_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00460_A1(String strObjectName) { + a2_0 = null; + a4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a4_0.a; + } + } + + class Cycle_a_00460_A2 { + Cycle_a_00460_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00460_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00460_A3 { + Cycle_a_00460_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00460_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_a_00460_A4 { + Cycle_a_00460_A1 a1_0; + Cycle_a_00460_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00460_A4(String strObjectName) { + a1_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a6_0.a; + } + } + + class Cycle_a_00460_A5 { + Cycle_a_00460_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00460_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00460_A6 { + Cycle_a_00460_A1 a1_0; + Cycle_a_00460_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00460_A6(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } +} + +class ThreadRc_Cycle_am_00470B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00470_A1 a1_main = new Cycle_a_00470_A1("a1_main"); + Cycle_a_00470_A5 a5_main = new Cycle_a_00470_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00470_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00470_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00470_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0.a6_0 = new Cycle_a_00470_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a1_0 = a1_main; + + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); + + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a6_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1446) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00470_A1 { + Cycle_a_00470_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00470_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00470_A2 { + Cycle_a_00470_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00470_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00470_A3 { + Cycle_a_00470_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00470_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_a_00470_A4 { + Cycle_a_00470_A1 a1_0; + Cycle_a_00470_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00470_A4(String strObjectName) { + a1_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a6_0.a; + } + } + + class Cycle_a_00470_A5 { + Cycle_a_00470_A1 a1_0; + Cycle_a_00470_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00470_A5(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_00470_A6 { + Cycle_a_00470_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00470_A6(String strObjectName) { + a5_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } + } +} + +class ThreadRc_Cycle_am_00480B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00480_A1 a1_main = new Cycle_a_00480_A1("a1_main"); + Cycle_a_00480_A5 a5_main = new Cycle_a_00480_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00480_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00480_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00480_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0.a6_0 = new Cycle_a_00480_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a1_main.a2_0.a3_0.a4_0.a6_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.a2_0.a3_0.a4_0.a6_0.a1_0 = a1_main; + + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a3_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + + + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a1_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); +// a1_main.a2_0.a3_0.a4_0.a6_0.a5_0.add(); +// a1_main.a2_0.a3_0.a4_0.a6_0.a4_0.add(); +// a1_main.a2_0.a3_0.a4_0.a6_0.a1_0.add(); + + a5_main.a3_0.add(); + a5_main.a3_0.a4_0.add(); + +// System.out.println("a1_main.sum:"+a1_main.sum); +// System.out.println("a4_main.sum:"+a5_main.sum); +// System.out.println("a1_main.a2_0.sum:"+a1_main.a2_0.sum); +// System.out.println("a1_main.a2_0.a3_0.sum:"+a1_main.a2_0.a3_0.sum); +// System.out.println("a1_main.a2_0.a3_0.a4_0.sum:"+a1_main.a2_0.a3_0.a4_0.sum); +// System.out.println("a1_main.a2_0.a3_0.a4_0.a6_0.sum:"+a1_main.a2_0.a3_0.a4_0.a6_0.sum); +// System.out.println("a1_main.a2_0.a3_0.a4_0.a6_0.a4_0.sum:"+a1_main.a2_0.a3_0.a4_0.a6_0.a4_0.sum); + + +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a5_main.sum+a1_main.a2_0.sum+a1_main.a2_0.a3_0.sum+a1_main.a2_0.a3_0.a4_0.sum+a1_main.a2_0.a3_0.a4_0.a6_0.sum); + + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a6_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1550) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00480_A1 { + Cycle_a_00480_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00480_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00480_A2 { + Cycle_a_00480_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00480_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00480_A3 { + Cycle_a_00480_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00480_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_a_00480_A4 { + Cycle_a_00480_A1 a1_0; + Cycle_a_00480_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00480_A4(String strObjectName) { + a1_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a6_0.a; + } + } + + class Cycle_a_00480_A5 { + Cycle_a_00480_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00480_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00480_A6 { + Cycle_a_00480_A1 a1_0; + Cycle_a_00480_A4 a4_0; + Cycle_a_00480_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00480_A6(String strObjectName) { + a1_0 = null; + a4_0 = null; + a5_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a4_0.a + a5_0.a; + } + } +} + +class ThreadRc_Cycle_am_00490B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00490_A1 a1_main = new Cycle_a_00490_A1("a1_main"); + Cycle_a_00490_A4 a4_main = new Cycle_a_00490_A4("a4_main"); + Cycle_a_00490_A7 a7_main = new Cycle_a_00490_A7("a7_main"); + a1_main.a2_0 = new Cycle_a_00490_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00490_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + + a4_main.a5_0 = new Cycle_a_00490_A5("a5_0"); + a4_main.a5_0.a6_0 = new Cycle_a_00490_A6("a6_0"); + a4_main.a5_0.a6_0.a4_0 = a4_main; +// a4_main.a5_0.a6_0.a3_0 = new Cycle_a_00490_A3("a3_0"); + a4_main.a5_0.a6_0.a3_0 = a1_main.a2_0.a3_0; + a4_main.a5_0.a6_0.a3_0.a1_0 = a1_main; + + a7_main.a9_0 = new Cycle_a_00490_A9("a9_0"); + a7_main.a9_0.a8_0 = new Cycle_a_00490_A8("a8_0"); + a7_main.a9_0.a8_0.a7_0 = a7_main; + a7_main.a9_0.a8_0.a5_0 = a4_main.a5_0; + + a1_main.add(); + a4_main.add(); + a7_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a1_0.add(); + a4_main.a5_0.add(); + a4_main.a5_0.a6_0.add(); + a4_main.a5_0.a6_0.a4_0.add(); + a4_main.a5_0.a6_0.a3_0.add(); + a4_main.a5_0.a6_0.a3_0.a1_0.add(); + + a7_main.a9_0.add(); + a7_main.a9_0.a8_0.add(); + a7_main.a9_0.a8_0.a7_0.add(); + a7_main.a9_0.a8_0.a5_0.add(); +// +// System.out.println("a1_main.sum:"+a1_main.sum); +// System.out.println("a4_main.sum:"+a4_main.sum); +// System.out.println("a7_main.sum:"+a7_main.sum); +// System.out.println("a1_main.a2_0.sum:"+a1_main.a2_0.sum); +// System.out.println("a1_main.a2_0.a3_0.sum:"+a1_main.a2_0.a3_0.sum); +// System.out.println("a4_main.a5_0.sum:"+a4_main.a5_0.sum); +// System.out.println("a4_main.a5_0.a6_0.sum:"+a4_main.a5_0.a6_0.sum); +// System.out.println("a7_main.a9_0.sum:"+a7_main.a9_0.sum); +// System.out.println("a7_main.a9_0.a8_0.sum:"+a7_main.a9_0.a8_0.sum); + + +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a4_main.sum+a7_main.sum+a1_main.a2_0.sum+a1_main.a2_0.a3_0.sum+a4_main.a5_0.sum+a4_main.a5_0.a6_0.sum+a7_main.a9_0.sum+a7_main.a9_0.a8_0.sum); + + int result = a1_main.sum + a4_main.sum + a7_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a4_main.a5_0.sum + a4_main.a5_0.a6_0.sum + a7_main.a9_0.sum + a7_main.a9_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 2098) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00490_A1 { + Cycle_a_00490_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00490_A2 { + Cycle_a_00490_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00490_A3 { + Cycle_a_00490_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_00490_A4 { + Cycle_a_00490_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_a_00490_A5 { + Cycle_a_00490_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00490_A6 { + Cycle_a_00490_A3 a3_0; + Cycle_a_00490_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A6(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + + class Cycle_a_00490_A7 { + Cycle_a_00490_A9 a9_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A7(String strObjectName) { + a9_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a9_0.a; + } + } + + class Cycle_a_00490_A8 { + Cycle_a_00490_A5 a5_0; + Cycle_a_00490_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A8(String strObjectName) { + a5_0 = null; + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a + a5_0.a; + } + } + + class Cycle_a_00490_A9 { + Cycle_a_00490_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00490_A9(String strObjectName) { + a8_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + + void add() { + sum = a + a8_0.a; + } + } +} + +class ThreadRc_Cycle_am_00500B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00500_A1 a1_main = new Cycle_a_00500_A1("a1_main"); + Cycle_a_00500_A4 a4_main = new Cycle_a_00500_A4("a4_main"); + Cycle_a_00500_A7 a7_main = new Cycle_a_00500_A7("a7_main"); + a1_main.a2_0 = new Cycle_a_00500_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00500_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + + a4_main.a1_0 = a1_main; + a4_main.a5_0 = new Cycle_a_00500_A5("a5_0"); + a4_main.a5_0.a6_0 = new Cycle_a_00500_A6("a6_0"); + a4_main.a5_0.a6_0.a4_0 = a4_main; + + a4_main.a5_0.a8_0 = new Cycle_a_00500_A8("a8_0"); + a4_main.a5_0.a8_0.a7_0 = a7_main; + + a7_main.a9_0 = new Cycle_a_00500_A9("a9_0"); + a7_main.a9_0.a8_0 = new Cycle_a_00500_A8("a8_0"); + a7_main.a9_0.a8_0.a7_0 = a7_main; + + a1_main.add(); + a4_main.add(); + a7_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a1_0.add(); + a4_main.a1_0.add(); + a4_main.a5_0.add(); + a4_main.a5_0.a6_0.add(); + a4_main.a5_0.a6_0.a4_0.add(); + a4_main.a5_0.a8_0.add(); + a4_main.a5_0.a8_0.a7_0.add(); + a7_main.a9_0.add(); + a7_main.a9_0.a8_0.add(); + a7_main.a9_0.a8_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a7_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a4_main.a5_0.sum + a4_main.a5_0.a6_0.sum + a7_main.a9_0.sum + a7_main.a9_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 2099) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00500_A1 { + Cycle_a_00500_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00500_A2 { + Cycle_a_00500_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_00500_A3 { + Cycle_a_00500_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_00500_A4 { + Cycle_a_00500_A1 a1_0; + Cycle_a_00500_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A4(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_00500_A5 { + Cycle_a_00500_A6 a6_0; + Cycle_a_00500_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + + class Cycle_a_00500_A6 { + Cycle_a_00500_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A6(String strObjectName) { + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_a_00500_A7 { + Cycle_a_00500_A9 a9_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A7(String strObjectName) { + a9_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a9_0.a; + } + } + + class Cycle_a_00500_A8 { + Cycle_a_00500_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_a_00500_A9 { + Cycle_a_00500_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00500_A9(String strObjectName) { + a8_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + + void add() { + sum = a + a8_0.a; + } + } +} + +public class Cycle_am_00510 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00180B A1_Cycle_am_00180 = new ThreadRc_Cycle_am_00180B(); + ThreadRc_Cycle_am_00180B A2_Cycle_am_00180 = new ThreadRc_Cycle_am_00180B(); + ThreadRc_Cycle_am_00190B A1_Cycle_am_00190 = new ThreadRc_Cycle_am_00190B(); + ThreadRc_Cycle_am_00190B A2_Cycle_am_00190 = new ThreadRc_Cycle_am_00190B(); + ThreadRc_Cycle_am_00200B A1_Cycle_am_00200 = new ThreadRc_Cycle_am_00200B(); + ThreadRc_Cycle_am_00200B A2_Cycle_am_00200 = new ThreadRc_Cycle_am_00200B(); + ThreadRc_Cycle_am_00210B A1_Cycle_am_00210 = new ThreadRc_Cycle_am_00210B(); + ThreadRc_Cycle_am_00210B A2_Cycle_am_00210 = new ThreadRc_Cycle_am_00210B(); + ThreadRc_Cycle_am_00220B A1_Cycle_am_00220 = new ThreadRc_Cycle_am_00220B(); + ThreadRc_Cycle_am_00220B A2_Cycle_am_00220 = new ThreadRc_Cycle_am_00220B(); + ThreadRc_Cycle_am_00230B A1_Cycle_am_00230 = new ThreadRc_Cycle_am_00230B(); + ThreadRc_Cycle_am_00230B A2_Cycle_am_00230 = new ThreadRc_Cycle_am_00230B(); + ThreadRc_Cycle_am_00240B A1_Cycle_am_00240 = new ThreadRc_Cycle_am_00240B(); + ThreadRc_Cycle_am_00240B A2_Cycle_am_00240 = new ThreadRc_Cycle_am_00240B(); + ThreadRc_Cycle_am_00250B A1_Cycle_am_00250 = new ThreadRc_Cycle_am_00250B(); + ThreadRc_Cycle_am_00250B A2_Cycle_am_00250 = new ThreadRc_Cycle_am_00250B(); + ThreadRc_Cycle_am_00260B A1_Cycle_am_00260 = new ThreadRc_Cycle_am_00260B(); + ThreadRc_Cycle_am_00260B A2_Cycle_am_00260 = new ThreadRc_Cycle_am_00260B(); + ThreadRc_Cycle_am_00270B A1_Cycle_am_00270 = new ThreadRc_Cycle_am_00270B(); + ThreadRc_Cycle_am_00270B A2_Cycle_am_00270 = new ThreadRc_Cycle_am_00270B(); + ThreadRc_Cycle_am_00280B A1_Cycle_am_00280 = new ThreadRc_Cycle_am_00280B(); + ThreadRc_Cycle_am_00280B A2_Cycle_am_00280 = new ThreadRc_Cycle_am_00280B(); + ThreadRc_Cycle_am_00290B A1_Cycle_am_00290 = new ThreadRc_Cycle_am_00290B(); + ThreadRc_Cycle_am_00290B A2_Cycle_am_00290 = new ThreadRc_Cycle_am_00290B(); + ThreadRc_Cycle_am_00300B A1_Cycle_am_00300 = new ThreadRc_Cycle_am_00300B(); + ThreadRc_Cycle_am_00300B A2_Cycle_am_00300 = new ThreadRc_Cycle_am_00300B(); + ThreadRc_Cycle_am_00310B A1_Cycle_am_00310 = new ThreadRc_Cycle_am_00310B(); + ThreadRc_Cycle_am_00310B A2_Cycle_am_00310 = new ThreadRc_Cycle_am_00310B(); + ThreadRc_Cycle_am_00320B A1_Cycle_am_00320 = new ThreadRc_Cycle_am_00320B(); + ThreadRc_Cycle_am_00320B A2_Cycle_am_00320 = new ThreadRc_Cycle_am_00320B(); + ThreadRc_Cycle_am_00330B A1_Cycle_am_00330 = new ThreadRc_Cycle_am_00330B(); + ThreadRc_Cycle_am_00330B A2_Cycle_am_00330 = new ThreadRc_Cycle_am_00330B(); + ThreadRc_Cycle_am_00340B A1_Cycle_am_00340 = new ThreadRc_Cycle_am_00340B(); + ThreadRc_Cycle_am_00340B A2_Cycle_am_00340 = new ThreadRc_Cycle_am_00340B(); + ThreadRc_Cycle_am_00350B A1_Cycle_am_00350 = new ThreadRc_Cycle_am_00350B(); + ThreadRc_Cycle_am_00350B A2_Cycle_am_00350 = new ThreadRc_Cycle_am_00350B(); + ThreadRc_Cycle_am_00360B A1_Cycle_am_00360 = new ThreadRc_Cycle_am_00360B(); + ThreadRc_Cycle_am_00360B A2_Cycle_am_00360 = new ThreadRc_Cycle_am_00360B(); + ThreadRc_Cycle_am_00370B A1_Cycle_am_00370 = new ThreadRc_Cycle_am_00370B(); + ThreadRc_Cycle_am_00370B A2_Cycle_am_00370 = new ThreadRc_Cycle_am_00370B(); + ThreadRc_Cycle_am_00380B A1_Cycle_am_00380 = new ThreadRc_Cycle_am_00380B(); + ThreadRc_Cycle_am_00380B A2_Cycle_am_00380 = new ThreadRc_Cycle_am_00380B(); + ThreadRc_Cycle_am_00390B A1_Cycle_am_00390 = new ThreadRc_Cycle_am_00390B(); + ThreadRc_Cycle_am_00390B A2_Cycle_am_00390 = new ThreadRc_Cycle_am_00390B(); + ThreadRc_Cycle_am_00400B A1_Cycle_am_00400 = new ThreadRc_Cycle_am_00400B(); + ThreadRc_Cycle_am_00400B A2_Cycle_am_00400 = new ThreadRc_Cycle_am_00400B(); + ThreadRc_Cycle_am_00410B A1_Cycle_am_00410 = new ThreadRc_Cycle_am_00410B(); + ThreadRc_Cycle_am_00410B A2_Cycle_am_00410 = new ThreadRc_Cycle_am_00410B(); + ThreadRc_Cycle_am_00420B A1_Cycle_am_00420 = new ThreadRc_Cycle_am_00420B(); + ThreadRc_Cycle_am_00420B A2_Cycle_am_00420 = new ThreadRc_Cycle_am_00420B(); + ThreadRc_Cycle_am_00430B A1_Cycle_am_00430 = new ThreadRc_Cycle_am_00430B(); + ThreadRc_Cycle_am_00430B A2_Cycle_am_00430 = new ThreadRc_Cycle_am_00430B(); + ThreadRc_Cycle_am_00440B A1_Cycle_am_00440 = new ThreadRc_Cycle_am_00440B(); + ThreadRc_Cycle_am_00440B A2_Cycle_am_00440 = new ThreadRc_Cycle_am_00440B(); + ThreadRc_Cycle_am_00450B A1_Cycle_am_00450 = new ThreadRc_Cycle_am_00450B(); + ThreadRc_Cycle_am_00450B A2_Cycle_am_00450 = new ThreadRc_Cycle_am_00450B(); + ThreadRc_Cycle_am_00460B A1_Cycle_am_00460 = new ThreadRc_Cycle_am_00460B(); + ThreadRc_Cycle_am_00460B A2_Cycle_am_00460 = new ThreadRc_Cycle_am_00460B(); + ThreadRc_Cycle_am_00470B A1_Cycle_am_00470 = new ThreadRc_Cycle_am_00470B(); + ThreadRc_Cycle_am_00470B A2_Cycle_am_00470 = new ThreadRc_Cycle_am_00470B(); + ThreadRc_Cycle_am_00480B A1_Cycle_am_00480 = new ThreadRc_Cycle_am_00480B(); + ThreadRc_Cycle_am_00480B A2_Cycle_am_00480 = new ThreadRc_Cycle_am_00480B(); + ThreadRc_Cycle_am_00490B A1_Cycle_am_00490 = new ThreadRc_Cycle_am_00490B(); + ThreadRc_Cycle_am_00490B A2_Cycle_am_00490 = new ThreadRc_Cycle_am_00490B(); + ThreadRc_Cycle_am_00500B A1_Cycle_am_00500 = new ThreadRc_Cycle_am_00500B(); + ThreadRc_Cycle_am_00500B A2_Cycle_am_00500 = new ThreadRc_Cycle_am_00500B(); + A1_Cycle_am_00180.start(); + A2_Cycle_am_00180.start(); + A1_Cycle_am_00190.start(); + A2_Cycle_am_00190.start(); + A1_Cycle_am_00200.start(); + A2_Cycle_am_00200.start(); + A1_Cycle_am_00210.start(); + A2_Cycle_am_00210.start(); + A1_Cycle_am_00220.start(); + A2_Cycle_am_00220.start(); + A1_Cycle_am_00230.start(); + A2_Cycle_am_00230.start(); + A1_Cycle_am_00240.start(); + A2_Cycle_am_00240.start(); + A1_Cycle_am_00250.start(); + A2_Cycle_am_00250.start(); + A1_Cycle_am_00260.start(); + A2_Cycle_am_00260.start(); + A1_Cycle_am_00270.start(); + A2_Cycle_am_00270.start(); + A1_Cycle_am_00280.start(); + A2_Cycle_am_00280.start(); + A1_Cycle_am_00290.start(); + A2_Cycle_am_00290.start(); + A1_Cycle_am_00300.start(); + A2_Cycle_am_00300.start(); + A1_Cycle_am_00310.start(); + A2_Cycle_am_00310.start(); + A1_Cycle_am_00320.start(); + A2_Cycle_am_00320.start(); + A1_Cycle_am_00330.start(); + A2_Cycle_am_00330.start(); + A1_Cycle_am_00340.start(); + A2_Cycle_am_00340.start(); + A1_Cycle_am_00350.start(); + A2_Cycle_am_00350.start(); + A1_Cycle_am_00360.start(); + A2_Cycle_am_00360.start(); + A1_Cycle_am_00370.start(); + A2_Cycle_am_00370.start(); + A1_Cycle_am_00380.start(); + A2_Cycle_am_00380.start(); + A1_Cycle_am_00390.start(); + A2_Cycle_am_00390.start(); + A1_Cycle_am_00400.start(); + A2_Cycle_am_00400.start(); + A1_Cycle_am_00410.start(); + A2_Cycle_am_00410.start(); + A1_Cycle_am_00420.start(); + A2_Cycle_am_00420.start(); + A1_Cycle_am_00430.start(); + A2_Cycle_am_00430.start(); + A1_Cycle_am_00440.start(); + A2_Cycle_am_00440.start(); + A1_Cycle_am_00450.start(); + A2_Cycle_am_00450.start(); + A1_Cycle_am_00460.start(); + A2_Cycle_am_00460.start(); + A1_Cycle_am_00470.start(); + A2_Cycle_am_00470.start(); + A1_Cycle_am_00480.start(); + A2_Cycle_am_00480.start(); + A1_Cycle_am_00490.start(); + A2_Cycle_am_00490.start(); + A1_Cycle_am_00500.start(); + A2_Cycle_am_00500.start(); + try { + A1_Cycle_am_00180.join(); + A2_Cycle_am_00180.join(); + A1_Cycle_am_00190.join(); + A2_Cycle_am_00190.join(); + A1_Cycle_am_00200.join(); + A2_Cycle_am_00200.join(); + A1_Cycle_am_00210.join(); + A2_Cycle_am_00210.join(); + A1_Cycle_am_00220.join(); + A2_Cycle_am_00220.join(); + A1_Cycle_am_00230.join(); + A2_Cycle_am_00230.join(); + A1_Cycle_am_00240.join(); + A2_Cycle_am_00240.join(); + A1_Cycle_am_00250.join(); + A2_Cycle_am_00250.join(); + A1_Cycle_am_00260.join(); + A2_Cycle_am_00260.join(); + A1_Cycle_am_00270.join(); + A2_Cycle_am_00270.join(); + A1_Cycle_am_00280.join(); + A2_Cycle_am_00280.join(); + A1_Cycle_am_00290.join(); + A2_Cycle_am_00290.join(); + A1_Cycle_am_00300.join(); + A2_Cycle_am_00300.join(); + A1_Cycle_am_00310.join(); + A2_Cycle_am_00310.join(); + A1_Cycle_am_00320.join(); + A2_Cycle_am_00320.join(); + A1_Cycle_am_00330.join(); + A2_Cycle_am_00330.join(); + A1_Cycle_am_00340.join(); + A2_Cycle_am_00340.join(); + A1_Cycle_am_00350.join(); + A2_Cycle_am_00350.join(); + A1_Cycle_am_00360.join(); + A2_Cycle_am_00360.join(); + A1_Cycle_am_00370.join(); + A2_Cycle_am_00370.join(); + A1_Cycle_am_00380.join(); + A2_Cycle_am_00380.join(); + A1_Cycle_am_00390.join(); + A2_Cycle_am_00390.join(); + A1_Cycle_am_00400.join(); + A2_Cycle_am_00400.join(); + A1_Cycle_am_00410.join(); + A2_Cycle_am_00410.join(); + A1_Cycle_am_00420.join(); + A2_Cycle_am_00420.join(); + A1_Cycle_am_00430.join(); + A2_Cycle_am_00430.join(); + A1_Cycle_am_00440.join(); + A2_Cycle_am_00440.join(); + A1_Cycle_am_00450.join(); + A2_Cycle_am_00450.join(); + A1_Cycle_am_00460.join(); + A2_Cycle_am_00460.join(); + A1_Cycle_am_00470.join(); + A2_Cycle_am_00470.join(); + A1_Cycle_am_00480.join(); + A2_Cycle_am_00480.join(); + A1_Cycle_am_00490.join(); + A2_Cycle_am_00490.join(); + A1_Cycle_am_00500.join(); + A2_Cycle_am_00500.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00180.check() && A2_Cycle_am_00180.check() && A1_Cycle_am_00190.check() && A2_Cycle_am_00190.check() && A1_Cycle_am_00200.check() && A2_Cycle_am_00200.check() && A1_Cycle_am_00210.check() && A2_Cycle_am_00210.check() && A1_Cycle_am_00220.check() && A2_Cycle_am_00220.check() && A1_Cycle_am_00230.check() && A2_Cycle_am_00230.check() && A1_Cycle_am_00240.check() && A2_Cycle_am_00240.check() && A1_Cycle_am_00250.check() && A2_Cycle_am_00250.check() && A1_Cycle_am_00260.check() && A2_Cycle_am_00260.check() && A1_Cycle_am_00270.check() && A2_Cycle_am_00270.check() && A1_Cycle_am_00280.check() && A2_Cycle_am_00280.check() && A1_Cycle_am_00290.check() && A2_Cycle_am_00290.check() && A1_Cycle_am_00300.check() && A2_Cycle_am_00300.check() && A1_Cycle_am_00310.check() && A2_Cycle_am_00310.check() && A1_Cycle_am_00320.check() && A2_Cycle_am_00320.check() && A1_Cycle_am_00330.check() && A2_Cycle_am_00330.check() && A1_Cycle_am_00340.check() && A2_Cycle_am_00340.check() && A1_Cycle_am_00350.check() && A2_Cycle_am_00350.check() && A1_Cycle_am_00360.check() && A2_Cycle_am_00360.check() && A1_Cycle_am_00370.check() && A2_Cycle_am_00370.check() && A1_Cycle_am_00380.check() && A2_Cycle_am_00380.check() && A1_Cycle_am_00390.check() && A2_Cycle_am_00390.check() && A1_Cycle_am_00400.check() && A2_Cycle_am_00400.check() && A1_Cycle_am_00410.check() && A2_Cycle_am_00410.check() && A1_Cycle_am_00420.check() && A2_Cycle_am_00420.check() && A1_Cycle_am_00430.check() && A2_Cycle_am_00430.check() && A1_Cycle_am_00440.check() && A2_Cycle_am_00440.check() && A1_Cycle_am_00450.check() && A2_Cycle_am_00450.check() && A1_Cycle_am_00460.check() && A2_Cycle_am_00460.check() && A1_Cycle_am_00470.check() && A2_Cycle_am_00470.check() && A1_Cycle_am_00480.check() && A2_Cycle_am_00480.check() && A1_Cycle_am_00490.check() && A2_Cycle_am_00490.check() && A1_Cycle_am_00500.check() && A2_Cycle_am_00500.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\nExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0154-rc-function-RC_Thread01-Cycle_am_10010/Cycle_am_10010.java b/test/testsuite/ouroboros/rc_test/RC0154-rc-function-RC_Thread01-Cycle_am_10010/Cycle_am_10010.java new file mode 100755 index 0000000000000000000000000000000000000000..554ee10582077ca74c37168010025e10df203609 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0154-rc-function-RC_Thread01-Cycle_am_10010/Cycle_am_10010.java @@ -0,0 +1,423 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_10010.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_10010 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_10010.java + *- @ExecuteClass: Cycle_am_10010 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_am_10010 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_10010_A1 a1_main = new Cycle_a_10010_A1("a1_main"); + Cycle_a_10010_A4 a4_main = new Cycle_a_10010_A4("a4_main"); + Cycle_a_10010_A6 a6_main = new Cycle_a_10010_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_10010_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_10010_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_10010_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a4_0 = a4_main; + a4_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a5_0.a7_0 = new Cycle_a_10010_A7("a7_0"); + a6_main.a7_0 = a1_main.a2_0.a3_0.a5_0.a7_0; + a6_main.a5_0 = a1_main.a2_0.a3_0.a5_0; + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + + Cycle_a_10010_2A1 a1_2main = new Cycle_a_10010_2A1("a1_2main"); + Cycle_a_10010_2A4 a4_2main = new Cycle_a_10010_2A4("a4_2main"); + Cycle_a_10010_2A6 a6_2main = new Cycle_a_10010_2A6("a6_2main"); + a1_2main.a2_0 = new Cycle_a_10010_2A2("a2_0"); + a1_2main.a2_0.a3_0 = new Cycle_a_10010_2A3("a3_0"); + a1_2main.a2_0.a4_0 = a4_2main; + a4_2main.a1_0 = a1_2main; + a1_2main.a2_0.a3_0.a1_0 = a1_2main; + a1_2main.a2_0.a3_0.a5_0 = new Cycle_a_10010_2A5("a5_0"); + a1_2main.a2_0.a3_0.a5_0.a6_0 = a6_2main; + a1_2main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_10010_2A8("a8_0"); + a1_2main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_10010_2A7("a7_0"); + a1_2main.a2_0.a3_0.a5_0.a8_0.a7_0.a3_0 = a1_2main.a2_0.a3_0; + a6_2main.a1_0 = a1_2main; + a6_2main.a3_0 = a1_2main.a2_0.a3_0; + + + a1_2main.add(); + a4_2main.add(); + a6_2main.add(); + a1_2main.a2_0.add(); + a1_2main.a2_0.a3_0.add(); + a1_2main.a2_0.a3_0.a5_0.add(); + a1_2main.a2_0.a3_0.a5_0.a8_0.add(); + a1_2main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + + int result2 = a1_2main.sum + a4_2main.sum + a6_2main.sum + a1_2main.a2_0.sum + a1_2main.a2_0.a3_0.sum + a1_2main.a2_0.a3_0.a5_0.sum + a6_2main.a3_0.a5_0.a8_0.a7_0.sum + a6_2main.a3_0.a5_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + result += result2; + + if (result == 3852) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_10010_A1 { + Cycle_a_10010_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_10010_A2 { + Cycle_a_10010_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_10010_A3 { + Cycle_a_10010_A1 a1_0; + Cycle_a_10010_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_10010_A4 { + Cycle_a_10010_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_10010_A5 { + Cycle_a_10010_A4 a4_0; + Cycle_a_10010_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_A5(String strObjectName) { + a4_0 = null; + a7_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a4_0.a + a7_0.a; + } + } + + class Cycle_a_10010_A6 { + Cycle_a_10010_A5 a5_0; + Cycle_a_10010_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_A6(String strObjectName) { + a5_0 = null; + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a5_0.a + a7_0.a; + } + } + + class Cycle_a_10010_A7 { + int a; + int sum; + String strObjectName; + + Cycle_a_10010_A7(String strObjectName) { + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Cycle_a_10010_2A1 { + Cycle_a_10010_2A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_2A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_10010_2A2 { + Cycle_a_10010_2A3 a3_0; + Cycle_a_10010_2A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_2A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + + class Cycle_a_10010_2A3 { + Cycle_a_10010_2A1 a1_0; + Cycle_a_10010_2A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_2A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_10010_2A4 { + Cycle_a_10010_2A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_2A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_10010_2A5 { + Cycle_a_10010_2A6 a6_0; + Cycle_a_10010_2A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_2A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + + class Cycle_a_10010_2A6 { + Cycle_a_10010_2A1 a1_0; + Cycle_a_10010_2A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_2A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_10010_2A7 { + Cycle_a_10010_2A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_2A7(String strObjectName) { + a3_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_10010_2A8 { + Cycle_a_10010_2A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_2A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } +} + + +public class Cycle_am_10010 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_10010 A1_Cycle_am_10010 = new ThreadRc_Cycle_am_10010(); + ThreadRc_Cycle_am_10010 A2_Cycle_am_10010 = new ThreadRc_Cycle_am_10010(); + ThreadRc_Cycle_am_10010 A3_Cycle_am_10010 = new ThreadRc_Cycle_am_10010(); + ThreadRc_Cycle_am_10010 A4_Cycle_am_10010 = new ThreadRc_Cycle_am_10010(); + ThreadRc_Cycle_am_10010 A5_Cycle_am_10010 = new ThreadRc_Cycle_am_10010(); + ThreadRc_Cycle_am_10010 A6_Cycle_am_10010 = new ThreadRc_Cycle_am_10010(); + + A1_Cycle_am_10010.start(); + A2_Cycle_am_10010.start(); + A3_Cycle_am_10010.start(); + A4_Cycle_am_10010.start(); + A5_Cycle_am_10010.start(); + A6_Cycle_am_10010.start(); + + try { + A1_Cycle_am_10010.join(); + A2_Cycle_am_10010.join(); + A3_Cycle_am_10010.join(); + A4_Cycle_am_10010.join(); + A5_Cycle_am_10010.join(); + A6_Cycle_am_10010.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_10010.check() && A2_Cycle_am_10010.check() && A3_Cycle_am_10010.check() && A4_Cycle_am_10010.check() && A5_Cycle_am_10010.check() && A6_Cycle_am_10010.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0155-rc-function-RC_Thread01-Cycle_am_10020/Cycle_am_10020.java b/test/testsuite/ouroboros/rc_test/RC0155-rc-function-RC_Thread01-Cycle_am_10020/Cycle_am_10020.java new file mode 100755 index 0000000000000000000000000000000000000000..65e191ec9d500a274913c3066d1f5d1a0cc65bd6 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0155-rc-function-RC_Thread01-Cycle_am_10020/Cycle_am_10020.java @@ -0,0 +1,383 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_10020.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_10020 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_10020.java + *- @ExecuteClass: Cycle_am_10020 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_am_10020 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_10020_A1 a1_main = new Cycle_a_10020_A1("a1_main"); + Cycle_a_10020_A4 a4_main = new Cycle_a_10020_A4("a4_main"); + Cycle_a_10020_A6 a6_main = new Cycle_a_10020_A6("a6_main"); + Cycle_a_10020_A9 a9_main = new Cycle_a_10020_A9("a9_main"); + a1_main.a2_0 = new Cycle_a_10020_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_10020_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_10020_A5("a5_0"); + a1_main.a2_0.a3_0.a10_0 = new Cycle_a_10020_A10("a10_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_10020_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_10020_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a10_0.a9_0 = a9_main; + a9_main.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a9_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a10_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a9_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum + a6_main.a3_0.a10_0.sum; + //System.out.println("RC-Testing_Result="+result); + Cycle_a_10020_2A1 a1_2main = new Cycle_a_10020_2A1("a1_2main"); + a1_2main.a2_0 = new Cycle_a_10020_2A2("a2_0"); + a1_2main.a2_0.a1_0 = a1_2main; + a1_2main.a2_0.a3_0 = new Cycle_a_10020_2A3("a3_0"); + a1_2main.a2_0.a3_0.a1_0 = a1_2main; + a1_2main.a2_0.a3_0.a2_0 = a1_2main.a2_0; + + + a1_2main.add(); + a1_2main.a2_0.add(); + a1_2main.a2_0.a3_0.add(); + + int result2 = a1_2main.sum + a1_2main.a2_0.sum + a1_2main.a2_0.a3_0.sum; + //System.out.println("RC-Testing_Result="+result); + result += result2; + + if (result == 3438) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_10020_A1 { + Cycle_a_10020_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_10020_A2 { + Cycle_a_10020_A3 a3_0; + Cycle_a_10020_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + + class Cycle_a_10020_A3 { + Cycle_a_10020_A1 a1_0; + Cycle_a_10020_A5 a5_0; + Cycle_a_10020_A10 a10_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a10_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a + a10_0.a; + } + } + + class Cycle_a_10020_A4 { + Cycle_a_10020_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_10020_A5 { + Cycle_a_10020_A6 a6_0; + Cycle_a_10020_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + + class Cycle_a_10020_A6 { + Cycle_a_10020_A1 a1_0; + Cycle_a_10020_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_10020_A7 { + Cycle_a_10020_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_10020_A8 { + Cycle_a_10020_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_a_10020_A9 { + Cycle_a_10020_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A9(String strObjectName) { + a6_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_10020_A10 { + Cycle_a_10020_A9 a9_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A10(String strObjectName) { + a9_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + + void add() { + sum = a + a9_0.a; + } + } + + class Cycle_a_10020_2A1 { + Cycle_a_10020_2A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_2A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_10020_2A2 { + Cycle_a_10020_2A1 a1_0; + Cycle_a_10020_2A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_2A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_10020_2A3 { + Cycle_a_10020_2A1 a1_0; + Cycle_a_10020_2A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_2A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a2_0.a; + } + } +} + + +public class Cycle_am_10020 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_10020 A1_Cycle_am_10020 = new ThreadRc_Cycle_am_10020(); + ThreadRc_Cycle_am_10020 A2_Cycle_am_10020 = new ThreadRc_Cycle_am_10020(); + ThreadRc_Cycle_am_10020 A3_Cycle_am_10020 = new ThreadRc_Cycle_am_10020(); + ThreadRc_Cycle_am_10020 A4_Cycle_am_10020 = new ThreadRc_Cycle_am_10020(); + ThreadRc_Cycle_am_10020 A5_Cycle_am_10020 = new ThreadRc_Cycle_am_10020(); + ThreadRc_Cycle_am_10020 A6_Cycle_am_10020 = new ThreadRc_Cycle_am_10020(); + + A1_Cycle_am_10020.start(); + A2_Cycle_am_10020.start(); + A3_Cycle_am_10020.start(); + A4_Cycle_am_10020.start(); + A5_Cycle_am_10020.start(); + A6_Cycle_am_10020.start(); + + try { + A1_Cycle_am_10020.join(); + A2_Cycle_am_10020.join(); + A3_Cycle_am_10020.join(); + A4_Cycle_am_10020.join(); + A5_Cycle_am_10020.join(); + A6_Cycle_am_10020.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_10020.check() && A2_Cycle_am_10020.check() && A3_Cycle_am_10020.check() && A4_Cycle_am_10020.check() && A5_Cycle_am_10020.check() && A6_Cycle_am_10020.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0156-rc-function-RC_Thread01-Cycle_am_10030/Cycle_am_10030.java b/test/testsuite/ouroboros/rc_test/RC0156-rc-function-RC_Thread01-Cycle_am_10030/Cycle_am_10030.java new file mode 100755 index 0000000000000000000000000000000000000000..f8808cda40f95965f9db67856b4aed7bd8855b52 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0156-rc-function-RC_Thread01-Cycle_am_10030/Cycle_am_10030.java @@ -0,0 +1,764 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_am_10030.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_a_10030 in RC测试-Cycle-01 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_am_10030.java + *- @ExecuteClass: Cycle_am_10030 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_am_10020B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_10020_A1 a1_main = new Cycle_a_10020_A1("a1_main"); + Cycle_a_10020_A4 a4_main = new Cycle_a_10020_A4("a4_main"); + Cycle_a_10020_A6 a6_main = new Cycle_a_10020_A6("a6_main"); + Cycle_a_10020_A9 a9_main = new Cycle_a_10020_A9("a9_main"); + a1_main.a2_0 = new Cycle_a_10020_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_10020_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_10020_A5("a5_0"); + a1_main.a2_0.a3_0.a10_0 = new Cycle_a_10020_A10("a10_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_10020_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_10020_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a10_0.a9_0 = a9_main; + a9_main.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a9_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a10_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a9_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum + a6_main.a3_0.a10_0.sum; + //System.out.println("RC-Testing_Result="+result); + Cycle_a_10020_2A1 a1_2main = new Cycle_a_10020_2A1("a1_2main"); + a1_2main.a2_0 = new Cycle_a_10020_2A2("a2_0"); + a1_2main.a2_0.a1_0 = a1_2main; + a1_2main.a2_0.a3_0 = new Cycle_a_10020_2A3("a3_0"); + a1_2main.a2_0.a3_0.a1_0 = a1_2main; + a1_2main.a2_0.a3_0.a2_0 = a1_2main.a2_0; + + + a1_2main.add(); + a1_2main.a2_0.add(); + a1_2main.a2_0.a3_0.add(); + + int result2 = a1_2main.sum + a1_2main.a2_0.sum + a1_2main.a2_0.a3_0.sum; + //System.out.println("RC-Testing_Result="+result); + result += result2; + + if (result == 3438) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_10020_A1 { + Cycle_a_10020_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_10020_A2 { + Cycle_a_10020_A3 a3_0; + Cycle_a_10020_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + + class Cycle_a_10020_A3 { + Cycle_a_10020_A1 a1_0; + Cycle_a_10020_A5 a5_0; + Cycle_a_10020_A10 a10_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a10_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a + a10_0.a; + } + } + + class Cycle_a_10020_A4 { + Cycle_a_10020_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_10020_A5 { + Cycle_a_10020_A6 a6_0; + Cycle_a_10020_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + + class Cycle_a_10020_A6 { + Cycle_a_10020_A1 a1_0; + Cycle_a_10020_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_10020_A7 { + Cycle_a_10020_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_10020_A8 { + Cycle_a_10020_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_a_10020_A9 { + Cycle_a_10020_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A9(String strObjectName) { + a6_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_10020_A10 { + Cycle_a_10020_A9 a9_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_A10(String strObjectName) { + a9_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + + void add() { + sum = a + a9_0.a; + } + } + + class Cycle_a_10020_2A1 { + Cycle_a_10020_2A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_2A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_10020_2A2 { + Cycle_a_10020_2A1 a1_0; + Cycle_a_10020_2A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_2A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_10020_2A3 { + Cycle_a_10020_2A1 a1_0; + Cycle_a_10020_2A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10020_2A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a2_0.a; + } + } +} + +class ThreadRc_Cycle_am_10010B extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_10010_A1 a1_main = new Cycle_a_10010_A1("a1_main"); + Cycle_a_10010_A4 a4_main = new Cycle_a_10010_A4("a4_main"); + Cycle_a_10010_A6 a6_main = new Cycle_a_10010_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_10010_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_10010_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_10010_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a4_0 = a4_main; + a4_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a5_0.a7_0 = new Cycle_a_10010_A7("a7_0"); + a6_main.a7_0 = a1_main.a2_0.a3_0.a5_0.a7_0; + a6_main.a5_0 = a1_main.a2_0.a3_0.a5_0; + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + + Cycle_a_10010_2A1 a1_2main = new Cycle_a_10010_2A1("a1_2main"); + Cycle_a_10010_2A4 a4_2main = new Cycle_a_10010_2A4("a4_2main"); + Cycle_a_10010_2A6 a6_2main = new Cycle_a_10010_2A6("a6_2main"); + a1_2main.a2_0 = new Cycle_a_10010_2A2("a2_0"); + a1_2main.a2_0.a3_0 = new Cycle_a_10010_2A3("a3_0"); + a1_2main.a2_0.a4_0 = a4_2main; + a4_2main.a1_0 = a1_2main; + a1_2main.a2_0.a3_0.a1_0 = a1_2main; + a1_2main.a2_0.a3_0.a5_0 = new Cycle_a_10010_2A5("a5_0"); + a1_2main.a2_0.a3_0.a5_0.a6_0 = a6_2main; + a1_2main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_10010_2A8("a8_0"); + a1_2main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_10010_2A7("a7_0"); + a1_2main.a2_0.a3_0.a5_0.a8_0.a7_0.a3_0 = a1_2main.a2_0.a3_0; + a6_2main.a1_0 = a1_2main; + a6_2main.a3_0 = a1_2main.a2_0.a3_0; + + + a1_2main.add(); + a4_2main.add(); + a6_2main.add(); + a1_2main.a2_0.add(); + a1_2main.a2_0.a3_0.add(); + a1_2main.a2_0.a3_0.a5_0.add(); + a1_2main.a2_0.a3_0.a5_0.a8_0.add(); + a1_2main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + + int result2 = a1_2main.sum + a4_2main.sum + a6_2main.sum + a1_2main.a2_0.sum + a1_2main.a2_0.a3_0.sum + a1_2main.a2_0.a3_0.a5_0.sum + a6_2main.a3_0.a5_0.a8_0.a7_0.sum + a6_2main.a3_0.a5_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + result += result2; + + if (result == 3852) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_10010_A1 { + Cycle_a_10010_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_10010_A2 { + Cycle_a_10010_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_10010_A3 { + Cycle_a_10010_A1 a1_0; + Cycle_a_10010_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_10010_A4 { + Cycle_a_10010_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_10010_A5 { + Cycle_a_10010_A4 a4_0; + Cycle_a_10010_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_A5(String strObjectName) { + a4_0 = null; + a7_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a4_0.a + a7_0.a; + } + } + + class Cycle_a_10010_A6 { + Cycle_a_10010_A5 a5_0; + Cycle_a_10010_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_A6(String strObjectName) { + a5_0 = null; + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a5_0.a + a7_0.a; + } + } + + class Cycle_a_10010_A7 { + int a; + int sum; + String strObjectName; + + Cycle_a_10010_A7(String strObjectName) { + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Cycle_a_10010_2A1 { + Cycle_a_10010_2A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_2A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_10010_2A2 { + Cycle_a_10010_2A3 a3_0; + Cycle_a_10010_2A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_2A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + + class Cycle_a_10010_2A3 { + Cycle_a_10010_2A1 a1_0; + Cycle_a_10010_2A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_2A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + class Cycle_a_10010_2A4 { + Cycle_a_10010_2A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_2A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_10010_2A5 { + Cycle_a_10010_2A6 a6_0; + Cycle_a_10010_2A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_2A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + + class Cycle_a_10010_2A6 { + Cycle_a_10010_2A1 a1_0; + Cycle_a_10010_2A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_2A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_10010_2A7 { + Cycle_a_10010_2A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_2A7(String strObjectName) { + a3_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_a_10010_2A8 { + Cycle_a_10010_2A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_10010_2A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } +} + +public class Cycle_am_10030 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_10010B A1_Cycle_am_10010 = new ThreadRc_Cycle_am_10010B(); + ThreadRc_Cycle_am_10010B A2_Cycle_am_10010 = new ThreadRc_Cycle_am_10010B(); + ThreadRc_Cycle_am_10010B A3_Cycle_am_10010 = new ThreadRc_Cycle_am_10010B(); + ThreadRc_Cycle_am_10010B A4_Cycle_am_10010 = new ThreadRc_Cycle_am_10010B(); + ThreadRc_Cycle_am_10010B A5_Cycle_am_10010 = new ThreadRc_Cycle_am_10010B(); + ThreadRc_Cycle_am_10010B A6_Cycle_am_10010 = new ThreadRc_Cycle_am_10010B(); + ThreadRc_Cycle_am_10020B A1_Cycle_am_10020 = new ThreadRc_Cycle_am_10020B(); + ThreadRc_Cycle_am_10020B A2_Cycle_am_10020 = new ThreadRc_Cycle_am_10020B(); + ThreadRc_Cycle_am_10020B A3_Cycle_am_10020 = new ThreadRc_Cycle_am_10020B(); + ThreadRc_Cycle_am_10020B A4_Cycle_am_10020 = new ThreadRc_Cycle_am_10020B(); + ThreadRc_Cycle_am_10020B A5_Cycle_am_10020 = new ThreadRc_Cycle_am_10020B(); + ThreadRc_Cycle_am_10020B A6_Cycle_am_10020 = new ThreadRc_Cycle_am_10020B(); + A1_Cycle_am_10010.start(); + A2_Cycle_am_10010.start(); + A3_Cycle_am_10010.start(); + A4_Cycle_am_10010.start(); + A5_Cycle_am_10010.start(); + A6_Cycle_am_10010.start(); + A1_Cycle_am_10020.start(); + A2_Cycle_am_10020.start(); + A3_Cycle_am_10020.start(); + A4_Cycle_am_10020.start(); + A5_Cycle_am_10020.start(); + A6_Cycle_am_10020.start(); + + try { + A1_Cycle_am_10010.join(); + A2_Cycle_am_10010.join(); + A3_Cycle_am_10010.join(); + A4_Cycle_am_10010.join(); + A5_Cycle_am_10010.join(); + A6_Cycle_am_10010.join(); + A1_Cycle_am_10020.join(); + A2_Cycle_am_10020.join(); + A3_Cycle_am_10020.join(); + A4_Cycle_am_10020.join(); + A5_Cycle_am_10020.join(); + A6_Cycle_am_10020.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_10010.check() && A2_Cycle_am_10010.check() && A3_Cycle_am_10010.check() && A4_Cycle_am_10010.check() && A5_Cycle_am_10010.check() && A6_Cycle_am_10010.check() && A1_Cycle_am_10020.check() && A2_Cycle_am_10020.check() && A3_Cycle_am_10020.check() && A4_Cycle_am_10020.check() && A5_Cycle_am_10020.check() && A6_Cycle_am_10020.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0157-rc-function-RC_Thread01-Cycle_Bm_1_00010/Cycle_Bm_1_00010.java b/test/testsuite/ouroboros/rc_test/RC0157-rc-function-RC_Thread01-Cycle_Bm_1_00010/Cycle_Bm_1_00010.java new file mode 100755 index 0000000000000000000000000000000000000000..7bf5f162dfa08a7fb376203c55e7979b05c1d1f2 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0157-rc-function-RC_Thread01-Cycle_Bm_1_00010/Cycle_Bm_1_00010.java @@ -0,0 +1,95 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_1_00010.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_1_00010 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_1_00010.java + *- @ExecuteClass: Cycle_Bm_1_00010 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_1_00010 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00010_A1 a1_0 = new Cycle_B_1_00010_A1(); + a1_0.a1_0 = a1_0; + a1_0.add(); + int nsum = a1_0.sum; + //System.out.println(nsum); + + if (nsum == 246) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00010_A1 { + Cycle_B_1_00010_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00010_A1() { + a1_0 = null; + a = 123; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + + +public class Cycle_Bm_1_00010 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00010 A1_Cycle_Bm_1_00010 = new ThreadRc_Cycle_Bm_1_00010(); + ThreadRc_Cycle_Bm_1_00010 A2_Cycle_Bm_1_00010 = new ThreadRc_Cycle_Bm_1_00010(); + ThreadRc_Cycle_Bm_1_00010 A3_Cycle_Bm_1_00010 = new ThreadRc_Cycle_Bm_1_00010(); + ThreadRc_Cycle_Bm_1_00010 A4_Cycle_Bm_1_00010 = new ThreadRc_Cycle_Bm_1_00010(); + ThreadRc_Cycle_Bm_1_00010 A5_Cycle_Bm_1_00010 = new ThreadRc_Cycle_Bm_1_00010(); + ThreadRc_Cycle_Bm_1_00010 A6_Cycle_Bm_1_00010 = new ThreadRc_Cycle_Bm_1_00010(); + + A1_Cycle_Bm_1_00010.start(); + A2_Cycle_Bm_1_00010.start(); + A3_Cycle_Bm_1_00010.start(); + A4_Cycle_Bm_1_00010.start(); + A5_Cycle_Bm_1_00010.start(); + A6_Cycle_Bm_1_00010.start(); + + try { + A1_Cycle_Bm_1_00010.join(); + A2_Cycle_Bm_1_00010.join(); + A3_Cycle_Bm_1_00010.join(); + A4_Cycle_Bm_1_00010.join(); + A5_Cycle_Bm_1_00010.join(); + A6_Cycle_Bm_1_00010.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00010.check() && A2_Cycle_Bm_1_00010.check() && A3_Cycle_Bm_1_00010.check() && A4_Cycle_Bm_1_00010.check() && A5_Cycle_Bm_1_00010.check() && A6_Cycle_Bm_1_00010.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0158-rc-function-RC_Thread01-Cycle_Bm_1_00020/Cycle_Bm_1_00020.java b/test/testsuite/ouroboros/rc_test/RC0158-rc-function-RC_Thread01-Cycle_Bm_1_00020/Cycle_Bm_1_00020.java new file mode 100755 index 0000000000000000000000000000000000000000..7717641eebd914eae8ebf04122c445f5f6ff4e15 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0158-rc-function-RC_Thread01-Cycle_Bm_1_00020/Cycle_Bm_1_00020.java @@ -0,0 +1,115 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_1_00020.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_1_00020 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_1_00020.java + *- @ExecuteClass: Cycle_Bm_1_00020 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_Bm_1_00020 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00020_A1 a1_0 = new Cycle_B_1_00020_A1(); + a1_0.a2_0 = new Cycle_B_1_00020_A2(); + a1_0.a2_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + + int nsum = (a1_0.sum + a1_0.a2_0.sum); + //System.out.println(nsum); + + if (nsum == 6) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00020_A1 { + Cycle_B_1_00020_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00020_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00020_A2 { + Cycle_B_1_00020_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00020_A2() { + a1_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + + +public class Cycle_Bm_1_00020 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00020 A1_Cycle_Bm_1_00020 = new ThreadRc_Cycle_Bm_1_00020(); + ThreadRc_Cycle_Bm_1_00020 A2_Cycle_Bm_1_00020 = new ThreadRc_Cycle_Bm_1_00020(); + ThreadRc_Cycle_Bm_1_00020 A3_Cycle_Bm_1_00020 = new ThreadRc_Cycle_Bm_1_00020(); + ThreadRc_Cycle_Bm_1_00020 A4_Cycle_Bm_1_00020 = new ThreadRc_Cycle_Bm_1_00020(); + ThreadRc_Cycle_Bm_1_00020 A5_Cycle_Bm_1_00020 = new ThreadRc_Cycle_Bm_1_00020(); + ThreadRc_Cycle_Bm_1_00020 A6_Cycle_Bm_1_00020 = new ThreadRc_Cycle_Bm_1_00020(); + + A1_Cycle_Bm_1_00020.start(); + A2_Cycle_Bm_1_00020.start(); + A3_Cycle_Bm_1_00020.start(); + A4_Cycle_Bm_1_00020.start(); + A5_Cycle_Bm_1_00020.start(); + A6_Cycle_Bm_1_00020.start(); + + try { + A1_Cycle_Bm_1_00020.join(); + A2_Cycle_Bm_1_00020.join(); + A3_Cycle_Bm_1_00020.join(); + A4_Cycle_Bm_1_00020.join(); + A5_Cycle_Bm_1_00020.join(); + A6_Cycle_Bm_1_00020.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00020.check() && A2_Cycle_Bm_1_00020.check() && A3_Cycle_Bm_1_00020.check() && A4_Cycle_Bm_1_00020.check() && A5_Cycle_Bm_1_00020.check() && A6_Cycle_Bm_1_00020.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0159-rc-function-RC_Thread01-Cycle_Bm_1_00030/Cycle_Bm_1_00030.java b/test/testsuite/ouroboros/rc_test/RC0159-rc-function-RC_Thread01-Cycle_Bm_1_00030/Cycle_Bm_1_00030.java new file mode 100755 index 0000000000000000000000000000000000000000..4d8c144d58667891df27f3f67511bea822418d25 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0159-rc-function-RC_Thread01-Cycle_Bm_1_00030/Cycle_Bm_1_00030.java @@ -0,0 +1,132 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_1_00030.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_1_00030 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_1_00030.java + *- @ExecuteClass: Cycle_Bm_1_00030 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_Bm_1_00030 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00030_A1 a1_0 = new Cycle_B_1_00030_A1(); + a1_0.a2_0 = new Cycle_B_1_00030_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00030_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + + if (nsum == 12) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00030_A1 { + Cycle_B_1_00030_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00030_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00030_A2 { + Cycle_B_1_00030_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00030_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00030_A3 { + Cycle_B_1_00030_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00030_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + + +public class Cycle_Bm_1_00030 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00030 A1_Cycle_Bm_1_00030 = new ThreadRc_Cycle_Bm_1_00030(); + ThreadRc_Cycle_Bm_1_00030 A2_Cycle_Bm_1_00030 = new ThreadRc_Cycle_Bm_1_00030(); + ThreadRc_Cycle_Bm_1_00030 A3_Cycle_Bm_1_00030 = new ThreadRc_Cycle_Bm_1_00030(); + ThreadRc_Cycle_Bm_1_00030 A4_Cycle_Bm_1_00030 = new ThreadRc_Cycle_Bm_1_00030(); + ThreadRc_Cycle_Bm_1_00030 A5_Cycle_Bm_1_00030 = new ThreadRc_Cycle_Bm_1_00030(); + ThreadRc_Cycle_Bm_1_00030 A6_Cycle_Bm_1_00030 = new ThreadRc_Cycle_Bm_1_00030(); + + A1_Cycle_Bm_1_00030.start(); + A2_Cycle_Bm_1_00030.start(); + A3_Cycle_Bm_1_00030.start(); + A4_Cycle_Bm_1_00030.start(); + A5_Cycle_Bm_1_00030.start(); + A6_Cycle_Bm_1_00030.start(); + + try { + A1_Cycle_Bm_1_00030.join(); + A2_Cycle_Bm_1_00030.join(); + A3_Cycle_Bm_1_00030.join(); + A4_Cycle_Bm_1_00030.join(); + A5_Cycle_Bm_1_00030.join(); + A6_Cycle_Bm_1_00030.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00030.check() && A2_Cycle_Bm_1_00030.check() && A3_Cycle_Bm_1_00030.check() && A4_Cycle_Bm_1_00030.check() && A5_Cycle_Bm_1_00030.check() && A6_Cycle_Bm_1_00030.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0160-rc-function-RC_Thread01-Cycle_Bm_1_00040/Cycle_Bm_1_00040.java b/test/testsuite/ouroboros/rc_test/RC0160-rc-function-RC_Thread01-Cycle_Bm_1_00040/Cycle_Bm_1_00040.java new file mode 100755 index 0000000000000000000000000000000000000000..82f03ef0d5d5fd388685b3c6bc46fc19a6268278 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0160-rc-function-RC_Thread01-Cycle_Bm_1_00040/Cycle_Bm_1_00040.java @@ -0,0 +1,152 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_1_00040.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_1_00040 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_1_00040.java + *- @ExecuteClass: Cycle_Bm_1_00040 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_Bm_1_00040 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00040_A1 a1_0 = new Cycle_B_1_00040_A1(); + a1_0.a2_0 = new Cycle_B_1_00040_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00040_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_1_00040_A4(); + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum; + //System.out.println(nsum); + + if (nsum == 21) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00040_A1 { + Cycle_B_1_00040_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00040_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00040_A2 { + Cycle_B_1_00040_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00040_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00040_A3 { + Cycle_B_1_00040_A1 a1_0; + Cycle_B_1_00040_A4 a4_0; + int a; + int sum; + + Cycle_B_1_00040_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00040_A4 { + + int a; + int sum; + + Cycle_B_1_00040_A4() { + a = 4; + sum = 0; + } + + void add() { + sum = a + 5; + } + } +} + + +public class Cycle_Bm_1_00040 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00040 A1_Cycle_Bm_1_00040 = new ThreadRc_Cycle_Bm_1_00040(); + ThreadRc_Cycle_Bm_1_00040 A2_Cycle_Bm_1_00040 = new ThreadRc_Cycle_Bm_1_00040(); + ThreadRc_Cycle_Bm_1_00040 A3_Cycle_Bm_1_00040 = new ThreadRc_Cycle_Bm_1_00040(); + ThreadRc_Cycle_Bm_1_00040 A4_Cycle_Bm_1_00040 = new ThreadRc_Cycle_Bm_1_00040(); + ThreadRc_Cycle_Bm_1_00040 A5_Cycle_Bm_1_00040 = new ThreadRc_Cycle_Bm_1_00040(); + ThreadRc_Cycle_Bm_1_00040 A6_Cycle_Bm_1_00040 = new ThreadRc_Cycle_Bm_1_00040(); + + A1_Cycle_Bm_1_00040.start(); + A2_Cycle_Bm_1_00040.start(); + A3_Cycle_Bm_1_00040.start(); + A4_Cycle_Bm_1_00040.start(); + A5_Cycle_Bm_1_00040.start(); + A6_Cycle_Bm_1_00040.start(); + + try { + A1_Cycle_Bm_1_00040.join(); + A2_Cycle_Bm_1_00040.join(); + A3_Cycle_Bm_1_00040.join(); + A4_Cycle_Bm_1_00040.join(); + A5_Cycle_Bm_1_00040.join(); + A6_Cycle_Bm_1_00040.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00040.check() && A2_Cycle_Bm_1_00040.check() && A3_Cycle_Bm_1_00040.check() && A4_Cycle_Bm_1_00040.check() && A5_Cycle_Bm_1_00040.check() && A6_Cycle_Bm_1_00040.check()) + System.out.println("ExpectResult"); + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0161-rc-function-RC_Thread01-Cycle_Bm_1_00050/Cycle_Bm_1_00050.java b/test/testsuite/ouroboros/rc_test/RC0161-rc-function-RC_Thread01-Cycle_Bm_1_00050/Cycle_Bm_1_00050.java new file mode 100755 index 0000000000000000000000000000000000000000..540003c0edba3f2e55f381fa7a4a5a849e82283c --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0161-rc-function-RC_Thread01-Cycle_Bm_1_00050/Cycle_Bm_1_00050.java @@ -0,0 +1,170 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_1_00050.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_1_00050 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_1_00050.java + *- @ExecuteClass: Cycle_Bm_1_00050 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_Bm_1_00050 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00050_A1 a1_0 = new Cycle_B_1_00050_A1(); + a1_0.a2_0 = new Cycle_B_1_00050_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00050_A3(); + a1_0.a2_0.a4_0 = new Cycle_B_1_00050_A4(); + a1_0.a2_0.a5_0 = new Cycle_B_1_00050_A5(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + a1_0.a2_0.a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum + a1_0.a2_0.a5_0.sum; + //System.out.println(nsum); + + if (nsum == 34) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00050_A1 { + Cycle_B_1_00050_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00050_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00050_A2 { + Cycle_B_1_00050_A3 a3_0; + Cycle_B_1_00050_A4 a4_0; + Cycle_B_1_00050_A5 a5_0; + int a; + int sum; + + Cycle_B_1_00050_A2() { + a3_0 = null; + a4_0 = null; + a5_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00050_A3 { + Cycle_B_1_00050_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00050_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00050_A4 { + + int a; + int sum; + + Cycle_B_1_00050_A4() { + a = 4; + sum = 0; + } + + void add() { + sum = a + 5; + } + } + + class Cycle_B_1_00050_A5 { + + int a; + int sum; + + Cycle_B_1_00050_A5() { + a = 6; + sum = 0; + } + + void add() { + sum = a + 7; + } + } +} + + +public class Cycle_Bm_1_00050 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00050 A1_Cycle_Bm_1_00050 = new ThreadRc_Cycle_Bm_1_00050(); + ThreadRc_Cycle_Bm_1_00050 A2_Cycle_Bm_1_00050 = new ThreadRc_Cycle_Bm_1_00050(); + ThreadRc_Cycle_Bm_1_00050 A3_Cycle_Bm_1_00050 = new ThreadRc_Cycle_Bm_1_00050(); + ThreadRc_Cycle_Bm_1_00050 A4_Cycle_Bm_1_00050 = new ThreadRc_Cycle_Bm_1_00050(); + ThreadRc_Cycle_Bm_1_00050 A5_Cycle_Bm_1_00050 = new ThreadRc_Cycle_Bm_1_00050(); + ThreadRc_Cycle_Bm_1_00050 A6_Cycle_Bm_1_00050 = new ThreadRc_Cycle_Bm_1_00050(); + + A1_Cycle_Bm_1_00050.start(); + A2_Cycle_Bm_1_00050.start(); + A3_Cycle_Bm_1_00050.start(); + A4_Cycle_Bm_1_00050.start(); + A5_Cycle_Bm_1_00050.start(); + A6_Cycle_Bm_1_00050.start(); + + try { + A1_Cycle_Bm_1_00050.join(); + A2_Cycle_Bm_1_00050.join(); + A3_Cycle_Bm_1_00050.join(); + A4_Cycle_Bm_1_00050.join(); + A5_Cycle_Bm_1_00050.join(); + A6_Cycle_Bm_1_00050.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00050.check() && A2_Cycle_Bm_1_00050.check() && A3_Cycle_Bm_1_00050.check() && A4_Cycle_Bm_1_00050.check() && A5_Cycle_Bm_1_00050.check() && A6_Cycle_Bm_1_00050.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0162-rc-function-RC_Thread01-Cycle_Bm_1_00060/Cycle_Bm_1_00060.java b/test/testsuite/ouroboros/rc_test/RC0162-rc-function-RC_Thread01-Cycle_Bm_1_00060/Cycle_Bm_1_00060.java new file mode 100755 index 0000000000000000000000000000000000000000..67dbf933bff7530e4bfc56d3dad104556f8b000b --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0162-rc-function-RC_Thread01-Cycle_Bm_1_00060/Cycle_Bm_1_00060.java @@ -0,0 +1,151 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_1_00060.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_1_00060 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_1_00060.java + *- @ExecuteClass: Cycle_Bm_1_00060 + *- @ExecuteArgs: + *- @Remark: + */ + +class ThreadRc_Cycle_Bm_1_00060 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00060_A1 a1_0 = new Cycle_B_1_00060_A1(); + a1_0.a2_0 = new Cycle_B_1_00060_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00060_A3(); + Cycle_B_1_00060_A4 a4_0 = new Cycle_B_1_00060_A4(); + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum; + //System.out.println(nsum); + + if (nsum == 19) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00060_A1 { + Cycle_B_1_00060_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00060_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00060_A2 { + Cycle_B_1_00060_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00060_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00060_A3 { + Cycle_B_1_00060_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00060_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00060_A4 { + Cycle_B_1_00060_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00060_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } +} + + +public class Cycle_Bm_1_00060 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00060 A1_Cycle_Bm_1_00060 = new ThreadRc_Cycle_Bm_1_00060(); + ThreadRc_Cycle_Bm_1_00060 A2_Cycle_Bm_1_00060 = new ThreadRc_Cycle_Bm_1_00060(); + ThreadRc_Cycle_Bm_1_00060 A3_Cycle_Bm_1_00060 = new ThreadRc_Cycle_Bm_1_00060(); + ThreadRc_Cycle_Bm_1_00060 A4_Cycle_Bm_1_00060 = new ThreadRc_Cycle_Bm_1_00060(); + ThreadRc_Cycle_Bm_1_00060 A5_Cycle_Bm_1_00060 = new ThreadRc_Cycle_Bm_1_00060(); + ThreadRc_Cycle_Bm_1_00060 A6_Cycle_Bm_1_00060 = new ThreadRc_Cycle_Bm_1_00060(); + + A1_Cycle_Bm_1_00060.start(); + A2_Cycle_Bm_1_00060.start(); + A3_Cycle_Bm_1_00060.start(); + A4_Cycle_Bm_1_00060.start(); + A5_Cycle_Bm_1_00060.start(); + A6_Cycle_Bm_1_00060.start(); + + try { + A1_Cycle_Bm_1_00060.join(); + A2_Cycle_Bm_1_00060.join(); + A3_Cycle_Bm_1_00060.join(); + A4_Cycle_Bm_1_00060.join(); + A5_Cycle_Bm_1_00060.join(); + A6_Cycle_Bm_1_00060.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00060.check() && A2_Cycle_Bm_1_00060.check() && A3_Cycle_Bm_1_00060.check() && A4_Cycle_Bm_1_00060.check() && A5_Cycle_Bm_1_00060.check() && A6_Cycle_Bm_1_00060.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0163-rc-function-RC_Thread01-Cycle_Bm_1_00070/Cycle_Bm_1_00070.java b/test/testsuite/ouroboros/rc_test/RC0163-rc-function-RC_Thread01-Cycle_Bm_1_00070/Cycle_Bm_1_00070.java new file mode 100755 index 0000000000000000000000000000000000000000..23c0831c9deade0fc5a01085e153910bf3f0d82b --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0163-rc-function-RC_Thread01-Cycle_Bm_1_00070/Cycle_Bm_1_00070.java @@ -0,0 +1,150 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_1_00070.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_1_00070 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_1_00070.java + *- @ExecuteClass: Cycle_Bm_1_00070 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_1_00070 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00070_A1 a1_0 = new Cycle_B_1_00070_A1(); + a1_0.a2_0 = new Cycle_B_1_00070_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00070_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_1_00070_A4(); + + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum; + //System.out.println(nsum); + + if (nsum == 21) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00070_A1 { + Cycle_B_1_00070_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00070_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00070_A2 { + Cycle_B_1_00070_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00070_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00070_A3 { + Cycle_B_1_00070_A1 a1_0; + Cycle_B_1_00070_A4 a4_0; + int a; + int sum; + + Cycle_B_1_00070_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00070_A4 { + int a; + int sum; + + Cycle_B_1_00070_A4() { + a = 4; + sum = 0; + } + + void add() { + sum = a + 5; + } + } +} + + +public class Cycle_Bm_1_00070 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00070 A1_Cycle_Bm_1_00070 = new ThreadRc_Cycle_Bm_1_00070(); + ThreadRc_Cycle_Bm_1_00070 A2_Cycle_Bm_1_00070 = new ThreadRc_Cycle_Bm_1_00070(); + ThreadRc_Cycle_Bm_1_00070 A3_Cycle_Bm_1_00070 = new ThreadRc_Cycle_Bm_1_00070(); + ThreadRc_Cycle_Bm_1_00070 A4_Cycle_Bm_1_00070 = new ThreadRc_Cycle_Bm_1_00070(); + ThreadRc_Cycle_Bm_1_00070 A5_Cycle_Bm_1_00070 = new ThreadRc_Cycle_Bm_1_00070(); + ThreadRc_Cycle_Bm_1_00070 A6_Cycle_Bm_1_00070 = new ThreadRc_Cycle_Bm_1_00070(); + + A1_Cycle_Bm_1_00070.start(); + A2_Cycle_Bm_1_00070.start(); + A3_Cycle_Bm_1_00070.start(); + A4_Cycle_Bm_1_00070.start(); + A5_Cycle_Bm_1_00070.start(); + A6_Cycle_Bm_1_00070.start(); + + try { + A1_Cycle_Bm_1_00070.join(); + A2_Cycle_Bm_1_00070.join(); + A3_Cycle_Bm_1_00070.join(); + A4_Cycle_Bm_1_00070.join(); + A5_Cycle_Bm_1_00070.join(); + A6_Cycle_Bm_1_00070.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00070.check() && A2_Cycle_Bm_1_00070.check() && A3_Cycle_Bm_1_00070.check() && A4_Cycle_Bm_1_00070.check() && A5_Cycle_Bm_1_00070.check() && A6_Cycle_Bm_1_00070.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0164-rc-function-RC_Thread01-Cycle_Bm_1_00080/Cycle_Bm_1_00080.java b/test/testsuite/ouroboros/rc_test/RC0164-rc-function-RC_Thread01-Cycle_Bm_1_00080/Cycle_Bm_1_00080.java new file mode 100755 index 0000000000000000000000000000000000000000..2323814f67ec7aa84bbebd0055eb913a595e8c32 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0164-rc-function-RC_Thread01-Cycle_Bm_1_00080/Cycle_Bm_1_00080.java @@ -0,0 +1,167 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_1_00080.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_1_00080 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_1_00080.java + *- @ExecuteClass: Cycle_Bm_1_00080 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_1_00080 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00080_A1 a1_0 = new Cycle_B_1_00080_A1(); + a1_0.a2_0 = new Cycle_B_1_00080_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00080_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_1_00080_A4(); + a1_0.a2_0.a3_0.a5_0 = new Cycle_B_1_00080_A5(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a5_0.sum; + //System.out.println(nsum); + + if (nsum == 56) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00080_A1 { + Cycle_B_1_00080_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00080_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00080_A2 { + Cycle_B_1_00080_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00080_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00080_A3 { + Cycle_B_1_00080_A1 a1_0; + Cycle_B_1_00080_A4 a4_0; + Cycle_B_1_00080_A5 a5_0; + int a; + int sum; + + Cycle_B_1_00080_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + a4_0.add(); + a5_0.add(); + sum = a + a1_0.a + a4_0.sum + a5_0.sum; + } + } + + class Cycle_B_1_00080_A4 { + int a; + int sum; + + Cycle_B_1_00080_A4() { + a = 4; + sum = 0; + } + + void add() { + sum = a + 5; + } + } + + class Cycle_B_1_00080_A5 { + int a; + int sum; + + Cycle_B_1_00080_A5() { + a = 6; + sum = 0; + } + + void add() { + sum = a + 7; + } + } +} + + +public class Cycle_Bm_1_00080 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00080 A1_Cycle_Bm_1_00080 = new ThreadRc_Cycle_Bm_1_00080(); + ThreadRc_Cycle_Bm_1_00080 A2_Cycle_Bm_1_00080 = new ThreadRc_Cycle_Bm_1_00080(); + ThreadRc_Cycle_Bm_1_00080 A3_Cycle_Bm_1_00080 = new ThreadRc_Cycle_Bm_1_00080(); + ThreadRc_Cycle_Bm_1_00080 A4_Cycle_Bm_1_00080 = new ThreadRc_Cycle_Bm_1_00080(); + ThreadRc_Cycle_Bm_1_00080 A5_Cycle_Bm_1_00080 = new ThreadRc_Cycle_Bm_1_00080(); + ThreadRc_Cycle_Bm_1_00080 A6_Cycle_Bm_1_00080 = new ThreadRc_Cycle_Bm_1_00080(); + + A1_Cycle_Bm_1_00080.start(); + A2_Cycle_Bm_1_00080.start(); + A3_Cycle_Bm_1_00080.start(); + A4_Cycle_Bm_1_00080.start(); + A5_Cycle_Bm_1_00080.start(); + A6_Cycle_Bm_1_00080.start(); + + try { + A1_Cycle_Bm_1_00080.join(); + A2_Cycle_Bm_1_00080.join(); + A3_Cycle_Bm_1_00080.join(); + A4_Cycle_Bm_1_00080.join(); + A5_Cycle_Bm_1_00080.join(); + A6_Cycle_Bm_1_00080.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00080.check() && A2_Cycle_Bm_1_00080.check() && A3_Cycle_Bm_1_00080.check() && A4_Cycle_Bm_1_00080.check() && A5_Cycle_Bm_1_00080.check() && A6_Cycle_Bm_1_00080.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0165-rc-function-RC_Thread01-Cycle_Bm_1_00090/Cycle_Bm_1_00090.java b/test/testsuite/ouroboros/rc_test/RC0165-rc-function-RC_Thread01-Cycle_Bm_1_00090/Cycle_Bm_1_00090.java new file mode 100755 index 0000000000000000000000000000000000000000..5c1eb169225f3d2bbe939a35d6661c1e703fe4bc --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0165-rc-function-RC_Thread01-Cycle_Bm_1_00090/Cycle_Bm_1_00090.java @@ -0,0 +1,169 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_1_00090.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_1_00090 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_1_00090.java + *- @ExecuteClass: Cycle_Bm_1_00090 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_1_00090 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00090_A1 a1_0 = new Cycle_B_1_00090_A1(); + a1_0.a2_0 = new Cycle_B_1_00090_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00090_A3(); + Cycle_B_1_00090_A4 a4_0 = new Cycle_B_1_00090_A4(); + Cycle_B_1_00090_A5 a5_0 = new Cycle_B_1_00090_A5(); + a4_0.a2_0 = a1_0.a2_0; + a5_0.a2_0 = a1_0.a2_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum; + //System.out.println(nsum); + + if (nsum == 25) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00090_A1 { + Cycle_B_1_00090_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00090_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00090_A2 { + Cycle_B_1_00090_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00090_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00090_A3 { + Cycle_B_1_00090_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00090_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00090_A4 { + Cycle_B_1_00090_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00090_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00090_A5 { + Cycle_B_1_00090_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00090_A5() { + a2_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } +} + + +public class Cycle_Bm_1_00090 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00090 A1_Cycle_Bm_1_00090 = new ThreadRc_Cycle_Bm_1_00090(); + ThreadRc_Cycle_Bm_1_00090 A2_Cycle_Bm_1_00090 = new ThreadRc_Cycle_Bm_1_00090(); + ThreadRc_Cycle_Bm_1_00090 A3_Cycle_Bm_1_00090 = new ThreadRc_Cycle_Bm_1_00090(); + ThreadRc_Cycle_Bm_1_00090 A4_Cycle_Bm_1_00090 = new ThreadRc_Cycle_Bm_1_00090(); + ThreadRc_Cycle_Bm_1_00090 A5_Cycle_Bm_1_00090 = new ThreadRc_Cycle_Bm_1_00090(); + ThreadRc_Cycle_Bm_1_00090 A6_Cycle_Bm_1_00090 = new ThreadRc_Cycle_Bm_1_00090(); + + A1_Cycle_Bm_1_00090.start(); + A2_Cycle_Bm_1_00090.start(); + A3_Cycle_Bm_1_00090.start(); + A4_Cycle_Bm_1_00090.start(); + A5_Cycle_Bm_1_00090.start(); + A6_Cycle_Bm_1_00090.start(); + + try { + A1_Cycle_Bm_1_00090.join(); + A2_Cycle_Bm_1_00090.join(); + A3_Cycle_Bm_1_00090.join(); + A4_Cycle_Bm_1_00090.join(); + A5_Cycle_Bm_1_00090.join(); + A6_Cycle_Bm_1_00090.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00090.check() && A2_Cycle_Bm_1_00090.check() && A3_Cycle_Bm_1_00090.check() && A4_Cycle_Bm_1_00090.check() && A5_Cycle_Bm_1_00090.check() && A6_Cycle_Bm_1_00090.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0166-rc-function-RC_Thread01-Cycle_Bm_1_00100/Cycle_Bm_1_00100.java b/test/testsuite/ouroboros/rc_test/RC0166-rc-function-RC_Thread01-Cycle_Bm_1_00100/Cycle_Bm_1_00100.java new file mode 100755 index 0000000000000000000000000000000000000000..2ab401a6e3e47018b6695540f0ce1c6036e17b4a --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0166-rc-function-RC_Thread01-Cycle_Bm_1_00100/Cycle_Bm_1_00100.java @@ -0,0 +1,171 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_1_00100.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_1_00100 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_1_00100.java + *- @ExecuteClass: Cycle_Bm_1_00100 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_1_00100 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00100_A1 a1_0 = new Cycle_B_1_00100_A1(); + a1_0.a2_0 = new Cycle_B_1_00100_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00100_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a4_0 = new Cycle_B_1_00100_A4(); + a1_0.a2_0.a4_0.a5_0 = new Cycle_B_1_00100_A5(); + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + a1_0.a2_0.a4_0.a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum + a1_0.a2_0.a4_0.a5_0.sum; + ; + //System.out.println(nsum); + + if (nsum == 38) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00100_A1 { + Cycle_B_1_00100_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00100_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00100_A2 { + Cycle_B_1_00100_A3 a3_0; + Cycle_B_1_00100_A4 a4_0; + int a; + int sum; + + Cycle_B_1_00100_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00100_A3 { + Cycle_B_1_00100_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00100_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00100_A4 { + + int a; + int sum; + Cycle_B_1_00100_A5 a5_0; + + Cycle_B_1_00100_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + a5_0.add(); + sum = a + a5_0.sum; + } + } + + class Cycle_B_1_00100_A5 { + + int a; + int sum; + + Cycle_B_1_00100_A5() { + a = 5; + sum = 0; + } + + void add() { + sum = a + 6; + } + } +} + + +public class Cycle_Bm_1_00100 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00100 A1_Cycle_Bm_1_00100 = new ThreadRc_Cycle_Bm_1_00100(); + ThreadRc_Cycle_Bm_1_00100 A2_Cycle_Bm_1_00100 = new ThreadRc_Cycle_Bm_1_00100(); + ThreadRc_Cycle_Bm_1_00100 A3_Cycle_Bm_1_00100 = new ThreadRc_Cycle_Bm_1_00100(); + ThreadRc_Cycle_Bm_1_00100 A4_Cycle_Bm_1_00100 = new ThreadRc_Cycle_Bm_1_00100(); + ThreadRc_Cycle_Bm_1_00100 A5_Cycle_Bm_1_00100 = new ThreadRc_Cycle_Bm_1_00100(); + ThreadRc_Cycle_Bm_1_00100 A6_Cycle_Bm_1_00100 = new ThreadRc_Cycle_Bm_1_00100(); + + A1_Cycle_Bm_1_00100.start(); + A2_Cycle_Bm_1_00100.start(); + A3_Cycle_Bm_1_00100.start(); + A4_Cycle_Bm_1_00100.start(); + A5_Cycle_Bm_1_00100.start(); + A6_Cycle_Bm_1_00100.start(); + + try { + A1_Cycle_Bm_1_00100.join(); + A2_Cycle_Bm_1_00100.join(); + A3_Cycle_Bm_1_00100.join(); + A4_Cycle_Bm_1_00100.join(); + A5_Cycle_Bm_1_00100.join(); + A6_Cycle_Bm_1_00100.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00100.check() && A2_Cycle_Bm_1_00100.check() && A3_Cycle_Bm_1_00100.check() && A4_Cycle_Bm_1_00100.check() && A5_Cycle_Bm_1_00100.check() && A6_Cycle_Bm_1_00100.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0167-rc-function-RC_Thread01-Cycle_Bm_1_00110/Cycle_Bm_1_00110.java b/test/testsuite/ouroboros/rc_test/RC0167-rc-function-RC_Thread01-Cycle_Bm_1_00110/Cycle_Bm_1_00110.java new file mode 100755 index 0000000000000000000000000000000000000000..75dc56e34fd412da751f2d93832cba8e49707f7b --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0167-rc-function-RC_Thread01-Cycle_Bm_1_00110/Cycle_Bm_1_00110.java @@ -0,0 +1,168 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_1_00110.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_1_00110 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_1_00110.java + *- @ExecuteClass: Cycle_Bm_1_00110 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_1_00110 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00110_A1 a1_0 = new Cycle_B_1_00110_A1(); + a1_0.a2_0 = new Cycle_B_1_00110_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00110_A3(); + Cycle_B_1_00110_A5 a5_0 = new Cycle_B_1_00110_A5(); + a5_0.a4_0 = new Cycle_B_1_00110_A4(); + a5_0.a4_0.a2_0 = a1_0.a2_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a5_0.a4_0.add(); + a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a5_0.a4_0.sum + a5_0.sum; + //System.out.println(nsum); + + if (nsum == 27) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00110_A1 { + Cycle_B_1_00110_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00110_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00110_A2 { + Cycle_B_1_00110_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00110_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00110_A3 { + Cycle_B_1_00110_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00110_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00110_A4 { + Cycle_B_1_00110_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00110_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00110_A5 { + Cycle_B_1_00110_A4 a4_0; + int a; + int sum; + + Cycle_B_1_00110_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } +} + + +public class Cycle_Bm_1_00110 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00110 A1_Cycle_Bm_1_00110 = new ThreadRc_Cycle_Bm_1_00110(); + ThreadRc_Cycle_Bm_1_00110 A2_Cycle_Bm_1_00110 = new ThreadRc_Cycle_Bm_1_00110(); + ThreadRc_Cycle_Bm_1_00110 A3_Cycle_Bm_1_00110 = new ThreadRc_Cycle_Bm_1_00110(); + ThreadRc_Cycle_Bm_1_00110 A4_Cycle_Bm_1_00110 = new ThreadRc_Cycle_Bm_1_00110(); + ThreadRc_Cycle_Bm_1_00110 A5_Cycle_Bm_1_00110 = new ThreadRc_Cycle_Bm_1_00110(); + ThreadRc_Cycle_Bm_1_00110 A6_Cycle_Bm_1_00110 = new ThreadRc_Cycle_Bm_1_00110(); + + A1_Cycle_Bm_1_00110.start(); + A2_Cycle_Bm_1_00110.start(); + A3_Cycle_Bm_1_00110.start(); + A4_Cycle_Bm_1_00110.start(); + A5_Cycle_Bm_1_00110.start(); + A6_Cycle_Bm_1_00110.start(); + + try { + A1_Cycle_Bm_1_00110.join(); + A2_Cycle_Bm_1_00110.join(); + A3_Cycle_Bm_1_00110.join(); + A4_Cycle_Bm_1_00110.join(); + A5_Cycle_Bm_1_00110.join(); + A6_Cycle_Bm_1_00110.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00110.check() && A2_Cycle_Bm_1_00110.check() && A3_Cycle_Bm_1_00110.check() && A4_Cycle_Bm_1_00110.check() && A5_Cycle_Bm_1_00110.check() && A6_Cycle_Bm_1_00110.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0168-rc-function-RC_Thread01-Cycle_Bm_1_00120/Cycle_Bm_1_00120.java b/test/testsuite/ouroboros/rc_test/RC0168-rc-function-RC_Thread01-Cycle_Bm_1_00120/Cycle_Bm_1_00120.java new file mode 100755 index 0000000000000000000000000000000000000000..c0ec1efeacadb1fa585f23e9aa6e8a109ff68c4b --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0168-rc-function-RC_Thread01-Cycle_Bm_1_00120/Cycle_Bm_1_00120.java @@ -0,0 +1,168 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_1_00120.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_1_00120 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_1_00120.java + *- @ExecuteClass: Cycle_Bm_1_00120 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_1_00120 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00120_A1 a1_0 = new Cycle_B_1_00120_A1(); + a1_0.a2_0 = new Cycle_B_1_00120_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00120_A3(); + Cycle_B_1_00120_A5 a5_0 = new Cycle_B_1_00120_A5(); + a5_0.a4_0 = new Cycle_B_1_00120_A4(); + a5_0.a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a5_0.a4_0.add(); + a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a5_0.a4_0.sum + a5_0.sum; + //System.out.println(nsum); + + if (nsum == 28) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00120_A1 { + Cycle_B_1_00120_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00120_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00120_A2 { + Cycle_B_1_00120_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00120_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00120_A3 { + Cycle_B_1_00120_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00120_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00120_A4 { + Cycle_B_1_00120_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00120_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00120_A5 { + Cycle_B_1_00120_A4 a4_0; + int a; + int sum; + + Cycle_B_1_00120_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } +} + + +public class Cycle_Bm_1_00120 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00120 A1_Cycle_Bm_1_00120 = new ThreadRc_Cycle_Bm_1_00120(); + ThreadRc_Cycle_Bm_1_00120 A2_Cycle_Bm_1_00120 = new ThreadRc_Cycle_Bm_1_00120(); + ThreadRc_Cycle_Bm_1_00120 A3_Cycle_Bm_1_00120 = new ThreadRc_Cycle_Bm_1_00120(); + ThreadRc_Cycle_Bm_1_00120 A4_Cycle_Bm_1_00120 = new ThreadRc_Cycle_Bm_1_00120(); + ThreadRc_Cycle_Bm_1_00120 A5_Cycle_Bm_1_00120 = new ThreadRc_Cycle_Bm_1_00120(); + ThreadRc_Cycle_Bm_1_00120 A6_Cycle_Bm_1_00120 = new ThreadRc_Cycle_Bm_1_00120(); + + A1_Cycle_Bm_1_00120.start(); + A2_Cycle_Bm_1_00120.start(); + A3_Cycle_Bm_1_00120.start(); + A4_Cycle_Bm_1_00120.start(); + A5_Cycle_Bm_1_00120.start(); + A6_Cycle_Bm_1_00120.start(); + + try { + A1_Cycle_Bm_1_00120.join(); + A2_Cycle_Bm_1_00120.join(); + A3_Cycle_Bm_1_00120.join(); + A4_Cycle_Bm_1_00120.join(); + A5_Cycle_Bm_1_00120.join(); + A6_Cycle_Bm_1_00120.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00120.check() && A2_Cycle_Bm_1_00120.check() && A3_Cycle_Bm_1_00120.check() && A4_Cycle_Bm_1_00120.check() && A5_Cycle_Bm_1_00120.check() && A6_Cycle_Bm_1_00120.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0169-rc-function-RC_Thread01-Cycle_Bm_1_00130/Cycle_Bm_1_00130.java b/test/testsuite/ouroboros/rc_test/RC0169-rc-function-RC_Thread01-Cycle_Bm_1_00130/Cycle_Bm_1_00130.java new file mode 100755 index 0000000000000000000000000000000000000000..bcf022e604c5f11d39b7bfa3dd0ce19b74b6802a --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0169-rc-function-RC_Thread01-Cycle_Bm_1_00130/Cycle_Bm_1_00130.java @@ -0,0 +1,133 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_1_00130.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_1_00130 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_1_00130.java + *- @ExecuteClass: Cycle_Bm_1_00130 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_1_00130 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00130_A1 a1_0 = new Cycle_B_1_00130_A1(); + Cycle_B_1_00130_A2 a2_0 = new Cycle_B_1_00130_A2(); + Cycle_B_1_00130_A3 a3_0 = new Cycle_B_1_00130_A3(); + a1_0.a3_0 = a3_0; + a2_0.a3_0 = a3_0; + a3_0.a1_0 = a1_0; + a1_0.add(); + a2_0.add(); + a3_0.add(); + int nsum = (a1_0.sum + a2_0.sum + a3_0.sum); + //System.out.println(nsum); + + if (nsum == 13) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00130_A1 { + Cycle_B_1_00130_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00130_A1() { + a3_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00130_A2 { + Cycle_B_1_00130_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00130_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00130_A3 { + Cycle_B_1_00130_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00130_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + + +public class Cycle_Bm_1_00130 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00130 A1_Cycle_Bm_1_00130 = new ThreadRc_Cycle_Bm_1_00130(); + ThreadRc_Cycle_Bm_1_00130 A2_Cycle_Bm_1_00130 = new ThreadRc_Cycle_Bm_1_00130(); + ThreadRc_Cycle_Bm_1_00130 A3_Cycle_Bm_1_00130 = new ThreadRc_Cycle_Bm_1_00130(); + ThreadRc_Cycle_Bm_1_00130 A4_Cycle_Bm_1_00130 = new ThreadRc_Cycle_Bm_1_00130(); + ThreadRc_Cycle_Bm_1_00130 A5_Cycle_Bm_1_00130 = new ThreadRc_Cycle_Bm_1_00130(); + ThreadRc_Cycle_Bm_1_00130 A6_Cycle_Bm_1_00130 = new ThreadRc_Cycle_Bm_1_00130(); + + A1_Cycle_Bm_1_00130.start(); + A2_Cycle_Bm_1_00130.start(); + A3_Cycle_Bm_1_00130.start(); + A4_Cycle_Bm_1_00130.start(); + A5_Cycle_Bm_1_00130.start(); + A6_Cycle_Bm_1_00130.start(); + + try { + A1_Cycle_Bm_1_00130.join(); + A2_Cycle_Bm_1_00130.join(); + A3_Cycle_Bm_1_00130.join(); + A4_Cycle_Bm_1_00130.join(); + A5_Cycle_Bm_1_00130.join(); + A6_Cycle_Bm_1_00130.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00130.check() && A2_Cycle_Bm_1_00130.check() && A3_Cycle_Bm_1_00130.check() && A4_Cycle_Bm_1_00130.check() && A5_Cycle_Bm_1_00130.check() && A6_Cycle_Bm_1_00130.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0170-rc-function-RC_Thread01-Cycle_Bm_1_00140/Cycle_Bm_1_00140.java b/test/testsuite/ouroboros/rc_test/RC0170-rc-function-RC_Thread01-Cycle_Bm_1_00140/Cycle_Bm_1_00140.java new file mode 100755 index 0000000000000000000000000000000000000000..9449c9cfe2e58b709923ccce30f233cc5fde2f9d --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0170-rc-function-RC_Thread01-Cycle_Bm_1_00140/Cycle_Bm_1_00140.java @@ -0,0 +1,150 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_1_00140.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_1_00140 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_1_00140.java + *- @ExecuteClass: Cycle_Bm_1_00140 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_1_00140 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00140_A1 a1_0 = new Cycle_B_1_00140_A1(); + a1_0.a2_0 = new Cycle_B_1_00140_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00140_A3(); + Cycle_B_1_00140_A4 a4_0 = new Cycle_B_1_00140_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + + if (nsum == 12) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00140_A1 { + Cycle_B_1_00140_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00140_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00140_A2 { + Cycle_B_1_00140_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00140_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00140_A3 { + Cycle_B_1_00140_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00140_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00140_A4 { + Cycle_B_1_00140_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00140_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } +} + + +public class Cycle_Bm_1_00140 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00140 A1_Cycle_Bm_1_00140 = new ThreadRc_Cycle_Bm_1_00140(); + ThreadRc_Cycle_Bm_1_00140 A2_Cycle_Bm_1_00140 = new ThreadRc_Cycle_Bm_1_00140(); + ThreadRc_Cycle_Bm_1_00140 A3_Cycle_Bm_1_00140 = new ThreadRc_Cycle_Bm_1_00140(); + ThreadRc_Cycle_Bm_1_00140 A4_Cycle_Bm_1_00140 = new ThreadRc_Cycle_Bm_1_00140(); + ThreadRc_Cycle_Bm_1_00140 A5_Cycle_Bm_1_00140 = new ThreadRc_Cycle_Bm_1_00140(); + ThreadRc_Cycle_Bm_1_00140 A6_Cycle_Bm_1_00140 = new ThreadRc_Cycle_Bm_1_00140(); + + A1_Cycle_Bm_1_00140.start(); + A2_Cycle_Bm_1_00140.start(); + A3_Cycle_Bm_1_00140.start(); + A4_Cycle_Bm_1_00140.start(); + A5_Cycle_Bm_1_00140.start(); + A6_Cycle_Bm_1_00140.start(); + + try { + A1_Cycle_Bm_1_00140.join(); + A2_Cycle_Bm_1_00140.join(); + A3_Cycle_Bm_1_00140.join(); + A4_Cycle_Bm_1_00140.join(); + A5_Cycle_Bm_1_00140.join(); + A6_Cycle_Bm_1_00140.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00140.check() && A2_Cycle_Bm_1_00140.check() && A3_Cycle_Bm_1_00140.check() && A4_Cycle_Bm_1_00140.check() && A5_Cycle_Bm_1_00140.check() && A6_Cycle_Bm_1_00140.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0171-rc-function-RC_Thread01-Cycle_Bm_1_00150/Cycle_Bm_1_00150.java b/test/testsuite/ouroboros/rc_test/RC0171-rc-function-RC_Thread01-Cycle_Bm_1_00150/Cycle_Bm_1_00150.java new file mode 100755 index 0000000000000000000000000000000000000000..4b0bd2b4850a8c7d960428ece8203303a092401b --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0171-rc-function-RC_Thread01-Cycle_Bm_1_00150/Cycle_Bm_1_00150.java @@ -0,0 +1,171 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_1_00150.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_1_00150 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_1_00150.java + *- @ExecuteClass: Cycle_Bm_1_00150 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_1_00150 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00150_A1 a1_0 = new Cycle_B_1_00150_A1(); + a1_0.a2_0 = new Cycle_B_1_00150_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00150_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_1_00150_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_1_00150_A5(); + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum; + ; + //System.out.println(nsum); + + if (nsum == 38) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00150_A1 { + Cycle_B_1_00150_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00150_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00150_A2 { + Cycle_B_1_00150_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00150_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00150_A3 { + Cycle_B_1_00150_A1 a1_0; + Cycle_B_1_00150_A4 a4_0; + int a; + int sum; + + Cycle_B_1_00150_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00150_A4 { + + int a; + int sum; + Cycle_B_1_00150_A5 a5_0; + + Cycle_B_1_00150_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + a5_0.add(); + sum = a + a5_0.sum; + } + } + + class Cycle_B_1_00150_A5 { + + int a; + int sum; + + Cycle_B_1_00150_A5() { + a = 5; + sum = 0; + } + + void add() { + sum = a + 6; + } + } +} + + +public class Cycle_Bm_1_00150 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00150 A1_Cycle_Bm_1_00150 = new ThreadRc_Cycle_Bm_1_00150(); + ThreadRc_Cycle_Bm_1_00150 A2_Cycle_Bm_1_00150 = new ThreadRc_Cycle_Bm_1_00150(); + ThreadRc_Cycle_Bm_1_00150 A3_Cycle_Bm_1_00150 = new ThreadRc_Cycle_Bm_1_00150(); + ThreadRc_Cycle_Bm_1_00150 A4_Cycle_Bm_1_00150 = new ThreadRc_Cycle_Bm_1_00150(); + ThreadRc_Cycle_Bm_1_00150 A5_Cycle_Bm_1_00150 = new ThreadRc_Cycle_Bm_1_00150(); + ThreadRc_Cycle_Bm_1_00150 A6_Cycle_Bm_1_00150 = new ThreadRc_Cycle_Bm_1_00150(); + + A1_Cycle_Bm_1_00150.start(); + A2_Cycle_Bm_1_00150.start(); + A3_Cycle_Bm_1_00150.start(); + A4_Cycle_Bm_1_00150.start(); + A5_Cycle_Bm_1_00150.start(); + A6_Cycle_Bm_1_00150.start(); + + try { + A1_Cycle_Bm_1_00150.join(); + A2_Cycle_Bm_1_00150.join(); + A3_Cycle_Bm_1_00150.join(); + A4_Cycle_Bm_1_00150.join(); + A5_Cycle_Bm_1_00150.join(); + A6_Cycle_Bm_1_00150.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00150.check() && A2_Cycle_Bm_1_00150.check() && A3_Cycle_Bm_1_00150.check() && A4_Cycle_Bm_1_00150.check() && A5_Cycle_Bm_1_00150.check() && A6_Cycle_Bm_1_00150.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0172-rc-function-RC_Thread01-Cycle_Bm_1_00160/Cycle_Bm_1_00160.java b/test/testsuite/ouroboros/rc_test/RC0172-rc-function-RC_Thread01-Cycle_Bm_1_00160/Cycle_Bm_1_00160.java new file mode 100755 index 0000000000000000000000000000000000000000..c7d8c4162e63caadd8619c2ad1069b7a0f8f1ca0 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0172-rc-function-RC_Thread01-Cycle_Bm_1_00160/Cycle_Bm_1_00160.java @@ -0,0 +1,150 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_1_00160.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_1_00160 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_1_00160.java + *- @ExecuteClass: Cycle_Bm_1_00160 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_1_00160 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00160_A1 a1_0 = new Cycle_B_1_00160_A1(); + a1_0.a2_0 = new Cycle_B_1_00160_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00160_A3(); + Cycle_B_1_00160_A4 a4_0 = new Cycle_B_1_00160_A4(); + a4_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + + if (nsum == 17) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00160_A1 { + Cycle_B_1_00160_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00160_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00160_A2 { + Cycle_B_1_00160_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00160_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00160_A3 { + Cycle_B_1_00160_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00160_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00160_A4 { + Cycle_B_1_00160_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00160_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + + +public class Cycle_Bm_1_00160 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00160 A1_Cycle_Bm_1_00160 = new ThreadRc_Cycle_Bm_1_00160(); + ThreadRc_Cycle_Bm_1_00160 A2_Cycle_Bm_1_00160 = new ThreadRc_Cycle_Bm_1_00160(); + ThreadRc_Cycle_Bm_1_00160 A3_Cycle_Bm_1_00160 = new ThreadRc_Cycle_Bm_1_00160(); + ThreadRc_Cycle_Bm_1_00160 A4_Cycle_Bm_1_00160 = new ThreadRc_Cycle_Bm_1_00160(); + ThreadRc_Cycle_Bm_1_00160 A5_Cycle_Bm_1_00160 = new ThreadRc_Cycle_Bm_1_00160(); + ThreadRc_Cycle_Bm_1_00160 A6_Cycle_Bm_1_00160 = new ThreadRc_Cycle_Bm_1_00160(); + + A1_Cycle_Bm_1_00160.start(); + A2_Cycle_Bm_1_00160.start(); + A3_Cycle_Bm_1_00160.start(); + A4_Cycle_Bm_1_00160.start(); + A5_Cycle_Bm_1_00160.start(); + A6_Cycle_Bm_1_00160.start(); + + try { + A1_Cycle_Bm_1_00160.join(); + A2_Cycle_Bm_1_00160.join(); + A3_Cycle_Bm_1_00160.join(); + A4_Cycle_Bm_1_00160.join(); + A5_Cycle_Bm_1_00160.join(); + A6_Cycle_Bm_1_00160.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00160.check() && A2_Cycle_Bm_1_00160.check() && A3_Cycle_Bm_1_00160.check() && A4_Cycle_Bm_1_00160.check() && A5_Cycle_Bm_1_00160.check() && A6_Cycle_Bm_1_00160.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0173-rc-function-RC_Thread01-Cycle_Bm_1_00170/Cycle_Bm_1_00170.java b/test/testsuite/ouroboros/rc_test/RC0173-rc-function-RC_Thread01-Cycle_Bm_1_00170/Cycle_Bm_1_00170.java new file mode 100755 index 0000000000000000000000000000000000000000..9f0f864522aaee4b47787b3a77ccd42d51b70723 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0173-rc-function-RC_Thread01-Cycle_Bm_1_00170/Cycle_Bm_1_00170.java @@ -0,0 +1,169 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_1_00170.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_1_00170 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_1_00170.java + *- @ExecuteClass: Cycle_Bm_1_00170 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_1_00170 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00170_A1 a1_0 = new Cycle_B_1_00170_A1(); + a1_0.a2_0 = new Cycle_B_1_00170_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00170_A3(); + Cycle_B_1_00170_A4 a4_0 = new Cycle_B_1_00170_A4(); + Cycle_B_1_00170_A5 a5_0 = new Cycle_B_1_00170_A5(); + a5_0.a4_0 = a4_0; + a4_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + //System.out.println(nsum); + + if (nsum == 26) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00170_A1 { + Cycle_B_1_00170_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00170_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00170_A2 { + Cycle_B_1_00170_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00170_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00170_A3 { + Cycle_B_1_00170_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00170_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00170_A4 { + Cycle_B_1_00170_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00170_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00170_A5 { + Cycle_B_1_00170_A4 a4_0; + int a; + int sum; + + Cycle_B_1_00170_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } +} + + +public class Cycle_Bm_1_00170 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00170 A1_Cycle_Bm_1_00170 = new ThreadRc_Cycle_Bm_1_00170(); + ThreadRc_Cycle_Bm_1_00170 A2_Cycle_Bm_1_00170 = new ThreadRc_Cycle_Bm_1_00170(); + ThreadRc_Cycle_Bm_1_00170 A3_Cycle_Bm_1_00170 = new ThreadRc_Cycle_Bm_1_00170(); + ThreadRc_Cycle_Bm_1_00170 A4_Cycle_Bm_1_00170 = new ThreadRc_Cycle_Bm_1_00170(); + ThreadRc_Cycle_Bm_1_00170 A5_Cycle_Bm_1_00170 = new ThreadRc_Cycle_Bm_1_00170(); + ThreadRc_Cycle_Bm_1_00170 A6_Cycle_Bm_1_00170 = new ThreadRc_Cycle_Bm_1_00170(); + + A1_Cycle_Bm_1_00170.start(); + A2_Cycle_Bm_1_00170.start(); + A3_Cycle_Bm_1_00170.start(); + A4_Cycle_Bm_1_00170.start(); + A5_Cycle_Bm_1_00170.start(); + A6_Cycle_Bm_1_00170.start(); + + try { + A1_Cycle_Bm_1_00170.join(); + A2_Cycle_Bm_1_00170.join(); + A3_Cycle_Bm_1_00170.join(); + A4_Cycle_Bm_1_00170.join(); + A5_Cycle_Bm_1_00170.join(); + A6_Cycle_Bm_1_00170.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00170.check() && A2_Cycle_Bm_1_00170.check() && A3_Cycle_Bm_1_00170.check() && A4_Cycle_Bm_1_00170.check() && A5_Cycle_Bm_1_00170.check() && A6_Cycle_Bm_1_00170.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0174-rc-function-RC_Thread01-Cycle_Bm_1_00180/Cycle_Bm_1_00180.java b/test/testsuite/ouroboros/rc_test/RC0174-rc-function-RC_Thread01-Cycle_Bm_1_00180/Cycle_Bm_1_00180.java new file mode 100755 index 0000000000000000000000000000000000000000..0bf69d98ccb7b53af71f9652e918dad0c999e3ba --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0174-rc-function-RC_Thread01-Cycle_Bm_1_00180/Cycle_Bm_1_00180.java @@ -0,0 +1,169 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_1_00180.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_1_00180 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_1_00180.java + *- @ExecuteClass: Cycle_Bm_1_00180 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_1_00180 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00180_A1 a1_0 = new Cycle_B_1_00180_A1(); + a1_0.a2_0 = new Cycle_B_1_00180_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00180_A3(); + Cycle_B_1_00180_A4 a4_0 = new Cycle_B_1_00180_A4(); + Cycle_B_1_00180_A5 a5_0 = new Cycle_B_1_00180_A5(); + a4_0.a1_0 = a1_0; + a5_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + //System.out.println(nsum); + + if (nsum == 23) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00180_A1 { + Cycle_B_1_00180_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00180_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00180_A2 { + Cycle_B_1_00180_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00180_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00180_A3 { + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00180_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00180_A4 { + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00180_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00180_A5 { + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00180_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + + +public class Cycle_Bm_1_00180 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00180 A1_Cycle_Bm_1_00180 = new ThreadRc_Cycle_Bm_1_00180(); + ThreadRc_Cycle_Bm_1_00180 A2_Cycle_Bm_1_00180 = new ThreadRc_Cycle_Bm_1_00180(); + ThreadRc_Cycle_Bm_1_00180 A3_Cycle_Bm_1_00180 = new ThreadRc_Cycle_Bm_1_00180(); + ThreadRc_Cycle_Bm_1_00180 A4_Cycle_Bm_1_00180 = new ThreadRc_Cycle_Bm_1_00180(); + ThreadRc_Cycle_Bm_1_00180 A5_Cycle_Bm_1_00180 = new ThreadRc_Cycle_Bm_1_00180(); + ThreadRc_Cycle_Bm_1_00180 A6_Cycle_Bm_1_00180 = new ThreadRc_Cycle_Bm_1_00180(); + + A1_Cycle_Bm_1_00180.start(); + A2_Cycle_Bm_1_00180.start(); + A3_Cycle_Bm_1_00180.start(); + A4_Cycle_Bm_1_00180.start(); + A5_Cycle_Bm_1_00180.start(); + A6_Cycle_Bm_1_00180.start(); + + try { + A1_Cycle_Bm_1_00180.join(); + A2_Cycle_Bm_1_00180.join(); + A3_Cycle_Bm_1_00180.join(); + A4_Cycle_Bm_1_00180.join(); + A5_Cycle_Bm_1_00180.join(); + A6_Cycle_Bm_1_00180.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00180.check() && A2_Cycle_Bm_1_00180.check() && A3_Cycle_Bm_1_00180.check() && A4_Cycle_Bm_1_00180.check() && A5_Cycle_Bm_1_00180.check() && A6_Cycle_Bm_1_00180.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0175-rc-function-RC_Thread01-Cycle_Bm_1_00190/Cycle_Bm_1_00190.java b/test/testsuite/ouroboros/rc_test/RC0175-rc-function-RC_Thread01-Cycle_Bm_1_00190/Cycle_Bm_1_00190.java new file mode 100755 index 0000000000000000000000000000000000000000..2f3eac40ec5e6bd98e6e42585e91cd785fbec848 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0175-rc-function-RC_Thread01-Cycle_Bm_1_00190/Cycle_Bm_1_00190.java @@ -0,0 +1,150 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_1_00190.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_1_00190 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_1_00190.java + *- @ExecuteClass: Cycle_Bm_1_00190 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_1_00190 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00190_A1 a1_0 = new Cycle_B_1_00190_A1(); + a1_0.a2_0 = new Cycle_B_1_00190_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00190_A3(); + Cycle_B_1_00190_A4 a4_0 = new Cycle_B_1_00190_A4(); + a1_0.a4_0 = a4_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + + if (nsum == 21) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00190_A1 { + Cycle_B_1_00190_A2 a2_0; + Cycle_B_1_00190_A4 a4_0; + int a; + int sum; + + Cycle_B_1_00190_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00190_A2 { + Cycle_B_1_00190_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00190_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00190_A3 { + Cycle_B_1_00190_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00190_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00190_A4 { + int a; + int sum; + + Cycle_B_1_00190_A4() { + a = 4; + sum = 0; + } + + void add() { + sum = a + 5; + } + } +} + + +public class Cycle_Bm_1_00190 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00190 A1_Cycle_Bm_1_00190 = new ThreadRc_Cycle_Bm_1_00190(); + ThreadRc_Cycle_Bm_1_00190 A2_Cycle_Bm_1_00190 = new ThreadRc_Cycle_Bm_1_00190(); + ThreadRc_Cycle_Bm_1_00190 A3_Cycle_Bm_1_00190 = new ThreadRc_Cycle_Bm_1_00190(); + ThreadRc_Cycle_Bm_1_00190 A4_Cycle_Bm_1_00190 = new ThreadRc_Cycle_Bm_1_00190(); + ThreadRc_Cycle_Bm_1_00190 A5_Cycle_Bm_1_00190 = new ThreadRc_Cycle_Bm_1_00190(); + ThreadRc_Cycle_Bm_1_00190 A6_Cycle_Bm_1_00190 = new ThreadRc_Cycle_Bm_1_00190(); + + A1_Cycle_Bm_1_00190.start(); + A2_Cycle_Bm_1_00190.start(); + A3_Cycle_Bm_1_00190.start(); + A4_Cycle_Bm_1_00190.start(); + A5_Cycle_Bm_1_00190.start(); + A6_Cycle_Bm_1_00190.start(); + + try { + A1_Cycle_Bm_1_00190.join(); + A2_Cycle_Bm_1_00190.join(); + A3_Cycle_Bm_1_00190.join(); + A4_Cycle_Bm_1_00190.join(); + A5_Cycle_Bm_1_00190.join(); + A6_Cycle_Bm_1_00190.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00190.check() && A2_Cycle_Bm_1_00190.check() && A3_Cycle_Bm_1_00190.check() && A4_Cycle_Bm_1_00190.check() && A5_Cycle_Bm_1_00190.check() && A6_Cycle_Bm_1_00190.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0176-rc-function-RC_Thread01-Cycle_Bm_1_00200/Cycle_Bm_1_00200.java b/test/testsuite/ouroboros/rc_test/RC0176-rc-function-RC_Thread01-Cycle_Bm_1_00200/Cycle_Bm_1_00200.java new file mode 100755 index 0000000000000000000000000000000000000000..4f0a4ce43574026b6725b3fea6b7771383d56fb8 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0176-rc-function-RC_Thread01-Cycle_Bm_1_00200/Cycle_Bm_1_00200.java @@ -0,0 +1,169 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_1_00200.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_1_00200 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_1_00200.java + *- @ExecuteClass: Cycle_Bm_1_00200 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_1_00200 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00200_A1 a1_0 = new Cycle_B_1_00200_A1(); + a1_0.a2_0 = new Cycle_B_1_00200_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00200_A3(); + Cycle_B_1_00200_A4 a4_0 = new Cycle_B_1_00200_A4(); + Cycle_B_1_00200_A5 a5_0 = new Cycle_B_1_00200_A5(); + a1_0.a4_0 = a4_0; + a1_0.a5_0 = a5_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + //System.out.println(nsum); + + if (nsum == 38) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00200_A1 { + Cycle_B_1_00200_A2 a2_0; + Cycle_B_1_00200_A4 a4_0; + Cycle_B_1_00200_A5 a5_0; + int a; + int sum; + + Cycle_B_1_00200_A1() { + a2_0 = null; + a4_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00200_A2 { + Cycle_B_1_00200_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00200_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00200_A3 { + Cycle_B_1_00200_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00200_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00200_A4 { + int a; + int sum; + + Cycle_B_1_00200_A4() { + a = 5; + sum = 0; + } + + void add() { + sum = a + 6; + } + } + + class Cycle_B_1_00200_A5 { + int a; + int sum; + + Cycle_B_1_00200_A5() { + a = 7; + sum = 0; + } + + void add() { + sum = a + 8; + } + } +} + + +public class Cycle_Bm_1_00200 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00200 A1_Cycle_Bm_1_00200 = new ThreadRc_Cycle_Bm_1_00200(); + ThreadRc_Cycle_Bm_1_00200 A2_Cycle_Bm_1_00200 = new ThreadRc_Cycle_Bm_1_00200(); + ThreadRc_Cycle_Bm_1_00200 A3_Cycle_Bm_1_00200 = new ThreadRc_Cycle_Bm_1_00200(); + ThreadRc_Cycle_Bm_1_00200 A4_Cycle_Bm_1_00200 = new ThreadRc_Cycle_Bm_1_00200(); + ThreadRc_Cycle_Bm_1_00200 A5_Cycle_Bm_1_00200 = new ThreadRc_Cycle_Bm_1_00200(); + ThreadRc_Cycle_Bm_1_00200 A6_Cycle_Bm_1_00200 = new ThreadRc_Cycle_Bm_1_00200(); + + A1_Cycle_Bm_1_00200.start(); + A2_Cycle_Bm_1_00200.start(); + A3_Cycle_Bm_1_00200.start(); + A4_Cycle_Bm_1_00200.start(); + A5_Cycle_Bm_1_00200.start(); + A6_Cycle_Bm_1_00200.start(); + + try { + A1_Cycle_Bm_1_00200.join(); + A2_Cycle_Bm_1_00200.join(); + A3_Cycle_Bm_1_00200.join(); + A4_Cycle_Bm_1_00200.join(); + A5_Cycle_Bm_1_00200.join(); + A6_Cycle_Bm_1_00200.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00200.check() && A2_Cycle_Bm_1_00200.check() && A3_Cycle_Bm_1_00200.check() && A4_Cycle_Bm_1_00200.check() && A5_Cycle_Bm_1_00200.check() && A6_Cycle_Bm_1_00200.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0177-rc-function-RC_Thread01-Cycle_Bm_1_00210/Cycle_Bm_1_00210.java b/test/testsuite/ouroboros/rc_test/RC0177-rc-function-RC_Thread01-Cycle_Bm_1_00210/Cycle_Bm_1_00210.java new file mode 100755 index 0000000000000000000000000000000000000000..ceb2c1cb5ae10ee412c4c8a4de29366b29c0df33 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0177-rc-function-RC_Thread01-Cycle_Bm_1_00210/Cycle_Bm_1_00210.java @@ -0,0 +1,2038 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_1_00210.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:make Cycle_B_1_xx together to this Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_1_00210.java + *- @ExecuteClass: Cycle_Bm_1_00210 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_1_00010B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00010_A1 a1_0 = new Cycle_B_1_00010_A1(); + a1_0.a1_0 = a1_0; + a1_0.add(); + int nsum = a1_0.sum; + //System.out.println(nsum); + + if (nsum == 246) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00010_A1 { + Cycle_B_1_00010_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00010_A1() { + a1_0 = null; + a = 123; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_1_00020B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00020_A1 a1_0 = new Cycle_B_1_00020_A1(); + a1_0.a2_0 = new Cycle_B_1_00020_A2(); + a1_0.a2_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + + int nsum = (a1_0.sum + a1_0.a2_0.sum); + //System.out.println(nsum); + + if (nsum == 6) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00020_A1 { + Cycle_B_1_00020_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00020_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00020_A2 { + Cycle_B_1_00020_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00020_A2() { + a1_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_1_00030B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00030_A1 a1_0 = new Cycle_B_1_00030_A1(); + a1_0.a2_0 = new Cycle_B_1_00030_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00030_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + + if (nsum == 12) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00030_A1 { + Cycle_B_1_00030_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00030_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00030_A2 { + Cycle_B_1_00030_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00030_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00030_A3 { + Cycle_B_1_00030_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00030_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_1_00040B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00040_A1 a1_0 = new Cycle_B_1_00040_A1(); + a1_0.a2_0 = new Cycle_B_1_00040_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00040_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_1_00040_A4(); + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum; + //System.out.println(nsum); + + if (nsum == 21) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00040_A1 { + Cycle_B_1_00040_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00040_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00040_A2 { + Cycle_B_1_00040_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00040_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00040_A3 { + Cycle_B_1_00040_A1 a1_0; + Cycle_B_1_00040_A4 a4_0; + int a; + int sum; + + Cycle_B_1_00040_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00040_A4 { + + int a; + int sum; + + Cycle_B_1_00040_A4() { + a = 4; + sum = 0; + } + + void add() { + sum = a + 5; + } + } +} + +class ThreadRc_Cycle_Bm_1_00050B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00050_A1 a1_0 = new Cycle_B_1_00050_A1(); + a1_0.a2_0 = new Cycle_B_1_00050_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00050_A3(); + a1_0.a2_0.a4_0 = new Cycle_B_1_00050_A4(); + a1_0.a2_0.a5_0 = new Cycle_B_1_00050_A5(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + a1_0.a2_0.a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum + a1_0.a2_0.a5_0.sum; + //System.out.println(nsum); + + if (nsum == 34) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00050_A1 { + Cycle_B_1_00050_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00050_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00050_A2 { + Cycle_B_1_00050_A3 a3_0; + Cycle_B_1_00050_A4 a4_0; + Cycle_B_1_00050_A5 a5_0; + int a; + int sum; + + Cycle_B_1_00050_A2() { + a3_0 = null; + a4_0 = null; + a5_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00050_A3 { + Cycle_B_1_00050_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00050_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00050_A4 { + + int a; + int sum; + + Cycle_B_1_00050_A4() { + a = 4; + sum = 0; + } + + void add() { + sum = a + 5; + } + } + + class Cycle_B_1_00050_A5 { + + int a; + int sum; + + Cycle_B_1_00050_A5() { + a = 6; + sum = 0; + } + + void add() { + sum = a + 7; + } + } +} + +class ThreadRc_Cycle_Bm_1_00060B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00060_A1 a1_0 = new Cycle_B_1_00060_A1(); + a1_0.a2_0 = new Cycle_B_1_00060_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00060_A3(); + Cycle_B_1_00060_A4 a4_0 = new Cycle_B_1_00060_A4(); + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum; + //System.out.println(nsum); + + if (nsum == 19) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00060_A1 { + Cycle_B_1_00060_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00060_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00060_A2 { + Cycle_B_1_00060_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00060_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00060_A3 { + Cycle_B_1_00060_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00060_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00060_A4 { + Cycle_B_1_00060_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00060_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_1_00070B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00070_A1 a1_0 = new Cycle_B_1_00070_A1(); + a1_0.a2_0 = new Cycle_B_1_00070_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00070_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_1_00070_A4(); + + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum; + //System.out.println(nsum); + + if (nsum == 21) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00070_A1 { + Cycle_B_1_00070_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00070_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00070_A2 { + Cycle_B_1_00070_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00070_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00070_A3 { + Cycle_B_1_00070_A1 a1_0; + Cycle_B_1_00070_A4 a4_0; + int a; + int sum; + + Cycle_B_1_00070_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00070_A4 { + int a; + int sum; + + Cycle_B_1_00070_A4() { + a = 4; + sum = 0; + } + + void add() { + sum = a + 5; + } + } +} + +class ThreadRc_Cycle_Bm_1_00080B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00080_A1 a1_0 = new Cycle_B_1_00080_A1(); + a1_0.a2_0 = new Cycle_B_1_00080_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00080_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_1_00080_A4(); + a1_0.a2_0.a3_0.a5_0 = new Cycle_B_1_00080_A5(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a5_0.sum; + //System.out.println(nsum); + + if (nsum == 56) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00080_A1 { + Cycle_B_1_00080_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00080_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00080_A2 { + Cycle_B_1_00080_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00080_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00080_A3 { + Cycle_B_1_00080_A1 a1_0; + Cycle_B_1_00080_A4 a4_0; + Cycle_B_1_00080_A5 a5_0; + int a; + int sum; + + Cycle_B_1_00080_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + a4_0.add(); + a5_0.add(); + sum = a + a1_0.a + a4_0.sum + a5_0.sum; + } + } + + class Cycle_B_1_00080_A4 { + int a; + int sum; + + Cycle_B_1_00080_A4() { + a = 4; + sum = 0; + } + + void add() { + sum = a + 5; + } + } + + class Cycle_B_1_00080_A5 { + int a; + int sum; + + Cycle_B_1_00080_A5() { + a = 6; + sum = 0; + } + + void add() { + sum = a + 7; + } + } +} + +class ThreadRc_Cycle_Bm_1_00090B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00090_A1 a1_0 = new Cycle_B_1_00090_A1(); + a1_0.a2_0 = new Cycle_B_1_00090_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00090_A3(); + Cycle_B_1_00090_A4 a4_0 = new Cycle_B_1_00090_A4(); + Cycle_B_1_00090_A5 a5_0 = new Cycle_B_1_00090_A5(); + a4_0.a2_0 = a1_0.a2_0; + a5_0.a2_0 = a1_0.a2_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum; + //System.out.println(nsum); + + if (nsum == 25) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00090_A1 { + Cycle_B_1_00090_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00090_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00090_A2 { + Cycle_B_1_00090_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00090_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00090_A3 { + Cycle_B_1_00090_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00090_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00090_A4 { + Cycle_B_1_00090_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00090_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00090_A5 { + Cycle_B_1_00090_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00090_A5() { + a2_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_1_00100B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00100_A1 a1_0 = new Cycle_B_1_00100_A1(); + a1_0.a2_0 = new Cycle_B_1_00100_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00100_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a4_0 = new Cycle_B_1_00100_A4(); + a1_0.a2_0.a4_0.a5_0 = new Cycle_B_1_00100_A5(); + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + a1_0.a2_0.a4_0.a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum + a1_0.a2_0.a4_0.a5_0.sum; + //System.out.println(nsum); + + if (nsum == 38) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00100_A1 { + Cycle_B_1_00100_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00100_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00100_A2 { + Cycle_B_1_00100_A3 a3_0; + Cycle_B_1_00100_A4 a4_0; + int a; + int sum; + + Cycle_B_1_00100_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00100_A3 { + Cycle_B_1_00100_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00100_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00100_A4 { + + int a; + int sum; + Cycle_B_1_00100_A5 a5_0; + + Cycle_B_1_00100_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + a5_0.add(); + sum = a + a5_0.sum; + } + } + + class Cycle_B_1_00100_A5 { + + int a; + int sum; + + Cycle_B_1_00100_A5() { + a = 5; + sum = 0; + } + + void add() { + sum = a + 6; + } + } +} + +class ThreadRc_Cycle_Bm_1_00110B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00110_A1 a1_0 = new Cycle_B_1_00110_A1(); + a1_0.a2_0 = new Cycle_B_1_00110_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00110_A3(); + Cycle_B_1_00110_A5 a5_0 = new Cycle_B_1_00110_A5(); + a5_0.a4_0 = new Cycle_B_1_00110_A4(); + a5_0.a4_0.a2_0 = a1_0.a2_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a5_0.a4_0.add(); + a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a5_0.a4_0.sum + a5_0.sum; + //System.out.println(nsum); + + if (nsum == 27) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00110_A1 { + Cycle_B_1_00110_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00110_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00110_A2 { + Cycle_B_1_00110_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00110_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00110_A3 { + Cycle_B_1_00110_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00110_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00110_A4 { + Cycle_B_1_00110_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00110_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00110_A5 { + Cycle_B_1_00110_A4 a4_0; + int a; + int sum; + + Cycle_B_1_00110_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_1_00120B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00120_A1 a1_0 = new Cycle_B_1_00120_A1(); + a1_0.a2_0 = new Cycle_B_1_00120_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00120_A3(); + Cycle_B_1_00120_A5 a5_0 = new Cycle_B_1_00120_A5(); + a5_0.a4_0 = new Cycle_B_1_00120_A4(); + a5_0.a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a5_0.a4_0.add(); + a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a5_0.a4_0.sum + a5_0.sum; + //System.out.println(nsum); + + if (nsum == 28) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00120_A1 { + Cycle_B_1_00120_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00120_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00120_A2 { + Cycle_B_1_00120_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00120_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00120_A3 { + Cycle_B_1_00120_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00120_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00120_A4 { + Cycle_B_1_00120_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00120_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00120_A5 { + Cycle_B_1_00120_A4 a4_0; + int a; + int sum; + + Cycle_B_1_00120_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_1_00130B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00130_A1 a1_0 = new Cycle_B_1_00130_A1(); + Cycle_B_1_00130_A2 a2_0 = new Cycle_B_1_00130_A2(); + Cycle_B_1_00130_A3 a3_0 = new Cycle_B_1_00130_A3(); + a1_0.a3_0 = a3_0; + a2_0.a3_0 = a3_0; + a3_0.a1_0 = a1_0; + a1_0.add(); + a2_0.add(); + a3_0.add(); + int nsum = (a1_0.sum + a2_0.sum + a3_0.sum); + //System.out.println(nsum); + + if (nsum == 13) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00130_A1 { + Cycle_B_1_00130_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00130_A1() { + a3_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00130_A2 { + Cycle_B_1_00130_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00130_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00130_A3 { + Cycle_B_1_00130_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00130_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_1_00140B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00140_A1 a1_0 = new Cycle_B_1_00140_A1(); + a1_0.a2_0 = new Cycle_B_1_00140_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00140_A3(); + Cycle_B_1_00140_A4 a4_0 = new Cycle_B_1_00140_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + + if (nsum == 12) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00140_A1 { + Cycle_B_1_00140_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00140_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00140_A2 { + Cycle_B_1_00140_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00140_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00140_A3 { + Cycle_B_1_00140_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00140_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00140_A4 { + Cycle_B_1_00140_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00140_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_1_00150B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00150_A1 a1_0 = new Cycle_B_1_00150_A1(); + a1_0.a2_0 = new Cycle_B_1_00150_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00150_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_1_00150_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_1_00150_A5(); + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum; + //System.out.println(nsum); + + if (nsum == 38) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00150_A1 { + Cycle_B_1_00150_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00150_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00150_A2 { + Cycle_B_1_00150_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00150_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00150_A3 { + Cycle_B_1_00150_A1 a1_0; + Cycle_B_1_00150_A4 a4_0; + int a; + int sum; + + Cycle_B_1_00150_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00150_A4 { + + int a; + int sum; + Cycle_B_1_00150_A5 a5_0; + + Cycle_B_1_00150_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + a5_0.add(); + sum = a + a5_0.sum; + } + } + + class Cycle_B_1_00150_A5 { + + int a; + int sum; + + Cycle_B_1_00150_A5() { + a = 5; + sum = 0; + } + + void add() { + sum = a + 6; + } + } +} + +class ThreadRc_Cycle_Bm_1_00160B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00160_A1 a1_0 = new Cycle_B_1_00160_A1(); + a1_0.a2_0 = new Cycle_B_1_00160_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00160_A3(); + Cycle_B_1_00160_A4 a4_0 = new Cycle_B_1_00160_A4(); + a4_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + + if (nsum == 17) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00160_A1 { + Cycle_B_1_00160_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00160_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00160_A2 { + Cycle_B_1_00160_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00160_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00160_A3 { + Cycle_B_1_00160_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00160_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00160_A4 { + Cycle_B_1_00160_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00160_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_1_00170B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00170_A1 a1_0 = new Cycle_B_1_00170_A1(); + a1_0.a2_0 = new Cycle_B_1_00170_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00170_A3(); + Cycle_B_1_00170_A4 a4_0 = new Cycle_B_1_00170_A4(); + Cycle_B_1_00170_A5 a5_0 = new Cycle_B_1_00170_A5(); + a5_0.a4_0 = a4_0; + a4_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + //System.out.println(nsum); + + if (nsum == 26) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00170_A1 { + Cycle_B_1_00170_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00170_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00170_A2 { + Cycle_B_1_00170_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00170_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00170_A3 { + Cycle_B_1_00170_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00170_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00170_A4 { + Cycle_B_1_00170_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00170_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00170_A5 { + Cycle_B_1_00170_A4 a4_0; + int a; + int sum; + + Cycle_B_1_00170_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_1_00180B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00180_A1 a1_0 = new Cycle_B_1_00180_A1(); + a1_0.a2_0 = new Cycle_B_1_00180_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00180_A3(); + Cycle_B_1_00180_A4 a4_0 = new Cycle_B_1_00180_A4(); + Cycle_B_1_00180_A5 a5_0 = new Cycle_B_1_00180_A5(); + a4_0.a1_0 = a1_0; + a5_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + //System.out.println(nsum); + + if (nsum == 23) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00180_A1 { + Cycle_B_1_00180_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00180_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00180_A2 { + Cycle_B_1_00180_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00180_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00180_A3 { + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00180_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00180_A4 { + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00180_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00180_A5 { + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00180_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_1_00190B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00190_A1 a1_0 = new Cycle_B_1_00190_A1(); + a1_0.a2_0 = new Cycle_B_1_00190_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00190_A3(); + Cycle_B_1_00190_A4 a4_0 = new Cycle_B_1_00190_A4(); + a1_0.a4_0 = a4_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + + if (nsum == 21) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00190_A1 { + Cycle_B_1_00190_A2 a2_0; + Cycle_B_1_00190_A4 a4_0; + int a; + int sum; + + Cycle_B_1_00190_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00190_A2 { + Cycle_B_1_00190_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00190_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00190_A3 { + Cycle_B_1_00190_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00190_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00190_A4 { + int a; + int sum; + + Cycle_B_1_00190_A4() { + a = 4; + sum = 0; + } + + void add() { + sum = a + 5; + } + } +} + +class ThreadRc_Cycle_Bm_1_00200B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00200_A1 a1_0 = new Cycle_B_1_00200_A1(); + a1_0.a2_0 = new Cycle_B_1_00200_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00200_A3(); + Cycle_B_1_00200_A4 a4_0 = new Cycle_B_1_00200_A4(); + Cycle_B_1_00200_A5 a5_0 = new Cycle_B_1_00200_A5(); + a1_0.a4_0 = a4_0; + a1_0.a5_0 = a5_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + //System.out.println(nsum); + + if (nsum == 38) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00200_A1 { + Cycle_B_1_00200_A2 a2_0; + Cycle_B_1_00200_A4 a4_0; + Cycle_B_1_00200_A5 a5_0; + int a; + int sum; + + Cycle_B_1_00200_A1() { + a2_0 = null; + a4_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00200_A2 { + Cycle_B_1_00200_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00200_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00200_A3 { + Cycle_B_1_00200_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00200_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00200_A4 { + int a; + int sum; + + Cycle_B_1_00200_A4() { + a = 5; + sum = 0; + } + + void add() { + sum = a + 6; + } + } + + class Cycle_B_1_00200_A5 { + int a; + int sum; + + Cycle_B_1_00200_A5() { + a = 7; + sum = 0; + } + + void add() { + sum = a + 8; + } + } +} + +public class Cycle_Bm_1_00210 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00010B A1_00010 = new ThreadRc_Cycle_Bm_1_00010B(); + ThreadRc_Cycle_Bm_1_00010B A2_00010 = new ThreadRc_Cycle_Bm_1_00010B(); + ThreadRc_Cycle_Bm_1_00020B A1_00020 = new ThreadRc_Cycle_Bm_1_00020B(); + ThreadRc_Cycle_Bm_1_00020B A2_00020 = new ThreadRc_Cycle_Bm_1_00020B(); + ThreadRc_Cycle_Bm_1_00030B A1_00030 = new ThreadRc_Cycle_Bm_1_00030B(); + ThreadRc_Cycle_Bm_1_00030B A2_00030 = new ThreadRc_Cycle_Bm_1_00030B(); + ThreadRc_Cycle_Bm_1_00040B A1_00040 = new ThreadRc_Cycle_Bm_1_00040B(); + ThreadRc_Cycle_Bm_1_00040B A2_00040 = new ThreadRc_Cycle_Bm_1_00040B(); + ThreadRc_Cycle_Bm_1_00050B A1_00050 = new ThreadRc_Cycle_Bm_1_00050B(); + ThreadRc_Cycle_Bm_1_00050B A2_00050 = new ThreadRc_Cycle_Bm_1_00050B(); + ThreadRc_Cycle_Bm_1_00060B A1_00060 = new ThreadRc_Cycle_Bm_1_00060B(); + ThreadRc_Cycle_Bm_1_00060B A2_00060 = new ThreadRc_Cycle_Bm_1_00060B(); + ThreadRc_Cycle_Bm_1_00070B A1_00070 = new ThreadRc_Cycle_Bm_1_00070B(); + ThreadRc_Cycle_Bm_1_00070B A2_00070 = new ThreadRc_Cycle_Bm_1_00070B(); + ThreadRc_Cycle_Bm_1_00080B A1_00080 = new ThreadRc_Cycle_Bm_1_00080B(); + ThreadRc_Cycle_Bm_1_00080B A2_00080 = new ThreadRc_Cycle_Bm_1_00080B(); + ThreadRc_Cycle_Bm_1_00090B A1_00090 = new ThreadRc_Cycle_Bm_1_00090B(); + ThreadRc_Cycle_Bm_1_00090B A2_00090 = new ThreadRc_Cycle_Bm_1_00090B(); + ThreadRc_Cycle_Bm_1_00100B A1_00100 = new ThreadRc_Cycle_Bm_1_00100B(); + ThreadRc_Cycle_Bm_1_00100B A2_00100 = new ThreadRc_Cycle_Bm_1_00100B(); + ThreadRc_Cycle_Bm_1_00110B A1_00110 = new ThreadRc_Cycle_Bm_1_00110B(); + ThreadRc_Cycle_Bm_1_00110B A2_00110 = new ThreadRc_Cycle_Bm_1_00110B(); + ThreadRc_Cycle_Bm_1_00120B A1_00120 = new ThreadRc_Cycle_Bm_1_00120B(); + ThreadRc_Cycle_Bm_1_00120B A2_00120 = new ThreadRc_Cycle_Bm_1_00120B(); + ThreadRc_Cycle_Bm_1_00130B A1_00130 = new ThreadRc_Cycle_Bm_1_00130B(); + ThreadRc_Cycle_Bm_1_00130B A2_00130 = new ThreadRc_Cycle_Bm_1_00130B(); + ThreadRc_Cycle_Bm_1_00140B A1_00140 = new ThreadRc_Cycle_Bm_1_00140B(); + ThreadRc_Cycle_Bm_1_00140B A2_00140 = new ThreadRc_Cycle_Bm_1_00140B(); + ThreadRc_Cycle_Bm_1_00150B A1_00150 = new ThreadRc_Cycle_Bm_1_00150B(); + ThreadRc_Cycle_Bm_1_00150B A2_00150 = new ThreadRc_Cycle_Bm_1_00150B(); + ThreadRc_Cycle_Bm_1_00160B A1_00160 = new ThreadRc_Cycle_Bm_1_00160B(); + ThreadRc_Cycle_Bm_1_00160B A2_00160 = new ThreadRc_Cycle_Bm_1_00160B(); + ThreadRc_Cycle_Bm_1_00170B A1_00170 = new ThreadRc_Cycle_Bm_1_00170B(); + ThreadRc_Cycle_Bm_1_00170B A2_00170 = new ThreadRc_Cycle_Bm_1_00170B(); + ThreadRc_Cycle_Bm_1_00180B A1_00180 = new ThreadRc_Cycle_Bm_1_00180B(); + ThreadRc_Cycle_Bm_1_00180B A2_00180 = new ThreadRc_Cycle_Bm_1_00180B(); + ThreadRc_Cycle_Bm_1_00190B A1_00190 = new ThreadRc_Cycle_Bm_1_00190B(); + ThreadRc_Cycle_Bm_1_00190B A2_00190 = new ThreadRc_Cycle_Bm_1_00190B(); + ThreadRc_Cycle_Bm_1_00200B A1_00200 = new ThreadRc_Cycle_Bm_1_00200B(); + ThreadRc_Cycle_Bm_1_00200B A2_00200 = new ThreadRc_Cycle_Bm_1_00200B(); + A1_00010.start(); + A2_00010.start(); + A1_00020.start(); + A2_00020.start(); + A1_00030.start(); + A2_00030.start(); + A1_00040.start(); + A2_00040.start(); + A1_00050.start(); + A2_00050.start(); + A1_00060.start(); + A2_00060.start(); + A1_00070.start(); + A2_00070.start(); + A1_00080.start(); + A2_00080.start(); + A1_00090.start(); + A2_00090.start(); + A1_00100.start(); + A2_00100.start(); + A1_00110.start(); + A2_00110.start(); + A1_00120.start(); + A2_00120.start(); + A1_00130.start(); + A2_00130.start(); + A1_00140.start(); + A2_00140.start(); + A1_00150.start(); + A2_00150.start(); + A1_00160.start(); + A2_00160.start(); + A1_00170.start(); + A2_00170.start(); + A1_00180.start(); + A2_00180.start(); + A1_00190.start(); + A2_00190.start(); + A1_00200.start(); + A2_00200.start(); + try { + A1_00010.join(); + A2_00010.join(); + A1_00020.join(); + A2_00020.join(); + A1_00030.join(); + A2_00030.join(); + A1_00040.join(); + A2_00040.join(); + A1_00050.join(); + A2_00050.join(); + A1_00060.join(); + A2_00060.join(); + A1_00070.join(); + A2_00070.join(); + A1_00080.join(); + A2_00080.join(); + A1_00090.join(); + A2_00090.join(); + A1_00100.join(); + A2_00100.join(); + A1_00110.join(); + A2_00110.join(); + A1_00120.join(); + A2_00120.join(); + A1_00130.join(); + A2_00130.join(); + A1_00140.join(); + A2_00140.join(); + A1_00150.join(); + A2_00150.join(); + A1_00160.join(); + A2_00160.join(); + A1_00170.join(); + A2_00170.join(); + A1_00180.join(); + A2_00180.join(); + A1_00190.join(); + A2_00190.join(); + A1_00200.join(); + A2_00200.join(); + } catch (InterruptedException e) { + } + if (A1_00010.check() && A2_00010.check() && A1_00020.check() && A2_00020.check() && A1_00030.check() && A2_00030.check() && A1_00040.check() && A2_00040.check() && A1_00050.check() && A2_00050.check() && A1_00060.check() && A2_00060.check() && A1_00070.check() && A2_00070.check() && A1_00080.check() && A2_00080.check() && A1_00090.check() && A2_00090.check() && A1_00100.check() && A2_00100.check() && A1_00110.check() && A2_00110.check() && A1_00120.check() && A2_00120.check() && A1_00130.check() && A2_00130.check() && A1_00140.check() && A2_00140.check() && A1_00150.check() && A2_00150.check() && A1_00160.check() && A2_00160.check() && A1_00170.check() && A2_00170.check() && A1_00180.check() && A2_00180.check() && A1_00190.check() && A2_00190.check() && A1_00200.check() && A2_00200.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0178-rc-function-RC_Thread01-Cycle_Bm_1_10010/Cycle_Bm_1_10010.java b/test/testsuite/ouroboros/rc_test/RC0178-rc-function-RC_Thread01-Cycle_Bm_1_10010/Cycle_Bm_1_10010.java new file mode 100755 index 0000000000000000000000000000000000000000..ffc182552c31b0934fbb64a83bf0afadbb6eb4f3 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0178-rc-function-RC_Thread01-Cycle_Bm_1_10010/Cycle_Bm_1_10010.java @@ -0,0 +1,188 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_1_10010.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_1_10010 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_1_10010.java + *- @ExecuteClass: Cycle_Bm_1_10010 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_1_10010 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_10010_A1 a1_0 = new Cycle_B_1_10010_A1(); + a1_0.a2_0 = new Cycle_B_1_10010_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_10010_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + Cycle_B_1_10010_2A1 a1_10 = new Cycle_B_1_10010_2A1(); + a1_10.a2_0 = new Cycle_B_1_10010_2A2(); + a1_10.a2_0.a3_0 = new Cycle_B_1_10010_2A3(); + a1_10.a2_0.a3_0.a1_0 = a1_10; + a1_10.add(); + a1_10.a2_0.add(); + a1_10.a2_0.a3_0.add(); + int nsum2 = (a1_10.sum + a1_10.a2_0.sum + a1_10.a2_0.a3_0.sum); + //System.out.println(nsum); + nsum += nsum2; + + if (nsum == 24) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_10010_A1 { + Cycle_B_1_10010_A2 a2_0; + int a; + int sum; + + Cycle_B_1_10010_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_10010_A2 { + Cycle_B_1_10010_A3 a3_0; + int a; + int sum; + + Cycle_B_1_10010_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_10010_A3 { + Cycle_B_1_10010_A1 a1_0; + int a; + int sum; + + Cycle_B_1_10010_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_10010_2A1 { + Cycle_B_1_10010_2A2 a2_0; + int a; + int sum; + + Cycle_B_1_10010_2A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_10010_2A2 { + Cycle_B_1_10010_2A3 a3_0; + int a; + int sum; + + Cycle_B_1_10010_2A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_10010_2A3 { + Cycle_B_1_10010_2A1 a1_0; + int a; + int sum; + + Cycle_B_1_10010_2A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + + +public class Cycle_Bm_1_10010 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_10010 A1_Cycle_Bm_1_10010 = new ThreadRc_Cycle_Bm_1_10010(); + ThreadRc_Cycle_Bm_1_10010 A2_Cycle_Bm_1_10010 = new ThreadRc_Cycle_Bm_1_10010(); + ThreadRc_Cycle_Bm_1_10010 A3_Cycle_Bm_1_10010 = new ThreadRc_Cycle_Bm_1_10010(); + ThreadRc_Cycle_Bm_1_10010 A4_Cycle_Bm_1_10010 = new ThreadRc_Cycle_Bm_1_10010(); + ThreadRc_Cycle_Bm_1_10010 A5_Cycle_Bm_1_10010 = new ThreadRc_Cycle_Bm_1_10010(); + ThreadRc_Cycle_Bm_1_10010 A6_Cycle_Bm_1_10010 = new ThreadRc_Cycle_Bm_1_10010(); + + A1_Cycle_Bm_1_10010.start(); + A2_Cycle_Bm_1_10010.start(); + A3_Cycle_Bm_1_10010.start(); + A4_Cycle_Bm_1_10010.start(); + A5_Cycle_Bm_1_10010.start(); + A6_Cycle_Bm_1_10010.start(); + + try { + A1_Cycle_Bm_1_10010.join(); + A2_Cycle_Bm_1_10010.join(); + A3_Cycle_Bm_1_10010.join(); + A4_Cycle_Bm_1_10010.join(); + A5_Cycle_Bm_1_10010.join(); + A6_Cycle_Bm_1_10010.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_10010.check() && A2_Cycle_Bm_1_10010.check() && A3_Cycle_Bm_1_10010.check() && A4_Cycle_Bm_1_10010.check() && A5_Cycle_Bm_1_10010.check() && A6_Cycle_Bm_1_10010.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0179-rc-function-RC_Thread01-Cycle_Bm_1_10020/Cycle_Bm_1_10020.java b/test/testsuite/ouroboros/rc_test/RC0179-rc-function-RC_Thread01-Cycle_Bm_1_10020/Cycle_Bm_1_10020.java new file mode 100755 index 0000000000000000000000000000000000000000..824c3c5cb3da457fa5c08bc5c3ca553db9b877c9 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0179-rc-function-RC_Thread01-Cycle_Bm_1_10020/Cycle_Bm_1_10020.java @@ -0,0 +1,263 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_1_10020.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_1_10020 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_1_10020.java + *- @ExecuteClass: Cycle_Bm_1_10020 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_1_10020 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_10020_A1 a1_0 = new Cycle_B_1_10020_A1(); + a1_0.a2_0 = new Cycle_B_1_10020_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_10020_A3(); + Cycle_B_1_10020_A4 a4_0 = new Cycle_B_1_10020_A4(); + Cycle_B_1_10020_A5 a5_0 = new Cycle_B_1_10020_A5(); + a4_0.a1_0 = a1_0; + a5_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + Cycle_B_1_10020_2A1 a1_20 = new Cycle_B_1_10020_2A1(); + a1_20.a2_0 = new Cycle_B_1_10020_2A2(); + a1_20.a2_0.a3_0 = new Cycle_B_1_10020_2A3(); + Cycle_B_1_10020_2A4 a4_20 = new Cycle_B_1_10020_2A4(); + Cycle_B_1_10020_2A5 a5_20 = new Cycle_B_1_10020_2A5(); + a1_20.a4_0 = a4_20; + a1_20.a5_0 = a5_20; + a1_20.a2_0.a3_0.a1_0 = a1_20; + a1_20.add(); + a1_20.a2_0.add(); + a1_20.a2_0.a3_0.add(); + a4_20.add(); + a5_20.add(); + int nsum1 = (a1_20.sum + a1_20.a2_0.sum + a1_20.a2_0.a3_0.sum + a4_20.sum + a5_20.sum); + nsum += nsum1; + + if (nsum == 61) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_10020_A1 { + Cycle_B_1_10020_A2 a2_0; + int a; + int sum; + + Cycle_B_1_10020_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_10020_A2 { + Cycle_B_1_10020_A3 a3_0; + int a; + int sum; + + Cycle_B_1_10020_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_10020_A3 { + Cycle_B_1_10020_A1 a1_0; + int a; + int sum; + + Cycle_B_1_10020_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_10020_A4 { + Cycle_B_1_10020_A1 a1_0; + int a; + int sum; + + Cycle_B_1_10020_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_10020_A5 { + Cycle_B_1_10020_A1 a1_0; + int a; + int sum; + + Cycle_B_1_10020_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_10020_2A1 { + Cycle_B_1_10020_2A2 a2_0; + Cycle_B_1_10020_2A4 a4_0; + Cycle_B_1_10020_2A5 a5_0; + int a; + int sum; + + Cycle_B_1_10020_2A1() { + a2_0 = null; + a4_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_10020_2A2 { + Cycle_B_1_10020_2A3 a3_0; + int a; + int sum; + + Cycle_B_1_10020_2A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_10020_2A3 { + Cycle_B_1_10020_2A1 a1_0; + int a; + int sum; + + Cycle_B_1_10020_2A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_10020_2A4 { + int a; + int sum; + + Cycle_B_1_10020_2A4() { + a = 5; + sum = 0; + } + + void add() { + sum = a + 6; + } + } + + class Cycle_B_1_10020_2A5 { + int a; + int sum; + + Cycle_B_1_10020_2A5() { + a = 7; + sum = 0; + } + + void add() { + sum = a + 8; + } + } +} + + +public class Cycle_Bm_1_10020 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_10020 A1_Cycle_Bm_1_10020 = new ThreadRc_Cycle_Bm_1_10020(); + ThreadRc_Cycle_Bm_1_10020 A2_Cycle_Bm_1_10020 = new ThreadRc_Cycle_Bm_1_10020(); + ThreadRc_Cycle_Bm_1_10020 A3_Cycle_Bm_1_10020 = new ThreadRc_Cycle_Bm_1_10020(); + ThreadRc_Cycle_Bm_1_10020 A4_Cycle_Bm_1_10020 = new ThreadRc_Cycle_Bm_1_10020(); + ThreadRc_Cycle_Bm_1_10020 A5_Cycle_Bm_1_10020 = new ThreadRc_Cycle_Bm_1_10020(); + ThreadRc_Cycle_Bm_1_10020 A6_Cycle_Bm_1_10020 = new ThreadRc_Cycle_Bm_1_10020(); + + A1_Cycle_Bm_1_10020.start(); + A2_Cycle_Bm_1_10020.start(); + A3_Cycle_Bm_1_10020.start(); + A4_Cycle_Bm_1_10020.start(); + A5_Cycle_Bm_1_10020.start(); + A6_Cycle_Bm_1_10020.start(); + + try { + A1_Cycle_Bm_1_10020.join(); + A2_Cycle_Bm_1_10020.join(); + A3_Cycle_Bm_1_10020.join(); + A4_Cycle_Bm_1_10020.join(); + A5_Cycle_Bm_1_10020.join(); + A6_Cycle_Bm_1_10020.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_10020.check() && A2_Cycle_Bm_1_10020.check() && A3_Cycle_Bm_1_10020.check() && A4_Cycle_Bm_1_10020.check() && A5_Cycle_Bm_1_10020.check() && A6_Cycle_Bm_1_10020.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0180-rc-function-RC_Thread01-Cycle_Bm_1_10030/Cycle_Bm_1_10030.java b/test/testsuite/ouroboros/rc_test/RC0180-rc-function-RC_Thread01-Cycle_Bm_1_10030/Cycle_Bm_1_10030.java new file mode 100755 index 0000000000000000000000000000000000000000..72ccb2bf141c7ece6f4671033bfd10d61ac0b06f --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0180-rc-function-RC_Thread01-Cycle_Bm_1_10030/Cycle_Bm_1_10030.java @@ -0,0 +1,410 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_1_10030.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_1_10030 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_1_10030.java + *- @ExecuteClass: Cycle_Bm_1_10030 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_1_10010B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_10010_A1 a1_0 = new Cycle_B_1_10010_A1(); + a1_0.a2_0 = new Cycle_B_1_10010_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_10010_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + Cycle_B_1_10010_2A1 a1_10 = new Cycle_B_1_10010_2A1(); + a1_10.a2_0 = new Cycle_B_1_10010_2A2(); + a1_10.a2_0.a3_0 = new Cycle_B_1_10010_2A3(); + a1_10.a2_0.a3_0.a1_0 = a1_10; + a1_10.add(); + a1_10.a2_0.add(); + a1_10.a2_0.a3_0.add(); + int nsum2 = (a1_10.sum + a1_10.a2_0.sum + a1_10.a2_0.a3_0.sum); + //System.out.println(nsum); + nsum += nsum2; + + if (nsum == 24) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_10010_A1 { + Cycle_B_1_10010_A2 a2_0; + int a; + int sum; + + Cycle_B_1_10010_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_10010_A2 { + Cycle_B_1_10010_A3 a3_0; + int a; + int sum; + + Cycle_B_1_10010_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_10010_A3 { + Cycle_B_1_10010_A1 a1_0; + int a; + int sum; + + Cycle_B_1_10010_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_10010_2A1 { + Cycle_B_1_10010_2A2 a2_0; + int a; + int sum; + + Cycle_B_1_10010_2A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_10010_2A2 { + Cycle_B_1_10010_2A3 a3_0; + int a; + int sum; + + Cycle_B_1_10010_2A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_10010_2A3 { + Cycle_B_1_10010_2A1 a1_0; + int a; + int sum; + + Cycle_B_1_10010_2A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_1_10020B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_10020_A1 a1_0 = new Cycle_B_1_10020_A1(); + a1_0.a2_0 = new Cycle_B_1_10020_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_10020_A3(); + Cycle_B_1_10020_A4 a4_0 = new Cycle_B_1_10020_A4(); + Cycle_B_1_10020_A5 a5_0 = new Cycle_B_1_10020_A5(); + a4_0.a1_0 = a1_0; + a5_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + Cycle_B_1_10020_2A1 a1_20 = new Cycle_B_1_10020_2A1(); + a1_20.a2_0 = new Cycle_B_1_10020_2A2(); + a1_20.a2_0.a3_0 = new Cycle_B_1_10020_2A3(); + Cycle_B_1_10020_2A4 a4_20 = new Cycle_B_1_10020_2A4(); + Cycle_B_1_10020_2A5 a5_20 = new Cycle_B_1_10020_2A5(); + a1_20.a4_0 = a4_20; + a1_20.a5_0 = a5_20; + a1_20.a2_0.a3_0.a1_0 = a1_20; + a1_20.add(); + a1_20.a2_0.add(); + a1_20.a2_0.a3_0.add(); + a4_20.add(); + a5_20.add(); + int nsum1 = (a1_20.sum + a1_20.a2_0.sum + a1_20.a2_0.a3_0.sum + a4_20.sum + a5_20.sum); + nsum += nsum1; + + if (nsum == 61) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_10020_A1 { + Cycle_B_1_10020_A2 a2_0; + int a; + int sum; + + Cycle_B_1_10020_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_10020_A2 { + Cycle_B_1_10020_A3 a3_0; + int a; + int sum; + + Cycle_B_1_10020_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_10020_A3 { + Cycle_B_1_10020_A1 a1_0; + int a; + int sum; + + Cycle_B_1_10020_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_10020_A4 { + Cycle_B_1_10020_A1 a1_0; + int a; + int sum; + + Cycle_B_1_10020_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_10020_A5 { + Cycle_B_1_10020_A1 a1_0; + int a; + int sum; + + Cycle_B_1_10020_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_10020_2A1 { + Cycle_B_1_10020_2A2 a2_0; + Cycle_B_1_10020_2A4 a4_0; + Cycle_B_1_10020_2A5 a5_0; + int a; + int sum; + + Cycle_B_1_10020_2A1() { + a2_0 = null; + a4_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_10020_2A2 { + Cycle_B_1_10020_2A3 a3_0; + int a; + int sum; + + Cycle_B_1_10020_2A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_10020_2A3 { + Cycle_B_1_10020_2A1 a1_0; + int a; + int sum; + + Cycle_B_1_10020_2A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_10020_2A4 { + int a; + int sum; + + Cycle_B_1_10020_2A4() { + a = 5; + sum = 0; + } + + void add() { + sum = a + 6; + } + } + + class Cycle_B_1_10020_2A5 { + int a; + int sum; + + Cycle_B_1_10020_2A5() { + a = 7; + sum = 0; + } + + void add() { + sum = a + 8; + } + } +} + +public class Cycle_Bm_1_10030 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_10010B A1_Cycle_Bm_1_10010 = new ThreadRc_Cycle_Bm_1_10010B(); + ThreadRc_Cycle_Bm_1_10010B A2_Cycle_Bm_1_10010 = new ThreadRc_Cycle_Bm_1_10010B(); + ThreadRc_Cycle_Bm_1_10010B A3_Cycle_Bm_1_10010 = new ThreadRc_Cycle_Bm_1_10010B(); + ThreadRc_Cycle_Bm_1_10010B A4_Cycle_Bm_1_10010 = new ThreadRc_Cycle_Bm_1_10010B(); + ThreadRc_Cycle_Bm_1_10010B A5_Cycle_Bm_1_10010 = new ThreadRc_Cycle_Bm_1_10010B(); + ThreadRc_Cycle_Bm_1_10010B A6_Cycle_Bm_1_10010 = new ThreadRc_Cycle_Bm_1_10010B(); + ThreadRc_Cycle_Bm_1_10020B A1_Cycle_Bm_1_10020 = new ThreadRc_Cycle_Bm_1_10020B(); + ThreadRc_Cycle_Bm_1_10020B A2_Cycle_Bm_1_10020 = new ThreadRc_Cycle_Bm_1_10020B(); + ThreadRc_Cycle_Bm_1_10020B A3_Cycle_Bm_1_10020 = new ThreadRc_Cycle_Bm_1_10020B(); + ThreadRc_Cycle_Bm_1_10020B A4_Cycle_Bm_1_10020 = new ThreadRc_Cycle_Bm_1_10020B(); + ThreadRc_Cycle_Bm_1_10020B A5_Cycle_Bm_1_10020 = new ThreadRc_Cycle_Bm_1_10020B(); + ThreadRc_Cycle_Bm_1_10020B A6_Cycle_Bm_1_10020 = new ThreadRc_Cycle_Bm_1_10020B(); + A1_Cycle_Bm_1_10010.start(); + A2_Cycle_Bm_1_10010.start(); + A3_Cycle_Bm_1_10010.start(); + A4_Cycle_Bm_1_10010.start(); + A5_Cycle_Bm_1_10010.start(); + A6_Cycle_Bm_1_10010.start(); + A1_Cycle_Bm_1_10020.start(); + A2_Cycle_Bm_1_10020.start(); + A3_Cycle_Bm_1_10020.start(); + A4_Cycle_Bm_1_10020.start(); + A5_Cycle_Bm_1_10020.start(); + A6_Cycle_Bm_1_10020.start(); + + try { + A1_Cycle_Bm_1_10010.join(); + A2_Cycle_Bm_1_10010.join(); + A3_Cycle_Bm_1_10010.join(); + A4_Cycle_Bm_1_10010.join(); + A5_Cycle_Bm_1_10010.join(); + A6_Cycle_Bm_1_10010.join(); + A1_Cycle_Bm_1_10020.join(); + A2_Cycle_Bm_1_10020.join(); + A3_Cycle_Bm_1_10020.join(); + A4_Cycle_Bm_1_10020.join(); + A5_Cycle_Bm_1_10020.join(); + A6_Cycle_Bm_1_10020.join(); + } catch (InterruptedException e) { + e.getStackTrace(); + } + if (A1_Cycle_Bm_1_10010.check() && A2_Cycle_Bm_1_10010.check() && A3_Cycle_Bm_1_10010.check() && A4_Cycle_Bm_1_10010.check() && A5_Cycle_Bm_1_10010.check() && A6_Cycle_Bm_1_10010.check() && A1_Cycle_Bm_1_10020.check() && A2_Cycle_Bm_1_10020.check() && A3_Cycle_Bm_1_10020.check() && A4_Cycle_Bm_1_10020.check() && A5_Cycle_Bm_1_10020.check() && A6_Cycle_Bm_1_10020.check()) + System.out.println("ExpectResult"); + } + + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0181-rc-function-RC_Thread01-Cycle_Bm_2_00010/Cycle_Bm_2_00010.java b/test/testsuite/ouroboros/rc_test/RC0181-rc-function-RC_Thread01-Cycle_Bm_2_00010/Cycle_Bm_2_00010.java new file mode 100755 index 0000000000000000000000000000000000000000..3b19e62e3e916c94e9795365fd679c1589b59942 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0181-rc-function-RC_Thread01-Cycle_Bm_2_00010/Cycle_Bm_2_00010.java @@ -0,0 +1,152 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_2_00010.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_2_00010 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_2_00010.java + *- @ExecuteClass: Cycle_Bm_2_00010 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_2_00010 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00010_A1 a1_0 = new Cycle_B_2_00010_A1(); + a1_0.a2_0 = new Cycle_B_2_00010_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00010_A3(); + a1_0.a2_0.a4_0 = new Cycle_B_2_00010_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a4_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum); + //System.out.println(nsum); + + if (nsum == 18) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00010_A1 { + Cycle_B_2_00010_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00010_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00010_A2 { + Cycle_B_2_00010_A3 a3_0; + Cycle_B_2_00010_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00010_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00010_A3 { + Cycle_B_2_00010_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00010_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00010_A4 { + Cycle_B_2_00010_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00010_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } +} + + +public class Cycle_Bm_2_00010 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00010 A1_Cycle_Bm_2_00010 = new ThreadRc_Cycle_Bm_2_00010(); + ThreadRc_Cycle_Bm_2_00010 A2_Cycle_Bm_2_00010 = new ThreadRc_Cycle_Bm_2_00010(); + ThreadRc_Cycle_Bm_2_00010 A3_Cycle_Bm_2_00010 = new ThreadRc_Cycle_Bm_2_00010(); + ThreadRc_Cycle_Bm_2_00010 A4_Cycle_Bm_2_00010 = new ThreadRc_Cycle_Bm_2_00010(); + ThreadRc_Cycle_Bm_2_00010 A5_Cycle_Bm_2_00010 = new ThreadRc_Cycle_Bm_2_00010(); + ThreadRc_Cycle_Bm_2_00010 A6_Cycle_Bm_2_00010 = new ThreadRc_Cycle_Bm_2_00010(); + + A1_Cycle_Bm_2_00010.start(); + A2_Cycle_Bm_2_00010.start(); + A3_Cycle_Bm_2_00010.start(); + A4_Cycle_Bm_2_00010.start(); + A5_Cycle_Bm_2_00010.start(); + A6_Cycle_Bm_2_00010.start(); + + try { + A1_Cycle_Bm_2_00010.join(); + A2_Cycle_Bm_2_00010.join(); + A3_Cycle_Bm_2_00010.join(); + A4_Cycle_Bm_2_00010.join(); + A5_Cycle_Bm_2_00010.join(); + A6_Cycle_Bm_2_00010.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00010.check() && A2_Cycle_Bm_2_00010.check() && A3_Cycle_Bm_2_00010.check() && A4_Cycle_Bm_2_00010.check() && A5_Cycle_Bm_2_00010.check() && A6_Cycle_Bm_2_00010.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0182-rc-function-RC_Thread01-Cycle_Bm_2_00020/Cycle_Bm_2_00020.java b/test/testsuite/ouroboros/rc_test/RC0182-rc-function-RC_Thread01-Cycle_Bm_2_00020/Cycle_Bm_2_00020.java new file mode 100755 index 0000000000000000000000000000000000000000..7d6ca17b55bf3187e2c8814b92a3088e2be36886 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0182-rc-function-RC_Thread01-Cycle_Bm_2_00020/Cycle_Bm_2_00020.java @@ -0,0 +1,155 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_2_00020.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_2_00020 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_2_00020.java + *- @ExecuteClass: Cycle_Bm_2_00020 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_2_00020 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00020_A1 a1_0 = new Cycle_B_2_00020_A1(); + a1_0.a2_0 = new Cycle_B_2_00020_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00020_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00020_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum); + //System.out.println(nsum); + + if (nsum == 19) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00020_A1 { + Cycle_B_2_00020_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00020_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00020_A2 { + Cycle_B_2_00020_A3 a3_0; + Cycle_B_2_00020_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00020_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00020_A3 { + Cycle_B_2_00020_A1 a1_0; + Cycle_B_2_00020_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00020_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00020_A4 { + Cycle_B_2_00020_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00020_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } +} + + +public class Cycle_Bm_2_00020 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00020 A1_Cycle_Bm_2_00020 = new ThreadRc_Cycle_Bm_2_00020(); + ThreadRc_Cycle_Bm_2_00020 A2_Cycle_Bm_2_00020 = new ThreadRc_Cycle_Bm_2_00020(); + ThreadRc_Cycle_Bm_2_00020 A3_Cycle_Bm_2_00020 = new ThreadRc_Cycle_Bm_2_00020(); + ThreadRc_Cycle_Bm_2_00020 A4_Cycle_Bm_2_00020 = new ThreadRc_Cycle_Bm_2_00020(); + ThreadRc_Cycle_Bm_2_00020 A5_Cycle_Bm_2_00020 = new ThreadRc_Cycle_Bm_2_00020(); + ThreadRc_Cycle_Bm_2_00020 A6_Cycle_Bm_2_00020 = new ThreadRc_Cycle_Bm_2_00020(); + + A1_Cycle_Bm_2_00020.start(); + A2_Cycle_Bm_2_00020.start(); + A3_Cycle_Bm_2_00020.start(); + A4_Cycle_Bm_2_00020.start(); + A5_Cycle_Bm_2_00020.start(); + A6_Cycle_Bm_2_00020.start(); + + try { + A1_Cycle_Bm_2_00020.join(); + A2_Cycle_Bm_2_00020.join(); + A3_Cycle_Bm_2_00020.join(); + A4_Cycle_Bm_2_00020.join(); + A5_Cycle_Bm_2_00020.join(); + A6_Cycle_Bm_2_00020.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00020.check() && A2_Cycle_Bm_2_00020.check() && A3_Cycle_Bm_2_00020.check() && A4_Cycle_Bm_2_00020.check() && A5_Cycle_Bm_2_00020.check() && A6_Cycle_Bm_2_00020.check()) + System.out.println("ExpectResult"); + + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0183-rc-function-RC_Thread01-Cycle_Bm_2_00030/Cycle_Bm_2_00030.java b/test/testsuite/ouroboros/rc_test/RC0183-rc-function-RC_Thread01-Cycle_Bm_2_00030/Cycle_Bm_2_00030.java new file mode 100755 index 0000000000000000000000000000000000000000..a18b65c28ee077e9f9ba774b6380bd331f953b13 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0183-rc-function-RC_Thread01-Cycle_Bm_2_00030/Cycle_Bm_2_00030.java @@ -0,0 +1,153 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_2_00030.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_2_00030 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_2_00030.java + *- @ExecuteClass: Cycle_Bm_2_00030 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_2_00030 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00030_A1 a1_0 = new Cycle_B_2_00030_A1(); + a1_0.a2_0 = new Cycle_B_2_00030_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00030_A3(); + Cycle_B_2_00030_A4 a4_0 = new Cycle_B_2_00030_A4(); + a4_0.a1_0 = a1_0; + a1_0.a4_0 = a4_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + + if (nsum == 16) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00030_A1 { + Cycle_B_2_00030_A2 a2_0; + Cycle_B_2_00030_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00030_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00030_A2 { + Cycle_B_2_00030_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00030_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00030_A3 { + Cycle_B_2_00030_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00030_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00030_A4 { + Cycle_B_2_00030_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00030_A4() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + + +public class Cycle_Bm_2_00030 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00030 A1_Cycle_Bm_2_00030 = new ThreadRc_Cycle_Bm_2_00030(); + ThreadRc_Cycle_Bm_2_00030 A2_Cycle_Bm_2_00030 = new ThreadRc_Cycle_Bm_2_00030(); + ThreadRc_Cycle_Bm_2_00030 A3_Cycle_Bm_2_00030 = new ThreadRc_Cycle_Bm_2_00030(); + ThreadRc_Cycle_Bm_2_00030 A4_Cycle_Bm_2_00030 = new ThreadRc_Cycle_Bm_2_00030(); + ThreadRc_Cycle_Bm_2_00030 A5_Cycle_Bm_2_00030 = new ThreadRc_Cycle_Bm_2_00030(); + ThreadRc_Cycle_Bm_2_00030 A6_Cycle_Bm_2_00030 = new ThreadRc_Cycle_Bm_2_00030(); + + A1_Cycle_Bm_2_00030.start(); + A2_Cycle_Bm_2_00030.start(); + A3_Cycle_Bm_2_00030.start(); + A4_Cycle_Bm_2_00030.start(); + A5_Cycle_Bm_2_00030.start(); + A6_Cycle_Bm_2_00030.start(); + + try { + A1_Cycle_Bm_2_00030.join(); + A2_Cycle_Bm_2_00030.join(); + A3_Cycle_Bm_2_00030.join(); + A4_Cycle_Bm_2_00030.join(); + A5_Cycle_Bm_2_00030.join(); + A6_Cycle_Bm_2_00030.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00030.check() && A2_Cycle_Bm_2_00030.check() && A3_Cycle_Bm_2_00030.check() && A4_Cycle_Bm_2_00030.check() && A5_Cycle_Bm_2_00030.check() && A6_Cycle_Bm_2_00030.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0184-rc-function-RC_Thread01-Cycle_Bm_2_00040/Cycle_Bm_2_00040.java b/test/testsuite/ouroboros/rc_test/RC0184-rc-function-RC_Thread01-Cycle_Bm_2_00040/Cycle_Bm_2_00040.java new file mode 100755 index 0000000000000000000000000000000000000000..48f38f782497a82a10c891c55f2b6788137f8311 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0184-rc-function-RC_Thread01-Cycle_Bm_2_00040/Cycle_Bm_2_00040.java @@ -0,0 +1,155 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_2_00040.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_2_00040 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_2_00040.java + *- @ExecuteClass: Cycle_Bm_2_00040 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_2_00040 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00040_A1 a1_0 = new Cycle_B_2_00040_A1(); + a1_0.a2_0 = new Cycle_B_2_00040_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00040_A3(); + Cycle_B_2_00040_A4 a4_0 = new Cycle_B_2_00040_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a4_0 = a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + + if (nsum == 19) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00040_A1 { + Cycle_B_2_00040_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00040_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00040_A2 { + Cycle_B_2_00040_A3 a3_0; + Cycle_B_2_00040_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00040_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00040_A3 { + Cycle_B_2_00040_A1 a1_0; + Cycle_B_2_00040_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00040_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00040_A4 { + Cycle_B_2_00040_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00040_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } +} + + +public class Cycle_Bm_2_00040 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00040 A1_Cycle_Bm_2_00040 = new ThreadRc_Cycle_Bm_2_00040(); + ThreadRc_Cycle_Bm_2_00040 A2_Cycle_Bm_2_00040 = new ThreadRc_Cycle_Bm_2_00040(); + ThreadRc_Cycle_Bm_2_00040 A3_Cycle_Bm_2_00040 = new ThreadRc_Cycle_Bm_2_00040(); + ThreadRc_Cycle_Bm_2_00040 A4_Cycle_Bm_2_00040 = new ThreadRc_Cycle_Bm_2_00040(); + ThreadRc_Cycle_Bm_2_00040 A5_Cycle_Bm_2_00040 = new ThreadRc_Cycle_Bm_2_00040(); + ThreadRc_Cycle_Bm_2_00040 A6_Cycle_Bm_2_00040 = new ThreadRc_Cycle_Bm_2_00040(); + + A1_Cycle_Bm_2_00040.start(); + A2_Cycle_Bm_2_00040.start(); + A3_Cycle_Bm_2_00040.start(); + A4_Cycle_Bm_2_00040.start(); + A5_Cycle_Bm_2_00040.start(); + A6_Cycle_Bm_2_00040.start(); + + try { + A1_Cycle_Bm_2_00040.join(); + A2_Cycle_Bm_2_00040.join(); + A3_Cycle_Bm_2_00040.join(); + A4_Cycle_Bm_2_00040.join(); + A5_Cycle_Bm_2_00040.join(); + A6_Cycle_Bm_2_00040.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00040.check() && A2_Cycle_Bm_2_00040.check() && A3_Cycle_Bm_2_00040.check() && A4_Cycle_Bm_2_00040.check() && A5_Cycle_Bm_2_00040.check() && A6_Cycle_Bm_2_00040.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0185-rc-function-RC_Thread01-Cycle_Bm_2_00050/Cycle_Bm_2_00050.java b/test/testsuite/ouroboros/rc_test/RC0185-rc-function-RC_Thread01-Cycle_Bm_2_00050/Cycle_Bm_2_00050.java new file mode 100755 index 0000000000000000000000000000000000000000..6d3be76204217c0718872e9a76c54ece94cb4173 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0185-rc-function-RC_Thread01-Cycle_Bm_2_00050/Cycle_Bm_2_00050.java @@ -0,0 +1,174 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_2_00050.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_2_00050 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_2_00050.java + *- @ExecuteClass: Cycle_Bm_2_00050 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_2_00050 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00050_A1 a1_0 = new Cycle_B_2_00050_A1(); + a1_0.a2_0 = new Cycle_B_2_00050_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00050_A3(); + Cycle_B_2_00050_A4 a4_0 = new Cycle_B_2_00050_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a4_0.a3_0.a5_0 = new Cycle_B_2_00050_A5(); + a1_0.a2_0.a3_0.a5_0 = a4_0.a3_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a4_0.a3_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a4_0.a3_0.a5_0.sum); + //System.out.println(nsum); + + if (nsum == 28) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00050_A1 { + Cycle_B_2_00050_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00050_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00050_A2 { + Cycle_B_2_00050_A3 a3_0; + Cycle_B_2_00050_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00050_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00050_A3 { + Cycle_B_2_00050_A1 a1_0; + Cycle_B_2_00050_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00050_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00050_A4 { + Cycle_B_2_00050_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00050_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00050_A5 { + Cycle_B_2_00050_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00050_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } +} + + +public class Cycle_Bm_2_00050 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00050 A1_Cycle_Bm_2_00050 = new ThreadRc_Cycle_Bm_2_00050(); + ThreadRc_Cycle_Bm_2_00050 A2_Cycle_Bm_2_00050 = new ThreadRc_Cycle_Bm_2_00050(); + ThreadRc_Cycle_Bm_2_00050 A3_Cycle_Bm_2_00050 = new ThreadRc_Cycle_Bm_2_00050(); + ThreadRc_Cycle_Bm_2_00050 A4_Cycle_Bm_2_00050 = new ThreadRc_Cycle_Bm_2_00050(); + ThreadRc_Cycle_Bm_2_00050 A5_Cycle_Bm_2_00050 = new ThreadRc_Cycle_Bm_2_00050(); + ThreadRc_Cycle_Bm_2_00050 A6_Cycle_Bm_2_00050 = new ThreadRc_Cycle_Bm_2_00050(); + + A1_Cycle_Bm_2_00050.start(); + A2_Cycle_Bm_2_00050.start(); + A3_Cycle_Bm_2_00050.start(); + A4_Cycle_Bm_2_00050.start(); + A5_Cycle_Bm_2_00050.start(); + A6_Cycle_Bm_2_00050.start(); + + try { + A1_Cycle_Bm_2_00050.join(); + A2_Cycle_Bm_2_00050.join(); + A3_Cycle_Bm_2_00050.join(); + A4_Cycle_Bm_2_00050.join(); + A5_Cycle_Bm_2_00050.join(); + A6_Cycle_Bm_2_00050.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00050.check() && A2_Cycle_Bm_2_00050.check() && A3_Cycle_Bm_2_00050.check() && A4_Cycle_Bm_2_00050.check() && A5_Cycle_Bm_2_00050.check() && A6_Cycle_Bm_2_00050.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0186-rc-function-RC_Thread01-Cycle_Bm_2_00060/Cycle_Bm_2_00060.java b/test/testsuite/ouroboros/rc_test/RC0186-rc-function-RC_Thread01-Cycle_Bm_2_00060/Cycle_Bm_2_00060.java new file mode 100755 index 0000000000000000000000000000000000000000..82e2e1296435b79489fe0dc883ab0ef58e213d8b --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0186-rc-function-RC_Thread01-Cycle_Bm_2_00060/Cycle_Bm_2_00060.java @@ -0,0 +1,177 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_2_00060.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_2_00060 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_2_00060.java + *- @ExecuteClass: Cycle_Bm_2_00060 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_2_00060 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00060_A1 a1_0 = new Cycle_B_2_00060_A1(); + a1_0.a2_0 = new Cycle_B_2_00060_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00060_A3(); + Cycle_B_2_00060_A4 a4_0 = new Cycle_B_2_00060_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a4_0.a3_0.a5_0 = new Cycle_B_2_00060_A5(); + a1_0.a2_0.a3_0.a5_0 = a4_0.a3_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.a5_0 = a4_0.a3_0.a5_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a4_0.a3_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a4_0.a3_0.a5_0.sum); + //System.out.println(nsum); + + if (nsum == 28) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00060_A1 { + Cycle_B_2_00060_A2 a2_0; + Cycle_B_2_00060_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00060_A1() { + a2_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00060_A2 { + Cycle_B_2_00060_A3 a3_0; + Cycle_B_2_00060_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00060_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00060_A3 { + Cycle_B_2_00060_A1 a1_0; + Cycle_B_2_00060_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00060_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00060_A4 { + Cycle_B_2_00060_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00060_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00060_A5 { + Cycle_B_2_00060_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00060_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } +} + + +public class Cycle_Bm_2_00060 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00060 A1_Cycle_Bm_2_00060 = new ThreadRc_Cycle_Bm_2_00060(); + ThreadRc_Cycle_Bm_2_00060 A2_Cycle_Bm_2_00060 = new ThreadRc_Cycle_Bm_2_00060(); + ThreadRc_Cycle_Bm_2_00060 A3_Cycle_Bm_2_00060 = new ThreadRc_Cycle_Bm_2_00060(); + ThreadRc_Cycle_Bm_2_00060 A4_Cycle_Bm_2_00060 = new ThreadRc_Cycle_Bm_2_00060(); + ThreadRc_Cycle_Bm_2_00060 A5_Cycle_Bm_2_00060 = new ThreadRc_Cycle_Bm_2_00060(); + ThreadRc_Cycle_Bm_2_00060 A6_Cycle_Bm_2_00060 = new ThreadRc_Cycle_Bm_2_00060(); + + A1_Cycle_Bm_2_00060.start(); + A2_Cycle_Bm_2_00060.start(); + A3_Cycle_Bm_2_00060.start(); + A4_Cycle_Bm_2_00060.start(); + A5_Cycle_Bm_2_00060.start(); + A6_Cycle_Bm_2_00060.start(); + + try { + A1_Cycle_Bm_2_00060.join(); + A2_Cycle_Bm_2_00060.join(); + A3_Cycle_Bm_2_00060.join(); + A4_Cycle_Bm_2_00060.join(); + A5_Cycle_Bm_2_00060.join(); + A6_Cycle_Bm_2_00060.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00060.check() && A2_Cycle_Bm_2_00060.check() && A3_Cycle_Bm_2_00060.check() && A4_Cycle_Bm_2_00060.check() && A5_Cycle_Bm_2_00060.check() && A6_Cycle_Bm_2_00060.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0187-rc-function-RC_Thread01-Cycle_Bm_2_00070/Cycle_Bm_2_00070.java b/test/testsuite/ouroboros/rc_test/RC0187-rc-function-RC_Thread01-Cycle_Bm_2_00070/Cycle_Bm_2_00070.java new file mode 100755 index 0000000000000000000000000000000000000000..1a53ab1812a26ad704ae7cc26363181c17e97369 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0187-rc-function-RC_Thread01-Cycle_Bm_2_00070/Cycle_Bm_2_00070.java @@ -0,0 +1,193 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_2_00070.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_2_00070 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_2_00070.java + *- @ExecuteClass: Cycle_Bm_2_00070 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_2_00070 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00070_A1 a1_0 = new Cycle_B_2_00070_A1(); + a1_0.a2_0 = new Cycle_B_2_00070_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00070_A3(); + Cycle_B_2_00070_A4 a4_0 = new Cycle_B_2_00070_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a4_0.a3_0.a5_0 = new Cycle_B_2_00070_A5(); + Cycle_B_2_00070_A6 a6_0 = new Cycle_B_2_00070_A6(); + a6_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a5_0 = a4_0.a3_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a6_0.add(); + a4_0.a3_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a4_0.a3_0.a5_0.sum + a6_0.sum); + //System.out.println(nsum); + + if (nsum == 37) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00070_A1 { + Cycle_B_2_00070_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00070_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00070_A2 { + Cycle_B_2_00070_A3 a3_0; + Cycle_B_2_00070_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00070_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00070_A3 { + Cycle_B_2_00070_A1 a1_0; + Cycle_B_2_00070_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00070_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00070_A4 { + Cycle_B_2_00070_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00070_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00070_A5 { + Cycle_B_2_00070_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00070_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_B_2_00070_A6 { + Cycle_B_2_00070_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00070_A6() { + a3_0 = null; + a = 6; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } +} + + +public class Cycle_Bm_2_00070 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00070 A1_Cycle_Bm_2_00070 = new ThreadRc_Cycle_Bm_2_00070(); + ThreadRc_Cycle_Bm_2_00070 A2_Cycle_Bm_2_00070 = new ThreadRc_Cycle_Bm_2_00070(); + ThreadRc_Cycle_Bm_2_00070 A3_Cycle_Bm_2_00070 = new ThreadRc_Cycle_Bm_2_00070(); + ThreadRc_Cycle_Bm_2_00070 A4_Cycle_Bm_2_00070 = new ThreadRc_Cycle_Bm_2_00070(); + ThreadRc_Cycle_Bm_2_00070 A5_Cycle_Bm_2_00070 = new ThreadRc_Cycle_Bm_2_00070(); + ThreadRc_Cycle_Bm_2_00070 A6_Cycle_Bm_2_00070 = new ThreadRc_Cycle_Bm_2_00070(); + + A1_Cycle_Bm_2_00070.start(); + A2_Cycle_Bm_2_00070.start(); + A3_Cycle_Bm_2_00070.start(); + A4_Cycle_Bm_2_00070.start(); + A5_Cycle_Bm_2_00070.start(); + A6_Cycle_Bm_2_00070.start(); + + try { + A1_Cycle_Bm_2_00070.join(); + A2_Cycle_Bm_2_00070.join(); + A3_Cycle_Bm_2_00070.join(); + A4_Cycle_Bm_2_00070.join(); + A5_Cycle_Bm_2_00070.join(); + A6_Cycle_Bm_2_00070.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00070.check() && A2_Cycle_Bm_2_00070.check() && A3_Cycle_Bm_2_00070.check() && A4_Cycle_Bm_2_00070.check() && A5_Cycle_Bm_2_00070.check() && A6_Cycle_Bm_2_00070.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0188-rc-function-RC_Thread01-Cycle_Bm_2_00080/Cycle_Bm_2_00080.java b/test/testsuite/ouroboros/rc_test/RC0188-rc-function-RC_Thread01-Cycle_Bm_2_00080/Cycle_Bm_2_00080.java new file mode 100755 index 0000000000000000000000000000000000000000..82dff0bd56fa70c04f3e601a3983b4e30214e984 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0188-rc-function-RC_Thread01-Cycle_Bm_2_00080/Cycle_Bm_2_00080.java @@ -0,0 +1,181 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_2_00080.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_2_00080 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_2_00080.java + *- @ExecuteClass: Cycle_Bm_2_00080 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_2_00080 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00080_A1 a1_0 = new Cycle_B_2_00080_A1(); + a1_0.a2_0 = new Cycle_B_2_00080_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00080_A3(); + Cycle_B_2_00080_A4 a4_0 = new Cycle_B_2_00080_A4(); + a4_0.a2_0 = a1_0.a2_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a4_0.a3_0.a5_0 = new Cycle_B_2_00080_A5(); + a1_0.a2_0.a3_0.a5_0 = a4_0.a3_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.a5_0 = a4_0.a3_0.a5_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a4_0.a3_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a4_0.a3_0.a5_0.sum); + //System.out.println(nsum); + + if (nsum == 28) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00080_A1 { + Cycle_B_2_00080_A2 a2_0; + Cycle_B_2_00080_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00080_A1() { + a2_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00080_A2 { + Cycle_B_2_00080_A3 a3_0; + Cycle_B_2_00080_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00080_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00080_A3 { + Cycle_B_2_00080_A1 a1_0; + Cycle_B_2_00080_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00080_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00080_A4 { + Cycle_B_2_00080_A3 a3_0; + Cycle_B_2_00080_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00080_A4() { + a3_0 = null; + a2_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00080_A5 { + Cycle_B_2_00080_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00080_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } +} + + +public class Cycle_Bm_2_00080 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00080 A1_Cycle_Bm_2_00080 = new ThreadRc_Cycle_Bm_2_00080(); + ThreadRc_Cycle_Bm_2_00080 A2_Cycle_Bm_2_00080 = new ThreadRc_Cycle_Bm_2_00080(); + ThreadRc_Cycle_Bm_2_00080 A3_Cycle_Bm_2_00080 = new ThreadRc_Cycle_Bm_2_00080(); + ThreadRc_Cycle_Bm_2_00080 A4_Cycle_Bm_2_00080 = new ThreadRc_Cycle_Bm_2_00080(); + ThreadRc_Cycle_Bm_2_00080 A5_Cycle_Bm_2_00080 = new ThreadRc_Cycle_Bm_2_00080(); + ThreadRc_Cycle_Bm_2_00080 A6_Cycle_Bm_2_00080 = new ThreadRc_Cycle_Bm_2_00080(); + + A1_Cycle_Bm_2_00080.start(); + A2_Cycle_Bm_2_00080.start(); + A3_Cycle_Bm_2_00080.start(); + A4_Cycle_Bm_2_00080.start(); + A5_Cycle_Bm_2_00080.start(); + A6_Cycle_Bm_2_00080.start(); + + try { + A1_Cycle_Bm_2_00080.join(); + A2_Cycle_Bm_2_00080.join(); + A3_Cycle_Bm_2_00080.join(); + A4_Cycle_Bm_2_00080.join(); + A5_Cycle_Bm_2_00080.join(); + A6_Cycle_Bm_2_00080.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00080.check() && A2_Cycle_Bm_2_00080.check() && A3_Cycle_Bm_2_00080.check() && A4_Cycle_Bm_2_00080.check() && A5_Cycle_Bm_2_00080.check() && A6_Cycle_Bm_2_00080.check()) + System.out.println("ExpectResult"); + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0189-rc-function-RC_Thread01-Cycle_Bm_2_00090/Cycle_Bm_2_00090.java b/test/testsuite/ouroboros/rc_test/RC0189-rc-function-RC_Thread01-Cycle_Bm_2_00090/Cycle_Bm_2_00090.java new file mode 100755 index 0000000000000000000000000000000000000000..15ffb5c552190698634eba60492a8c5e6c2cc6fb --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0189-rc-function-RC_Thread01-Cycle_Bm_2_00090/Cycle_Bm_2_00090.java @@ -0,0 +1,135 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_2_00090.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_2_00090 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_2_00090.java + *- @ExecuteClass: Cycle_Bm_2_00090 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_2_00090 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00090_A1 a1_0 = new Cycle_B_2_00090_A1(); + Cycle_B_2_00090_A3 a3_0 = new Cycle_B_2_00090_A3(); + a1_0.a2_0 = new Cycle_B_2_00090_A2(); + a1_0.a2_0.a1_0 = a1_0; + a3_0.a2_0 = a1_0.a2_0; + a3_0.a2_0.a3_0 = a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a3_0.sum); + //System.out.println(nsum); + + if (nsum == 9) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00090_A1 { + Cycle_B_2_00090_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00090_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00090_A2 { + Cycle_B_2_00090_A1 a1_0; + Cycle_B_2_00090_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00090_A2() { + a1_0 = null; + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00090_A3 { + Cycle_B_2_00090_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00090_A3() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } +} + + +public class Cycle_Bm_2_00090 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00090 A1_Cycle_Bm_2_00090 = new ThreadRc_Cycle_Bm_2_00090(); + ThreadRc_Cycle_Bm_2_00090 A2_Cycle_Bm_2_00090 = new ThreadRc_Cycle_Bm_2_00090(); + ThreadRc_Cycle_Bm_2_00090 A3_Cycle_Bm_2_00090 = new ThreadRc_Cycle_Bm_2_00090(); + ThreadRc_Cycle_Bm_2_00090 A4_Cycle_Bm_2_00090 = new ThreadRc_Cycle_Bm_2_00090(); + ThreadRc_Cycle_Bm_2_00090 A5_Cycle_Bm_2_00090 = new ThreadRc_Cycle_Bm_2_00090(); + ThreadRc_Cycle_Bm_2_00090 A6_Cycle_Bm_2_00090 = new ThreadRc_Cycle_Bm_2_00090(); + + A1_Cycle_Bm_2_00090.start(); + A2_Cycle_Bm_2_00090.start(); + A3_Cycle_Bm_2_00090.start(); + A4_Cycle_Bm_2_00090.start(); + A5_Cycle_Bm_2_00090.start(); + A6_Cycle_Bm_2_00090.start(); + + try { + A1_Cycle_Bm_2_00090.join(); + A2_Cycle_Bm_2_00090.join(); + A3_Cycle_Bm_2_00090.join(); + A4_Cycle_Bm_2_00090.join(); + A5_Cycle_Bm_2_00090.join(); + A6_Cycle_Bm_2_00090.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00090.check() && A2_Cycle_Bm_2_00090.check() && A3_Cycle_Bm_2_00090.check() && A4_Cycle_Bm_2_00090.check() && A5_Cycle_Bm_2_00090.check() && A6_Cycle_Bm_2_00090.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0190-rc-function-RC_Thread01-Cycle_Bm_2_00100/Cycle_Bm_2_00100.java b/test/testsuite/ouroboros/rc_test/RC0190-rc-function-RC_Thread01-Cycle_Bm_2_00100/Cycle_Bm_2_00100.java new file mode 100755 index 0000000000000000000000000000000000000000..ed919a351cc8bee99420d4a95528f348300ca9ec --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0190-rc-function-RC_Thread01-Cycle_Bm_2_00100/Cycle_Bm_2_00100.java @@ -0,0 +1,170 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_2_00100.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_2_00100 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_2_00100.java + *- @ExecuteClass: Cycle_Bm_2_00100 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_2_00100 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00100_A1 a1_0 = new Cycle_B_2_00100_A1(); + a1_0.a2_0 = new Cycle_B_2_00100_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00100_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00100_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00100_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum); + //System.out.println(nsum); + + if (nsum == 29) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00100_A1 { + Cycle_B_2_00100_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00100_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00100_A2 { + Cycle_B_2_00100_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00100_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00100_A3 { + Cycle_B_2_00100_A1 a1_0; + Cycle_B_2_00100_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00100_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00100_A4 { + Cycle_B_2_00100_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00100_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_B_2_00100_A5 { + Cycle_B_2_00100_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00100_A5() { + a3_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } +} + + +public class Cycle_Bm_2_00100 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00100 A1_Cycle_Bm_2_00100 = new ThreadRc_Cycle_Bm_2_00100(); + ThreadRc_Cycle_Bm_2_00100 A2_Cycle_Bm_2_00100 = new ThreadRc_Cycle_Bm_2_00100(); + ThreadRc_Cycle_Bm_2_00100 A3_Cycle_Bm_2_00100 = new ThreadRc_Cycle_Bm_2_00100(); + ThreadRc_Cycle_Bm_2_00100 A4_Cycle_Bm_2_00100 = new ThreadRc_Cycle_Bm_2_00100(); + ThreadRc_Cycle_Bm_2_00100 A5_Cycle_Bm_2_00100 = new ThreadRc_Cycle_Bm_2_00100(); + ThreadRc_Cycle_Bm_2_00100 A6_Cycle_Bm_2_00100 = new ThreadRc_Cycle_Bm_2_00100(); + + A1_Cycle_Bm_2_00100.start(); + A2_Cycle_Bm_2_00100.start(); + A3_Cycle_Bm_2_00100.start(); + A4_Cycle_Bm_2_00100.start(); + A5_Cycle_Bm_2_00100.start(); + A6_Cycle_Bm_2_00100.start(); + + try { + A1_Cycle_Bm_2_00100.join(); + A2_Cycle_Bm_2_00100.join(); + A3_Cycle_Bm_2_00100.join(); + A4_Cycle_Bm_2_00100.join(); + A5_Cycle_Bm_2_00100.join(); + A6_Cycle_Bm_2_00100.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00100.check() && A2_Cycle_Bm_2_00100.check() && A3_Cycle_Bm_2_00100.check() && A4_Cycle_Bm_2_00100.check() && A5_Cycle_Bm_2_00100.check() && A6_Cycle_Bm_2_00100.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0191-rc-function-RC_Thread01-Cycle_Bm_2_00110/Cycle_Bm_2_00110.java b/test/testsuite/ouroboros/rc_test/RC0191-rc-function-RC_Thread01-Cycle_Bm_2_00110/Cycle_Bm_2_00110.java new file mode 100755 index 0000000000000000000000000000000000000000..a6d7b4b8c5c8ff0fb5b6c3b052df2abadbe583ab --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0191-rc-function-RC_Thread01-Cycle_Bm_2_00110/Cycle_Bm_2_00110.java @@ -0,0 +1,170 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_2_00110.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_2_00110 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_2_00110.java + *- @ExecuteClass: Cycle_Bm_2_00110 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_2_00110 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00110_A1 a1_0 = new Cycle_B_2_00110_A1(); + a1_0.a2_0 = new Cycle_B_2_00110_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00110_A3(); + a1_0.a2_0.a4_0 = new Cycle_B_2_00110_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a4_0.a5_0 = new Cycle_B_2_00110_A5(); + a1_0.a2_0.a4_0.a5_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + a1_0.a2_0.a4_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum + a1_0.a2_0.a4_0.a5_0.sum); + //System.out.println(nsum); + + if (nsum == 28) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00110_A1 { + Cycle_B_2_00110_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00110_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00110_A2 { + Cycle_B_2_00110_A3 a3_0; + Cycle_B_2_00110_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00110_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00110_A3 { + Cycle_B_2_00110_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00110_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00110_A4 { + Cycle_B_2_00110_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00110_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_B_2_00110_A5 { + Cycle_B_2_00110_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00110_A5() { + a2_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } +} + + +public class Cycle_Bm_2_00110 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00110 A1_Cycle_Bm_2_00110 = new ThreadRc_Cycle_Bm_2_00110(); + ThreadRc_Cycle_Bm_2_00110 A2_Cycle_Bm_2_00110 = new ThreadRc_Cycle_Bm_2_00110(); + ThreadRc_Cycle_Bm_2_00110 A3_Cycle_Bm_2_00110 = new ThreadRc_Cycle_Bm_2_00110(); + ThreadRc_Cycle_Bm_2_00110 A4_Cycle_Bm_2_00110 = new ThreadRc_Cycle_Bm_2_00110(); + ThreadRc_Cycle_Bm_2_00110 A5_Cycle_Bm_2_00110 = new ThreadRc_Cycle_Bm_2_00110(); + ThreadRc_Cycle_Bm_2_00110 A6_Cycle_Bm_2_00110 = new ThreadRc_Cycle_Bm_2_00110(); + + A1_Cycle_Bm_2_00110.start(); + A2_Cycle_Bm_2_00110.start(); + A3_Cycle_Bm_2_00110.start(); + A4_Cycle_Bm_2_00110.start(); + A5_Cycle_Bm_2_00110.start(); + A6_Cycle_Bm_2_00110.start(); + + try { + A1_Cycle_Bm_2_00110.join(); + A2_Cycle_Bm_2_00110.join(); + A3_Cycle_Bm_2_00110.join(); + A4_Cycle_Bm_2_00110.join(); + A5_Cycle_Bm_2_00110.join(); + A6_Cycle_Bm_2_00110.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00110.check() && A2_Cycle_Bm_2_00110.check() && A3_Cycle_Bm_2_00110.check() && A4_Cycle_Bm_2_00110.check() && A5_Cycle_Bm_2_00110.check() && A6_Cycle_Bm_2_00110.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0192-rc-function-RC_Thread01-Cycle_Bm_2_00120/Cycle_Bm_2_00120.java b/test/testsuite/ouroboros/rc_test/RC0192-rc-function-RC_Thread01-Cycle_Bm_2_00120/Cycle_Bm_2_00120.java new file mode 100755 index 0000000000000000000000000000000000000000..e6337d76e2b07ff49fa4145476703e8ebfa82819 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0192-rc-function-RC_Thread01-Cycle_Bm_2_00120/Cycle_Bm_2_00120.java @@ -0,0 +1,170 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_2_00120.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_2_00120 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_2_00120.java + *- @ExecuteClass: Cycle_Bm_2_00120 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_2_00120 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00120_A1 a1_0 = new Cycle_B_2_00120_A1(); + a1_0.a2_0 = new Cycle_B_2_00120_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00120_A3(); + a1_0.a4_0 = new Cycle_B_2_00120_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a4_0.a5_0 = new Cycle_B_2_00120_A5(); + a1_0.a4_0.a5_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a4_0.add(); + a1_0.a4_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a4_0.sum + a1_0.a4_0.a5_0.sum); + //System.out.println(nsum); + + if (nsum == 27) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00120_A1 { + Cycle_B_2_00120_A2 a2_0; + Cycle_B_2_00120_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00120_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00120_A2 { + Cycle_B_2_00120_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00120_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00120_A3 { + Cycle_B_2_00120_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00120_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00120_A4 { + Cycle_B_2_00120_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00120_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_B_2_00120_A5 { + Cycle_B_2_00120_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00120_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + + +public class Cycle_Bm_2_00120 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00120 A1_Cycle_Bm_2_00120 = new ThreadRc_Cycle_Bm_2_00120(); + ThreadRc_Cycle_Bm_2_00120 A2_Cycle_Bm_2_00120 = new ThreadRc_Cycle_Bm_2_00120(); + ThreadRc_Cycle_Bm_2_00120 A3_Cycle_Bm_2_00120 = new ThreadRc_Cycle_Bm_2_00120(); + ThreadRc_Cycle_Bm_2_00120 A4_Cycle_Bm_2_00120 = new ThreadRc_Cycle_Bm_2_00120(); + ThreadRc_Cycle_Bm_2_00120 A5_Cycle_Bm_2_00120 = new ThreadRc_Cycle_Bm_2_00120(); + ThreadRc_Cycle_Bm_2_00120 A6_Cycle_Bm_2_00120 = new ThreadRc_Cycle_Bm_2_00120(); + + A1_Cycle_Bm_2_00120.start(); + A2_Cycle_Bm_2_00120.start(); + A3_Cycle_Bm_2_00120.start(); + A4_Cycle_Bm_2_00120.start(); + A5_Cycle_Bm_2_00120.start(); + A6_Cycle_Bm_2_00120.start(); + + try { + A1_Cycle_Bm_2_00120.join(); + A2_Cycle_Bm_2_00120.join(); + A3_Cycle_Bm_2_00120.join(); + A4_Cycle_Bm_2_00120.join(); + A5_Cycle_Bm_2_00120.join(); + A6_Cycle_Bm_2_00120.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00120.check() && A2_Cycle_Bm_2_00120.check() && A3_Cycle_Bm_2_00120.check() && A4_Cycle_Bm_2_00120.check() && A5_Cycle_Bm_2_00120.check() && A6_Cycle_Bm_2_00120.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0193-rc-function-RC_Thread01-Cycle_Bm_2_00130/Cycle_Bm_2_00130.java b/test/testsuite/ouroboros/rc_test/RC0193-rc-function-RC_Thread01-Cycle_Bm_2_00130/Cycle_Bm_2_00130.java new file mode 100755 index 0000000000000000000000000000000000000000..b9196c3064d1967f743281a0d3e0d4334d3be0bd --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0193-rc-function-RC_Thread01-Cycle_Bm_2_00130/Cycle_Bm_2_00130.java @@ -0,0 +1,191 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_2_00130.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_2_00130 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_2_00130.java + *- @ExecuteClass: Cycle_Bm_2_00130 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_2_00130 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00130_A1 a1_0 = new Cycle_B_2_00130_A1(); + a1_0.a2_0 = new Cycle_B_2_00130_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00130_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00130_A4(); + a1_0.a2_0.a3_0.a4_0.a1_0 = a1_0; + Cycle_B_2_00130_A5 a5_0 = new Cycle_B_2_00130_A5(); + a1_0.a2_0.a3_0.a4_0.a6_0 = new Cycle_B_2_00130_A6(); + a1_0.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_0; + a5_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a6_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a5_0.sum + a1_0.a2_0.a3_0.a4_0.a6_0.sum); + //System.out.println(nsum); + + if (nsum == 45) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00130_A1 { + Cycle_B_2_00130_A2 a2_0; + Cycle_B_2_00130_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00130_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00130_A2 { + Cycle_B_2_00130_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00130_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00130_A3 { + Cycle_B_2_00130_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00130_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_B_2_00130_A4 { + Cycle_B_2_00130_A1 a1_0; + Cycle_B_2_00130_A6 a6_0; + int a; + int sum; + + Cycle_B_2_00130_A4() { + a1_0 = null; + a6_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a + a6_0.a; + } + } + + class Cycle_B_2_00130_A5 { + Cycle_B_2_00130_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00130_A5() { + a3_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00130_A6 { + Cycle_B_2_00130_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00130_A6() { + a5_0 = null; + a = 6; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } + } +} + + +public class Cycle_Bm_2_00130 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00130 A1_Cycle_Bm_2_00130 = new ThreadRc_Cycle_Bm_2_00130(); + ThreadRc_Cycle_Bm_2_00130 A2_Cycle_Bm_2_00130 = new ThreadRc_Cycle_Bm_2_00130(); + ThreadRc_Cycle_Bm_2_00130 A3_Cycle_Bm_2_00130 = new ThreadRc_Cycle_Bm_2_00130(); + ThreadRc_Cycle_Bm_2_00130 A4_Cycle_Bm_2_00130 = new ThreadRc_Cycle_Bm_2_00130(); + ThreadRc_Cycle_Bm_2_00130 A5_Cycle_Bm_2_00130 = new ThreadRc_Cycle_Bm_2_00130(); + ThreadRc_Cycle_Bm_2_00130 A6_Cycle_Bm_2_00130 = new ThreadRc_Cycle_Bm_2_00130(); + + A1_Cycle_Bm_2_00130.start(); + A2_Cycle_Bm_2_00130.start(); + A3_Cycle_Bm_2_00130.start(); + A4_Cycle_Bm_2_00130.start(); + A5_Cycle_Bm_2_00130.start(); + A6_Cycle_Bm_2_00130.start(); + + try { + A1_Cycle_Bm_2_00130.join(); + A2_Cycle_Bm_2_00130.join(); + A3_Cycle_Bm_2_00130.join(); + A4_Cycle_Bm_2_00130.join(); + A5_Cycle_Bm_2_00130.join(); + A6_Cycle_Bm_2_00130.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00130.check() && A2_Cycle_Bm_2_00130.check() && A3_Cycle_Bm_2_00130.check() && A4_Cycle_Bm_2_00130.check() && A5_Cycle_Bm_2_00130.check() && A6_Cycle_Bm_2_00130.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0194-rc-function-RC_Thread01-Cycle_Bm_2_00140/Cycle_Bm_2_00140.java b/test/testsuite/ouroboros/rc_test/RC0194-rc-function-RC_Thread01-Cycle_Bm_2_00140/Cycle_Bm_2_00140.java new file mode 100755 index 0000000000000000000000000000000000000000..4054a870acdad714d0930ab09c64b7dd2e44888c --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0194-rc-function-RC_Thread01-Cycle_Bm_2_00140/Cycle_Bm_2_00140.java @@ -0,0 +1,136 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_2_00140.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_2_00140 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_2_00140.java + *- @ExecuteClass: Cycle_Bm_2_00140 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_2_00140 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00140_A1 a1_0 = new Cycle_B_2_00140_A1(); + a1_0.a2_0 = new Cycle_B_2_00140_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00140_A3(); + a1_0.a2_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + + if (nsum == 13) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00140_A1 { + Cycle_B_2_00140_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00140_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00140_A2 { + Cycle_B_2_00140_A3 a3_0; + Cycle_B_2_00140_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00140_A2() { + a3_0 = null; + a1_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a + a1_0.a; + } + } + + class Cycle_B_2_00140_A3 { + Cycle_B_2_00140_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00140_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + + +public class Cycle_Bm_2_00140 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00140 A1_Cycle_Bm_2_00140 = new ThreadRc_Cycle_Bm_2_00140(); + ThreadRc_Cycle_Bm_2_00140 A2_Cycle_Bm_2_00140 = new ThreadRc_Cycle_Bm_2_00140(); + ThreadRc_Cycle_Bm_2_00140 A3_Cycle_Bm_2_00140 = new ThreadRc_Cycle_Bm_2_00140(); + ThreadRc_Cycle_Bm_2_00140 A4_Cycle_Bm_2_00140 = new ThreadRc_Cycle_Bm_2_00140(); + ThreadRc_Cycle_Bm_2_00140 A5_Cycle_Bm_2_00140 = new ThreadRc_Cycle_Bm_2_00140(); + ThreadRc_Cycle_Bm_2_00140 A6_Cycle_Bm_2_00140 = new ThreadRc_Cycle_Bm_2_00140(); + + A1_Cycle_Bm_2_00140.start(); + A2_Cycle_Bm_2_00140.start(); + A3_Cycle_Bm_2_00140.start(); + A4_Cycle_Bm_2_00140.start(); + A5_Cycle_Bm_2_00140.start(); + A6_Cycle_Bm_2_00140.start(); + + try { + A1_Cycle_Bm_2_00140.join(); + A2_Cycle_Bm_2_00140.join(); + A3_Cycle_Bm_2_00140.join(); + A4_Cycle_Bm_2_00140.join(); + A5_Cycle_Bm_2_00140.join(); + A6_Cycle_Bm_2_00140.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00140.check() && A2_Cycle_Bm_2_00140.check() && A3_Cycle_Bm_2_00140.check() && A4_Cycle_Bm_2_00140.check() && A5_Cycle_Bm_2_00140.check() && A6_Cycle_Bm_2_00140.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0195-rc-function-RC_Thread01-Cycle_Bm_2_00150/Cycle_Bm_2_00150.java b/test/testsuite/ouroboros/rc_test/RC0195-rc-function-RC_Thread01-Cycle_Bm_2_00150/Cycle_Bm_2_00150.java new file mode 100755 index 0000000000000000000000000000000000000000..294605fcaf19e33e4d6d189cbba5da8e01f900d1 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0195-rc-function-RC_Thread01-Cycle_Bm_2_00150/Cycle_Bm_2_00150.java @@ -0,0 +1,134 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_2_00150.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_2_00150 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_2_00150.java + *- @ExecuteClass: Cycle_Bm_2_00150 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_2_00150 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00150_A1 a1_0 = new Cycle_B_2_00150_A1(); + a1_0.a2_0 = new Cycle_B_2_00150_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00150_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + + if (nsum == 14) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00150_A1 { + Cycle_B_2_00150_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00150_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00150_A2 { + Cycle_B_2_00150_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00150_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00150_A3 { + Cycle_B_2_00150_A1 a1_0; + Cycle_B_2_00150_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00150_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a + a2_0.a; + } + } +} + + +public class Cycle_Bm_2_00150 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00150 A1_Cycle_Bm_2_00150 = new ThreadRc_Cycle_Bm_2_00150(); + ThreadRc_Cycle_Bm_2_00150 A2_Cycle_Bm_2_00150 = new ThreadRc_Cycle_Bm_2_00150(); + ThreadRc_Cycle_Bm_2_00150 A3_Cycle_Bm_2_00150 = new ThreadRc_Cycle_Bm_2_00150(); + ThreadRc_Cycle_Bm_2_00150 A4_Cycle_Bm_2_00150 = new ThreadRc_Cycle_Bm_2_00150(); + ThreadRc_Cycle_Bm_2_00150 A5_Cycle_Bm_2_00150 = new ThreadRc_Cycle_Bm_2_00150(); + ThreadRc_Cycle_Bm_2_00150 A6_Cycle_Bm_2_00150 = new ThreadRc_Cycle_Bm_2_00150(); + + A1_Cycle_Bm_2_00150.start(); + A2_Cycle_Bm_2_00150.start(); + A3_Cycle_Bm_2_00150.start(); + A4_Cycle_Bm_2_00150.start(); + A5_Cycle_Bm_2_00150.start(); + A6_Cycle_Bm_2_00150.start(); + + try { + A1_Cycle_Bm_2_00150.join(); + A2_Cycle_Bm_2_00150.join(); + A3_Cycle_Bm_2_00150.join(); + A4_Cycle_Bm_2_00150.join(); + A5_Cycle_Bm_2_00150.join(); + A6_Cycle_Bm_2_00150.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00150.check() && A2_Cycle_Bm_2_00150.check() && A3_Cycle_Bm_2_00150.check() && A4_Cycle_Bm_2_00150.check() && A5_Cycle_Bm_2_00150.check() && A6_Cycle_Bm_2_00150.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0196-rc-function-RC_Thread01-Cycle_Bm_2_00160/Cycle_Bm_2_00160.java b/test/testsuite/ouroboros/rc_test/RC0196-rc-function-RC_Thread01-Cycle_Bm_2_00160/Cycle_Bm_2_00160.java new file mode 100755 index 0000000000000000000000000000000000000000..bb28ba54c071dcece8f1a5a9f9425e4c1fcde8ff --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0196-rc-function-RC_Thread01-Cycle_Bm_2_00160/Cycle_Bm_2_00160.java @@ -0,0 +1,134 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_2_00160.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_2_00160 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_2_00160.java + *- @ExecuteClass: Cycle_Bm_2_00160 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_2_00160 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00160_A1 a1_0 = new Cycle_B_2_00160_A1(); + a1_0.a2_0 = new Cycle_B_2_00160_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00160_A3(); + a1_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + + if (nsum == 15) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00160_A1 { + Cycle_B_2_00160_A2 a2_0; + Cycle_B_2_00160_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00160_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } + } + + class Cycle_B_2_00160_A2 { + Cycle_B_2_00160_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00160_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00160_A3 { + Cycle_B_2_00160_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00160_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + + +public class Cycle_Bm_2_00160 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00160 A1_Cycle_Bm_2_00160 = new ThreadRc_Cycle_Bm_2_00160(); + ThreadRc_Cycle_Bm_2_00160 A2_Cycle_Bm_2_00160 = new ThreadRc_Cycle_Bm_2_00160(); + ThreadRc_Cycle_Bm_2_00160 A3_Cycle_Bm_2_00160 = new ThreadRc_Cycle_Bm_2_00160(); + ThreadRc_Cycle_Bm_2_00160 A4_Cycle_Bm_2_00160 = new ThreadRc_Cycle_Bm_2_00160(); + ThreadRc_Cycle_Bm_2_00160 A5_Cycle_Bm_2_00160 = new ThreadRc_Cycle_Bm_2_00160(); + ThreadRc_Cycle_Bm_2_00160 A6_Cycle_Bm_2_00160 = new ThreadRc_Cycle_Bm_2_00160(); + + A1_Cycle_Bm_2_00160.start(); + A2_Cycle_Bm_2_00160.start(); + A3_Cycle_Bm_2_00160.start(); + A4_Cycle_Bm_2_00160.start(); + A5_Cycle_Bm_2_00160.start(); + A6_Cycle_Bm_2_00160.start(); + + try { + A1_Cycle_Bm_2_00160.join(); + A2_Cycle_Bm_2_00160.join(); + A3_Cycle_Bm_2_00160.join(); + A4_Cycle_Bm_2_00160.join(); + A5_Cycle_Bm_2_00160.join(); + A6_Cycle_Bm_2_00160.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00160.check() && A2_Cycle_Bm_2_00160.check() && A3_Cycle_Bm_2_00160.check() && A4_Cycle_Bm_2_00160.check() && A5_Cycle_Bm_2_00160.check() && A6_Cycle_Bm_2_00160.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0197-rc-function-RC_Thread01-Cycle_Bm_2_00170/Cycle_Bm_2_00170.java b/test/testsuite/ouroboros/rc_test/RC0197-rc-function-RC_Thread01-Cycle_Bm_2_00170/Cycle_Bm_2_00170.java new file mode 100755 index 0000000000000000000000000000000000000000..cb11e0c27e299591f017d206b902b8c156a86ff0 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0197-rc-function-RC_Thread01-Cycle_Bm_2_00170/Cycle_Bm_2_00170.java @@ -0,0 +1,151 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_2_00170.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_2_00170 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_2_00170.java + *- @ExecuteClass: Cycle_Bm_2_00170 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_2_00170 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00170_A1 a1_0 = new Cycle_B_2_00170_A1(); + a1_0.a2_0 = new Cycle_B_2_00170_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00170_A3(); + a1_0.a2_0.a4_0 = new Cycle_B_2_00170_A4(); + a1_0.a2_0.a4_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum); + //System.out.println(nsum); + + if (nsum == 21) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00170_A1 { + Cycle_B_2_00170_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00170_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00170_A2 { + Cycle_B_2_00170_A3 a3_0; + Cycle_B_2_00170_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00170_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + + class Cycle_B_2_00170_A3 { + Cycle_B_2_00170_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00170_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00170_A4 { + Cycle_B_2_00170_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00170_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + + +public class Cycle_Bm_2_00170 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00170 A1_Cycle_Bm_2_00170 = new ThreadRc_Cycle_Bm_2_00170(); + ThreadRc_Cycle_Bm_2_00170 A2_Cycle_Bm_2_00170 = new ThreadRc_Cycle_Bm_2_00170(); + ThreadRc_Cycle_Bm_2_00170 A3_Cycle_Bm_2_00170 = new ThreadRc_Cycle_Bm_2_00170(); + ThreadRc_Cycle_Bm_2_00170 A4_Cycle_Bm_2_00170 = new ThreadRc_Cycle_Bm_2_00170(); + ThreadRc_Cycle_Bm_2_00170 A5_Cycle_Bm_2_00170 = new ThreadRc_Cycle_Bm_2_00170(); + ThreadRc_Cycle_Bm_2_00170 A6_Cycle_Bm_2_00170 = new ThreadRc_Cycle_Bm_2_00170(); + + A1_Cycle_Bm_2_00170.start(); + A2_Cycle_Bm_2_00170.start(); + A3_Cycle_Bm_2_00170.start(); + A4_Cycle_Bm_2_00170.start(); + A5_Cycle_Bm_2_00170.start(); + A6_Cycle_Bm_2_00170.start(); + + try { + A1_Cycle_Bm_2_00170.join(); + A2_Cycle_Bm_2_00170.join(); + A3_Cycle_Bm_2_00170.join(); + A4_Cycle_Bm_2_00170.join(); + A5_Cycle_Bm_2_00170.join(); + A6_Cycle_Bm_2_00170.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00170.check() && A2_Cycle_Bm_2_00170.check() && A3_Cycle_Bm_2_00170.check() && A4_Cycle_Bm_2_00170.check() && A5_Cycle_Bm_2_00170.check() && A6_Cycle_Bm_2_00170.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0198-rc-function-RC_Thread01-Cycle_Bm_2_00180/Cycle_Bm_2_00180.java b/test/testsuite/ouroboros/rc_test/RC0198-rc-function-RC_Thread01-Cycle_Bm_2_00180/Cycle_Bm_2_00180.java new file mode 100755 index 0000000000000000000000000000000000000000..0872c537c55eea6836dee83ea4008c9588c3f0f2 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0198-rc-function-RC_Thread01-Cycle_Bm_2_00180/Cycle_Bm_2_00180.java @@ -0,0 +1,151 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_2_00180.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_2_00180 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_2_00180.java + *- @ExecuteClass: Cycle_Bm_2_00180 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_2_00180 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00180_A1 a1_0 = new Cycle_B_2_00180_A1(); + a1_0.a2_0 = new Cycle_B_2_00180_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00180_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00180_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum); + //System.out.println(nsum); + + if (nsum == 15) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00180_A1 { + Cycle_B_2_00180_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00180_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00180_A2 { + Cycle_B_2_00180_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00180_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00180_A3 { + Cycle_B_2_00180_A1 a1_0; + Cycle_B_2_00180_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00180_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a + a4_0.a; + } + } + + class Cycle_B_2_00180_A4 { + Cycle_B_2_00180_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00180_A4() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + + +public class Cycle_Bm_2_00180 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00180 A1_Cycle_Bm_2_00180 = new ThreadRc_Cycle_Bm_2_00180(); + ThreadRc_Cycle_Bm_2_00180 A2_Cycle_Bm_2_00180 = new ThreadRc_Cycle_Bm_2_00180(); + ThreadRc_Cycle_Bm_2_00180 A3_Cycle_Bm_2_00180 = new ThreadRc_Cycle_Bm_2_00180(); + ThreadRc_Cycle_Bm_2_00180 A4_Cycle_Bm_2_00180 = new ThreadRc_Cycle_Bm_2_00180(); + ThreadRc_Cycle_Bm_2_00180 A5_Cycle_Bm_2_00180 = new ThreadRc_Cycle_Bm_2_00180(); + ThreadRc_Cycle_Bm_2_00180 A6_Cycle_Bm_2_00180 = new ThreadRc_Cycle_Bm_2_00180(); + + A1_Cycle_Bm_2_00180.start(); + A2_Cycle_Bm_2_00180.start(); + A3_Cycle_Bm_2_00180.start(); + A4_Cycle_Bm_2_00180.start(); + A5_Cycle_Bm_2_00180.start(); + A6_Cycle_Bm_2_00180.start(); + + try { + A1_Cycle_Bm_2_00180.join(); + A2_Cycle_Bm_2_00180.join(); + A3_Cycle_Bm_2_00180.join(); + A4_Cycle_Bm_2_00180.join(); + A5_Cycle_Bm_2_00180.join(); + A6_Cycle_Bm_2_00180.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00180.check() && A2_Cycle_Bm_2_00180.check() && A3_Cycle_Bm_2_00180.check() && A4_Cycle_Bm_2_00180.check() && A5_Cycle_Bm_2_00180.check() && A6_Cycle_Bm_2_00180.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0199-rc-function-RC_Thread01-Cycle_Bm_2_00190/Cycle_Bm_2_00190.java b/test/testsuite/ouroboros/rc_test/RC0199-rc-function-RC_Thread01-Cycle_Bm_2_00190/Cycle_Bm_2_00190.java new file mode 100755 index 0000000000000000000000000000000000000000..7db4488c8383604b14c8840d238a0afae752bc84 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0199-rc-function-RC_Thread01-Cycle_Bm_2_00190/Cycle_Bm_2_00190.java @@ -0,0 +1,151 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_2_00190.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_2_00190 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_2_00190.java + *- @ExecuteClass: Cycle_Bm_2_00190 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_2_00190 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00190_A1 a1_0 = new Cycle_B_2_00190_A1(); + a1_0.a2_0 = new Cycle_B_2_00190_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00190_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00190_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum); + //System.out.println(nsum); + + if (nsum == 15) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00190_A1 { + Cycle_B_2_00190_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00190_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00190_A2 { + Cycle_B_2_00190_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00190_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00190_A3 { + Cycle_B_2_00190_A1 a1_0; + Cycle_B_2_00190_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00190_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_B_2_00190_A4 { + Cycle_B_2_00190_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00190_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } +} + + +public class Cycle_Bm_2_00190 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00190 A1_Cycle_Bm_2_00190 = new ThreadRc_Cycle_Bm_2_00190(); + ThreadRc_Cycle_Bm_2_00190 A2_Cycle_Bm_2_00190 = new ThreadRc_Cycle_Bm_2_00190(); + ThreadRc_Cycle_Bm_2_00190 A3_Cycle_Bm_2_00190 = new ThreadRc_Cycle_Bm_2_00190(); + ThreadRc_Cycle_Bm_2_00190 A4_Cycle_Bm_2_00190 = new ThreadRc_Cycle_Bm_2_00190(); + ThreadRc_Cycle_Bm_2_00190 A5_Cycle_Bm_2_00190 = new ThreadRc_Cycle_Bm_2_00190(); + ThreadRc_Cycle_Bm_2_00190 A6_Cycle_Bm_2_00190 = new ThreadRc_Cycle_Bm_2_00190(); + + A1_Cycle_Bm_2_00190.start(); + A2_Cycle_Bm_2_00190.start(); + A3_Cycle_Bm_2_00190.start(); + A4_Cycle_Bm_2_00190.start(); + A5_Cycle_Bm_2_00190.start(); + A6_Cycle_Bm_2_00190.start(); + + try { + A1_Cycle_Bm_2_00190.join(); + A2_Cycle_Bm_2_00190.join(); + A3_Cycle_Bm_2_00190.join(); + A4_Cycle_Bm_2_00190.join(); + A5_Cycle_Bm_2_00190.join(); + A6_Cycle_Bm_2_00190.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00190.check() && A2_Cycle_Bm_2_00190.check() && A3_Cycle_Bm_2_00190.check() && A4_Cycle_Bm_2_00190.check() && A5_Cycle_Bm_2_00190.check() && A6_Cycle_Bm_2_00190.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0200-rc-function-RC_Thread01-Cycle_Bm_2_00200/Cycle_Bm_2_00200.java b/test/testsuite/ouroboros/rc_test/RC0200-rc-function-RC_Thread01-Cycle_Bm_2_00200/Cycle_Bm_2_00200.java new file mode 100755 index 0000000000000000000000000000000000000000..7971593eb68025b5ace09474ad0f9ed14f6b048d --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0200-rc-function-RC_Thread01-Cycle_Bm_2_00200/Cycle_Bm_2_00200.java @@ -0,0 +1,152 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_2_00200.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_2_00200 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_2_00200.java + *- @ExecuteClass: Cycle_Bm_2_00200 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_2_00200 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00200_A1 a1_0 = new Cycle_B_2_00200_A1(); + a1_0.a2_0 = new Cycle_B_2_00200_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00200_A3(); + Cycle_B_2_00200_A4 a4_0 = new Cycle_B_2_00200_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0 = a4_0; + a4_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + + if (nsum == 16) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00200_A1 { + Cycle_B_2_00200_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00200_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00200_A2 { + Cycle_B_2_00200_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00200_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00200_A3 { + Cycle_B_2_00200_A1 a1_0; + Cycle_B_2_00200_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00200_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a4_0.a + a1_0.a; + } + } + + class Cycle_B_2_00200_A4 { + Cycle_B_2_00200_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00200_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } +} + + +public class Cycle_Bm_2_00200 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00200 A1_Cycle_Bm_2_00200 = new ThreadRc_Cycle_Bm_2_00200(); + ThreadRc_Cycle_Bm_2_00200 A2_Cycle_Bm_2_00200 = new ThreadRc_Cycle_Bm_2_00200(); + ThreadRc_Cycle_Bm_2_00200 A3_Cycle_Bm_2_00200 = new ThreadRc_Cycle_Bm_2_00200(); + ThreadRc_Cycle_Bm_2_00200 A4_Cycle_Bm_2_00200 = new ThreadRc_Cycle_Bm_2_00200(); + ThreadRc_Cycle_Bm_2_00200 A5_Cycle_Bm_2_00200 = new ThreadRc_Cycle_Bm_2_00200(); + ThreadRc_Cycle_Bm_2_00200 A6_Cycle_Bm_2_00200 = new ThreadRc_Cycle_Bm_2_00200(); + + A1_Cycle_Bm_2_00200.start(); + A2_Cycle_Bm_2_00200.start(); + A3_Cycle_Bm_2_00200.start(); + A4_Cycle_Bm_2_00200.start(); + A5_Cycle_Bm_2_00200.start(); + A6_Cycle_Bm_2_00200.start(); + + try { + A1_Cycle_Bm_2_00200.join(); + A2_Cycle_Bm_2_00200.join(); + A3_Cycle_Bm_2_00200.join(); + A4_Cycle_Bm_2_00200.join(); + A5_Cycle_Bm_2_00200.join(); + A6_Cycle_Bm_2_00200.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00200.check() && A2_Cycle_Bm_2_00200.check() && A3_Cycle_Bm_2_00200.check() && A4_Cycle_Bm_2_00200.check() && A5_Cycle_Bm_2_00200.check() && A6_Cycle_Bm_2_00200.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0201-rc-function-RC_Thread01-Cycle_Bm_2_00210/Cycle_Bm_2_00210.java b/test/testsuite/ouroboros/rc_test/RC0201-rc-function-RC_Thread01-Cycle_Bm_2_00210/Cycle_Bm_2_00210.java new file mode 100755 index 0000000000000000000000000000000000000000..c80da3695ae9dcf981c4365208ea4b85f2d0bdaa --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0201-rc-function-RC_Thread01-Cycle_Bm_2_00210/Cycle_Bm_2_00210.java @@ -0,0 +1,242 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_2_00210.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_2_00210 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_2_00210.java + *- @ExecuteClass: Cycle_Bm_2_00210 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_2_00210 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00210_A1 a1_0 = new Cycle_B_2_00210_A1(); + a1_0.a2_0 = new Cycle_B_2_00210_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00210_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00210_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00210_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_B_2_00210_A6(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0 = new Cycle_B_2_00210_A8(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0 = new Cycle_B_2_00210_A9(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.a7_0 = new Cycle_B_2_00210_A7(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.a7_0.a4_0 = a1_0.a2_0.a3_0.a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.a7_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.a7_0.sum); + //System.out.println(nsum); + + if (nsum == 94) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00210_A1 { + Cycle_B_2_00210_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00210_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00210_A2 { + Cycle_B_2_00210_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00210_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00210_A3 { + Cycle_B_2_00210_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00210_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_B_2_00210_A4 { + Cycle_B_2_00210_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00210_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_B_2_00210_A5 { + Cycle_B_2_00210_A6 a6_0; + int a; + int sum; + + Cycle_B_2_00210_A5() { + a6_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_B_2_00210_A6 { + Cycle_B_2_00210_A1 a1_0; + Cycle_B_2_00210_A8 a8_0; + int a; + int sum; + + Cycle_B_2_00210_A6() { + a1_0 = null; + a8_0 = null; + a = 6; + sum = 0; + } + + void add() { + sum = a + a1_0.a + a8_0.a; + } + } + + class Cycle_B_2_00210_A8 { + Cycle_B_2_00210_A9 a9_0; + int a; + int sum; + + Cycle_B_2_00210_A8() { + a9_0 = null; + a = 7; + sum = 0; + } + + void add() { + sum = a + a9_0.a; + } + } + + class Cycle_B_2_00210_A9 { + Cycle_B_2_00210_A7 a7_0; + int a; + int sum; + + Cycle_B_2_00210_A9() { + a7_0 = null; + a = 8; + sum = 0; + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_B_2_00210_A7 { + Cycle_B_2_00210_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00210_A7() { + a4_0 = null; + a = 9; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } +} + + +public class Cycle_Bm_2_00210 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00210 A1_Cycle_Bm_2_00210 = new ThreadRc_Cycle_Bm_2_00210(); + ThreadRc_Cycle_Bm_2_00210 A2_Cycle_Bm_2_00210 = new ThreadRc_Cycle_Bm_2_00210(); + ThreadRc_Cycle_Bm_2_00210 A3_Cycle_Bm_2_00210 = new ThreadRc_Cycle_Bm_2_00210(); + ThreadRc_Cycle_Bm_2_00210 A4_Cycle_Bm_2_00210 = new ThreadRc_Cycle_Bm_2_00210(); + ThreadRc_Cycle_Bm_2_00210 A5_Cycle_Bm_2_00210 = new ThreadRc_Cycle_Bm_2_00210(); + ThreadRc_Cycle_Bm_2_00210 A6_Cycle_Bm_2_00210 = new ThreadRc_Cycle_Bm_2_00210(); + + A1_Cycle_Bm_2_00210.start(); + A2_Cycle_Bm_2_00210.start(); + A3_Cycle_Bm_2_00210.start(); + A4_Cycle_Bm_2_00210.start(); + A5_Cycle_Bm_2_00210.start(); + A6_Cycle_Bm_2_00210.start(); + + try { + A1_Cycle_Bm_2_00210.join(); + A2_Cycle_Bm_2_00210.join(); + A3_Cycle_Bm_2_00210.join(); + A4_Cycle_Bm_2_00210.join(); + A5_Cycle_Bm_2_00210.join(); + A6_Cycle_Bm_2_00210.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00210.check() && A2_Cycle_Bm_2_00210.check() && A3_Cycle_Bm_2_00210.check() && A4_Cycle_Bm_2_00210.check() && A5_Cycle_Bm_2_00210.check() && A6_Cycle_Bm_2_00210.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0202-rc-function-RC_Thread01-Cycle_Bm_2_00220/Cycle_Bm_2_00220.java b/test/testsuite/ouroboros/rc_test/RC0202-rc-function-RC_Thread01-Cycle_Bm_2_00220/Cycle_Bm_2_00220.java new file mode 100755 index 0000000000000000000000000000000000000000..f509ef7b28cc9cfa0c2a06eb41efe27bddc67f43 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0202-rc-function-RC_Thread01-Cycle_Bm_2_00220/Cycle_Bm_2_00220.java @@ -0,0 +1,242 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_2_00220.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_2_00220 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_2_00220.java + *- @ExecuteClass: Cycle_Bm_2_00220 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_2_00220 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00220_A1 a1_0 = new Cycle_B_2_00220_A1(); + a1_0.a2_0 = new Cycle_B_2_00220_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00220_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00220_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00220_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_B_2_00220_A6(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_0; + a1_0.a8_0 = new Cycle_B_2_00220_A8(); + a1_0.a8_0.a9_0 = new Cycle_B_2_00220_A9(); + a1_0.a8_0.a9_0.a7_0 = new Cycle_B_2_00220_A7(); + a1_0.a8_0.a9_0.a7_0.a4_0 = a1_0.a2_0.a3_0.a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a1_0.a8_0.add(); + a1_0.a8_0.a9_0.add(); + a1_0.a8_0.a9_0.a7_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a1_0.a8_0.sum + a1_0.a8_0.a9_0.sum + a1_0.a8_0.a9_0.a7_0.sum); + //System.out.println(nsum); + + if (nsum == 94) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00220_A1 { + Cycle_B_2_00220_A2 a2_0; + Cycle_B_2_00220_A8 a8_0; + int a; + int sum; + + Cycle_B_2_00220_A1() { + a2_0 = null; + a8_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a + a8_0.a; + } + } + + class Cycle_B_2_00220_A2 { + Cycle_B_2_00220_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00220_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00220_A3 { + Cycle_B_2_00220_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00220_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_B_2_00220_A4 { + Cycle_B_2_00220_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00220_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_B_2_00220_A5 { + Cycle_B_2_00220_A6 a6_0; + int a; + int sum; + + Cycle_B_2_00220_A5() { + a6_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_B_2_00220_A6 { + Cycle_B_2_00220_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00220_A6() { + a1_0 = null; + a = 6; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00220_A8 { + Cycle_B_2_00220_A9 a9_0; + int a; + int sum; + + Cycle_B_2_00220_A8() { + a9_0 = null; + a = 7; + sum = 0; + } + + void add() { + sum = a + a9_0.a; + } + } + + class Cycle_B_2_00220_A9 { + Cycle_B_2_00220_A7 a7_0; + int a; + int sum; + + Cycle_B_2_00220_A9() { + a7_0 = null; + a = 8; + sum = 0; + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_B_2_00220_A7 { + Cycle_B_2_00220_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00220_A7() { + a4_0 = null; + a = 9; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } +} + + +public class Cycle_Bm_2_00220 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00220 A1_Cycle_Bm_2_00220 = new ThreadRc_Cycle_Bm_2_00220(); + ThreadRc_Cycle_Bm_2_00220 A2_Cycle_Bm_2_00220 = new ThreadRc_Cycle_Bm_2_00220(); + ThreadRc_Cycle_Bm_2_00220 A3_Cycle_Bm_2_00220 = new ThreadRc_Cycle_Bm_2_00220(); + ThreadRc_Cycle_Bm_2_00220 A4_Cycle_Bm_2_00220 = new ThreadRc_Cycle_Bm_2_00220(); + ThreadRc_Cycle_Bm_2_00220 A5_Cycle_Bm_2_00220 = new ThreadRc_Cycle_Bm_2_00220(); + ThreadRc_Cycle_Bm_2_00220 A6_Cycle_Bm_2_00220 = new ThreadRc_Cycle_Bm_2_00220(); + + A1_Cycle_Bm_2_00220.start(); + A2_Cycle_Bm_2_00220.start(); + A3_Cycle_Bm_2_00220.start(); + A4_Cycle_Bm_2_00220.start(); + A5_Cycle_Bm_2_00220.start(); + A6_Cycle_Bm_2_00220.start(); + + try { + A1_Cycle_Bm_2_00220.join(); + A2_Cycle_Bm_2_00220.join(); + A3_Cycle_Bm_2_00220.join(); + A4_Cycle_Bm_2_00220.join(); + A5_Cycle_Bm_2_00220.join(); + A6_Cycle_Bm_2_00220.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00220.check() && A2_Cycle_Bm_2_00220.check() && A3_Cycle_Bm_2_00220.check() && A4_Cycle_Bm_2_00220.check() && A5_Cycle_Bm_2_00220.check() && A6_Cycle_Bm_2_00220.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0203-rc-function-RC_Thread01-Cycle_Bm_2_00230/Cycle_Bm_2_00230.java b/test/testsuite/ouroboros/rc_test/RC0203-rc-function-RC_Thread01-Cycle_Bm_2_00230/Cycle_Bm_2_00230.java new file mode 100755 index 0000000000000000000000000000000000000000..fb32ae3a9043ff17ca9669c5e6b89f34b26a5c19 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0203-rc-function-RC_Thread01-Cycle_Bm_2_00230/Cycle_Bm_2_00230.java @@ -0,0 +1,262 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_2_00230.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Cycle_B_2_00230 in RC测试-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_2_00230.java + *- @ExecuteClass: Cycle_Bm_2_00230 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_2_00230 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00230_A1 a1_0 = new Cycle_B_2_00230_A1(); + a1_0.a2_0 = new Cycle_B_2_00230_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00230_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00230_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00230_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_B_2_00230_A6(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_0; + + Cycle_B_2_00230_A10 a10_0 = new Cycle_B_2_00230_A10(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a10_0 = a10_0; + a10_0.a8_0 = new Cycle_B_2_00230_A8(); + a10_0.a8_0.a9_0 = new Cycle_B_2_00230_A9(); + a10_0.a8_0.a9_0.a7_0 = new Cycle_B_2_00230_A7(); + a10_0.a8_0.a9_0.a7_0.a4_0 = a1_0.a2_0.a3_0.a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a10_0.a8_0.add(); + a10_0.a8_0.a9_0.add(); + a10_0.a8_0.a9_0.a7_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a10_0.a8_0.sum + a10_0.a8_0.a9_0.sum + a10_0.a8_0.a9_0.a7_0.sum); + + //System.out.println(nsum); + + if (nsum == 97) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00230_A1 { + Cycle_B_2_00230_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00230_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00230_A2 { + Cycle_B_2_00230_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00230_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00230_A3 { + Cycle_B_2_00230_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00230_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_B_2_00230_A4 { + Cycle_B_2_00230_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00230_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_B_2_00230_A5 { + Cycle_B_2_00230_A6 a6_0; + int a; + int sum; + + Cycle_B_2_00230_A5() { + a6_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_B_2_00230_A6 { + Cycle_B_2_00230_A1 a1_0; + Cycle_B_2_00230_A10 a10_0; + int a; + int sum; + + Cycle_B_2_00230_A6() { + a1_0 = null; + a10_0 = null; + a = 6; + sum = 0; + } + + void add() { + sum = a + a1_0.a + a10_0.a; + } + } + + class Cycle_B_2_00230_A8 { + Cycle_B_2_00230_A9 a9_0; + int a; + int sum; + + Cycle_B_2_00230_A8() { + a9_0 = null; + a = 7; + sum = 0; + } + + void add() { + sum = a + a9_0.a; + } + } + + class Cycle_B_2_00230_A9 { + Cycle_B_2_00230_A7 a7_0; + int a; + int sum; + + Cycle_B_2_00230_A9() { + a7_0 = null; + a = 8; + sum = 0; + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_B_2_00230_A7 { + Cycle_B_2_00230_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00230_A7() { + a4_0 = null; + a = 9; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_B_2_00230_A10 { + Cycle_B_2_00230_A8 a8_0; + int a; + int sum; + + Cycle_B_2_00230_A10() { + a8_0 = null; + a = 10; + sum = 0; + } + + void add() { + sum = a + a8_0.a; + } + } +} + + +public class Cycle_Bm_2_00230 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00230 A1_Cycle_Bm_2_00230 = new ThreadRc_Cycle_Bm_2_00230(); + ThreadRc_Cycle_Bm_2_00230 A2_Cycle_Bm_2_00230 = new ThreadRc_Cycle_Bm_2_00230(); + ThreadRc_Cycle_Bm_2_00230 A3_Cycle_Bm_2_00230 = new ThreadRc_Cycle_Bm_2_00230(); + ThreadRc_Cycle_Bm_2_00230 A4_Cycle_Bm_2_00230 = new ThreadRc_Cycle_Bm_2_00230(); + ThreadRc_Cycle_Bm_2_00230 A5_Cycle_Bm_2_00230 = new ThreadRc_Cycle_Bm_2_00230(); + ThreadRc_Cycle_Bm_2_00230 A6_Cycle_Bm_2_00230 = new ThreadRc_Cycle_Bm_2_00230(); + + A1_Cycle_Bm_2_00230.start(); + A2_Cycle_Bm_2_00230.start(); + A3_Cycle_Bm_2_00230.start(); + A4_Cycle_Bm_2_00230.start(); + A5_Cycle_Bm_2_00230.start(); + A6_Cycle_Bm_2_00230.start(); + + try { + A1_Cycle_Bm_2_00230.join(); + A2_Cycle_Bm_2_00230.join(); + A3_Cycle_Bm_2_00230.join(); + A4_Cycle_Bm_2_00230.join(); + A5_Cycle_Bm_2_00230.join(); + A6_Cycle_Bm_2_00230.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00230.check() && A2_Cycle_Bm_2_00230.check() && A3_Cycle_Bm_2_00230.check() && A4_Cycle_Bm_2_00230.check() && A5_Cycle_Bm_2_00230.check() && A6_Cycle_Bm_2_00230.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0204-rc-function-RC_Thread01-Cycle_Bm_2_00240/Cycle_Bm_2_00240.java b/test/testsuite/ouroboros/rc_test/RC0204-rc-function-RC_Thread01-Cycle_Bm_2_00240/Cycle_Bm_2_00240.java new file mode 100755 index 0000000000000000000000000000000000000000..e37e0eccddab727a105265a5463e8e62568972c1 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0204-rc-function-RC_Thread01-Cycle_Bm_2_00240/Cycle_Bm_2_00240.java @@ -0,0 +1,2755 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_2_00240.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Make Cycle_B_2_00240 together to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\nExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_2_00240.java + *- @ExecuteClass: Cycle_Bm_2_00240 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_2_00010B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00010_A1 a1_0 = new Cycle_B_2_00010_A1(); + a1_0.a2_0 = new Cycle_B_2_00010_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00010_A3(); + a1_0.a2_0.a4_0 = new Cycle_B_2_00010_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a4_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum); + //System.out.println(nsum); + + if (nsum == 18) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00010_A1 { + Cycle_B_2_00010_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00010_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00010_A2 { + Cycle_B_2_00010_A3 a3_0; + Cycle_B_2_00010_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00010_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00010_A3 { + Cycle_B_2_00010_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00010_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00010_A4 { + Cycle_B_2_00010_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00010_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_2_00020B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00020_A1 a1_0 = new Cycle_B_2_00020_A1(); + a1_0.a2_0 = new Cycle_B_2_00020_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00020_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00020_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum); + //System.out.println(nsum); + + if (nsum == 19) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00020_A1 { + Cycle_B_2_00020_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00020_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00020_A2 { + Cycle_B_2_00020_A3 a3_0; + Cycle_B_2_00020_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00020_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00020_A3 { + Cycle_B_2_00020_A1 a1_0; + Cycle_B_2_00020_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00020_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00020_A4 { + Cycle_B_2_00020_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00020_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_2_00030B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00030_A1 a1_0 = new Cycle_B_2_00030_A1(); + a1_0.a2_0 = new Cycle_B_2_00030_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00030_A3(); + Cycle_B_2_00030_A4 a4_0 = new Cycle_B_2_00030_A4(); + a4_0.a1_0 = a1_0; + a1_0.a4_0 = a4_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + + if (nsum == 16) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00030_A1 { + Cycle_B_2_00030_A2 a2_0; + Cycle_B_2_00030_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00030_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00030_A2 { + Cycle_B_2_00030_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00030_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00030_A3 { + Cycle_B_2_00030_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00030_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00030_A4 { + Cycle_B_2_00030_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00030_A4() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_2_00040B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00040_A1 a1_0 = new Cycle_B_2_00040_A1(); + a1_0.a2_0 = new Cycle_B_2_00040_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00040_A3(); + Cycle_B_2_00040_A4 a4_0 = new Cycle_B_2_00040_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a4_0 = a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + + if (nsum == 19) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00040_A1 { + Cycle_B_2_00040_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00040_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00040_A2 { + Cycle_B_2_00040_A3 a3_0; + Cycle_B_2_00040_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00040_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00040_A3 { + Cycle_B_2_00040_A1 a1_0; + Cycle_B_2_00040_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00040_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00040_A4 { + Cycle_B_2_00040_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00040_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_2_00050B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00050_A1 a1_0 = new Cycle_B_2_00050_A1(); + a1_0.a2_0 = new Cycle_B_2_00050_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00050_A3(); + Cycle_B_2_00050_A4 a4_0 = new Cycle_B_2_00050_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a4_0.a3_0.a5_0 = new Cycle_B_2_00050_A5(); + a1_0.a2_0.a3_0.a5_0 = a4_0.a3_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a4_0.a3_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a4_0.a3_0.a5_0.sum); + //System.out.println(nsum); + + if (nsum == 28) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00050_A1 { + Cycle_B_2_00050_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00050_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00050_A2 { + Cycle_B_2_00050_A3 a3_0; + Cycle_B_2_00050_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00050_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00050_A3 { + Cycle_B_2_00050_A1 a1_0; + Cycle_B_2_00050_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00050_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00050_A4 { + Cycle_B_2_00050_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00050_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00050_A5 { + Cycle_B_2_00050_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00050_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_2_00060B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00060_A1 a1_0 = new Cycle_B_2_00060_A1(); + a1_0.a2_0 = new Cycle_B_2_00060_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00060_A3(); + Cycle_B_2_00060_A4 a4_0 = new Cycle_B_2_00060_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a4_0.a3_0.a5_0 = new Cycle_B_2_00060_A5(); + a1_0.a2_0.a3_0.a5_0 = a4_0.a3_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.a5_0 = a4_0.a3_0.a5_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a4_0.a3_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a4_0.a3_0.a5_0.sum); + //System.out.println(nsum); + + if (nsum == 28) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00060_A1 { + Cycle_B_2_00060_A2 a2_0; + Cycle_B_2_00060_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00060_A1() { + a2_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00060_A2 { + Cycle_B_2_00060_A3 a3_0; + Cycle_B_2_00060_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00060_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00060_A3 { + Cycle_B_2_00060_A1 a1_0; + Cycle_B_2_00060_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00060_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00060_A4 { + Cycle_B_2_00060_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00060_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00060_A5 { + Cycle_B_2_00060_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00060_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_2_00070B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00070_A1 a1_0 = new Cycle_B_2_00070_A1(); + a1_0.a2_0 = new Cycle_B_2_00070_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00070_A3(); + Cycle_B_2_00070_A4 a4_0 = new Cycle_B_2_00070_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a4_0.a3_0.a5_0 = new Cycle_B_2_00070_A5(); + Cycle_B_2_00070_A6 a6_0 = new Cycle_B_2_00070_A6(); + a6_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a5_0 = a4_0.a3_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a6_0.add(); + a4_0.a3_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a4_0.a3_0.a5_0.sum + a6_0.sum); + //System.out.println(nsum); + + if (nsum == 37) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00070_A1 { + Cycle_B_2_00070_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00070_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00070_A2 { + Cycle_B_2_00070_A3 a3_0; + Cycle_B_2_00070_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00070_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00070_A3 { + Cycle_B_2_00070_A1 a1_0; + Cycle_B_2_00070_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00070_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00070_A4 { + Cycle_B_2_00070_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00070_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00070_A5 { + Cycle_B_2_00070_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00070_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_B_2_00070_A6 { + Cycle_B_2_00070_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00070_A6() { + a3_0 = null; + a = 6; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_2_00080B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00080_A1 a1_0 = new Cycle_B_2_00080_A1(); + a1_0.a2_0 = new Cycle_B_2_00080_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00080_A3(); + Cycle_B_2_00080_A4 a4_0 = new Cycle_B_2_00080_A4(); + a4_0.a2_0 = a1_0.a2_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a4_0.a3_0.a5_0 = new Cycle_B_2_00080_A5(); + a1_0.a2_0.a3_0.a5_0 = a4_0.a3_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.a5_0 = a4_0.a3_0.a5_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a4_0.a3_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a4_0.a3_0.a5_0.sum); + //System.out.println(nsum); + + if (nsum == 28) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00080_A1 { + Cycle_B_2_00080_A2 a2_0; + Cycle_B_2_00080_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00080_A1() { + a2_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00080_A2 { + Cycle_B_2_00080_A3 a3_0; + Cycle_B_2_00080_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00080_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00080_A3 { + Cycle_B_2_00080_A1 a1_0; + Cycle_B_2_00080_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00080_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00080_A4 { + Cycle_B_2_00080_A3 a3_0; + Cycle_B_2_00080_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00080_A4() { + a3_0 = null; + a2_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00080_A5 { + Cycle_B_2_00080_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00080_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_2_00090B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00090_A1 a1_0 = new Cycle_B_2_00090_A1(); + Cycle_B_2_00090_A3 a3_0 = new Cycle_B_2_00090_A3(); + a1_0.a2_0 = new Cycle_B_2_00090_A2(); + a1_0.a2_0.a1_0 = a1_0; + a3_0.a2_0 = a1_0.a2_0; + a3_0.a2_0.a3_0 = a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a3_0.sum); + //System.out.println(nsum); + + if (nsum == 9) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00090_A1 { + Cycle_B_2_00090_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00090_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00090_A2 { + Cycle_B_2_00090_A1 a1_0; + Cycle_B_2_00090_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00090_A2() { + a1_0 = null; + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00090_A3 { + Cycle_B_2_00090_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00090_A3() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_2_00100B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00100_A1 a1_0 = new Cycle_B_2_00100_A1(); + a1_0.a2_0 = new Cycle_B_2_00100_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00100_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00100_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00100_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum); + //System.out.println(nsum); + + if (nsum == 29) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00100_A1 { + Cycle_B_2_00100_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00100_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00100_A2 { + Cycle_B_2_00100_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00100_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00100_A3 { + Cycle_B_2_00100_A1 a1_0; + Cycle_B_2_00100_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00100_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00100_A4 { + Cycle_B_2_00100_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00100_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_B_2_00100_A5 { + Cycle_B_2_00100_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00100_A5() { + a3_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_2_00110B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00110_A1 a1_0 = new Cycle_B_2_00110_A1(); + a1_0.a2_0 = new Cycle_B_2_00110_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00110_A3(); + a1_0.a2_0.a4_0 = new Cycle_B_2_00110_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a4_0.a5_0 = new Cycle_B_2_00110_A5(); + a1_0.a2_0.a4_0.a5_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + a1_0.a2_0.a4_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum + a1_0.a2_0.a4_0.a5_0.sum); + //System.out.println(nsum); + + if (nsum == 28) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00110_A1 { + Cycle_B_2_00110_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00110_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00110_A2 { + Cycle_B_2_00110_A3 a3_0; + Cycle_B_2_00110_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00110_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00110_A3 { + Cycle_B_2_00110_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00110_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00110_A4 { + Cycle_B_2_00110_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00110_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_B_2_00110_A5 { + Cycle_B_2_00110_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00110_A5() { + a2_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_2_00120B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00120_A1 a1_0 = new Cycle_B_2_00120_A1(); + a1_0.a2_0 = new Cycle_B_2_00120_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00120_A3(); + a1_0.a4_0 = new Cycle_B_2_00120_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a4_0.a5_0 = new Cycle_B_2_00120_A5(); + a1_0.a4_0.a5_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a4_0.add(); + a1_0.a4_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a4_0.sum + a1_0.a4_0.a5_0.sum); + //System.out.println(nsum); + + if (nsum == 27) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00120_A1 { + Cycle_B_2_00120_A2 a2_0; + Cycle_B_2_00120_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00120_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00120_A2 { + Cycle_B_2_00120_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00120_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00120_A3 { + Cycle_B_2_00120_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00120_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00120_A4 { + Cycle_B_2_00120_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00120_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_B_2_00120_A5 { + Cycle_B_2_00120_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00120_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_2_00130B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00130_A1 a1_0 = new Cycle_B_2_00130_A1(); + a1_0.a2_0 = new Cycle_B_2_00130_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00130_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00130_A4(); + a1_0.a2_0.a3_0.a4_0.a1_0 = a1_0; + Cycle_B_2_00130_A5 a5_0 = new Cycle_B_2_00130_A5(); + a1_0.a2_0.a3_0.a4_0.a6_0 = new Cycle_B_2_00130_A6(); + a1_0.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_0; + a5_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a6_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a5_0.sum + a1_0.a2_0.a3_0.a4_0.a6_0.sum); + //System.out.println(nsum); + + if (nsum == 45) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00130_A1 { + Cycle_B_2_00130_A2 a2_0; + Cycle_B_2_00130_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00130_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00130_A2 { + Cycle_B_2_00130_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00130_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00130_A3 { + Cycle_B_2_00130_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00130_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_B_2_00130_A4 { + Cycle_B_2_00130_A1 a1_0; + Cycle_B_2_00130_A6 a6_0; + int a; + int sum; + + Cycle_B_2_00130_A4() { + a1_0 = null; + a6_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a + a6_0.a; + } + } + + class Cycle_B_2_00130_A5 { + Cycle_B_2_00130_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00130_A5() { + a3_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00130_A6 { + Cycle_B_2_00130_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00130_A6() { + a5_0 = null; + a = 6; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_2_00140B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00140_A1 a1_0 = new Cycle_B_2_00140_A1(); + a1_0.a2_0 = new Cycle_B_2_00140_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00140_A3(); + a1_0.a2_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + + if (nsum == 13) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00140_A1 { + Cycle_B_2_00140_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00140_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00140_A2 { + Cycle_B_2_00140_A3 a3_0; + Cycle_B_2_00140_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00140_A2() { + a3_0 = null; + a1_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a + a1_0.a; + } + } + + class Cycle_B_2_00140_A3 { + Cycle_B_2_00140_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00140_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_2_00150B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00150_A1 a1_0 = new Cycle_B_2_00150_A1(); + a1_0.a2_0 = new Cycle_B_2_00150_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00150_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + + if (nsum == 14) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00150_A1 { + Cycle_B_2_00150_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00150_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00150_A2 { + Cycle_B_2_00150_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00150_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00150_A3 { + Cycle_B_2_00150_A1 a1_0; + Cycle_B_2_00150_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00150_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a + a2_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_2_00160B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00160_A1 a1_0 = new Cycle_B_2_00160_A1(); + a1_0.a2_0 = new Cycle_B_2_00160_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00160_A3(); + a1_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + + if (nsum == 15) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00160_A1 { + Cycle_B_2_00160_A2 a2_0; + Cycle_B_2_00160_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00160_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } + } + + class Cycle_B_2_00160_A2 { + Cycle_B_2_00160_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00160_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00160_A3 { + Cycle_B_2_00160_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00160_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + + +class ThreadRc_Cycle_Bm_2_00170B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00170_A1 a1_0 = new Cycle_B_2_00170_A1(); + a1_0.a2_0 = new Cycle_B_2_00170_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00170_A3(); + a1_0.a2_0.a4_0 = new Cycle_B_2_00170_A4(); + a1_0.a2_0.a4_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum); + //System.out.println(nsum); + + if (nsum == 21) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00170_A1 { + Cycle_B_2_00170_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00170_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00170_A2 { + Cycle_B_2_00170_A3 a3_0; + Cycle_B_2_00170_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00170_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + + class Cycle_B_2_00170_A3 { + Cycle_B_2_00170_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00170_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00170_A4 { + Cycle_B_2_00170_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00170_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_2_00180B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00180_A1 a1_0 = new Cycle_B_2_00180_A1(); + a1_0.a2_0 = new Cycle_B_2_00180_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00180_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00180_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum); + //System.out.println(nsum); + + if (nsum == 15) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00180_A1 { + Cycle_B_2_00180_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00180_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00180_A2 { + Cycle_B_2_00180_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00180_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00180_A3 { + Cycle_B_2_00180_A1 a1_0; + Cycle_B_2_00180_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00180_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a + a4_0.a; + } + } + + class Cycle_B_2_00180_A4 { + Cycle_B_2_00180_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00180_A4() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_2_00190B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00190_A1 a1_0 = new Cycle_B_2_00190_A1(); + a1_0.a2_0 = new Cycle_B_2_00190_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00190_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00190_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum); + //System.out.println(nsum); + + if (nsum == 15) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00190_A1 { + Cycle_B_2_00190_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00190_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00190_A2 { + Cycle_B_2_00190_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00190_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00190_A3 { + Cycle_B_2_00190_A1 a1_0; + Cycle_B_2_00190_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00190_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_B_2_00190_A4 { + Cycle_B_2_00190_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00190_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } +} + + +class ThreadRc_Cycle_Bm_2_00200B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00200_A1 a1_0 = new Cycle_B_2_00200_A1(); + a1_0.a2_0 = new Cycle_B_2_00200_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00200_A3(); + Cycle_B_2_00200_A4 a4_0 = new Cycle_B_2_00200_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0 = a4_0; + a4_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + + if (nsum == 16) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00200_A1 { + Cycle_B_2_00200_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00200_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00200_A2 { + Cycle_B_2_00200_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00200_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00200_A3 { + Cycle_B_2_00200_A1 a1_0; + Cycle_B_2_00200_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00200_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a4_0.a + a1_0.a; + } + } + + class Cycle_B_2_00200_A4 { + Cycle_B_2_00200_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00200_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } +} + + +class ThreadRc_Cycle_Bm_2_00210B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00210_A1 a1_0 = new Cycle_B_2_00210_A1(); + a1_0.a2_0 = new Cycle_B_2_00210_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00210_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00210_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00210_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_B_2_00210_A6(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0 = new Cycle_B_2_00210_A8(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0 = new Cycle_B_2_00210_A9(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.a7_0 = new Cycle_B_2_00210_A7(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.a7_0.a4_0 = a1_0.a2_0.a3_0.a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.a7_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.a7_0.sum); + //System.out.println(nsum); + + if (nsum == 94) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00210_A1 { + Cycle_B_2_00210_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00210_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00210_A2 { + Cycle_B_2_00210_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00210_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00210_A3 { + Cycle_B_2_00210_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00210_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_B_2_00210_A4 { + Cycle_B_2_00210_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00210_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_B_2_00210_A5 { + Cycle_B_2_00210_A6 a6_0; + int a; + int sum; + + Cycle_B_2_00210_A5() { + a6_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_B_2_00210_A6 { + Cycle_B_2_00210_A1 a1_0; + Cycle_B_2_00210_A8 a8_0; + int a; + int sum; + + Cycle_B_2_00210_A6() { + a1_0 = null; + a8_0 = null; + a = 6; + sum = 0; + } + + void add() { + sum = a + a1_0.a + a8_0.a; + } + } + + class Cycle_B_2_00210_A8 { + Cycle_B_2_00210_A9 a9_0; + int a; + int sum; + + Cycle_B_2_00210_A8() { + a9_0 = null; + a = 7; + sum = 0; + } + + void add() { + sum = a + a9_0.a; + } + } + + class Cycle_B_2_00210_A9 { + Cycle_B_2_00210_A7 a7_0; + int a; + int sum; + + Cycle_B_2_00210_A9() { + a7_0 = null; + a = 8; + sum = 0; + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_B_2_00210_A7 { + Cycle_B_2_00210_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00210_A7() { + a4_0 = null; + a = 9; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_2_00220B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00220_A1 a1_0 = new Cycle_B_2_00220_A1(); + a1_0.a2_0 = new Cycle_B_2_00220_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00220_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00220_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00220_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_B_2_00220_A6(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_0; + a1_0.a8_0 = new Cycle_B_2_00220_A8(); + a1_0.a8_0.a9_0 = new Cycle_B_2_00220_A9(); + a1_0.a8_0.a9_0.a7_0 = new Cycle_B_2_00220_A7(); + a1_0.a8_0.a9_0.a7_0.a4_0 = a1_0.a2_0.a3_0.a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a1_0.a8_0.add(); + a1_0.a8_0.a9_0.add(); + a1_0.a8_0.a9_0.a7_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a1_0.a8_0.sum + a1_0.a8_0.a9_0.sum + a1_0.a8_0.a9_0.a7_0.sum); + //System.out.println(nsum); + + if (nsum == 94) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00220_A1 { + Cycle_B_2_00220_A2 a2_0; + Cycle_B_2_00220_A8 a8_0; + int a; + int sum; + + Cycle_B_2_00220_A1() { + a2_0 = null; + a8_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a + a8_0.a; + } + } + + class Cycle_B_2_00220_A2 { + Cycle_B_2_00220_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00220_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00220_A3 { + Cycle_B_2_00220_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00220_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_B_2_00220_A4 { + Cycle_B_2_00220_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00220_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_B_2_00220_A5 { + Cycle_B_2_00220_A6 a6_0; + int a; + int sum; + + Cycle_B_2_00220_A5() { + a6_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_B_2_00220_A6 { + Cycle_B_2_00220_A1 a1_0; + int a; + int sum; + + Cycle_B_2_00220_A6() { + a1_0 = null; + a = 6; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00220_A8 { + Cycle_B_2_00220_A9 a9_0; + int a; + int sum; + + Cycle_B_2_00220_A8() { + a9_0 = null; + a = 7; + sum = 0; + } + + void add() { + sum = a + a9_0.a; + } + } + + class Cycle_B_2_00220_A9 { + Cycle_B_2_00220_A7 a7_0; + int a; + int sum; + + Cycle_B_2_00220_A9() { + a7_0 = null; + a = 8; + sum = 0; + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_B_2_00220_A7 { + Cycle_B_2_00220_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00220_A7() { + a4_0 = null; + a = 9; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } +} + +class ThreadRc_Cycle_Bm_2_00230B extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00230_A1 a1_0 = new Cycle_B_2_00230_A1(); + a1_0.a2_0 = new Cycle_B_2_00230_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00230_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00230_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00230_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_B_2_00230_A6(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_0; + + Cycle_B_2_00230_A10 a10_0 = new Cycle_B_2_00230_A10(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a10_0 = a10_0; + a10_0.a8_0 = new Cycle_B_2_00230_A8(); + a10_0.a8_0.a9_0 = new Cycle_B_2_00230_A9(); + a10_0.a8_0.a9_0.a7_0 = new Cycle_B_2_00230_A7(); + a10_0.a8_0.a9_0.a7_0.a4_0 = a1_0.a2_0.a3_0.a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a10_0.a8_0.add(); + a10_0.a8_0.a9_0.add(); + a10_0.a8_0.a9_0.a7_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a10_0.a8_0.sum + a10_0.a8_0.a9_0.sum + a10_0.a8_0.a9_0.a7_0.sum); + + //System.out.println(nsum); + + if (nsum == 97) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00230_A1 { + Cycle_B_2_00230_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00230_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00230_A2 { + Cycle_B_2_00230_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00230_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00230_A3 { + Cycle_B_2_00230_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00230_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_B_2_00230_A4 { + Cycle_B_2_00230_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00230_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_B_2_00230_A5 { + Cycle_B_2_00230_A6 a6_0; + int a; + int sum; + + Cycle_B_2_00230_A5() { + a6_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_B_2_00230_A6 { + Cycle_B_2_00230_A1 a1_0; + Cycle_B_2_00230_A10 a10_0; + int a; + int sum; + + Cycle_B_2_00230_A6() { + a1_0 = null; + a10_0 = null; + a = 6; + sum = 0; + } + + void add() { + sum = a + a1_0.a + a10_0.a; + } + } + + class Cycle_B_2_00230_A8 { + Cycle_B_2_00230_A9 a9_0; + int a; + int sum; + + Cycle_B_2_00230_A8() { + a9_0 = null; + a = 7; + sum = 0; + } + + void add() { + sum = a + a9_0.a; + } + } + + class Cycle_B_2_00230_A9 { + Cycle_B_2_00230_A7 a7_0; + int a; + int sum; + + Cycle_B_2_00230_A9() { + a7_0 = null; + a = 8; + sum = 0; + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_B_2_00230_A7 { + Cycle_B_2_00230_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00230_A7() { + a4_0 = null; + a = 9; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_B_2_00230_A10 { + Cycle_B_2_00230_A8 a8_0; + int a; + int sum; + + Cycle_B_2_00230_A10() { + a8_0 = null; + a = 10; + sum = 0; + } + + void add() { + sum = a + a8_0.a; + } + } +} + +public class Cycle_Bm_2_00240 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00010B A1_00010 = new ThreadRc_Cycle_Bm_2_00010B(); + ThreadRc_Cycle_Bm_2_00010B A2_00010 = new ThreadRc_Cycle_Bm_2_00010B(); + ThreadRc_Cycle_Bm_2_00020B A1_00020 = new ThreadRc_Cycle_Bm_2_00020B(); + ThreadRc_Cycle_Bm_2_00020B A2_00020 = new ThreadRc_Cycle_Bm_2_00020B(); + ThreadRc_Cycle_Bm_2_00030B A1_00030 = new ThreadRc_Cycle_Bm_2_00030B(); + ThreadRc_Cycle_Bm_2_00030B A2_00030 = new ThreadRc_Cycle_Bm_2_00030B(); + ThreadRc_Cycle_Bm_2_00040B A1_00040 = new ThreadRc_Cycle_Bm_2_00040B(); + ThreadRc_Cycle_Bm_2_00040B A2_00040 = new ThreadRc_Cycle_Bm_2_00040B(); + ThreadRc_Cycle_Bm_2_00050B A1_00050 = new ThreadRc_Cycle_Bm_2_00050B(); + ThreadRc_Cycle_Bm_2_00050B A2_00050 = new ThreadRc_Cycle_Bm_2_00050B(); + ThreadRc_Cycle_Bm_2_00060B A1_00060 = new ThreadRc_Cycle_Bm_2_00060B(); + ThreadRc_Cycle_Bm_2_00060B A2_00060 = new ThreadRc_Cycle_Bm_2_00060B(); + ThreadRc_Cycle_Bm_2_00070B A1_00070 = new ThreadRc_Cycle_Bm_2_00070B(); + ThreadRc_Cycle_Bm_2_00070B A2_00070 = new ThreadRc_Cycle_Bm_2_00070B(); + ThreadRc_Cycle_Bm_2_00080B A1_00080 = new ThreadRc_Cycle_Bm_2_00080B(); + ThreadRc_Cycle_Bm_2_00080B A2_00080 = new ThreadRc_Cycle_Bm_2_00080B(); + ThreadRc_Cycle_Bm_2_00090B A1_00090 = new ThreadRc_Cycle_Bm_2_00090B(); + ThreadRc_Cycle_Bm_2_00090B A2_00090 = new ThreadRc_Cycle_Bm_2_00090B(); + ThreadRc_Cycle_Bm_2_00100B A1_00100 = new ThreadRc_Cycle_Bm_2_00100B(); + ThreadRc_Cycle_Bm_2_00100B A2_00100 = new ThreadRc_Cycle_Bm_2_00100B(); + ThreadRc_Cycle_Bm_2_00110B A1_00110 = new ThreadRc_Cycle_Bm_2_00110B(); + ThreadRc_Cycle_Bm_2_00110B A2_00110 = new ThreadRc_Cycle_Bm_2_00110B(); + ThreadRc_Cycle_Bm_2_00120B A1_00120 = new ThreadRc_Cycle_Bm_2_00120B(); + ThreadRc_Cycle_Bm_2_00120B A2_00120 = new ThreadRc_Cycle_Bm_2_00120B(); + ThreadRc_Cycle_Bm_2_00130B A1_00130 = new ThreadRc_Cycle_Bm_2_00130B(); + ThreadRc_Cycle_Bm_2_00130B A2_00130 = new ThreadRc_Cycle_Bm_2_00130B(); + ThreadRc_Cycle_Bm_2_00140B A1_00140 = new ThreadRc_Cycle_Bm_2_00140B(); + ThreadRc_Cycle_Bm_2_00140B A2_00140 = new ThreadRc_Cycle_Bm_2_00140B(); + ThreadRc_Cycle_Bm_2_00150B A1_00150 = new ThreadRc_Cycle_Bm_2_00150B(); + ThreadRc_Cycle_Bm_2_00150B A2_00150 = new ThreadRc_Cycle_Bm_2_00150B(); + ThreadRc_Cycle_Bm_2_00160B A1_00160 = new ThreadRc_Cycle_Bm_2_00160B(); + ThreadRc_Cycle_Bm_2_00160B A2_00160 = new ThreadRc_Cycle_Bm_2_00160B(); + ThreadRc_Cycle_Bm_2_00170B A1_00170 = new ThreadRc_Cycle_Bm_2_00170B(); + ThreadRc_Cycle_Bm_2_00170B A2_00170 = new ThreadRc_Cycle_Bm_2_00170B(); + ThreadRc_Cycle_Bm_2_00180B A1_00180 = new ThreadRc_Cycle_Bm_2_00180B(); + ThreadRc_Cycle_Bm_2_00180B A2_00180 = new ThreadRc_Cycle_Bm_2_00180B(); + ThreadRc_Cycle_Bm_2_00190B A1_00190 = new ThreadRc_Cycle_Bm_2_00190B(); + ThreadRc_Cycle_Bm_2_00190B A2_00190 = new ThreadRc_Cycle_Bm_2_00190B(); + ThreadRc_Cycle_Bm_2_00200B A1_00200 = new ThreadRc_Cycle_Bm_2_00200B(); + ThreadRc_Cycle_Bm_2_00200B A2_00200 = new ThreadRc_Cycle_Bm_2_00200B(); + ThreadRc_Cycle_Bm_2_00210B A1_00210 = new ThreadRc_Cycle_Bm_2_00210B(); + ThreadRc_Cycle_Bm_2_00210B A2_00210 = new ThreadRc_Cycle_Bm_2_00210B(); + ThreadRc_Cycle_Bm_2_00220B A1_00220 = new ThreadRc_Cycle_Bm_2_00220B(); + ThreadRc_Cycle_Bm_2_00220B A2_00220 = new ThreadRc_Cycle_Bm_2_00220B(); + ThreadRc_Cycle_Bm_2_00230B A1_00230 = new ThreadRc_Cycle_Bm_2_00230B(); + ThreadRc_Cycle_Bm_2_00230B A2_00230 = new ThreadRc_Cycle_Bm_2_00230B(); + A1_00010.start(); + A2_00010.start(); + A1_00020.start(); + A2_00020.start(); + A1_00030.start(); + A2_00030.start(); + A1_00040.start(); + A2_00040.start(); + A1_00050.start(); + A2_00050.start(); + A1_00060.start(); + A2_00060.start(); + A1_00070.start(); + A2_00070.start(); + A1_00080.start(); + A2_00080.start(); + A1_00090.start(); + A2_00090.start(); + A1_00100.start(); + A2_00100.start(); + A1_00110.start(); + A2_00110.start(); + A1_00120.start(); + A2_00120.start(); + A1_00130.start(); + A2_00130.start(); + A1_00140.start(); + A2_00140.start(); + A1_00150.start(); + A2_00150.start(); + A1_00160.start(); + A2_00160.start(); + A1_00170.start(); + A2_00170.start(); + A1_00180.start(); + A2_00180.start(); + A1_00190.start(); + A2_00190.start(); + A1_00200.start(); + A2_00200.start(); + A1_00210.start(); + A2_00210.start(); + A1_00220.start(); + A2_00220.start(); + A1_00230.start(); + A2_00230.start(); + try { + A1_00010.join(); + A2_00010.join(); + A1_00020.join(); + A2_00020.join(); + A1_00030.join(); + A2_00030.join(); + A1_00040.join(); + A2_00040.join(); + A1_00050.join(); + A2_00050.join(); + A1_00060.join(); + A2_00060.join(); + A1_00070.join(); + A2_00070.join(); + A1_00080.join(); + A2_00080.join(); + A1_00090.join(); + A2_00090.join(); + A1_00100.join(); + A2_00100.join(); + A1_00110.join(); + A2_00110.join(); + A1_00120.join(); + A2_00120.join(); + A1_00130.join(); + A2_00130.join(); + A1_00140.join(); + A2_00140.join(); + A1_00150.join(); + A2_00150.join(); + A1_00160.join(); + A2_00160.join(); + A1_00170.join(); + A2_00170.join(); + A1_00180.join(); + A2_00180.join(); + A1_00190.join(); + A2_00190.join(); + A1_00200.join(); + A2_00200.join(); + A1_00210.join(); + A2_00210.join(); + A1_00220.join(); + A2_00220.join(); + A1_00230.join(); + A2_00230.join(); + + } catch (InterruptedException e) { + } + if (A1_00010.check() && A2_00010.check() && A1_00020.check() && A2_00020.check() && A1_00030.check() && A2_00030.check() && A1_00040.check() && A2_00040.check() && A1_00050.check() && A2_00050.check() && A1_00060.check() && A2_00060.check() && A1_00070.check() && A2_00070.check() && A1_00080.check() && A2_00080.check() && A1_00090.check() && A2_00090.check() && A1_00100.check() && A2_00100.check() && A1_00110.check() && A2_00110.check() && A1_00120.check() && A2_00120.check() && A1_00130.check() && A2_00130.check() && A1_00140.check() && A2_00140.check() && A1_00150.check() && A2_00150.check() && A1_00160.check() && A2_00160.check() && A1_00170.check() && A2_00170.check() && A1_00180.check() && A2_00180.check() && A1_00190.check() && A2_00190.check() && A1_00200.check() && A2_00200.check() && A1_00210.check() && A2_00210.check() && A1_00220.check() && A2_00220.check() && A1_00230.check() && A2_00230.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\nExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0205-rc-function-RC_Thread01-Cycle_Bm_2_10240/Cycle_Bm_2_10240.java b/test/testsuite/ouroboros/rc_test/RC0205-rc-function-RC_Thread01-Cycle_Bm_2_10240/Cycle_Bm_2_10240.java new file mode 100755 index 0000000000000000000000000000000000000000..a547d7842f1003149938fd941dccfb94c637c62d --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0205-rc-function-RC_Thread01-Cycle_Bm_2_10240/Cycle_Bm_2_10240.java @@ -0,0 +1,276 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Cycle_Bm_2_10240.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Make Cycle_B_2_10240 together to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\nExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Cycle_Bm_2_10240.java + *- @ExecuteClass: Cycle_Bm_2_10240 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Cycle_Bm_2_10240 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00240_A1 a1_main = new Cycle_B_2_00240_A1("a1_main"); + a1_main.a2_0 = new Cycle_B_2_00240_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_B_2_00240_A3("a3_0"); + a1_main.a2_0.a4_0 = new Cycle_B_2_00240_A4("a4_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a4_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a4_0.a1_0 = a1_main; + + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a4_0.add(); + + + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + + Cycle_B_2_00240_B1 b1_0 = new Cycle_B_2_00240_B1(); + b1_0.a3_0 = new Cycle_B_2_00240_A3("a3_b1"); + b1_0.b2_0 = new Cycle_B_2_00240_B2(); + b1_0.c2_0 = new Nocycle_B_2_00240_C2("c2_b1"); + b1_0.b2_0.b1_0 = b1_0; + b1_0.add(); + b1_0.b2_0.add(); + + int nsum = (b1_0.sum + b1_0.b2_0.sum); + // System.out.println(nsum); + + + Nocycle_B_2_00240_C1 c1_main = new Nocycle_B_2_00240_C1("c1_main"); + c1_main.c2_0 = new Nocycle_B_2_00240_C2("c2_0"); + c1_main.add(); + c1_main.c2_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",c1_main.sum+c1_main.b1_0.sum); + int result2 = c1_main.sum + c1_main.c2_0.sum; + //System.out.println("RC-Testing_Result="+result2); + + if (result == 1124 && nsum == 310 && result2 == 704) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00240_A1 { + Cycle_B_2_00240_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_B_2_00240_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00240_A2 { + Cycle_B_2_00240_A1 a1_0; + Cycle_B_2_00240_A3 a3_0; + Cycle_B_2_00240_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_B_2_00240_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } + } + + class Cycle_B_2_00240_A3 { + Cycle_B_2_00240_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_B_2_00240_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00240_A4 { + Cycle_B_2_00240_A1 a1_0; + Cycle_B_2_00240_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_B_2_00240_A4(String strObjectName) { + a2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a2_0.a; + } + } + + class Cycle_B_2_00240_B1 { + Cycle_B_2_00240_A3 a3_0; + Cycle_B_2_00240_B2 b2_0; + Nocycle_B_2_00240_C2 c2_0; + + + int a; + int sum; + + Cycle_B_2_00240_B1() { + a3_0 = null; + b2_0 = null; + c2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a3_0.a + b2_0.a + c2_0.a; + } + } + + class Cycle_B_2_00240_B2 { + Cycle_B_2_00240_B1 b1_0; + int a; + int sum; + + Cycle_B_2_00240_B2() { + b1_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_B_2_00240_C1 { + Nocycle_B_2_00240_C2 c2_0; + int a; + int sum; + String strObjectName; + + Nocycle_B_2_00240_C1(String strObjectName) { + c2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + // protected void finalize() throws java.lang.Throwable { +// System.out.println("RC-Testing_Destruction_A1_"+strObjectName); +// } + void add() { + sum = a + c2_0.a; + } + } + + class Nocycle_B_2_00240_C2 { + int a; + int sum; + String strObjectName; + + Nocycle_B_2_00240_C2(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + // protected void finalize() throws java.lang.Throwable { +// System.out.println("RC-Testing_Destruction_B1_"+strObjectName); +// } + void add() { + sum = a + a; + } + } +} + + +public class Cycle_Bm_2_10240 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_10240 A1_Cycle_Bm_2_10240 = new ThreadRc_Cycle_Bm_2_10240(); + ThreadRc_Cycle_Bm_2_10240 A2_Cycle_Bm_2_10240 = new ThreadRc_Cycle_Bm_2_10240(); + ThreadRc_Cycle_Bm_2_10240 A3_Cycle_Bm_2_10240 = new ThreadRc_Cycle_Bm_2_10240(); + ThreadRc_Cycle_Bm_2_10240 A4_Cycle_Bm_2_10240 = new ThreadRc_Cycle_Bm_2_10240(); + ThreadRc_Cycle_Bm_2_10240 A5_Cycle_Bm_2_10240 = new ThreadRc_Cycle_Bm_2_10240(); + ThreadRc_Cycle_Bm_2_10240 A6_Cycle_Bm_2_10240 = new ThreadRc_Cycle_Bm_2_10240(); + + A1_Cycle_Bm_2_10240.start(); + A2_Cycle_Bm_2_10240.start(); + A3_Cycle_Bm_2_10240.start(); + A4_Cycle_Bm_2_10240.start(); + A5_Cycle_Bm_2_10240.start(); + A6_Cycle_Bm_2_10240.start(); + + try { + A1_Cycle_Bm_2_10240.join(); + A2_Cycle_Bm_2_10240.join(); + A3_Cycle_Bm_2_10240.join(); + A4_Cycle_Bm_2_10240.join(); + A5_Cycle_Bm_2_10240.join(); + A6_Cycle_Bm_2_10240.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_10240.check() && A2_Cycle_Bm_2_10240.check() && A3_Cycle_Bm_2_10240.check() && A4_Cycle_Bm_2_10240.check() && A5_Cycle_Bm_2_10240.check() && A6_Cycle_Bm_2_10240.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\nExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0206-rc-function-RC_Thread01-Nocycle_am_00010/Nocycle_am_00010.java b/test/testsuite/ouroboros/rc_test/RC0206-rc-function-RC_Thread01-Nocycle_am_00010/Nocycle_am_00010.java new file mode 100755 index 0000000000000000000000000000000000000000..57438f8b0ceade81081d91d2bff34e35161afcdc --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0206-rc-function-RC_Thread01-Nocycle_am_00010/Nocycle_am_00010.java @@ -0,0 +1,120 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Nocycle_am_00010.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Nocycle_a_00010 in RC测试-No-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_am_00010.java + *- @ExecuteClass: Nocycle_am_00010 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_00010 extends Thread { + private boolean checkout; + + public void run() { + Nocycle_am_00010_A1 a1_main = new Nocycle_am_00010_A1("a1_main"); + a1_main.b1_0 = new Nocycle_am_00010_B1("b1_0"); + a1_main.add(); + a1_main.b1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum; + // System.out.println("RC-Testing_Result_Thread="+result); + if (result == 704) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_am_00010_A1 { + Nocycle_am_00010_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_am_00010_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + // protected void finalize() throws java.lang.Throwable { +// System.out.println("RC-Testing_Destruction_A1_"+strObjectName); +// } + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_am_00010_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_am_00010_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + // protected void finalize() throws java.lang.Throwable { +// System.out.println("RC-Testing_Destruction_B1_"+strObjectName); +// } + void add() { + sum = a + a; + } + } +} + + +public class Nocycle_am_00010 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_00010 t_00010 = new ThreadRc_00010(); + t_00010.start(); + ThreadRc_00010 t_00020 = new ThreadRc_00010(); + t_00020.start(); + ThreadRc_00010 t_00030 = new ThreadRc_00010(); + t_00030.start(); + ThreadRc_00010 t_00040 = new ThreadRc_00010(); + t_00040.start(); + ThreadRc_00010 t_00050 = new ThreadRc_00010(); + t_00050.start(); + ThreadRc_00010 t_00060 = new ThreadRc_00010(); + t_00060.start(); + try { + t_00010.join(); + t_00020.join(); + t_00030.join(); + t_00040.join(); + t_00050.join(); + t_00060.join(); + } catch (InterruptedException e) { + } + + if (t_00010.check() == true && t_00060.check() == true && t_00020.check() == true && t_00030.check() == true && t_00040.check() == true && t_00050.check() == true) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0207-rc-function-RC_Thread01-Nocycle_am_00020/Nocycle_am_00020.java b/test/testsuite/ouroboros/rc_test/RC0207-rc-function-RC_Thread01-Nocycle_am_00020/Nocycle_am_00020.java new file mode 100755 index 0000000000000000000000000000000000000000..0fb86d3c391d1802995f66c38e01be2cd69bd58f --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0207-rc-function-RC_Thread01-Nocycle_am_00020/Nocycle_am_00020.java @@ -0,0 +1,137 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Nocycle_am_00020.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Nocycle_a_00020 in RC测试-No-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_am_00020.java + *- @ExecuteClass: Nocycle_am_00020 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_00020 extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00020_A1 a1_main = new Nocycle_a_00020_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00020_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00020_B2("b2_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + //System.out.println("RC-Testing_Result_Thread1="+result); + if (result == 1310) + checkout = true; + //System.out.println(checkout); + + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00020_A1 { + Nocycle_a_00020_B1 b1_0; + Nocycle_a_00020_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00020_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + + class Nocycle_a_00020_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00020_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00020_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00020_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + + +public class Nocycle_am_00020 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_00020 A1_00020 = new ThreadRc_00020(); + ThreadRc_00020 A2_00020 = new ThreadRc_00020(); + ThreadRc_00020 A3_00020 = new ThreadRc_00020(); + ThreadRc_00020 A4_00020 = new ThreadRc_00020(); + ThreadRc_00020 A5_00020 = new ThreadRc_00020(); + ThreadRc_00020 A6_00020 = new ThreadRc_00020(); + + A1_00020.start(); + A2_00020.start(); + A3_00020.start(); + A4_00020.start(); + A5_00020.start(); + A6_00020.start(); + try { + A1_00020.join(); + A2_00020.join(); + A3_00020.join(); + A4_00020.join(); + A5_00020.join(); + A6_00020.join(); + } catch (InterruptedException e) { + } + + if (A1_00020.check() && A2_00020.check() && A3_00020.check() && A4_00020.check() && A5_00020.check() && A6_00020.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0208-rc-function-RC_Thread01-Nocycle_am_00030/Nocycle_am_00030.java b/test/testsuite/ouroboros/rc_test/RC0208-rc-function-RC_Thread01-Nocycle_am_00030/Nocycle_am_00030.java new file mode 100755 index 0000000000000000000000000000000000000000..261e3f2d8cfe219760d60aeb689f4aa602637924 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0208-rc-function-RC_Thread01-Nocycle_am_00030/Nocycle_am_00030.java @@ -0,0 +1,156 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Nocycle_am_00030.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Nocycle_a_00030 in RC测试-No-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_am_00030.java + *- @ExecuteClass: Nocycle_am_00030 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_00030 extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00030_A1 a1_main = new Nocycle_a_00030_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00030_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00030_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00030_B3("b3_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum; + //System.out.println("RC-Testing_Result_Thread1="+result); + if (result == 1919) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00030_A1 { + Nocycle_a_00030_B1 b1_0; + Nocycle_a_00030_B2 b2_0; + Nocycle_a_00030_B3 b3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00030_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } + } + + class Nocycle_a_00030_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00030_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00030_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00030_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00030_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00030_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + + +public class Nocycle_am_00030 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_00030 A1_00030 = new ThreadRc_00030(); + ThreadRc_00030 A2_00030 = new ThreadRc_00030(); + ThreadRc_00030 A3_00030 = new ThreadRc_00030(); + ThreadRc_00030 A4_00030 = new ThreadRc_00030(); + ThreadRc_00030 A5_00030 = new ThreadRc_00030(); + ThreadRc_00030 A6_00030 = new ThreadRc_00030(); + + A1_00030.start(); + A2_00030.start(); + A3_00030.start(); + A4_00030.start(); + A5_00030.start(); + A6_00030.start(); + try { + A1_00030.join(); + A2_00030.join(); + A3_00030.join(); + A4_00030.join(); + A5_00030.join(); + A6_00030.join(); + } catch (InterruptedException e) { + } + if (A1_00030.check() && A2_00030.check() && A3_00030.check() && A4_00030.check() && A5_00030.check() && A6_00030.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0209-rc-function-RC_Thread01-Nocycle_am_00040/Nocycle_am_00040.java b/test/testsuite/ouroboros/rc_test/RC0209-rc-function-RC_Thread01-Nocycle_am_00040/Nocycle_am_00040.java new file mode 100755 index 0000000000000000000000000000000000000000..0a6a411c585fb007709de0db2d55fcce56679ab0 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0209-rc-function-RC_Thread01-Nocycle_am_00040/Nocycle_am_00040.java @@ -0,0 +1,302 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Nocycle_am_00040.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Nocycle_a_00040 in RC测试-No-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_am_00040.java + *- @ExecuteClass: Nocycle_am_00040 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_00040 extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00040_A1 a1_main = new Nocycle_a_00040_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00040_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00040_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00040_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00040_B4("b4_0"); + a1_main.b5_0 = new Nocycle_a_00040_B5("b5_0"); + a1_main.b6_0 = new Nocycle_a_00040_B6("b6_0"); + a1_main.b7_0 = new Nocycle_a_00040_B7("b7_0"); + a1_main.b8_0 = new Nocycle_a_00040_B8("b8_0"); + a1_main.b9_0 = new Nocycle_a_00040_B9("b9_0"); + a1_main.b10_0 = new Nocycle_a_00040_B10("b10_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b5_0.add(); + a1_main.b6_0.add(); + a1_main.b7_0.add(); + a1_main.b8_0.add(); + a1_main.b9_0.add(); + a1_main.b10_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b5_0.sum+a1_main.b6_0.sum+a1_main.b7_0.sum+a1_main.b8_0.sum+a1_main.b9_0.sum+a1_main.b10_0.sum); + + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b5_0.sum + a1_main.b6_0.sum + a1_main.b7_0.sum + a1_main.b8_0.sum + a1_main.b9_0.sum + a1_main.b10_0.sum; + //System.out.println("RC-Testing_Result_Thread1="+result); + if (result == 6266) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00040_A1 { + Nocycle_a_00040_B1 b1_0; + Nocycle_a_00040_B2 b2_0; + Nocycle_a_00040_B3 b3_0; + Nocycle_a_00040_B4 b4_0; + Nocycle_a_00040_B5 b5_0; + Nocycle_a_00040_B6 b6_0; + Nocycle_a_00040_B7 b7_0; + Nocycle_a_00040_B8 b8_0; + Nocycle_a_00040_B9 b9_0; + Nocycle_a_00040_B10 b10_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + b5_0 = null; + b6_0 = null; + b7_0 = null; + b8_0 = null; + b9_0 = null; + b10_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a + b5_0.a + b6_0.a + b7_0.a + b8_0.a + b9_0.a + b10_0.a; + } + } + + class Nocycle_a_00040_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00040_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00040_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00040_B4 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00040_B5 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B5(String strObjectName) { + a = 205; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B5_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00040_B6 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B6(String strObjectName) { + a = 206; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B6_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00040_B7 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B7(String strObjectName) { + a = 207; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B7_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00040_B8 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B8(String strObjectName) { + a = 208; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B8_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00040_B9 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B9(String strObjectName) { + a = 209; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B9_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00040_B10 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B10(String strObjectName) { + a = 210; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B10_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +public class Nocycle_am_00040 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_00040 A1_00040 = new ThreadRc_00040(); + ThreadRc_00040 A2_00040 = new ThreadRc_00040(); + ThreadRc_00040 A3_00040 = new ThreadRc_00040(); + ThreadRc_00040 A4_00040 = new ThreadRc_00040(); + ThreadRc_00040 A5_00040 = new ThreadRc_00040(); + ThreadRc_00040 A6_00040 = new ThreadRc_00040(); + + A1_00040.start(); + A2_00040.start(); + A3_00040.start(); + A4_00040.start(); + A5_00040.start(); + A6_00040.start(); + try { + A1_00040.join(); + A2_00040.join(); + A3_00040.join(); + A4_00040.join(); + A5_00040.join(); + A6_00040.join(); + } catch (InterruptedException e) { + } + if (A1_00040.check() && A2_00040.check() && A3_00040.check() && A4_00040.check() && A5_00040.check() && A6_00040.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0210-rc-function-RC_Thread01-Nocycle_am_00050/Nocycle_am_00050.java b/test/testsuite/ouroboros/rc_test/RC0210-rc-function-RC_Thread01-Nocycle_am_00050/Nocycle_am_00050.java new file mode 100755 index 0000000000000000000000000000000000000000..91a3db83b876dd5510c5f2566098dbf4f6c30a4a --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0210-rc-function-RC_Thread01-Nocycle_am_00050/Nocycle_am_00050.java @@ -0,0 +1,240 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Nocycle_am_00050.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Nocycle_a_00050 in RC测试-No-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_am_00050.java + *- @ExecuteClass: Nocycle_am_00050 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_00050 extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00050_A1 a1_main = new Nocycle_a_00050_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00050_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_a_00050_C1("c1_0"); + a1_main.b1_0.c2_0 = new Nocycle_a_00050_C2("c2_0"); + a1_main.b1_0.c3_0 = new Nocycle_a_00050_C3("c3_0"); + a1_main.b2_0 = new Nocycle_a_00050_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00050_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00050_B4("b4_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b1_0.c1_0.add(); + a1_main.b1_0.c2_0.add(); + a1_main.b1_0.c3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b1_0.c1_0.sum+a1_main.b1_0.c2_0.sum+a1_main.b1_0.c3_0.sum); + + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b1_0.c1_0.sum + a1_main.b1_0.c2_0.sum + a1_main.b1_0.c3_0.sum; + //System.out.println("RC-Testing_Result_Thread1="+result); + if (result == 5048) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00050_A1 { + Nocycle_a_00050_B1 b1_0; + Nocycle_a_00050_B2 b2_0; + Nocycle_a_00050_B3 b3_0; + Nocycle_a_00050_B4 b4_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00050_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } + } + + class Nocycle_a_00050_B1 { + Nocycle_a_00050_C1 c1_0; + Nocycle_a_00050_C2 c2_0; + Nocycle_a_00050_C3 c3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00050_B1(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } + } + + class Nocycle_a_00050_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00050_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00050_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00050_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00050_B4 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00050_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00050_C1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00050_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00050_C2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00050_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00050_C3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00050_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + + +public class Nocycle_am_00050 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_00050 A1_00050 = new ThreadRc_00050(); + ThreadRc_00050 A2_00050 = new ThreadRc_00050(); + ThreadRc_00050 A3_00050 = new ThreadRc_00050(); + ThreadRc_00050 A4_00050 = new ThreadRc_00050(); + ThreadRc_00050 A5_00050 = new ThreadRc_00050(); + ThreadRc_00050 A6_00050 = new ThreadRc_00050(); + + A1_00050.start(); + A2_00050.start(); + A3_00050.start(); + A4_00050.start(); + A5_00050.start(); + A6_00050.start(); + try { + A1_00050.join(); + A2_00050.join(); + A3_00050.join(); + A4_00050.join(); + A5_00050.join(); + A6_00050.join(); + } catch (InterruptedException e) { + } + if (A1_00050.check() && A2_00050.check() && A3_00050.check() && A4_00050.check() && A5_00050.check() && A6_00050.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0211-rc-function-RC_Thread01-Nocycle_am_00060/Nocycle_am_00060.java b/test/testsuite/ouroboros/rc_test/RC0211-rc-function-RC_Thread01-Nocycle_am_00060/Nocycle_am_00060.java new file mode 100755 index 0000000000000000000000000000000000000000..58248d8f13efc4e3cc9029e4dc8065aa239c72a5 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0211-rc-function-RC_Thread01-Nocycle_am_00060/Nocycle_am_00060.java @@ -0,0 +1,252 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Nocycle_am_00060.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Nocycle_a_00060 in RC测试-No-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_am_00060.java + *- @ExecuteClass: Nocycle_am_00060 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_00060 extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00060_A1 a1_main = new Nocycle_a_00060_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00060_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00060_B2("b2_0"); + a1_main.b2_0.c1_0 = new Nocycle_a_00060_C1("c1_0"); + a1_main.b2_0.c2_0 = new Nocycle_a_00060_C2("c2_0"); + a1_main.b2_0.c3_0 = new Nocycle_a_00060_C3("c3_0"); + a1_main.b3_0 = new Nocycle_a_00060_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00060_B4("b4_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b2_0.c1_0.add(); + a1_main.b2_0.c2_0.add(); + a1_main.b2_0.c3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b2_0.c1_0.sum+a1_main.b2_0.c2_0.sum+a1_main.b2_0.c3_0.sum); + + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b2_0.c1_0.sum + a1_main.b2_0.c2_0.sum + a1_main.b2_0.c3_0.sum; + //System.out.println("RC-Testing_Result_Thread1="+result); + if (result == 5047) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00060_A1 { + Nocycle_a_00060_B1 b1_0; + Nocycle_a_00060_B2 b2_0; + Nocycle_a_00060_B3 b3_0; + Nocycle_a_00060_B4 b4_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00060_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } + } + + class Nocycle_a_00060_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00060_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00060_B2 { + Nocycle_a_00060_C1 c1_0; + Nocycle_a_00060_C2 c2_0; + Nocycle_a_00060_C3 c3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00060_B2(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } + } + + class Nocycle_a_00060_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00060_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00060_B4 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00060_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00060_C1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00060_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00060_C2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00060_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00060_C3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00060_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +public class Nocycle_am_00060 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_00060 A1_00060 = new ThreadRc_00060(); + ThreadRc_00060 A2_00060 = new ThreadRc_00060(); + ThreadRc_00060 A3_00060 = new ThreadRc_00060(); + ThreadRc_00060 A4_00060 = new ThreadRc_00060(); + ThreadRc_00060 A5_00060 = new ThreadRc_00060(); + ThreadRc_00060 A6_00060 = new ThreadRc_00060(); + ThreadRc_00060 A7_00060 = new ThreadRc_00060(); + ThreadRc_00060 A8_00060 = new ThreadRc_00060(); + ThreadRc_00060 A9_00060 = new ThreadRc_00060(); + ThreadRc_00060 A10_00060 = new ThreadRc_00060(); + + A1_00060.start(); + A2_00060.start(); + A3_00060.start(); + A4_00060.start(); + A5_00060.start(); + A6_00060.start(); + A7_00060.start(); + A8_00060.start(); + A9_00060.start(); + A10_00060.start(); + + try { + A1_00060.join(); + A2_00060.join(); + A3_00060.join(); + A4_00060.join(); + A5_00060.join(); + A6_00060.join(); + A7_00060.join(); + A8_00060.join(); + A9_00060.join(); + A10_00060.join(); + } catch (InterruptedException e) { + } + if (A1_00060.check() && A2_00060.check() && A3_00060.check() && A4_00060.check() && A5_00060.check() && A6_00060.check() && A7_00060.check() && A8_00060.check() && A9_00060.check() && A10_00060.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0212-rc-function-RC_Thread01-Nocycle_am_00070/Nocycle_am_00070.java b/test/testsuite/ouroboros/rc_test/RC0212-rc-function-RC_Thread01-Nocycle_am_00070/Nocycle_am_00070.java new file mode 100755 index 0000000000000000000000000000000000000000..6613971d1ccb355c3af68cc7a247e42e0befe04c --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0212-rc-function-RC_Thread01-Nocycle_am_00070/Nocycle_am_00070.java @@ -0,0 +1,243 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Nocycle_am_00070.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Nocycle_a_00070 in RC测试-No-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_am_00070.java + *- @ExecuteClass: Nocycle_am_00070 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_00070 extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00070_A1 a1_main = new Nocycle_a_00070_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00070_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00070_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00070_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00070_B4("b4_0"); + a1_main.b4_0.c1_0 = new Nocycle_a_00070_C1("c1_0"); + a1_main.b4_0.c2_0 = new Nocycle_a_00070_C2("c2_0"); + a1_main.b4_0.c3_0 = new Nocycle_a_00070_C3("c3_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b4_0.c1_0.add(); + a1_main.b4_0.c2_0.add(); + a1_main.b4_0.c3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b4_0.c1_0.sum+a1_main.b4_0.c2_0.sum+a1_main.b4_0.c3_0.sum); + + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b4_0.c1_0.sum + a1_main.b4_0.c2_0.sum + a1_main.b4_0.c3_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 5045) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00070_A1 { + Nocycle_a_00070_B1 b1_0; + Nocycle_a_00070_B2 b2_0; + Nocycle_a_00070_B3 b3_0; + Nocycle_a_00070_B4 b4_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00070_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } + } + + class Nocycle_a_00070_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00070_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00070_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00070_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00070_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00070_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00070_B4 { + Nocycle_a_00070_C1 c1_0; + Nocycle_a_00070_C2 c2_0; + Nocycle_a_00070_C3 c3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00070_B4(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } + } + + class Nocycle_a_00070_C1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00070_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00070_C2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00070_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00070_C3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00070_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + + +public class Nocycle_am_00070 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_00070 A1_00070 = new ThreadRc_00070(); + ThreadRc_00070 A2_00070 = new ThreadRc_00070(); + ThreadRc_00070 A3_00070 = new ThreadRc_00070(); + ThreadRc_00070 A4_00070 = new ThreadRc_00070(); + ThreadRc_00070 A5_00070 = new ThreadRc_00070(); + ThreadRc_00070 A6_00070 = new ThreadRc_00070(); + + A1_00070.start(); + A2_00070.start(); + A3_00070.start(); + A4_00070.start(); + A5_00070.start(); + A6_00070.start(); + + try { + A1_00070.join(); + A2_00070.join(); + A3_00070.join(); + A4_00070.join(); + A5_00070.join(); + A6_00070.join(); + + } catch (InterruptedException e) { + } + if (A1_00070.check() && A2_00070.check() && A3_00070.check() && A4_00070.check() && A5_00070.check() && A6_00070.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0213-rc-function-RC_Thread01-Nocycle_am_00080/Nocycle_am_00080.java b/test/testsuite/ouroboros/rc_test/RC0213-rc-function-RC_Thread01-Nocycle_am_00080/Nocycle_am_00080.java new file mode 100755 index 0000000000000000000000000000000000000000..ed81ff36fd6957fb977db850e2051a2eb1ed3f96 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0213-rc-function-RC_Thread01-Nocycle_am_00080/Nocycle_am_00080.java @@ -0,0 +1,135 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Nocycle_am_00080.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Nocycle_a_00080 in RC测试-No-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_am_00080.java + *- @ExecuteClass: Nocycle_am_00080 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_00080 extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00080_A1 a1_main = new Nocycle_a_00080_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00080_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_a_00080_C1("c1_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b1_0.c1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b1_0.c1_0.sum); + + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b1_0.c1_0.sum; + //System.out.println("RC-Testing_Result_Thread1="+result); + if (result == 1406) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00080_A1 { + Nocycle_a_00080_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00080_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00080_B1 { + Nocycle_a_00080_C1 c1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00080_B1(String strObjectName) { + c1_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } + } + + class Nocycle_a_00080_C1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00080_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +public class Nocycle_am_00080 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_00080 A1_00080 = new ThreadRc_00080(); + ThreadRc_00080 A2_00080 = new ThreadRc_00080(); + ThreadRc_00080 A3_00080 = new ThreadRc_00080(); + ThreadRc_00080 A4_00080 = new ThreadRc_00080(); + ThreadRc_00080 A5_00080 = new ThreadRc_00080(); + ThreadRc_00080 A6_00080 = new ThreadRc_00080(); + + A1_00080.start(); + A2_00080.start(); + A3_00080.start(); + A4_00080.start(); + A5_00080.start(); + A6_00080.start(); + try { + A1_00080.join(); + A2_00080.join(); + A3_00080.join(); + A4_00080.join(); + A5_00080.join(); + A6_00080.join(); + + } catch (InterruptedException e) { + } + if (A1_00080.check() && A2_00080.check() && A3_00080.check() && A4_00080.check() && A5_00080.check() && A6_00080.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0214-rc-function-RC_Thread01-Nocycle_am_00090/Nocycle_am_00090.java b/test/testsuite/ouroboros/rc_test/RC0214-rc-function-RC_Thread01-Nocycle_am_00090/Nocycle_am_00090.java new file mode 100755 index 0000000000000000000000000000000000000000..07c5b432abab17ee0e1d807ee9827f9713dacfbc --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0214-rc-function-RC_Thread01-Nocycle_am_00090/Nocycle_am_00090.java @@ -0,0 +1,160 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Nocycle_am_00090.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Nocycle_a_00090 in RC测试-No-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_am_00090.java + *- @ExecuteClass: Nocycle_am_00090 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_00090 extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00090_A1 a1_main = new Nocycle_a_00090_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00090_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_a_00090_C1("c1_0"); + a1_main.b1_0.c1_0.d1_0 = new Nocycle_a_00090_D1("d1_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b1_0.c1_0.add(); + a1_main.b1_0.c1_0.d1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b1_0.c1_0.sum+a1_main.b1_0.c1_0.d1_0.sum); + + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b1_0.c1_0.sum + a1_main.b1_0.c1_0.d1_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 2308) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00090_A1 { + Nocycle_a_00090_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00090_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00090_B1 { + Nocycle_a_00090_C1 c1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00090_B1(String strObjectName) { + c1_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } + } + + class Nocycle_a_00090_C1 { + Nocycle_a_00090_D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00090_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + d1_0.a; + } + } + + class Nocycle_a_00090_D1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00090_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + + +public class Nocycle_am_00090 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_00090 A1_00090 = new ThreadRc_00090(); + ThreadRc_00090 A2_00090 = new ThreadRc_00090(); + ThreadRc_00090 A3_00090 = new ThreadRc_00090(); + ThreadRc_00090 A4_00090 = new ThreadRc_00090(); + ThreadRc_00090 A5_00090 = new ThreadRc_00090(); + ThreadRc_00090 A6_00090 = new ThreadRc_00090(); + + A1_00090.start(); + A2_00090.start(); + A3_00090.start(); + A4_00090.start(); + A5_00090.start(); + A6_00090.start(); + + try { + A1_00090.join(); + A2_00090.join(); + A3_00090.join(); + A4_00090.join(); + A5_00090.join(); + A6_00090.join(); + + } catch (InterruptedException e) { + } + if (A1_00090.check() && A2_00090.check() && A3_00090.check() && A4_00090.check() && A5_00090.check() && A6_00090.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0215-rc-function-RC_Thread01-Nocycle_am_00100/Nocycle_am_00100.java b/test/testsuite/ouroboros/rc_test/RC0215-rc-function-RC_Thread01-Nocycle_am_00100/Nocycle_am_00100.java new file mode 100755 index 0000000000000000000000000000000000000000..083895e8a6f6fec0e21143301f3f8e7542172d5b --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0215-rc-function-RC_Thread01-Nocycle_am_00100/Nocycle_am_00100.java @@ -0,0 +1,297 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Nocycle_am_00100.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Nocycle_a_00100 in RC测试-No-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_am_00100.java + *- @ExecuteClass: Nocycle_am_00100 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_00100 extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00100_A1 a1_main = new Nocycle_a_00100_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00100_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_a_00100_C1("c1_0"); + a1_main.b1_0.c1_0.d1_0 = new Nocycle_a_00100_D1("d1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0 = new Nocycle_a_00100_E1("e1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0 = new Nocycle_a_00100_F1("f1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0 = new Nocycle_a_00100_G1("g1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0 = new Nocycle_a_00100_H1("h1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0 = new Nocycle_a_00100_I1("i1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0 = new Nocycle_a_00100_J1("j1_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b1_0.c1_0.add(); + a1_main.b1_0.c1_0.d1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.add(); +// System.out.printf("a=%d\n",a1_main.sum); +// System.out.printf("b=%d\n",a1_main.b1_0.sum); +// System.out.printf("c=%d\n",a1_main.b1_0.c1_0.sum); +// System.out.printf("d=%d\n",a1_main.b1_0.c1_0.d1_0.sum); +// System.out.printf("e=%d\n",a1_main.b1_0.c1_0.d1_0.e1_0.sum); +// System.out.printf("f=%d\n",a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.sum); +// System.out.printf("g=%d\n",a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.sum); +// System.out.printf("h=%d\n",a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.sum); +// System.out.printf("i=%d\n",a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.sum); +// System.out.printf("j=%d\n",a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.sum); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b1_0.c1_0.sum+a1_main.b1_0.c1_0.d1_0.sum+a1_main.b1_0.c1_0.d1_0.e1_0.sum+a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.sum+a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.sum+a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.sum+a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.sum+a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.sum); + + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b1_0.c1_0.sum + a1_main.b1_0.c1_0.d1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.sum; + + //System.out.println("RC-Testing_Result="+result); + + if (result == 11920) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00100_A1 { + Nocycle_a_00100_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00100_B1 { + Nocycle_a_00100_C1 c1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_B1(String strObjectName) { + c1_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } + } + + class Nocycle_a_00100_C1 { + Nocycle_a_00100_D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + d1_0.a; + } + } + + class Nocycle_a_00100_D1 { + Nocycle_a_00100_E1 e1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_D1(String strObjectName) { + e1_0 = null; + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + + void add() { + sum = a + e1_0.a; + } + } + + class Nocycle_a_00100_E1 { + Nocycle_a_00100_F1 f1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_E1(String strObjectName) { + f1_0 = null; + a = 501; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_E1_"+strObjectName); + } + + void add() { + sum = a + f1_0.a; + } + } + + class Nocycle_a_00100_F1 { + Nocycle_a_00100_G1 g1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_F1(String strObjectName) { + g1_0 = null; + a = 601; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_F1_"+strObjectName); + } + + void add() { + sum = a + g1_0.a; + } + } + + class Nocycle_a_00100_G1 { + Nocycle_a_00100_H1 h1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_G1(String strObjectName) { + h1_0 = null; + a = 701; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_G1_"+strObjectName); + } + + void add() { + sum = a + h1_0.a; + } + } + + class Nocycle_a_00100_H1 { + Nocycle_a_00100_I1 i1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_H1(String strObjectName) { + i1_0 = null; + a = 801; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_H1_"+strObjectName); + } + + void add() { + sum = a + i1_0.a; + } + } + + class Nocycle_a_00100_I1 { + Nocycle_a_00100_J1 j1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_I1(String strObjectName) { + j1_0 = null; + a = 901; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_I1_"+strObjectName); + } + + void add() { + sum = a + j1_0.a; + } + } + + class Nocycle_a_00100_J1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_J1(String strObjectName) { + a = 1001; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_J1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + + +public class Nocycle_am_00100 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_00100 A1_00100 = new ThreadRc_00100(); + ThreadRc_00100 A2_00100 = new ThreadRc_00100(); + ThreadRc_00100 A3_00100 = new ThreadRc_00100(); + ThreadRc_00100 A4_00100 = new ThreadRc_00100(); + ThreadRc_00100 A5_00100 = new ThreadRc_00100(); + ThreadRc_00100 A6_00100 = new ThreadRc_00100(); + + A1_00100.start(); + A2_00100.start(); + A3_00100.start(); + A4_00100.start(); + A5_00100.start(); + A6_00100.start(); + + try { + A1_00100.join(); + A2_00100.join(); + A3_00100.join(); + A4_00100.join(); + A5_00100.join(); + A6_00100.join(); + + } catch (InterruptedException e) { + } + if (A1_00100.check() && A2_00100.check() && A3_00100.check() && A4_00100.check() && A5_00100.check() && A6_00100.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0216-rc-function-RC_Thread01-Nocycle_am_00110/Nocycle_am_00110.java b/test/testsuite/ouroboros/rc_test/RC0216-rc-function-RC_Thread01-Nocycle_am_00110/Nocycle_am_00110.java new file mode 100755 index 0000000000000000000000000000000000000000..b86e701a461b6f65621cf526c83c289f05cad9be --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0216-rc-function-RC_Thread01-Nocycle_am_00110/Nocycle_am_00110.java @@ -0,0 +1,347 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Nocycle_am_00110.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Nocycle_a_00110 in RC测试-No-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_am_00110.java + *- @ExecuteClass: Nocycle_am_00110 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_00110 extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00110_A1 a1_main = new Nocycle_a_00110_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00110_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00110_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00110_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00110_B4("b4_0"); + a1_main.b1_0.d1_0 = new Nocycle_a_00110_D1("d1_0"); + a1_main.b2_0.c2_0 = new Nocycle_a_00110_C2("c2_0"); + a1_main.b3_0.c1_0 = new Nocycle_a_00110_C1("c1_0"); + a1_main.b4_0.c3_0 = new Nocycle_a_00110_C3("c3_0"); + a1_main.b3_0.c1_0.d2_0 = new Nocycle_a_00110_D2("d2_0"); + a1_main.b2_0.c2_0.d3_0 = new Nocycle_a_00110_D3("d3_0"); + a1_main.b2_0.c2_0.d4_0 = new Nocycle_a_00110_D4("d4_0"); + a1_main.d5_0 = new Nocycle_a_00110_D5("d5_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b2_0.c2_0.add(); + a1_main.b3_0.c1_0.add(); + a1_main.b4_0.c3_0.add(); + a1_main.b1_0.d1_0.add(); + a1_main.b3_0.c1_0.d2_0.add(); + a1_main.b2_0.c2_0.d3_0.add(); + a1_main.b2_0.c2_0.d4_0.add(); + a1_main.d5_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b2_0.c2_0.sum+a1_main.b3_0.c1_0.sum+a1_main.b4_0.c3_0.sum+a1_main.b1_0.d1_0.sum+a1_main.b3_0.c1_0.d2_0.sum+a1_main.b2_0.c2_0.d3_0.sum+a1_main.b2_0.c2_0.d4_0.sum+a1_main.d5_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b2_0.c2_0.sum + a1_main.b3_0.c1_0.sum + a1_main.b4_0.c3_0.sum + a1_main.b1_0.d1_0.sum + a1_main.b3_0.c1_0.d2_0.sum + a1_main.b2_0.c2_0.d3_0.sum + a1_main.b2_0.c2_0.d4_0.sum + a1_main.d5_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 9881) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00110_A1 { + Nocycle_a_00110_B1 b1_0; + Nocycle_a_00110_B2 b2_0; + Nocycle_a_00110_B3 b3_0; + Nocycle_a_00110_B4 b4_0; + Nocycle_a_00110_D5 d5_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + d5_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a + d5_0.a; + } + } + + class Nocycle_a_00110_B1 { + Nocycle_a_00110_D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + d1_0.a; + } + } + + class Nocycle_a_00110_B2 { + Nocycle_a_00110_C2 c2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_B2(String strObjectName) { + c2_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + c2_0.a; + } + } + + class Nocycle_a_00110_B3 { + Nocycle_a_00110_C1 c1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } + } + + class Nocycle_a_00110_B4 { + Nocycle_a_00110_C3 c3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_B4(String strObjectName) { + c3_0 = null; + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + + void add() { + sum = a + c3_0.a; + } + } + + class Nocycle_a_00110_C1 { + Nocycle_a_00110_D2 d2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_C1(String strObjectName) { + d2_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + d2_0.a; + } + } + + class Nocycle_a_00110_C2 { + Nocycle_a_00110_D3 d3_0; + Nocycle_a_00110_D4 d4_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_C2(String strObjectName) { + d3_0 = null; + d4_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + d3_0.a + d4_0.a; + } + } + + class Nocycle_a_00110_C3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00110_D1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00110_D2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00110_D3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00110_D4 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_D4(String strObjectName) { + a = 404; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D4_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00110_D5 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_D5(String strObjectName) { + a = 405; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D5_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + + +public class Nocycle_am_00110 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_00110 A1_00110 = new ThreadRc_00110(); + ThreadRc_00110 A2_00110 = new ThreadRc_00110(); + ThreadRc_00110 A3_00110 = new ThreadRc_00110(); + ThreadRc_00110 A4_00110 = new ThreadRc_00110(); + ThreadRc_00110 A5_00110 = new ThreadRc_00110(); + ThreadRc_00110 A6_00110 = new ThreadRc_00110(); + + A1_00110.start(); + A2_00110.start(); + A3_00110.start(); + A4_00110.start(); + A5_00110.start(); + A6_00110.start(); + + try { + A1_00110.join(); + A2_00110.join(); + A3_00110.join(); + A4_00110.join(); + A5_00110.join(); + A6_00110.join(); + + } catch (InterruptedException e) { + } + if (A1_00110.check() && A2_00110.check() && A3_00110.check() && A4_00110.check() && A5_00110.check() && A6_00110.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0217-rc-function-RC_Thread01-Nocycle_am_00120/Nocycle_am_00120.java b/test/testsuite/ouroboros/rc_test/RC0217-rc-function-RC_Thread01-Nocycle_am_00120/Nocycle_am_00120.java new file mode 100755 index 0000000000000000000000000000000000000000..37ae1689ea4b1681ed2e6769033714068a3ba69d --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0217-rc-function-RC_Thread01-Nocycle_am_00120/Nocycle_am_00120.java @@ -0,0 +1,140 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Nocycle_am_00120.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Nocycle_a_00120 in RC测试-No-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_am_00120.java + *- @ExecuteClass: Nocycle_am_00120 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_00120 extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00120_A1 a1_main = new Nocycle_a_00120_A1("a1_main"); + Nocycle_a_00120_A2 a2_main = new Nocycle_a_00120_A2("a2_main"); + a1_main.b1_0 = new Nocycle_a_00120_B1("b1_0"); + a2_main.b1_0 = new Nocycle_a_00120_B1("b1_0"); + a1_main.add(); + a2_main.add(); + a1_main.b1_0.add(); + a2_main.b1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a1_main.b1_0.sum); + + int result = a1_main.sum + a2_main.sum + a1_main.b1_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1007) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00120_A1 { + Nocycle_a_00120_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00120_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00120_A2 { + Nocycle_a_00120_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00120_A2(String strObjectName) { + b1_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00120_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00120_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + + +public class Nocycle_am_00120 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_00120 A1_00120 = new ThreadRc_00120(); + ThreadRc_00120 A2_00120 = new ThreadRc_00120(); + ThreadRc_00120 A3_00120 = new ThreadRc_00120(); + ThreadRc_00120 A4_00120 = new ThreadRc_00120(); + ThreadRc_00120 A5_00120 = new ThreadRc_00120(); + ThreadRc_00120 A6_00120 = new ThreadRc_00120(); + + A1_00120.start(); + A2_00120.start(); + A3_00120.start(); + A4_00120.start(); + A5_00120.start(); + A6_00120.start(); + + try { + A1_00120.join(); + A2_00120.join(); + A3_00120.join(); + A4_00120.join(); + A5_00120.join(); + A6_00120.join(); + + } catch (InterruptedException e) { + } + if (A1_00120.check() && A2_00120.check() && A3_00120.check() && A4_00120.check() && A5_00120.check() && A6_00120.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0218-rc-function-RC_Thread01-Nocycle_am_00130/Nocycle_am_00130.java b/test/testsuite/ouroboros/rc_test/RC0218-rc-function-RC_Thread01-Nocycle_am_00130/Nocycle_am_00130.java new file mode 100755 index 0000000000000000000000000000000000000000..1ad3258d4b6d7e4d07bf6a9a1ab0ec52f43e76e1 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0218-rc-function-RC_Thread01-Nocycle_am_00130/Nocycle_am_00130.java @@ -0,0 +1,324 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Nocycle_am_00130.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Nocycle_a_00130 in RC测试-No-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_am_00130.java + *- @ExecuteClass: Nocycle_am_00130 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_00130 extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00130_A1 a1_main = new Nocycle_a_00130_A1("a1_main"); + Nocycle_a_00130_A2 a2_main = new Nocycle_a_00130_A2("a2_main"); + Nocycle_a_00130_A3 a3_main = new Nocycle_a_00130_A3("a3_main"); + Nocycle_a_00130_A4 a4_main = new Nocycle_a_00130_A4("a4_main"); + Nocycle_a_00130_A5 a5_main = new Nocycle_a_00130_A5("a5_main"); + Nocycle_a_00130_A6 a6_main = new Nocycle_a_00130_A6("a6_main"); + Nocycle_a_00130_A7 a7_main = new Nocycle_a_00130_A7("a7_main"); + Nocycle_a_00130_A8 a8_main = new Nocycle_a_00130_A8("a8_main"); + Nocycle_a_00130_A9 a9_main = new Nocycle_a_00130_A9("a9_main"); + Nocycle_a_00130_A10 a10_main = new Nocycle_a_00130_A10("a10_main"); + a1_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a2_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a3_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a4_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a5_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a6_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a7_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a8_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a9_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a10_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a5_main.add(); + a6_main.add(); + a7_main.add(); + a8_main.add(); + a9_main.add(); + a10_main.add(); + a1_main.b1_0.add(); + a2_main.b1_0.add(); + a3_main.b1_0.add(); + a4_main.b1_0.add(); + a5_main.b1_0.add(); + a6_main.b1_0.add(); + a7_main.b1_0.add(); + a8_main.b1_0.add(); + a9_main.b1_0.add(); + a10_main.b1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a3_main.sum+a4_main.sum+a5_main.sum+a6_main.sum+a7_main.sum+a8_main.sum+a9_main.sum+a10_main.sum+a1_main.b1_0.sum); + + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a5_main.sum + a6_main.sum + a7_main.sum + a8_main.sum + a9_main.sum + a10_main.sum + a1_main.b1_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 3467) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00130_A1 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00130_A2 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A2(String strObjectName) { + b1_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00130_A3 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A3(String strObjectName) { + b1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00130_A4 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A4(String strObjectName) { + b1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00130_A5 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A5(String strObjectName) { + b1_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00130_A6 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A6(String strObjectName) { + b1_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00130_A7 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A7(String strObjectName) { + b1_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00130_A8 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A8(String strObjectName) { + b1_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00130_A9 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A9(String strObjectName) { + b1_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00130_A10 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A10(String strObjectName) { + b1_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00130_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + + +public class Nocycle_am_00130 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_00130 A1_00130 = new ThreadRc_00130(); + ThreadRc_00130 A2_00130 = new ThreadRc_00130(); + ThreadRc_00130 A3_00130 = new ThreadRc_00130(); + ThreadRc_00130 A4_00130 = new ThreadRc_00130(); + ThreadRc_00130 A5_00130 = new ThreadRc_00130(); + ThreadRc_00130 A6_00130 = new ThreadRc_00130(); + + A1_00130.start(); + A2_00130.start(); + A3_00130.start(); + A4_00130.start(); + A5_00130.start(); + A6_00130.start(); + + try { + A1_00130.join(); + A2_00130.join(); + A3_00130.join(); + A4_00130.join(); + A5_00130.join(); + A6_00130.join(); + + } catch (InterruptedException e) { + } + if (A1_00130.check() && A2_00130.check() && A3_00130.check() && A4_00130.check() && A5_00130.check() && A6_00130.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0219-rc-function-RC_Thread01-Nocycle_am_00140/Nocycle_am_00140.java b/test/testsuite/ouroboros/rc_test/RC0219-rc-function-RC_Thread01-Nocycle_am_00140/Nocycle_am_00140.java new file mode 100755 index 0000000000000000000000000000000000000000..73ff9a622645670b0427734454af90980deda28f --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0219-rc-function-RC_Thread01-Nocycle_am_00140/Nocycle_am_00140.java @@ -0,0 +1,162 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Nocycle_am_00140.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Nocycle_a_00140 in RC测试-No-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_am_00140.java + *- @ExecuteClass: Nocycle_am_00140 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_00140 extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00140_A1 a1_main = new Nocycle_a_00140_A1("a1_main"); + Nocycle_a_00140_A2 a2_main = new Nocycle_a_00140_A2("a2_main"); + a1_main.b1_0 = new Nocycle_a_00140_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00140_B2("b2_0"); + a2_main.b1_0 = new Nocycle_a_00140_B1("b1_0"); + a1_main.add(); + a2_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a2_main.b1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum); + + int result = a1_main.sum + a2_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1613) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00140_A1 { + Nocycle_a_00140_B1 b1_0; + Nocycle_a_00140_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00140_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + + class Nocycle_a_00140_A2 { + Nocycle_a_00140_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00140_A2(String strObjectName) { + b1_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00140_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00140_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00140_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00140_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + + +public class Nocycle_am_00140 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_00140 A1_00140 = new ThreadRc_00140(); + ThreadRc_00140 A2_00140 = new ThreadRc_00140(); + ThreadRc_00140 A3_00140 = new ThreadRc_00140(); + ThreadRc_00140 A4_00140 = new ThreadRc_00140(); + ThreadRc_00140 A5_00140 = new ThreadRc_00140(); + ThreadRc_00140 A6_00140 = new ThreadRc_00140(); + + A1_00140.start(); + A2_00140.start(); + A3_00140.start(); + A4_00140.start(); + A5_00140.start(); + A6_00140.start(); + + try { + A1_00140.join(); + A2_00140.join(); + A3_00140.join(); + A4_00140.join(); + A5_00140.join(); + A6_00140.join(); + + } catch (InterruptedException e) { + } + if (A1_00140.check() && A2_00140.check() && A3_00140.check() && A4_00140.check() && A5_00140.check() && A6_00140.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0220-rc-function-RC_Thread01-Nocycle_am_00150/Nocycle_am_00150.java b/test/testsuite/ouroboros/rc_test/RC0220-rc-function-RC_Thread01-Nocycle_am_00150/Nocycle_am_00150.java new file mode 100755 index 0000000000000000000000000000000000000000..290294df09c4a750994d8c49ddd688dc66c7f29b --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0220-rc-function-RC_Thread01-Nocycle_am_00150/Nocycle_am_00150.java @@ -0,0 +1,166 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Nocycle_am_00150.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Nocycle_a_00150 in RC测试-No-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_am_00150.java + *- @ExecuteClass: Nocycle_am_00150 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_00150 extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00150_A1 a1_main = new Nocycle_a_00150_A1("a1_main"); + Nocycle_a_00150_A2 a2_main = new Nocycle_a_00150_A2("a2_main"); + a1_main.b1_0 = new Nocycle_a_00150_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00150_B2("b2_0"); + a2_main.b1_0 = new Nocycle_a_00150_B1("b1_0"); + a2_main.b2_0 = new Nocycle_a_00150_B2("b2_0"); + a1_main.add(); + a2_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a2_main.b1_0.add(); + a2_main.b2_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum); + + int result = a1_main.sum + a2_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1815) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00150_A1 { + Nocycle_a_00150_B1 b1_0; + Nocycle_a_00150_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00150_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + + class Nocycle_a_00150_A2 { + Nocycle_a_00150_B1 b1_0; + Nocycle_a_00150_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00150_A2(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + + class Nocycle_a_00150_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00150_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00150_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00150_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + + +public class Nocycle_am_00150 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_00150 A1_00150 = new ThreadRc_00150(); + ThreadRc_00150 A2_00150 = new ThreadRc_00150(); + ThreadRc_00150 A3_00150 = new ThreadRc_00150(); + ThreadRc_00150 A4_00150 = new ThreadRc_00150(); + ThreadRc_00150 A5_00150 = new ThreadRc_00150(); + ThreadRc_00150 A6_00150 = new ThreadRc_00150(); + + A1_00150.start(); + A2_00150.start(); + A3_00150.start(); + A4_00150.start(); + A5_00150.start(); + A6_00150.start(); + + try { + A1_00150.join(); + A2_00150.join(); + A3_00150.join(); + A4_00150.join(); + A5_00150.join(); + A6_00150.join(); + + } catch (InterruptedException e) { + } + if (A1_00150.check() && A2_00150.check() && A3_00150.check() && A4_00150.check() && A5_00150.check() && A6_00150.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0221-rc-function-RC_Thread01-Nocycle_am_00160/Nocycle_am_00160.java b/test/testsuite/ouroboros/rc_test/RC0221-rc-function-RC_Thread01-Nocycle_am_00160/Nocycle_am_00160.java new file mode 100755 index 0000000000000000000000000000000000000000..fb29c235b1cc9c4f149d1389da8684f2dfb986f6 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0221-rc-function-RC_Thread01-Nocycle_am_00160/Nocycle_am_00160.java @@ -0,0 +1,220 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Nocycle_am_00160.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Nocycle_a_00160 in RC测试-No-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_am_00160.java + *- @ExecuteClass: Nocycle_am_00160 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_00160 extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00160_A1 a1_main = new Nocycle_a_00160_A1("a1_main"); + Nocycle_a_00160_A2 a2_main = new Nocycle_a_00160_A2("a2_main"); + Nocycle_a_00160_A3 a3_main = new Nocycle_a_00160_A3("a3_main"); + Nocycle_a_00160_A4 a4_main = new Nocycle_a_00160_A4("a4_main"); + a1_main.b1_0 = new Nocycle_a_00160_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00160_B2("b2_0"); + a2_main.b1_0 = new Nocycle_a_00160_B1("b1_0"); + a2_main.b2_0 = new Nocycle_a_00160_B2("b2_0"); + a3_main.b1_0 = new Nocycle_a_00160_B1("b1_0"); + a3_main.b2_0 = new Nocycle_a_00160_B2("b2_0"); + a4_main.b1_0 = new Nocycle_a_00160_B1("b1_0"); + a4_main.b2_0 = new Nocycle_a_00160_B2("b2_0"); + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a2_main.b1_0.add(); + a2_main.b2_0.add(); + a3_main.b1_0.add(); + a3_main.b2_0.add(); + a4_main.b1_0.add(); + a4_main.b2_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a3_main.sum+a4_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum); + + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 2828) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00160_A1 { + Nocycle_a_00160_B1 b1_0; + Nocycle_a_00160_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00160_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + + class Nocycle_a_00160_A2 { + Nocycle_a_00160_B1 b1_0; + Nocycle_a_00160_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00160_A2(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + + class Nocycle_a_00160_A3 { + Nocycle_a_00160_B1 b1_0; + Nocycle_a_00160_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00160_A3(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + + class Nocycle_a_00160_A4 { + Nocycle_a_00160_B1 b1_0; + Nocycle_a_00160_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00160_A4(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + + class Nocycle_a_00160_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00160_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00160_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00160_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + + +public class Nocycle_am_00160 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_00160 A1_00160 = new ThreadRc_00160(); + ThreadRc_00160 A2_00160 = new ThreadRc_00160(); + ThreadRc_00160 A3_00160 = new ThreadRc_00160(); + ThreadRc_00160 A4_00160 = new ThreadRc_00160(); + ThreadRc_00160 A5_00160 = new ThreadRc_00160(); + ThreadRc_00160 A6_00160 = new ThreadRc_00160(); + + A1_00160.start(); + A2_00160.start(); + A3_00160.start(); + A4_00160.start(); + A5_00160.start(); + A6_00160.start(); + + try { + A1_00160.join(); + A2_00160.join(); + A3_00160.join(); + A4_00160.join(); + A5_00160.join(); + A6_00160.join(); + + } catch (InterruptedException e) { + } + if (A1_00160.check() && A2_00160.check() && A3_00160.check() && A4_00160.check() && A5_00160.check() && A6_00160.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0222-rc-function-RC_Thread01-Nocycle_am_00170/Nocycle_am_00170.java b/test/testsuite/ouroboros/rc_test/RC0222-rc-function-RC_Thread01-Nocycle_am_00170/Nocycle_am_00170.java new file mode 100755 index 0000000000000000000000000000000000000000..2cbd63ba216dbd88680618f7111a43b3f3428878 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0222-rc-function-RC_Thread01-Nocycle_am_00170/Nocycle_am_00170.java @@ -0,0 +1,254 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Nocycle_am_00170.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Nocycle_a_00170 in RC测试-No-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_am_00170.java + *- @ExecuteClass: Nocycle_am_00170 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_00170 extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00170_A1 a1_main = new Nocycle_a_00170_A1("a1_main"); + Nocycle_a_00170_A2 a2_main = new Nocycle_a_00170_A2("a2_main"); + Nocycle_a_00170_A3 a3_main = new Nocycle_a_00170_A3("a3_main"); + Nocycle_a_00170_A4 a4_main = new Nocycle_a_00170_A4("a4_main"); + a1_main.b1_0 = new Nocycle_a_00170_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00170_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00170_B3("b3_0"); + a2_main.b1_0 = new Nocycle_a_00170_B1("b1_0"); + a2_main.b2_0 = new Nocycle_a_00170_B2("b2_0"); + a2_main.b3_0 = new Nocycle_a_00170_B3("b3_0"); + a3_main.b1_0 = new Nocycle_a_00170_B1("b1_0"); + a3_main.b2_0 = new Nocycle_a_00170_B2("b2_0"); + a3_main.b3_0 = new Nocycle_a_00170_B3("b3_0"); + a4_main.b1_0 = new Nocycle_a_00170_B1("b1_0"); + a4_main.b2_0 = new Nocycle_a_00170_B2("b2_0"); + a4_main.b3_0 = new Nocycle_a_00170_B3("b3_0"); + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a2_main.b1_0.add(); + a2_main.b2_0.add(); + a2_main.b3_0.add(); + a3_main.b1_0.add(); + a3_main.b2_0.add(); + a3_main.b3_0.add(); + a4_main.b1_0.add(); + a4_main.b2_0.add(); + a4_main.b3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a3_main.sum+a4_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum); + + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 4046) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00170_A1 { + Nocycle_a_00170_B1 b1_0; + Nocycle_a_00170_B2 b2_0; + Nocycle_a_00170_B3 b3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00170_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } + } + + class Nocycle_a_00170_A2 { + Nocycle_a_00170_B1 b1_0; + Nocycle_a_00170_B2 b2_0; + Nocycle_a_00170_B3 b3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00170_A2(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } + } + + class Nocycle_a_00170_A3 { + Nocycle_a_00170_B1 b1_0; + Nocycle_a_00170_B2 b2_0; + Nocycle_a_00170_B3 b3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00170_A3(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } + } + + class Nocycle_a_00170_A4 { + Nocycle_a_00170_B1 b1_0; + Nocycle_a_00170_B2 b2_0; + Nocycle_a_00170_B3 b3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00170_A4(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } + } + + class Nocycle_a_00170_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00170_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00170_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00170_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00170_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00170_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + + +public class Nocycle_am_00170 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_00170 A1_00170 = new ThreadRc_00170(); + ThreadRc_00170 A2_00170 = new ThreadRc_00170(); + ThreadRc_00170 A3_00170 = new ThreadRc_00170(); + ThreadRc_00170 A4_00170 = new ThreadRc_00170(); + ThreadRc_00170 A5_00170 = new ThreadRc_00170(); + ThreadRc_00170 A6_00170 = new ThreadRc_00170(); + + A1_00170.start(); + A2_00170.start(); + A3_00170.start(); + A4_00170.start(); + A5_00170.start(); + A6_00170.start(); + + try { + A1_00170.join(); + A2_00170.join(); + A3_00170.join(); + A4_00170.join(); + A5_00170.join(); + A6_00170.join(); + + } catch (InterruptedException e) { + } + if (A1_00170.check() && A2_00170.check() && A3_00170.check() && A4_00170.check() && A5_00170.check() && A6_00170.check()) + System.out.println("ExpectResult"); + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0223-rc-function-RC_Thread01-Nocycle_am_00180/Nocycle_am_00180.java b/test/testsuite/ouroboros/rc_test/RC0223-rc-function-RC_Thread01-Nocycle_am_00180/Nocycle_am_00180.java new file mode 100755 index 0000000000000000000000000000000000000000..e9f755f04fa6224b2af175338a30a1c7fe16e534 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0223-rc-function-RC_Thread01-Nocycle_am_00180/Nocycle_am_00180.java @@ -0,0 +1,394 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Nocycle_am_00180.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Nocycle_a_00180 in RC测试-No-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_am_00180.java + *- @ExecuteClass: Nocycle_am_00180 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_00180 extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00180_A1 a1_main = new Nocycle_a_00180_A1("a1_main"); + Nocycle_a_00180_A2 a2_main = new Nocycle_a_00180_A2("a2_main"); + Nocycle_a_00180_A3 a3_main = new Nocycle_a_00180_A3("a3_main"); + Nocycle_a_00180_A4 a4_main = new Nocycle_a_00180_A4("a4_main"); + a1_main.b1_0 = new Nocycle_a_00180_B1("b1_0"); + a1_main.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a1_main.b1_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + + a2_main.b2_0 = new Nocycle_a_00180_B2("b2_0"); + a2_main.b2_0.c1_0 = new Nocycle_a_00180_C1("c1_0"); + a2_main.b2_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a2_main.b2_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a2_main.b2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + + a3_main.b2_0 = new Nocycle_a_00180_B2("b2_0"); + a3_main.b2_0.c1_0 = new Nocycle_a_00180_C1("c1_0"); + a3_main.b2_0.c1_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a3_main.b2_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a3_main.b2_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a3_main.b2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + + a3_main.c2_0 = new Nocycle_a_00180_C2("c2_0"); + a3_main.c2_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a3_main.c2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + + a4_main.b3_0 = new Nocycle_a_00180_B3("b3_0"); + a4_main.b3_0.c1_0 = new Nocycle_a_00180_C1("c1_0"); + a4_main.b3_0.c1_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a4_main.c2_0 = new Nocycle_a_00180_C2("c2_0"); + a4_main.c2_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a4_main.c2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main.b1_0.add(); + a1_main.d1_0.add(); + a1_main.b1_0.d2_0.add(); + + a2_main.b2_0.add(); + a2_main.b2_0.c1_0.add(); + a2_main.b2_0.d1_0.add(); + a2_main.b2_0.d2_0.add(); + a2_main.b2_0.d3_0.add(); + a2_main.b2_0.c1_0.d1_0.add(); + + a3_main.b2_0.add(); + a3_main.b2_0.c1_0.add(); + a3_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.d1_0.add(); + a3_main.b2_0.d2_0.add(); + a3_main.b2_0.d3_0.add(); + + a3_main.c2_0.add(); + a3_main.c2_0.d2_0.add(); + a3_main.c2_0.d3_0.add(); + + a4_main.b3_0.add(); + a4_main.b3_0.c1_0.add(); + a4_main.b3_0.c1_0.d1_0.add(); + a4_main.c2_0.add(); + a4_main.c2_0.d2_0.add(); + a4_main.c2_0.d3_0.add(); + +// System.out.printf("a1_main.sum=%d\n",a1_main.sum); +// System.out.printf("a2_main.sum=%d\n",a2_main.sum); +// System.out.printf("a3_main.sum=%d\n",a3_main.sum); +// System.out.printf("a4_main.sum=%d\n",a4_main.sum); +// System.out.printf("a1_main.b1_0.sum=%d\n",a1_main.b1_0.sum); +// System.out.printf("a2_main.b2_0.sum=%d\n",a2_main.b2_0.sum); +// System.out.printf("a4_main.b3_0.sum=%d\n",a4_main.b3_0.sum); +// System.out.printf("a2_main.b2_0.c1_0.sum=%d\n",a2_main.b2_0.c1_0.sum); +// System.out.printf("a3_main.c2_0.sum=%d\n",a3_main.c2_0.sum); +// System.out.printf("a1_main.d1_0.sum=%d\n",a1_main.d1_0.sum); +// System.out.printf("a3_main.c2_0.d2_0.sum=%d\n",a3_main.c2_0.d2_0.sum); +// System.out.printf("a3_main.c2_0.d3_0.sum=%d\n",a3_main.c2_0.d3_0.sum); + + +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a3_main.sum+a4_main.sum+a1_main.b1_0.sum+a2_main.b2_0.sum+a4_main.b3_0.sum+a2_main.b2_0.c1_0.sum+a3_main.c2_0.sum+a1_main.d1_0.sum+a3_main.c2_0.d2_0.sum+a3_main.c2_0.d3_0.sum); + + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main.b1_0.sum + a2_main.b2_0.sum + a4_main.b3_0.sum + a2_main.b2_0.c1_0.sum + a3_main.c2_0.sum + a1_main.d1_0.sum + a3_main.c2_0.d2_0.sum + a3_main.c2_0.d3_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 9260) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00180_A1 { + Nocycle_a_00180_B1 b1_0; + Nocycle_a_00180_D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + d1_0.a; + } + } + + class Nocycle_a_00180_A2 { + Nocycle_a_00180_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b2_0.a; + } + } + + class Nocycle_a_00180_A3 { + Nocycle_a_00180_B2 b2_0; + Nocycle_a_00180_C2 c2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + b2_0.a + c2_0.a; + } + } + + class Nocycle_a_00180_A4 { + Nocycle_a_00180_B3 b3_0; + Nocycle_a_00180_C2 c2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + b3_0.a + c2_0.a; + } + } + + class Nocycle_a_00180_B1 { + Nocycle_a_00180_D2 d2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + d2_0.a; + } + } + + class Nocycle_a_00180_B2 { + Nocycle_a_00180_C1 c1_0; + Nocycle_a_00180_D1 d1_0; + Nocycle_a_00180_D2 d2_0; + Nocycle_a_00180_D3 d3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } + } + + class Nocycle_a_00180_B3 { + Nocycle_a_00180_C1 c1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } + } + + class Nocycle_a_00180_C1 { + Nocycle_a_00180_D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + d1_0.a; + } + } + + class Nocycle_a_00180_C2 { + Nocycle_a_00180_D2 d2_0; + Nocycle_a_00180_D3 d3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + d2_0.a + d3_0.a; + } + } + + class Nocycle_a_00180_D1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00180_D2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00180_D3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + + +public class Nocycle_am_00180 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_00180 A1_00180 = new ThreadRc_00180(); + ThreadRc_00180 A2_00180 = new ThreadRc_00180(); + ThreadRc_00180 A3_00180 = new ThreadRc_00180(); + ThreadRc_00180 A4_00180 = new ThreadRc_00180(); + ThreadRc_00180 A5_00180 = new ThreadRc_00180(); + ThreadRc_00180 A6_00180 = new ThreadRc_00180(); + + A1_00180.start(); + A2_00180.start(); + A3_00180.start(); + A4_00180.start(); + A5_00180.start(); + A6_00180.start(); + + try { + A1_00180.join(); + A2_00180.join(); + A3_00180.join(); + A4_00180.join(); + A5_00180.join(); + A6_00180.join(); + + } catch (InterruptedException e) { + } + if (A1_00180.check() && A2_00180.check() && A3_00180.check() && A4_00180.check() && A5_00180.check() && A6_00180.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0224-rc-function-RC_Thread01-Nocycle_am_00190/Nocycle_am_00190.java b/test/testsuite/ouroboros/rc_test/RC0224-rc-function-RC_Thread01-Nocycle_am_00190/Nocycle_am_00190.java new file mode 100755 index 0000000000000000000000000000000000000000..429784c45ded367ed8b45ff0123de6d3a9c44d10 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0224-rc-function-RC_Thread01-Nocycle_am_00190/Nocycle_am_00190.java @@ -0,0 +1,3140 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Nocycle_am_00190.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:make Nocycle_a_xx together to this Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_am_00190.java + *- @ExecuteClass: Nocycle_am_00190 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_00010B extends Thread { + private boolean checkout; + + public void run() { + Nocycle_am_00010_A1 a1_main = new Nocycle_am_00010_A1("a1_main"); + a1_main.b1_0 = new Nocycle_am_00010_B1("b1_0"); + a1_main.add(); + a1_main.b1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 704) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_am_00010_A1 { + Nocycle_am_00010_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_am_00010_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + // protected void finalize() throws java.lang.Throwable { +// System.out.println("RC-Testing_Destruction_A1_"+strObjectName); +// } + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_am_00010_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_am_00010_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + // protected void finalize() throws java.lang.Throwable { +// System.out.println("RC-Testing_Destruction_B1_"+strObjectName); +// } + void add() { + sum = a + a; + } + } +} + +class ThreadRc_00020B extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00020_A1 a1_main = new Nocycle_a_00020_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00020_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00020_B2("b2_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1310) + checkout = true; + //System.out.println(checkout); + + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00020_A1 { + Nocycle_a_00020_B1 b1_0; + Nocycle_a_00020_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00020_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + + class Nocycle_a_00020_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00020_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00020_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00020_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +class ThreadRc_00030B extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00030_A1 a1_main = new Nocycle_a_00030_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00030_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00030_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00030_B3("b3_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1919) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00030_A1 { + Nocycle_a_00030_B1 b1_0; + Nocycle_a_00030_B2 b2_0; + Nocycle_a_00030_B3 b3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00030_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } + } + + class Nocycle_a_00030_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00030_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00030_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00030_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00030_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00030_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +class ThreadRc_00040B extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00040_A1 a1_main = new Nocycle_a_00040_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00040_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00040_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00040_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00040_B4("b4_0"); + a1_main.b5_0 = new Nocycle_a_00040_B5("b5_0"); + a1_main.b6_0 = new Nocycle_a_00040_B6("b6_0"); + a1_main.b7_0 = new Nocycle_a_00040_B7("b7_0"); + a1_main.b8_0 = new Nocycle_a_00040_B8("b8_0"); + a1_main.b9_0 = new Nocycle_a_00040_B9("b9_0"); + a1_main.b10_0 = new Nocycle_a_00040_B10("b10_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b5_0.add(); + a1_main.b6_0.add(); + a1_main.b7_0.add(); + a1_main.b8_0.add(); + a1_main.b9_0.add(); + a1_main.b10_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b5_0.sum+a1_main.b6_0.sum+a1_main.b7_0.sum+a1_main.b8_0.sum+a1_main.b9_0.sum+a1_main.b10_0.sum); + + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b5_0.sum + a1_main.b6_0.sum + a1_main.b7_0.sum + a1_main.b8_0.sum + a1_main.b9_0.sum + a1_main.b10_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 6266) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00040_A1 { + Nocycle_a_00040_B1 b1_0; + Nocycle_a_00040_B2 b2_0; + Nocycle_a_00040_B3 b3_0; + Nocycle_a_00040_B4 b4_0; + Nocycle_a_00040_B5 b5_0; + Nocycle_a_00040_B6 b6_0; + Nocycle_a_00040_B7 b7_0; + Nocycle_a_00040_B8 b8_0; + Nocycle_a_00040_B9 b9_0; + Nocycle_a_00040_B10 b10_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + b5_0 = null; + b6_0 = null; + b7_0 = null; + b8_0 = null; + b9_0 = null; + b10_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a + b5_0.a + b6_0.a + b7_0.a + b8_0.a + b9_0.a + b10_0.a; + } + } + + class Nocycle_a_00040_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00040_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00040_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00040_B4 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00040_B5 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B5(String strObjectName) { + a = 205; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B5_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00040_B6 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B6(String strObjectName) { + a = 206; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B6_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00040_B7 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B7(String strObjectName) { + a = 207; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B7_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00040_B8 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B8(String strObjectName) { + a = 208; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B8_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00040_B9 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B9(String strObjectName) { + a = 209; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B9_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00040_B10 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00040_B10(String strObjectName) { + a = 210; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B10_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +class ThreadRc_00050B extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00050_A1 a1_main = new Nocycle_a_00050_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00050_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_a_00050_C1("c1_0"); + a1_main.b1_0.c2_0 = new Nocycle_a_00050_C2("c2_0"); + a1_main.b1_0.c3_0 = new Nocycle_a_00050_C3("c3_0"); + a1_main.b2_0 = new Nocycle_a_00050_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00050_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00050_B4("b4_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b1_0.c1_0.add(); + a1_main.b1_0.c2_0.add(); + a1_main.b1_0.c3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b1_0.c1_0.sum+a1_main.b1_0.c2_0.sum+a1_main.b1_0.c3_0.sum); + + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b1_0.c1_0.sum + a1_main.b1_0.c2_0.sum + a1_main.b1_0.c3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 5048) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00050_A1 { + Nocycle_a_00050_B1 b1_0; + Nocycle_a_00050_B2 b2_0; + Nocycle_a_00050_B3 b3_0; + Nocycle_a_00050_B4 b4_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00050_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } + } + + class Nocycle_a_00050_B1 { + Nocycle_a_00050_C1 c1_0; + Nocycle_a_00050_C2 c2_0; + Nocycle_a_00050_C3 c3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00050_B1(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } + } + + class Nocycle_a_00050_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00050_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00050_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00050_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00050_B4 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00050_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00050_C1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00050_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00050_C2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00050_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00050_C3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00050_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +class ThreadRc_00060B extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00060_A1 a1_main = new Nocycle_a_00060_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00060_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00060_B2("b2_0"); + a1_main.b2_0.c1_0 = new Nocycle_a_00060_C1("c1_0"); + a1_main.b2_0.c2_0 = new Nocycle_a_00060_C2("c2_0"); + a1_main.b2_0.c3_0 = new Nocycle_a_00060_C3("c3_0"); + a1_main.b3_0 = new Nocycle_a_00060_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00060_B4("b4_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b2_0.c1_0.add(); + a1_main.b2_0.c2_0.add(); + a1_main.b2_0.c3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b2_0.c1_0.sum+a1_main.b2_0.c2_0.sum+a1_main.b2_0.c3_0.sum); + + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b2_0.c1_0.sum + a1_main.b2_0.c2_0.sum + a1_main.b2_0.c3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 5047) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00060_A1 { + Nocycle_a_00060_B1 b1_0; + Nocycle_a_00060_B2 b2_0; + Nocycle_a_00060_B3 b3_0; + Nocycle_a_00060_B4 b4_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00060_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } + } + + class Nocycle_a_00060_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00060_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00060_B2 { + Nocycle_a_00060_C1 c1_0; + Nocycle_a_00060_C2 c2_0; + Nocycle_a_00060_C3 c3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00060_B2(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } + } + + class Nocycle_a_00060_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00060_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00060_B4 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00060_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00060_C1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00060_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00060_C2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00060_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00060_C3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00060_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +class ThreadRc_00070B extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00070_A1 a1_main = new Nocycle_a_00070_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00070_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00070_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00070_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00070_B4("b4_0"); + a1_main.b4_0.c1_0 = new Nocycle_a_00070_C1("c1_0"); + a1_main.b4_0.c2_0 = new Nocycle_a_00070_C2("c2_0"); + a1_main.b4_0.c3_0 = new Nocycle_a_00070_C3("c3_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b4_0.c1_0.add(); + a1_main.b4_0.c2_0.add(); + a1_main.b4_0.c3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b4_0.c1_0.sum+a1_main.b4_0.c2_0.sum+a1_main.b4_0.c3_0.sum); + + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b4_0.c1_0.sum + a1_main.b4_0.c2_0.sum + a1_main.b4_0.c3_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 5045) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00070_A1 { + Nocycle_a_00070_B1 b1_0; + Nocycle_a_00070_B2 b2_0; + Nocycle_a_00070_B3 b3_0; + Nocycle_a_00070_B4 b4_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00070_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } + } + + class Nocycle_a_00070_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00070_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00070_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00070_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00070_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00070_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00070_B4 { + Nocycle_a_00070_C1 c1_0; + Nocycle_a_00070_C2 c2_0; + Nocycle_a_00070_C3 c3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00070_B4(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } + } + + class Nocycle_a_00070_C1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00070_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00070_C2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00070_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00070_C3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00070_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +class ThreadRc_00080B extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00080_A1 a1_main = new Nocycle_a_00080_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00080_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_a_00080_C1("c1_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b1_0.c1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b1_0.c1_0.sum); + + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b1_0.c1_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1406) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00080_A1 { + Nocycle_a_00080_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00080_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00080_B1 { + Nocycle_a_00080_C1 c1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00080_B1(String strObjectName) { + c1_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } + } + + class Nocycle_a_00080_C1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00080_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +class ThreadRc_00090B extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00090_A1 a1_main = new Nocycle_a_00090_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00090_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_a_00090_C1("c1_0"); + a1_main.b1_0.c1_0.d1_0 = new Nocycle_a_00090_D1("d1_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b1_0.c1_0.add(); + a1_main.b1_0.c1_0.d1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b1_0.c1_0.sum+a1_main.b1_0.c1_0.d1_0.sum); + + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b1_0.c1_0.sum + a1_main.b1_0.c1_0.d1_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 2308) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00090_A1 { + Nocycle_a_00090_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00090_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00090_B1 { + Nocycle_a_00090_C1 c1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00090_B1(String strObjectName) { + c1_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } + } + + class Nocycle_a_00090_C1 { + Nocycle_a_00090_D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00090_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + d1_0.a; + } + } + + class Nocycle_a_00090_D1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00090_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +class ThreadRc_00100B extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00100_A1 a1_main = new Nocycle_a_00100_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00100_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_a_00100_C1("c1_0"); + a1_main.b1_0.c1_0.d1_0 = new Nocycle_a_00100_D1("d1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0 = new Nocycle_a_00100_E1("e1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0 = new Nocycle_a_00100_F1("f1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0 = new Nocycle_a_00100_G1("g1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0 = new Nocycle_a_00100_H1("h1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0 = new Nocycle_a_00100_I1("i1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0 = new Nocycle_a_00100_J1("j1_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b1_0.c1_0.add(); + a1_main.b1_0.c1_0.d1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.add(); +// System.out.printf("a=%d\n",a1_main.sum); +// System.out.printf("b=%d\n",a1_main.b1_0.sum); +// System.out.printf("c=%d\n",a1_main.b1_0.c1_0.sum); +// System.out.printf("d=%d\n",a1_main.b1_0.c1_0.d1_0.sum); +// System.out.printf("e=%d\n",a1_main.b1_0.c1_0.d1_0.e1_0.sum); +// System.out.printf("f=%d\n",a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.sum); +// System.out.printf("g=%d\n",a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.sum); +// System.out.printf("h=%d\n",a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.sum); +// System.out.printf("i=%d\n",a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.sum); +// System.out.printf("j=%d\n",a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.sum); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b1_0.c1_0.sum+a1_main.b1_0.c1_0.d1_0.sum+a1_main.b1_0.c1_0.d1_0.e1_0.sum+a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.sum+a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.sum+a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.sum+a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.sum+a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.sum); + + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b1_0.c1_0.sum + a1_main.b1_0.c1_0.d1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.sum; + + //System.out.println("RC-Testing_Result="+result); + + if (result == 11920) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00100_A1 { + Nocycle_a_00100_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00100_B1 { + Nocycle_a_00100_C1 c1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_B1(String strObjectName) { + c1_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } + } + + class Nocycle_a_00100_C1 { + Nocycle_a_00100_D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + d1_0.a; + } + } + + class Nocycle_a_00100_D1 { + Nocycle_a_00100_E1 e1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_D1(String strObjectName) { + e1_0 = null; + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + + void add() { + sum = a + e1_0.a; + } + } + + class Nocycle_a_00100_E1 { + Nocycle_a_00100_F1 f1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_E1(String strObjectName) { + f1_0 = null; + a = 501; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_E1_"+strObjectName); + } + + void add() { + sum = a + f1_0.a; + } + } + + class Nocycle_a_00100_F1 { + Nocycle_a_00100_G1 g1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_F1(String strObjectName) { + g1_0 = null; + a = 601; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_F1_"+strObjectName); + } + + void add() { + sum = a + g1_0.a; + } + } + + class Nocycle_a_00100_G1 { + Nocycle_a_00100_H1 h1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_G1(String strObjectName) { + h1_0 = null; + a = 701; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_G1_"+strObjectName); + } + + void add() { + sum = a + h1_0.a; + } + } + + class Nocycle_a_00100_H1 { + Nocycle_a_00100_I1 i1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_H1(String strObjectName) { + i1_0 = null; + a = 801; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_H1_"+strObjectName); + } + + void add() { + sum = a + i1_0.a; + } + } + + class Nocycle_a_00100_I1 { + Nocycle_a_00100_J1 j1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_I1(String strObjectName) { + j1_0 = null; + a = 901; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_I1_"+strObjectName); + } + + void add() { + sum = a + j1_0.a; + } + } + + class Nocycle_a_00100_J1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00100_J1(String strObjectName) { + a = 1001; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_J1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +class ThreadRc_00110B extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00110_A1 a1_main = new Nocycle_a_00110_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00110_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00110_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00110_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00110_B4("b4_0"); + a1_main.b1_0.d1_0 = new Nocycle_a_00110_D1("d1_0"); + a1_main.b2_0.c2_0 = new Nocycle_a_00110_C2("c2_0"); + a1_main.b3_0.c1_0 = new Nocycle_a_00110_C1("c1_0"); + a1_main.b4_0.c3_0 = new Nocycle_a_00110_C3("c3_0"); + a1_main.b3_0.c1_0.d2_0 = new Nocycle_a_00110_D2("d2_0"); + a1_main.b2_0.c2_0.d3_0 = new Nocycle_a_00110_D3("d3_0"); + a1_main.b2_0.c2_0.d4_0 = new Nocycle_a_00110_D4("d4_0"); + a1_main.d5_0 = new Nocycle_a_00110_D5("d5_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b2_0.c2_0.add(); + a1_main.b3_0.c1_0.add(); + a1_main.b4_0.c3_0.add(); + a1_main.b1_0.d1_0.add(); + a1_main.b3_0.c1_0.d2_0.add(); + a1_main.b2_0.c2_0.d3_0.add(); + a1_main.b2_0.c2_0.d4_0.add(); + a1_main.d5_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b2_0.c2_0.sum+a1_main.b3_0.c1_0.sum+a1_main.b4_0.c3_0.sum+a1_main.b1_0.d1_0.sum+a1_main.b3_0.c1_0.d2_0.sum+a1_main.b2_0.c2_0.d3_0.sum+a1_main.b2_0.c2_0.d4_0.sum+a1_main.d5_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b2_0.c2_0.sum + a1_main.b3_0.c1_0.sum + a1_main.b4_0.c3_0.sum + a1_main.b1_0.d1_0.sum + a1_main.b3_0.c1_0.d2_0.sum + a1_main.b2_0.c2_0.d3_0.sum + a1_main.b2_0.c2_0.d4_0.sum + a1_main.d5_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 9881) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00110_A1 { + Nocycle_a_00110_B1 b1_0; + Nocycle_a_00110_B2 b2_0; + Nocycle_a_00110_B3 b3_0; + Nocycle_a_00110_B4 b4_0; + Nocycle_a_00110_D5 d5_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + d5_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a + d5_0.a; + } + } + + class Nocycle_a_00110_B1 { + Nocycle_a_00110_D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + d1_0.a; + } + } + + class Nocycle_a_00110_B2 { + Nocycle_a_00110_C2 c2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_B2(String strObjectName) { + c2_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + c2_0.a; + } + } + + class Nocycle_a_00110_B3 { + Nocycle_a_00110_C1 c1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } + } + + class Nocycle_a_00110_B4 { + Nocycle_a_00110_C3 c3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_B4(String strObjectName) { + c3_0 = null; + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + + void add() { + sum = a + c3_0.a; + } + } + + class Nocycle_a_00110_C1 { + Nocycle_a_00110_D2 d2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_C1(String strObjectName) { + d2_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + d2_0.a; + } + } + + class Nocycle_a_00110_C2 { + Nocycle_a_00110_D3 d3_0; + Nocycle_a_00110_D4 d4_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_C2(String strObjectName) { + d3_0 = null; + d4_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + d3_0.a + d4_0.a; + } + } + + class Nocycle_a_00110_C3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00110_D1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00110_D2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00110_D3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00110_D4 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_D4(String strObjectName) { + a = 404; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D4_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00110_D5 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00110_D5(String strObjectName) { + a = 405; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D5_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +class ThreadRc_00120B extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00120_A1 a1_main = new Nocycle_a_00120_A1("a1_main"); + Nocycle_a_00120_A2 a2_main = new Nocycle_a_00120_A2("a2_main"); + a1_main.b1_0 = new Nocycle_a_00120_B1("b1_0"); + a2_main.b1_0 = new Nocycle_a_00120_B1("b1_0"); + a1_main.add(); + a2_main.add(); + a1_main.b1_0.add(); + a2_main.b1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a1_main.b1_0.sum); + + int result = a1_main.sum + a2_main.sum + a1_main.b1_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1007) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00120_A1 { + Nocycle_a_00120_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00120_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00120_A2 { + Nocycle_a_00120_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00120_A2(String strObjectName) { + b1_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00120_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00120_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +class ThreadRc_00130B extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00130_A1 a1_main = new Nocycle_a_00130_A1("a1_main"); + Nocycle_a_00130_A2 a2_main = new Nocycle_a_00130_A2("a2_main"); + Nocycle_a_00130_A3 a3_main = new Nocycle_a_00130_A3("a3_main"); + Nocycle_a_00130_A4 a4_main = new Nocycle_a_00130_A4("a4_main"); + Nocycle_a_00130_A5 a5_main = new Nocycle_a_00130_A5("a5_main"); + Nocycle_a_00130_A6 a6_main = new Nocycle_a_00130_A6("a6_main"); + Nocycle_a_00130_A7 a7_main = new Nocycle_a_00130_A7("a7_main"); + Nocycle_a_00130_A8 a8_main = new Nocycle_a_00130_A8("a8_main"); + Nocycle_a_00130_A9 a9_main = new Nocycle_a_00130_A9("a9_main"); + Nocycle_a_00130_A10 a10_main = new Nocycle_a_00130_A10("a10_main"); + a1_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a2_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a3_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a4_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a5_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a6_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a7_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a8_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a9_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a10_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a5_main.add(); + a6_main.add(); + a7_main.add(); + a8_main.add(); + a9_main.add(); + a10_main.add(); + a1_main.b1_0.add(); + a2_main.b1_0.add(); + a3_main.b1_0.add(); + a4_main.b1_0.add(); + a5_main.b1_0.add(); + a6_main.b1_0.add(); + a7_main.b1_0.add(); + a8_main.b1_0.add(); + a9_main.b1_0.add(); + a10_main.b1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a3_main.sum+a4_main.sum+a5_main.sum+a6_main.sum+a7_main.sum+a8_main.sum+a9_main.sum+a10_main.sum+a1_main.b1_0.sum); + + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a5_main.sum + a6_main.sum + a7_main.sum + a8_main.sum + a9_main.sum + a10_main.sum + a1_main.b1_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 3467) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00130_A1 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00130_A2 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A2(String strObjectName) { + b1_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00130_A3 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A3(String strObjectName) { + b1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00130_A4 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A4(String strObjectName) { + b1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00130_A5 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A5(String strObjectName) { + b1_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00130_A6 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A6(String strObjectName) { + b1_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00130_A7 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A7(String strObjectName) { + b1_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00130_A8 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A8(String strObjectName) { + b1_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00130_A9 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A9(String strObjectName) { + b1_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00130_A10 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_A10(String strObjectName) { + b1_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00130_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00130_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +class ThreadRc_00140B extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00140_A1 a1_main = new Nocycle_a_00140_A1("a1_main"); + Nocycle_a_00140_A2 a2_main = new Nocycle_a_00140_A2("a2_main"); + a1_main.b1_0 = new Nocycle_a_00140_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00140_B2("b2_0"); + a2_main.b1_0 = new Nocycle_a_00140_B1("b1_0"); + a1_main.add(); + a2_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a2_main.b1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum); + + int result = a1_main.sum + a2_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1613) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00140_A1 { + Nocycle_a_00140_B1 b1_0; + Nocycle_a_00140_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00140_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + + class Nocycle_a_00140_A2 { + Nocycle_a_00140_B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00140_A2(String strObjectName) { + b1_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_00140_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00140_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00140_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00140_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +class ThreadRc_00150B extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00150_A1 a1_main = new Nocycle_a_00150_A1("a1_main"); + Nocycle_a_00150_A2 a2_main = new Nocycle_a_00150_A2("a2_main"); + a1_main.b1_0 = new Nocycle_a_00150_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00150_B2("b2_0"); + a2_main.b1_0 = new Nocycle_a_00150_B1("b1_0"); + a2_main.b2_0 = new Nocycle_a_00150_B2("b2_0"); + a1_main.add(); + a2_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a2_main.b1_0.add(); + a2_main.b2_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum); + + int result = a1_main.sum + a2_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1815) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00150_A1 { + Nocycle_a_00150_B1 b1_0; + Nocycle_a_00150_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00150_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + + class Nocycle_a_00150_A2 { + Nocycle_a_00150_B1 b1_0; + Nocycle_a_00150_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00150_A2(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + + class Nocycle_a_00150_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00150_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00150_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00150_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +class ThreadRc_00160B extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00160_A1 a1_main = new Nocycle_a_00160_A1("a1_main"); + Nocycle_a_00160_A2 a2_main = new Nocycle_a_00160_A2("a2_main"); + Nocycle_a_00160_A3 a3_main = new Nocycle_a_00160_A3("a3_main"); + Nocycle_a_00160_A4 a4_main = new Nocycle_a_00160_A4("a4_main"); + a1_main.b1_0 = new Nocycle_a_00160_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00160_B2("b2_0"); + a2_main.b1_0 = new Nocycle_a_00160_B1("b1_0"); + a2_main.b2_0 = new Nocycle_a_00160_B2("b2_0"); + a3_main.b1_0 = new Nocycle_a_00160_B1("b1_0"); + a3_main.b2_0 = new Nocycle_a_00160_B2("b2_0"); + a4_main.b1_0 = new Nocycle_a_00160_B1("b1_0"); + a4_main.b2_0 = new Nocycle_a_00160_B2("b2_0"); + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a2_main.b1_0.add(); + a2_main.b2_0.add(); + a3_main.b1_0.add(); + a3_main.b2_0.add(); + a4_main.b1_0.add(); + a4_main.b2_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a3_main.sum+a4_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum); + + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 2828) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00160_A1 { + Nocycle_a_00160_B1 b1_0; + Nocycle_a_00160_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00160_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + + class Nocycle_a_00160_A2 { + Nocycle_a_00160_B1 b1_0; + Nocycle_a_00160_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00160_A2(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + + class Nocycle_a_00160_A3 { + Nocycle_a_00160_B1 b1_0; + Nocycle_a_00160_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00160_A3(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + + class Nocycle_a_00160_A4 { + Nocycle_a_00160_B1 b1_0; + Nocycle_a_00160_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00160_A4(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + + class Nocycle_a_00160_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00160_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00160_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00160_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +class ThreadRc_00170B extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00170_A1 a1_main = new Nocycle_a_00170_A1("a1_main"); + Nocycle_a_00170_A2 a2_main = new Nocycle_a_00170_A2("a2_main"); + Nocycle_a_00170_A3 a3_main = new Nocycle_a_00170_A3("a3_main"); + Nocycle_a_00170_A4 a4_main = new Nocycle_a_00170_A4("a4_main"); + a1_main.b1_0 = new Nocycle_a_00170_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00170_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00170_B3("b3_0"); + a2_main.b1_0 = new Nocycle_a_00170_B1("b1_0"); + a2_main.b2_0 = new Nocycle_a_00170_B2("b2_0"); + a2_main.b3_0 = new Nocycle_a_00170_B3("b3_0"); + a3_main.b1_0 = new Nocycle_a_00170_B1("b1_0"); + a3_main.b2_0 = new Nocycle_a_00170_B2("b2_0"); + a3_main.b3_0 = new Nocycle_a_00170_B3("b3_0"); + a4_main.b1_0 = new Nocycle_a_00170_B1("b1_0"); + a4_main.b2_0 = new Nocycle_a_00170_B2("b2_0"); + a4_main.b3_0 = new Nocycle_a_00170_B3("b3_0"); + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a2_main.b1_0.add(); + a2_main.b2_0.add(); + a2_main.b3_0.add(); + a3_main.b1_0.add(); + a3_main.b2_0.add(); + a3_main.b3_0.add(); + a4_main.b1_0.add(); + a4_main.b2_0.add(); + a4_main.b3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a3_main.sum+a4_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum); + + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 4046) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00170_A1 { + Nocycle_a_00170_B1 b1_0; + Nocycle_a_00170_B2 b2_0; + Nocycle_a_00170_B3 b3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00170_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } + } + + class Nocycle_a_00170_A2 { + Nocycle_a_00170_B1 b1_0; + Nocycle_a_00170_B2 b2_0; + Nocycle_a_00170_B3 b3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00170_A2(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } + } + + class Nocycle_a_00170_A3 { + Nocycle_a_00170_B1 b1_0; + Nocycle_a_00170_B2 b2_0; + Nocycle_a_00170_B3 b3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00170_A3(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } + } + + class Nocycle_a_00170_A4 { + Nocycle_a_00170_B1 b1_0; + Nocycle_a_00170_B2 b2_0; + Nocycle_a_00170_B3 b3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00170_A4(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } + } + + class Nocycle_a_00170_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00170_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00170_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00170_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00170_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00170_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + + +class ThreadRc_00180B extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00180_A1 a1_main = new Nocycle_a_00180_A1("a1_main"); + Nocycle_a_00180_A2 a2_main = new Nocycle_a_00180_A2("a2_main"); + Nocycle_a_00180_A3 a3_main = new Nocycle_a_00180_A3("a3_main"); + Nocycle_a_00180_A4 a4_main = new Nocycle_a_00180_A4("a4_main"); + a1_main.b1_0 = new Nocycle_a_00180_B1("b1_0"); + a1_main.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a1_main.b1_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + + a2_main.b2_0 = new Nocycle_a_00180_B2("b2_0"); + a2_main.b2_0.c1_0 = new Nocycle_a_00180_C1("c1_0"); + a2_main.b2_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a2_main.b2_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a2_main.b2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + + a3_main.b2_0 = new Nocycle_a_00180_B2("b2_0"); + a3_main.b2_0.c1_0 = new Nocycle_a_00180_C1("c1_0"); + a3_main.b2_0.c1_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a3_main.b2_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a3_main.b2_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a3_main.b2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + + a3_main.c2_0 = new Nocycle_a_00180_C2("c2_0"); + a3_main.c2_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a3_main.c2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + + a4_main.b3_0 = new Nocycle_a_00180_B3("b3_0"); + a4_main.b3_0.c1_0 = new Nocycle_a_00180_C1("c1_0"); + a4_main.b3_0.c1_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a4_main.c2_0 = new Nocycle_a_00180_C2("c2_0"); + a4_main.c2_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a4_main.c2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main.b1_0.add(); + a1_main.d1_0.add(); + a1_main.b1_0.d2_0.add(); + + a2_main.b2_0.add(); + a2_main.b2_0.c1_0.add(); + a2_main.b2_0.d1_0.add(); + a2_main.b2_0.d2_0.add(); + a2_main.b2_0.d3_0.add(); + a2_main.b2_0.c1_0.d1_0.add(); + + a3_main.b2_0.add(); + a3_main.b2_0.c1_0.add(); + a3_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.d1_0.add(); + a3_main.b2_0.d2_0.add(); + a3_main.b2_0.d3_0.add(); + + a3_main.c2_0.add(); + a3_main.c2_0.d2_0.add(); + a3_main.c2_0.d3_0.add(); + + a4_main.b3_0.add(); + a4_main.b3_0.c1_0.add(); + a4_main.b3_0.c1_0.d1_0.add(); + a4_main.c2_0.add(); + a4_main.c2_0.d2_0.add(); + a4_main.c2_0.d3_0.add(); + +// System.out.printf("a1_main.sum=%d\n",a1_main.sum); +// System.out.printf("a2_main.sum=%d\n",a2_main.sum); +// System.out.printf("a3_main.sum=%d\n",a3_main.sum); +// System.out.printf("a4_main.sum=%d\n",a4_main.sum); +// System.out.printf("a1_main.b1_0.sum=%d\n",a1_main.b1_0.sum); +// System.out.printf("a2_main.b2_0.sum=%d\n",a2_main.b2_0.sum); +// System.out.printf("a4_main.b3_0.sum=%d\n",a4_main.b3_0.sum); +// System.out.printf("a2_main.b2_0.c1_0.sum=%d\n",a2_main.b2_0.c1_0.sum); +// System.out.printf("a3_main.c2_0.sum=%d\n",a3_main.c2_0.sum); +// System.out.printf("a1_main.d1_0.sum=%d\n",a1_main.d1_0.sum); +// System.out.printf("a3_main.c2_0.d2_0.sum=%d\n",a3_main.c2_0.d2_0.sum); +// System.out.printf("a3_main.c2_0.d3_0.sum=%d\n",a3_main.c2_0.d3_0.sum); + + +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a3_main.sum+a4_main.sum+a1_main.b1_0.sum+a2_main.b2_0.sum+a4_main.b3_0.sum+a2_main.b2_0.c1_0.sum+a3_main.c2_0.sum+a1_main.d1_0.sum+a3_main.c2_0.d2_0.sum+a3_main.c2_0.d3_0.sum); + + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main.b1_0.sum + a2_main.b2_0.sum + a4_main.b3_0.sum + a2_main.b2_0.c1_0.sum + a3_main.c2_0.sum + a1_main.d1_0.sum + a3_main.c2_0.d2_0.sum + a3_main.c2_0.d3_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 9260) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00180_A1 { + Nocycle_a_00180_B1 b1_0; + Nocycle_a_00180_D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + d1_0.a; + } + } + + class Nocycle_a_00180_A2 { + Nocycle_a_00180_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b2_0.a; + } + } + + class Nocycle_a_00180_A3 { + Nocycle_a_00180_B2 b2_0; + Nocycle_a_00180_C2 c2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + b2_0.a + c2_0.a; + } + } + + class Nocycle_a_00180_A4 { + Nocycle_a_00180_B3 b3_0; + Nocycle_a_00180_C2 c2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + b3_0.a + c2_0.a; + } + } + + class Nocycle_a_00180_B1 { + Nocycle_a_00180_D2 d2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + d2_0.a; + } + } + + class Nocycle_a_00180_B2 { + Nocycle_a_00180_C1 c1_0; + Nocycle_a_00180_D1 d1_0; + Nocycle_a_00180_D2 d2_0; + Nocycle_a_00180_D3 d3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } + } + + class Nocycle_a_00180_B3 { + Nocycle_a_00180_C1 c1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } + } + + class Nocycle_a_00180_C1 { + Nocycle_a_00180_D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + d1_0.a; + } + } + + class Nocycle_a_00180_C2 { + Nocycle_a_00180_D2 d2_0; + Nocycle_a_00180_D3 d3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + d2_0.a + d3_0.a; + } + } + + class Nocycle_a_00180_D1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00180_D2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00180_D3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00180_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +public class Nocycle_am_00190 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_00010B A1_00010 = new ThreadRc_00010B(); + ThreadRc_00010B A2_00010 = new ThreadRc_00010B(); + ThreadRc_00020B A1_00020 = new ThreadRc_00020B(); + ThreadRc_00020B A2_00020 = new ThreadRc_00020B(); + ThreadRc_00030B A1_00030 = new ThreadRc_00030B(); + ThreadRc_00030B A2_00030 = new ThreadRc_00030B(); + ThreadRc_00040B A1_00040 = new ThreadRc_00040B(); + ThreadRc_00040B A2_00040 = new ThreadRc_00040B(); + ThreadRc_00050B A1_00050 = new ThreadRc_00050B(); + ThreadRc_00050B A2_00050 = new ThreadRc_00050B(); + ThreadRc_00060B A1_00060 = new ThreadRc_00060B(); + ThreadRc_00060B A2_00060 = new ThreadRc_00060B(); + ThreadRc_00070B A1_00070 = new ThreadRc_00070B(); + ThreadRc_00070B A2_00070 = new ThreadRc_00070B(); + ThreadRc_00080B A1_00080 = new ThreadRc_00080B(); + ThreadRc_00080B A2_00080 = new ThreadRc_00080B(); + ThreadRc_00090B A1_00090 = new ThreadRc_00090B(); + ThreadRc_00090B A2_00090 = new ThreadRc_00090B(); + ThreadRc_00100B A1_00100 = new ThreadRc_00100B(); + ThreadRc_00100B A2_00100 = new ThreadRc_00100B(); + ThreadRc_00110B A1_00110 = new ThreadRc_00110B(); + ThreadRc_00110B A2_00110 = new ThreadRc_00110B(); + ThreadRc_00120B A1_00120 = new ThreadRc_00120B(); + ThreadRc_00120B A2_00120 = new ThreadRc_00120B(); + ThreadRc_00130B A1_00130 = new ThreadRc_00130B(); + ThreadRc_00130B A2_00130 = new ThreadRc_00130B(); + ThreadRc_00140B A1_00140 = new ThreadRc_00140B(); + ThreadRc_00140B A2_00140 = new ThreadRc_00140B(); + ThreadRc_00150B A1_00150 = new ThreadRc_00150B(); + ThreadRc_00150B A2_00150 = new ThreadRc_00150B(); + ThreadRc_00160B A1_00160 = new ThreadRc_00160B(); + ThreadRc_00160B A2_00160 = new ThreadRc_00160B(); + ThreadRc_00170B A1_00170 = new ThreadRc_00170B(); + ThreadRc_00170B A2_00170 = new ThreadRc_00170B(); + ThreadRc_00180B A1_00180 = new ThreadRc_00180B(); + ThreadRc_00180B A2_00180 = new ThreadRc_00180B(); + A1_00010.start(); + A2_00010.start(); + A1_00020.start(); + A2_00020.start(); + A1_00030.start(); + A2_00030.start(); + A1_00040.start(); + A2_00040.start(); + A1_00050.start(); + A2_00050.start(); + A1_00060.start(); + A2_00060.start(); + A1_00070.start(); + A2_00070.start(); + A1_00080.start(); + A2_00080.start(); + A1_00090.start(); + A2_00090.start(); + A1_00100.start(); + A2_00100.start(); + A1_00110.start(); + A2_00110.start(); + A1_00120.start(); + A2_00120.start(); + A1_00130.start(); + A2_00130.start(); + A1_00140.start(); + A2_00140.start(); + A1_00150.start(); + A2_00150.start(); + A1_00160.start(); + A2_00160.start(); + A1_00170.start(); + A2_00170.start(); + A1_00180.start(); + A2_00180.start(); + try { + A1_00010.join(); + A2_00010.join(); + A1_00020.join(); + A2_00020.join(); + A1_00030.join(); + A2_00030.join(); + A1_00040.join(); + A2_00040.join(); + A1_00050.join(); + A2_00050.join(); + A1_00060.join(); + A2_00060.join(); + A1_00070.join(); + A2_00070.join(); + A1_00080.join(); + A2_00080.join(); + A1_00090.join(); + A2_00090.join(); + A1_00100.join(); + A2_00100.join(); + A1_00110.join(); + A2_00110.join(); + A1_00120.join(); + A2_00120.join(); + A1_00130.join(); + A2_00130.join(); + A1_00140.join(); + A2_00140.join(); + A1_00150.join(); + A2_00150.join(); + A1_00160.join(); + A2_00160.join(); + A1_00170.join(); + A2_00170.join(); + A1_00180.join(); + A2_00180.join(); + } catch (InterruptedException e) { + } + if (A1_00010.check() && A2_00010.check() && A1_00020.check() && A2_00020.check() && A1_00030.check() && A2_00030.check() && A1_00040.check() && A2_00040.check() && A1_00050.check() && A2_00050.check() && A1_00060.check() && A2_00060.check() && A1_00070.check() && A2_00070.check() && A1_00080.check() && A2_00080.check() && A1_00090.check() && A2_00090.check() && A1_00100.check() && A2_00100.check() && A1_00110.check() && A2_00110.check() && A1_00120.check() && A2_00120.check() && A1_00130.check() && A2_00130.check() && A1_00140.check() && A2_00140.check() && A1_00150.check() && A2_00150.check() && A1_00160.check() && A2_00160.check() && A1_00170.check() && A2_00170.check() && A1_00180.check() && A2_00180.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0225-rc-function-RC_Thread01-Nocycle_am_2_00010/Nocycle_am_2_00010.java b/test/testsuite/ouroboros/rc_test/RC0225-rc-function-RC_Thread01-Nocycle_am_2_00010/Nocycle_am_2_00010.java new file mode 100755 index 0000000000000000000000000000000000000000..19ca946aa8a8785481b22ff78e61e08a3a165472 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0225-rc-function-RC_Thread01-Nocycle_am_2_00010/Nocycle_am_2_00010.java @@ -0,0 +1,178 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Nocycle_am_2_00010.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Nocycle_a_2_00010 in RC测试-No-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_am_2_00010.java + *- @ExecuteClass: Nocycle_am_2_00010 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Nocycle_am_2_00010 extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_2_00010_A1 a1_main = new Nocycle_a_2_00010_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_2_00010_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_2_00010_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_2_00010_B3("b3_0"); + Nocycle_a_2_00010_A2 a2_main = new Nocycle_a_2_00010_A2("a2_main"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a2_main.add(); + // System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a2_main.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1939) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_2_00010_A1 { + Nocycle_a_2_00010_B1 b1_0; + Nocycle_a_2_00010_B2 b2_0; + Nocycle_a_2_00010_B3 b3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00010_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } + } + + class Nocycle_a_2_00010_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00010_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_2_00010_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00010_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_2_00010_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00010_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_2_00010_A2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00010_A2(String strObjectName) { + a = 10; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + + +public class Nocycle_am_2_00010 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Nocycle_am_2_00010 A1_Nocycle_am_2_00010 = new ThreadRc_Nocycle_am_2_00010(); + ThreadRc_Nocycle_am_2_00010 A2_Nocycle_am_2_00010 = new ThreadRc_Nocycle_am_2_00010(); + ThreadRc_Nocycle_am_2_00010 A3_Nocycle_am_2_00010 = new ThreadRc_Nocycle_am_2_00010(); + ThreadRc_Nocycle_am_2_00010 A4_Nocycle_am_2_00010 = new ThreadRc_Nocycle_am_2_00010(); + ThreadRc_Nocycle_am_2_00010 A5_Nocycle_am_2_00010 = new ThreadRc_Nocycle_am_2_00010(); + ThreadRc_Nocycle_am_2_00010 A6_Nocycle_am_2_00010 = new ThreadRc_Nocycle_am_2_00010(); + + A1_Nocycle_am_2_00010.start(); + A2_Nocycle_am_2_00010.start(); + A3_Nocycle_am_2_00010.start(); + A4_Nocycle_am_2_00010.start(); + A5_Nocycle_am_2_00010.start(); + A6_Nocycle_am_2_00010.start(); + + try { + A1_Nocycle_am_2_00010.join(); + A2_Nocycle_am_2_00010.join(); + A3_Nocycle_am_2_00010.join(); + A4_Nocycle_am_2_00010.join(); + A5_Nocycle_am_2_00010.join(); + A6_Nocycle_am_2_00010.join(); + + } catch (InterruptedException e) { + } + if (A1_Nocycle_am_2_00010.check() && A2_Nocycle_am_2_00010.check() && A3_Nocycle_am_2_00010.check() && A4_Nocycle_am_2_00010.check() && A5_Nocycle_am_2_00010.check() && A6_Nocycle_am_2_00010.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0226-rc-function-RC_Thread01-Nocycle_am_2_00020/Nocycle_am_2_00020.java b/test/testsuite/ouroboros/rc_test/RC0226-rc-function-RC_Thread01-Nocycle_am_2_00020/Nocycle_am_2_00020.java new file mode 100755 index 0000000000000000000000000000000000000000..37900c284ae9b4943ed20edea1529f9cd5e95f04 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0226-rc-function-RC_Thread01-Nocycle_am_2_00020/Nocycle_am_2_00020.java @@ -0,0 +1,761 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Nocycle_am_2_00020.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Nocycle_a_2_00020 in RC测试-No-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_am_2_00020.java + *- @ExecuteClass: Nocycle_am_2_00020 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Nocycle_am_2_00020 extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_2_00020_A1 a1_main = new Nocycle_a_2_00020_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_2_00020_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_2_00020_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_2_00020_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_2_00020_B4("b4_0"); + a1_main.b4_0.c1_0 = new Nocycle_a_2_00020_C1("c1_0"); + a1_main.b4_0.c2_0 = new Nocycle_a_2_00020_C2("c2_0"); + a1_main.b4_0.c3_0 = new Nocycle_a_2_00020_C3("c3_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b4_0.c1_0.add(); + a1_main.b4_0.c2_0.add(); + a1_main.b4_0.c3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b4_0.c1_0.sum+a1_main.b4_0.c2_0.sum+a1_main.b4_0.c3_0.sum); + + int result1 = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b4_0.c1_0.sum + a1_main.b4_0.c2_0.sum + a1_main.b4_0.c3_0.sum; + //System.out.println("RC-Testing_Result="+result1); + Nocycle_a_2_00020_2A1 a1_main2 = new Nocycle_a_2_00020_2A1("a1_main2"); + a1_main2.b1_0 = new Nocycle_a_2_00020_2B1("b1_0"); + a1_main2.b1_0.c1_0 = new Nocycle_a_2_00020_2C1("c1_0"); + a1_main2.b1_0.c1_0.d1_0 = new Nocycle_a_2_00020_2D1("d1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0 = new Nocycle_a_2_00020_2E1("e1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0 = new Nocycle_a_2_00020_2F1("f1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0 = new Nocycle_a_2_00020_2G1("g1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0 = new Nocycle_a_2_00020_2H1("h1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0 = new Nocycle_a_2_00020_2I1("i1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0 = new Nocycle_a_2_00020_2J1("j1_0"); + a1_main2.add(); + a1_main2.b1_0.add(); + a1_main2.b1_0.c1_0.add(); + a1_main2.b1_0.c1_0.d1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.add(); + + int result2 = a1_main2.sum + a1_main2.b1_0.sum + a1_main2.b1_0.c1_0.sum + a1_main2.b1_0.c1_0.d1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.sum; + + Nocycle_a_2_00020_3A1 a1_main3 = new Nocycle_a_2_00020_3A1("a1_main3"); + Nocycle_a_2_00020_3A2 a2_main = new Nocycle_a_2_00020_3A2("a2_main"); + Nocycle_a_2_00020_3A3 a3_main = new Nocycle_a_2_00020_3A3("a3_main"); + Nocycle_a_2_00020_3A4 a4_main = new Nocycle_a_2_00020_3A4("a4_main"); + a1_main3.b1_0 = new Nocycle_a_2_00020_3B1("b1_0"); + a1_main3.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a1_main3.b1_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + + a2_main.b2_0 = new Nocycle_a_2_00020_3B2("b2_0"); + a2_main.b2_0.c1_0 = new Nocycle_a_2_00020_3C1("c1_0"); + a2_main.b2_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a2_main.b2_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a2_main.b2_0.d3_0 = new Nocycle_a_2_00020_3D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + + a3_main.b2_0 = new Nocycle_a_2_00020_3B2("b2_0"); + a3_main.b2_0.c1_0 = new Nocycle_a_2_00020_3C1("c1_0"); + a3_main.b2_0.c1_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a3_main.b2_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a3_main.b2_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a3_main.b2_0.d3_0 = new Nocycle_a_2_00020_3D3("d3_0"); + + a3_main.c2_0 = new Nocycle_a_2_00020_3C2("c2_0"); + a3_main.c2_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a3_main.c2_0.d3_0 = new Nocycle_a_2_00020_3D3("d3_0"); + + a4_main.b3_0 = new Nocycle_a_2_00020_3B3("b3_0"); + a4_main.b3_0.c1_0 = new Nocycle_a_2_00020_3C1("c1_0"); + a4_main.b3_0.c1_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a4_main.c2_0 = new Nocycle_a_2_00020_3C2("c2_0"); + a4_main.c2_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a4_main.c2_0.d3_0 = new Nocycle_a_2_00020_3D3("d3_0"); + + a1_main3.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main3.b1_0.add(); + a1_main3.d1_0.add(); + a1_main3.b1_0.d2_0.add(); + + a2_main.b2_0.add(); + a2_main.b2_0.c1_0.add(); + a2_main.b2_0.d1_0.add(); + a2_main.b2_0.d2_0.add(); + a2_main.b2_0.d3_0.add(); + a2_main.b2_0.c1_0.d1_0.add(); + + a3_main.b2_0.add(); + a3_main.b2_0.c1_0.add(); + a3_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.d1_0.add(); + a3_main.b2_0.d2_0.add(); + a3_main.b2_0.d3_0.add(); + + a3_main.c2_0.add(); + a3_main.c2_0.d2_0.add(); + a3_main.c2_0.d3_0.add(); + + a4_main.b3_0.add(); + a4_main.b3_0.c1_0.add(); + a4_main.b3_0.c1_0.d1_0.add(); + a4_main.c2_0.add(); + a4_main.c2_0.d2_0.add(); + a4_main.c2_0.d3_0.add(); + + + int result3 = a1_main3.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main3.b1_0.sum + a2_main.b2_0.sum + a4_main.b3_0.sum + a2_main.b2_0.c1_0.sum + a3_main.c2_0.sum + a1_main3.d1_0.sum + a3_main.c2_0.d2_0.sum + a3_main.c2_0.d3_0.sum; + + int result = result1 + result2 + result3; + + if (result == 26225) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_2_00020_A1 { + Nocycle_a_2_00020_B1 b1_0; + Nocycle_a_2_00020_B2 b2_0; + Nocycle_a_2_00020_B3 b3_0; + Nocycle_a_2_00020_B4 b4_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } + } + + class Nocycle_a_2_00020_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_2_00020_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_2_00020_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_2_00020_B4 { + Nocycle_a_2_00020_C1 c1_0; + Nocycle_a_2_00020_C2 c2_0; + Nocycle_a_2_00020_C3 c3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_B4(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } + } + + class Nocycle_a_2_00020_C1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_2_00020_C2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_2_00020_C3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_2_00020_2A1 { + Nocycle_a_2_00020_2B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_2_00020_2B1 { + Nocycle_a_2_00020_2C1 c1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2B1(String strObjectName) { + c1_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } + } + + class Nocycle_a_2_00020_2C1 { + Nocycle_a_2_00020_2D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + d1_0.a; + } + } + + class Nocycle_a_2_00020_2D1 { + Nocycle_a_2_00020_2E1 e1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2D1(String strObjectName) { + e1_0 = null; + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + + void add() { + sum = a + e1_0.a; + } + } + + class Nocycle_a_2_00020_2E1 { + Nocycle_a_2_00020_2F1 f1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2E1(String strObjectName) { + f1_0 = null; + a = 501; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_E1_"+strObjectName); + } + + void add() { + sum = a + f1_0.a; + } + } + + class Nocycle_a_2_00020_2F1 { + Nocycle_a_2_00020_2G1 g1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2F1(String strObjectName) { + g1_0 = null; + a = 601; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_F1_"+strObjectName); + } + + void add() { + sum = a + g1_0.a; + } + } + + class Nocycle_a_2_00020_2G1 { + Nocycle_a_2_00020_2H1 h1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2G1(String strObjectName) { + h1_0 = null; + a = 701; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_G1_"+strObjectName); + } + + void add() { + sum = a + h1_0.a; + } + } + + class Nocycle_a_2_00020_2H1 { + Nocycle_a_2_00020_2I1 i1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2H1(String strObjectName) { + i1_0 = null; + a = 801; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_H1_"+strObjectName); + } + + void add() { + sum = a + i1_0.a; + } + } + + class Nocycle_a_2_00020_2I1 { + Nocycle_a_2_00020_2J1 j1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2I1(String strObjectName) { + j1_0 = null; + a = 901; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_I1_"+strObjectName); + } + + void add() { + sum = a + j1_0.a; + } + } + + class Nocycle_a_2_00020_2J1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2J1(String strObjectName) { + a = 1001; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_J1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_2_00020_3A1 { + Nocycle_a_2_00020_3B1 b1_0; + Nocycle_a_2_00020_3D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + d1_0.a; + } + } + + class Nocycle_a_2_00020_3A2 { + Nocycle_a_2_00020_3B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b2_0.a; + } + } + + class Nocycle_a_2_00020_3A3 { + Nocycle_a_2_00020_3B2 b2_0; + Nocycle_a_2_00020_3C2 c2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + b2_0.a + c2_0.a; + } + } + + class Nocycle_a_2_00020_3A4 { + Nocycle_a_2_00020_3B3 b3_0; + Nocycle_a_2_00020_3C2 c2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + b3_0.a + c2_0.a; + } + } + + class Nocycle_a_2_00020_3B1 { + Nocycle_a_2_00020_3D2 d2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + d2_0.a; + } + } + + class Nocycle_a_2_00020_3B2 { + Nocycle_a_2_00020_3C1 c1_0; + Nocycle_a_2_00020_3D1 d1_0; + Nocycle_a_2_00020_3D2 d2_0; + Nocycle_a_2_00020_3D3 d3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } + } + + class Nocycle_a_2_00020_3B3 { + Nocycle_a_2_00020_3C1 c1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } + } + + class Nocycle_a_2_00020_3C1 { + Nocycle_a_2_00020_3D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + d1_0.a; + } + } + + class Nocycle_a_2_00020_3C2 { + Nocycle_a_2_00020_3D2 d2_0; + Nocycle_a_2_00020_3D3 d3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + d2_0.a + d3_0.a; + } + } + + class Nocycle_a_2_00020_3D1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_2_00020_3D2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_2_00020_3D3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + + +public class Nocycle_am_2_00020 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Nocycle_am_2_00020 A1_Nocycle_am_2_00020 = new ThreadRc_Nocycle_am_2_00020(); + ThreadRc_Nocycle_am_2_00020 A2_Nocycle_am_2_00020 = new ThreadRc_Nocycle_am_2_00020(); + ThreadRc_Nocycle_am_2_00020 A3_Nocycle_am_2_00020 = new ThreadRc_Nocycle_am_2_00020(); + ThreadRc_Nocycle_am_2_00020 A4_Nocycle_am_2_00020 = new ThreadRc_Nocycle_am_2_00020(); + ThreadRc_Nocycle_am_2_00020 A5_Nocycle_am_2_00020 = new ThreadRc_Nocycle_am_2_00020(); + ThreadRc_Nocycle_am_2_00020 A6_Nocycle_am_2_00020 = new ThreadRc_Nocycle_am_2_00020(); + + A1_Nocycle_am_2_00020.start(); + A2_Nocycle_am_2_00020.start(); + A3_Nocycle_am_2_00020.start(); + A4_Nocycle_am_2_00020.start(); + A5_Nocycle_am_2_00020.start(); + A6_Nocycle_am_2_00020.start(); + + try { + A1_Nocycle_am_2_00020.join(); + A2_Nocycle_am_2_00020.join(); + A3_Nocycle_am_2_00020.join(); + A4_Nocycle_am_2_00020.join(); + A5_Nocycle_am_2_00020.join(); + A6_Nocycle_am_2_00020.join(); + + } catch (InterruptedException e) { + } + if (A1_Nocycle_am_2_00020.check() && A2_Nocycle_am_2_00020.check() && A3_Nocycle_am_2_00020.check() && A4_Nocycle_am_2_00020.check() && A5_Nocycle_am_2_00020.check() && A6_Nocycle_am_2_00020.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0227-rc-function-RC_Thread01-Nocycle_am_2_00030/Nocycle_am_2_00030.java b/test/testsuite/ouroboros/rc_test/RC0227-rc-function-RC_Thread01-Nocycle_am_2_00030/Nocycle_am_2_00030.java new file mode 100755 index 0000000000000000000000000000000000000000..51797f16c38b1699ef4051a00eab4f0c87ff1c8c --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0227-rc-function-RC_Thread01-Nocycle_am_2_00030/Nocycle_am_2_00030.java @@ -0,0 +1,897 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/Nocycle_am_2_00030.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change Nocycle_a_2_00030 in RC测试-No-Cycle-00.vsd to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: Nocycle_am_2_00030.java + *- @ExecuteClass: Nocycle_am_2_00030 + *- @ExecuteArgs: + *- @Remark: + */ +class ThreadRc_Nocycle_am_2_00010B extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_2_00010_A1 a1_main = new Nocycle_a_2_00010_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_2_00010_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_2_00010_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_2_00010_B3("b3_0"); + Nocycle_a_2_00010_A2 a2_main = new Nocycle_a_2_00010_A2("a2_main"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a2_main.add(); + // System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a2_main.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1939) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_2_00010_A1 { + Nocycle_a_2_00010_B1 b1_0; + Nocycle_a_2_00010_B2 b2_0; + Nocycle_a_2_00010_B3 b3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00010_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } + } + + class Nocycle_a_2_00010_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00010_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_2_00010_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00010_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_2_00010_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00010_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_2_00010_A2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00010_A2(String strObjectName) { + a = 10; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +class ThreadRc_Nocycle_am_2_00020B extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_2_00020_A1 a1_main = new Nocycle_a_2_00020_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_2_00020_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_2_00020_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_2_00020_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_2_00020_B4("b4_0"); + a1_main.b4_0.c1_0 = new Nocycle_a_2_00020_C1("c1_0"); + a1_main.b4_0.c2_0 = new Nocycle_a_2_00020_C2("c2_0"); + a1_main.b4_0.c3_0 = new Nocycle_a_2_00020_C3("c3_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b4_0.c1_0.add(); + a1_main.b4_0.c2_0.add(); + a1_main.b4_0.c3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b4_0.c1_0.sum+a1_main.b4_0.c2_0.sum+a1_main.b4_0.c3_0.sum); + + int result1 = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b4_0.c1_0.sum + a1_main.b4_0.c2_0.sum + a1_main.b4_0.c3_0.sum; + //System.out.println("RC-Testing_Result="+result1); + Nocycle_a_2_00020_2A1 a1_main2 = new Nocycle_a_2_00020_2A1("a1_main2"); + a1_main2.b1_0 = new Nocycle_a_2_00020_2B1("b1_0"); + a1_main2.b1_0.c1_0 = new Nocycle_a_2_00020_2C1("c1_0"); + a1_main2.b1_0.c1_0.d1_0 = new Nocycle_a_2_00020_2D1("d1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0 = new Nocycle_a_2_00020_2E1("e1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0 = new Nocycle_a_2_00020_2F1("f1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0 = new Nocycle_a_2_00020_2G1("g1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0 = new Nocycle_a_2_00020_2H1("h1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0 = new Nocycle_a_2_00020_2I1("i1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0 = new Nocycle_a_2_00020_2J1("j1_0"); + a1_main2.add(); + a1_main2.b1_0.add(); + a1_main2.b1_0.c1_0.add(); + a1_main2.b1_0.c1_0.d1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.add(); + + int result2 = a1_main2.sum + a1_main2.b1_0.sum + a1_main2.b1_0.c1_0.sum + a1_main2.b1_0.c1_0.d1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.sum; + + Nocycle_a_2_00020_3A1 a1_main3 = new Nocycle_a_2_00020_3A1("a1_main3"); + Nocycle_a_2_00020_3A2 a2_main = new Nocycle_a_2_00020_3A2("a2_main"); + Nocycle_a_2_00020_3A3 a3_main = new Nocycle_a_2_00020_3A3("a3_main"); + Nocycle_a_2_00020_3A4 a4_main = new Nocycle_a_2_00020_3A4("a4_main"); + a1_main3.b1_0 = new Nocycle_a_2_00020_3B1("b1_0"); + a1_main3.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a1_main3.b1_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + + a2_main.b2_0 = new Nocycle_a_2_00020_3B2("b2_0"); + a2_main.b2_0.c1_0 = new Nocycle_a_2_00020_3C1("c1_0"); + a2_main.b2_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a2_main.b2_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a2_main.b2_0.d3_0 = new Nocycle_a_2_00020_3D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + + a3_main.b2_0 = new Nocycle_a_2_00020_3B2("b2_0"); + a3_main.b2_0.c1_0 = new Nocycle_a_2_00020_3C1("c1_0"); + a3_main.b2_0.c1_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a3_main.b2_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a3_main.b2_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a3_main.b2_0.d3_0 = new Nocycle_a_2_00020_3D3("d3_0"); + + a3_main.c2_0 = new Nocycle_a_2_00020_3C2("c2_0"); + a3_main.c2_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a3_main.c2_0.d3_0 = new Nocycle_a_2_00020_3D3("d3_0"); + + a4_main.b3_0 = new Nocycle_a_2_00020_3B3("b3_0"); + a4_main.b3_0.c1_0 = new Nocycle_a_2_00020_3C1("c1_0"); + a4_main.b3_0.c1_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a4_main.c2_0 = new Nocycle_a_2_00020_3C2("c2_0"); + a4_main.c2_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a4_main.c2_0.d3_0 = new Nocycle_a_2_00020_3D3("d3_0"); + + a1_main3.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main3.b1_0.add(); + a1_main3.d1_0.add(); + a1_main3.b1_0.d2_0.add(); + + a2_main.b2_0.add(); + a2_main.b2_0.c1_0.add(); + a2_main.b2_0.d1_0.add(); + a2_main.b2_0.d2_0.add(); + a2_main.b2_0.d3_0.add(); + a2_main.b2_0.c1_0.d1_0.add(); + + a3_main.b2_0.add(); + a3_main.b2_0.c1_0.add(); + a3_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.d1_0.add(); + a3_main.b2_0.d2_0.add(); + a3_main.b2_0.d3_0.add(); + + a3_main.c2_0.add(); + a3_main.c2_0.d2_0.add(); + a3_main.c2_0.d3_0.add(); + + a4_main.b3_0.add(); + a4_main.b3_0.c1_0.add(); + a4_main.b3_0.c1_0.d1_0.add(); + a4_main.c2_0.add(); + a4_main.c2_0.d2_0.add(); + a4_main.c2_0.d3_0.add(); + + + int result3 = a1_main3.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main3.b1_0.sum + a2_main.b2_0.sum + a4_main.b3_0.sum + a2_main.b2_0.c1_0.sum + a3_main.c2_0.sum + a1_main3.d1_0.sum + a3_main.c2_0.d2_0.sum + a3_main.c2_0.d3_0.sum; + + int result = result1 + result2 + result3; + + if (result == 26225) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_2_00020_A1 { + Nocycle_a_2_00020_B1 b1_0; + Nocycle_a_2_00020_B2 b2_0; + Nocycle_a_2_00020_B3 b3_0; + Nocycle_a_2_00020_B4 b4_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } + } + + class Nocycle_a_2_00020_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_2_00020_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_2_00020_B3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_2_00020_B4 { + Nocycle_a_2_00020_C1 c1_0; + Nocycle_a_2_00020_C2 c2_0; + Nocycle_a_2_00020_C3 c3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_B4(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } + } + + class Nocycle_a_2_00020_C1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_2_00020_C2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_2_00020_C3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_2_00020_2A1 { + Nocycle_a_2_00020_2B1 b1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a; + } + } + + class Nocycle_a_2_00020_2B1 { + Nocycle_a_2_00020_2C1 c1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2B1(String strObjectName) { + c1_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } + } + + class Nocycle_a_2_00020_2C1 { + Nocycle_a_2_00020_2D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + d1_0.a; + } + } + + class Nocycle_a_2_00020_2D1 { + Nocycle_a_2_00020_2E1 e1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2D1(String strObjectName) { + e1_0 = null; + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + + void add() { + sum = a + e1_0.a; + } + } + + class Nocycle_a_2_00020_2E1 { + Nocycle_a_2_00020_2F1 f1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2E1(String strObjectName) { + f1_0 = null; + a = 501; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_E1_"+strObjectName); + } + + void add() { + sum = a + f1_0.a; + } + } + + class Nocycle_a_2_00020_2F1 { + Nocycle_a_2_00020_2G1 g1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2F1(String strObjectName) { + g1_0 = null; + a = 601; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_F1_"+strObjectName); + } + + void add() { + sum = a + g1_0.a; + } + } + + class Nocycle_a_2_00020_2G1 { + Nocycle_a_2_00020_2H1 h1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2G1(String strObjectName) { + h1_0 = null; + a = 701; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_G1_"+strObjectName); + } + + void add() { + sum = a + h1_0.a; + } + } + + class Nocycle_a_2_00020_2H1 { + Nocycle_a_2_00020_2I1 i1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2H1(String strObjectName) { + i1_0 = null; + a = 801; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_H1_"+strObjectName); + } + + void add() { + sum = a + i1_0.a; + } + } + + class Nocycle_a_2_00020_2I1 { + Nocycle_a_2_00020_2J1 j1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2I1(String strObjectName) { + j1_0 = null; + a = 901; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_I1_"+strObjectName); + } + + void add() { + sum = a + j1_0.a; + } + } + + class Nocycle_a_2_00020_2J1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_2J1(String strObjectName) { + a = 1001; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_J1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_2_00020_3A1 { + Nocycle_a_2_00020_3B1 b1_0; + Nocycle_a_2_00020_3D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + d1_0.a; + } + } + + class Nocycle_a_2_00020_3A2 { + Nocycle_a_2_00020_3B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b2_0.a; + } + } + + class Nocycle_a_2_00020_3A3 { + Nocycle_a_2_00020_3B2 b2_0; + Nocycle_a_2_00020_3C2 c2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + b2_0.a + c2_0.a; + } + } + + class Nocycle_a_2_00020_3A4 { + Nocycle_a_2_00020_3B3 b3_0; + Nocycle_a_2_00020_3C2 c2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + b3_0.a + c2_0.a; + } + } + + class Nocycle_a_2_00020_3B1 { + Nocycle_a_2_00020_3D2 d2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + d2_0.a; + } + } + + class Nocycle_a_2_00020_3B2 { + Nocycle_a_2_00020_3C1 c1_0; + Nocycle_a_2_00020_3D1 d1_0; + Nocycle_a_2_00020_3D2 d2_0; + Nocycle_a_2_00020_3D3 d3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } + } + + class Nocycle_a_2_00020_3B3 { + Nocycle_a_2_00020_3C1 c1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } + } + + class Nocycle_a_2_00020_3C1 { + Nocycle_a_2_00020_3D1 d1_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + d1_0.a; + } + } + + class Nocycle_a_2_00020_3C2 { + Nocycle_a_2_00020_3D2 d2_0; + Nocycle_a_2_00020_3D3 d3_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + d2_0.a + d3_0.a; + } + } + + class Nocycle_a_2_00020_3D1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_2_00020_3D2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_2_00020_3D3 { + int a; + int sum; + String strObjectName; + + Nocycle_a_2_00020_3D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +public class Nocycle_am_2_00030 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Nocycle_am_2_00010B A1_Nocycle_am_2_00010 = new ThreadRc_Nocycle_am_2_00010B(); + ThreadRc_Nocycle_am_2_00010B A2_Nocycle_am_2_00010 = new ThreadRc_Nocycle_am_2_00010B(); + ThreadRc_Nocycle_am_2_00010B A3_Nocycle_am_2_00010 = new ThreadRc_Nocycle_am_2_00010B(); + ThreadRc_Nocycle_am_2_00010B A4_Nocycle_am_2_00010 = new ThreadRc_Nocycle_am_2_00010B(); + ThreadRc_Nocycle_am_2_00010B A5_Nocycle_am_2_00010 = new ThreadRc_Nocycle_am_2_00010B(); + ThreadRc_Nocycle_am_2_00010B A6_Nocycle_am_2_00010 = new ThreadRc_Nocycle_am_2_00010B(); + ThreadRc_Nocycle_am_2_00020B A1_Nocycle_am_2_00020 = new ThreadRc_Nocycle_am_2_00020B(); + ThreadRc_Nocycle_am_2_00020B A2_Nocycle_am_2_00020 = new ThreadRc_Nocycle_am_2_00020B(); + ThreadRc_Nocycle_am_2_00020B A3_Nocycle_am_2_00020 = new ThreadRc_Nocycle_am_2_00020B(); + ThreadRc_Nocycle_am_2_00020B A4_Nocycle_am_2_00020 = new ThreadRc_Nocycle_am_2_00020B(); + ThreadRc_Nocycle_am_2_00020B A5_Nocycle_am_2_00020 = new ThreadRc_Nocycle_am_2_00020B(); + ThreadRc_Nocycle_am_2_00020B A6_Nocycle_am_2_00020 = new ThreadRc_Nocycle_am_2_00020B(); + + A1_Nocycle_am_2_00010.start(); + A2_Nocycle_am_2_00010.start(); + A3_Nocycle_am_2_00010.start(); + A4_Nocycle_am_2_00010.start(); + A5_Nocycle_am_2_00010.start(); + A6_Nocycle_am_2_00010.start(); + A1_Nocycle_am_2_00020.start(); + A2_Nocycle_am_2_00020.start(); + A3_Nocycle_am_2_00020.start(); + A4_Nocycle_am_2_00020.start(); + A5_Nocycle_am_2_00020.start(); + A6_Nocycle_am_2_00020.start(); + + try { + A1_Nocycle_am_2_00010.join(); + A2_Nocycle_am_2_00010.join(); + A3_Nocycle_am_2_00010.join(); + A4_Nocycle_am_2_00010.join(); + A5_Nocycle_am_2_00010.join(); + A6_Nocycle_am_2_00010.join(); + A1_Nocycle_am_2_00020.join(); + A2_Nocycle_am_2_00020.join(); + A3_Nocycle_am_2_00020.join(); + A4_Nocycle_am_2_00020.join(); + A5_Nocycle_am_2_00020.join(); + A6_Nocycle_am_2_00020.join(); + + } catch (InterruptedException e) { + } + if (A1_Nocycle_am_2_00010.check() && A2_Nocycle_am_2_00010.check() && A3_Nocycle_am_2_00010.check() && A4_Nocycle_am_2_00010.check() && A5_Nocycle_am_2_00010.check() && A6_Nocycle_am_2_00010.check() && A1_Nocycle_am_2_00020.check() && A2_Nocycle_am_2_00020.check() && A3_Nocycle_am_2_00020.check() && A4_Nocycle_am_2_00020.check() && A5_Nocycle_am_2_00020.check() && A6_Nocycle_am_2_00020.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0228-rc-function-RC_Thread02-RC_Thread_01/RC_Thread_01.java b/test/testsuite/ouroboros/rc_test/RC0228-rc-function-RC_Thread02-RC_Thread_01/RC_Thread_01.java new file mode 100755 index 0000000000000000000000000000000000000000..e40a91e2478ef5a5177ce47bd9e3630924c6b213 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0228-rc-function-RC_Thread02-RC_Thread_01/RC_Thread_01.java @@ -0,0 +1,427 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread02/RC_Thread_01.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Multi Thread reads or writes static para.mofidfy from Nocycle_a_00180 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Thread_01.java + *- @ExecuteClass: RC_Thread_01 + *- @ExecuteArgs: + *- @Remark: + + * + */ + +class RC_Thread_01_1 extends Thread { + public void run() { + RC_Thread_01 rcth01 = new RC_Thread_01(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_01_2 extends Thread { + public void run() { + RC_Thread_01 rcth01 = new RC_Thread_01(); + try { + rcth01.setA2null(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_01_3 extends Thread { + public void run() { + RC_Thread_01 rcth01 = new RC_Thread_01(); + try { + rcth01.setA3(); + } catch (NullPointerException e) { + + } + + } +} + +class RC_Thread_01_4 extends Thread { + public void run() { + RC_Thread_01 rcth01 = new RC_Thread_01(); + try { + rcth01.setA3null(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_01_5 extends Thread { + public void run() { + RC_Thread_01 rcth01 = new RC_Thread_01(); + try { + rcth01.setA4null(); + } catch (NullPointerException e) { + + } + } +} + + +public class RC_Thread_01 { + private volatile static RC_Thread_01_A1 a1_main = null; + private volatile static RC_Thread_01_A2 a2_main = null; + private volatile static RC_Thread_01_A3 a3_main = null; + private volatile static RC_Thread_01_A4 a4_main = null; + + RC_Thread_01() { + try { + a1_main = new RC_Thread_01_A1("a1_main"); + a2_main = new RC_Thread_01_A2("a2_main"); + a3_main = new RC_Thread_01_A3("a3_main"); + a4_main = new RC_Thread_01_A4("a4_main"); + a1_main.b1_0 = new RC_Thread_01_B1("b1_0"); + a1_main.d1_0 = new RC_Thread_01_D1("d1_0"); + a1_main.b1_0.d2_0 = new RC_Thread_01_D2("d2_0"); + + a2_main.b2_0 = new RC_Thread_01_B2("b2_0"); + a2_main.b2_0.c1_0 = new RC_Thread_01_C1("c1_0"); + a2_main.b2_0.d1_0 = new RC_Thread_01_D1("d1_0"); + a2_main.b2_0.d2_0 = new RC_Thread_01_D2("d2_0"); + a2_main.b2_0.d3_0 = new RC_Thread_01_D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = new RC_Thread_01_D1("d1_0"); + + a3_main.b2_0 = new RC_Thread_01_B2("b2_0"); + a3_main.b2_0.c1_0 = new RC_Thread_01_C1("c1_0"); + a3_main.b2_0.c1_0.d1_0 = new RC_Thread_01_D1("d1_0"); + a3_main.b2_0.d1_0 = new RC_Thread_01_D1("d1_0"); + a3_main.b2_0.d2_0 = new RC_Thread_01_D2("d2_0"); + a3_main.b2_0.d3_0 = new RC_Thread_01_D3("d3_0"); + + a3_main.c2_0 = new RC_Thread_01_C2("c2_0"); + a3_main.c2_0.d2_0 = new RC_Thread_01_D2("d2_0"); + a3_main.c2_0.d3_0 = new RC_Thread_01_D3("d3_0"); + + a4_main.b3_0 = new RC_Thread_01_B3("b3_0"); + a4_main.b3_0.c1_0 = new RC_Thread_01_C1("c1_0"); + a4_main.b3_0.c1_0.d1_0 = new RC_Thread_01_D1("d1_0"); + a4_main.c2_0 = new RC_Thread_01_C2("c2_0"); + a4_main.c2_0.d2_0 = new RC_Thread_01_D2("d2_0"); + a4_main.c2_0.d3_0 = new RC_Thread_01_D3("d3_0"); + } catch (NullPointerException e) { + + } + } + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + + } + + private static void rc_testcase_main_wrapper() { + RC_Thread_01_1 t1=new RC_Thread_01_1(); + RC_Thread_01_2 t2=new RC_Thread_01_2(); + RC_Thread_01_3 t3=new RC_Thread_01_3(); + RC_Thread_01_4 t4=new RC_Thread_01_4(); + RC_Thread_01_5 t5=new RC_Thread_01_5(); + t1.start(); + t2.start(); + t3.start(); + t4.start(); + t5.start(); + try { + t1.join(); + t2.join(); + t3.join(); + t4.join(); + t5.join(); + } catch (InterruptedException e) {} + + } + + + + public void setA1null() { + a1_main = null; + } + + public void setA2null() { + a2_main = null; + } + + public void setA3() { + try { + a3_main.c2_0.d2_0 = new RC_Thread_01_D2("new"); + a3_main = new RC_Thread_01_A3("a3_new"); + a3_main = null; + } catch (NullPointerException e) { + + } + } + + public void setA3null() { + a3_main = null; + } + + public void setA4null() { + a4_main = null; + } + + class RC_Thread_01_A1 { + volatile RC_Thread_01_B1 b1_0; + volatile RC_Thread_01_D1 d1_0; + int a; + int sum; + String strObjectName; + + RC_Thread_01_A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + d1_0.a; + } + } + + + class RC_Thread_01_A2 { + volatile RC_Thread_01_B2 b2_0; + int a; + int sum; + String strObjectName; + + RC_Thread_01_A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b2_0.a; + } + } + + + class RC_Thread_01_A3 { + volatile RC_Thread_01_B2 b2_0; + volatile RC_Thread_01_C2 c2_0; + int a; + int sum; + String strObjectName; + + RC_Thread_01_A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + b2_0.a + c2_0.a; + } + } + + class RC_Thread_01_A4 { + volatile RC_Thread_01_B3 b3_0; + volatile RC_Thread_01_C2 c2_0; + int a; + int sum; + String strObjectName; + + RC_Thread_01_A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + b3_0.a + c2_0.a; + } + } + + + class RC_Thread_01_B1 { + volatile RC_Thread_01_D2 d2_0; + int a; + int sum; + String strObjectName; + + RC_Thread_01_B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + d2_0.a; + } + } + + + class RC_Thread_01_B2 { + volatile RC_Thread_01_C1 c1_0; + volatile RC_Thread_01_D1 d1_0; + volatile RC_Thread_01_D2 d2_0; + volatile RC_Thread_01_D3 d3_0; + int a; + int sum; + String strObjectName; + + RC_Thread_01_B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } + } + + + class RC_Thread_01_B3 { + volatile RC_Thread_01_C1 c1_0; + int a; + int sum; + String strObjectName; + + RC_Thread_01_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } + } + + + class RC_Thread_01_C1 { + volatile RC_Thread_01_D1 d1_0; + int a; + int sum; + String strObjectName; + + RC_Thread_01_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + d1_0.a; + } + } + + class RC_Thread_01_C2 { + volatile RC_Thread_01_D2 d2_0; + volatile RC_Thread_01_D3 d3_0; + int a; + int sum; + String strObjectName; + + RC_Thread_01_C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + d2_0.a + d3_0.a; + } + } + + + class RC_Thread_01_D1 { + int a; + int sum; + String strObjectName; + + RC_Thread_01_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class RC_Thread_01_D2 { + int a; + int sum; + String strObjectName; + + RC_Thread_01_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class RC_Thread_01_D3 { + int a; + int sum; + String strObjectName; + + RC_Thread_01_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0229-rc-function-RC_Thread02-RC_Thread_02/RC_Thread_02.java b/test/testsuite/ouroboros/rc_test/RC0229-rc-function-RC_Thread02-RC_Thread_02/RC_Thread_02.java new file mode 100755 index 0000000000000000000000000000000000000000..d637845b154a3d0a3746e631d65e683f12a0b916 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0229-rc-function-RC_Thread02-RC_Thread_02/RC_Thread_02.java @@ -0,0 +1,294 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread02/RC_Thread_02.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Multi Thread reads or writes static para.mofidfy from Nocycle_a_00050 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Thread_02.java + *- @ExecuteClass: RC_Thread_02 + *- @ExecuteArgs: + *- @Remark: + + * + */ +class RC_Thread_02_1 extends Thread { + public void run() { + RC_Thread_02 rcth01 = new RC_Thread_02("rcth01"); + try { + rcth01.addSum(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_02_2 extends Thread { + public void run() { + RC_Thread_02 rcth01 = new RC_Thread_02("rcth01"); + try { + rcth01.ModifyB4(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_02_3 extends Thread { + public void run() { + RC_Thread_02 rcth01 = new RC_Thread_02("rcth01"); + try { + rcth01.deleteA1(); + } catch (NullPointerException e) { + + } + + } +} + +class RC_Thread_02_4 extends Thread { + public void run() { + RC_Thread_02 rcth01 = new RC_Thread_02("rcth01"); + try { + rcth01.setA1(null); + } catch (NullPointerException e) { + + } + } +} + + +public class RC_Thread_02 { + private volatile static RC_Thread_02_A1 a1 = null; + + RC_Thread_02(String str) { + try { + a1 = new RC_Thread_02_A1("a1"); + a1.b1_0 = new RC_Thread_02_B1("b1_0"); + a1.b1_0.c1_0 = new RC_Thread_02_C1("c1_0"); + a1.b1_0.c2_0 = new RC_Thread_02_C2("c2_0"); + a1.b1_0.c3_0 = new RC_Thread_02_C3("c3_0"); + a1.b2_0 = new RC_Thread_02_B2("b2_0"); + a1.b3_0 = new RC_Thread_02_B3("b3_0"); + a1.b4_0 = new RC_Thread_02_B4("b4_0"); + } catch (NullPointerException e) { + + } + } + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + + private static void rc_testcase_main_wrapper() { + RC_Thread_02_1 t1=new RC_Thread_02_1(); + RC_Thread_02_2 t2=new RC_Thread_02_2(); + RC_Thread_02_3 t3=new RC_Thread_02_3(); + RC_Thread_02_4 t4=new RC_Thread_02_4(); + t1.start(); + t2.start(); + t3.start(); + t4.start(); + try{ + t1.join(); + t2.join(); + t3.join(); + t4.join(); + + }catch(InterruptedException e){} + } + + public void deleteA1() { + a1 = null; + } + + public void ModifyB4() { + try{ + a1.b4_0 = new RC_Thread_02_B4("new_b4"); + }catch(NullPointerException e){ + + } + } + + public void addSum() { + try { + a1.add(); + a1.b1_0.add(); + a1.b2_0.add(); + a1.b3_0.add(); + a1.b4_0.add(); + a1.b1_0.c1_0.add(); + a1.b1_0.c2_0.add(); + a1.b1_0.c3_0.add(); + } catch (NullPointerException e) { + + } + } + + public void setA1(RC_Thread_02_A1 a1) { + this.a1 = a1; + } + + class RC_Thread_02_A1 { + volatile RC_Thread_02_B1 b1_0; + volatile RC_Thread_02_B2 b2_0; + volatile RC_Thread_02_B3 b3_0; + volatile RC_Thread_02_B4 b4_0; + int a; + int sum; + String strObjectName; + + RC_Thread_02_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } + } + + class RC_Thread_02_B1 { + volatile RC_Thread_02_C1 c1_0; + volatile RC_Thread_02_C2 c2_0; + volatile RC_Thread_02_C3 c3_0; + int a; + int sum; + String strObjectName; + + RC_Thread_02_B1(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } + } + + class RC_Thread_02_B2 { + int a; + int sum; + String strObjectName; + + RC_Thread_02_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + + class RC_Thread_02_B3 { + int a; + int sum; + String strObjectName; + + RC_Thread_02_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class RC_Thread_02_B4 { + int a; + int sum; + String strObjectName; + + RC_Thread_02_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class RC_Thread_02_C1 { + int a; + int sum; + String strObjectName; + + RC_Thread_02_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class RC_Thread_02_C2 { + int a; + int sum; + String strObjectName; + + RC_Thread_02_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class RC_Thread_02_C3 { + int a; + int sum; + String strObjectName; + + RC_Thread_02_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0230-rc-function-RC_Thread02-RC_Thread_03/RC_Thread_03.java b/test/testsuite/ouroboros/rc_test/RC0230-rc-function-RC_Thread02-RC_Thread_03/RC_Thread_03.java new file mode 100644 index 0000000000000000000000000000000000000000..74c3c7d5570a54cdd153fff50417db56e47ec40a --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0230-rc-function-RC_Thread02-RC_Thread_03/RC_Thread_03.java @@ -0,0 +1,371 @@ +/* + * -@TestCaseID:maple/runtime/rc/function/RC_Thread02/RC_Thread_03.java + * -@TestCaseName:RC_Thread_03 + * -@RequirementID:SR-10620538 + * -@RequirementName:[运行时需求]支持自动内存管理 + * -@Title/Destination:Multi Thread reads or writes static para.mofidfy from Nocycle_a_00180 + * -@Condition: no + * -#c1 + * -@Brief:Multi Thread reads or writes static para. It is modified from Nocycle_a_00180. At the same time,another thread is GC. + * -#step1 + * -@Expect:ExpectResult\nExpectResult\n + * -@Priority: High + * -@Source: RC_Thread_03.java + * -@ExecuteClass: RC_Thread_03 + * -@ExecuteArgs: + * -@Remark: + * + */ + +class RcThread0301 extends Thread { + public void run() { + RC_Thread_03 rcth01 = new RC_Thread_03(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + // do nothing + } + } +} + +class RcThread0302 extends Thread { + public void run() { + RC_Thread_03 rcth01 = new RC_Thread_03(); + try { + rcth01.setA2null(); + } catch (NullPointerException e) { + // do nothing + } + } +} + +class RcThread0303 extends Thread { + public void run() { + RC_Thread_03 rcth01 = new RC_Thread_03(); + try { + rcth01.setA3(); + } catch (NullPointerException e) { + // do nothing + } + } +} + +class RcThread0304 extends Thread { + public void run() { + RC_Thread_03 rcth01 = new RC_Thread_03(); + try { + rcth01.setA3null(); + } catch (NullPointerException e) { + // do nothing + } + } +} + +class RcThread0305 extends Thread { + public void run() { + RC_Thread_03 rcth01 = new RC_Thread_03(); + try { + rcth01.setA4(); + } catch (NullPointerException e) { + // do nothing + } + } +} + +class RcThread03GC extends Thread { + public void run() { + int start = 0; + do { + Runtime.getRuntime().gc(); + start++; + } while (start < 50); + if (start == 50) { + System.out.println("ExpectResult"); + } + } +} + +public class RC_Thread_03 { + private static volatile RcThread03A1 a1_main = null; + private static volatile RcThread03A2 a2_main = null; + private static volatile RcThread03A3 a3_main = null; + private static volatile RcThread03A4 a4_main = null; + + RC_Thread_03() { + try { + a1_main = new RcThread03A1("a1_main"); + a2_main = new RcThread03A2("a2_main"); + a3_main = new RcThread03A3("a3_main"); + a4_main = new RcThread03A4("a4_main"); + a1_main.b1_0 = new RcThread03B1("b1_0"); + a1_main.d1_0 = new RcThread03D1("d1_0"); + a1_main.b1_0.d2_0 = new RcThread03D2("d2_0"); + a2_main.b2_0 = new RcThread03B2("b2_0"); + a2_main.b2_0.c1_0 = new RcThread03C1("c1_0"); + a2_main.b2_0.d1_0 = new RcThread03D1("d1_0"); + a2_main.b2_0.d2_0 = new RcThread03D2("d2_0"); + a2_main.b2_0.d3_0 = new RcThread03D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = new RcThread03D1("d1_0"); + a3_main.b2_0 = new RcThread03B2("b2_0"); + a3_main.b2_0.c1_0 = new RcThread03C1("c1_0"); + a3_main.b2_0.c1_0.d1_0 = new RcThread03D1("d1_0"); + a3_main.b2_0.d1_0 = new RcThread03D1("d1_0"); + a3_main.b2_0.d2_0 = new RcThread03D2("d2_0"); + a3_main.b2_0.d3_0 = new RcThread03D3("d3_0"); + a3_main.c2_0 = new RcThread03C2("c2_0"); + a3_main.c2_0.d2_0 = new RcThread03D2("d2_0"); + a3_main.c2_0.d3_0 = new RcThread03D3("d3_0"); + a4_main.b3_0 = new RcThread03B3("b3_0"); + a4_main.b3_0.c1_0 = new RcThread03C1("c1_0"); + a4_main.b3_0.c1_0.d1_0 = new RcThread03D1("d1_0"); + a4_main.c2_0 = new RcThread03C2("c2_0"); + a4_main.c2_0.d2_0 = new RcThread03D2("d2_0"); + a4_main.c2_0.d3_0 = new RcThread03D3("d3_0"); + } catch (NullPointerException e) { + // do nothing + } + } + + public static void main(String[] args) { + RcThread03GC gc = new RcThread03GC(); + gc.run(); + for(int start = 0; start < 10; start++) { + rcTestcaseMainWrapper(); + } + System.out.println("ExpectResult"); + + } + + private static void rcTestcaseMainWrapper() { + RcThread0301 t1 = new RcThread0301(); + RcThread0302 t2 = new RcThread0302(); + RcThread0303 t3 = new RcThread0303(); + RcThread0304 t4 = new RcThread0304(); + RcThread0305 t5 = new RcThread0305(); + t1.start(); + t2.start(); + t3.start(); + t4.start(); + t5.start(); + try { + t1.join(); + t2.join(); + t3.join(); + t4.join(); + t5.join(); + + }catch(InterruptedException e){ + // do nothing + } + } + + void setA1null() { + a1_main = null; + } + + void setA2null() { + a2_main = null; + } + + void setA3() { + try { + a3_main.c2_0.d2_0 = new RcThread03D2("new"); + a3_main = new RcThread03A3("a3_new"); + a3_main = null; + } catch (NullPointerException e) { + // do nothing + } + } + + void setA3null() { + a3_main = null; + } + + void setA4() { + try { + a4_main = new RcThread03A4("a4_new"); + } catch (NullPointerException e) { + // do nothing + } + } + + class RcThread03A1 { + volatile RcThread03B1 b1_0; + volatile RcThread03D1 d1_0; + int a; + int sum; + String strObjectName; + + RcThread03A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + } + + class RcThread03A2 { + volatile RcThread03B2 b2_0; + int a; + int sum; + String strObjectName; + + RcThread03A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; + } + } + + class RcThread03A3 { + volatile RcThread03B2 b2_0; + volatile RcThread03C2 c2_0; + int a; + int sum; + String strObjectName; + + RcThread03A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; + } + } + + class RcThread03A4 { + volatile RcThread03B3 b3_0; + volatile RcThread03C2 c2_0; + int a; + int sum; + String strObjectName; + + RcThread03A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; + } + } + + class RcThread03B1 { + volatile RcThread03D2 d2_0; + int a; + int sum; + String strObjectName; + + RcThread03B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; + } + + } + + class RcThread03B2 { + volatile RcThread03C1 c1_0; + volatile RcThread03D1 d1_0; + volatile RcThread03D2 d2_0; + volatile RcThread03D3 d3_0; + int a; + int sum; + String strObjectName; + + RcThread03B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; + } + } + + class RcThread03B3 { + volatile RcThread03C1 c1_0; + int a; + int sum; + String strObjectName; + + RcThread03B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; + } + } + + class RcThread03C1 { + volatile RcThread03D1 d1_0; + int a; + int sum; + String strObjectName; + + RcThread03C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; + } + } + + class RcThread03C2 { + volatile RcThread03D2 d2_0; + volatile RcThread03D3 d3_0; + int a; + int sum; + String strObjectName; + + RcThread03C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; + } + } + + class RcThread03D1 { + int a; + int sum; + String strObjectName; + + RcThread03D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; + } + } + + class RcThread03D2 { + int a; + int sum; + String strObjectName; + + RcThread03D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; + } + } + + class RcThread03D3 { + int a; + int sum; + String strObjectName; + + RcThread03D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0231-rc-function-RC_Thread02-RC_Thread_04/RC_Thread_04.java b/test/testsuite/ouroboros/rc_test/RC0231-rc-function-RC_Thread02-RC_Thread_04/RC_Thread_04.java new file mode 100644 index 0000000000000000000000000000000000000000..4ca13b6d50a6d9d9af5c1ef6323baf78b2799805 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0231-rc-function-RC_Thread02-RC_Thread_04/RC_Thread_04.java @@ -0,0 +1,206 @@ +/* + * -@TestCaseID:maple/runtime/rc/function/RC_Thread02/RC_Thread_04.java + * -@TestCaseName:RC_Thread_04.java + * -@RequirementID:SR-10620538 + * -@RequirementName:[运行时需求]支持自动内存管理 + * -@Title/Destination:Multi Thread reads or writes static para.It is modified from Cycle_B_1_00180.At the same time,another thread is GC. + * -@Condition: no + * -#c1 + * -@Brief:Multi Thread reads or writes static para.It is modified from Cycle_B_1_00180.At the same time,another thread is GC. + * -#step1 + * -@Expect:ExpectResult\nExpectResult\n + * -@Priority: High + * -@Source: RC_Thread_04.java + * -@ExecuteClass: RC_Thread_04 + * -@ExecuteArgs: + * -@Remark: + * + */ + +class RcThread0401 extends Thread { + public void run() { + RC_Thread_04 rcth01 = new RC_Thread_04(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + // do nothing + } + } +} + +class RcThread0402 extends Thread { + public void run() { + RC_Thread_04 rcth01 = new RC_Thread_04(); + try { + rcth01.setA4null(); + } catch (NullPointerException e) { + // do nothing + } + } +} + +class RcThread0403 extends Thread { + public void run() { + RC_Thread_04 rcth01 = new RC_Thread_04(); + try { + rcth01.setA5null(); + } catch (NullPointerException e) { + // do nothing + } + } +} + +class RcThread04GC extends Thread { + public void run() { + int start = 0; + do { + Runtime.getRuntime().gc(); + start++; + } while (start < 50); + if (start == 50) { + System.out.println("ExpectResult"); + } + } +} + +public class RC_Thread_04 { + private static volatile RcThread04A1 a1_main = null; + private static volatile RcThread04A4 a4_main = null; + private static volatile RcThread04A5 a5_main = null; + + RC_Thread_04() { + try { + RcThread04A1 a1 = new RcThread04A1(); + a1.a2_0 = new RcThread04A2(); + a1.a2_0.a3_0 = new RcThread04A3(); + RcThread04A4 a4 = new RcThread04A4(); + RcThread04A5 a5 = new RcThread04A5(); + a4.a1_0 = a1; + a5.a1_0 = a1; + a1.a2_0.a3_0.a1_0 = a1; + a1_main = a1; + a4_main = a4; + a5_main = a5; + } catch (NullPointerException e) { + // do nothing + } + } + + public static void main(String[] args) { + cyclePatternWrapper(); + RcThread04GC gc = new RcThread04GC(); + gc.start(); + rcTestcaseMainWrapper(); + rcTestcaseMainWrapper(); + rcTestcaseMainWrapper(); + rcTestcaseMainWrapper(); + System.out.println("ExpectResult"); + } + + private static void cyclePatternWrapper() { + a1_main = new RcThread04A1(); + a1_main.a2_0 = new RcThread04A2(); + a1_main.a2_0.a3_0 = new RcThread04A3(); + a4_main = new RcThread04A4(); + a5_main = new RcThread04A5(); + a4_main.a1_0 = a1_main; + a5_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main = null; + a4_main = null; + a5_main = null; + Runtime.getRuntime().gc(); // 单独构造一次Cycle_B_1_00180环,通过gc学习到环模式 + } + + private static void rcTestcaseMainWrapper() { + RcThread0401 t1 = new RcThread0401(); + RcThread0402 t2 = new RcThread0402(); + RcThread0403 t3 = new RcThread0403(); + t1.start(); + t2.start(); + t3.start(); + try { + t1.join(); + t2.join(); + t3.join(); + + }catch(InterruptedException e){ + // do nothing + } + } + + void setA1null() { + a1_main = null; + } + + void setA4null() { + a4_main = null; + } + + void setA5null() { + a5_main = null; + } + + static class RcThread04A1 { + volatile RcThread04A2 a2_0; + int a; + int sum; + + RcThread04A1() { + a2_0 = null; + a = 1; + sum = 0; + } + } + + static class RcThread04A2 { + volatile RcThread04A3 a3_0; + int a; + int sum; + + RcThread04A2() { + a3_0 = null; + a = 2; + sum = 0; + } + } + + static class RcThread04A3 { + volatile RcThread04A1 a1_0; + int a; + int sum; + + RcThread04A3() { + a1_0 = null; + a = 3; + sum = 0; + } + } + + static class RcThread04A4 { + volatile RcThread04A1 a1_0; + int a; + int sum; + + RcThread04A4() { + a1_0 = null; + a = 4; + sum = 0; + } + } + + static class RcThread04A5 { + volatile RcThread04A1 a1_0; + int a; + int sum; + + RcThread04A5() { + a1_0 = null; + a = 5; + sum = 0; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0232-rc-function-RC_Thread02-RC_Thread_05/RC_Thread_05.java b/test/testsuite/ouroboros/rc_test/RC0232-rc-function-RC_Thread02-RC_Thread_05/RC_Thread_05.java new file mode 100644 index 0000000000000000000000000000000000000000..9900888e00bb229275dcba0b5df792b0666a00bb --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0232-rc-function-RC_Thread02-RC_Thread_05/RC_Thread_05.java @@ -0,0 +1,268 @@ +/* + * -@TestCaseID:maple/runtime/rc/function/RC_Thread02/RC_Thread_05.java + * -@TestCaseName:RC_Thread_05 + * -@RequirementID:SR-10620538 + * -@RequirementName:[运行时需求]支持自动内存管理 + * -@Title/Destination:Multi Thread reads or writes static para.It is modified from Cycle_B_1_00180.At the same time,another thread is doing GC. + * -@Condition: no + * -#c1 + * -@Brief:Multi Thread reads or writes static para.It is modified from Cycle_B_1_00180.At the same time,another thread is doing GC. + * -#step1 + * -@Expect:ExpectResult\nExpectResult\n + * -@Priority: High + * -@Source: RC_Thread_05.java + * -@ExecuteClass: RC_Thread_05 + * -@ExecuteArgs: + * -@Remark: + * + */ + +class RcThread0501 extends Thread { + public void run() { + RC_Thread_05 rcth01 = new RC_Thread_05(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + // do nothing + } + } +} + +class RcThread0502 extends Thread { + public void run() { + RC_Thread_05 rcth01 = new RC_Thread_05(); + try { + rcth01.setA4null(); + } catch (NullPointerException e) { + // do nothing + } + } +} + +class RcThread0503 extends Thread { + public void run() { + RC_Thread_05 rcth01 = new RC_Thread_05(); + try { + rcth01.setA5null(); + } catch (NullPointerException e) { + // do nothing + } + } +} + +class RcThread0504 extends Thread { + public void run() { + RC_Thread_05 rcth01 = new RC_Thread_05(); + try { + rcth01.setA1(); + } catch (NullPointerException e) { + // do nothing + } + } +} + +class RcThread0505 extends Thread { + public void run() { + RC_Thread_05 rcth01 = new RC_Thread_05(); + try { + rcth01.checkA3(); + } catch (NullPointerException e) { + // do nothing + } + } +} + +class RcThread0506 extends Thread { + public void run() { + RC_Thread_05 rcth01 = new RC_Thread_05(); + try { + rcth01.setA3_a(5); + } catch (NullPointerException e) { + // do nothing + } + } +} + +class RcThread05GC extends Thread { + public void run() { + int start = 0; + do { + Runtime.getRuntime().gc(); + start++; + } while (start < 50); + if (start == 50) { + System.out.println("ExpectResult"); + } + } +} + +public class RC_Thread_05 { + private static volatile RcThread05A1 a1Main = null; + private static volatile RcThread05A4 a4Main = null; + private static volatile RcThread05A5 a5Main = null; + + RC_Thread_05() { + try { + a1Main = new RcThread05A1(); + a1Main.a2_0 = new RcThread05A2(); + a1Main.a2_0.a3_0 = new RcThread05A3(); + a4Main = new RcThread05A4(); + a5Main = new RcThread05A5(); + a4Main.a1_0 = a1Main; + a5Main.a1_0 = a1Main; + a1Main.a2_0.a3_0.a1_0 = a1Main; + } catch (NullPointerException e) { + // do nothing + } + } + + public static void main(String[] args) { + cyclePatternWrapper(); + RcThread05GC gc = new RcThread05GC(); + gc.run(); + rcTestcaseMainWrapper(); + rcTestcaseMainWrapper(); + rcTestcaseMainWrapper(); + rcTestcaseMainWrapper(); + System.out.println("ExpectResult"); + } + + private static void cyclePatternWrapper() { + a1Main = new RcThread05A1(); + a1Main.a2_0 = new RcThread05A2(); + a1Main.a2_0.a3_0 = new RcThread05A3(); + a4Main = new RcThread05A4(); + a5Main = new RcThread05A5(); + a4Main.a1_0 = a1Main; + a5Main.a1_0 = a1Main; + a1Main.a2_0.a3_0.a1_0 = a1Main; + a1Main = null; + a4Main = null; + a5Main = null; + Runtime.getRuntime().gc(); // 单独构造一次Cycle_B_1_00180环,通过gc学习到环模式 + } + + private static void rcTestcaseMainWrapper() { + RcThread0501 t1 = new RcThread0501(); + RcThread0502 t2 = new RcThread0502(); + RcThread0503 t3 = new RcThread0503(); + RcThread0504 t4 = new RcThread0504(); + RcThread0505 t5 = new RcThread0505(); + RcThread0506 t6 = new RcThread0506(); + t1.start(); + t2.start(); + t3.start(); + t4.start(); + t5.start(); + t6.start(); + try { + t1.join(); + t2.join(); + t3.join(); + t4.join(); + t5.join(); + t6.join(); + }catch(InterruptedException e){ + // do nothing + } + } + + void setA1null() { + a1Main = null; + } + + void setA4null() { + a4Main = null; + } + + void setA5null() { + a5Main = null; + } + + void setA1() { + try { + this.a1Main = new RcThread05A1(); + a1Main.a2_0 = new RcThread05A2(); + a1Main.a2_0.a3_0 = new RcThread05A3(); + } catch (NullPointerException e) { + // do nothing + } + } + + void checkA3() { + try { + int a = a1Main.a2_0.a3_0.a; + } catch (NullPointerException e) { + // do nothing + } + } + + void setA3_a(int a) { + try { + this.a1Main.a2_0.a3_0.a = a; + } catch (NullPointerException e) { } + } + + static class RcThread05A1 { + volatile RcThread05A2 a2_0; + int a; + int sum; + + RcThread05A1() { + a2_0 = null; + a = 1; + sum = 0; + } + } + + static class RcThread05A2 { + volatile RcThread05A3 a3_0; + int a; + int sum; + + RcThread05A2() { + a3_0 = null; + a = 2; + sum = 0; + } + } + + static class RcThread05A3 { + volatile RcThread05A1 a1_0; + int a; + int sum; + + RcThread05A3() { + a1_0 = null; + a = 3; + sum = 0; + } + } + + static class RcThread05A4 { + volatile RcThread05A1 a1_0; + int a; + int sum; + + RcThread05A4() { + a1_0 = null; + a = 4; + sum = 0; + } + } + + static class RcThread05A5 { + volatile RcThread05A1 a1_0; + int a; + int sum; + + RcThread05A5() { + a1_0 = null; + a = 5; + sum = 0; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0233-rc-function-RC_Thread02-RC_Thread_06/RC_Thread_06.java b/test/testsuite/ouroboros/rc_test/RC0233-rc-function-RC_Thread02-RC_Thread_06/RC_Thread_06.java new file mode 100644 index 0000000000000000000000000000000000000000..61156df128b919754f8e7504034f488b767ad618 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0233-rc-function-RC_Thread02-RC_Thread_06/RC_Thread_06.java @@ -0,0 +1,243 @@ +/* + * -@TestCaseID:maple/runtime/rc/function/RC_Thread02/RC_Thread_06.java + * -@TestCaseName:RC_Thread_06 + * -@RequirementID:SR-10620538 + * -@RequirementName:[运行时需求]支持自动内存管理 + * -@Title/Destination:Multi Thread reads or writes static para.It is modified from Cycle_B_2_00130. At the same time,another thread is doing GC. + * -@Condition: no + * -#c1 + * -@Brief:Multi Thread reads or writes static para.It is modified from Cycle_B_2_00130. At the same time,another thread is doing GC. + * -#step1 + * -@Expect:ExpectResult\nExpectResult\n + * -@Priority: High + * -@Source: RC_Thread_06.java + * -@ExecuteClass: RC_Thread_06 + * -@ExecuteArgs: + * -@Remark: + * + */ + +class RcThread0601 extends Thread { + public void run() { + RC_Thread_06 rcth01 = new RC_Thread_06(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + // do nothing + } + } +} + +class RcThread0602 extends Thread { + public void run() { + RC_Thread_06 rcth01 = new RC_Thread_06(); + try { + rcth01.setA4null(); + } catch (NullPointerException e) { + // do nothing + } + } +} + +class RcThread0603 extends Thread { + public void run() { + RC_Thread_06 rcth01 = new RC_Thread_06(); + try { + rcth01.setA5null(); + } catch (NullPointerException e) { + // do nothing + } + } +} + +class RcThread06GC extends Thread { + public void run() { + int start = 0; + do { + Runtime.getRuntime().gc(); + start++; + } while (start < 50); + if (start == 50) { + System.out.println("ExpectResult"); + } + } +} + +public class RC_Thread_06 { + private static volatile RcThread06A1 a1Main = null; + private static volatile RcThread06A5 a5Main = null; + + RC_Thread_06() { + try { + a1Main = new RcThread06A1(); + a1Main.a2_0 = new RcThread06A2(); + a1Main.a2_0.a3_0 = new RcThread06A3(); + a1Main.a2_0.a3_0.a4_0 = new RcThread06A4(); + a1Main.a2_0.a3_0.a4_0.a1_0 = a1Main; + a5Main = new RcThread06A5(); + a1Main.a2_0.a3_0.a4_0.a6_0 = new RcThread06A6(); + a1Main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5Main; + a5Main.a3_0 = a1Main.a2_0.a3_0; + } catch (NullPointerException e) { + // do nothing + } + } + + public static void main(String[] args) { + cyclePatternWrapper(); + Runtime.getRuntime().gc(); + RcThread06GC gc = new RcThread06GC(); + gc.run(); + int start = 0; + for (;start < 20; start++) { + rcTestcaseMainWrapper(); + } + if (start == 20) { + System.out.println("ExpectResult"); + } + } + + private static void cyclePatternWrapper() { + a1Main = new RcThread06A1(); + a1Main.a2_0 = new RcThread06A2(); + a1Main.a2_0.a3_0 = new RcThread06A3(); + a1Main.a2_0.a3_0.a4_0 = new RcThread06A4(); + a1Main.a2_0.a3_0.a4_0.a1_0 = a1Main; + a5Main = new RcThread06A5(); + a1Main.a2_0.a3_0.a4_0.a6_0 = new RcThread06A6(); + a1Main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5Main; + a5Main.a3_0 = a1Main.a2_0.a3_0; + a1Main = null; + a5Main = null; + + a1Main = new RcThread06A1(); + a1Main.a2_0 = new RcThread06A2(); + a1Main.a2_0.a3_0 = new RcThread06A3(); + a1Main.a2_0.a3_0.a4_0 = new RcThread06A4(); + a1Main.a2_0.a3_0.a4_0.a1_0 = a1Main; + a1Main = null; + + a1Main = new RcThread06A1(); + a1Main.a2_0 = new RcThread06A2(); + a1Main.a2_0.a3_0 = new RcThread06A3(); + a1Main.a2_0.a3_0.a4_0 = new RcThread06A4(); + a1Main.a2_0.a3_0.a4_0.a1_0 = a1Main; + a5Main = new RcThread06A5(); + a1Main.a2_0.a3_0.a4_0.a6_0 = new RcThread06A6(); + a1Main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5Main; + a5Main.a3_0 = a1Main.a2_0.a3_0; + a1Main.a2_0.a3_0 = null; + a1Main = null; + a5Main = null; //总共三种环类型 + } + + private static void rcTestcaseMainWrapper() { + RcThread0601 t1 = new RcThread0601(); + RcThread0602 t2 = new RcThread0602(); + RcThread0603 t3 = new RcThread0603(); + t1.start(); + t2.start(); + t3.start(); + try { + t1.join(); + t2.join(); + t3.join(); + } catch (InterruptedException e){ + // do nothing + } + } + + void setA1null() { + a1Main = null; + } + + void setA4null() { + try { + a1Main.a2_0.a3_0.a4_0 = null; + a5Main.a3_0.a4_0 = null; + } catch (NullPointerException e) { } + } + + void setA5null() { + a5Main = null; + } + + static class RcThread06A1 { + volatile RcThread06A2 a2_0; + volatile RcThread06A4 a4_0; + int a; + int sum; + + RcThread06A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + } + + static class RcThread06A2 { + volatile RcThread06A3 a3_0; + int a; + int sum; + + RcThread06A2() { + a3_0 = null; + a = 2; + sum = 0; + } + } + + static class RcThread06A3 { + volatile RcThread06A4 a4_0; + int a; + int sum; + + RcThread06A3() { + a4_0 = null; + a = 3; + sum = 0; + } + } + + static class RcThread06A4 { + volatile RcThread06A1 a1_0; + volatile RcThread06A6 a6_0; + int a; + int sum; + + RcThread06A4() { + a1_0 = null; + a6_0 = null; + a = 4; + sum = 0; + } + } + + static class RcThread06A5 { + volatile RcThread06A3 a3_0; + int a; + int sum; + + RcThread06A5() { + a3_0 = null; + a = 5; + sum = 0; + } + } + + static class RcThread06A6 { + volatile RcThread06A5 a5_0; + int a; + int sum; + + RcThread06A6() { + a5_0 = null; + a = 6; + sum = 0; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0234-rc-function-RC_Thread02-RC_Thread_07/RC_Thread_07.java b/test/testsuite/ouroboros/rc_test/RC0234-rc-function-RC_Thread02-RC_Thread_07/RC_Thread_07.java new file mode 100644 index 0000000000000000000000000000000000000000..85f7631a605b0d7843b9014bf0e2f8c8667f814d --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0234-rc-function-RC_Thread02-RC_Thread_07/RC_Thread_07.java @@ -0,0 +1,271 @@ +/* + * -@TestCaseID:RC_Thread_07.java + * -@TestCaseName:MyselfClassName + * -@RequirementID:SR-10620538 + * -@RequirementName:[运行时需求]支持自动内存管理 + * -@Title/Destination:Multi Thread reads or writes static para.mofidfy from Cycle_B_2_00130 + * -@Condition: no + * -#c1 + * -@Brief:Multi Thread reads or writes static para. it is modified from Cycle_B_2_00130.At the same time,another thread is doing GC. + * -#step1 + * -@Expect:ExpectResult\n + * -@Priority: High + * -@Source: RC_Thread_07.java + * -@ExecuteClass: RC_Thread_07 + * -@ExecuteArgs: + * -@Remark: + * + */ + +class RcThread0701 extends Thread { + public void run() { + RC_Thread_07 rcth01 = new RC_Thread_07(); + try { + rcth01.modifyA1(); + } catch (NullPointerException e) { + // do nothing + } + } +} + +class RcThread0702 extends Thread { + public void run() { + RC_Thread_07 rcth01 = new RC_Thread_07(); + try { + rcth01.checkA4(); + } catch (NullPointerException e) { + // do nothing + } + } +} + +class RcThread0703 extends Thread { + public void run() { + RC_Thread_07 rcth01 = new RC_Thread_07(); + try { + rcth01.setA5(); + } catch (NullPointerException e) { + // do nothing + } + } +} + +class RcThread07GC extends Thread { + public void run() { + RC_Thread_07 rcth01 = new RC_Thread_07(); + int start = 0; + do { + Runtime.getRuntime().gc(); + start++; + } while (start < 20); + } +} + +public class RC_Thread_07 { + private static volatile RcThread07A1 a1_main = null; + private static volatile RcThread07A5 a5_main = null; + + RC_Thread_07() { + try { + RcThread07A1 a1_1 = new RcThread07A1(); + a1_1.a2_0 = new RcThread07A2(); + a1_1.a2_0.a3_0 = new RcThread07A3(); + a1_1.a2_0.a3_0.a4_0 = new RcThread07A4(); + a1_1.a2_0.a3_0.a4_0.a1_0 = a1_1; + RcThread07A5 a5_1 = new RcThread07A5(); + a1_1.a2_0.a3_0.a4_0.a6_0 = new RcThread07A6(); + a1_1.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_1; + a5_1.a3_0 = a1_1.a2_0.a3_0; + a1_main = a1_1; + a5_main = a5_1; + } catch (NullPointerException e) { + // do nothing + } + } + + public static void main(String[] args) { + cyclePatternWrapper(); + Runtime.getRuntime().gc(); + cyclePatternWrapper(); + Runtime.getRuntime().gc(); + RcThread07GC gc = new RcThread07GC(); + gc.start(); + rcTestcaseMainWrapper(); + rcTestcaseMainWrapper(); + System.out.println("ExpectResult"); + } + + private static void cyclePatternWrapper() { + RcThread07A1 a1 = new RcThread07A1(); + a1.a2_0 = new RcThread07A2(); + a1.a2_0.a3_0 = new RcThread07A3(); + a1.a2_0.a3_0.a4_0 = new RcThread07A4(); + a1.a2_0.a3_0.a4_0.a1_0 = a1; + RcThread07A5 a5 = new RcThread07A5(); + a1.a2_0.a3_0.a4_0.a6_0 = new RcThread07A6(); + a1.a2_0.a3_0.a4_0.a6_0.a5_0 = a5; + a5.a3_0 = a1.a2_0.a3_0; + a1 = null; + a5 = null; + + a1 = new RcThread07A1(); + a1.a2_0 = new RcThread07A2(); + a1.a2_0.a3_0 = new RcThread07A3(); + a1.a2_0.a3_0.a4_0 = new RcThread07A4(); + a1.a2_0.a3_0.a4_0.a1_0 = a1; + a1 = null; + + a1 = new RcThread07A1(); + a1.a2_0 = new RcThread07A2(); + a1.a2_0.a3_0 = new RcThread07A3(); + a1.a2_0.a3_0.a4_0 = new RcThread07A4(); + a1.a2_0.a3_0.a4_0.a1_0 = a1; + a5 = new RcThread07A5(); + a1.a2_0.a3_0.a4_0.a6_0 = new RcThread07A6(); + a1.a2_0.a3_0.a4_0.a6_0.a5_0 = a5; + a5.a3_0 = a1.a2_0.a3_0; + a1.a2_0.a3_0 = null; + a1 = null; + a5 = null; + } + + private static void rcTestcaseMainWrapper() { + RcThread0701 t1 = new RcThread0701(); + RcThread0702 t2 = new RcThread0702(); + RcThread0703 t3 = new RcThread0703(); + t1.start(); + t2.start(); + t3.start(); + try { + t1.join(); + t2.join(); + t3.join(); + } catch (InterruptedException e){ + // do nothing + } + } + + void modifyA1() { + a1_main.a2_0.a3_0 = null; + a1_main = null; + } + + void checkA4() { + try { + int[] arr = new int[2]; + arr[0] = a5_main.a3_0.a4_0.sum; + arr[1] = a5_main.a3_0.a4_0.a; + } catch (NullPointerException e) { + // do nothing + } + } + + void setA5() { + RcThread07A5 a5 = new RcThread07A5(); + a5 = this.a5_main; + a5_main = null; + } + + static class RcThread07A1 { + volatile RcThread07A2 a2_0; + volatile RcThread07A4 a4_0; + int a; + int sum; + + RcThread07A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + static class RcThread07A2 { + volatile RcThread07A3 a3_0; + int a; + int sum; + + RcThread07A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + static class RcThread07A3 { + volatile RcThread07A4 a4_0; + int a; + int sum; + + RcThread07A3() { + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } + + static class RcThread07A4 { + volatile RcThread07A1 a1_0; + volatile RcThread07A6 a6_0; + int a; + int sum; + + RcThread07A4() { + a1_0 = null; + a6_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a + a6_0.a; + } + } + + static class RcThread07A5 { + volatile RcThread07A3 a3_0; + int a; + int sum; + + RcThread07A5() { + a3_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + static class RcThread07A6 { + volatile RcThread07A5 a5_0; + int a; + int sum; + + RcThread07A6() { + a5_0 = null; + a = 6; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0235-rc-function-RC_Thread02-RC_Thread_08/RC_Thread_08.java b/test/testsuite/ouroboros/rc_test/RC0235-rc-function-RC_Thread02-RC_Thread_08/RC_Thread_08.java new file mode 100755 index 0000000000000000000000000000000000000000..22b6c54d062e03a86b767f81756957c01ef23a2a --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0235-rc-function-RC_Thread02-RC_Thread_08/RC_Thread_08.java @@ -0,0 +1,285 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread02/RC_Thread_08.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Multi Thread reads or writes static para.mofidfy from Cycle_a_00320 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Thread_08.java + *- @ExecuteClass: RC_Thread_08 + *- @ExecuteArgs: + *- @Remark: + * + */ +import java.lang.Runtime; +class RC_Thread_08_1 extends Thread { + public void run() { + RC_Thread_08 rcth01 = new RC_Thread_08(); + try { + rcth01.ModifyA3(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_08_2 extends Thread { + public void run() { + RC_Thread_08 rcth01 = new RC_Thread_08(); + try { + rcth01.checkA3(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_08_3 extends Thread { + public void run() { + RC_Thread_08 rcth01 = new RC_Thread_08(); + try { + rcth01.setA3null(); + } catch (NullPointerException e) { + + } + + } +} + +public class RC_Thread_08 { + private volatile static RC_Thread_08_A1 a1_main = null; + private volatile static RC_Thread_08_A4 a4_main = null; + private volatile static RC_Thread_08_A6 a6_main = null; + + RC_Thread_08() { + try { + RC_Thread_08_A1 a1 = new RC_Thread_08_A1("a1"); + RC_Thread_08_A4 a4 = new RC_Thread_08_A4("a4"); + RC_Thread_08_A6 a6 = new RC_Thread_08_A6("a6"); + a1.a2_0 = new RC_Thread_08_A2("a2_0"); + a1.a2_0.a3_0 = new RC_Thread_08_A3("a3_0"); + a1.a2_0.a3_0.a1_0 = a1; + a1.a2_0.a3_0.a5_0 = new RC_Thread_08_A5("a5_0"); + a1.a2_0.a3_0.a5_0.a6_0 = a6; + a6.a1_0 = a1; + a6.a3_0 = a1.a2_0.a3_0; + a4.a5_0 = a1.a2_0.a3_0.a5_0; + a6.a4_0 = a4; + a1_main = a1; + a4_main = a4; + a6_main = a6; + } catch (NullPointerException e) { + + } + } + + public static void main(String[] args) { + cycle_pattern_wrapper(); + + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + System.out.println("ExpectResult"); + + } + + private static void cycle_pattern_wrapper(){ + RC_Thread_08_A1 a1 = new RC_Thread_08_A1("a1"); + RC_Thread_08_A4 a4 = new RC_Thread_08_A4("a4"); + RC_Thread_08_A6 a6 = new RC_Thread_08_A6("a6"); + a1.a2_0 = new RC_Thread_08_A2("a2_0"); + a1.a2_0.a3_0 = new RC_Thread_08_A3("a3_0"); + a1.a2_0.a3_0.a1_0 = a1; + a1.a2_0.a3_0.a5_0 = new RC_Thread_08_A5("a5_0"); + a1.a2_0.a3_0.a5_0.a6_0 = a6; + a6.a1_0 = a1; + a6.a3_0 = a1.a2_0.a3_0; + a4.a5_0 = a1.a2_0.a3_0.a5_0; + a6.a4_0 = a4; + a1=null; + a4=null; + a6=null; + Runtime.getRuntime().gc(); + } + + private static void rc_testcase_main_wrapper() { + RC_Thread_08_1 t_00010= new RC_Thread_08_1(); + RC_Thread_08_2 t_00020= new RC_Thread_08_2(); + RC_Thread_08_3 t_00030= new RC_Thread_08_3(); + t_00010.start(); + t_00020.start(); + t_00030.start(); + try { + t_00010.join(); + t_00020.join(); + t_00030.join(); + + } catch (InterruptedException e) {} + + } + + public void checkA3() { + int[] arr = new int[2]; + try { + arr[0] = a1_main.a2_0.a3_0.a; + arr[1] = a1_main.a2_0.a3_0.sum; + } catch (NullPointerException e) { + + } + } + + public void ModifyA3() { + try { + a1_main.a2_0.a3_0 = new RC_Thread_08_A3("new-a3"); + } catch (NullPointerException e) { + + } + } + + public void setA3null() { + RC_Thread_08_A3 a3 = new RC_Thread_08_A3("test"); + try { + a3 = this.a1_main.a2_0.a3_0; + this.a1_main.a2_0.a3_0 = null; + } catch (NullPointerException e) { + + } + + } + + static class RC_Thread_08_A1 { + volatile RC_Thread_08_A2 a2_0; + int a; + int sum; + String strObjectName; + + RC_Thread_08_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + static class RC_Thread_08_A2 { + volatile RC_Thread_08_A3 a3_0; + int a; + int sum; + String strObjectName; + + RC_Thread_08_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + static class RC_Thread_08_A3 { + volatile RC_Thread_08_A1 a1_0; + volatile RC_Thread_08_A5 a5_0; + int a; + int sum; + String strObjectName; + + RC_Thread_08_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + + static class RC_Thread_08_A4 { + volatile RC_Thread_08_A5 a5_0; + int a; + int sum; + String strObjectName; + + RC_Thread_08_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } + } + + static class RC_Thread_08_A5 { + volatile RC_Thread_08_A6 a6_0; + int a; + int sum; + String strObjectName; + + RC_Thread_08_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + static class RC_Thread_08_A6 { + volatile RC_Thread_08_A1 a1_0; + volatile RC_Thread_08_A3 a3_0; + volatile RC_Thread_08_A4 a4_0; + int a; + int sum; + String strObjectName; + + RC_Thread_08_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0236-rc-function-RC_Thread02-RC_Thread_09/RC_Thread_09.java b/test/testsuite/ouroboros/rc_test/RC0236-rc-function-RC_Thread02-RC_Thread_09/RC_Thread_09.java new file mode 100755 index 0000000000000000000000000000000000000000..d7d93639b43f6c7d3c26c2ae92108fc3fa41fb46 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0236-rc-function-RC_Thread02-RC_Thread_09/RC_Thread_09.java @@ -0,0 +1,426 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread02/RC_Thread_09 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Multi Thread reads or writes static para.mofidfy from Nocycle_a_00180 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Thread_09.java + *- @ExecuteClass: RC_Thread_09 + *- @ExecuteArgs: + *- @Remark: + + * + */ + +class RC_Thread_09_1 extends Thread { + public void run() { + RC_Thread_09 rcth01 = new RC_Thread_09(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_09_2 extends Thread { + public void run() { + RC_Thread_09 rcth01 = new RC_Thread_09(); + try { + rcth01.setA2null(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_09_3 extends Thread { + public void run() { + RC_Thread_09 rcth01 = new RC_Thread_09(); + try { + rcth01.setA3(); + } catch (NullPointerException e) { + + } + + } +} + +class RC_Thread_09_4 extends Thread { + public void run() { + RC_Thread_09 rcth01 = new RC_Thread_09(); + try { + rcth01.setA3null(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_09_5 extends Thread { + public void run() { + RC_Thread_09 rcth01 = new RC_Thread_09(); + try { + rcth01.setA4null(); + } catch (NullPointerException e) { + + } + } +} + + +public class RC_Thread_09 { + private static RC_Thread_09_A1 a1_main = null; + private static RC_Thread_09_A2 a2_main = null; + private static RC_Thread_09_A3 a3_main = null; + private static RC_Thread_09_A4 a4_main = null; + + RC_Thread_09() { + try { + a1_main = new RC_Thread_09_A1("a1_main"); + a2_main = new RC_Thread_09_A2("a2_main"); + a3_main = new RC_Thread_09_A3("a3_main"); + a4_main = new RC_Thread_09_A4("a4_main"); + a1_main.b1_0 = new RC_Thread_09_B1("b1_0"); + a1_main.d1_0 = new RC_Thread_09_D1("d1_0"); + a1_main.b1_0.d2_0 = new RC_Thread_09_D2("d2_0"); + + a2_main.b2_0 = new RC_Thread_09_B2("b2_0"); + a2_main.b2_0.c1_0 = new RC_Thread_09_C1("c1_0"); + a2_main.b2_0.d1_0 = new RC_Thread_09_D1("d1_0"); + a2_main.b2_0.d2_0 = new RC_Thread_09_D2("d2_0"); + a2_main.b2_0.d3_0 = new RC_Thread_09_D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = new RC_Thread_09_D1("d1_0"); + + a3_main.b2_0 = new RC_Thread_09_B2("b2_0"); + a3_main.b2_0.c1_0 = new RC_Thread_09_C1("c1_0"); + a3_main.b2_0.c1_0.d1_0 = new RC_Thread_09_D1("d1_0"); + a3_main.b2_0.d1_0 = new RC_Thread_09_D1("d1_0"); + a3_main.b2_0.d2_0 = new RC_Thread_09_D2("d2_0"); + a3_main.b2_0.d3_0 = new RC_Thread_09_D3("d3_0"); + + a3_main.c2_0 = new RC_Thread_09_C2("c2_0"); + a3_main.c2_0.d2_0 = new RC_Thread_09_D2("d2_0"); + a3_main.c2_0.d3_0 = new RC_Thread_09_D3("d3_0"); + + a4_main.b3_0 = new RC_Thread_09_B3("b3_0"); + a4_main.b3_0.c1_0 = new RC_Thread_09_C1("c1_0"); + a4_main.b3_0.c1_0.d1_0 = new RC_Thread_09_D1("d1_0"); + a4_main.c2_0 = new RC_Thread_09_C2("c2_0"); + a4_main.c2_0.d2_0 = new RC_Thread_09_D2("d2_0"); + a4_main.c2_0.d3_0 = new RC_Thread_09_D3("d3_0"); + } catch (NullPointerException e) { + + } + } + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + + private static void rc_testcase_main_wrapper() { + RC_Thread_09_1 t1 = new RC_Thread_09_1(); + RC_Thread_09_2 t2 = new RC_Thread_09_2(); + RC_Thread_09_3 t3 = new RC_Thread_09_3(); + RC_Thread_09_4 t4 = new RC_Thread_09_4(); + RC_Thread_09_5 t5 = new RC_Thread_09_5(); + t1.start(); + t2.start(); + t3.start(); + t4.start(); + t5.start(); + try { + t1.join(); + t2.join(); + t3.join(); + t4.join(); + t5.join(); + } catch (InterruptedException e) { + } + + } + + + public void setA1null() { + a1_main = null; + } + + public void setA2null() { + a2_main = null; + } + + public void setA3() { + try { + a3_main.c2_0.d2_0 = new RC_Thread_09_D2("new"); + a3_main = new RC_Thread_09_A3("a3_new"); + a3_main = null; + } catch (NullPointerException e) { + + } + } + + public void setA3null() { + a3_main = null; + } + + public void setA4null() { + a4_main = null; + } + + class RC_Thread_09_A1 { + RC_Thread_09_B1 b1_0; + RC_Thread_09_D1 d1_0; + int a; + int sum; + String strObjectName; + + RC_Thread_09_A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + d1_0.a; + } + } + + + class RC_Thread_09_A2 { + RC_Thread_09_B2 b2_0; + int a; + int sum; + String strObjectName; + + RC_Thread_09_A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b2_0.a; + } + } + + + class RC_Thread_09_A3 { + RC_Thread_09_B2 b2_0; + RC_Thread_09_C2 c2_0; + int a; + int sum; + String strObjectName; + + RC_Thread_09_A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + b2_0.a + c2_0.a; + } + } + + class RC_Thread_09_A4 { + RC_Thread_09_B3 b3_0; + RC_Thread_09_C2 c2_0; + int a; + int sum; + String strObjectName; + + RC_Thread_09_A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + b3_0.a + c2_0.a; + } + } + + + class RC_Thread_09_B1 { + RC_Thread_09_D2 d2_0; + int a; + int sum; + String strObjectName; + + RC_Thread_09_B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + d2_0.a; + } + } + + + class RC_Thread_09_B2 { + RC_Thread_09_C1 c1_0; + RC_Thread_09_D1 d1_0; + RC_Thread_09_D2 d2_0; + RC_Thread_09_D3 d3_0; + int a; + int sum; + String strObjectName; + + RC_Thread_09_B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } + } + + + class RC_Thread_09_B3 { + RC_Thread_09_C1 c1_0; + int a; + int sum; + String strObjectName; + + RC_Thread_09_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } + } + + + class RC_Thread_09_C1 { + RC_Thread_09_D1 d1_0; + int a; + int sum; + String strObjectName; + + RC_Thread_09_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + d1_0.a; + } + } + + class RC_Thread_09_C2 { + RC_Thread_09_D2 d2_0; + RC_Thread_09_D3 d3_0; + int a; + int sum; + String strObjectName; + + RC_Thread_09_C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + d2_0.a + d3_0.a; + } + } + + + class RC_Thread_09_D1 { + int a; + int sum; + String strObjectName; + + RC_Thread_09_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class RC_Thread_09_D2 { + int a; + int sum; + String strObjectName; + + RC_Thread_09_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class RC_Thread_09_D3 { + int a; + int sum; + String strObjectName; + + RC_Thread_09_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0237-rc-function-RC_Thread02-RC_Thread_10/RC_Thread_10.java b/test/testsuite/ouroboros/rc_test/RC0237-rc-function-RC_Thread02-RC_Thread_10/RC_Thread_10.java new file mode 100755 index 0000000000000000000000000000000000000000..49309ea00661982213ec7f2e8990075037f6996c --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0237-rc-function-RC_Thread02-RC_Thread_10/RC_Thread_10.java @@ -0,0 +1,295 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread02/RC_Thread_10 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Multi Thread reads or writes static para.mofidfy from Nocycle_a_00050 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Thread_10.java + *- @ExecuteClass: RC_Thread_10 + *- @ExecuteArgs: + *- @Remark: + + * + */ +class RC_Thread_10_1 extends Thread { + public void run() { + RC_Thread_10 rcth01 = new RC_Thread_10("rcth01"); + try { + rcth01.addSum(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_10_2 extends Thread { + public void run() { + RC_Thread_10 rcth01 = new RC_Thread_10("rcth01"); + try { + rcth01.ModifyB4(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_10_3 extends Thread { + public void run() { + RC_Thread_10 rcth01 = new RC_Thread_10("rcth01"); + try { + rcth01.deleteA1(); + } catch (NullPointerException e) { + + } + + } +} + +class RC_Thread_10_4 extends Thread { + public void run() { + RC_Thread_10 rcth01 = new RC_Thread_10("rcth01"); + try { + rcth01.setA1(null); + } catch (NullPointerException e) { + + } + } +} + + +public class RC_Thread_10 { + private static RC_Thread_10_A1 a1 = null; + + RC_Thread_10(String str) { + try { + a1 = new RC_Thread_10_A1("a1"); + a1.b1_0 = new RC_Thread_10_B1("b1_0"); + a1.b1_0.c1_0 = new RC_Thread_10_C1("c1_0"); + a1.b1_0.c2_0 = new RC_Thread_10_C2("c2_0"); + a1.b1_0.c3_0 = new RC_Thread_10_C3("c3_0"); + a1.b2_0 = new RC_Thread_10_B2("b2_0"); + a1.b3_0 = new RC_Thread_10_B3("b3_0"); + a1.b4_0 = new RC_Thread_10_B4("b4_0"); + } catch (NullPointerException e) { + + } + } + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + + private static void rc_testcase_main_wrapper() { + RC_Thread_10_1 t1 = new RC_Thread_10_1(); + RC_Thread_10_2 t2 = new RC_Thread_10_2(); + RC_Thread_10_3 t3 = new RC_Thread_10_3(); + RC_Thread_10_4 t4 = new RC_Thread_10_4(); + t1.start(); + t2.start(); + t3.start(); + t4.start(); + try { + t1.join(); + t2.join(); + t3.join(); + t4.join(); + + } catch (InterruptedException e) { + } + } + + public void deleteA1() { + a1 = null; + } + + public void ModifyB4() { + try { + a1.b4_0 = new RC_Thread_10_B4("new_b4"); + } catch (NullPointerException e) { + + } + } + + public void addSum() { + try { + a1.add(); + a1.b1_0.add(); + a1.b2_0.add(); + a1.b3_0.add(); + a1.b4_0.add(); + a1.b1_0.c1_0.add(); + a1.b1_0.c2_0.add(); + a1.b1_0.c3_0.add(); + } catch (NullPointerException e) { + + } + } + + public void setA1(RC_Thread_10_A1 a1) { + this.a1 = a1; + } + + class RC_Thread_10_A1 { + RC_Thread_10_B1 b1_0; + RC_Thread_10_B2 b2_0; + RC_Thread_10_B3 b3_0; + RC_Thread_10_B4 b4_0; + int a; + int sum; + String strObjectName; + + RC_Thread_10_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } + } + + class RC_Thread_10_B1 { + RC_Thread_10_C1 c1_0; + RC_Thread_10_C2 c2_0; + RC_Thread_10_C3 c3_0; + int a; + int sum; + String strObjectName; + + RC_Thread_10_B1(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } + } + + class RC_Thread_10_B2 { + int a; + int sum; + String strObjectName; + + RC_Thread_10_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + + class RC_Thread_10_B3 { + int a; + int sum; + String strObjectName; + + RC_Thread_10_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class RC_Thread_10_B4 { + int a; + int sum; + String strObjectName; + + RC_Thread_10_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class RC_Thread_10_C1 { + int a; + int sum; + String strObjectName; + + RC_Thread_10_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class RC_Thread_10_C2 { + int a; + int sum; + String strObjectName; + + RC_Thread_10_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class RC_Thread_10_C3 { + int a; + int sum; + String strObjectName; + + RC_Thread_10_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0238-rc-function-RC_Thread02-RC_Thread_11/RC_Thread_11.java b/test/testsuite/ouroboros/rc_test/RC0238-rc-function-RC_Thread02-RC_Thread_11/RC_Thread_11.java new file mode 100755 index 0000000000000000000000000000000000000000..10a01d0f94865ea57be6dcc6ca69cfb154f0022e --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0238-rc-function-RC_Thread02-RC_Thread_11/RC_Thread_11.java @@ -0,0 +1,429 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread02/RC_Thread_11 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Multi Thread reads or writes static para.mofidfy from Nocycle_a_00180 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Thread_11.java + *- @ExecuteClass: RC_Thread_11 + *- @ExecuteArgs: + *- @Remark: + + * + */ + +class RC_Thread_11_1 extends Thread { + public void run() { + RC_Thread_11 rcth01 = new RC_Thread_11(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_11_2 extends Thread { + public void run() { + RC_Thread_11 rcth01 = new RC_Thread_11(); + try { + rcth01.setA2null(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_11_3 extends Thread { + public void run() { + RC_Thread_11 rcth01 = new RC_Thread_11(); + try { + rcth01.setA3(); + } catch (NullPointerException e) { + + } + + } +} + +class RC_Thread_11_4 extends Thread { + public void run() { + RC_Thread_11 rcth01 = new RC_Thread_11(); + try { + rcth01.setA3null(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_11_5 extends Thread { + public void run() { + RC_Thread_11 rcth01 = new RC_Thread_11(); + try { + rcth01.setA4(); + } catch (NullPointerException e) { + + } + + } +} + +public class RC_Thread_11 { + private static RC_Thread_11_A1 a1_main = null; + private static RC_Thread_11_A2 a2_main = null; + private static RC_Thread_11_A3 a3_main = null; + private static RC_Thread_11_A4 a4_main = null; + + RC_Thread_11() { + try { + a1_main = new RC_Thread_11_A1("a1_main"); + a2_main = new RC_Thread_11_A2("a2_main"); + a3_main = new RC_Thread_11_A3("a3_main"); + a4_main = new RC_Thread_11_A4("a4_main"); + a1_main.b1_0 = new RC_Thread_11_B1("b1_0"); + a1_main.d1_0 = new RC_Thread_11_D1("d1_0"); + a1_main.b1_0.d2_0 = new RC_Thread_11_D2("d2_0"); + + a2_main.b2_0 = new RC_Thread_11_B2("b2_0"); + a2_main.b2_0.c1_0 = new RC_Thread_11_C1("c1_0"); + a2_main.b2_0.d1_0 = new RC_Thread_11_D1("d1_0"); + a2_main.b2_0.d2_0 = new RC_Thread_11_D2("d2_0"); + a2_main.b2_0.d3_0 = new RC_Thread_11_D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = new RC_Thread_11_D1("d1_0"); + + a3_main.b2_0 = new RC_Thread_11_B2("b2_0"); + a3_main.b2_0.c1_0 = new RC_Thread_11_C1("c1_0"); + a3_main.b2_0.c1_0.d1_0 = new RC_Thread_11_D1("d1_0"); + a3_main.b2_0.d1_0 = new RC_Thread_11_D1("d1_0"); + a3_main.b2_0.d2_0 = new RC_Thread_11_D2("d2_0"); + a3_main.b2_0.d3_0 = new RC_Thread_11_D3("d3_0"); + + a3_main.c2_0 = new RC_Thread_11_C2("c2_0"); + a3_main.c2_0.d2_0 = new RC_Thread_11_D2("d2_0"); + a3_main.c2_0.d3_0 = new RC_Thread_11_D3("d3_0"); + + a4_main.b3_0 = new RC_Thread_11_B3("b3_0"); + a4_main.b3_0.c1_0 = new RC_Thread_11_C1("c1_0"); + a4_main.b3_0.c1_0.d1_0 = new RC_Thread_11_D1("d1_0"); + a4_main.c2_0 = new RC_Thread_11_C2("c2_0"); + a4_main.c2_0.d2_0 = new RC_Thread_11_D2("d2_0"); + a4_main.c2_0.d3_0 = new RC_Thread_11_D3("d3_0"); + } catch (NullPointerException e) { + + } + } + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + + private static void rc_testcase_main_wrapper() { + RC_Thread_11_1 t1 = new RC_Thread_11_1(); + RC_Thread_11_2 t2 = new RC_Thread_11_2(); + RC_Thread_11_3 t3 = new RC_Thread_11_3(); + RC_Thread_11_4 t4 = new RC_Thread_11_4(); + RC_Thread_11_5 t5 = new RC_Thread_11_5(); + t1.start(); + t2.start(); + t3.start(); + t4.start(); + t5.start(); + try { + t1.join(); + t2.join(); + t3.join(); + t4.join(); + t5.join(); + + } catch (InterruptedException e) { + } + } + + public void setA1null() { + a1_main = null; + } + + public void setA2null() { + a2_main = null; + } + + public void setA3() { + try { + a3_main.c2_0.d2_0 = new RC_Thread_11_D2("new"); + a3_main = new RC_Thread_11_A3("a3_new"); + a3_main = null; + } catch (NullPointerException e) { + + } + } + + public void setA3null() { + a3_main = null; + } + + public void setA4() { + try { + a4_main = new RC_Thread_11_A4("a4_new"); + + } catch (NullPointerException e) { + } + } + + class RC_Thread_11_A1 { + RC_Thread_11_B1 b1_0; + RC_Thread_11_D1 d1_0; + int a; + int sum; + String strObjectName; + + RC_Thread_11_A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + d1_0.a; + } + } + + + class RC_Thread_11_A2 { + RC_Thread_11_B2 b2_0; + int a; + int sum; + String strObjectName; + + RC_Thread_11_A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b2_0.a; + } + } + + + class RC_Thread_11_A3 { + RC_Thread_11_B2 b2_0; + RC_Thread_11_C2 c2_0; + int a; + int sum; + String strObjectName; + + RC_Thread_11_A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + b2_0.a + c2_0.a; + } + } + + class RC_Thread_11_A4 { + RC_Thread_11_B3 b3_0; + RC_Thread_11_C2 c2_0; + int a; + int sum; + String strObjectName; + + RC_Thread_11_A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + b3_0.a + c2_0.a; + } + } + + + class RC_Thread_11_B1 { + RC_Thread_11_D2 d2_0; + int a; + int sum; + String strObjectName; + + RC_Thread_11_B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + d2_0.a; + } + } + + + class RC_Thread_11_B2 { + RC_Thread_11_C1 c1_0; + RC_Thread_11_D1 d1_0; + RC_Thread_11_D2 d2_0; + RC_Thread_11_D3 d3_0; + int a; + int sum; + String strObjectName; + + RC_Thread_11_B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } + } + + + class RC_Thread_11_B3 { + RC_Thread_11_C1 c1_0; + int a; + int sum; + String strObjectName; + + RC_Thread_11_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } + } + + + class RC_Thread_11_C1 { + RC_Thread_11_D1 d1_0; + int a; + int sum; + String strObjectName; + + RC_Thread_11_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + d1_0.a; + } + } + + class RC_Thread_11_C2 { + RC_Thread_11_D2 d2_0; + RC_Thread_11_D3 d3_0; + int a; + int sum; + String strObjectName; + + RC_Thread_11_C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + d2_0.a + d3_0.a; + } + } + + + class RC_Thread_11_D1 { + int a; + int sum; + String strObjectName; + + RC_Thread_11_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class RC_Thread_11_D2 { + int a; + int sum; + String strObjectName; + + RC_Thread_11_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class RC_Thread_11_D3 { + int a; + int sum; + String strObjectName; + + RC_Thread_11_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0239-rc-function-RC_Thread02-RC_Thread_12/RC_Thread_12.java b/test/testsuite/ouroboros/rc_test/RC0239-rc-function-RC_Thread02-RC_Thread_12/RC_Thread_12.java new file mode 100755 index 0000000000000000000000000000000000000000..639800d067d1f269b3941353f2236c0d1e6723c4 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0239-rc-function-RC_Thread02-RC_Thread_12/RC_Thread_12.java @@ -0,0 +1,219 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread02/RC_Thread_12 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Multi Thread reads or writes static para.mofidfy from Cycle_B_1_00180 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Thread_12.java + *- @ExecuteClass: RC_Thread_12 + *- @ExecuteArgs: + *- @Remark: + + * + */ +import java.lang.Runtime; +class RC_Thread_12_1 extends Thread { + public void run() { + RC_Thread_12 rcth01 = new RC_Thread_12(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_12_2 extends Thread { + public void run() { + RC_Thread_12 rcth01 = new RC_Thread_12(); + try { + rcth01.setA4null(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_12_3 extends Thread { + public void run() { + RC_Thread_12 rcth01 = new RC_Thread_12(); + try { + rcth01.setA5null(); + } catch (NullPointerException e) { + + } + + } +} + +public class RC_Thread_12 { + private static RC_Thread_12_A1 a1_main = null; + private static RC_Thread_12_A4 a4_main = null; + private static RC_Thread_12_A5 a5_main = null; + + RC_Thread_12() { + try { + a1_main = new RC_Thread_12_A1(); + a1_main.a2_0 = new RC_Thread_12_A2(); + a1_main.a2_0.a3_0 = new RC_Thread_12_A3(); + a4_main = new RC_Thread_12_A4(); + a5_main = new RC_Thread_12_A5(); + a4_main.a1_0 = a1_main; + a5_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + } catch (NullPointerException e) { + + } + } + + public static void main(String[] args) { + cycle_pattern_wrapper(); + + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + System.out.println("ExpectResult"); + } + + private static void cycle_pattern_wrapper(){ + a1_main = new RC_Thread_12_A1(); + a1_main.a2_0 = new RC_Thread_12_A2(); + a1_main.a2_0.a3_0 = new RC_Thread_12_A3(); + a4_main = new RC_Thread_12_A4(); + a5_main = new RC_Thread_12_A5(); + a4_main.a1_0 = a1_main; + a5_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main=null; + a4_main=null; + a5_main=null; + Runtime.getRuntime().gc(); + } + + private static void rc_testcase_main_wrapper() { + RC_Thread_12_1 t1 = new RC_Thread_12_1(); + RC_Thread_12_2 t2 = new RC_Thread_12_2(); + RC_Thread_12_3 t3 = new RC_Thread_12_3(); + t1.start(); + t2.start(); + t3.start(); + try { + t1.join(); + t2.join(); + t3.join(); + + } catch (InterruptedException e) { + } + } + + public void setA1null() { + a1_main = null; + } + + public void setA4null() { + a4_main = null; + } + + public void setA5null() { + a5_main = null; + } + + static class RC_Thread_12_A1 { + RC_Thread_12_A2 a2_0; + int a; + int sum; + + RC_Thread_12_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + + static class RC_Thread_12_A2 { + RC_Thread_12_A3 a3_0; + int a; + int sum; + + RC_Thread_12_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + + static class RC_Thread_12_A3 { + RC_Thread_12_A1 a1_0; + int a; + int sum; + + RC_Thread_12_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + static class RC_Thread_12_A4 { + RC_Thread_12_A1 a1_0; + int a; + int sum; + + RC_Thread_12_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + + static class RC_Thread_12_A5 { + RC_Thread_12_A1 a1_0; + int a; + int sum; + + RC_Thread_12_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0240-rc-function-RC_Thread02-RC_Thread_13/RC_Thread_13.java b/test/testsuite/ouroboros/rc_test/RC0240-rc-function-RC_Thread02-RC_Thread_13/RC_Thread_13.java new file mode 100755 index 0000000000000000000000000000000000000000..576a8d148256e44f2d0b68a8ebc7d6364baa6d9b --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0240-rc-function-RC_Thread02-RC_Thread_13/RC_Thread_13.java @@ -0,0 +1,274 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread02/RC_Thread_13 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Multi Thread reads or writes static para.mofidfy from Cycle_B_1_00180 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Thread_13.java + *- @ExecuteClass: RC_Thread_13 + *- @ExecuteArgs: + *- @Remark: + + * + */ +import java.lang.Runtime; +class RC_Thread_13_1 extends Thread { + public void run() { + RC_Thread_13 rcth01 = new RC_Thread_13(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_13_2 extends Thread { + public void run() { + RC_Thread_13 rcth01 = new RC_Thread_13(); + try { + rcth01.setA4null(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_13_3 extends Thread { + public void run() { + RC_Thread_13 rcth01 = new RC_Thread_13(); + try { + rcth01.setA5null(); + } catch (NullPointerException e) { + + } + + } +} + +class RC_Thread_13_4 extends Thread { + public void run() { + RC_Thread_13 rcth01 = new RC_Thread_13(); + try { + rcth01.setA1(); + } catch (NullPointerException e) { + + } + + } +} + +class RC_Thread_13_5 extends Thread { + public void run() { + RC_Thread_13 rcth01 = new RC_Thread_13(); + try { + rcth01.checkA3(); + } catch (NullPointerException e) { + + } + + } +} + +class RC_Thread_13_6 extends Thread { + public void run() { + RC_Thread_13 rcth01 = new RC_Thread_13(); + try { + rcth01.setA3_a(5); + } catch (NullPointerException e) { + + } + + } +} + +public class RC_Thread_13 { + private static RC_Thread_13_A1 a1_main = null; + private static RC_Thread_13_A4 a4_main = null; + private static RC_Thread_13_A5 a5_main = null; + + RC_Thread_13() { + try { + a1_main = new RC_Thread_13_A1(); + a1_main.a2_0 = new RC_Thread_13_A2(); + a1_main.a2_0.a3_0 = new RC_Thread_13_A3(); + a4_main = new RC_Thread_13_A4(); + a5_main = new RC_Thread_13_A5(); + a4_main.a1_0 = a1_main; + a5_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + } catch (NullPointerException e) { + + } + } + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + System.out.println("ExpectResult"); + } + + private static void rc_testcase_main_wrapper() { + RC_Thread_13_1 t1 = new RC_Thread_13_1(); + RC_Thread_13_2 t2 = new RC_Thread_13_2(); + RC_Thread_13_3 t3 = new RC_Thread_13_3(); + RC_Thread_13_4 t4 = new RC_Thread_13_4(); + RC_Thread_13_5 t5 = new RC_Thread_13_5(); + RC_Thread_13_6 t6 = new RC_Thread_13_6(); + t1.start(); + t2.start(); + t3.start(); + t4.start(); + t5.start(); + t6.start(); + try { + t1.join(); + t2.join(); + t3.join(); + t4.join(); + t5.join(); + t6.join(); + + } catch (InterruptedException e) { + } + } + + public void setA1null() { + a1_main = null; + } + + public void setA4null() { + a4_main = null; + } + + public void setA5null() { + a5_main = null; + } + + public void setA1() { + try { + this.a1_main = new RC_Thread_13_A1(); + a1_main.a2_0 = new RC_Thread_13_A2(); + a1_main.a2_0.a3_0 = new RC_Thread_13_A3(); + } catch (NullPointerException e) { + + } + + } + + public void checkA3() { + try { + int a = a1_main.a2_0.a3_0.a; + } catch (NullPointerException e) { + + } + + } + + public void setA3_a(int a) { + try { + this.a1_main.a2_0.a3_0.a = a; + } catch (NullPointerException e) { + } + } + + class RC_Thread_13_A1 { + RC_Thread_13_A2 a2_0; + int a; + int sum; + + RC_Thread_13_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + + class RC_Thread_13_A2 { + RC_Thread_13_A3 a3_0; + int a; + int sum; + + RC_Thread_13_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + + class RC_Thread_13_A3 { + RC_Thread_13_A1 a1_0; + int a; + int sum; + + RC_Thread_13_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class RC_Thread_13_A4 { + RC_Thread_13_A1 a1_0; + int a; + int sum; + + RC_Thread_13_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + + class RC_Thread_13_A5 { + RC_Thread_13_A1 a1_0; + int a; + int sum; + + RC_Thread_13_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0241-rc-function-RC_Thread02-RC_Thread_14/RC_Thread_14.java b/test/testsuite/ouroboros/rc_test/RC0241-rc-function-RC_Thread02-RC_Thread_14/RC_Thread_14.java new file mode 100755 index 0000000000000000000000000000000000000000..a6506dd633d82a6f62ad71f0e3eb08556e872886 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0241-rc-function-RC_Thread02-RC_Thread_14/RC_Thread_14.java @@ -0,0 +1,262 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread02/RC_Thread_14 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Multi Thread reads or writes static para.mofidfy from Cycle_B_2_00130 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Thread_14.java + *- @ExecuteClass: RC_Thread_14 + *- @ExecuteArgs: + *- @Remark: + + * + */ +import java.lang.Runtime; +class RC_Thread_14_1 extends Thread { + public void run() { + RC_Thread_14 rcth01 = new RC_Thread_14(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + e.printStackTrace(); + } + } +} + +class RC_Thread_14_2 extends Thread { + public void run() { + RC_Thread_14 rcth01 = new RC_Thread_14(); + try { + rcth01.setA4null(); + } catch (NullPointerException e) { + e.printStackTrace(); + } + } +} + +class RC_Thread_14_3 extends Thread { + public void run() { + RC_Thread_14 rcth01 = new RC_Thread_14(); + try { + rcth01.setA5null(); + } catch (NullPointerException e) { + e.printStackTrace(); + } + + } +} + +public class RC_Thread_14 { + private static RC_Thread_14_A1 a1_main = null; + private static RC_Thread_14_A5 a5_main = null; + + RC_Thread_14() { + try { + a1_main = new RC_Thread_14_A1(); + a1_main.a2_0 = new RC_Thread_14_A2(); + a1_main.a2_0.a3_0 = new RC_Thread_14_A3(); + a1_main.a2_0.a3_0.a4_0 = new RC_Thread_14_A4(); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a5_main = new RC_Thread_14_A5(); + a1_main.a2_0.a3_0.a4_0.a6_0 = new RC_Thread_14_A6(); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + } catch (NullPointerException e) { + } + } + + public static void main(String[] args) { + cycle_pattern_wrapper(); + Runtime.getRuntime().gc(); + + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + System.out.println("ExpectResult"); + } + + private static void cycle_pattern_wrapper(){ + a1_main = new RC_Thread_14_A1(); + a1_main.a2_0 = new RC_Thread_14_A2(); + a1_main.a2_0.a3_0 = new RC_Thread_14_A3(); + a1_main.a2_0.a3_0.a4_0 = new RC_Thread_14_A4(); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a5_main = new RC_Thread_14_A5(); + a1_main.a2_0.a3_0.a4_0.a6_0 = new RC_Thread_14_A6(); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a1_main=null; + a5_main=null; + + a1_main = new RC_Thread_14_A1(); + a1_main.a2_0 = new RC_Thread_14_A2(); + a1_main.a2_0.a3_0 = new RC_Thread_14_A3(); + a1_main.a2_0.a3_0.a4_0 = new RC_Thread_14_A4(); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main=null; + + a1_main = new RC_Thread_14_A1(); + a1_main.a2_0 = new RC_Thread_14_A2(); + a1_main.a2_0.a3_0 = new RC_Thread_14_A3(); + a1_main.a2_0.a3_0.a4_0 = new RC_Thread_14_A4(); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a5_main = new RC_Thread_14_A5(); + a1_main.a2_0.a3_0.a4_0.a6_0 = new RC_Thread_14_A6(); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0=null; + a1_main=null; + a5_main=null; + //Runtime.getRuntime().gc(); + } + + private static void rc_testcase_main_wrapper() { + RC_Thread_14_1 t1 = new RC_Thread_14_1(); + RC_Thread_14_2 t2 = new RC_Thread_14_2(); + RC_Thread_14_3 t3 = new RC_Thread_14_3(); + t1.start(); + t2.start(); + t3.start(); + try { + t1.join(); + t2.join(); + t3.join(); + } catch (InterruptedException e) { + } + } + + public void setA1null() { + a1_main = null; + } + + public void setA4null() { + try { + a1_main.a2_0.a3_0.a4_0 = null; + a5_main.a3_0.a4_0 = null; + } catch (NullPointerException e) { + } + } + + public void setA5null() { + a5_main = null; + } + + static class RC_Thread_14_A1 { + RC_Thread_14_A2 a2_0; + RC_Thread_14_A4 a4_0; + int a; + int sum; + + RC_Thread_14_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + + static class RC_Thread_14_A2 { + RC_Thread_14_A3 a3_0; + int a; + int sum; + + RC_Thread_14_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + + static class RC_Thread_14_A3 { + RC_Thread_14_A4 a4_0; + int a; + int sum; + + RC_Thread_14_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } + + + static class RC_Thread_14_A4 { + RC_Thread_14_A1 a1_0; + RC_Thread_14_A6 a6_0; + int a; + int sum; + + RC_Thread_14_A4() { + a1_0 = null; + a6_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a + a6_0.a; + } + } + + static class RC_Thread_14_A5 { + RC_Thread_14_A3 a3_0; + int a; + int sum; + + RC_Thread_14_A5() { + a3_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + static class RC_Thread_14_A6 { + RC_Thread_14_A5 a5_0; + int a; + int sum; + + RC_Thread_14_A6() { + a5_0 = null; + a = 6; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0242-rc-function-RC_Thread02-RC_Thread_15/RC_Thread_15.java b/test/testsuite/ouroboros/rc_test/RC0242-rc-function-RC_Thread02-RC_Thread_15/RC_Thread_15.java new file mode 100755 index 0000000000000000000000000000000000000000..eeedc693f6d5c000d64e83a58999f929c059a7ac --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0242-rc-function-RC_Thread02-RC_Thread_15/RC_Thread_15.java @@ -0,0 +1,249 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread02/RC_Thread_15 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Multi Thread reads or writes static para.mofidfy from Cycle_B_2_00130 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Thread_15.java + *- @ExecuteClass: RC_Thread_15 + *- @ExecuteArgs: + *- @Remark: + + * + */ +import java.lang.Runtime; +class RC_Thread_15_1 extends Thread { + public void run() { + RC_Thread_15 rcth01 = new RC_Thread_15(); + try { + rcth01.ModifyA1(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_15_2 extends Thread { + public void run() { + RC_Thread_15 rcth01 = new RC_Thread_15(); + try { + rcth01.checkA4(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_15_3 extends Thread { + public void run() { + RC_Thread_15 rcth01 = new RC_Thread_15(); + try { + rcth01.setA5(); + } catch (NullPointerException e) { + + } + + } +} + +public class RC_Thread_15 { + private static RC_Thread_15_A1 a1_main = null; + private static RC_Thread_15_A5 a5_main = null; + + RC_Thread_15() { + try { + RC_Thread_15_A1 a1 = new RC_Thread_15_A1(); + a1.a2_0 = new RC_Thread_15_A2(); + a1.a2_0.a3_0 = new RC_Thread_15_A3(); + a1.a2_0.a3_0.a4_0 = new RC_Thread_15_A4(); + a1.a2_0.a3_0.a4_0.a1_0 = a1; + RC_Thread_15_A5 a5 = new RC_Thread_15_A5(); + a1.a2_0.a3_0.a4_0.a6_0 = new RC_Thread_15_A6(); + a1.a2_0.a3_0.a4_0.a6_0.a5_0 = a5; + a5.a3_0 = a1.a2_0.a3_0; + a1_main = a1; + a5_main = a5; + } catch (NullPointerException e) { + + } + } + + public static void main(String[] args) { + cycle_pattern_wrapper(); + + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + System.out.println("ExpectResult"); + } + + private static void cycle_pattern_wrapper(){ + RC_Thread_15_A1 a1 = new RC_Thread_15_A1(); + a1.a2_0 = new RC_Thread_15_A2(); + a1.a2_0.a3_0 = new RC_Thread_15_A3(); + a1.a2_0.a3_0.a4_0 = new RC_Thread_15_A4(); + a1.a2_0.a3_0.a4_0.a1_0 = a1; + RC_Thread_15_A5 a5 = new RC_Thread_15_A5(); + a1.a2_0.a3_0.a4_0.a6_0 = new RC_Thread_15_A6(); + a1.a2_0.a3_0.a4_0.a6_0.a5_0 = a5; + a5.a3_0 = a1.a2_0.a3_0; + a1=null; + a5=null; + Runtime.getRuntime().gc(); + } + + private static void rc_testcase_main_wrapper() { + RC_Thread_15_1 t1 = new RC_Thread_15_1(); + RC_Thread_15_2 t2 = new RC_Thread_15_2(); + RC_Thread_15_3 t3 = new RC_Thread_15_3(); + t1.start(); + t2.start(); + t3.start(); + try { + t1.join(); + t2.join(); + t3.join(); + } catch (InterruptedException e) { + } + } + + public void ModifyA1() { + a1_main.a2_0.a3_0 = null; + a1_main = null; + } + + public void checkA4() { + try { + int[] arr = new int[2]; + arr[0] = a5_main.a3_0.a4_0.sum; + arr[1] = a5_main.a3_0.a4_0.a; + } catch (NullPointerException e) { + + } + } + + public void setA5() { + RC_Thread_15_A5 a5 = new RC_Thread_15_A5(); + a5 = this.a5_main; + a5_main = null; + } + + static class RC_Thread_15_A1 { + RC_Thread_15_A2 a2_0; + RC_Thread_15_A4 a4_0; + int a; + int sum; + + RC_Thread_15_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + + static class RC_Thread_15_A2 { + RC_Thread_15_A3 a3_0; + int a; + int sum; + + RC_Thread_15_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + + static class RC_Thread_15_A3 { + RC_Thread_15_A4 a4_0; + int a; + int sum; + + RC_Thread_15_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } + + + static class RC_Thread_15_A4 { + RC_Thread_15_A1 a1_0; + RC_Thread_15_A6 a6_0; + int a; + int sum; + + RC_Thread_15_A4() { + a1_0 = null; + a6_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a + a6_0.a; + } + } + + static class RC_Thread_15_A5 { + RC_Thread_15_A3 a3_0; + int a; + int sum; + + RC_Thread_15_A5() { + a3_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + static class RC_Thread_15_A6 { + RC_Thread_15_A5 a5_0; + int a; + int sum; + + RC_Thread_15_A6() { + a5_0 = null; + a = 6; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0243-rc-function-RC_Thread02-RC_Thread_16/RC_Thread_16.java b/test/testsuite/ouroboros/rc_test/RC0243-rc-function-RC_Thread02-RC_Thread_16/RC_Thread_16.java new file mode 100755 index 0000000000000000000000000000000000000000..eb6f2cc1840c9c20a296b764ecef5c30c8f753bb --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0243-rc-function-RC_Thread02-RC_Thread_16/RC_Thread_16.java @@ -0,0 +1,285 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread02/RC_Thread_16 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Multi Thread reads or writes static para.mofidfy from Cycle_a_00320 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Thread_16.java + *- @ExecuteClass: RC_Thread_16 + *- @ExecuteArgs: + *- @Remark: + * + */ +import java.lang.Runtime; +class RC_Thread_16_1 extends Thread { + public void run() { + RC_Thread_16 rcth01 = new RC_Thread_16(); + try { + rcth01.ModifyA3(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_16_2 extends Thread { + public void run() { + RC_Thread_16 rcth01 = new RC_Thread_16(); + try { + rcth01.checkA3(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_16_3 extends Thread { + public void run() { + RC_Thread_16 rcth01 = new RC_Thread_16(); + try { + rcth01.setA3null(); + } catch (NullPointerException e) { + + } + + } +} + +public class RC_Thread_16 { + private static RC_Thread_16_A1 a1_main = null; + private static RC_Thread_16_A4 a4_main = null; + private static RC_Thread_16_A6 a6_main = null; + + RC_Thread_16() { + try { + RC_Thread_16_A1 a1 = new RC_Thread_16_A1("a1"); + RC_Thread_16_A4 a4 = new RC_Thread_16_A4("a4"); + RC_Thread_16_A6 a6 = new RC_Thread_16_A6("a6"); + a1.a2_0 = new RC_Thread_16_A2("a2_0"); + a1.a2_0.a3_0 = new RC_Thread_16_A3("a3_0"); + a1.a2_0.a3_0.a1_0 = a1; + a1.a2_0.a3_0.a5_0 = new RC_Thread_16_A5("a5_0"); + a1.a2_0.a3_0.a5_0.a6_0 = a6; + a6.a1_0 = a1; + a6.a3_0 = a1.a2_0.a3_0; + a4.a5_0 = a1.a2_0.a3_0.a5_0; + a6.a4_0 = a4; + a1_main = a1; + a4_main = a4; + a6_main = a6; + } catch (NullPointerException e) { + + } + } + + public static void main(String[] args) { + cycle_pattern_wrapper(); + + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + System.out.println("ExpectResult"); + } + + private static void cycle_pattern_wrapper(){ + RC_Thread_16_A1 a1 = new RC_Thread_16_A1("a1"); + RC_Thread_16_A4 a4 = new RC_Thread_16_A4("a4"); + RC_Thread_16_A6 a6 = new RC_Thread_16_A6("a6"); + a1.a2_0 = new RC_Thread_16_A2("a2_0"); + a1.a2_0.a3_0 = new RC_Thread_16_A3("a3_0"); + a1.a2_0.a3_0.a1_0 = a1; + a1.a2_0.a3_0.a5_0 = new RC_Thread_16_A5("a5_0"); + a1.a2_0.a3_0.a5_0.a6_0 = a6; + a6.a1_0 = a1; + a6.a3_0 = a1.a2_0.a3_0; + a4.a5_0 = a1.a2_0.a3_0.a5_0; + a6.a4_0 = a4; + a1=null; + a4=null; + a6=null; + Runtime.getRuntime().gc(); + } + + private static void rc_testcase_main_wrapper() { + RC_Thread_16_1 t_00010 = new RC_Thread_16_1(); + RC_Thread_16_2 t_00020 = new RC_Thread_16_2(); + RC_Thread_16_3 t_00030 = new RC_Thread_16_3(); + t_00010.start(); + t_00020.start(); + t_00030.start(); + try { + t_00010.join(); + t_00020.join(); + t_00030.join(); + + } catch (InterruptedException e) { + } + + } + + public void checkA3() { + int[] arr = new int[2]; + try { + arr[0] = a1_main.a2_0.a3_0.a; + arr[1] = a1_main.a2_0.a3_0.sum; + } catch (NullPointerException e) { + + } + } + + public void ModifyA3() { + try { + a1_main.a2_0.a3_0 = new RC_Thread_16_A3("new-a3"); + } catch (NullPointerException e) { + + } + } + + public void setA3null() { + RC_Thread_16_A3 a3 = new RC_Thread_16_A3("test"); + try { + a3 = this.a1_main.a2_0.a3_0; + this.a1_main.a2_0.a3_0 = null; + } catch (NullPointerException e) { + + } + + } + + static class RC_Thread_16_A1 { + RC_Thread_16_A2 a2_0; + int a; + int sum; + String strObjectName; + + RC_Thread_16_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + static class RC_Thread_16_A2 { + RC_Thread_16_A3 a3_0; + int a; + int sum; + String strObjectName; + + RC_Thread_16_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + static class RC_Thread_16_A3 { + RC_Thread_16_A1 a1_0; + RC_Thread_16_A5 a5_0; + int a; + int sum; + String strObjectName; + + RC_Thread_16_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + + static class RC_Thread_16_A4 { + RC_Thread_16_A5 a5_0; + int a; + int sum; + String strObjectName; + + RC_Thread_16_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } + } + + static class RC_Thread_16_A5 { + RC_Thread_16_A6 a6_0; + int a; + int sum; + String strObjectName; + + RC_Thread_16_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + static class RC_Thread_16_A6 { + RC_Thread_16_A1 a1_0; + RC_Thread_16_A3 a3_0; + RC_Thread_16_A4 a4_0; + int a; + int sum; + String strObjectName; + + RC_Thread_16_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0244-rc-function-RC_Thread02-RC_Thread_17/RC_Thread_17.java b/test/testsuite/ouroboros/rc_test/RC0244-rc-function-RC_Thread02-RC_Thread_17/RC_Thread_17.java new file mode 100755 index 0000000000000000000000000000000000000000..067a4e5da941e8ca788871e66aacf0159f6f99ba --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0244-rc-function-RC_Thread02-RC_Thread_17/RC_Thread_17.java @@ -0,0 +1,223 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread02/RC_Thread_17 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Multi Thread reads or writes static para.mofidfy from Cycle_B_1_00180 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Thread_17.java + *- @ExecuteClass: RC_Thread_17 + *- @ExecuteArgs: + *- @Remark: + + * + */ +import java.lang.Runtime; +class RC_Thread_17_1 extends Thread { + public void run() { + RC_Thread_17 rcth01 = new RC_Thread_17(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_17_2 extends Thread { + public void run() { + RC_Thread_17 rcth01 = new RC_Thread_17(); + try { + rcth01.setA4null(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_17_3 extends Thread { + public void run() { + RC_Thread_17 rcth01 = new RC_Thread_17(); + try { + rcth01.setA5null(); + } catch (NullPointerException e) { + + } + + } +} + +public class RC_Thread_17 { + private static RC_Thread_17_A1 a1_main = null; + private static RC_Thread_17_A4 a4_main = null; + private static RC_Thread_17_A5 a5_main = null; + private static RC_Thread_17_A2 a2=null; + + RC_Thread_17() { + try { + a1_main = new RC_Thread_17_A1(); + a2 = new RC_Thread_17_A2(); + a1_main.a2_0=a2; + a1_main.a2_0.a3_0 = new RC_Thread_17_A3(); + a4_main = new RC_Thread_17_A4(); + a5_main = new RC_Thread_17_A5(); + a4_main.a1_0 = a1_main; + a5_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + } catch (NullPointerException e) { + + } + } + + public static void main(String[] args) { + cycle_pattern_wrapper(); + + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + System.out.println("ExpectResult"); + } + + private static void cycle_pattern_wrapper(){ + a1_main = new RC_Thread_17_A1(); + a2 = new RC_Thread_17_A2(); + a1_main.a2_0=a2; + a1_main.a2_0.a3_0 = new RC_Thread_17_A3(); + a4_main = new RC_Thread_17_A4(); + a5_main = new RC_Thread_17_A5(); + a4_main.a1_0 = a1_main; + a5_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main=null; + a4_main=null; + a2=null; + a5_main=null; + Runtime.getRuntime().gc(); + } + + private static void rc_testcase_main_wrapper() { + RC_Thread_17_1 t1 = new RC_Thread_17_1(); + RC_Thread_17_2 t2 = new RC_Thread_17_2(); + RC_Thread_17_3 t3 = new RC_Thread_17_3(); + t1.start(); + t2.start(); + t3.start(); + try { + t1.join(); + t2.join(); + t3.join(); + + } catch (InterruptedException e) { + } + } + + public void setA1null() { + a1_main = null; + } + + public void setA4null() { + a4_main = null; + } + + public void setA5null() { + a5_main = null; + } + + static class RC_Thread_17_A1 { + RC_Thread_17_A2 a2_0; + int a; + int sum; + + RC_Thread_17_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + + static class RC_Thread_17_A2 { + RC_Thread_17_A3 a3_0; + int a; + int sum; + + RC_Thread_17_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + + static class RC_Thread_17_A3 { + RC_Thread_17_A1 a1_0; + int a; + int sum; + + RC_Thread_17_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + static class RC_Thread_17_A4 { + RC_Thread_17_A1 a1_0; + int a; + int sum; + + RC_Thread_17_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + + static class RC_Thread_17_A5 { + RC_Thread_17_A1 a1_0; + int a; + int sum; + + RC_Thread_17_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0245-rc-function-RC_Thread02-RC_Thread_18/RC_Thread_18.java b/test/testsuite/ouroboros/rc_test/RC0245-rc-function-RC_Thread02-RC_Thread_18/RC_Thread_18.java new file mode 100755 index 0000000000000000000000000000000000000000..b2226c77b2d34141f46aeb85b2ced54a986d2c1e --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0245-rc-function-RC_Thread02-RC_Thread_18/RC_Thread_18.java @@ -0,0 +1,288 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread02/RC_Thread_18.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Multi Thread reads or writes static para.mofidfy from Cycle_a_00320 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Thread_18.java + *- @ExecuteClass: RC_Thread_18 + *- @ExecuteArgs: + *- @Remark: + * + */ +import java.lang.Runtime; +class RC_Thread_18_1 extends Thread { + public void run() { + RC_Thread_18 rcth01 = new RC_Thread_18(); + try { + rcth01.ModifyA3(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_18_2 extends Thread { + public void run() { + RC_Thread_18 rcth01 = new RC_Thread_18(); + try { + rcth01.checkA3(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_18_3 extends Thread { + public void run() { + RC_Thread_18 rcth01 = new RC_Thread_18(); + try { + rcth01.setA3null(); + } catch (NullPointerException e) { + + } + + } +} + +public class RC_Thread_18 { + private volatile static RC_Thread_18_A1 a1_main = null; + private volatile static RC_Thread_18_A4 a4_main = null; + private volatile static RC_Thread_18_A6 a6_main = null; + private static RC_Thread_18_A2 a2=null; + RC_Thread_18() { + try { + RC_Thread_18_A1 a1 = new RC_Thread_18_A1("a1"); + RC_Thread_18_A4 a4 = new RC_Thread_18_A4("a4"); + RC_Thread_18_A6 a6 = new RC_Thread_18_A6("a6"); + a2 = new RC_Thread_18_A2("a2_0"); + a1.a2_0=a2; + a1.a2_0.a3_0 = new RC_Thread_18_A3("a3_0"); + a1.a2_0.a3_0.a1_0 = a1; + a1.a2_0.a3_0.a5_0 = new RC_Thread_18_A5("a5_0"); + a1.a2_0.a3_0.a5_0.a6_0 = a6; + a6.a1_0 = a1; + a6.a3_0 = a1.a2_0.a3_0; + a4.a5_0 = a1.a2_0.a3_0.a5_0; + a6.a4_0 = a4; + a1_main = a1; + a4_main = a4; + a6_main = a6; + } catch (NullPointerException e) { + + } + } + + public static void main(String[] args) { + cycle_pattern_wrapper(); + + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + System.out.println("ExpectResult"); + + } + + private static void cycle_pattern_wrapper(){ + RC_Thread_18_A1 a1 = new RC_Thread_18_A1("a1"); + RC_Thread_18_A4 a4 = new RC_Thread_18_A4("a4"); + RC_Thread_18_A6 a6 = new RC_Thread_18_A6("a6"); + a2 = new RC_Thread_18_A2("a2_0"); + a1.a2_0=a2; + a1.a2_0.a3_0 = new RC_Thread_18_A3("a3_0"); + a1.a2_0.a3_0.a1_0 = a1; + a1.a2_0.a3_0.a5_0 = new RC_Thread_18_A5("a5_0"); + a1.a2_0.a3_0.a5_0.a6_0 = a6; + a6.a1_0 = a1; + a6.a3_0 = a1.a2_0.a3_0; + a4.a5_0 = a1.a2_0.a3_0.a5_0; + a6.a4_0 = a4; + a1=null; + a2=null; + a4=null; + a6=null; + Runtime.getRuntime().gc(); + } + + private static void rc_testcase_main_wrapper() { + RC_Thread_18_1 t_00010= new RC_Thread_18_1(); + RC_Thread_18_2 t_00020= new RC_Thread_18_2(); + RC_Thread_18_3 t_00030= new RC_Thread_18_3(); + t_00010.start(); + t_00020.start(); + t_00030.start(); + try { + t_00010.join(); + t_00020.join(); + t_00030.join(); + + } catch (InterruptedException e) {} + + } + + public void checkA3() { + int[] arr = new int[2]; + try { + arr[0] = a1_main.a2_0.a3_0.a; + arr[1] = a1_main.a2_0.a3_0.sum; + } catch (NullPointerException e) { + + } + } + + public void ModifyA3() { + try { + a1_main.a2_0.a3_0 = new RC_Thread_18_A3("new-a3"); + } catch (NullPointerException e) { + + } + } + + public void setA3null() { + RC_Thread_18_A3 a3 = new RC_Thread_18_A3("test"); + try { + a3 = this.a1_main.a2_0.a3_0; + this.a1_main.a2_0.a3_0 = null; + } catch (NullPointerException e) { + + } + + } + + static class RC_Thread_18_A1 { + volatile RC_Thread_18_A2 a2_0; + int a; + int sum; + String strObjectName; + + RC_Thread_18_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + static class RC_Thread_18_A2 { + volatile RC_Thread_18_A3 a3_0; + int a; + int sum; + String strObjectName; + + RC_Thread_18_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + static class RC_Thread_18_A3 { + volatile RC_Thread_18_A1 a1_0; + volatile RC_Thread_18_A5 a5_0; + int a; + int sum; + String strObjectName; + + RC_Thread_18_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + + static class RC_Thread_18_A4 { + volatile RC_Thread_18_A5 a5_0; + int a; + int sum; + String strObjectName; + + RC_Thread_18_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } + } + + static class RC_Thread_18_A5 { + volatile RC_Thread_18_A6 a6_0; + int a; + int sum; + String strObjectName; + + RC_Thread_18_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + static class RC_Thread_18_A6 { + volatile RC_Thread_18_A1 a1_0; + volatile RC_Thread_18_A3 a3_0; + volatile RC_Thread_18_A4 a4_0; + int a; + int sum; + String strObjectName; + + RC_Thread_18_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0246-rc-function-RC_Thread02-RC_Thread_19/RC_Thread_19.java b/test/testsuite/ouroboros/rc_test/RC0246-rc-function-RC_Thread02-RC_Thread_19/RC_Thread_19.java new file mode 100755 index 0000000000000000000000000000000000000000..a235e574c55845597c5c8a88a84a314b0cb83fd4 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0246-rc-function-RC_Thread02-RC_Thread_19/RC_Thread_19.java @@ -0,0 +1,297 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread02/RC_Thread_19 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Multi Thread reads or writes static para.mofidfy from Nocycle_a_00050 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Thread_19.java + *- @ExecuteClass: RC_Thread_19 + *- @ExecuteArgs: + *- @Remark: + + * + */ +class RC_Thread_19_1 extends Thread { + public void run() { + RC_Thread_19 rcth01 = new RC_Thread_19("rcth01"); + try { + rcth01.addSum(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_19_2 extends Thread { + public void run() { + RC_Thread_19 rcth01 = new RC_Thread_19("rcth01"); + try { + rcth01.ModifyB4(); + } catch (NullPointerException e) { + + } + } +} + +class RC_Thread_19_3 extends Thread { + public void run() { + RC_Thread_19 rcth01 = new RC_Thread_19("rcth01"); + try { + rcth01.deleteA1(); + } catch (NullPointerException e) { + + } + + } +} + +class RC_Thread_19_4 extends Thread { + public void run() { + RC_Thread_19 rcth01 = new RC_Thread_19("rcth01"); + try { + rcth01.setA1(null); + } catch (NullPointerException e) { + + } + } +} + + +public class RC_Thread_19 { + private static RC_Thread_19_A1 a1 = null; + private volatile static RC_Thread_19_B4 b4; + + RC_Thread_19(String str) { + try { + a1 = new RC_Thread_19_A1("a1"); + a1.b1_0 = new RC_Thread_19_B1("b1_0"); + a1.b1_0.c1_0 = new RC_Thread_19_C1("c1_0"); + a1.b1_0.c2_0 = new RC_Thread_19_C2("c2_0"); + a1.b1_0.c3_0 = new RC_Thread_19_C3("c3_0"); + a1.b2_0 = new RC_Thread_19_B2("b2_0"); + a1.b3_0 = new RC_Thread_19_B3("b3_0"); + b4=new RC_Thread_19_B4("b4_0"); + a1.b4_0 =b4; + } catch (NullPointerException e) { + + } + } + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + + private static void rc_testcase_main_wrapper() { + RC_Thread_19_1 t1 = new RC_Thread_19_1(); + RC_Thread_19_2 t2 = new RC_Thread_19_2(); + RC_Thread_19_3 t3 = new RC_Thread_19_3(); + RC_Thread_19_4 t4 = new RC_Thread_19_4(); + t1.start(); + t2.start(); + t3.start(); + t4.start(); + try { + t1.join(); + t2.join(); + t3.join(); + t4.join(); + + } catch (InterruptedException e) { + } + } + + public void deleteA1() { + a1 = null; + } + + public void ModifyB4() { + try { + a1.b4_0 = new RC_Thread_19_B4("new_b4"); + } catch (NullPointerException e) { + + } + } + + public void addSum() { + try { + a1.add(); + a1.b1_0.add(); + a1.b2_0.add(); + a1.b3_0.add(); + a1.b4_0.add(); + a1.b1_0.c1_0.add(); + a1.b1_0.c2_0.add(); + a1.b1_0.c3_0.add(); + } catch (NullPointerException e) { + + } + } + + public void setA1(RC_Thread_19_A1 a1) { + this.a1 = a1; + } + + class RC_Thread_19_A1 { + RC_Thread_19_B1 b1_0; + RC_Thread_19_B2 b2_0; + RC_Thread_19_B3 b3_0; + RC_Thread_19_B4 b4_0; + int a; + int sum; + String strObjectName; + + RC_Thread_19_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } + } + + class RC_Thread_19_B1 { + RC_Thread_19_C1 c1_0; + RC_Thread_19_C2 c2_0; + RC_Thread_19_C3 c3_0; + int a; + int sum; + String strObjectName; + + RC_Thread_19_B1(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } + } + + class RC_Thread_19_B2 { + int a; + int sum; + String strObjectName; + + RC_Thread_19_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + + class RC_Thread_19_B3 { + int a; + int sum; + String strObjectName; + + RC_Thread_19_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class RC_Thread_19_B4 { + int a; + int sum; + String strObjectName; + + RC_Thread_19_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class RC_Thread_19_C1 { + int a; + int sum; + String strObjectName; + + RC_Thread_19_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class RC_Thread_19_C2 { + int a; + int sum; + String strObjectName; + + RC_Thread_19_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class RC_Thread_19_C3 { + int a; + int sum; + String strObjectName; + + RC_Thread_19_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0247-rc-function-RC_Thread02-RC_Thread_20/RC_Thread_20.java b/test/testsuite/ouroboros/rc_test/RC0247-rc-function-RC_Thread02-RC_Thread_20/RC_Thread_20.java new file mode 100755 index 0000000000000000000000000000000000000000..7850875affba62811d5e2e4c0aba47e4fcd8db56 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0247-rc-function-RC_Thread02-RC_Thread_20/RC_Thread_20.java @@ -0,0 +1,249 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread02/RC_Thread_20 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Multi Thread reads or writes static para.mofidfy from Cycle_B_2_00130 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Thread_20.java + *- @ExecuteClass: RC_Thread_20 + *- @ExecuteArgs: + *- @Remark: + + * + */ +import java.lang.Runtime; +class RC_Thread_20_1 extends Thread { + public void run() { + RC_Thread_20 rcth01 = new RC_Thread_20(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + e.printStackTrace(); + } + } +} + +class RC_Thread_20_2 extends Thread { + public void run() { + RC_Thread_20 rcth01 = new RC_Thread_20(); + try { + rcth01.setA4null(); + } catch (NullPointerException e) { + e.printStackTrace(); + } + } +} + +class RC_Thread_20_3 extends Thread { + public void run() { + RC_Thread_20 rcth01 = new RC_Thread_20(); + try { + rcth01.setA5null(); + } catch (NullPointerException e) { + e.printStackTrace(); + } + + } +} + +public class RC_Thread_20 { + private static RC_Thread_20_A1 a1_main = null; + private static RC_Thread_20_A5 a5_main = null; + private static RC_Thread_20_A4 a4; + + RC_Thread_20() { + try { + RC_Thread_20_A1 a1 = new RC_Thread_20_A1(); + a1.a2_0 = new RC_Thread_20_A2(); + a1.a2_0.a3_0 = new RC_Thread_20_A3(); + RC_Thread_20_A4 a4_temp=new RC_Thread_20_A4(); + a1.a2_0.a3_0.a4_0 = a4_temp; + a1.a2_0.a3_0.a4_0.a1_0 = a1; + RC_Thread_20_A5 a5 = new RC_Thread_20_A5(); + a1.a2_0.a3_0.a4_0.a6_0 = new RC_Thread_20_A6(); + a1.a2_0.a3_0.a4_0.a6_0.a5_0 = a5; + a5.a3_0 = a1.a2_0.a3_0; + a1_main=a1; + a4=a4_temp; + a5_main=a5; + } catch (NullPointerException e) { + } + } + + public static void main(String[] args) { + cycle_pattern_wrapper(); + Runtime.getRuntime().gc(); + + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + + System.out.println("ExpectResult"); + } + + private static void cycle_pattern_wrapper(){ + a1_main = new RC_Thread_20_A1(); + a1_main.a2_0 = new RC_Thread_20_A2(); + a1_main.a2_0.a3_0 = new RC_Thread_20_A3(); + a4=new RC_Thread_20_A4(); + a1_main.a2_0.a3_0.a4_0 = a4; + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a5_main = new RC_Thread_20_A5(); + a1_main.a2_0.a3_0.a4_0.a6_0 = new RC_Thread_20_A6(); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a1_main=null; + a4=null; + a5_main=null; + Runtime.getRuntime().gc(); + } + + private static void rc_testcase_main_wrapper() { + RC_Thread_20_1 t1 = new RC_Thread_20_1(); + RC_Thread_20_2 t2 = new RC_Thread_20_2(); + RC_Thread_20_3 t3 = new RC_Thread_20_3(); + t1.start(); + t2.start(); + t3.start(); + try { + t1.join(); + t2.join(); + t3.join(); + } catch (InterruptedException e) { + } + } + + public void setA1null() { + a1_main = null; + } + + public void setA4null() { + try { + a1_main.a2_0.a3_0.a4_0 = null; + a5_main.a3_0.a4_0 = null; + } catch (NullPointerException e) { + } + } + + public void setA5null() { + a5_main = null; + } + + static class RC_Thread_20_A1 { + RC_Thread_20_A2 a2_0; + RC_Thread_20_A4 a4_0; + int a; + int sum; + + RC_Thread_20_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + + static class RC_Thread_20_A2 { + RC_Thread_20_A3 a3_0; + int a; + int sum; + + RC_Thread_20_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + + static class RC_Thread_20_A3 { + RC_Thread_20_A4 a4_0; + int a; + int sum; + + RC_Thread_20_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } + + + static class RC_Thread_20_A4 { + RC_Thread_20_A1 a1_0; + RC_Thread_20_A6 a6_0; + int a; + int sum; + + RC_Thread_20_A4() { + a1_0 = null; + a6_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a + a6_0.a; + } + } + + static class RC_Thread_20_A5 { + RC_Thread_20_A3 a3_0; + int a; + int sum; + + RC_Thread_20_A5() { + a3_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + static class RC_Thread_20_A6 { + RC_Thread_20_A5 a5_0; + int a; + int sum; + + RC_Thread_20_A6() { + a5_0 = null; + a = 6; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0248-rc-function-RC_Finalize_02/RC_Finalize_02.java b/test/testsuite/ouroboros/rc_test/RC0248-rc-function-RC_Finalize_02/RC_Finalize_02.java new file mode 100755 index 0000000000000000000000000000000000000000..2e6b142d2d4feaf5cd3ca77ff88611499b85a278 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0248-rc-function-RC_Finalize_02/RC_Finalize_02.java @@ -0,0 +1,38 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Finalize_02.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: test Finalizer for RC . + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Finalize_02.java + *- @ExecuteClass: RC_Finalize_02 + *- @ExecuteArgs: + *- @Remark: + */ +import java.io.PrintStream; + +public class RC_Finalize_02 { + + public void finalize() { + System.out.println("ExpectResult"); + } + + public static int run(String argv[], PrintStream out) { + return 0; + } + + public static void main(String argv[]) { + + System.runFinalizersOnExit(true); + RC_Finalize_02 testClass = new RC_Finalize_02(); + } +} // end RC_Finalize_02 +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0249-rc-function-RC_Finalize_03/RC_Finalize_03.java b/test/testsuite/ouroboros/rc_test/RC0249-rc-function-RC_Finalize_03/RC_Finalize_03.java new file mode 100755 index 0000000000000000000000000000000000000000..fc474f9fc6d7c4534f54036863f6ce74a6041901 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0249-rc-function-RC_Finalize_03/RC_Finalize_03.java @@ -0,0 +1,81 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Finalize_03.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: test Finalizer for RC . + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Finalize_03.java + *- @ExecuteClass: RC_Finalize_03 + *- @ExecuteArgs: + *- @Remark: + */ +import java.io.PrintStream; +class RC_Finalize_031 { + public void finalize() { + RC_Finalize_03.fo_finalized = true; + RC_Finalize_03.dummy = 1 / RC_Finalize_03.zero; + RC_Finalize_03.fo_exception_occerred = false; + } +} +public class RC_Finalize_03 { + + public static boolean fo_finalized; + public static boolean fo_exception_occerred; + public static final long TIMEOUT = 50000; + public static final int zero = 0; + public static int dummy; + + public static int run(String argv[], PrintStream out) { + + fo_finalized = false; + fo_exception_occerred = true; + + RC_Finalize_031 cl1 = new RC_Finalize_031(); + cl1 = null; + long startTime = System.currentTimeMillis(); + while (System.currentTimeMillis() - startTime < TIMEOUT){ + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + if (!fo_finalized) { + try { + Thread.sleep(500); + } catch (InterruptedException e) { + //out.println("InterruptedException: " + e); + return 2; + } catch(Throwable e) { + //out.println("Throwable: " + e); + return 2; + } + } else { + break; + } + } + if (!fo_finalized) { + //out.println("Ok, RC_Finalize_031 was not finalized during " + TIMEOUT/1000 + "sec"); + return 0; + } + + if (fo_exception_occerred) { + return 0; + } else { + //out.println("Failed: expected exception is not thrown"); + } + + return 2; + } + + public static void main(String argv[]) { + if(run(argv, System.out)==0) + System.out.println("ExpectResult"); + + } +} // end RC_Finalize_03 +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0250-rc-function-ROSAlloc-Alloc_11_15x8B/Alloc_11_15x8B.java b/test/testsuite/ouroboros/rc_test/RC0250-rc-function-ROSAlloc-Alloc_11_15x8B/Alloc_11_15x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..fa5427194e89e37df18617c1df341ddd477eff74 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0250-rc-function-ROSAlloc-Alloc_11_15x8B/Alloc_11_15x8B.java @@ -0,0 +1,75 @@ +/* + *- @TestCaseID:Alloc_11_15x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This testcase is mainly for testing objects from 11*8B to 15*8B(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_11_15x8B.java + *- @ExecuteClass: Alloc_11_15x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +public class Alloc_11_15x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_11_8B=11*8; + private final static int MAX_12_8B=12*8; + private final static int MAX_13_8B=13*8; + private final static int MAX_14_8B=14*8; + private final static int MAX_15_8B=15*8; + private static ArrayList store; + + private static int alloc_test(int slot_type){ + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + + for(;i<=slot_type-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*2/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + store=new ArrayList(); + return check_size; + } + public static void main(String[] args) { + store = new ArrayList(); + int countSize11 = alloc_test(MAX_11_8B); + int countSize12 = alloc_test(MAX_12_8B); + int countSize13 = alloc_test(MAX_13_8B); + int countSize14 = alloc_test(MAX_14_8B); + int countSize15 = alloc_test(MAX_15_8B); + //System.out.println(countSize11); + //System.out.println(countSize12); + //System.out.println(countSize13); + //System.out.println(countSize14); + //System.out.println(countSize15); + + if (countSize11 == 853 && countSize12 == 788 && countSize13 == 728 && countSize14 == 681 && countSize15 == 639) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0251-rc-function-ROSAlloc-Alloc_128x8B/Alloc_128x8B.java b/test/testsuite/ouroboros/rc_test/RC0251-rc-function-ROSAlloc-Alloc_128x8B/Alloc_128x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..57a103199edc577959033e2a78530e36f8a2e21e --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0251-rc-function-ROSAlloc-Alloc_128x8B/Alloc_128x8B.java @@ -0,0 +1,64 @@ +/* + *- @TestCaseID:Alloc_128x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This testcase is mainly for testing objects from 64*8B to 128*8B(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_128x8B.java + *- @ExecuteClass: Alloc_128x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +public class Alloc_128x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_128_8B=128*8; + private static ArrayList store; + + private static int alloc_test(int slot_type){ + int sum=0; + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + + for(;i<=slot_type-OBJ_HEADSIZE;i=i+3) + { + for(int j=0;j<(PAGE_SIZE*256/(i+OBJ_HEADSIZE)+5);j++) + { + temp = new byte[i]; + store.add(temp); + } + sum +=store.size(); + store=new ArrayList(); + } + return sum; + } + public static void main(String[] args) { + store = new ArrayList(); + + int result = alloc_test(MAX_128_8B); + //System.out.println(result); + if ( result == 243561) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0252-rc-function-ROSAlloc-Alloc_16_20x8B/Alloc_16_20x8B.java b/test/testsuite/ouroboros/rc_test/RC0252-rc-function-ROSAlloc-Alloc_16_20x8B/Alloc_16_20x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..38b36dad9ec169eb61502058e52070db5deca0c1 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0252-rc-function-ROSAlloc-Alloc_16_20x8B/Alloc_16_20x8B.java @@ -0,0 +1,75 @@ +/* + *- @TestCaseID:Alloc_16_20x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This testcase is mainly for testing objects from 16*8B to 20*8B(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_16_20x8B.java + *- @ExecuteClass: Alloc_16_20x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +public class Alloc_16_20x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_16_8B=16*8; + private final static int MAX_17_8B=17*8; + private final static int MAX_18_8B=18*8; + private final static int MAX_19_8B=19*8; + private final static int MAX_20_8B=20*8; + private static ArrayList store; + + private static int alloc_test(int slot_type){ + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + + for(;i<=slot_type-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*2/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + store=new ArrayList(); + return check_size; + } + public static void main(String[] args) { + store = new ArrayList(); + int countSize16 = alloc_test(MAX_16_8B); + int countSize17 = alloc_test(MAX_17_8B); + int countSize18 = alloc_test(MAX_18_8B); + int countSize19 = alloc_test(MAX_19_8B); + int countSize20 = alloc_test(MAX_20_8B); + //System.out.println(countSize16); + //System.out.println(countSize17); + //System.out.println(countSize18); + //System.out.println(countSize19); + //System.out.println(countSize20); + + if (countSize16 == 604 && countSize17 == 572 && countSize18 == 542 && countSize19 == 517 && countSize20 == 495) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0253-rc-function-ROSAlloc-Alloc_192x8B/Alloc_192x8B.java b/test/testsuite/ouroboros/rc_test/RC0253-rc-function-ROSAlloc-Alloc_192x8B/Alloc_192x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..372625967230077296e094bb0b411a8c9bcd78ff --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0253-rc-function-ROSAlloc-Alloc_192x8B/Alloc_192x8B.java @@ -0,0 +1,54 @@ +/* + * -@TestCaseID:Alloc_192x8B + * -@TestCaseName:Alloc_192x8B + * -@RequirementID:SR-10620538 + * -@RequirementName:[运行时需求]支持自动内存管理 + * -@Title:ROS Allocator is in charge of applying and releasing objects.This testcase is mainly for testing big objects from 128*8B to 192*8B(max) + * -@Condition: no + * -#c1 + * -@Brief:ROS Allocator is in charge of applying and releasing objects.This testcase is mainly for testing big objects from 128*8B to 192*8B(max) + * -#step1 + * -@Expect:ExpectResult\n + * -@Priority: High + * -@Source: Alloc_192x8B.java + * -@ExecuteClass: Alloc_192x8B + * -@ExecuteArgs: + * -@Remark: + */ +import java.util.ArrayList; + +public class Alloc_192x8B { + private static final int PAGE_SIZE = 4*1024; + private static final int OBJ_HEADSIZE = 8; + private static final int MAX_192_8B = 192*8; + private static ArrayList store; + + private static int alloc_test(int slot_type) { + int sum = 0; + store = new ArrayList(); + byte[] temp; + + for (int i = 1024 + 1 - OBJ_HEADSIZE; i <= slot_type - OBJ_HEADSIZE; i = i + 6) { + for (int j = 0; j < (PAGE_SIZE * 1280 / (i + OBJ_HEADSIZE) + 5); j++) { + temp = new byte[i]; + store.add(temp); + } + sum += store.size(); + store = new ArrayList(); + } + return sum; + } + + public static void main(String[] args) { + store = new ArrayList(); + int result = alloc_test(MAX_192_8B); + if ( result == 357534) { + System.out.println("ExpectResult"); + } else { + System.out.println("Error"); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0254-rc-function-ROSAlloc-Alloc_21_25x8B/Alloc_21_25x8B.java b/test/testsuite/ouroboros/rc_test/RC0254-rc-function-ROSAlloc-Alloc_21_25x8B/Alloc_21_25x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..3de6b076b14c83765e18c8079d5a42c299a2ce81 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0254-rc-function-ROSAlloc-Alloc_21_25x8B/Alloc_21_25x8B.java @@ -0,0 +1,76 @@ +/* + *- @TestCaseID:Alloc_21_25x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This testcase is mainly for testing objects from 21*8B to 25*8B(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_21_25x8B.java + *- @ExecuteClass: Alloc_21_25x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +public class Alloc_21_25x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_21_8B=21*8; + private final static int MAX_22_8B=22*8; + private final static int MAX_23_8B=23*8; + private final static int MAX_24_8B=24*8; + private final static int MAX_25_8B=25*8; + private static ArrayList store; + + private static int alloc_test(int slot_type){ + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + + for(;i<=slot_type-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*3/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + store=new ArrayList(); + return check_size; + } + public static void main(String[] args) { + store = new ArrayList(); + int countSize21 = alloc_test(MAX_21_8B); + int countSize22 = alloc_test(MAX_22_8B); + int countSize23 = alloc_test(MAX_23_8B); + int countSize24 = alloc_test(MAX_24_8B); + int countSize25 = alloc_test(MAX_25_8B); + //System.out.println(countSize21); + //System.out.println(countSize22); + //System.out.println(countSize23); + //System.out.println(countSize24); + //System.out.println(countSize25); + + if (countSize21 == 674 && countSize22 == 646 && countSize23 == 621 && countSize24 == 599 && countSize25 == 577) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0255-rc-function-ROSAlloc-Alloc_256x8B/Alloc_256x8B.java b/test/testsuite/ouroboros/rc_test/RC0255-rc-function-ROSAlloc-Alloc_256x8B/Alloc_256x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..728fe3aa323d407e1e03fbd38cd5e3a9583d4679 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0255-rc-function-ROSAlloc-Alloc_256x8B/Alloc_256x8B.java @@ -0,0 +1,55 @@ +/* + *- @TestCaseID:Alloc_256x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This testcase is mainly for testing big objects from 192*8B to 256*8B(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_256x8B.java + *- @ExecuteClass: Alloc_256x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +public class Alloc_256x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_256_8B=256*8; + private static ArrayList store; + + private static int alloc_test(int slot_type){ + int sum=0; + store=new ArrayList(); + byte[] temp; + + for(int i=1024+1-OBJ_HEADSIZE;i<=slot_type-OBJ_HEADSIZE;i=i+256) + { + for(int j=0;j<(PAGE_SIZE*5120/(i+OBJ_HEADSIZE)+5);j++) + { + temp = new byte[i]; + store.add(temp); + } + sum +=store.size(); + store=new ArrayList(); + } + return sum; + } + public static void main(String[] args) { + store = new ArrayList(); + int result = alloc_test(MAX_256_8B); + //System.out.println(result); + if ( result == 62191) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0256-rc-function-ROSAlloc-Alloc_26_30x8B/Alloc_26_30x8B.java b/test/testsuite/ouroboros/rc_test/RC0256-rc-function-ROSAlloc-Alloc_26_30x8B/Alloc_26_30x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..d5d9eb49305e689b2c9b3bd8cc9efc0b02b53bf7 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0256-rc-function-ROSAlloc-Alloc_26_30x8B/Alloc_26_30x8B.java @@ -0,0 +1,75 @@ +/* + *- @TestCaseID:Alloc_26_30x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This testcase is mainly for testing objects from 26*8B to 30*8B(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_26_30x8B.java + *- @ExecuteClass: Alloc_26_30x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +public class Alloc_26_30x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_26_8B=26*8; + private final static int MAX_27_8B=27*8; + private final static int MAX_28_8B=28*8; + private final static int MAX_29_8B=29*8; + private final static int MAX_30_8B=30*8; + private static ArrayList store; + + private static int alloc_test(int slot_type){ + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + + for(;i<=slot_type-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*3/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + store=new ArrayList(); + return check_size; + } + public static void main(String[] args) { + store = new ArrayList(); + int countSize26 = alloc_test(MAX_26_8B); + int countSize27 = alloc_test(MAX_27_8B); + int countSize28 = alloc_test(MAX_28_8B); + int countSize29 = alloc_test(MAX_29_8B); + int countSize30 = alloc_test(MAX_30_8B); + //System.out.println(countSize26); + //System.out.println(countSize27); + //System.out.println(countSize28); + //System.out.println(countSize29); + //System.out.println(countSize30); + + if (countSize26 == 557 && countSize27 == 538 && countSize28 == 522 && countSize29 == 506 && countSize30 == 492) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0257-rc-function-ROSAlloc-Alloc_3_10x8B/Alloc_3_10x8B.java b/test/testsuite/ouroboros/rc_test/RC0257-rc-function-ROSAlloc-Alloc_3_10x8B/Alloc_3_10x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..b434691da98d5796eea1bfd764cf33b219fc8790 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0257-rc-function-ROSAlloc-Alloc_3_10x8B/Alloc_3_10x8B.java @@ -0,0 +1,77 @@ +/* + *- @TestCaseID:Alloc_3_10x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This testcase is mainly for testing objects from 3*8B to 10*8B(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_3_10x8B.java + *- @ExecuteClass: Alloc_3_10x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +public class Alloc_3_10x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_3_8B=3*8; + private final static int MAX_4_8B=4*8; + private final static int MAX_5_8B=5*8; + private final static int MAX_6_8B=6*8; + private final static int MAX_7_8B=7*8; + private final static int MAX_8_8B=8*8; + private final static int MAX_9_8B=9*8; + private final static int MAX_10_8B=10*8; + private static ArrayList store; + + private static int alloc_test(int slot_type){ + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + + for(;i<=slot_type-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + store=new ArrayList(); + return check_size; + } + public static void main(String[] args){ + store=new ArrayList(); + int countSize3 = alloc_test(MAX_3_8B); + int countSize4 = alloc_test(MAX_4_8B); + int countSize5 = alloc_test(MAX_5_8B); + int countSize6 = alloc_test(MAX_6_8B); + int countSize7 = alloc_test(MAX_7_8B); + int countSize8 = alloc_test(MAX_8_8B); + int countSize9 = alloc_test(MAX_9_8B); + int countSize10 = alloc_test(MAX_10_8B); + if(countSize3==4488 && countSize4==1234 && countSize5==978 && countSize6==816 && countSize7==701 && countSize8==620 &&countSize9==556 && countSize10==505 ) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0258-rc-function-ROSAlloc-Alloc_31_35x8B/Alloc_31_35x8B.java b/test/testsuite/ouroboros/rc_test/RC0258-rc-function-ROSAlloc-Alloc_31_35x8B/Alloc_31_35x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..78690ea9e5d44bd5c86177e79589dab37a497e69 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0258-rc-function-ROSAlloc-Alloc_31_35x8B/Alloc_31_35x8B.java @@ -0,0 +1,75 @@ +/* + *- @TestCaseID:Alloc_31_35x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This testcase is mainly for testing objects from 31*8B to 35*8B(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_31_35x8B.java + *- @ExecuteClass: Alloc_31_35x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +public class Alloc_31_35x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_31_8B=31*8; + private final static int MAX_32_8B=32*8; + private final static int MAX_33_8B=33*8; + private final static int MAX_34_8B=34*8; + private final static int MAX_35_8B=35*8; + private static ArrayList store; + + private static int alloc_test(int slot_type){ + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + + for(;i<=slot_type-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*4/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + store=new ArrayList(); + return check_size; + } + public static void main(String[] args) { + store = new ArrayList(); + int countSize31 = alloc_test(MAX_31_8B); + int countSize32 = alloc_test(MAX_32_8B); + int countSize33 = alloc_test(MAX_33_8B); + int countSize34 = alloc_test(MAX_34_8B); + int countSize35 = alloc_test(MAX_35_8B); + //System.out.println(countSize31); + //System.out.println(countSize32); + //System.out.println(countSize33); + //System.out.println(countSize34); + //System.out.println(countSize35); + + if (countSize31 == 612 && countSize32 == 596 && countSize33 == 580 && countSize34 == 564 && countSize35 == 550) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0259-rc-function-ROSAlloc-Alloc_36_40x8B/Alloc_36_40x8B.java b/test/testsuite/ouroboros/rc_test/RC0259-rc-function-ROSAlloc-Alloc_36_40x8B/Alloc_36_40x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..5ed8f05a1fc370f2be99815d956d964bdc9a8f48 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0259-rc-function-ROSAlloc-Alloc_36_40x8B/Alloc_36_40x8B.java @@ -0,0 +1,75 @@ +/* + *- @TestCaseID:Alloc_36_40x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This testcase is mainly for testing objects from 36*8B to 40*8B(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_36_40x8B.java + *- @ExecuteClass: Alloc_36_40x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +public class Alloc_36_40x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_36_8B=36*8; + private final static int MAX_37_8B=37*8; + private final static int MAX_38_8B=38*8; + private final static int MAX_39_8B=39*8; + private final static int MAX_40_8B=40*8; + private static ArrayList store; + + private static int alloc_test(int slot_type){ + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + + for(;i<=slot_type-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*4/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + store=new ArrayList(); + return check_size; + } + public static void main(String[] args) { + store = new ArrayList(); + int countSize36 = alloc_test(MAX_36_8B); + int countSize37 = alloc_test(MAX_37_8B); + int countSize38 = alloc_test(MAX_38_8B); + int countSize39 = alloc_test(MAX_39_8B); + int countSize40 = alloc_test(MAX_40_8B); + //System.out.println(countSize36); + //System.out.println(countSize37); + //System.out.println(countSize38); + //System.out.println(countSize39); + //System.out.println(countSize40); + + if (countSize36 == 537 && countSize37 == 524 && countSize38 == 512 && countSize39 == 501 && countSize40 == 491) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0260-rc-function-ROSAlloc-Alloc_41_45x8B/Alloc_41_45x8B.java b/test/testsuite/ouroboros/rc_test/RC0260-rc-function-ROSAlloc-Alloc_41_45x8B/Alloc_41_45x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..90048ce7913e46532fc2b996ff53187ada30988d --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0260-rc-function-ROSAlloc-Alloc_41_45x8B/Alloc_41_45x8B.java @@ -0,0 +1,75 @@ +/* + *- @TestCaseID:Alloc_41_45x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This testcase is mainly for testing objects from 41*8B to 45*8B(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_41_45x8B.java + *- @ExecuteClass: Alloc_41_45x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +public class Alloc_41_45x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_41_8B=41*8; + private final static int MAX_42_8B=42*8; + private final static int MAX_43_8B=43*8; + private final static int MAX_44_8B=44*8; + private final static int MAX_45_8B=45*8; + private static ArrayList store; + + private static int alloc_test(int slot_type){ + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + + for(;i<=slot_type-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*5/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + store=new ArrayList(); + return check_size; + } + public static void main(String[] args) { + store = new ArrayList(); + int countSize41 = alloc_test(MAX_41_8B); + int countSize42 = alloc_test(MAX_42_8B); + int countSize43 = alloc_test(MAX_43_8B); + int countSize44 = alloc_test(MAX_44_8B); + int countSize45 = alloc_test(MAX_45_8B); + //System.out.println(countSize41); + //System.out.println(countSize42); + //System.out.println(countSize43); + //System.out.println(countSize44); + //System.out.println(countSize45); + + if (countSize41 == 581 && countSize42 == 569 && countSize43 == 557 && countSize44 == 547 && countSize45 == 536) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0261-rc-function-ROSAlloc-Alloc_46_50x8B/Alloc_46_50x8B.java b/test/testsuite/ouroboros/rc_test/RC0261-rc-function-ROSAlloc-Alloc_46_50x8B/Alloc_46_50x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..fe14b3fd88942487f778d31d5e42620fc12d54bb --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0261-rc-function-ROSAlloc-Alloc_46_50x8B/Alloc_46_50x8B.java @@ -0,0 +1,75 @@ +/* + *- @TestCaseID:Alloc_46_50x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This testcase is mainly for testing objects from 46*8B to 50*8B(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_46_50x8B.java + *- @ExecuteClass: Alloc_46_50x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +public class Alloc_46_50x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_46_8B=46*8; + private final static int MAX_47_8B=47*8; + private final static int MAX_48_8B=48*8; + private final static int MAX_49_8B=49*8; + private final static int MAX_50_8B=50*8; + private static ArrayList store; + + private static int alloc_test(int slot_type){ + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + + for(;i<=slot_type-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*5/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + store=new ArrayList(); + return check_size; + } + public static void main(String[] args) { + store = new ArrayList(); + int countSize46 = alloc_test(MAX_46_8B); + int countSize47 = alloc_test(MAX_47_8B); + int countSize48 = alloc_test(MAX_48_8B); + int countSize49 = alloc_test(MAX_49_8B); + int countSize50 = alloc_test(MAX_50_8B); + //System.out.println(countSize46); + //System.out.println(countSize47); + //System.out.println(countSize48); + //System.out.println(countSize49); + //System.out.println(countSize50); + + if (countSize46 == 525 && countSize47 == 516 && countSize48 == 507 && countSize49 == 498 && countSize50 == 489) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0262-rc-function-ROSAlloc-Alloc_51_55x8B/Alloc_51_55x8B.java b/test/testsuite/ouroboros/rc_test/RC0262-rc-function-ROSAlloc-Alloc_51_55x8B/Alloc_51_55x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..101325e1279560b8ff60abab5c06c9f9a549a795 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0262-rc-function-ROSAlloc-Alloc_51_55x8B/Alloc_51_55x8B.java @@ -0,0 +1,75 @@ +/* + *- @TestCaseID:Alloc_51_55x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This testcase is mainly for testing objects from 51*8B to 55*8B(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_51_55x8B.java + *- @ExecuteClass: Alloc_51_55x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +public class Alloc_51_55x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_51_8B=51*8; + private final static int MAX_52_8B=52*8; + private final static int MAX_53_8B=53*8; + private final static int MAX_54_8B=54*8; + private final static int MAX_55_8B=55*8; + private static ArrayList store; + + private static int alloc_test(int slot_type){ + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + + for(;i<=slot_type-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*6/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + store=new ArrayList(); + return check_size; + } + public static void main(String[] args) { + store = new ArrayList(); + int countSize51 = alloc_test(MAX_51_8B); + int countSize52 = alloc_test(MAX_52_8B); + int countSize53 = alloc_test(MAX_53_8B); + int countSize54 = alloc_test(MAX_54_8B); + int countSize55 = alloc_test(MAX_55_8B); + //System.out.println(countSize51); + //System.out.println(countSize52); + //System.out.println(countSize53); + //System.out.println(countSize54); + //System.out.println(countSize55); + + if (countSize51 == 562 && countSize52 == 553 && countSize53 == 543 && countSize54 == 535 && countSize55 == 526) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0263-rc-function-ROSAlloc-Alloc_56_60x8B/Alloc_56_60x8B.java b/test/testsuite/ouroboros/rc_test/RC0263-rc-function-ROSAlloc-Alloc_56_60x8B/Alloc_56_60x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..4b8347ce017fe12740d1f5d961764bf5e03970a1 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0263-rc-function-ROSAlloc-Alloc_56_60x8B/Alloc_56_60x8B.java @@ -0,0 +1,75 @@ +/* + *- @TestCaseID:Alloc_56_60x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This testcase is mainly for testing objects from 56*8B to 60*8B(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_56_60x8B.java + *- @ExecuteClass: Alloc_56_60x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +public class Alloc_56_60x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_56_8B=56*8; + private final static int MAX_57_8B=57*8; + private final static int MAX_58_8B=58*8; + private final static int MAX_59_8B=59*8; + private final static int MAX_60_8B=60*8; + private static ArrayList store; + + private static int alloc_test(int slot_type){ + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + + for(;i<=slot_type-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*6/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + store=new ArrayList(); + return check_size; + } + public static void main(String[] args) { + store = new ArrayList(); + int countSize56 = alloc_test(MAX_56_8B); + int countSize57 = alloc_test(MAX_57_8B); + int countSize58 = alloc_test(MAX_58_8B); + int countSize59 = alloc_test(MAX_59_8B); + int countSize60 = alloc_test(MAX_60_8B); + //System.out.println(countSize56); + //System.out.println(countSize57); + //System.out.println(countSize58); + //System.out.println(countSize59); + //System.out.println(countSize60); + + if (countSize56 == 518 && countSize57 == 511 && countSize58 == 503 && countSize59 == 496 && countSize60 == 488) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0264-rc-function-ROSAlloc-Alloc_61_64x8B/Alloc_61_64x8B.java b/test/testsuite/ouroboros/rc_test/RC0264-rc-function-ROSAlloc-Alloc_61_64x8B/Alloc_61_64x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..5aa541b77129606e810fa4f4b002a47e937ee18a --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0264-rc-function-ROSAlloc-Alloc_61_64x8B/Alloc_61_64x8B.java @@ -0,0 +1,72 @@ +/* + *- @TestCaseID:Alloc_61_64x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This testcase is mainly for testing objects from 61*8B to 64*8B(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_61_64x8B.java + *- @ExecuteClass: Alloc_61_64x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +public class Alloc_61_64x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_61_8B=61*8; + private final static int MAX_62_8B=62*8; + private final static int MAX_63_8B=63*8; + private final static int MAX_64_8B=64*8; + private static ArrayList store; + + private static int alloc_test(int slot_type){ + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + + for(;i<=slot_type-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*7/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + store=new ArrayList(); + return check_size; + } + public static void main(String[] args) { + store = new ArrayList(); + int countSize61 = alloc_test(MAX_61_8B); + int countSize62 = alloc_test(MAX_62_8B); + int countSize63 = alloc_test(MAX_63_8B); + int countSize64 = alloc_test(MAX_64_8B); + //System.out.println(countSize61); + //System.out.println(countSize62); + //System.out.println(countSize63); + //System.out.println(countSize64); + + if (countSize61 == 549 && countSize62 == 542 && countSize63 == 535 && countSize64 == 528 ) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0265-rc-function-ROSAlloc-Alloc_B256x8B/Alloc_B256x8B.java b/test/testsuite/ouroboros/rc_test/RC0265-rc-function-ROSAlloc-Alloc_B256x8B/Alloc_B256x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..6bc3bf20be087452c3838e0eda63e9befe792ff0 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0265-rc-function-ROSAlloc-Alloc_B256x8B/Alloc_B256x8B.java @@ -0,0 +1,54 @@ +/* + *- @TestCaseID:Alloc_B256x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This testcase is mainly for testing big objects more than 2KB + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_B256x8B.java + *- @ExecuteClass: Alloc_B256x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +public class Alloc_B256x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_B256_8B=2*1024*1024; + private static ArrayList store; + + private static int alloc_test(int slot_type){ + int sum=0; + store=new ArrayList(); + byte[] temp; + + for(int i=1024*1024-OBJ_HEADSIZE;i<=slot_type-OBJ_HEADSIZE;i=i+256) + { + for(int j=0;j<(PAGE_SIZE*2560/(i+OBJ_HEADSIZE)+5);j++) + { + temp = new byte[i]; + store.add(temp); + } + sum +=store.size(); + store=new ArrayList(); + } + return sum; + } + public static void main(String[] args) { + store = new ArrayList(); + int result = alloc_test(MAX_B256_8B); + //System.out.println(result); + if ( result == 46939) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0266-rc-function-ROSAlloc-Alloc_Thread_128x8B/Alloc_Thread_128x8B.java b/test/testsuite/ouroboros/rc_test/RC0266-rc-function-ROSAlloc-Alloc_Thread_128x8B/Alloc_Thread_128x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..ab8292789c34bc0c821e30d875b670f0213495d4 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0266-rc-function-ROSAlloc-Alloc_Thread_128x8B/Alloc_Thread_128x8B.java @@ -0,0 +1,69 @@ +/* + *- @TestCaseID:Alloc_Thread_128x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 64*8B to 128*8B(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Thread_128x8B.java + *- @ExecuteClass: Alloc_Thread_128x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Thread_128x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_128_8B=128*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + int check_size=0; + for(int i=512-OBJ_HEADSIZE;i<=MAX_128_8B-OBJ_HEADSIZE;i=i+100) + { + for(int j=0;j<(PAGE_SIZE*10240/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + + //System.out.println(check_size); + if(check_size == 348510) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Thread_128x8B { + public static void main(String[] args){ + Alloc_Thread_128x8B_01 test1=new Alloc_Thread_128x8B_01(); + test1.start(); + try{ + test1.join(); + }catch (InterruptedException e){} + if(test1.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0267-rc-function-ROSAlloc-Alloc_Thread_18x8B/Alloc_Thread_18x8B.java b/test/testsuite/ouroboros/rc_test/RC0267-rc-function-ROSAlloc-Alloc_Thread_18x8B/Alloc_Thread_18x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..016bfe7770c0bb8430c5552490a39a745c707502 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0267-rc-function-ROSAlloc-Alloc_Thread_18x8B/Alloc_Thread_18x8B.java @@ -0,0 +1,66 @@ +/* + *- @TestCaseID:Alloc_Thread_18x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 8B to 18*8B(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Thread_18x8B.java + *- @ExecuteClass: Alloc_Thread_18x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Thread_18x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_18_8B=18*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=1;i<=MAX_18_8B-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*64/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 743858) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Thread_18x8B { + public static void main(String[] args){ + Alloc_Thread_18x8B_01 test1=new Alloc_Thread_18x8B_01(); + test1.start(); + try{ + test1.join(); + }catch (InterruptedException e){} + if(test1.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0268-rc-function-ROSAlloc-Alloc_Thread_192x8B/Alloc_Thread_192x8B.java b/test/testsuite/ouroboros/rc_test/RC0268-rc-function-ROSAlloc-Alloc_Thread_192x8B/Alloc_Thread_192x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..29c74ebe553b1585d3abda2425409ee2ba35d75e --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0268-rc-function-ROSAlloc-Alloc_Thread_192x8B/Alloc_Thread_192x8B.java @@ -0,0 +1,69 @@ +/* + *- @TestCaseID:Alloc_Thread_192x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 128*8B to 192*8B(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Thread_192x8B.java + *- @ExecuteClass: Alloc_Thread_192x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Thread_192x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_192_8B=192*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + int check_size=0; + for(int i=1024-OBJ_HEADSIZE;i<=MAX_192_8B-OBJ_HEADSIZE;i=i+100) + { + for(int j=0;j<(PAGE_SIZE*10240/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + + //System.out.println(check_size); + if(check_size == 201256) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Thread_192x8B { + public static void main(String[] args){ + Alloc_Thread_192x8B_01 test1=new Alloc_Thread_192x8B_01(); + test1.start(); + try{ + test1.join(); + }catch (InterruptedException e){} + if(test1.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0269-rc-function-ROSAlloc-Alloc_Thread2_128x8B_2/Alloc_Thread2_128x8B_2.java b/test/testsuite/ouroboros/rc_test/RC0269-rc-function-ROSAlloc-Alloc_Thread2_128x8B_2/Alloc_Thread2_128x8B_2.java new file mode 100755 index 0000000000000000000000000000000000000000..de333fc7d50dc20a4767c37ac160df15d0287296 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0269-rc-function-ROSAlloc-Alloc_Thread2_128x8B_2/Alloc_Thread2_128x8B_2.java @@ -0,0 +1,78 @@ +/* + *- @TestCaseID:Alloc_Thread2_128x8B_2 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 64*8B to 128*8B with time sleep + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Thread2_128x8B_2.java + *- @ExecuteClass: Alloc_Thread2_128x8B_2 + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Thread2_128x8B_2_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_128_8B=128*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + try{Thread.sleep(100);}catch(InterruptedException e){} + byte[] temp; + int check_size=0; + for(int i=512-OBJ_HEADSIZE;i<=MAX_128_8B-OBJ_HEADSIZE;i=i+100) + { + for(int j=0;j<(PAGE_SIZE*10240/(i+OBJ_HEADSIZE)+10);j++) + { + if(j%10000==0) + { + try{Thread.sleep(100);}catch(InterruptedException e){} + } + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + + //System.out.println(check_size); + if(check_size == 348510) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Thread2_128x8B_2 { + public static void main(String[] args){ + Runtime.getRuntime().gc(); + Alloc_Thread2_128x8B_2_01 test1=new Alloc_Thread2_128x8B_2_01(); + test1.start(); + Alloc_Thread2_128x8B_2_01 test2=new Alloc_Thread2_128x8B_2_01(); + test2.start(); + try{ + test1.join(); + test2.join(); + }catch (InterruptedException e){} + if(test1.check()==true && test2.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0270-rc-function-ROSAlloc-Alloc_Thread2_128x8B/Alloc_Thread2_128x8B.java b/test/testsuite/ouroboros/rc_test/RC0270-rc-function-ROSAlloc-Alloc_Thread2_128x8B/Alloc_Thread2_128x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..60f185e3e04cf15405d6b3c16c556021ee027915 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0270-rc-function-ROSAlloc-Alloc_Thread2_128x8B/Alloc_Thread2_128x8B.java @@ -0,0 +1,73 @@ +/* + *- @TestCaseID:Alloc_Thread2_128x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This testcase is mainly for testing objects from 64*8B to 128*8B(max) with 2 threads. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Thread2_128x8B.java + *- @ExecuteClass: Alloc_Thread2_128x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Thread2_128x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_128_8B=128*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + int check_size=0; + for(int i=512-OBJ_HEADSIZE;i<=MAX_128_8B-OBJ_HEADSIZE;i=i+100) + { + for(int j=0;j<(PAGE_SIZE*10240/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + + //System.out.println(check_size); + if(check_size == 348510) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Thread2_128x8B { + public static void main(String[] args){ + Runtime.getRuntime().gc(); + Alloc_Thread2_128x8B_01 test1=new Alloc_Thread2_128x8B_01(); + test1.start(); + Alloc_Thread2_128x8B_01 test2=new Alloc_Thread2_128x8B_01(); + test2.start(); + try{ + test1.join(); + test2.join(); + }catch (InterruptedException e){} + if(test1.check()==true && test2.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0271-rc-function-ROSAlloc-Alloc_Thread2_18x8B/Alloc_Thread2_18x8B.java b/test/testsuite/ouroboros/rc_test/RC0271-rc-function-ROSAlloc-Alloc_Thread2_18x8B/Alloc_Thread2_18x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..947483b2e23235f0d25e2e9f43a134523714ef1e --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0271-rc-function-ROSAlloc-Alloc_Thread2_18x8B/Alloc_Thread2_18x8B.java @@ -0,0 +1,70 @@ +/* + *- @TestCaseID:Alloc_Thread2_18x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 8B to 18*8B(max) with 2 threads. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Thread2_18x8B.java + *- @ExecuteClass: Alloc_Thread2_18x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Thread2_18x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_18_8B=18*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=1;i<=MAX_18_8B-OBJ_HEADSIZE;i+=10) + { + for(int j=0;j<(PAGE_SIZE*64/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 89848) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Thread2_18x8B { + public static void main(String[] args){ + Alloc_Thread2_18x8B_01 test1=new Alloc_Thread2_18x8B_01(); + test1.start(); + Alloc_Thread2_18x8B_01 test2=new Alloc_Thread2_18x8B_01(); + test2.start(); + try{ + test1.join(); + test2.join(); + }catch (InterruptedException e){} + if(test1.check()==true && test2.check() == true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0272-rc-function-ROSAlloc-Alloc_Thread2_192x8B_2/Alloc_Thread2_192x8B_2.java b/test/testsuite/ouroboros/rc_test/RC0272-rc-function-ROSAlloc-Alloc_Thread2_192x8B_2/Alloc_Thread2_192x8B_2.java new file mode 100755 index 0000000000000000000000000000000000000000..6e81dcf631f32f797eab769c8148c3d425fd23b8 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0272-rc-function-ROSAlloc-Alloc_Thread2_192x8B_2/Alloc_Thread2_192x8B_2.java @@ -0,0 +1,77 @@ +/* + *- @TestCaseID:Alloc_Thread2_192x8B_2 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 128*8B to 192*8B(max) with time sleep + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Thread2_192x8B_2.java + *- @ExecuteClass: Alloc_Thread2_192x8B_2 + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Thread2_192x8B_2_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_192_8B=192*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + try{Thread.sleep(100);}catch(InterruptedException e){} + byte[] temp; + int check_size=0; + for(int i=1024-OBJ_HEADSIZE;i<=MAX_192_8B-OBJ_HEADSIZE;i=i+100) + { + for(int j=0;j<(PAGE_SIZE*10240/(i+OBJ_HEADSIZE)+10);j++) + { + if(j%10000==0) + { + try{Thread.sleep(100);}catch(InterruptedException e){} + } + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + + //System.out.println(check_size); + if(check_size == 201256) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Thread2_192x8B_2 { + public static void main(String[] args){ + Alloc_Thread2_192x8B_2_01 test1=new Alloc_Thread2_192x8B_2_01(); + test1.start(); + Alloc_Thread2_192x8B_2_01 test2=new Alloc_Thread2_192x8B_2_01(); + test2.start(); + try{ + test1.join(); + test2.join(); + }catch (InterruptedException e){} + if(test1.check()==true &&test2.check()==true ) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0273-rc-function-ROSAlloc-Alloc_Thread2_192x8B/Alloc_Thread2_192x8B.java b/test/testsuite/ouroboros/rc_test/RC0273-rc-function-ROSAlloc-Alloc_Thread2_192x8B/Alloc_Thread2_192x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..6050e4df4f7b5435f5c95b6386f9a3509642f6b2 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0273-rc-function-ROSAlloc-Alloc_Thread2_192x8B/Alloc_Thread2_192x8B.java @@ -0,0 +1,72 @@ +/* + *- @TestCaseID:Alloc_Thread2_192x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 128*8B to 192*8B(max) with 2 threads + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Thread2_192x8B.java + *- @ExecuteClass: Alloc_Thread2_192x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Thread2_192x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_192_8B=192*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + int check_size=0; + for(int i=1024-OBJ_HEADSIZE;i<=MAX_192_8B-OBJ_HEADSIZE;i=i+100) + { + for(int j=0;j<(PAGE_SIZE*10240/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + + //System.out.println(check_size); + if(check_size == 201256) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Thread2_192x8B { + public static void main(String[] args){ + Alloc_Thread2_192x8B_01 test1=new Alloc_Thread2_192x8B_01(); + test1.start(); + Alloc_Thread2_192x8B_01 test2=new Alloc_Thread2_192x8B_01(); + test2.start(); + try{ + test1.join(); + test2.join(); + }catch (InterruptedException e){} + if(test1.check()==true &&test2.check()==true ) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0274-rc-function-ROSAlloc-Alloc_Thread2_256x8B_2/Alloc_Thread2_256x8B_2.java b/test/testsuite/ouroboros/rc_test/RC0274-rc-function-ROSAlloc-Alloc_Thread2_256x8B_2/Alloc_Thread2_256x8B_2.java new file mode 100755 index 0000000000000000000000000000000000000000..85fd2fc5dd26039cff808e9cc87daae79979136c --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0274-rc-function-ROSAlloc-Alloc_Thread2_256x8B_2/Alloc_Thread2_256x8B_2.java @@ -0,0 +1,77 @@ +/* + *- @TestCaseID:Alloc_Thread2_256x8B_2 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 192*8B to 256*8B(max) with time sleep + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Thread2_256x8B_2.java + *- @ExecuteClass: Alloc_Thread2_256x8B_2 + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Thread2_256x8B_2_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_256_8B=256*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + try{Thread.sleep(100);}catch(InterruptedException e){} + byte[] temp; + int check_size=0; + for(int i=192*8-OBJ_HEADSIZE;i<=MAX_256_8B-OBJ_HEADSIZE;i=i+60) + { + for(int j=0;j<(PAGE_SIZE*10240/(i+OBJ_HEADSIZE)+10);j++) + { + if(j%10000==0) + { + try{Thread.sleep(100);}catch(InterruptedException e){} + } + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + + //System.out.println(check_size); + if(check_size == 214274) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Thread2_256x8B_2 { + public static void main(String[] args){ + Alloc_Thread2_256x8B_2_01 test1=new Alloc_Thread2_256x8B_2_01(); + test1.start(); + Alloc_Thread2_256x8B_2_01 test2=new Alloc_Thread2_256x8B_2_01(); + test2.start(); + try{ + test1.join(); + test2.join(); + }catch (InterruptedException e){} + if(test1.check()==true && test2.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0275-rc-function-ROSAlloc-Alloc_Thread2_256x8B/Alloc_Thread2_256x8B.java b/test/testsuite/ouroboros/rc_test/RC0275-rc-function-ROSAlloc-Alloc_Thread2_256x8B/Alloc_Thread2_256x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..5fc39300f810c01c0b0478ccb840e426e5e08b67 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0275-rc-function-ROSAlloc-Alloc_Thread2_256x8B/Alloc_Thread2_256x8B.java @@ -0,0 +1,72 @@ +/* + *- @TestCaseID:Alloc_Thread2_256x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 192*8B to 256*8B(max) with 2 threads + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Thread2_256x8B.java + *- @ExecuteClass: Alloc_Thread2_256x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Thread2_256x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_256_8B=256*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + int check_size=0; + for(int i=192*8-OBJ_HEADSIZE;i<=MAX_256_8B-OBJ_HEADSIZE;i=i+60) + { + for(int j=0;j<(PAGE_SIZE*10240/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + + //System.out.println(check_size); + if(check_size == 214274) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Thread2_256x8B { + public static void main(String[] args){ + Alloc_Thread2_256x8B_01 test1=new Alloc_Thread2_256x8B_01(); + test1.start(); + Alloc_Thread2_256x8B_01 test2=new Alloc_Thread2_256x8B_01(); + test2.start(); + try{ + test1.join(); + test2.join(); + }catch (InterruptedException e){} + if(test1.check()==true && test2.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0276-rc-function-ROSAlloc-Alloc_Thread2_30x8B/Alloc_Thread2_30x8B.java b/test/testsuite/ouroboros/rc_test/RC0276-rc-function-ROSAlloc-Alloc_Thread2_30x8B/Alloc_Thread2_30x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..1662b0c357c37f1c95e88955d9748df59cf66e9c --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0276-rc-function-ROSAlloc-Alloc_Thread2_30x8B/Alloc_Thread2_30x8B.java @@ -0,0 +1,69 @@ +/* + *- @TestCaseID:Alloc_Thread2_30x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 18*8B to 30*8B(max) with 2 threads + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Thread2_30x8B.java + *- @ExecuteClass: Alloc_Thread2_30x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Thread2_30x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_30_8B=30*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=144-OBJ_HEADSIZE;i<=MAX_30_8B-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*128/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 271654) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Thread2_30x8B { + public static void main(String[] args){ + Alloc_Thread2_30x8B_01 test1=new Alloc_Thread2_30x8B_01(); + test1.start(); + Alloc_Thread2_30x8B_01 test2=new Alloc_Thread2_30x8B_01(); + test2.start(); + try{ + test1.join(); + test2.join(); + }catch (InterruptedException e){} + if(test1.check()==true&& test2.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0277-rc-function-ROSAlloc-Alloc_Thread2_40x8B/Alloc_Thread2_40x8B.java b/test/testsuite/ouroboros/rc_test/RC0277-rc-function-ROSAlloc-Alloc_Thread2_40x8B/Alloc_Thread2_40x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..074d14c765bd6381fcefbe1293690d22c51e4f6f --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0277-rc-function-ROSAlloc-Alloc_Thread2_40x8B/Alloc_Thread2_40x8B.java @@ -0,0 +1,69 @@ +/* + *- @TestCaseID:Alloc_Thread2_40x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 30*8B to 40*8B(max) with 2 threads + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Thread2_40x8B.java + *- @ExecuteClass: Alloc_Thread2_40x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Thread2_40x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_40_8B=40*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=240-OBJ_HEADSIZE;i<=MAX_40_8B-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*128/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 153513) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Thread2_40x8B { + public static void main(String[] args){ + Alloc_Thread2_40x8B_01 test1=new Alloc_Thread2_40x8B_01(); + test1.start(); + Alloc_Thread2_40x8B_01 test2=new Alloc_Thread2_40x8B_01(); + test2.start(); + try{ + test1.join(); + test2.join(); + }catch (InterruptedException e){} + if(test1.check()==true&&test2.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0278-rc-function-ROSAlloc-Alloc_Thread2_50x8B/Alloc_Thread2_50x8B.java b/test/testsuite/ouroboros/rc_test/RC0278-rc-function-ROSAlloc-Alloc_Thread2_50x8B/Alloc_Thread2_50x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..679ffbd13d35a2828d8e233b6cdd8ef4e4241994 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0278-rc-function-ROSAlloc-Alloc_Thread2_50x8B/Alloc_Thread2_50x8B.java @@ -0,0 +1,69 @@ +/* + *- @TestCaseID:Alloc_Thread2_50x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 40*8B to 50*8B(max) with 2 threads + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Thread2_50x8B.java + *- @ExecuteClass: Alloc_Thread2_50x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Thread2_50x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_50_8B=50*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=320-OBJ_HEADSIZE;i<=MAX_50_8B-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*256/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 237701) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Thread2_50x8B { + public static void main(String[] args){ + Alloc_Thread2_50x8B_01 test1=new Alloc_Thread2_50x8B_01(); + test1.start(); + Alloc_Thread2_50x8B_01 test2=new Alloc_Thread2_50x8B_01(); + test2.start(); + try{ + test1.join(); + test2.join(); + }catch (InterruptedException e){} + if(test1.check()==true && test2.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0279-rc-function-ROSAlloc-Alloc_Thread_256x8B/Alloc_Thread_256x8B.java b/test/testsuite/ouroboros/rc_test/RC0279-rc-function-ROSAlloc-Alloc_Thread_256x8B/Alloc_Thread_256x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..d583c824af6497da5eb8e144e5628db6ae2ad5ad --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0279-rc-function-ROSAlloc-Alloc_Thread_256x8B/Alloc_Thread_256x8B.java @@ -0,0 +1,69 @@ +/* + *- @TestCaseID:Alloc_Thread_256x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 192*8B to 256*8B(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Thread_256x8B.java + *- @ExecuteClass: Alloc_Thread_256x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Thread_256x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_256_8B=256*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + int check_size=0; + for(int i=192*8-OBJ_HEADSIZE;i<=MAX_256_8B-OBJ_HEADSIZE;i=i+100) + { + for(int j=0;j<(PAGE_SIZE*10240/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + + //System.out.println(check_size); + if(check_size == 142271) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Thread_256x8B { + public static void main(String[] args){ + Alloc_Thread_256x8B_01 test1=new Alloc_Thread_256x8B_01(); + test1.start(); + try{ + test1.join(); + }catch (InterruptedException e){} + if(test1.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0280-rc-function-ROSAlloc-Alloc_Thread2_60x8B/Alloc_Thread2_60x8B.java b/test/testsuite/ouroboros/rc_test/RC0280-rc-function-ROSAlloc-Alloc_Thread2_60x8B/Alloc_Thread2_60x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..7ceff25f4ae9d74cfc520e1a2e2a8776783ec8ba --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0280-rc-function-ROSAlloc-Alloc_Thread2_60x8B/Alloc_Thread2_60x8B.java @@ -0,0 +1,69 @@ +/* + *- @TestCaseID:Alloc_Thread2_60x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 50*8B to 60*8B(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Thread2_60x8B.java + *- @ExecuteClass: Alloc_Thread2_60x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Thread2_60x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_60_8B=60*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=400-OBJ_HEADSIZE;i<=MAX_60_8B-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*256/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 194350) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Thread2_60x8B { + public static void main(String[] args){ + Alloc_Thread2_60x8B_01 test1=new Alloc_Thread2_60x8B_01(); + test1.start(); + Alloc_Thread2_60x8B_01 test2=new Alloc_Thread2_60x8B_01(); + test2.start(); + try{ + test1.join(); + test2.join(); + }catch (InterruptedException e){} + if(test1.check()==true && test2.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0281-rc-function-ROSAlloc-Alloc_Thread2_64x8B/Alloc_Thread2_64x8B.java b/test/testsuite/ouroboros/rc_test/RC0281-rc-function-ROSAlloc-Alloc_Thread2_64x8B/Alloc_Thread2_64x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..d71e026fd5d1f5a2184091b1216292093a445689 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0281-rc-function-ROSAlloc-Alloc_Thread2_64x8B/Alloc_Thread2_64x8B.java @@ -0,0 +1,70 @@ +/* + * -@TestCaseID:Alloc_Thread2_64x8B + * -@TestCaseName:MyselfClassName + * -@RequirementID:SR-10620538 + * -@RequirementName:[运行时需求]支持自动内存管理 + * -@Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 60*8B to 64*8B(max) + * -@Condition: no + * -#c1 + * -@Brief:functionTest + * -#step1 + * -@Expect:ExpectResult\n + * -@Priority: High + * -@Source: Alloc_Thread2_64x8B.java + * -@ExecuteClass: Alloc_Thread2_64x8B + * -@ExecuteArgs: + * -@Remark: + */ + +import java.util.ArrayList; + +class Alloc_Thread2_64x8B_01 extends Thread { + private static final int PAGE_SIZE = 4 * 1024; + private static final int OBJ_HEADSIZE = 8; + private static final int MAX_64_8B = 64 * 8; + private static boolean checkout = false; + + public void run() { + ArrayList store = new ArrayList(); + byte[] temp; + for (int i = 480 - OBJ_HEADSIZE; i <= MAX_64_8B - OBJ_HEADSIZE; i++) { + for (int j = 0; j < (PAGE_SIZE * 128 / (i + OBJ_HEADSIZE) + 10); j++) { + temp = new byte[i]; + store.add(temp); + } + } + int checkSize = store.size(); + if (checkSize == 35212) { + checkout = true; + } + } + + public boolean check() { + return checkout; + } +} + +public class Alloc_Thread2_64x8B { + public static void main(String[] args) { + Runtime.getRuntime().gc(); + Alloc_Thread2_64x8B_01 test1 = new Alloc_Thread2_64x8B_01(); + test1.start(); + Alloc_Thread2_64x8B_01 test2 = new Alloc_Thread2_64x8B_01(); + test2.start(); + try { + test1.join(); + test2.join(); + } catch (InterruptedException e) { + // do nothing + } + if (test1.check() && test2.check()) { + System.out.println("ExpectResult"); + } else { + System.out.println("Error"); + } + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0282-rc-function-ROSAlloc-Alloc_Thread2_B256x8B/Alloc_Thread2_B256x8B.java b/test/testsuite/ouroboros/rc_test/RC0282-rc-function-ROSAlloc-Alloc_Thread2_B256x8B/Alloc_Thread2_B256x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..61d6f79bb3d2dad35549936450964ef01b2691b5 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0282-rc-function-ROSAlloc-Alloc_Thread2_B256x8B/Alloc_Thread2_B256x8B.java @@ -0,0 +1,76 @@ +/* + *- @TestCaseID:Alloc_Thread2_B256x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 1MB to 2MB(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Thread2_B256x8B.java + *- @ExecuteClass: Alloc_Thread2_B256x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Thread2_B256x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_B256_8B=2*1024*1024; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + int check_size=0; + for(int i=1024*1024-OBJ_HEADSIZE;i<=MAX_B256_8B-OBJ_HEADSIZE;i=i+1024) + { + for(int j=0;j<(PAGE_SIZE*10240/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + + //System.out.println(check_size); + if(check_size == 38167) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Thread2_B256x8B { + public static void main(String[] args){ + Alloc_Thread2_B256x8B_01 test1=new Alloc_Thread2_B256x8B_01(); + test1.start(); + try{ test1.sleep(1000);} catch(InterruptedException e){} + Alloc_Thread2_B256x8B_01 test2=new Alloc_Thread2_B256x8B_01(); + test2.start(); + try{ test2.sleep(1000);} catch(InterruptedException e){} + try{ + test1.sleep(1000); + test2.sleep(1000); + test1.join(); + test2.join(); + }catch (InterruptedException e){} + if(test1.check()==true && test2.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0283-rc-function-ROSAlloc-Alloc_Thread_30x8B/Alloc_Thread_30x8B.java b/test/testsuite/ouroboros/rc_test/RC0283-rc-function-ROSAlloc-Alloc_Thread_30x8B/Alloc_Thread_30x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..a9ea90d2afaa4e2a8871118784026b19dbc74956 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0283-rc-function-ROSAlloc-Alloc_Thread_30x8B/Alloc_Thread_30x8B.java @@ -0,0 +1,66 @@ +/* + *- @TestCaseID:Alloc_Thread_30x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 18*8B to 30*8B(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Thread_30x8B.java + *- @ExecuteClass: Alloc_Thread_30x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Thread_30x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_30_8B=30*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=144-OBJ_HEADSIZE;i<=MAX_30_8B-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*128/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 271654) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Thread_30x8B { + public static void main(String[] args){ + Alloc_Thread_30x8B_01 test1=new Alloc_Thread_30x8B_01(); + test1.start(); + try{ + test1.join(); + }catch (InterruptedException e){} + if(test1.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0284-rc-function-ROSAlloc-Alloc_Thread_40x8B/Alloc_Thread_40x8B.java b/test/testsuite/ouroboros/rc_test/RC0284-rc-function-ROSAlloc-Alloc_Thread_40x8B/Alloc_Thread_40x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..616d84fd711ac3090cf0f45c53912f6bf12dcbcb --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0284-rc-function-ROSAlloc-Alloc_Thread_40x8B/Alloc_Thread_40x8B.java @@ -0,0 +1,66 @@ +/* + *- @TestCaseID:Alloc_Thread_40x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 30*8B to 40*8B(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Thread_40x8B.java + *- @ExecuteClass: Alloc_Thread_40x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Thread_40x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_40_8B=40*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=240-OBJ_HEADSIZE;i<=MAX_40_8B-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*128/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 153513) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Thread_40x8B { + public static void main(String[] args){ + Alloc_Thread_40x8B_01 test1=new Alloc_Thread_40x8B_01(); + test1.start(); + try{ + test1.join(); + }catch (InterruptedException e){} + if(test1.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0285-rc-function-ROSAlloc-Alloc_Thread_50x8B/Alloc_Thread_50x8B.java b/test/testsuite/ouroboros/rc_test/RC0285-rc-function-ROSAlloc-Alloc_Thread_50x8B/Alloc_Thread_50x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..971f1ae75f27d2029fd47218833a0ca383102b41 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0285-rc-function-ROSAlloc-Alloc_Thread_50x8B/Alloc_Thread_50x8B.java @@ -0,0 +1,66 @@ +/* + *- @TestCaseID:Alloc_Thread_50x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 40*8B to 50*8B(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Thread_50x8B.java + *- @ExecuteClass: Alloc_Thread_50x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Thread_50x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_50_8B=50*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=320-OBJ_HEADSIZE;i<=MAX_50_8B-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*256/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 237701) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Thread_50x8B { + public static void main(String[] args){ + Alloc_Thread_50x8B_01 test1=new Alloc_Thread_50x8B_01(); + test1.start(); + try{ + test1.join(); + }catch (InterruptedException e){} + if(test1.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0286-rc-function-ROSAlloc-Alloc_Thread_60x8B/Alloc_Thread_60x8B.java b/test/testsuite/ouroboros/rc_test/RC0286-rc-function-ROSAlloc-Alloc_Thread_60x8B/Alloc_Thread_60x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..83a058ec16964edc39727794329d6f0ee3dc1454 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0286-rc-function-ROSAlloc-Alloc_Thread_60x8B/Alloc_Thread_60x8B.java @@ -0,0 +1,66 @@ +/* + *- @TestCaseID:Alloc_Thread_60x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 50*8B to 60*8B(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Thread_60x8B.java + *- @ExecuteClass: Alloc_Thread_60x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Thread_60x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_60_8B=60*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=400-OBJ_HEADSIZE;i<=MAX_60_8B-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*256/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 194350) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Thread_60x8B { + public static void main(String[] args){ + Alloc_Thread_60x8B_01 test1=new Alloc_Thread_60x8B_01(); + test1.start(); + try{ + test1.join(); + }catch (InterruptedException e){} + if(test1.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0287-rc-function-ROSAlloc-Alloc_Thread_64x8B/Alloc_Thread_64x8B.java b/test/testsuite/ouroboros/rc_test/RC0287-rc-function-ROSAlloc-Alloc_Thread_64x8B/Alloc_Thread_64x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..2678706b25c28846690a408ccfd8a2d4b53e5c1f --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0287-rc-function-ROSAlloc-Alloc_Thread_64x8B/Alloc_Thread_64x8B.java @@ -0,0 +1,66 @@ +/* + *- @TestCaseID:Alloc_Thread_64x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 60*8B to 64*8B(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Thread_64x8B.java + *- @ExecuteClass: Alloc_Thread_64x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Thread_64x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_64_8B=64*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=480-OBJ_HEADSIZE;i<=MAX_64_8B-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*512/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 139895) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Thread_64x8B { + public static void main(String[] args){ + Alloc_Thread_64x8B_01 test1=new Alloc_Thread_64x8B_01(); + test1.start(); + try{ + test1.join(); + }catch (InterruptedException e){} + if(test1.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0288-rc-function-ROSAlloc-Alloc_Thread_B256x8B/Alloc_Thread_B256x8B.java b/test/testsuite/ouroboros/rc_test/RC0288-rc-function-ROSAlloc-Alloc_Thread_B256x8B/Alloc_Thread_B256x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..1430e570c6ea2dedf584557acb2e12853424e3e3 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0288-rc-function-ROSAlloc-Alloc_Thread_B256x8B/Alloc_Thread_B256x8B.java @@ -0,0 +1,69 @@ +/* + *- @TestCaseID:Alloc_Thread_B256x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 1MB to 2MB(max) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Thread_B256x8B.java + *- @ExecuteClass: Alloc_Thread_B256x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Thread_B256x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_B256_8B=2*1024*1024; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + int check_size=0; + for(int i=1024*1024-OBJ_HEADSIZE;i<=MAX_B256_8B-OBJ_HEADSIZE;i=i+1024) + { + for(int j=0;j<(PAGE_SIZE*10240/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + + //System.out.println(check_size); + if(check_size == 38167) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Thread_B256x8B { + public static void main(String[] args){ + Alloc_Thread_B256x8B_01 test1=new Alloc_Thread_B256x8B_01(); + test1.start(); + try{ + test1.join(); + }catch (InterruptedException e){} + if(test1.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0289-rc-function-ROSAlloc-Alloc_Threadm_128x8B_2/Alloc_Threadm_128x8B_2.java b/test/testsuite/ouroboros/rc_test/RC0289-rc-function-ROSAlloc-Alloc_Threadm_128x8B_2/Alloc_Threadm_128x8B_2.java new file mode 100755 index 0000000000000000000000000000000000000000..a23bf4f165de94e902ad91b788d6ae71b4a2d680 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0289-rc-function-ROSAlloc-Alloc_Threadm_128x8B_2/Alloc_Threadm_128x8B_2.java @@ -0,0 +1,89 @@ +/* + *- @TestCaseID:Alloc_Threadm_128x8B_2 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 64*8B to 128*8B(max) with 6 threads and time sleep + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Threadm_128x8B_2.java + *- @ExecuteClass: Alloc_Threadm_128x8B_2 + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Threadm_128x8B_2_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_128_8B=128*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + try{Thread.sleep(100);}catch(InterruptedException e){} + int check_size=0; + for(int i=512-OBJ_HEADSIZE;i<=MAX_128_8B-OBJ_HEADSIZE;i=i+10) + { + for(int j=0;j<(PAGE_SIZE*96/(i+OBJ_HEADSIZE)+10);j++) + { + if(j%1000==0) + { + try{Thread.sleep(100);}catch(InterruptedException e){} + } + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + + //System.out.println(check_size); + if(check_size == 28253) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Threadm_128x8B_2 { + public static void main(String[] args){ + Alloc_Threadm_128x8B_2_01 test1=new Alloc_Threadm_128x8B_2_01(); + test1.start(); + Alloc_Threadm_128x8B_2_01 test2=new Alloc_Threadm_128x8B_2_01(); + test2.start(); + Alloc_Threadm_128x8B_2_01 test3=new Alloc_Threadm_128x8B_2_01(); + test3.start(); + Alloc_Threadm_128x8B_2_01 test4=new Alloc_Threadm_128x8B_2_01(); + test4.start(); + Alloc_Threadm_128x8B_2_01 test5=new Alloc_Threadm_128x8B_2_01(); + test5.start(); + Alloc_Threadm_128x8B_2_01 test6=new Alloc_Threadm_128x8B_2_01(); + test6.start(); + try{ + test1.join(); + test2.join(); + test3.join(); + test4.join(); + test5.join(); + test6.join(); + }catch (InterruptedException e){} + if(test1.check()==true&&test2.check()==true && test3.check()==true&&test4.check()==true && test5.check()==true&&test6.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0290-rc-function-ROSAlloc-Alloc_Threadm_128x8B/Alloc_Threadm_128x8B.java b/test/testsuite/ouroboros/rc_test/RC0290-rc-function-ROSAlloc-Alloc_Threadm_128x8B/Alloc_Threadm_128x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..4bc1935ec5d0f8d6542474fa7ccabb25c6756e6a --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0290-rc-function-ROSAlloc-Alloc_Threadm_128x8B/Alloc_Threadm_128x8B.java @@ -0,0 +1,84 @@ +/* + *- @TestCaseID:Alloc_Threadm_128x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 40*8B to 50*8B(max) with 6 threads + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Threadm_128x8B.java + *- @ExecuteClass: Alloc_Threadm_128x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Threadm_128x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_128_8B=128*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + int check_size=0; + for(int i=512-OBJ_HEADSIZE;i<=MAX_128_8B-OBJ_HEADSIZE;i=i+10) + { + for(int j=0;j<(PAGE_SIZE*96/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + + //System.out.println(check_size); + if(check_size == 28253) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Threadm_128x8B { + public static void main(String[] args){ + Alloc_Threadm_128x8B_01 test1=new Alloc_Threadm_128x8B_01(); + test1.start(); + Alloc_Threadm_128x8B_01 test2=new Alloc_Threadm_128x8B_01(); + test2.start(); + Alloc_Threadm_128x8B_01 test3=new Alloc_Threadm_128x8B_01(); + test3.start(); + Alloc_Threadm_128x8B_01 test4=new Alloc_Threadm_128x8B_01(); + test4.start(); + Alloc_Threadm_128x8B_01 test5=new Alloc_Threadm_128x8B_01(); + test5.start(); + Alloc_Threadm_128x8B_01 test6=new Alloc_Threadm_128x8B_01(); + test6.start(); + try{ + test1.join(); + test2.join(); + test3.join(); + test4.join(); + test5.join(); + test6.join(); + }catch (InterruptedException e){} + if(test1.check()==true&&test2.check()==true && test3.check()==true&&test4.check()==true && test5.check()==true&&test6.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0291-rc-function-ROSAlloc-Alloc_Threadm_18x8B/Alloc_Threadm_18x8B.java b/test/testsuite/ouroboros/rc_test/RC0291-rc-function-ROSAlloc-Alloc_Threadm_18x8B/Alloc_Threadm_18x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..eb4fe2361d5d47a1ce1a116e683acf96ec5e2b01 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0291-rc-function-ROSAlloc-Alloc_Threadm_18x8B/Alloc_Threadm_18x8B.java @@ -0,0 +1,79 @@ +/* + *- @TestCaseID:Alloc_Threadm_18x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 8B to 18*8B(max) with 6 threads + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Threadm_18x8B.java + *- @ExecuteClass: Alloc_Threadm_18x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Threadm_18x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_18_8B=18*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=1;i<=MAX_18_8B-OBJ_HEADSIZE;i=i+20) + { + for(int j=0;j<(PAGE_SIZE*64/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 54765) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Threadm_18x8B { + public static void main(String[] args){ + Alloc_Threadm_18x8B_01 test1=new Alloc_Threadm_18x8B_01(); + test1.start(); + Alloc_Threadm_18x8B_01 test2=new Alloc_Threadm_18x8B_01(); + test2.start(); + Alloc_Threadm_18x8B_01 test3=new Alloc_Threadm_18x8B_01(); + test3.start(); + Alloc_Threadm_18x8B_01 test4=new Alloc_Threadm_18x8B_01(); + test4.start(); + Alloc_Threadm_18x8B_01 test5=new Alloc_Threadm_18x8B_01(); + test5.start(); + try{ + test1.join(); + test2.join(); + test3.join(); + test4.join(); + test5.join(); + }catch (InterruptedException e){} + if(test1.check()==true && test2.check() == true &&test3.check()==true && test4.check() == true&& test5.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0292-rc-function-ROSAlloc-Alloc_Threadm_192x8B_2/Alloc_Threadm_192x8B_2.java b/test/testsuite/ouroboros/rc_test/RC0292-rc-function-ROSAlloc-Alloc_Threadm_192x8B_2/Alloc_Threadm_192x8B_2.java new file mode 100755 index 0000000000000000000000000000000000000000..75231daed712a1c307924012ad5ec4233d5aacaa --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0292-rc-function-ROSAlloc-Alloc_Threadm_192x8B_2/Alloc_Threadm_192x8B_2.java @@ -0,0 +1,90 @@ +/* + * -@TestCaseID:Alloc_Threadm_192x8B_2 + * -@TestCaseName:MyselfClassName + * -@RequirementID:SR-10620538 + * -@RequirementName:[运行时需求]支持自动内存管理 + * -@Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing + * objects from 128*8B to 192*8B(max) with 6 threads and time sleep + * -@Condition: no + * -#c1 + * -@Brief:functionTest + * -#step1 + * -@Expect:ExpectResult\n + * -@Priority: High + * -@Source: Alloc_Threadm_192x8B_2.java + * -@ExecuteClass: Alloc_Threadm_192x8B_2 + * -@ExecuteArgs: + * -@Remark: + */ + +import java.util.ArrayList; + +class Alloc_Threadm_192x8B_2_01 extends Thread { + private static final int PAGE_SIZE = 4 * 1024; + private static final int OBJ_HEADSIZE = 8; + private static final int MAX_192_8B = 192 * 8; + private static boolean checkout = false; + + public void run() { + ArrayList store = new ArrayList(); + byte[] temp; + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // do nothing + } + int checkSize = 0; + for (int i = 1024 - OBJ_HEADSIZE; i <= MAX_192_8B - OBJ_HEADSIZE; i = i + 100) { + for (int j = 0; j < (PAGE_SIZE * 512 / (i + OBJ_HEADSIZE) + 10); j++) { + if (j % 1000 == 0) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // do nothing + } + } + temp = new byte[i]; + store.add(temp); + checkSize += store.size(); + store = new ArrayList(); + } + } + if (checkSize == 10117) { + checkout = true; + } + } + + public boolean check() { + return checkout; + } +} + +public class Alloc_Threadm_192x8B_2 { + public static void main(String[] args) { + Runtime.getRuntime().gc(); + Alloc_Threadm_192x8B_2_01 test1 = new Alloc_Threadm_192x8B_2_01(); + test1.start(); + Alloc_Threadm_192x8B_2_01 test2 = new Alloc_Threadm_192x8B_2_01(); + test2.start(); + Alloc_Threadm_192x8B_2_01 test3 = new Alloc_Threadm_192x8B_2_01(); + test3.start(); + Alloc_Threadm_192x8B_2_01 test4 = new Alloc_Threadm_192x8B_2_01(); + test4.start(); + try { + test1.join(); + test2.join(); + test3.join(); + test4.join(); + } catch (InterruptedException e) { + // do nothing + } + if (test1.check() == true && test2.check() == true && test3.check() == true && test4.check() == true) { + System.out.println("ExpectResult"); + } else { + System.out.println("Error"); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0293-rc-function-ROSAlloc-Alloc_Threadm_192x8B/Alloc_Threadm_192x8B.java b/test/testsuite/ouroboros/rc_test/RC0293-rc-function-ROSAlloc-Alloc_Threadm_192x8B/Alloc_Threadm_192x8B.java new file mode 100644 index 0000000000000000000000000000000000000000..c2f98182569fc5226755c9fe328c105cac91a890 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0293-rc-function-ROSAlloc-Alloc_Threadm_192x8B/Alloc_Threadm_192x8B.java @@ -0,0 +1,78 @@ +/* + * -@TestCaseID:Alloc_Threadm_192x8B + * -@TestCaseName:MyselfClassName + * -@RequirementID:SR-10620538 + * -@RequirementName:[运行时需求]支持自动内存管理 + * -@Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing + * objects from 128*8B to 192*8B(max) with 6 threads + * -@Condition: no + * -#c1 + * -@Brief:functionTest + * -#step1 + * -@Expect:ExpectResult\n + * -@Priority: High + * -@Source: Alloc_Threadm_192x8B.java + * -@ExecuteClass: Alloc_Threadm_192x8B + * -@ExecuteArgs: + * -@Remark: + */ + +import java.util.ArrayList; + +class Alloc_Threadm_192x8B_01 extends Thread { + private static final int PAGE_SIZE = 4 * 1024; + private static final int OBJ_HEADSIZE = 8; + private static final int MAX_192_8B = 192 * 8; + private static boolean checkout = false; + + public void run() { + ArrayList store = new ArrayList(); + byte[] temp; + int checkSize = 0; + for (int i = 1024 - OBJ_HEADSIZE; i <= MAX_192_8B - OBJ_HEADSIZE; i = i + 100) { + for (int j = 0; j < (PAGE_SIZE * 512 / (i + OBJ_HEADSIZE) + 10); j++) { + temp = new byte[i]; + store.add(temp); + checkSize++; + store = new ArrayList(); + } + } + if (checkSize == 10117) { + checkout = true; + } + } + + public boolean check() { + return checkout; + } +} + +public class Alloc_Threadm_192x8B { + public static void main(String[] args) { + Runtime.getRuntime().gc(); + Alloc_Threadm_192x8B_01 test1 = new Alloc_Threadm_192x8B_01(); + test1.start(); + Alloc_Threadm_192x8B_01 test2 = new Alloc_Threadm_192x8B_01(); + test2.start(); + Alloc_Threadm_192x8B_01 test3 = new Alloc_Threadm_192x8B_01(); + test3.start(); + Alloc_Threadm_192x8B_01 test4 = new Alloc_Threadm_192x8B_01(); + test4.start(); + try { + test1.join(); + test2.join(); + test3.join(); + test4.join(); + } catch (InterruptedException e) { + // do nothing + } + if (test1.check() && test2.check() && test3.check() && test4.check()) { + System.out.println("ExpectResult"); + } else { + System.out.println("Error"); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0294-rc-function-ROSAlloc-Alloc_Threadm_256x8B_2/Alloc_Threadm_256x8B_2.java b/test/testsuite/ouroboros/rc_test/RC0294-rc-function-ROSAlloc-Alloc_Threadm_256x8B_2/Alloc_Threadm_256x8B_2.java new file mode 100755 index 0000000000000000000000000000000000000000..efb274d6cb3e626c59b0f71369e8781ece2101f7 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0294-rc-function-ROSAlloc-Alloc_Threadm_256x8B_2/Alloc_Threadm_256x8B_2.java @@ -0,0 +1,91 @@ +/* + * -@TestCaseID:Alloc_Threadm_256x8B_2 + * -@TestCaseName:MyselfClassName + * -@RequirementID:SR-10620538 + * -@RequirementName:[运行时需求]支持自动内存管理 + * -@Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing + * objects from 192*8B to 256*8B(max) with 6 threads and time sleep + * -@Condition: no + * -#c1 + * -@Brief:functionTest + * -#step1 + * -@Expect:ExpectResult\n + * -@Priority: High + * -@Source: Alloc_Threadm_256x8B_2.java + * -@ExecuteClass: Alloc_Threadm_256x8B_2 + * -@ExecuteArgs: + * -@Remark: + */ + +import java.util.ArrayList; + +class Alloc_Threadm_256x8B_2_01 extends Thread { + private static final int PAGE_SIZE = 4 * 1024; + private static final int OBJ_HEADSIZE = 8; + private static final int MAX_256_8B = 256 * 8; + private static boolean checkOut = false; + + public void run() { + ArrayList store = new ArrayList(); + byte[] temp; + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // do nothing + } + int check_size = 0; + for (int i = 192 * 8 - OBJ_HEADSIZE; i <= MAX_256_8B - OBJ_HEADSIZE; i = i + 800) { + for (int j = 0; j < (PAGE_SIZE * 1024 / (i + OBJ_HEADSIZE) + 10); j++) { + if (j % 1000 == 0) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // do nothing + } + } + temp = new byte[i]; + store.add(temp); + check_size++; + store = new ArrayList(); + } + } + if (check_size == 2740) { + checkOut = true; + } + } + + public boolean check() { + return checkOut; + } +} + +public class Alloc_Threadm_256x8B_2 { + public static void main(String[] args) { + Runtime.getRuntime().gc(); + Alloc_Threadm_256x8B_2_01 test1 = new Alloc_Threadm_256x8B_2_01(); + test1.start(); + Alloc_Threadm_256x8B_2_01 test2 = new Alloc_Threadm_256x8B_2_01(); + test2.start(); + Alloc_Threadm_256x8B_2_01 test3 = new Alloc_Threadm_256x8B_2_01(); + test3.start(); + Alloc_Threadm_256x8B_2_01 test4 = new Alloc_Threadm_256x8B_2_01(); + test4.start(); + try { + test1.join(); + test2.join(); + test3.join(); + test4.join(); + } catch (InterruptedException e) { + // do nothing + } + if (test1.check() && test2.check() && test3.check() && test4.check()) { + System.out.println("ExpectResult"); + } else { + System.out.println("Error"); + } + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0295-rc-function-ROSAlloc-Alloc_Threadm_256x8B/Alloc_Threadm_256x8B.java b/test/testsuite/ouroboros/rc_test/RC0295-rc-function-ROSAlloc-Alloc_Threadm_256x8B/Alloc_Threadm_256x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..3366806b94de0d8c718a22e9a160afbaefcfab65 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0295-rc-function-ROSAlloc-Alloc_Threadm_256x8B/Alloc_Threadm_256x8B.java @@ -0,0 +1,79 @@ +/* + * -@TestCaseID:Alloc_Threadm_256x8B + * -@TestCaseName:MyselfClassName + * -@RequirementID:SR-10620538 + * -@RequirementName:[运行时需求]支持自动内存管理 + * -@Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing + * objects from 192*8B to 256*8B(max) with 6 threads + * -@Condition: no + * -#c1 + * -@Brief:functionTest + * -#step1 + * -@Expect:ExpectResult\n + * -@Priority: High + * -@Source: Alloc_Threadm_256x8B.java + * -@ExecuteClass: Alloc_Threadm_256x8B + * -@ExecuteArgs: + * -@Remark: + */ + +import java.util.ArrayList; + +class Alloc_Threadm_256x8B_01 extends Thread { + private static final int PAGE_SIZE = 4 * 1024; + private static final int OBJ_HEADSIZE = 8; + private static final int MAX_256_8B = 256 * 8; + private static boolean checkOut = false; + + public void run() { + ArrayList store = new ArrayList(); + byte[] temp; + int checkSize = 0; + for (int i = 192 * 8 - OBJ_HEADSIZE; i <= MAX_256_8B - OBJ_HEADSIZE; i = i + 800) { + for (int j = 0; j < (PAGE_SIZE * 512 / (i + OBJ_HEADSIZE) + 10); j++) { + temp = new byte[i]; + store.add(temp); + checkSize++; + store = new ArrayList(); + } + } + if (checkSize == 1375) { + checkOut = true; + } + } + + public boolean check() { + return checkOut; + } + +} + +public class Alloc_Threadm_256x8B { + public static void main(String[] args) { + Runtime.getRuntime().gc(); + Alloc_Threadm_256x8B_01 test1 = new Alloc_Threadm_256x8B_01(); + test1.start(); + Alloc_Threadm_256x8B_01 test2 = new Alloc_Threadm_256x8B_01(); + test2.start(); + Alloc_Threadm_256x8B_01 test3 = new Alloc_Threadm_256x8B_01(); + test3.start(); + Alloc_Threadm_256x8B_01 test4 = new Alloc_Threadm_256x8B_01(); + test4.start(); + try { + test1.join(); + test2.join(); + test3.join(); + test4.join(); + } catch (InterruptedException e) { + // do nothing + } + if (test1.check() && test2.check() && test3.check() && test4.check()) { + System.out.println("ExpectResult"); + } else { + System.out.println("Error"); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0296-rc-function-ROSAlloc-Alloc_Threadm_30x8B/Alloc_Threadm_30x8B.java b/test/testsuite/ouroboros/rc_test/RC0296-rc-function-ROSAlloc-Alloc_Threadm_30x8B/Alloc_Threadm_30x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..e6e84ab39d61305902809a270ec1ef87ff2c7d4a --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0296-rc-function-ROSAlloc-Alloc_Threadm_30x8B/Alloc_Threadm_30x8B.java @@ -0,0 +1,81 @@ +/* + *- @TestCaseID:Alloc_Threadm_30x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 18*8B to 30*8B(max) with 6 threads + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Threadm_30x8B.java + *- @ExecuteClass: Alloc_Threadm_30x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Threadm_30x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_30_8B=30*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=144-OBJ_HEADSIZE;i<=MAX_30_8B-OBJ_HEADSIZE;i=i+5) + { + for(int j=0;j<(PAGE_SIZE*64/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 28217) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Threadm_30x8B { + public static void main(String[] args){ + Alloc_Threadm_30x8B_01 test1=new Alloc_Threadm_30x8B_01(); + test1.start(); + Alloc_Threadm_30x8B_01 test2=new Alloc_Threadm_30x8B_01(); + test2.start(); + Alloc_Threadm_30x8B_01 test3=new Alloc_Threadm_30x8B_01(); + test3.start(); + Alloc_Threadm_30x8B_01 test4=new Alloc_Threadm_30x8B_01(); + test4.start(); + Alloc_Threadm_30x8B_01 test5=new Alloc_Threadm_30x8B_01(); + test5.start(); + Alloc_Threadm_30x8B_01 test6=new Alloc_Threadm_30x8B_01(); + test6.start(); + try{ + test1.join(); + test2.join(); + test3.join(); + test4.join(); + test5.join(); + test6.join(); + }catch (InterruptedException e){} + if(test1.check()==true&& test2.check()==true&&test3.check()==true&& test4.check()==true&&test5.check()==true&& test6.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0297-rc-function-ROSAlloc-Alloc_Threadm_40x8B/Alloc_Threadm_40x8B.java b/test/testsuite/ouroboros/rc_test/RC0297-rc-function-ROSAlloc-Alloc_Threadm_40x8B/Alloc_Threadm_40x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..2315b70678740563fa246c5d811f762d172c9a4d --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0297-rc-function-ROSAlloc-Alloc_Threadm_40x8B/Alloc_Threadm_40x8B.java @@ -0,0 +1,81 @@ +/* + *- @TestCaseID:Alloc_Threadm_40x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 30*8B to 40*8B(max) with 6 threads + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Threadm_40x8B.java + *- @ExecuteClass: Alloc_Threadm_40x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Threadm_40x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_40_8B=40*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=240-OBJ_HEADSIZE;i<=MAX_40_8B-OBJ_HEADSIZE;i+=4) + { + for(int j=0;j<(PAGE_SIZE*96/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 29915) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Threadm_40x8B { + public static void main(String[] args){ + Alloc_Threadm_40x8B_01 test1=new Alloc_Threadm_40x8B_01(); + test1.start(); + Alloc_Threadm_40x8B_01 test2=new Alloc_Threadm_40x8B_01(); + test2.start(); + Alloc_Threadm_40x8B_01 test3=new Alloc_Threadm_40x8B_01(); + test3.start(); + Alloc_Threadm_40x8B_01 test4=new Alloc_Threadm_40x8B_01(); + test4.start(); + Alloc_Threadm_40x8B_01 test5=new Alloc_Threadm_40x8B_01(); + test5.start(); + Alloc_Threadm_40x8B_01 test6=new Alloc_Threadm_40x8B_01(); + test6.start(); + try{ + test1.join(); + test2.join(); + test3.join(); + test4.join(); + test5.join(); + test6.join(); + }catch (InterruptedException e){} + if(test1.check()==true&&test2.check()==true && test3.check()==true&&test4.check()==true && test5.check()==true&&test6.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0298-rc-function-ROSAlloc-Alloc_Threadm_50x8B/Alloc_Threadm_50x8B.java b/test/testsuite/ouroboros/rc_test/RC0298-rc-function-ROSAlloc-Alloc_Threadm_50x8B/Alloc_Threadm_50x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..fc3baad1c7c8dadc8c45eb2e8318f580d79ee98a --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0298-rc-function-ROSAlloc-Alloc_Threadm_50x8B/Alloc_Threadm_50x8B.java @@ -0,0 +1,81 @@ +/* + *- @TestCaseID:Alloc_Threadm_50x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 40*8B to 50*8B(max) with 6 threads + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Threadm_50x8B.java + *- @ExecuteClass: Alloc_Threadm_50x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Threadm_50x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_50_8B=50*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=320-OBJ_HEADSIZE;i<=MAX_50_8B-OBJ_HEADSIZE;i=i+5) + { + for(int j=0;j<(PAGE_SIZE*96/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 18816) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Threadm_50x8B { + public static void main(String[] args){ + Alloc_Threadm_50x8B_01 test1=new Alloc_Threadm_50x8B_01(); + test1.start(); + Alloc_Threadm_50x8B_01 test2=new Alloc_Threadm_50x8B_01(); + test2.start(); + Alloc_Threadm_50x8B_01 test3=new Alloc_Threadm_50x8B_01(); + test3.start(); + Alloc_Threadm_50x8B_01 test4=new Alloc_Threadm_50x8B_01(); + test4.start(); + Alloc_Threadm_50x8B_01 test5=new Alloc_Threadm_50x8B_01(); + test5.start(); + Alloc_Threadm_50x8B_01 test6=new Alloc_Threadm_50x8B_01(); + test6.start(); + try{ + test1.join(); + test2.join(); + test3.join(); + test4.join(); + test5.join(); + test6.join(); + }catch (InterruptedException e){} + if(test1.check()==true&&test2.check()==true && test3.check()==true&&test4.check()==true && test5.check()==true&&test6.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0299-rc-function-ROSAlloc-Alloc_Threadm_60x8B/Alloc_Threadm_60x8B.java b/test/testsuite/ouroboros/rc_test/RC0299-rc-function-ROSAlloc-Alloc_Threadm_60x8B/Alloc_Threadm_60x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..63a4a45b22463923d39c1e656d87960304bd2643 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0299-rc-function-ROSAlloc-Alloc_Threadm_60x8B/Alloc_Threadm_60x8B.java @@ -0,0 +1,82 @@ +/* + *- @TestCaseID:Alloc_Threadm_60x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 50*8B to 60*8B(max) with 6 threads + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Threadm_60x8B.java + *- @ExecuteClass: Alloc_Threadm_60x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Threadm_60x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_60_8B=60*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=400-OBJ_HEADSIZE;i<=MAX_60_8B-OBJ_HEADSIZE;i+=3) + { + for(int j=0;j<(PAGE_SIZE*96/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 24509) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Threadm_60x8B { + public static void main(String[] args){ + Runtime.getRuntime().gc(); + Alloc_Threadm_60x8B_01 test1=new Alloc_Threadm_60x8B_01(); + test1.start(); + Alloc_Threadm_60x8B_01 test2=new Alloc_Threadm_60x8B_01(); + test2.start(); + Alloc_Threadm_60x8B_01 test3=new Alloc_Threadm_60x8B_01(); + test3.start(); + Alloc_Threadm_60x8B_01 test4=new Alloc_Threadm_60x8B_01(); + test4.start(); + Alloc_Threadm_60x8B_01 test5=new Alloc_Threadm_60x8B_01(); + test5.start(); + Alloc_Threadm_60x8B_01 test6=new Alloc_Threadm_60x8B_01(); + test6.start(); + try{ + test1.join(); + test2.join(); + test3.join(); + test4.join(); + test5.join(); + test6.join(); + }catch (InterruptedException e){} + if(test1.check()==true&&test2.check()==true && test3.check()==true&&test4.check()==true && test5.check()==true&&test6.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0300-rc-function-ROSAlloc-Alloc_Threadm_64x8B/Alloc_Threadm_64x8B.java b/test/testsuite/ouroboros/rc_test/RC0300-rc-function-ROSAlloc-Alloc_Threadm_64x8B/Alloc_Threadm_64x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..0b0be8d56a00f1327f6d7c114a2342438cf98d7f --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0300-rc-function-ROSAlloc-Alloc_Threadm_64x8B/Alloc_Threadm_64x8B.java @@ -0,0 +1,81 @@ +/* + *- @TestCaseID:Alloc_Threadm_64x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 60*8B to 64*8B(max) with 6 threads + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Threadm_64x8B.java + *- @ExecuteClass: Alloc_Threadm_64x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Threadm_64x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_64_8B=64*8; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=480-OBJ_HEADSIZE;i<=MAX_64_8B-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*96/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 26487) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Threadm_64x8B { + public static void main(String[] args){ + Alloc_Threadm_64x8B_01 test1=new Alloc_Threadm_64x8B_01(); + test1.start(); + Alloc_Threadm_64x8B_01 test2=new Alloc_Threadm_64x8B_01(); + test2.start(); + Alloc_Threadm_64x8B_01 test3=new Alloc_Threadm_64x8B_01(); + test3.start(); + Alloc_Threadm_64x8B_01 test4=new Alloc_Threadm_64x8B_01(); + test4.start(); + Alloc_Threadm_64x8B_01 test5=new Alloc_Threadm_64x8B_01(); + test5.start(); + Alloc_Threadm_64x8B_01 test6=new Alloc_Threadm_64x8B_01(); + test6.start(); + try{ + test1.join(); + test2.join(); + test3.join(); + test4.join(); + test5.join(); + test6.join(); + }catch (InterruptedException e){} + if(test1.check()==true&&test2.check()==true && test3.check()==true&&test4.check()==true && test5.check()==true&&test6.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0301-rc-function-ROSAlloc-Alloc_Threadm_B256x8B/Alloc_Threadm_B256x8B.java b/test/testsuite/ouroboros/rc_test/RC0301-rc-function-ROSAlloc-Alloc_Threadm_B256x8B/Alloc_Threadm_B256x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..37b4684488c091f1d3bf61f388600ee6877f7229 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0301-rc-function-ROSAlloc-Alloc_Threadm_B256x8B/Alloc_Threadm_B256x8B.java @@ -0,0 +1,89 @@ +/* + *- @TestCaseID:Alloc_Threadm_B256x8B + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title:ROS Allocator is in charge of applying and releasing objects.This mulit thread testcase is mainly for testing objects from 1MB to 2MB(max) with 6 threads + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Alloc_Threadm_B256x8B.java + *- @ExecuteClass: Alloc_Threadm_B256x8B + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.ArrayList; + +class Alloc_Threadm_B256x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_B256_8B=2*1024*1024; + private static boolean checkout=false; + + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + int check_size=0; + for(int i=1024*1024-OBJ_HEADSIZE;i<=MAX_B256_8B-OBJ_HEADSIZE;i=i+15120) + { + for(int j=0;j<(PAGE_SIZE*10240/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + + //System.out.println(check_size); + if(check_size == 2612) + checkout=true; + + } + public boolean check() { + return checkout; + } + +} + +public class Alloc_Threadm_B256x8B { + public static void main(String[] args){ + Alloc_Threadm_B256x8B_01 test1=new Alloc_Threadm_B256x8B_01(); + test1.start(); + try{ test1.sleep(1000);} catch(InterruptedException e){} + Alloc_Threadm_B256x8B_01 test2=new Alloc_Threadm_B256x8B_01(); + test2.start(); + try{ test2.sleep(1000);} catch(InterruptedException e){} + Alloc_Threadm_B256x8B_01 test3=new Alloc_Threadm_B256x8B_01(); + test3.start(); + try{ test3.sleep(1000);} catch(InterruptedException e){} + Alloc_Threadm_B256x8B_01 test4=new Alloc_Threadm_B256x8B_01(); + test4.start(); + try{ test4.sleep(1000);} catch(InterruptedException e){} + Alloc_Threadm_B256x8B_01 test5=new Alloc_Threadm_B256x8B_01(); + test5.start(); + try{ test5.sleep(1000);} catch(InterruptedException e){} + Alloc_Threadm_B256x8B_01 test6=new Alloc_Threadm_B256x8B_01(); + test6.start(); + try{ + test1.join(); + test2.join(); + test3.join(); + test4.join(); + test5.join(); + test6.join(); + }catch (InterruptedException e){} + if(test1.check()==true&&test2.check()==true && test3.check()==true&&test4.check()==true && test5.check()==true&&test6.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0302-rc-function-Ref-PhantomRefTest/PhantomRefTest.java b/test/testsuite/ouroboros/rc_test/RC0302-rc-function-Ref-PhantomRefTest/PhantomRefTest.java new file mode 100755 index 0000000000000000000000000000000000000000..2d1844adf114cb6dc5014b55b622c2acf24ce66e --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0302-rc-function-Ref-PhantomRefTest/PhantomRefTest.java @@ -0,0 +1,50 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/PhantomRefTest.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: PhantomRefTest basic testcase + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: PhantomRefTest.java + *- @ExecuteClass: PhantomRefTest + *- @ExecuteArgs: + *- @Remark: + * + */ +import java.lang.ref.*; + +public class PhantomRefTest { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static int a = 100; + + static void setPhantomReference() { + rp = new PhantomReference(new Object(), rq); + if (rp.get() != null) { + a++; + } + } + + public static void main(String [] args) throws Exception { + Reference r; + setPhantomReference(); + Thread.sleep(2000); + while ((r = rq.poll())!=null) { + if (!r.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + a++; + } + } + + if (a == 100) { + System.out.println("ExpectResult"); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0303-rc-function-Ref-SoftRefTest/SoftRefTest.java b/test/testsuite/ouroboros/rc_test/RC0303-rc-function-Ref-SoftRefTest/SoftRefTest.java new file mode 100755 index 0000000000000000000000000000000000000000..d1290b197a52241f8903113d554c4bfdfe2a2975 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0303-rc-function-Ref-SoftRefTest/SoftRefTest.java @@ -0,0 +1,64 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/SoftRefTest.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: SoftRefTest basic testcase + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: SoftRefTest.java + *- @ExecuteClass: SoftRefTest + *- @ExecuteArgs: + *- @Remark: + * + */ +import java.lang.ref.*; + +public class SoftRefTest { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static int a = 100; + + static void setSoftReference() { + rp = new SoftReference(new Object(), rq); + if (rp.get() == null) { + a++; + } + } + + static class TriggerRP implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + SoftReference sr = new SoftReference(new Object()); + try { + Thread.sleep(50); + } catch (Exception e) {} + } + } + } + + public static void main(String [] args) throws Exception { + Reference r; + setSoftReference(); + new Thread(new TriggerRP()).start(); + Thread.sleep(3000); + if (rp.get() != null) { + a++; + } + while ((r = rq.poll())!=null) { + if(!r.getClass().toString().equals("class java.lang.ref.SoftReference")) { + a++; + } + } + if (a == 101) { + System.out.println("ExpectResult"); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0304-rc-function-Ref-WeakRefTest/WeakRefTest.java b/test/testsuite/ouroboros/rc_test/RC0304-rc-function-Ref-WeakRefTest/WeakRefTest.java new file mode 100755 index 0000000000000000000000000000000000000000..a760b6019a21d80b518827d52fe8cbedd85e257e --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0304-rc-function-Ref-WeakRefTest/WeakRefTest.java @@ -0,0 +1,64 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/WeakRefTest.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: WeakRefTest basic testcase + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: WeakRefTest.java + *- @ExecuteClass: WeakRefTest + *- @ExecuteArgs: + *- @Remark: + * + */ +import java.lang.ref.*; + +public class WeakRefTest { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static int a = 100; + + static void setWeakReference() { + rp = new WeakReference(new Object(), rq); + if (rp.get() == null) { + a++; + } + } + + static class TriggerRP implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + WeakReference wr = new WeakReference(new Object()); + try { + Thread.sleep(50); + } catch (Exception e) {} + } + } + } + + public static void main(String [] args) throws Exception { + Reference r; + setWeakReference(); + new Thread(new TriggerRP()).start(); + Thread.sleep(3000); + if (rp.get() != null) { + a++; + } + while ((r = rq.poll())!=null) { + if (!r.getClass().toString().equals("class java.lang.ref.WeakReference")) { + a++; + } + } + + if (a == 100) { + System.out.println("ExpectResult"); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0309-rc-function-Optimization-RC_newObjectIassign_01/RC_newObjectIassign_01.java b/test/testsuite/ouroboros/rc_test/RC0309-rc-function-Optimization-RC_newObjectIassign_01/RC_newObjectIassign_01.java new file mode 100755 index 0000000000000000000000000000000000000000..dc993a3cf6c73bfc01c7e70005e888c9eb7d2147 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0309-rc-function-Optimization-RC_newObjectIassign_01/RC_newObjectIassign_01.java @@ -0,0 +1,79 @@ + +/* + *- @TestCaseID:maple/runtime/rc/function/RC_newObjectIassign_01.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: 针对RC优化new object assign 做场景测试:对象类中的某个域如果在类初始化时没有做赋值,则不会对它的incref(无集成场景) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_newObjectIassign_01.java + *- @ExecuteClass: RC_newObjectIassign_01 + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.Arrays; + +public class RC_newObjectIassign_01 { + final static String STR = "MapleTest"; + static int check = 0; + String[] strArray; + static String str1; + volatile String str2; + private RC_newObjectIassign_01(){ + strArray=new String[10]; + str1="MapleTest"; + str2="FigoTest"; + } + private RC_newObjectIassign_01(String str){ + str1=str; + str2=str; + } + private RC_newObjectIassign_01(String[] str){ + strArray=str; + } + + public static void main(String[] args){ + for(int i =1; i<=100 ; i++){ + test_new_objct_assign(); + if(check != 5){ + System.out.println("ErrorResult"); + break; + }else{ + check=0; + str1=null; + } + + } + System.out.println("ExpectResult"); + } + private static void test_new_objct_assign(){ + String[] example = {"a","b","c"}; + String[] arrayStr = {"a","b","c"}; + RC_newObjectIassign_01 rctest=new RC_newObjectIassign_01(arrayStr); + if(Arrays.equals(rctest.strArray,example) && rctest.str1 ==null && rctest.str2== null) + check +=1; + rctest.str1="firstTimeTestStr1"; + rctest.str2="firstTimeTestStr2"; + if(Arrays.equals(rctest.strArray,example) && rctest.str1 =="firstTimeTestStr1" && rctest.str2== "firstTimeTestStr2") + check +=1; + + rctest = new RC_newObjectIassign_01("secondTimeTest"); + if(Arrays.equals(rctest.strArray,null) && rctest.str1 =="secondTimeTest" && rctest.str2== "secondTimeTest") + check +=1; + rctest.strArray = arrayStr; + if(Arrays.equals(rctest.strArray,example) && rctest.str1 =="secondTimeTest" && rctest.str2== "secondTimeTest") + check +=1; + + rctest=new RC_newObjectIassign_01(); + if(rctest.strArray.length == 10 && rctest.str1 =="MapleTest" && rctest.str2== "FigoTest") + check +=1; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0310-rc-function-Optimization-RC_newObjectIassign_02/RC_newObjectIassign_02.java b/test/testsuite/ouroboros/rc_test/RC0310-rc-function-Optimization-RC_newObjectIassign_02/RC_newObjectIassign_02.java new file mode 100755 index 0000000000000000000000000000000000000000..be08b2d1836de77e1eebfba9e9f16ee9ecc778a0 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0310-rc-function-Optimization-RC_newObjectIassign_02/RC_newObjectIassign_02.java @@ -0,0 +1,82 @@ + +/* + *- @TestCaseID:maple/runtime/rc/function/RC_newObjectIassign_02.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: 针对RC优化new object assign 做场景测试:对象类中的某个域如果在类初始化时没有做赋值,则不会对它的incref(无集成场景) + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_newObjectIassign_02.java + *- @ExecuteClass: RC_newObjectIassign_02 + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.Arrays; +class Base{ + String[] strArray; + volatile String str2; +} + +public class RC_newObjectIassign_02 extends Base{ + final static String STR = "MapleTest"; + static int check = 0; + static String str1; + + private RC_newObjectIassign_02(){ + strArray=new String[10]; + str1="MapleTest"; + str2="FigoTest"; + } + private RC_newObjectIassign_02(String str){ + str1=str; + str2=str; + } + private RC_newObjectIassign_02(String[] str){ + strArray=str; + } + + public static void main(String[] args){ + for(int i =1; i<=100 ; i++){ + test_new_objct_assign(); + if(check != 5){ + System.out.println("ErrorResult"); + break; + }else{ + check=0; + str1=null; + } + + } + System.out.println("ExpectResult"); + } + private static void test_new_objct_assign(){ + String[] example = {"a","b","c"}; + String[] arrayStr = {"a","b","c"}; + RC_newObjectIassign_02 rctest=new RC_newObjectIassign_02(arrayStr); + if(Arrays.equals(rctest.strArray,example) && rctest.str1 ==null && rctest.str2== null) + check +=1; + rctest.str1="firstTimeTestStr1"; + rctest.str2="firstTimeTestStr2"; + if(Arrays.equals(rctest.strArray,example) && rctest.str1 =="firstTimeTestStr1" && rctest.str2== "firstTimeTestStr2") + check +=1; + + rctest = new RC_newObjectIassign_02("secondTimeTest"); + if(Arrays.equals(rctest.strArray,null) && rctest.str1 =="secondTimeTest" && rctest.str2== "secondTimeTest") + check +=1; + rctest.strArray = arrayStr; + if(Arrays.equals(rctest.strArray,example) && rctest.str1 =="secondTimeTest" && rctest.str2== "secondTimeTest") + check +=1; + + rctest=new RC_newObjectIassign_02(); + if(rctest.strArray.length == 10 && rctest.str1 =="MapleTest" && rctest.str2== "FigoTest") + check +=1; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0311-rc-function-Optimization-RC_newObjectToField/RC_newObjectToField.java b/test/testsuite/ouroboros/rc_test/RC0311-rc-function-Optimization-RC_newObjectToField/RC_newObjectToField.java new file mode 100755 index 0000000000000000000000000000000000000000..f7881e52977d5e93893a841f55124cbeaef0afd2 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0311-rc-function-Optimization-RC_newObjectToField/RC_newObjectToField.java @@ -0,0 +1,79 @@ + +/* + *- @TestCaseID:maple/runtime/rc/function/RC_newObjectToField.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: 对于像mR = new Obj()的语句; 为了分配一个新对象并将其引用分配给一个field,我们正在生成一对冗余的RC Inc / Dec操作 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_newObjectToField.java + *- @ExecuteClass: RC_newObjectToField + *- @ExecuteArgs: + *- @Remark:http://rnd-gitlab-ca.huawei.com/Maple/mapleall/issues/1780 + */ +import java.util.Arrays; + +public class RC_newObjectToField { + final static String STR = "MapleTest"; + static int check = 0; + volatile static String[] strArray; + static String str1; + volatile String str2; + private RC_newObjectToField(){ + strArray=new String[10]; + str1=new String("str1")+"MapleTest"; + str2="FigoTest"; + } + private RC_newObjectToField(String str){ + str1=new String("str1")+str; + str2=new String("str2")+str; + } + private RC_newObjectToField(String[] str){ + Arrays.sort(str); + Arrays.toString(str); + new Object(); + new String("Just Test"); + Arrays.binarySearch(str,"d"); + strArray=new String[10]; + strArray=str; + } + + + public static void main(String[] args){ + for(int i =1; i<=100 ; i++){ + test_new_objct_assign(); + if(check != 3){ + System.out.println("ErrorResult"); + break; + }else{ + check=0; + str1=null; + } + + } + System.out.println("ExpectResult"); + } + private static void test_new_objct_assign(){ + String[] example = {"a","b","c"}; + String[] arrayStr = {"c","a","b"}; + RC_newObjectToField rctest=new RC_newObjectToField(arrayStr); + if(Arrays.equals(rctest.strArray,example) && rctest.str1 ==null && rctest.str2== null) + check +=1; + + rctest = new RC_newObjectToField("secondTimeTest"); + if(Arrays.equals(rctest.strArray,example) && rctest.str1.equals("str1secondTimeTest") && rctest.str2.equals( "str2secondTimeTest")) + check +=1; + + rctest=new RC_newObjectToField(); + if(rctest.strArray.length == 10 && rctest.str1.equals("str1MapleTest") && rctest.str2== "FigoTest") + check +=1; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0312-rc-function-Optimization-RC_newObjectToField_02/RC_newObjectToField_02.java b/test/testsuite/ouroboros/rc_test/RC0312-rc-function-Optimization-RC_newObjectToField_02/RC_newObjectToField_02.java new file mode 100755 index 0000000000000000000000000000000000000000..586d2657de9abdf0d416a5ea033b4ed08a4ea3c7 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0312-rc-function-Optimization-RC_newObjectToField_02/RC_newObjectToField_02.java @@ -0,0 +1,84 @@ + +/* + *- @TestCaseID:maple/runtime/rc/function/RC_newObjectToField_02.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: 对于像mR = new Obj()的语句; 为了分配一个新对象并将其引用分配给一个field,我们正在生成一对冗余的RC Inc / Dec操作 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_newObjectToField_02.java + *- @ExecuteClass: RC_newObjectToField_02 + *- @ExecuteArgs: + *- @Remark:http://rnd-gitlab-ca.huawei.com/Maple/mapleall/issues/1780 + */ +import java.util.Arrays; + +public class RC_newObjectToField_02 { + final static String STR = "MapleTest"; + static int check = 0; + volatile static String[] strArray; + int[] intArray; + static String str1; + volatile String str2; + private RC_newObjectToField_02() throws ArithmeticException{ + strArray=new String[10]; + str1=new String("str1")+"MapleTest"; + str2="FigoTest"; + intArray = new int[]{1/0}; + } + private RC_newObjectToField_02(String str) throws StringIndexOutOfBoundsException{ + str1=(new String("str1")+str).substring(-1,-2); + str2=new String("str2")+str; + } + private RC_newObjectToField_02(String[] str) throws ArrayIndexOutOfBoundsException{ + Arrays.sort(str); + Arrays.toString(str); + new Object(); + new String("Just Test"); + Arrays.binarySearch(str,"d"); + intArray=new int[10]; + strArray=new String[1]; + strArray[2]=new String("IndexOutBounds"); + } + + public static void main(String[] args){ + for(int i =1; i<=100 ; i++){ + test_new_objct_assign(); + if(check != 3){ + System.out.println("ErrorResult"); + break; + }else{ + check=0; + str1=null; + } + + } + System.out.println("ExpectResult"); + } + private static void test_new_objct_assign(){ + String[] arrayStr = {"c","a","b"}; + try{ + RC_newObjectToField_02 rctest=new RC_newObjectToField_02(arrayStr); + }catch(ArrayIndexOutOfBoundsException a) { + check += 1; + } + try{ + RC_newObjectToField_02 rctest = new RC_newObjectToField_02("secondTimeTest");} + catch(StringIndexOutOfBoundsException s){ + check +=1; + } + try{ + RC_newObjectToField_02 rctest=new RC_newObjectToField_02();} + catch(ArithmeticException a){ + check +=1; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0313-rc-function-Optimization-RC_staticInput/RC_staticInput.java b/test/testsuite/ouroboros/rc_test/RC0313-rc-function-Optimization-RC_staticInput/RC_staticInput.java new file mode 100755 index 0000000000000000000000000000000000000000..7dba448a7056b10aa2a823b9996eecc0cc789eda --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0313-rc-function-Optimization-RC_staticInput/RC_staticInput.java @@ -0,0 +1,42 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_staticInput.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: RC_staticInput.java + *- @ExecuteClass: RC_staticInput + *- @ExecuteArgs: + *- @Remark: + */ +public class RC_staticInput { + static int []test= {10,20,30,40}; + + public static void main(String [] args) { + if(test.length==4) + System.out.println("ExpectResult"); + else + System.out.println("ErrorResult"); + test(4,test); + if(test.length==4) + System.out.println("ExpectResult"); + else + System.out.println("ErrorResult"); + } + public static void test(int first, int[] second) { + int [] xyz = {23,24,25,26}; + test = xyz; + if(second.length==4) + System.out.println("ExpectResult"); + else + System.out.println("ErrorResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0314-rc-function-Optimization-RC_staticInput_02/RC_staticInput_02.java b/test/testsuite/ouroboros/rc_test/RC0314-rc-function-Optimization-RC_staticInput_02/RC_staticInput_02.java new file mode 100755 index 0000000000000000000000000000000000000000..ce676e01e053d97dcf942d00ac1f50a9bb097913 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0314-rc-function-Optimization-RC_staticInput_02/RC_staticInput_02.java @@ -0,0 +1,45 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_staticInput_02.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: RC_staticInput_02.java + *- @ExecuteClass: RC_staticInput_02 + *- @ExecuteArgs: + *- @Remark: + */ +public class RC_staticInput_02 { + static int []test= {10,20,30,40}; + + public static void main(String [] args) { + if(test.length==4) + System.out.println("ExpectResult"); + else + System.out.println("ErrorResult"); + test(4,test); + if(test.length==4) + System.out.println("ExpectResult"); + else + System.out.println("ErrorResult"); + } + public static void test(int first, int[] second) { + int [] xyz = {23,24,25,26}; + modify(xyz); + if(second.length==4) + System.out.println("ExpectResult"); + else + System.out.println("ErrorResult"); + } + public static void modify(int[] temp){ + test=temp; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0315-rc-Memory-normalTestCase1/Memory_normalTestCase1.java b/test/testsuite/ouroboros/rc_test/RC0315-rc-Memory-normalTestCase1/Memory_normalTestCase1.java new file mode 100755 index 0000000000000000000000000000000000000000..3bb34c1d4d6810edf5f42b60ed333d725cdcc4bf --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0315-rc-Memory-normalTestCase1/Memory_normalTestCase1.java @@ -0,0 +1,646 @@ +/* + *- @TestCaseID:rc/stress/Memory_normalTestCase1.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:默认启动80个线程,对62个runslot去申请释放它们所管理的区间大小的内存块,所申请的内存块不会立刻释放。 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect: + *- @Priority: High + *- @Source: Memory_normalTestCase1.java + *- @ExecuteClass: Memory_normalTestCase1 + *- @ExecuteArgs: + *- @Remark: + *- @Author:从压力测试case中拆解 liuweiqing l00481345 + */ + + +import sun.misc.Cleaner; + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; + +public class Memory_normalTestCase1 { + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + private static final int ALLOC_4K = 4 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + + static List> mAllThreadReference = new ArrayList>(); + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + + private static void resetTestEnvirment(List> referenceList) { + + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + + public static void testCase1() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + int slot = 0; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + slot = i % MAX_SLOT_NUM; + t = new Thread(new MemAlloc(ALLOC_4K, slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, false, 1), "testCase1_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + System.out.println("ExpectResult"); + } + + public static void main(String[] args) { + testCase1(); + } + + + public static class AllocUnit { + public byte unit[]; + + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + + public abstract List alloc(boolean isStress); + } + + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + + public static class AllocUnitWithSoftReference extends AllocUnit { + + private Reference refArray; + + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private final Cleaner cleaner; + + private static class TestCleaner implements Runnable { + public byte unit[]; + + public TestCleaner(byte unit[]) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + + private Reference refArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + + } + + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + + return new AllocUnit(alloc_size); + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0316-rc-Memory-normalTestCase2/Memory_normalTestCase2.java b/test/testsuite/ouroboros/rc_test/RC0316-rc-Memory-normalTestCase2/Memory_normalTestCase2.java new file mode 100755 index 0000000000000000000000000000000000000000..22db92ecb381d8c0be94cd107bc3fb90e4c2b870 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0316-rc-Memory-normalTestCase2/Memory_normalTestCase2.java @@ -0,0 +1,653 @@ +/* + *- @TestCaseID:rc/stress/Memory_normalTestCase2.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:默认启动80个线程,对62个runslot去申请释放它们所管理的区间大小的内存块,一起释放。同时在起一个线程去申请同样大小的内存块去一半一半地释放。这样会造成大量的释放 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect: + *- @Priority: High + *- @Source: Memory_normalTestCase2.java + *- @ExecuteClass: Memory_normalTestCase2 + *- @ExecuteArgs: + *- @Remark: + *- @Author:从压力测试case中拆解 liuweiqing l00481345 + */ + +import sun.misc.Cleaner; + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; + +public class Memory_normalTestCase2 { + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + + static List> mAllThreadReference = new ArrayList>(); + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + + private static void resetTestEnvirment(List> referenceList) { + + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + + public static void testCase2() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + int slot = 0; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + slot = i % MAX_SLOT_NUM; + Runnable remain = new MemAlloc(ALLOC_4K, slot, mAllThreadReference, i, MemAlloc.SAVE_HALF_RAMDOM, true, 1); + t = new Thread(new MemAlloc(ALLOC_4K, slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, true, 1, DEFAULT_REPEAT_TIMES, remain), "testCase2_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + + } + + public static void main(String[] args) { + + testCase2(); + Runtime.getRuntime().gc(); + testCase2(); + System.out.println("ExpectResult"); + } + + + public static class AllocUnit { + public byte unit[]; + + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + + public abstract List alloc(boolean isStress); + } + + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + + public static class AllocUnitWithSoftReference extends AllocUnit { + + private Reference refArray; + + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private final Cleaner cleaner; + + private static class TestCleaner implements Runnable { + public byte unit[]; + + public TestCleaner(byte unit[]) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + + private Reference refArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + + return new AllocUnit(alloc_size); + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0317-rc-Memory-normalTestCase3/Memory_normalTestCase3.java b/test/testsuite/ouroboros/rc_test/RC0317-rc-Memory-normalTestCase3/Memory_normalTestCase3.java new file mode 100755 index 0000000000000000000000000000000000000000..172ad27fb95a136ded9667846e249ad264a6dbbb --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0317-rc-Memory-normalTestCase3/Memory_normalTestCase3.java @@ -0,0 +1,634 @@ +/* + * -@TestCaseID:rc/stress/Memory_normalTestCase3.java + * -@TestCaseName:MyselfClassName + * -@RequirementID:SR-10620538 + * -@RequirementName:[运行时需求]支持自动内存管理 + * -@Title/Destination:默认启动80个线程,对62个runslot去申请释放它们所管理的区间大小的内存块,不会立刻释放。同时在起一个线程去申请同样大小的内存块去一半一半地释放。 + * -@Condition: no + * -#c1 + * -@Brief:functionTest + * -#step1 + * -@Expect: + * -@Priority: High + * -@Source: Memory_normalTestCase3.java + * -@ExecuteClass: Memory_normalTestCase3 + * -@ExecuteArgs: + * -@Remark: + * -@Author:从压力测试case中拆解 liuweiqing l00481345 + */ + +import sun.misc.Cleaner; + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.Random; +import java.util.List; +import java.util.ArrayList; +import java.util.Set; +import java.util.HashSet; + +public class Memory_normalTestCase3 { + private static final int MAX_REALIVE_OBJ_NUM = 1000; + private static final int MAX_SLOT_NUM = 62; + private static final int DEFAULT_THREAD_NUM = 80; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + private static boolean running = true; + private static List> allThreadReference = new ArrayList>(); + private static boolean rest = false; + private static int restTime = 5000; + + private static void resetTestEnvirment(List> referenceList) { + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + + private static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + throw new RuntimeException("Thread interrupted during trySleep", e); + } + } + + private static boolean tryRest() { + if (rest) { + trySleep(restTime); + return true; + } + return false; + } + + private static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + + private static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + throw new RuntimeException("Thread interrupted while joining", e); + } + } + } + + public static void wrapper() { + resetTestEnvirment(allThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + int slot = 0; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + slot = i % MAX_SLOT_NUM; + Runnable remain = new MemAlloc(ALLOC_2K, slot, allThreadReference, i, MemAlloc.SAVE_HALF_RAMDOM, true, 1); + t = new Thread(new MemAlloc(ALLOC_4K, slot, allThreadReference, i, MemAlloc.SAVE_HALF, false, + 1, DEFAULT_REPEAT_TIMES, remain), "testCase3_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(allThreadReference); + } + + public static void main(String[] args) { + wrapper(); + Runtime.getRuntime().gc(); + wrapper(); + System.out.println("ExpectResult"); + } + + public static class AllocUnit { + public byte[] unit; + + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + + public abstract static class MemAllocMethod { + protected long mAllocSize; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + + public abstract List alloc(boolean isStress); + } + + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + + public static class AllocUnitWithSoftReference extends AllocUnit { + private Reference refArray; + + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + + public static class AllocUnitwithCleaner extends AllocUnit { + private final Cleaner cleaner; + + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + private Reference refArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); +// public static ArrayList refAndWeakRefAndCleanerFActiveObjList +// = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + static class MemAlloc implements Runnable { + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + private int mRepeatTimes = 1; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, + int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, + Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, + boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, + MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, + callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, + boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, + callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, + boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, + boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, + int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, + callBackAfterFree, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, + int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, + int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + + return new AllocUnit(alloc_size); + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!running) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + continue; + } + + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0318-rc-Memory-normalTestCase4/Memory_normalTestCase4.java b/test/testsuite/ouroboros/rc_test/RC0318-rc-Memory-normalTestCase4/Memory_normalTestCase4.java new file mode 100755 index 0000000000000000000000000000000000000000..258fa103bf8c036c833e502f5d01959289dab3fe --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0318-rc-Memory-normalTestCase4/Memory_normalTestCase4.java @@ -0,0 +1,653 @@ +/* + *- @TestCaseID:rc/stress/Memory_normalTestCase4.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:默认启动80个线程,对62个runslot去申请释放它们所管理的区间大小的内存块,不会立刻释放。同时在起一个线程去申请同样大小的内存块去一半一半地释放。 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect: + *- @Priority: High + *- @Source: Memory_normalTestCase4.java + *- @ExecuteClass: Memory_normalTestCase4 + *- @ExecuteArgs: + *- @Remark: + * - @Author:从压力测试case中拆解 liuweiqing l00481345 + */ + + +import sun.misc.Cleaner; + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; + +public class Memory_normalTestCase4 { + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + private static final int DEFAULT_REPEAT_TIMES = 1; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + + static List> mAllThreadReference = new ArrayList>(); + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + + private static void resetTestEnvirment(List> referenceList) { + + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + + public static void testCase4() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + int slot = 0; + for (int i = 0; i < MAX_SLOT_NUM; i++) { + slot = i % MAX_SLOT_NUM; + Runnable remain = new MemAlloc(ALLOC_2K, slot, mAllThreadReference, i, MemAlloc.SAVE_HALF_RAMDOM, true, 1); + t = new Thread(new MemAlloc(ALLOC_4K, slot, mAllThreadReference, i, MemAlloc.SAVE_HALF_RAMDOM, false, 1, DEFAULT_REPEAT_TIMES, remain), "testCase4_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(mAllThreadReference); + } + + public static void main(String[] args) { + testCase4(); + Runtime.getRuntime().gc(); + testCase4(); + System.out.println("ExpectResult"); + } + + + public static class AllocUnit { + public byte unit[]; + + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + + public abstract List alloc(boolean isStress); + } + + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + + public static class AllocUnitWithSoftReference extends AllocUnit { + + private Reference refArray; + + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private final Cleaner cleaner; + + private static class TestCleaner implements Runnable { + public byte unit[]; + + public TestCleaner(byte unit[]) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + + private Reference refArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + + return new AllocUnit(alloc_size); + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0319-rc-Memory-normalTestCase5/Memory_normalTestCase5.java b/test/testsuite/ouroboros/rc_test/RC0319-rc-Memory-normalTestCase5/Memory_normalTestCase5.java new file mode 100755 index 0000000000000000000000000000000000000000..f7ca29b18394c57d2066edbc511dbdffb836dc84 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0319-rc-Memory-normalTestCase5/Memory_normalTestCase5.java @@ -0,0 +1,644 @@ +/* + *- @TestCaseID:rc/stress/Memory_normalTestCase5.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect: + *- @Priority: High + *- @Source: Memory_normalTestCase5.java + *- @ExecuteClass: Memory_normalTestCase5 + *- @ExecuteArgs: + *- @Remark: + *- @Author:从压力测试case中拆解 liuweiqing l00481345 + */ + + +import sun.misc.Cleaner; + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; + +public class Memory_normalTestCase5 { + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + + static List> mAllThreadReference = new ArrayList>(); + + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + + private static void resetTestEnvirment(List> referenceList) { + + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if(s ==null) + return; + if(s.isAlive()){ + synchronized (list){ + list.remove(s); + } + } + } + } + } + + public static void testCase5() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + int average = ALLOC_4K / DEFAULT_THREAD_NUM; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + int slot = i % MAX_SLOT_NUM; + t = new Thread(new MemAlloc(ALLOC_4K + Math.max(getSlotSize(slot), average), slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, false, 1), "testCase5_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(mAllThreadReference); + } + public static void main(String[] args){ + testCase5(); + Runtime.getRuntime().gc(); + testCase5(); + System.out.println("ExpectResult"); + } + + + + + + public static class AllocUnit { + public byte unit[]; + + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + + public abstract List alloc(boolean isStress); + } + + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + + public static class AllocUnitWithSoftReference extends AllocUnit{ + + private Reference refArray; + + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + + public static class AllocUnitwithCleaner extends AllocUnit{ + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this,new TestCleaner(new byte[arrayLength])); + } + private final Cleaner cleaner; + private static class TestCleaner implements Runnable{ + public byte unit[]; + public TestCleaner(byte unit[]){ + this.unit = unit; + } + public void run(){ + this.unit = null; + } + } + } + + + public static class AllocUnitWithWeakRefrence extends AllocUnit{ + public WeakReference weakIntArray; + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithRefAndCleanerF extends AllocUnit{ + + private Reference refArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this,new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable{ + public byte[] unit; + public TestCleaner(byte[] unit){ + this.unit = unit; + } + + public void run(){ + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit{ + + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this,new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable{ + public byte[] unit; + public TestCleaner(byte[] unit){ + this.unit = unit; + } + + public void run(){ + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class ReAlive{ + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit{ + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this,new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable{ + public byte[] unit; + public TestCleaner(byte[] unit){ + this.unit = unit; + } + + public void run(){ + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM){ + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit{ + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this,new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable{ + public byte[] unit; + public TestCleaner(byte[] unit){ + this.unit = unit; + } + + public void run(){ + this.unit = null; + } + } + } + + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx+1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER){ + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if(curNum < 3){ + return new AllocUnitwithCleaner(alloc_size); + } + if(curNum < 4){ + return new AllocUnitWithWeakRefrence(alloc_size); + } + if(curNum < 5){ + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if(curNum < 6){ + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if(curNum < 7){ + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if(curNum < 8){ + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if(curNum < 2){ + return new AllocUnitWithWeakRefrence(alloc_size); + } + if(curNum < 3){ + return new AllocUnitWithSoftReference(alloc_size); + } + } + + return new AllocUnit(alloc_size); + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if(ret != null){ + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0320-rc-Memory-normalTestCase6/Memory_normalTestCase6.java b/test/testsuite/ouroboros/rc_test/RC0320-rc-Memory-normalTestCase6/Memory_normalTestCase6.java new file mode 100755 index 0000000000000000000000000000000000000000..90c0ffc3314be485228f4f8a5a1357e1aac77558 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0320-rc-Memory-normalTestCase6/Memory_normalTestCase6.java @@ -0,0 +1,662 @@ +/* + *- @TestCaseID:rc/stress/Memory_normalTestCase6.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect: + *- @Priority: High + *- @Source: Memory_normalTestCase6.java + *- @ExecuteClass: Memory_normalTestCase6 + *- @ExecuteArgs: + *- @Remark: + *- @Author:从压力测试case中拆解 liuweiqing l00481345 + */ + + +import sun.misc.Cleaner; + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; + +public class Memory_normalTestCase6 { + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + + static List> mAllThreadReference = new ArrayList>(); + + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + + private static void resetTestEnvirment(List> referenceList) { + + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + + public static void testCase6() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + t = new Thread(new MemAlloc(ALLOC_4K, (int) (Math.random() * MAX_SLOT_NUM), mAllThreadReference, 0, 1, false, 1, DEFAULT_THREAD_NUM), "testCase6_" + (1)); + list.add(t); + startAllThread(list); + waitAllThreadFinish(list); + list.clear(); + for (int i = 1; i < DEFAULT_THREAD_NUM + 1; i++) { + int slot = i % MAX_SLOT_NUM; + t = new Thread(new MemAlloc(ALLOC_8K - getSlotSize(slot), slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, false, 1), "testCase6_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(mAllThreadReference); + } + + public static void main(String[] args) { + testCase6(); + Runtime.getRuntime().gc(); + testCase6(); + System.out.println("ExpectResult"); + } + + + public static class AllocUnit { + public byte unit[]; + + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + + public abstract List alloc(boolean isStress); + } + + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + + public static class AllocUnitWithSoftReference extends AllocUnit { + + private Reference refArray; + + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private final Cleaner cleaner; + + private static class TestCleaner implements Runnable { + public byte unit[]; + + public TestCleaner(byte unit[]) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + + private Reference refArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + + return new AllocUnit(alloc_size); + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0321-rc-Memory-normalTestCase6_1/Memory_normalTestCase6_1.java b/test/testsuite/ouroboros/rc_test/RC0321-rc-Memory-normalTestCase6_1/Memory_normalTestCase6_1.java new file mode 100755 index 0000000000000000000000000000000000000000..4eb047478de329d1fa65205215f45f2fcc0be9a4 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0321-rc-Memory-normalTestCase6_1/Memory_normalTestCase6_1.java @@ -0,0 +1,661 @@ +/* + *- @TestCaseID:rc/stress/Memory_normalTestCase6_1.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect: + *- @Priority: High + *- @Source: Memory_normalTestCase6_1.java + *- @ExecuteClass: Memory_normalTestCase6_1 + *- @ExecuteArgs: + *- @Remark: + *- @Author:从压力测试case中拆解 liuweiqing l00481345 + */ + +import sun.misc.Cleaner; + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; + +public class Memory_normalTestCase6_1 { + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + + static List> mAllThreadReference = new ArrayList>(); + + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + + private static void resetTestEnvirment(List> referenceList) { + + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + + public static void testCase6_1() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + t = new Thread(new MemAlloc(ALLOC_4K, (int) (Math.random() * MAX_SLOT_NUM), mAllThreadReference, 0, 1, false, 1, DEFAULT_THREAD_NUM), "testCase6_1_" + (1)); + list.add(t); + startAllThread(list); + waitAllThreadFinish(list); + list.clear(); + for (int i = 1; i < DEFAULT_THREAD_NUM + 1; i++) { + int slot = i % MAX_SLOT_NUM; + t = new Thread(new MemAlloc(ALLOC_8K, slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, false, 1), "testCase6_1_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(mAllThreadReference); + } + + public static void main(String[] args) { + testCase6_1(); + Runtime.getRuntime().gc(); + testCase6_1(); + System.out.println("ExpectResult"); + } + + + public static class AllocUnit { + public byte unit[]; + + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + + public abstract List alloc(boolean isStress); + } + + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + + public static class AllocUnitWithSoftReference extends AllocUnit { + + private Reference refArray; + + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private final Cleaner cleaner; + + private static class TestCleaner implements Runnable { + public byte unit[]; + + public TestCleaner(byte unit[]) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + + private Reference refArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + + return new AllocUnit(alloc_size); + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0322-rc-Memory-normalTestCase7/Memory_normalTestCase7.java b/test/testsuite/ouroboros/rc_test/RC0322-rc-Memory-normalTestCase7/Memory_normalTestCase7.java new file mode 100755 index 0000000000000000000000000000000000000000..ba53c6d4c91d793dff0dddad1be862a659f656e1 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0322-rc-Memory-normalTestCase7/Memory_normalTestCase7.java @@ -0,0 +1,657 @@ +/* + *- @TestCaseID:rc/stress/Memory_normalTestCase7.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect: + *- @Priority: High + *- @Source: Memory_normalTestCase7.java + *- @ExecuteClass: Memory_normalTestCase7 + *- @ExecuteArgs: + *- @Remark: + *- @Author:从压力测试case中拆解 liuweiqing l00481345 + */ + +import sun.misc.Cleaner; + +//import java.lang.ref.Cleaner; +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; + +public class Memory_normalTestCase7 { + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + + static List> mAllThreadReference = new ArrayList>(); + + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + + private static void resetTestEnvirment(List> referenceList) { + + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + + public static void testCase7() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + int slot = i % MAX_SLOT_NUM; + t = new Thread(new MemAlloc(ALLOC_8K + getSlotSize(slot), slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, false, 1), "testCase7_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(mAllThreadReference); + } + + public static void main(String[] args) { + testCase7(); + Runtime.getRuntime().gc(); + testCase7(); + System.out.println("ExpectResult"); + } + + + public static class AllocUnit { + public byte unit[]; + + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + + public abstract List alloc(boolean isStress); + } + + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + + public static class AllocUnitWithSoftReference extends AllocUnit { + + private Reference refArray; + + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private final Cleaner cleaner; + + private static class TestCleaner implements Runnable { + public byte unit[]; + + public TestCleaner(byte unit[]) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + + private Reference refArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + + return new AllocUnit(alloc_size); + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0323-rc-Memory-normalTestCase8/Memory_normalTestCase8.java b/test/testsuite/ouroboros/rc_test/RC0323-rc-Memory-normalTestCase8/Memory_normalTestCase8.java new file mode 100755 index 0000000000000000000000000000000000000000..f7643202edd6fc0fe363064cf701676154f47e40 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0323-rc-Memory-normalTestCase8/Memory_normalTestCase8.java @@ -0,0 +1,653 @@ +/* + *- @TestCaseID:rc/stress/Memory_normalTestCase8.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect: + *- @Priority: High + *- @Source: Memory_normalTestCase8.java + *- @ExecuteClass: Memory_normalTestCase8 + *- @ExecuteArgs: + *- @Remark: + *- @Author:从压力测试case中拆解 liuweiqing l00481345 + */ + + +import sun.misc.Cleaner; + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; + +public class Memory_normalTestCase8 { + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + + static List> mAllThreadReference = new ArrayList>(); + + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + + private static void resetTestEnvirment(List> referenceList) { + + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + + public static void testCase8() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + int slot = i % MAX_SLOT_NUM; + t = new Thread(new MemAlloc(ALLOC_8K + ALLOC_4K, slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, false, 1), "testCase8_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(mAllThreadReference); + } + + public static void main(String[] args) { + testCase8(); + Runtime.getRuntime().gc(); + testCase8(); + System.out.println("ExpectResult"); + } + + + public static class AllocUnit { + public byte unit[]; + + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + + public abstract List alloc(boolean isStress); + } + + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + + public static class AllocUnitWithSoftReference extends AllocUnit { + + private Reference refArray; + + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private final Cleaner cleaner; + + private static class TestCleaner implements Runnable { + public byte unit[]; + + public TestCleaner(byte unit[]) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + + private Reference refArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + } + + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + + return new AllocUnit(alloc_size); + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0324-rc-Memory-normalTestCase9/Memory_normalTestCase9.java b/test/testsuite/ouroboros/rc_test/RC0324-rc-Memory-normalTestCase9/Memory_normalTestCase9.java new file mode 100755 index 0000000000000000000000000000000000000000..9f4340e0ac903722c2ca3a3550b798c91af803ca --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0324-rc-Memory-normalTestCase9/Memory_normalTestCase9.java @@ -0,0 +1,626 @@ +/* + * -@TestCaseID:rc/stress/Memory_normalTestCase9.java + * -@TestCaseName:MyselfClassName + * -@RequirementID:SR-10620538 + * -@RequirementName:[运行时需求]支持自动内存管理 + * -@Title/Destination: + * -@Condition: no + * -#c1 + * -@Brief:functionTest + * -#step1 + * -@Expect: + * -@Priority: High + * -@Source: Memory_normalTestCase9.java + * -@ExecuteClass: Memory_normalTestCase9 + * -@ExecuteArgs: + * -@Remark: + * -@Author:从压力测试case中拆解 liuweiqing l00481345 + */ + +import sun.misc.Cleaner; + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.*; + +public class Memory_normalTestCase9 { + static final int MAX_SLOT_NUM = 62; + private static final int MAX_REALIVE_OBJ_NUM = 1000; + private static final int DEFAULT_THREAD_NUM = 80; + private static final int ALLOC_12K = 12 * 1024; + static boolean running = true; + static List> allThreadReference = new ArrayList>(); + private static boolean rest = false; + private static int restTime = 5000; + + private static void resetTestEnvirment(List> referenceList) { + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + + private static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + throw new RuntimeException("Thread interrupted during trySleep", e); + } + } + + private static boolean tryRest() { + if (rest) { + trySleep(restTime); + return true; + } + return false; + } + + private static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + + private static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + throw new RuntimeException("Thread interrupted while joining", e); + } + } + } + + private static void testCase9() { + resetTestEnvirment(allThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + int slot = i % MAX_SLOT_NUM; + t = new Thread(new MemAlloc(ALLOC_12K, slot, allThreadReference, i, MemAlloc.SAVE_ALL, + false, 1), "testCase9_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(allThreadReference); + } + + public static void main(String[] args) { + testCase9(); + Runtime.getRuntime().gc(); + testCase9(); + System.out.println("ExpectResult"); + } + + public static class AllocUnit { + public byte[] unit; + + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + + public abstract List alloc(boolean isStress); + } + + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + + public static class AllocUnitWithSoftReference extends AllocUnit { + private Reference refArray; + + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + + public static class AllocUnitwithCleaner extends AllocUnit { + private final Cleaner cleaner; + + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + private Reference refArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + static class MemAlloc implements Runnable { + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + private int mRepeatTimes = 1; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, + int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, + Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, + boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, + MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, + callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, + boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, + callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, + boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, + boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, + int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, + repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, + int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, + repeatTimes, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, + int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + + return new AllocUnit(alloc_size); + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!running) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + continue; + } + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0325-rc-Memory-normalTestCase10/Memory_normalTestCase10.java b/test/testsuite/ouroboros/rc_test/RC0325-rc-Memory-normalTestCase10/Memory_normalTestCase10.java new file mode 100755 index 0000000000000000000000000000000000000000..620b75d9df435e85e07b52e1c53ddf105bcacb6a --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0325-rc-Memory-normalTestCase10/Memory_normalTestCase10.java @@ -0,0 +1,652 @@ +/* + *- @TestCaseID:rc/stress/Memory_normalTestCase10.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect: + *- @Priority: High + *- @Source: Memory_normalTestCase10.java + *- @ExecuteClass: Memory_normalTestCase10 + *- @ExecuteArgs: + *- @Remark: + *- @Author:从压力测试case中拆解 liuweiqing l00481345 + */ + +import sun.misc.Cleaner; + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; + +public class Memory_normalTestCase10 { + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + + static List> mAllThreadReference = new ArrayList>(); + + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + + private static void resetTestEnvirment(List> referenceList) { + + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + + public static void testCase10() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + int slot = i % MAX_SLOT_NUM; + t = new Thread(new MemAlloc(ALLOC_16K, slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, false, 1), "testCase10_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(mAllThreadReference); + } + + public static void main(String[] args) { + testCase10(); + Runtime.getRuntime().gc(); + testCase10(); + System.out.println("ExpectResult"); + + } + + + public static class AllocUnit { + public byte unit[]; + + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + + public abstract List alloc(boolean isStress); + } + + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + + public static class AllocUnitWithSoftReference extends AllocUnit { + + private Reference refArray; + + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private final Cleaner cleaner; + + private static class TestCleaner implements Runnable { + public byte unit[]; + + public TestCleaner(byte unit[]) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + + private Reference refArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + + return new AllocUnit(alloc_size); + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0326-rc-Memory-normalTestCase11/Memory_normalTestCase11.java b/test/testsuite/ouroboros/rc_test/RC0326-rc-Memory-normalTestCase11/Memory_normalTestCase11.java new file mode 100755 index 0000000000000000000000000000000000000000..377e253c8b8ec58a0dc54feb186dcf422daa5519 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0326-rc-Memory-normalTestCase11/Memory_normalTestCase11.java @@ -0,0 +1,688 @@ +/* + * -@TestCaseID:rc/stress/Memory_normalTestCase11.java + * -@TestCaseName:MyselfClassName + * -@RequirementID:SR-10620538 + * -@RequirementName:[运行时需求]支持自动内存管理 + * -@Title/Destination: + * -@Condition: no + * -#c1 + * -@Brief:functionTest + * -#step1 + * -@Expect: + * -@Priority: High + * -@Source: Memory_normalTestCase11.java + * -@ExecuteClass: Memory_normalTestCase11 + * -@ExecuteArgs: + * -@Remark: + * -@Author:从压力测试case中拆解 liuweiqing l00481345 + */ + +import sun.misc.Cleaner; + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; + +public class Memory_normalTestCase11 { + private static final int DEFAULT_THREAD_NUM = 80; + private static final int MAX_SLOT_NUM = 62; + private static boolean rest = false; + private static int restTime = 5000; + private static boolean running = true; + private static final int ALLOC_4K = 4 * 1024; + private static final int MAX_REALIVE_OBJ_NUM = 1000; + private static List> allThreadReference = new ArrayList>(); + + private static void resetTestEnvirment(List> referenceList) { + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + + private static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + throw new RuntimeException("Thread interrupted during trySleep", e); + } + } + + private static boolean tryRest() { + if (rest) { + trySleep(restTime); + return true; + } + return false; + } + + private static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + + private static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + throw new RuntimeException("Thread interrupted while joining", e); + } + } + } + + private static void testCase11() { + resetTestEnvirment(allThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + int slot = i % MAX_SLOT_NUM; + t = new Thread(new MemAlloc(ALLOC_4K, slot, allThreadReference, i, MemAlloc.SAVE_ALL, + false, 1), "testCase11_alloc_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + + list.clear(); + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + t = new Thread(new FreeReference(allThreadReference, i, false), "testCase11_free_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(allThreadReference); + } + + public static void main(String[] args) { + testCase11(); + Runtime.getRuntime().gc(); + testCase11(); + System.out.println("ExpectResult"); + } + + static class FreeReference implements Runnable { + private List> mAllReference = null; + private int mThreadIdx = 0; + private boolean mLoop = false; + private boolean mSync = false; + + public FreeReference(List> reference, int threadIdx, boolean loop, boolean sync) { + mAllReference = reference; + mThreadIdx = threadIdx; + mLoop = loop; + mSync = sync; + } + + public FreeReference(List> reference, int threadIdx, boolean loop) { + this(reference, threadIdx, loop, false); + } + + private void release() { + if (mSync) { + synchronized (mAllReference) { + releaseOperate(); + } + } else { + releaseOperate(); + } + } + + private void releaseOperate() { + if (mAllReference == null) { + return; + } + if (mThreadIdx >= mAllReference.size()) { + return; + } + List cur = mAllReference.get(mThreadIdx); + mAllReference.set(mThreadIdx, null); + if (cur != null) { + cur.clear(); + } + } + + @Override + public void run() { + if (!mLoop) { + release(); + return; + } + while (mLoop) { + if (!running) { + break; + } + release(); + trySleep(1); + } + } + } + + public static class AllocUnit { + public byte []unit; + + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + + public abstract static class MemAllocMethod { + public abstract List alloc(boolean isStress); + } + + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + + public static class AllocUnitWithSoftReference extends AllocUnit { + private Reference refArray; + + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private final Cleaner cleaner; + + private static class TestCleaner implements Runnable { + public byte []unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + private Reference refArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + private TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + static class MemAlloc implements Runnable { + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + public static final int PAGE_SIZE = 4016; + public static final int PAGE_HEADSIZE = 80; + public static final int OBJ_MAX_SIZE = 1008; + public static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + private int mRepeatTimes = 1; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, + int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, + Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, + boolean freeImmediately, int sleepTime, int repeatTimes, + Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, + callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, + boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, + callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, + boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, + boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, + int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes,Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, + callBackAfterFree, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, + int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, + repeatTimes, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, + int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + return new AllocUnit(alloc_size); + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!running) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + continue; + } + + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0327-rc-Memory-normalTestCase12/Memory_normalTestCase12.java b/test/testsuite/ouroboros/rc_test/RC0327-rc-Memory-normalTestCase12/Memory_normalTestCase12.java new file mode 100755 index 0000000000000000000000000000000000000000..74951f467786b0aae05e3e93255970ce667aa5d1 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0327-rc-Memory-normalTestCase12/Memory_normalTestCase12.java @@ -0,0 +1,728 @@ +/* + *- @TestCaseID:rc/stress/Memory_normalTestCase12.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect: + *- @Priority: High + *- @Source: Memory_normalTestCase12.java + *- @ExecuteClass: Memory_normalTestCase12 + *- @ExecuteArgs: + *- @Remark: + *- @Author:从压力测试case中拆解 liuweiqing l00481345 + */ + + +import sun.misc.Cleaner; + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; + +public class Memory_normalTestCase12 { + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + + static List> mAllThreadReference = new ArrayList>(); + + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + + private static void resetTestEnvirment(List> referenceList) { + + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + + public static void testCase11() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + int slot = i % MAX_SLOT_NUM; + t = new Thread(new MemAlloc(ALLOC_4K, slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, false, 1), "testCase11_alloc_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + + list.clear(); + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + t = new Thread(new FreeReference(mAllThreadReference, i, false), "testCase11_free_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(mAllThreadReference); + } + + public static void testCase12() { + for (int i = 0; i < 3; i++) { + testCase11(); + } + } + + public static void main(String[] args) { + testCase12(); + Runtime.getRuntime().gc(); + testCase12(); + System.out.println("ExpectResult"); + } + + static class FreeReference implements Runnable { + private List> mAllReference = null; + private int mThreadIdx = 0; + private boolean mLoop = false; + private boolean mSync = false; + + public FreeReference(List> reference, int threadIdx, boolean loop, boolean sync) { + mAllReference = reference; + mThreadIdx = threadIdx; + mLoop = loop; + mSync = sync; + } + + public FreeReference(List> reference, int threadIdx, boolean loop) { + this(reference, threadIdx, loop, false); + } + + private void release() { + if (mSync) { + synchronized (mAllReference) { + releaseOperate(); + } + } else { + releaseOperate(); + } + } + + private void releaseOperate() { + if (mAllReference == null) { + return; + } + if (mThreadIdx >= mAllReference.size()) { + return; + } + List cur = mAllReference.get(mThreadIdx); + mAllReference.set(mThreadIdx, null); + if (cur != null) { + cur.clear(); + } + } + + @Override + public void run() { + if (!mLoop) { + release(); + return; + } + while (mLoop) { + if (!mRunning) { + break; + } + release(); + trySleep(1); + } + } + } + + + public static class AllocUnit { + public byte unit[]; + + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + + public abstract List alloc(boolean isStress); + } + + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + + public static class AllocUnitWithSoftReference extends AllocUnit { + + private Reference refArray; + + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private final Cleaner cleaner; + + private static class TestCleaner implements Runnable { + public byte unit[]; + + public TestCleaner(byte unit[]) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + + private Reference refArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + + return new AllocUnit(alloc_size); + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0330-rc-Memory-normalTestCase15/Memory_normalTestCase15.java b/test/testsuite/ouroboros/rc_test/RC0330-rc-Memory-normalTestCase15/Memory_normalTestCase15.java new file mode 100755 index 0000000000000000000000000000000000000000..1089d514b4e7660820f4f7fb3ec0138873985dc7 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0330-rc-Memory-normalTestCase15/Memory_normalTestCase15.java @@ -0,0 +1,1016 @@ +/* + *- @TestCaseID:rc/stress/Memory_normalTestCase15.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect: + *- @Priority: High + *- @Source: Memory_normalTestCase15.java + *- @ExecuteClass: Memory_normalTestCase15 + *- @ExecuteArgs: + *- @Remark: + *- @Author:从压力测试case中拆解 liuweiqing l00481345 + */ + +import sun.misc.Cleaner; + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.Set; + +public class Memory_normalTestCase15 { + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + static final int LOCAL_MAX_IDX = 15; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int GLOBAL_MIN_IDX = 16; + static final int LARGE_PAGE_SIZE = 4096; + static final int LARGEOBJ_CHOSEN_NUM = 2; + static final int LARGEOBJ_ALLOC_SIZE = 128 * LARGE_PAGE_SIZE; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + + static List> mAllThreadReference = new ArrayList>(); + + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + + private static void resetTestEnvirment(List> referenceList) { + + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + + public static void testCase15() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + int slot = i % MAX_SLOT_NUM; + RandomAllocMethod allocMethod = new RandomAllocMethod(ALLOC_8K * 11, ENUM_RANGE.ENUM_RANGE_BOTH, 11, 0, Math.random() > 0.5d); + t = new Thread(new MemAlloc(ALLOC_8K * 11, slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, false, 1, DEFAULT_REPEAT_TIMES, null, allocMethod), "testCase15_alloc_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + + list.clear(); + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + t = new Thread(new FreeReference(mAllThreadReference, i, false), "testCase15_free_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(mAllThreadReference); + } + + public static void main(String[] args) { + testCase15(); + Runtime.getRuntime().gc(); + testCase15(); + System.out.println("ExpectResult"); + } + + public static int makesureprop(int prop) { + if (prop > 100 || prop <= 0) { + prop = 100; + } + return prop; + } + + public static ArrayList choose_idx(int min, int max, int chosen, boolean random) { + if (min > max) { + return null; + } + ArrayList ret = new ArrayList(); + if (!random) { + int grow = (max - min + chosen) / chosen; + for (int i = min; i < max; i = i + grow) { + Integer a = Integer.valueOf(i); + ret.add(a); + } + } else { + Random rand = new Random(); + for (int i = 0; i < chosen; i++) { + int randNumber = rand.nextInt(max - min) + min; + Integer rdn = Integer.valueOf(randNumber); + ret.add(rdn); + } + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + + public static ArrayList alloc_choose_prop(ArrayList purpose, ArrayList other, int prop, long size, int diff, boolean isStress) { + prop = makesureprop(prop); + ArrayList array = new ArrayList(); + long size_alloc = 0; + int n_p = prop / 10, n_o = (100 - prop) / 10; + boolean no_alloc = true; + + while (size_alloc < size) { + for (int i = 0; i < n_p; i++) { + Iterator it1 = purpose.iterator(); + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + + for (int i = 0; i < n_o; i++) { + Iterator it2 = other.iterator(); + while (it2.hasNext()) { + int a = (it2.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + if (no_alloc) + return array; + } + return array; + } + + public static ArrayList alloc_choose_idx(long size, ENUM_RANGE range, int chosen, int prop, boolean random, boolean isStress) { + ArrayList purpose = new ArrayList(); + ArrayList other = new ArrayList(); + ArrayList largeobj_list = new ArrayList(); + ArrayList array = new ArrayList(); + boolean has_small = false, has_large = false; + + if (!random) { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_small = true; + has_large = true; + break; + default: + break; + } + } else { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + Random rand = new Random(); + int largenum = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum; i++) { + int randNumber = rand.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + Random rand2 = new Random(); + int largenum2 = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum2; i++) { + int randNumber = rand2.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + has_small = true; + break; + default: + + } + } + if (has_small) { + array.addAll(alloc_choose_prop(purpose, other, prop, size, 0, isStress)); + } + if (has_large) { + array.addAll(alloc_list_large(LARGEOBJ_ALLOC_SIZE, largeobj_list, 50, isStress)); + } + return array; + } + + public static ArrayList alloc_list_large(long bytesize, ArrayList alloc_list, int prop, boolean isStress) { + ArrayList array = new ArrayList(); + long size_allocated = 0; + prop = makesureprop(prop); + int n_p = prop / 10, n_o = (100 - prop) / 10; + + while (size_allocated < bytesize) { + Iterator it1 = alloc_list.iterator(); + boolean first = true; + int loopn = n_p; + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + if (first) { + loopn = n_p; + first = false; + } else { + loopn = n_o; + first = true; + } + for (int i = 0; i < loopn; i++) { + size_allocated = size_allocated + a; + ArrayList temp_array = alloc_byte_large(a, a, 0, isStress); + array.addAll(temp_array); + if (size_allocated > bytesize) { + return array; + } + } + } + } + return array; + } + + public static ArrayList alloc_byte_large(long bytesize, int alloc_size, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + + if (alloc_size <= OBJ_MAX_SIZE) { + return null; + } + long size = 0; + if ((bytesize + diff * alloc_size) <= 0) { + return null; + } + bytesize = bytesize + diff * alloc_size; + while (size < bytesize) { + size = size + alloc_size; + array.add(MemAlloc.AllocOneUnit(alloc_size, isStress)); + } + return array; + } + + public static class RandomAllocMethod extends MemAllocMethod { + public RandomAllocMethod(long size, ENUM_RANGE range, int chosen, int prop, boolean random) { + mAllocSize = size; + mRange = range; + mChosen = chosen; + mProp = prop; + mRandorm = random; + } + + @Override + public List alloc(boolean isStress) { + List ret = alloc_choose_idx(mAllocSize, mRange, mChosen, mProp, mRandorm, isStress); + return ret; + } + } + + static class FreeReference implements Runnable { + private List> mAllReference = null; + private int mThreadIdx = 0; + private boolean mLoop = false; + private boolean mSync = false; + + public FreeReference(List> reference, int threadIdx, boolean loop, boolean sync) { + mAllReference = reference; + mThreadIdx = threadIdx; + mLoop = loop; + mSync = sync; + } + + public FreeReference(List> reference, int threadIdx, boolean loop) { + this(reference, threadIdx, loop, false); + } + + private void release() { + if (mSync) { + synchronized (mAllReference) { + releaseOperate(); + } + } else { + releaseOperate(); + } + } + + private void releaseOperate() { + if (mAllReference == null) { + return; + } + if (mThreadIdx >= mAllReference.size()) { + return; + } + List cur = mAllReference.get(mThreadIdx); + mAllReference.set(mThreadIdx, null); + if (cur != null) { + cur.clear(); + } + } + + @Override + public void run() { + if (!mLoop) { + release(); + return; + } + while (mLoop) { + if (!mRunning) { + break; + } + release(); + trySleep(1); + } + } + } + + + public static class AllocUnit { + public byte unit[]; + + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + + public abstract List alloc(boolean isStress); + } + + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + + public static class AllocUnitWithSoftReference extends AllocUnit { + + private Reference refArray; + + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private final Cleaner cleaner; + + private static class TestCleaner implements Runnable { + public byte unit[]; + + public TestCleaner(byte unit[]) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + + private Reference refArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + } + + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + + return new AllocUnit(alloc_size); + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0331-rc-Memory-normalTestCase16/Memory_normalTestCase16.java b/test/testsuite/ouroboros/rc_test/RC0331-rc-Memory-normalTestCase16/Memory_normalTestCase16.java new file mode 100755 index 0000000000000000000000000000000000000000..0eb8b2eda52e4fae60eb26dbef64e9ce57220039 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0331-rc-Memory-normalTestCase16/Memory_normalTestCase16.java @@ -0,0 +1,1015 @@ +/* + *- @TestCaseID:rc/stress/Memory_normalTestCase16.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect: + *- @Priority: High + *- @Source: Memory_normalTestCase16.java + *- @ExecuteClass: Memory_normalTestCase16 + *- @ExecuteArgs: + *- @Remark: + *- @Author:从压力测试case中拆解 liuweiqing l00481345 + */ + +import sun.misc.Cleaner; + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.Set; + +public class Memory_normalTestCase16 { + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + static final int LOCAL_MAX_IDX = 15; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int GLOBAL_MIN_IDX = 16; + static final int LARGE_PAGE_SIZE = 4096; + static final int LARGEOBJ_CHOSEN_NUM = 2; + static final int LARGEOBJ_ALLOC_SIZE = 128 * LARGE_PAGE_SIZE; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + + static List> mAllThreadReference = new ArrayList>(); + + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + + private static void resetTestEnvirment(List> referenceList) { + + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + + public static void testCase16() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + int slot = i % MAX_SLOT_NUM; + RandomAllocMethod allocMethod = new RandomAllocMethod(ALLOC_8K * 11, ENUM_RANGE.ENUM_RANGE_BOTH, 11, 80, Math.random() > 0.5d); + t = new Thread(new MemAlloc(ALLOC_8K * 11, slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, false, 1, DEFAULT_REPEAT_TIMES, null, allocMethod), "testCase16_alloc_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + + list.clear(); + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + t = new Thread(new FreeReference(mAllThreadReference, i, false), "testCase16_free_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(mAllThreadReference); + } + + public static void main(String[] args) { + testCase16(); + Runtime.getRuntime().gc(); + testCase16(); + System.out.println("ExpectResult"); + } + + public static int makesureprop(int prop) { + if (prop > 100 || prop <= 0) { + prop = 100; + } + return prop; + } + + public static ArrayList choose_idx(int min, int max, int chosen, boolean random) { + if (min > max) { + return null; + } + ArrayList ret = new ArrayList(); + if (!random) { + int grow = (max - min + chosen) / chosen; + for (int i = min; i < max; i = i + grow) { + Integer a = Integer.valueOf(i); + ret.add(a); + } + } else { + Random rand = new Random(); + for (int i = 0; i < chosen; i++) { + int randNumber = rand.nextInt(max - min) + min; + Integer rdn = Integer.valueOf(randNumber); + ret.add(rdn); + } + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + + public static ArrayList alloc_choose_prop(ArrayList purpose, ArrayList other, int prop, long size, int diff, boolean isStress) { + prop = makesureprop(prop); + ArrayList array = new ArrayList(); + long size_alloc = 0; + int n_p = prop / 10, n_o = (100 - prop) / 10; + boolean no_alloc = true; + + while (size_alloc < size) { + for (int i = 0; i < n_p; i++) { + Iterator it1 = purpose.iterator(); + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + + for (int i = 0; i < n_o; i++) { + Iterator it2 = other.iterator(); + while (it2.hasNext()) { + int a = (it2.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + if (no_alloc) + return array; + } + return array; + } + + public static ArrayList alloc_choose_idx(long size, ENUM_RANGE range, int chosen, int prop, boolean random, boolean isStress) { + ArrayList purpose = new ArrayList(); + ArrayList other = new ArrayList(); + ArrayList largeobj_list = new ArrayList(); + ArrayList array = new ArrayList(); + boolean has_small = false, has_large = false; + + if (!random) { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_small = true; + has_large = true; + break; + default: + break; + } + } else { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + Random rand = new Random(); + int largenum = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum; i++) { + int randNumber = rand.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + Random rand2 = new Random(); + int largenum2 = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum2; i++) { + int randNumber = rand2.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + has_small = true; + break; + default: + + } + } + if (has_small) { + array.addAll(alloc_choose_prop(purpose, other, prop, size, 0, isStress)); + } + if (has_large) { + array.addAll(alloc_list_large(LARGEOBJ_ALLOC_SIZE, largeobj_list, 50, isStress)); + } + return array; + } + + public static ArrayList alloc_list_large(long bytesize, ArrayList alloc_list, int prop, boolean isStress) { + ArrayList array = new ArrayList(); + long size_allocated = 0; + prop = makesureprop(prop); + int n_p = prop / 10, n_o = (100 - prop) / 10; + + while (size_allocated < bytesize) { + Iterator it1 = alloc_list.iterator(); + boolean first = true; + int loopn = n_p; + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + if (first) { + loopn = n_p; + first = false; + } else { + loopn = n_o; + first = true; + } + for (int i = 0; i < loopn; i++) { + size_allocated = size_allocated + a; + ArrayList temp_array = alloc_byte_large(a, a, 0, isStress); + array.addAll(temp_array); + if (size_allocated > bytesize) { + return array; + } + } + } + } + return array; + } + + public static ArrayList alloc_byte_large(long bytesize, int alloc_size, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + + if (alloc_size <= OBJ_MAX_SIZE) { + return null; + } + long size = 0; + if ((bytesize + diff * alloc_size) <= 0) { + return null; + } + bytesize = bytesize + diff * alloc_size; + while (size < bytesize) { + size = size + alloc_size; + array.add(MemAlloc.AllocOneUnit(alloc_size, isStress)); + } + return array; + } + + public static class RandomAllocMethod extends MemAllocMethod { + public RandomAllocMethod(long size, ENUM_RANGE range, int chosen, int prop, boolean random) { + mAllocSize = size; + mRange = range; + mChosen = chosen; + mProp = prop; + mRandorm = random; + } + + @Override + public List alloc(boolean isStress) { + List ret = alloc_choose_idx(mAllocSize, mRange, mChosen, mProp, mRandorm, isStress); + return ret; + } + } + + static class FreeReference implements Runnable { + private List> mAllReference = null; + private int mThreadIdx = 0; + private boolean mLoop = false; + private boolean mSync = false; + + public FreeReference(List> reference, int threadIdx, boolean loop, boolean sync) { + mAllReference = reference; + mThreadIdx = threadIdx; + mLoop = loop; + mSync = sync; + } + + public FreeReference(List> reference, int threadIdx, boolean loop) { + this(reference, threadIdx, loop, false); + } + + private void release() { + if (mSync) { + synchronized (mAllReference) { + releaseOperate(); + } + } else { + releaseOperate(); + } + } + + private void releaseOperate() { + if (mAllReference == null) { + return; + } + if (mThreadIdx >= mAllReference.size()) { + return; + } + List cur = mAllReference.get(mThreadIdx); + mAllReference.set(mThreadIdx, null); + if (cur != null) { + cur.clear(); + } + } + + @Override + public void run() { + if (!mLoop) { + release(); + return; + } + while (mLoop) { + if (!mRunning) { + break; + } + release(); + trySleep(1); + } + } + } + + + public static class AllocUnit { + public byte unit[]; + + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + + public abstract List alloc(boolean isStress); + } + + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + + public static class AllocUnitWithSoftReference extends AllocUnit { + + private Reference refArray; + + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private final Cleaner cleaner; + + private static class TestCleaner implements Runnable { + public byte unit[]; + + public TestCleaner(byte unit[]) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + + private Reference refArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + + return new AllocUnit(alloc_size); + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0332-rc-Memory-normalTestCase17/Memory_normalTestCase17.java b/test/testsuite/ouroboros/rc_test/RC0332-rc-Memory-normalTestCase17/Memory_normalTestCase17.java new file mode 100755 index 0000000000000000000000000000000000000000..9147167b8e539f4b26104967b91da21c3d0a21ae --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0332-rc-Memory-normalTestCase17/Memory_normalTestCase17.java @@ -0,0 +1,1005 @@ +/* + *- @TestCaseID:rc/stress/Memory_normalTestCase17.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect: + *- @Priority: High + *- @Source: Memory_normalTestCase17.java + *- @ExecuteClass: Memory_normalTestCase17 + *- @ExecuteArgs: + *- @Remark: + *- @Author:从压力测试case中拆解 liuweiqing l00481345 + */ + + +import sun.misc.Cleaner; + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.Set; + +public class Memory_normalTestCase17 { + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + static final int LOCAL_MAX_IDX = 15; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int GLOBAL_MIN_IDX = 16; + static final int LARGE_PAGE_SIZE = 4096; + static final int LARGEOBJ_CHOSEN_NUM = 2; + static final int LARGEOBJ_ALLOC_SIZE = 128 * LARGE_PAGE_SIZE; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + + static List> mAllThreadReference = new ArrayList>(); + + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + + private static void resetTestEnvirment(List> referenceList) { + + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + + public static void testCase17() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < 2 * DEFAULT_THREAD_NUM; i++) { + int slot = i % MAX_SLOT_NUM; + RandomAllocMethod allocMethod = new RandomAllocMethod(ALLOC_4K * 6, ENUM_RANGE.ENUM_RANGE_ALL, 6, 0, false); + t = new Thread(new MemAlloc(ALLOC_4K * 6, slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, false, 1, DEFAULT_REPEAT_TIMES, null, allocMethod), "testCase17_alloc_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + } + + public static void main(String[] args) { + testCase17(); + System.out.println("ExpectResult"); + } + + public static int makesureprop(int prop) { + if (prop > 100 || prop <= 0) { + prop = 100; + } + return prop; + } + + public static ArrayList choose_idx(int min, int max, int chosen, boolean random) { + if (min > max) { + return null; + } + ArrayList ret = new ArrayList(); + if (!random) { + int grow = (max - min + chosen) / chosen; + for (int i = min; i < max; i = i + grow) { + Integer a = Integer.valueOf(i); + ret.add(a); + } + } else { + Random rand = new Random(); + for (int i = 0; i < chosen; i++) { + int randNumber = rand.nextInt(max - min) + min; + Integer rdn = Integer.valueOf(randNumber); + ret.add(rdn); + } + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + + public static ArrayList alloc_choose_prop(ArrayList purpose, ArrayList other, int prop, long size, int diff, boolean isStress) { + prop = makesureprop(prop); + ArrayList array = new ArrayList(); + long size_alloc = 0; + int n_p = prop / 10, n_o = (100 - prop) / 10; + boolean no_alloc = true; + + while (size_alloc < size) { + for (int i = 0; i < n_p; i++) { + Iterator it1 = purpose.iterator(); + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + + for (int i = 0; i < n_o; i++) { + Iterator it2 = other.iterator(); + while (it2.hasNext()) { + int a = (it2.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + if (no_alloc) + return array; + } + return array; + } + + public static ArrayList alloc_choose_idx(long size, ENUM_RANGE range, int chosen, int prop, boolean random, boolean isStress) { + ArrayList purpose = new ArrayList(); + ArrayList other = new ArrayList(); + ArrayList largeobj_list = new ArrayList(); + ArrayList array = new ArrayList(); + boolean has_small = false, has_large = false; + + if (!random) { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_small = true; + has_large = true; + break; + default: + break; + } + } else { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + Random rand = new Random(); + int largenum = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum; i++) { + int randNumber = rand.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + Random rand2 = new Random(); + int largenum2 = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum2; i++) { + int randNumber = rand2.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + has_small = true; + break; + default: + + } + } + if (has_small) { + array.addAll(alloc_choose_prop(purpose, other, prop, size, 0, isStress)); + } + if (has_large) { + array.addAll(alloc_list_large(LARGEOBJ_ALLOC_SIZE, largeobj_list, 50, isStress)); + } + return array; + } + + public static ArrayList alloc_list_large(long bytesize, ArrayList alloc_list, int prop, boolean isStress) { + ArrayList array = new ArrayList(); + long size_allocated = 0; + prop = makesureprop(prop); + int n_p = prop / 10, n_o = (100 - prop) / 10; + + while (size_allocated < bytesize) { + Iterator it1 = alloc_list.iterator(); + boolean first = true; + int loopn = n_p; + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + if (first) { + loopn = n_p; + first = false; + } else { + loopn = n_o; + first = true; + } + for (int i = 0; i < loopn; i++) { + size_allocated = size_allocated + a; + ArrayList temp_array = alloc_byte_large(a, a, 0, isStress); + array.addAll(temp_array); + if (size_allocated > bytesize) { + return array; + } + } + } + } + return array; + } + + public static ArrayList alloc_byte_large(long bytesize, int alloc_size, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + + if (alloc_size <= OBJ_MAX_SIZE) { + return null; + } + long size = 0; + if ((bytesize + diff * alloc_size) <= 0) { + return null; + } + bytesize = bytesize + diff * alloc_size; + while (size < bytesize) { + size = size + alloc_size; + array.add(MemAlloc.AllocOneUnit(alloc_size, isStress)); + } + return array; + } + + public static class RandomAllocMethod extends MemAllocMethod { + public RandomAllocMethod(long size, ENUM_RANGE range, int chosen, int prop, boolean random) { + mAllocSize = size; + mRange = range; + mChosen = chosen; + mProp = prop; + mRandorm = random; + } + + @Override + public List alloc(boolean isStress) { + List ret = alloc_choose_idx(mAllocSize, mRange, mChosen, mProp, mRandorm, isStress); + return ret; + } + } + + static class FreeReference implements Runnable { + private List> mAllReference = null; + private int mThreadIdx = 0; + private boolean mLoop = false; + private boolean mSync = false; + + public FreeReference(List> reference, int threadIdx, boolean loop, boolean sync) { + mAllReference = reference; + mThreadIdx = threadIdx; + mLoop = loop; + mSync = sync; + } + + public FreeReference(List> reference, int threadIdx, boolean loop) { + this(reference, threadIdx, loop, false); + } + + private void release() { + if (mSync) { + synchronized (mAllReference) { + releaseOperate(); + } + } else { + releaseOperate(); + } + } + + private void releaseOperate() { + if (mAllReference == null) { + return; + } + if (mThreadIdx >= mAllReference.size()) { + return; + } + List cur = mAllReference.get(mThreadIdx); + mAllReference.set(mThreadIdx, null); + if (cur != null) { + cur.clear(); + } + } + + @Override + public void run() { + if (!mLoop) { + release(); + return; + } + while (mLoop) { + if (!mRunning) { + break; + } + release(); + trySleep(1); + } + } + } + + + public static class AllocUnit { + public byte unit[]; + + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + + public abstract List alloc(boolean isStress); + } + + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + + public static class AllocUnitWithSoftReference extends AllocUnit { + + private Reference refArray; + + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private final Cleaner cleaner; + + private static class TestCleaner implements Runnable { + public byte unit[]; + + public TestCleaner(byte unit[]) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + + private Reference refArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + + return new AllocUnit(alloc_size); + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0333-rc-Memory-normalTestCase18/Memory_normalTestCase18.java b/test/testsuite/ouroboros/rc_test/RC0333-rc-Memory-normalTestCase18/Memory_normalTestCase18.java new file mode 100755 index 0000000000000000000000000000000000000000..efa38967aef45f160d22726e7ba9c26d94c1086c --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0333-rc-Memory-normalTestCase18/Memory_normalTestCase18.java @@ -0,0 +1,1006 @@ +/* + *- @TestCaseID:rc/stress/Memory_normalTestCase18.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect: + *- @Priority: High + *- @Source: Memory_normalTestCase18.java + *- @ExecuteClass: Memory_normalTestCase18 + *- @ExecuteArgs: + *- @Remark: + *- @Author:从压力测试case中拆解 liuweiqing l00481345 + */ + +import sun.misc.Cleaner; + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.Set; + +public class Memory_normalTestCase18 { + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + static final int LOCAL_MAX_IDX = 15; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int GLOBAL_MIN_IDX = 16; + static final int LARGE_PAGE_SIZE = 4096; + static final int LARGEOBJ_CHOSEN_NUM = 2; + static final int LARGEOBJ_ALLOC_SIZE = 128 * LARGE_PAGE_SIZE; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + + static List> mAllThreadReference = new ArrayList>(); + + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + + private static void resetTestEnvirment(List> referenceList) { + + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + + public static void testCase18() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < 2 * DEFAULT_THREAD_NUM; i++) { + int slot = i % MAX_SLOT_NUM; + RandomAllocMethod allocMethod = new RandomAllocMethod(ALLOC_4K * 6, ENUM_RANGE.ENUM_RANGE_ALL, 6, 0, Math.random() > 0.5d); + t = new Thread(new MemAlloc(ALLOC_4K * 6, slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, true, 1, DEFAULT_REPEAT_TIMES, null, allocMethod), "testCase18_alloc_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + } + + public static void main(String[] args) { + testCase18(); + Runtime.getRuntime().gc(); + testCase18(); + System.out.println("ExpectResult"); + } + + public static int makesureprop(int prop) { + if (prop > 100 || prop <= 0) { + prop = 100; + } + return prop; + } + + public static ArrayList choose_idx(int min, int max, int chosen, boolean random) { + if (min > max) { + return null; + } + ArrayList ret = new ArrayList(); + if (!random) { + int grow = (max - min + chosen) / chosen; + for (int i = min; i < max; i = i + grow) { + Integer a = Integer.valueOf(i); + ret.add(a); + } + } else { + Random rand = new Random(); + for (int i = 0; i < chosen; i++) { + int randNumber = rand.nextInt(max - min) + min; + Integer rdn = Integer.valueOf(randNumber); + ret.add(rdn); + } + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + + public static ArrayList alloc_choose_prop(ArrayList purpose, ArrayList other, int prop, long size, int diff, boolean isStress) { + prop = makesureprop(prop); + ArrayList array = new ArrayList(); + long size_alloc = 0; + int n_p = prop / 10, n_o = (100 - prop) / 10; + boolean no_alloc = true; + + while (size_alloc < size) { + for (int i = 0; i < n_p; i++) { + Iterator it1 = purpose.iterator(); + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + + for (int i = 0; i < n_o; i++) { + Iterator it2 = other.iterator(); + while (it2.hasNext()) { + int a = (it2.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + if (no_alloc) + return array; + } + return array; + } + + public static ArrayList alloc_choose_idx(long size, ENUM_RANGE range, int chosen, int prop, boolean random, boolean isStress) { + ArrayList purpose = new ArrayList(); + ArrayList other = new ArrayList(); + ArrayList largeobj_list = new ArrayList(); + ArrayList array = new ArrayList(); + boolean has_small = false, has_large = false; + + if (!random) { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_small = true; + has_large = true; + break; + default: + break; + } + } else { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + Random rand = new Random(); + int largenum = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum; i++) { + int randNumber = rand.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + Random rand2 = new Random(); + int largenum2 = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum2; i++) { + int randNumber = rand2.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + has_small = true; + break; + default: + + } + } + if (has_small) { + array.addAll(alloc_choose_prop(purpose, other, prop, size, 0, isStress)); + } + if (has_large) { + array.addAll(alloc_list_large(LARGEOBJ_ALLOC_SIZE, largeobj_list, 50, isStress)); + } + return array; + } + + public static ArrayList alloc_list_large(long bytesize, ArrayList alloc_list, int prop, boolean isStress) { + ArrayList array = new ArrayList(); + long size_allocated = 0; + prop = makesureprop(prop); + int n_p = prop / 10, n_o = (100 - prop) / 10; + + while (size_allocated < bytesize) { + Iterator it1 = alloc_list.iterator(); + boolean first = true; + int loopn = n_p; + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + if (first) { + loopn = n_p; + first = false; + } else { + loopn = n_o; + first = true; + } + for (int i = 0; i < loopn; i++) { + size_allocated = size_allocated + a; + ArrayList temp_array = alloc_byte_large(a, a, 0, isStress); + array.addAll(temp_array); + if (size_allocated > bytesize) { + return array; + } + } + } + } + return array; + } + + public static ArrayList alloc_byte_large(long bytesize, int alloc_size, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + + if (alloc_size <= OBJ_MAX_SIZE) { + return null; + } + long size = 0; + if ((bytesize + diff * alloc_size) <= 0) { + return null; + } + bytesize = bytesize + diff * alloc_size; + while (size < bytesize) { + size = size + alloc_size; + array.add(MemAlloc.AllocOneUnit(alloc_size, isStress)); + } + return array; + } + + public static class RandomAllocMethod extends MemAllocMethod { + public RandomAllocMethod(long size, ENUM_RANGE range, int chosen, int prop, boolean random) { + mAllocSize = size; + mRange = range; + mChosen = chosen; + mProp = prop; + mRandorm = random; + } + + @Override + public List alloc(boolean isStress) { + List ret = alloc_choose_idx(mAllocSize, mRange, mChosen, mProp, mRandorm, isStress); + return ret; + } + } + + static class FreeReference implements Runnable { + private List> mAllReference = null; + private int mThreadIdx = 0; + private boolean mLoop = false; + private boolean mSync = false; + + public FreeReference(List> reference, int threadIdx, boolean loop, boolean sync) { + mAllReference = reference; + mThreadIdx = threadIdx; + mLoop = loop; + mSync = sync; + } + + public FreeReference(List> reference, int threadIdx, boolean loop) { + this(reference, threadIdx, loop, false); + } + + private void release() { + if (mSync) { + synchronized (mAllReference) { + releaseOperate(); + } + } else { + releaseOperate(); + } + } + + private void releaseOperate() { + if (mAllReference == null) { + return; + } + if (mThreadIdx >= mAllReference.size()) { + return; + } + List cur = mAllReference.get(mThreadIdx); + mAllReference.set(mThreadIdx, null); + if (cur != null) { + cur.clear(); + } + } + + @Override + public void run() { + if (!mLoop) { + release(); + return; + } + while (mLoop) { + if (!mRunning) { + break; + } + release(); + trySleep(1); + } + } + } + + + public static class AllocUnit { + public byte unit[]; + + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + + public abstract List alloc(boolean isStress); + } + + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + + public static class AllocUnitWithSoftReference extends AllocUnit { + + private Reference refArray; + + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private final Cleaner cleaner; + + private static class TestCleaner implements Runnable { + public byte unit[]; + + public TestCleaner(byte unit[]) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + + private Reference refArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + + return new AllocUnit(alloc_size); + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0334-rc-Memory-normalTestCase19/Memory_normalTestCase19.java b/test/testsuite/ouroboros/rc_test/RC0334-rc-Memory-normalTestCase19/Memory_normalTestCase19.java new file mode 100755 index 0000000000000000000000000000000000000000..bf167e3fdf708b315edaf1a3fee80f6d81620468 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0334-rc-Memory-normalTestCase19/Memory_normalTestCase19.java @@ -0,0 +1,1005 @@ +/* + *- @TestCaseID:rc/stress/Memory_normalTestCase19.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect: + *- @Priority: High + *- @Source: Memory_normalTestCase19.java + *- @ExecuteClass: Memory_normalTestCase19 + *- @ExecuteArgs: + *- @Remark: + *- @Author:从压力测试case中拆解 liuweiqing l00481345 + */ + +import sun.misc.Cleaner; + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.Set; + +public class Memory_normalTestCase19 { + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + static final int LOCAL_MAX_IDX = 15; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int GLOBAL_MIN_IDX = 16; + static final int LARGE_PAGE_SIZE = 4096; + static final int LARGEOBJ_CHOSEN_NUM = 2; + static final int LARGEOBJ_ALLOC_SIZE = 128 * LARGE_PAGE_SIZE; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + + static List> mAllThreadReference = new ArrayList>(); + + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + + private static void resetTestEnvirment(List> referenceList) { + + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + + public static void testCase19() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < 2 * DEFAULT_THREAD_NUM; i++) { + int slot = i % MAX_SLOT_NUM; + RandomAllocMethod allocMethod = new RandomAllocMethod(ALLOC_8K * 6, ENUM_RANGE.ENUM_RANGE_ALL, 6, 80, Math.random() > 0.5d); + t = new Thread(new MemAlloc(ALLOC_8K * 6, slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, false, 1, DEFAULT_REPEAT_TIMES, null, allocMethod), "testCase19_alloc_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + } + + public static void main(String[] args) { + testCase19(); + System.out.println("ExpectResult"); + } + + public static int makesureprop(int prop) { + if (prop > 100 || prop <= 0) { + prop = 100; + } + return prop; + } + + public static ArrayList choose_idx(int min, int max, int chosen, boolean random) { + if (min > max) { + return null; + } + ArrayList ret = new ArrayList(); + if (!random) { + int grow = (max - min + chosen) / chosen; + for (int i = min; i < max; i = i + grow) { + Integer a = Integer.valueOf(i); + ret.add(a); + } + } else { + Random rand = new Random(); + for (int i = 0; i < chosen; i++) { + int randNumber = rand.nextInt(max - min) + min; + Integer rdn = Integer.valueOf(randNumber); + ret.add(rdn); + } + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + + public static ArrayList alloc_choose_prop(ArrayList purpose, ArrayList other, int prop, long size, int diff, boolean isStress) { + prop = makesureprop(prop); + ArrayList array = new ArrayList(); + long size_alloc = 0; + int n_p = prop / 10, n_o = (100 - prop) / 10; + boolean no_alloc = true; + + while (size_alloc < size) { + for (int i = 0; i < n_p; i++) { + Iterator it1 = purpose.iterator(); + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + + for (int i = 0; i < n_o; i++) { + Iterator it2 = other.iterator(); + while (it2.hasNext()) { + int a = (it2.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + if (no_alloc) + return array; + } + return array; + } + + public static ArrayList alloc_choose_idx(long size, ENUM_RANGE range, int chosen, int prop, boolean random, boolean isStress) { + ArrayList purpose = new ArrayList(); + ArrayList other = new ArrayList(); + ArrayList largeobj_list = new ArrayList(); + ArrayList array = new ArrayList(); + boolean has_small = false, has_large = false; + + if (!random) { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_small = true; + has_large = true; + break; + default: + break; + } + } else { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + Random rand = new Random(); + int largenum = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum; i++) { + int randNumber = rand.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + Random rand2 = new Random(); + int largenum2 = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum2; i++) { + int randNumber = rand2.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + has_small = true; + break; + default: + + } + } + if (has_small) { + array.addAll(alloc_choose_prop(purpose, other, prop, size, 0, isStress)); + } + if (has_large) { + array.addAll(alloc_list_large(LARGEOBJ_ALLOC_SIZE, largeobj_list, 50, isStress)); + } + return array; + } + + public static ArrayList alloc_list_large(long bytesize, ArrayList alloc_list, int prop, boolean isStress) { + ArrayList array = new ArrayList(); + long size_allocated = 0; + prop = makesureprop(prop); + int n_p = prop / 10, n_o = (100 - prop) / 10; + + while (size_allocated < bytesize) { + Iterator it1 = alloc_list.iterator(); + boolean first = true; + int loopn = n_p; + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + if (first) { + loopn = n_p; + first = false; + } else { + loopn = n_o; + first = true; + } + for (int i = 0; i < loopn; i++) { + size_allocated = size_allocated + a; + ArrayList temp_array = alloc_byte_large(a, a, 0, isStress); + array.addAll(temp_array); + if (size_allocated > bytesize) { + return array; + } + } + } + } + return array; + } + + public static ArrayList alloc_byte_large(long bytesize, int alloc_size, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + + if (alloc_size <= OBJ_MAX_SIZE) { + return null; + } + long size = 0; + if ((bytesize + diff * alloc_size) <= 0) { + return null; + } + bytesize = bytesize + diff * alloc_size; + while (size < bytesize) { + size = size + alloc_size; + array.add(MemAlloc.AllocOneUnit(alloc_size, isStress)); + } + return array; + } + + public static class RandomAllocMethod extends MemAllocMethod { + public RandomAllocMethod(long size, ENUM_RANGE range, int chosen, int prop, boolean random) { + mAllocSize = size; + mRange = range; + mChosen = chosen; + mProp = prop; + mRandorm = random; + } + + @Override + public List alloc(boolean isStress) { + List ret = alloc_choose_idx(mAllocSize, mRange, mChosen, mProp, mRandorm, isStress); + return ret; + } + } + + static class FreeReference implements Runnable { + private List> mAllReference = null; + private int mThreadIdx = 0; + private boolean mLoop = false; + private boolean mSync = false; + + public FreeReference(List> reference, int threadIdx, boolean loop, boolean sync) { + mAllReference = reference; + mThreadIdx = threadIdx; + mLoop = loop; + mSync = sync; + } + + public FreeReference(List> reference, int threadIdx, boolean loop) { + this(reference, threadIdx, loop, false); + } + + private void release() { + if (mSync) { + synchronized (mAllReference) { + releaseOperate(); + } + } else { + releaseOperate(); + } + } + + private void releaseOperate() { + if (mAllReference == null) { + return; + } + if (mThreadIdx >= mAllReference.size()) { + return; + } + List cur = mAllReference.get(mThreadIdx); + mAllReference.set(mThreadIdx, null); + if (cur != null) { + cur.clear(); + } + } + + @Override + public void run() { + if (!mLoop) { + release(); + return; + } + while (mLoop) { + if (!mRunning) { + break; + } + release(); + trySleep(1); + } + } + } + + + public static class AllocUnit { + public byte unit[]; + + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + + public abstract List alloc(boolean isStress); + } + + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + + public static class AllocUnitWithSoftReference extends AllocUnit { + + private Reference refArray; + + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private final Cleaner cleaner; + + private static class TestCleaner implements Runnable { + public byte unit[]; + + public TestCleaner(byte unit[]) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + + private Reference refArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + } + + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + + return new AllocUnit(alloc_size); + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0335-rc-Memory-normalTestCase22/Memory_normalTestCase22.java b/test/testsuite/ouroboros/rc_test/RC0335-rc-Memory-normalTestCase22/Memory_normalTestCase22.java new file mode 100755 index 0000000000000000000000000000000000000000..bea0b8caba236df796de0b0354882277320514ee --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0335-rc-Memory-normalTestCase22/Memory_normalTestCase22.java @@ -0,0 +1,1015 @@ +/* + *- @TestCaseID:rc/stress/Memory_normalTestCase22.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect: + *- @Priority: High + *- @Source: Memory_normalTestCase22.java + *- @ExecuteClass: Memory_normalTestCase22 + *- @ExecuteArgs: + *- @Remark: + *- @Author:从压力测试case中拆解 liuweiqing l00481345 + */ + +import sun.misc.Cleaner; + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.Set; + +public class Memory_normalTestCase22 { + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + static final int LOCAL_MAX_IDX = 15; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int GLOBAL_MIN_IDX = 16; + static final int LARGE_PAGE_SIZE = 4096; + static final int LARGEOBJ_CHOSEN_NUM = 2; + static final int LARGEOBJ_ALLOC_SIZE = 128 * LARGE_PAGE_SIZE; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + private static final int DEFAULT_THREAD_NUM_HALF = DEFAULT_THREAD_NUM / 2; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + + static List> mAllThreadReference = new ArrayList>(); + + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + + private static void resetTestEnvirment(List> referenceList) { + + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + + public static void testCase22() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + int slot = new Random().nextInt(MAX_SLOT_NUM); + int size = new Random().nextInt(ALLOC_12K) + ALLOC_4K; + RandomAllocMethod allocMethod = new RandomAllocMethod(size, ENUM_RANGE.ENUM_RANGE_ALL, 6, (int) Math.random() * 100, Math.random() > 0.5d); + t = new Thread(new MemAlloc(size, slot, mAllThreadReference, i % DEFAULT_THREAD_NUM_HALF, MemAlloc.SAVE_ALL, true, 1000, DEFAULT_REPEAT_TIMES, null, allocMethod), "testCase22_alloc_" + (i + 1)); + list.add(t); + } + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + int slot = new Random().nextInt(MAX_SLOT_NUM); + int size = new Random().nextInt(ALLOC_12K) + ALLOC_4K; + RandomAllocMethod allocMethod = new RandomAllocMethod(size, ENUM_RANGE.ENUM_RANGE_ALL, 6, (int) Math.random() * 100, Math.random() > 0.5d); + t = new Thread(new MemAlloc(size, slot, mAllThreadReference, i % DEFAULT_THREAD_NUM_HALF, MemAlloc.SAVE_ALL, true, 1000, DEFAULT_REPEAT_TIMES, null, allocMethod), "testCase22_alloc_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + } + + public static void main(String[] args) { + testCase22(); + Runtime.getRuntime().gc(); + testCase22(); + System.out.println("ExpectResult"); + } + + public static int makesureprop(int prop) { + if (prop > 100 || prop <= 0) { + prop = 100; + } + return prop; + } + + public static ArrayList choose_idx(int min, int max, int chosen, boolean random) { + if (min > max) { + return null; + } + ArrayList ret = new ArrayList(); + if (!random) { + int grow = (max - min + chosen) / chosen; + for (int i = min; i < max; i = i + grow) { + Integer a = Integer.valueOf(i); + ret.add(a); + } + } else { + Random rand = new Random(); + for (int i = 0; i < chosen; i++) { + int randNumber = rand.nextInt(max - min) + min; + Integer rdn = Integer.valueOf(randNumber); + ret.add(rdn); + } + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + + public static ArrayList alloc_choose_prop(ArrayList purpose, ArrayList other, int prop, long size, int diff, boolean isStress) { + prop = makesureprop(prop); + ArrayList array = new ArrayList(); + long size_alloc = 0; + int n_p = prop / 10, n_o = (100 - prop) / 10; + boolean no_alloc = true; + + while (size_alloc < size) { + for (int i = 0; i < n_p; i++) { + Iterator it1 = purpose.iterator(); + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + + for (int i = 0; i < n_o; i++) { + Iterator it2 = other.iterator(); + while (it2.hasNext()) { + int a = (it2.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + if (no_alloc) + return array; + } + return array; + } + + public static ArrayList alloc_choose_idx(long size, ENUM_RANGE range, int chosen, int prop, boolean random, boolean isStress) { + ArrayList purpose = new ArrayList(); + ArrayList other = new ArrayList(); + ArrayList largeobj_list = new ArrayList(); + ArrayList array = new ArrayList(); + boolean has_small = false, has_large = false; + + if (!random) { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_small = true; + has_large = true; + break; + default: + break; + } + } else { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + Random rand = new Random(); + int largenum = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum; i++) { + int randNumber = rand.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + Random rand2 = new Random(); + int largenum2 = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum2; i++) { + int randNumber = rand2.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + has_small = true; + break; + default: + + } + } + if (has_small) { + array.addAll(alloc_choose_prop(purpose, other, prop, size, 0, isStress)); + } + if (has_large) { + array.addAll(alloc_list_large(LARGEOBJ_ALLOC_SIZE, largeobj_list, 50, isStress)); + } + return array; + } + + public static ArrayList alloc_list_large(long bytesize, ArrayList alloc_list, int prop, boolean isStress) { + ArrayList array = new ArrayList(); + long size_allocated = 0; + prop = makesureprop(prop); + int n_p = prop / 10, n_o = (100 - prop) / 10; + + while (size_allocated < bytesize) { + Iterator it1 = alloc_list.iterator(); + boolean first = true; + int loopn = n_p; + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + if (first) { + loopn = n_p; + first = false; + } else { + loopn = n_o; + first = true; + } + for (int i = 0; i < loopn; i++) { + size_allocated = size_allocated + a; + ArrayList temp_array = alloc_byte_large(a, a, 0, isStress); + array.addAll(temp_array); + if (size_allocated > bytesize) { + return array; + } + } + } + } + return array; + } + + public static ArrayList alloc_byte_large(long bytesize, int alloc_size, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + + if (alloc_size <= OBJ_MAX_SIZE) { + return null; + } + long size = 0; + if ((bytesize + diff * alloc_size) <= 0) { + return null; + } + bytesize = bytesize + diff * alloc_size; + while (size < bytesize) { + size = size + alloc_size; + array.add(MemAlloc.AllocOneUnit(alloc_size, isStress)); + } + return array; + } + + public static class RandomAllocMethod extends MemAllocMethod { + public RandomAllocMethod(long size, ENUM_RANGE range, int chosen, int prop, boolean random) { + mAllocSize = size; + mRange = range; + mChosen = chosen; + mProp = prop; + mRandorm = random; + } + + @Override + public List alloc(boolean isStress) { + List ret = alloc_choose_idx(mAllocSize, mRange, mChosen, mProp, mRandorm, isStress); + return ret; + } + } + + static class FreeReference implements Runnable { + private List> mAllReference = null; + private int mThreadIdx = 0; + private boolean mLoop = false; + private boolean mSync = false; + + public FreeReference(List> reference, int threadIdx, boolean loop, boolean sync) { + mAllReference = reference; + mThreadIdx = threadIdx; + mLoop = loop; + mSync = sync; + } + + public FreeReference(List> reference, int threadIdx, boolean loop) { + this(reference, threadIdx, loop, false); + } + + private void release() { + if (mSync) { + synchronized (mAllReference) { + releaseOperate(); + } + } else { + releaseOperate(); + } + } + + private void releaseOperate() { + if (mAllReference == null) { + return; + } + if (mThreadIdx >= mAllReference.size()) { + return; + } + List cur = mAllReference.get(mThreadIdx); + mAllReference.set(mThreadIdx, null); + if (cur != null) { + cur.clear(); + } + } + + @Override + public void run() { + if (!mLoop) { + release(); + return; + } + while (mLoop) { + if (!mRunning) { + break; + } + release(); + trySleep(1); + } + } + } + + + public static class AllocUnit { + public byte unit[]; + + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + + public abstract List alloc(boolean isStress); + } + + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + + public static class AllocUnitWithSoftReference extends AllocUnit { + + private Reference refArray; + + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private final Cleaner cleaner; + + private static class TestCleaner implements Runnable { + public byte unit[]; + + public TestCleaner(byte unit[]) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + + private Reference refArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + + return new AllocUnit(alloc_size); + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0336-rc-Memory-normalTestCase23/Memory_normalTestCase23.java b/test/testsuite/ouroboros/rc_test/RC0336-rc-Memory-normalTestCase23/Memory_normalTestCase23.java new file mode 100755 index 0000000000000000000000000000000000000000..cac489eec7845f48df916ef43acce7c1ba632aef --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0336-rc-Memory-normalTestCase23/Memory_normalTestCase23.java @@ -0,0 +1,1067 @@ +/* + *- @TestCaseID:rc/stress/Memory_normalTestCase23.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect: + *- @Priority: High + *- @Source: Memory_normalTestCase23.java + *- @ExecuteClass: Memory_normalTestCase23 + *- @ExecuteArgs: + *- @Remark: + *- @Author:从压力测试case中拆解 liuweiqing l00481345 + */ + + +import sun.misc.Cleaner; + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.Set; + +public class Memory_normalTestCase23 { + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + static final int LOCAL_MAX_IDX = 15; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int GLOBAL_MIN_IDX = 16; + static final int LARGE_PAGE_SIZE = 4096; + static final int LARGEOBJ_CHOSEN_NUM = 2; + static final int LARGEOBJ_ALLOC_SIZE = 128 * LARGE_PAGE_SIZE; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + private static final int DEFAULT_THREAD_NUM_HALF = DEFAULT_THREAD_NUM / 2; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + + static List> mAllThreadReference = new ArrayList>(); + + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + + private static void resetTestEnvirment(List> referenceList) { + + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + + public static void testCase23() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + int slot = new Random().nextInt(MAX_SLOT_NUM); + int size = new Random().nextInt(ALLOC_12K) + ALLOC_4K; + MemAllocMethod allocMethod = new ContinueRandomAllocMethod(size, ENUM_RANGE.ENUM_RANGE_ALL, 6, (int) Math.random() * 100, Math.random() > 0.5d, 100, 400, 0, false); + t = new Thread(new MemAlloc(size, slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, true, 1000, DEFAULT_REPEAT_TIMES, null, allocMethod), "testCase23_alloc_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + } + + public static void main(String[] args) { + testCase23(); + Runtime.getRuntime().gc(); + testCase23(); + System.out.println("ExpectResult"); + } + + public static int makesureprop(int prop) { + if (prop > 100 || prop <= 0) { + prop = 100; + } + return prop; + } + + public static ArrayList choose_idx(int min, int max, int chosen, boolean random) { + if (min > max) { + return null; + } + ArrayList ret = new ArrayList(); + if (!random) { + int grow = (max - min + chosen) / chosen; + for (int i = min; i < max; i = i + grow) { + Integer a = Integer.valueOf(i); + ret.add(a); + } + } else { + Random rand = new Random(); + for (int i = 0; i < chosen; i++) { + int randNumber = rand.nextInt(max - min) + min; + Integer rdn = Integer.valueOf(randNumber); + ret.add(rdn); + } + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + + public static ArrayList alloc_choose_prop(ArrayList purpose, ArrayList other, int prop, long size, int diff, boolean isStress) { + prop = makesureprop(prop); + ArrayList array = new ArrayList(); + long size_alloc = 0; + int n_p = prop / 10, n_o = (100 - prop) / 10; + boolean no_alloc = true; + + while (size_alloc < size) { + for (int i = 0; i < n_p; i++) { + Iterator it1 = purpose.iterator(); + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + + for (int i = 0; i < n_o; i++) { + Iterator it2 = other.iterator(); + while (it2.hasNext()) { + int a = (it2.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + if (no_alloc) + return array; + } + return array; + } + + public static ArrayList alloc_choose_idx(long size, ENUM_RANGE range, int chosen, int prop, boolean random, boolean isStress) { + ArrayList purpose = new ArrayList(); + ArrayList other = new ArrayList(); + ArrayList largeobj_list = new ArrayList(); + ArrayList array = new ArrayList(); + boolean has_small = false, has_large = false; + + if (!random) { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_small = true; + has_large = true; + break; + default: + break; + } + } else { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + Random rand = new Random(); + int largenum = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum; i++) { + int randNumber = rand.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + Random rand2 = new Random(); + int largenum2 = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum2; i++) { + int randNumber = rand2.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + has_small = true; + break; + default: + + } + } + if (has_small) { + array.addAll(alloc_choose_prop(purpose, other, prop, size, 0, isStress)); + } + if (has_large) { + array.addAll(alloc_list_large(LARGEOBJ_ALLOC_SIZE, largeobj_list, 50, isStress)); + } + return array; + } + + public static ArrayList alloc_list_large(long bytesize, ArrayList alloc_list, int prop, boolean isStress) { + ArrayList array = new ArrayList(); + long size_allocated = 0; + prop = makesureprop(prop); + int n_p = prop / 10, n_o = (100 - prop) / 10; + + while (size_allocated < bytesize) { + Iterator it1 = alloc_list.iterator(); + boolean first = true; + int loopn = n_p; + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + if (first) { + loopn = n_p; + first = false; + } else { + loopn = n_o; + first = true; + } + for (int i = 0; i < loopn; i++) { + size_allocated = size_allocated + a; + ArrayList temp_array = alloc_byte_large(a, a, 0, isStress); + array.addAll(temp_array); + if (size_allocated > bytesize) { + return array; + } + } + } + } + return array; + } + + public static ArrayList alloc_byte_large(long bytesize, int alloc_size, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + + if (alloc_size <= OBJ_MAX_SIZE) { + return null; + } + long size = 0; + if ((bytesize + diff * alloc_size) <= 0) { + return null; + } + bytesize = bytesize + diff * alloc_size; + while (size < bytesize) { + size = size + alloc_size; + array.add(MemAlloc.AllocOneUnit(alloc_size, isStress)); + } + return array; + } + + public static class RandomAllocMethod extends MemAllocMethod { + public RandomAllocMethod(long size, ENUM_RANGE range, int chosen, int prop, boolean random) { + mAllocSize = size; + mRange = range; + mChosen = chosen; + mProp = prop; + mRandorm = random; + } + + @Override + public List alloc(boolean isStress) { + List ret = alloc_choose_idx(mAllocSize, mRange, mChosen, mProp, mRandorm, isStress); + return ret; + } + } + + static class FreeReference implements Runnable { + private List> mAllReference = null; + private int mThreadIdx = 0; + private boolean mLoop = false; + private boolean mSync = false; + + public FreeReference(List> reference, int threadIdx, boolean loop, boolean sync) { + mAllReference = reference; + mThreadIdx = threadIdx; + mLoop = loop; + mSync = sync; + } + + public FreeReference(List> reference, int threadIdx, boolean loop) { + this(reference, threadIdx, loop, false); + } + + private void release() { + if (mSync) { + synchronized (mAllReference) { + releaseOperate(); + } + } else { + releaseOperate(); + } + } + + private void releaseOperate() { + if (mAllReference == null) { + return; + } + if (mThreadIdx >= mAllReference.size()) { + return; + } + List cur = mAllReference.get(mThreadIdx); + mAllReference.set(mThreadIdx, null); + if (cur != null) { + cur.clear(); + } + } + + @Override + public void run() { + if (!mLoop) { + release(); + return; + } + while (mLoop) { + if (!mRunning) { + break; + } + release(); + trySleep(1); + } + } + } + + public static class ContinueRandomAllocMethod extends MemAllocMethod { + private long mSleep; + private long mTotalTimes; + private long mTimes = 0; + private boolean mFreeImmediately; + + public ContinueRandomAllocMethod(long size, ENUM_RANGE range, int chosen, int prop, boolean random, long sleep, long totalTimes, int times, boolean freeImmediately) { + mAllocSize = size; + mRange = range; + mChosen = chosen; + mProp = prop; + mRandorm = random; + mSleep = sleep; + mTotalTimes = totalTimes; + mTimes = times; + mFreeImmediately = freeImmediately; + } + + @Override + public List alloc(boolean isStress) { + List ret = null; + List tmp = null; + if (mTotalTimes == 0 && mTimes == 0) { + ret = alloc_choose_idx(mAllocSize, mRange, mChosen, mProp, mRandorm, isStress); + return ret; + } + long elipseTime = 0; + boolean find = false; + ret = new ArrayList(); + + while (elipseTime < mTotalTimes) { + long now = System.currentTimeMillis(); + tmp = alloc_choose_idx(mAllocSize, mRange, mChosen, mProp, mRandorm, isStress); + if (!mFreeImmediately && tmp != null) { + ret.addAll(tmp); + } else { + tmp = null; + } + find = true; + trySleep(mSleep); + elipseTime += System.currentTimeMillis() - now; + } + if (!find) { + int time = 0; + while (time < mTotalTimes) { + tmp = alloc_choose_idx(mAllocSize, mRange, mChosen, mProp, mRandorm, isStress); + if (!mFreeImmediately && tmp != null) { + ret.addAll(tmp); + } else { + tmp = null; + } + time++; + trySleep(mSleep); + } + } + return ret; + } + } + + public static class AllocUnit { + public byte unit[]; + + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + + public abstract List alloc(boolean isStress); + } + + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + + public static class AllocUnitWithSoftReference extends AllocUnit { + + private Reference refArray; + + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + + @Override + public void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private final Cleaner cleaner; + + private static class TestCleaner implements Runnable { + public byte unit[]; + + public TestCleaner(byte unit[]) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + + private Reference refArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + + private static class TestCleaner implements Runnable { + public byte[] unit; + + public TestCleaner(byte[] unit) { + this.unit = unit; + } + + public void run() { + this.unit = null; + } + } + } + + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + + return new AllocUnit(alloc_size); + } + + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0337-rc-Memory-normalTestCase27/Memory_normalTestCase27.java b/test/testsuite/ouroboros/rc_test/RC0337-rc-Memory-normalTestCase27/Memory_normalTestCase27.java new file mode 100755 index 0000000000000000000000000000000000000000..ba42c18fa60c1049c6d822207692d3f16fbabcdb --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0337-rc-Memory-normalTestCase27/Memory_normalTestCase27.java @@ -0,0 +1,125 @@ +/* + *- @TestCaseID:rc/stress/Memory_normalTestCase27.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect: + *- @Priority: High + *- @Source: Memory_normalTestCase27.java + *- @ExecuteClass: Memory_normalTestCase27 + *- @ExecuteArgs: + *- @Remark: + *- @Author:从压力测试case中拆解 liuweiqing l00481345 + */ + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.*; + +public class Memory_normalTestCase27 { + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + static final int LOCAL_MAX_IDX = 15; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int GLOBAL_MIN_IDX = 16; + static final int LARGE_PAGE_SIZE = 4096; + static final int LARGEOBJ_CHOSEN_NUM = 2; + static final int LARGEOBJ_ALLOC_SIZE = 128 * LARGE_PAGE_SIZE; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + private static final int DEFAULT_STRESS_THREAD_NUM = 60; + private static final int DEFAULT_STRESS_THREAD_NUM_HALF = DEFAULT_STRESS_THREAD_NUM / 2; + private static ArrayList mThreadList = new ArrayList(); + + public static void testCase27() { + RCWeakProxyTest.RCWeakProxyTestEntry(); + } + + public static void main(String[] args) { + testCase27(); + System.out.println("ExpectResult"); + } +} + +class RCWeakProxyTest { + static class A { + Object o; + } + + static class ThreadRunning extends Thread { + HashMap map; + Hashtable table; + + ThreadRunning(HashMap m, Hashtable t) { + super("testCase_RCWeakProxy"); + map = m; + table = t; + } + + int foo() { + return map.values().size(); + } + + public void run() { + for (int i = 0; i < 500; i++) { + /* + * Collection c = map.values(); if (c == null) { + * System.out.println("error"); return; } int x = c.size(); + */ + int x = foo(); + if (x == 100) { + } else { + A a = new A(); + a = new A(); + } + + /* + * int y = table.values().size(); if (y == 100) { + * System.out.println("bla"); } + */ + } + } + } + + public static void RCWeakProxyTestEntry() { + HashMap map = new HashMap(); + map.put("key1", "value1"); + Hashtable table = new Hashtable(); + table.put("key1", "value1"); + int num_thread = 2; + ThreadRunning t[] = new ThreadRunning[num_thread]; + for (int i = 0; i < num_thread; i++) { + t[i] = new ThreadRunning(map, table); + t[i].start(); + } + + try { + for (int i = 0; i < num_thread; i++) { + t[i].join(); + } + } catch (Exception e) { + } + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0338-rc-Memory-normalTestCase28/Memory_normalTestCase28.java b/test/testsuite/ouroboros/rc_test/RC0338-rc-Memory-normalTestCase28/Memory_normalTestCase28.java new file mode 100755 index 0000000000000000000000000000000000000000..6d0c96bd0d69206c6009fcadc78baaa4aef974ef --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0338-rc-Memory-normalTestCase28/Memory_normalTestCase28.java @@ -0,0 +1,173 @@ +/* + *- @TestCaseID:rc/stress/Memory_normalTestCase28.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect: + *- @Priority: High + *- @Source: Memory_normalTestCase28.java + *- @ExecuteClass: Memory_normalTestCase28 + *- @ExecuteArgs: + *- @Remark: + *- @Author:从压力测试case中拆解 liuweiqing l00481345 + */ + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.Set; + +public class Memory_normalTestCase28 { + private static final int DEFAULT_THREAD_NUM = 80; + public static final int LOCAL_MIN_IDX = 0; + private static final int DEFAULT_STRESS_THREAD_NUM = 60; + private static final String MODULE_NAME_MEMT = "MemAllocTest"; + static List> mAllStressThreadReference = new ArrayList>(); + private static ArrayList mThreadList = new ArrayList(); + + private static void resetTestEnvirment(List> referenceList) { + + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + + public static void main(String[] args) { + testCase28(); + Runtime.getRuntime().gc(); + testCase28(); + Runtime.getRuntime().gc(); + testCase28(); + Runtime.getRuntime().gc(); + testCase28(); + Runtime.getRuntime().gc(); + testCase28(); + System.out.println("ExpectResult"); + } + + public static void testCase28() { + + ArrayList list = new ArrayList(); + resetTestEnvirment(mAllStressThreadReference); + Thread t = null; + for (int i = 0; i < DEFAULT_THREAD_NUM / 8; i++) { + t = new Thread(new Runnable() { + + @Override + public void run() { + for (int j = 0; j < 50; j++) { + NativeTestFunc nativeTestFunc = new NativeTestFunc(); + nativeTestFunc.testNativeWeakDelete(nativeTestFunc); + System.runFinalization(); + } + } + }, MODULE_NAME_MEMT + "_testCase28_weak_" + i); + list.add(t); + } + + for (int i = 0; i < DEFAULT_THREAD_NUM / 8; i++) { + t = new Thread(new Runnable() { + + @Override + public void run() { + for (int j = 0; j < 50; j++) { + NativeTestFunc nativeTestFunc = new NativeTestFunc(); + nativeTestFunc.testNativeGlobalDelete(nativeTestFunc); + System.runFinalization(); + } + } + }, MODULE_NAME_MEMT + "_testCase28_global_" + i); + list.add(t); + } + + mThreadList.addAll(list); + startAllThread(list); + waitAllThreadFinish(list); + + } + + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + + public static class AllocUnit { + public byte unit[]; + + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + +} + +class NativeTestFunc { + static { + // System.loadLibrary("StressTestNative"); + } + + public native void testNativeAttach(); + + public native void testNativeWeakDelete(Object input); + + public native void testNativeGlobalDelete(Object input); +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0339-rc-rp-cycle_all_weak/Ref_Processor_Cycle_All_Weak_Ref.java b/test/testsuite/ouroboros/rc_test/RC0339-rc-rp-cycle_all_weak/Ref_Processor_Cycle_All_Weak_Ref.java new file mode 100755 index 0000000000000000000000000000000000000000..1bc86ea837d040fb80f0fca3f9d69f2c25ce855a --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0339-rc-rp-cycle_all_weak/Ref_Processor_Cycle_All_Weak_Ref.java @@ -0,0 +1,187 @@ +/* + *- @TestCaseID: maple/runtime/rc/function/Ref_Processor_Cycle_All_Weak_Ref.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Reference Processor: 1.Circular references, all of which are weak references + *- @Condition: no + *- @Brief:functionTest + * -#step1: 分别创建Cycle_A、Cycle_B、Cycle_C、Cycle_D 四个类的对象,均含有弱引用,并且这四个对象互为循环引用; + * -#step2: 分别取出step1中四个对象的sum属性的值,计算它们的和并赋值给allSum; + * -#step3: 让当前线程休眠2000ms; + * -#step4: 确认四个类的对象的引用均已经释放; + * -#step5: 将step1中Cycle_A的实例对象cycleA赋值为null; + * -#step6: 让当前线程休眠2000ms; + * -#step7: 经判断得出step1中的四个实例对象均为null; + * -#step8: 调用Runtime.getRuntime().gc()进行垃圾回收,重复步骤2~8; + * -#step9: 分别判断allSum和checkCount的值,并确定step1中四个互为循环引用的对象为弱引用; + *- @Expect: ExpectResult\n + *- @Priority: High + *- @Source: Ref_Processor_Cycle_All_Weak_Ref.java + *- @ExecuteClass: Ref_Processor_Cycle_All_Weak_Ref + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.*; + +public class Ref_Processor_Cycle_All_Weak_Ref { + static int checkCount = 0; + static final int TEST_NUM = 1; + static int allSum; + + public static void main(String[] args) { + checkCount = 0; + for (int i = 0; i < TEST_NUM; i++) { + test_01(); + Runtime.getRuntime().gc(); + test_01(); + + if (allSum == 20) { + checkCount++; + System.out.println("sum is wrong"); + } + + if (checkCount == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("errorResult ---- checkCount: " + checkCount); + } + } + } + + private static void test_01() { + Cycle_A cycleA = new Cycle_A(); + cycleA.cyb = new Cycle_B(); + cycleA.cyb.cyc = new Cycle_C(); + cycleA.cyb.cyc.cyd = new Cycle_D(); + cycleA.cyb.cyc.cyd.cya = cycleA; + allSum = cycleA.sum + cycleA.cyb.sum + cycleA.cyb.cyc.sum + cycleA.cyb.cyc.cyd.sum; + sleep(2000); + if ((cycleA.wr.get() != null) || (cycleA.cyb.sr.get() != null) || (cycleA.cyb.cyc.pr.get() != null) + || (cycleA.cyb.cyc.cyd.str.get() != null)) { + checkCount++; + } + cycleA = null; + sleep(2000); + if (cycleA != null && cycleA.cyb != null && cycleA.cyb.cyc != null && cycleA.cyb.cyc.cyd != null + && cycleA.cyb.cyc.cyd.cya != null) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " [test_01]a1 has not free"); + } + } + + private static void sleep(int sleepNum) { + try { + Thread.sleep(sleepNum); + } catch (InterruptedException e) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " sleep was Interrupted"); + } + } +} + +class Cycle_A { + Reference wr; + Cycle_B cyb; + int aNum; + int sum; + static StringBuffer stringBufferA = new StringBuffer("ref_processor_cycle_A"); + + Cycle_A() { + stringBufferA = new StringBuffer("ref_processor_cycle_A"); + wr = new WeakReference<>(stringBufferA); + if (wr.get() == null) { + assert false; + } + stringBufferA = null; + cyb = null; + aNum = 1; + } + + int joinStr() { + try { + sum = aNum + cyb.bNum; + } catch (Exception e) { + } + return sum; + } +} + +class Cycle_B { + Reference sr; + Cycle_C cyc; + int bNum; + int sum; + static StringBuffer stringBufferB = new StringBuffer("ref_processor_cycle_B"); + + Cycle_B() { + stringBufferB = new StringBuffer("ref_processor_cycle_B"); + sr = new WeakReference<>(stringBufferB); + if (sr.get() == null) { + assert false; + } + stringBufferB = null; + cyc = null; + bNum = 2; + } + + int joinStr() { + try { + sum = bNum + cyc.cNum; + } catch (Exception e) { + } + return sum; + } +} + +class Cycle_C { + Reference pr; + Cycle_D cyd; + StringBuffer stringBufferC = new StringBuffer("ref_processor_cycle_C"); + int sum; + int cNum; + + Cycle_C() { + stringBufferC = new StringBuffer("ref_processor_cycle_C"); + pr = new WeakReference<>(stringBufferC); + if (pr.get() == null) { + assert false; + } + stringBufferC = null; + cyd = null; + cNum = 3; + } + + int joinStr() { + try { + sum = cNum + cyd.dNum; + } catch (Exception e) { + } + return sum; + } +} + +class Cycle_D { + Reference str; + Cycle_A cya; + StringBuffer stringBufferD = new StringBuffer("ref_processor_cycle_D"); + int dNum; + int sum; + + Cycle_D() { + stringBufferD = new StringBuffer("ref_processor_cycle_D"); + str = new WeakReference(stringBufferD); + stringBufferD = null; + cya = null; + dNum = 4; + } + + int joinStr() { + try { + int sum = dNum + cya.aNum; + } catch (Exception e) { + } + return sum; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0340-rc-rp-cycle_weak_strong/Ref_Processor_Cycle_Weak_Strong_Ref.java b/test/testsuite/ouroboros/rc_test/RC0340-rc-rp-cycle_weak_strong/Ref_Processor_Cycle_Weak_Strong_Ref.java new file mode 100755 index 0000000000000000000000000000000000000000..cfba5550729c35733c9f40eb2bffe9b00cc3ed3b --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0340-rc-rp-cycle_weak_strong/Ref_Processor_Cycle_Weak_Strong_Ref.java @@ -0,0 +1,183 @@ +/* + *- @TestCaseID: maple/runtime/rc/function/Ref_Processor_Cycle_Weak_Strong_Ref.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Reference Processor: 1.Circular reference, has strong and weak references + *- @Condition: no + *- @Brief:functionTest + * -#step1: 分别创建Cycle_A、Cycle_B、Cycle_C、Cycle_D 四个类的对象,含有强弱引用,并且这四个对象互为循环引用; + * -#step2: 分别取出step1中四个对象的sum属性的值,计算它们的和并赋值给allSum; + * -#step3: 让当前线程休眠2000ms; + * -#step4: 确认四个类的对象的引用均已经释放; + * -#step5: 将step1中Cycle_A的实例对象cycleA赋值为null; + * -#step6: 让当前线程休眠2000ms; + * -#step7: 经判断得出step1中的四个实例对象均为null; + * -#step8: 调用Runtime.getRuntime().gc()进行垃圾回收,重复步骤2~8; + * -#step9: 分别判断allSum和checkCount的值,并确定step1中四个互为循环引用的对象既有强引用,又有弱引用; + *- @Expect: ExpectResult\n + *- @Priority: High + *- @Source: Ref_Processor_Cycle_Weak_Strong_Ref.java + *- @ExecuteClass: Ref_Processor_Cycle_Weak_Strong_Ref + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.*; + +public class Ref_Processor_Cycle_Weak_Strong_Ref { + static int checkCount = 0; + static final int TEST_NUM = 1; + static int allSum; + + public static void main(String[] args) { + checkCount = 0; + for (int i = 0; i < TEST_NUM; i++) { + test_01(); + Runtime.getRuntime().gc(); + test_01(); + + if (allSum == 20) { + checkCount++; + System.out.println("sum is wrong"); + } + + if (checkCount == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("errorResult ---- checkCount: " + checkCount); + } + } + } + + private static void test_01() { + Cycle_A cycleA = new Cycle_A(); + cycleA.cyb = new Cycle_B(); + cycleA.cyb.cyc = new Cycle_C(); + cycleA.cyb.cyc.cyd = new Cycle_D(); + cycleA.cyb.cyc.cyd.cya = cycleA; + allSum = cycleA.sum + cycleA.cyb.sum + cycleA.cyb.cyc.sum + cycleA.cyb.cyc.cyd.sum; + sleep(2000); + if ((cycleA.wr.get() != null) || (cycleA.cyb.sr.get() != null) || (cycleA.cyb.cyc.pr.get() != null) + || (cycleA.cyb.cyc.cyd.string == null)) { + checkCount++; + } + cycleA = null; + sleep(2000); + if (cycleA != null && cycleA.cyb != null && cycleA.cyb.cyc != null && cycleA.cyb.cyc.cyd != null + && cycleA.cyb.cyc.cyd.cya != null) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " [test_01]a1 has not free"); + } + } + + private static void sleep(int sleepNum) { + try { + Thread.sleep(sleepNum); + } catch (InterruptedException e) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " sleep was Interrupted"); + } + } +} + +class Cycle_A { + Reference wr; + Cycle_B cyb; + int aNum; + int sum; + static StringBuffer stringBufferA = new StringBuffer("ref_processor_cycle_A"); + + Cycle_A() { + stringBufferA = new StringBuffer("ref_processor_cycle_A"); + wr = new WeakReference<>(stringBufferA); + if (wr.get() == null) { + assert false; + } + stringBufferA = null; + cyb = null; + aNum = 1; + } + + int joinStr() { + try { + sum = aNum + cyb.bNum; + } catch (Exception e) { + } + return sum; + } +} + +class Cycle_B { + Reference sr; + Cycle_C cyc; + int bNum; + int sum; + static StringBuffer stringBufferB = new StringBuffer("ref_processor_cycle_B"); + + Cycle_B() { + stringBufferB = new StringBuffer("ref_processor_cycle_B"); + sr = new WeakReference<>(stringBufferB); + if (sr.get() == null) { + assert false; + } + stringBufferB = null; + cyc = null; + bNum = 2; + } + + int joinStr() { + try { + sum = bNum + cyc.cNum; + } catch (Exception e) { + } + return sum; + } +} + +class Cycle_C { + Reference pr; + Cycle_D cyd; + StringBuffer stringBufferC = new StringBuffer("ref_processor_cycle_C"); + int sum; + int cNum; + + Cycle_C() { + stringBufferC = new StringBuffer("ref_processor_cycle_C"); + pr = new WeakReference<>(stringBufferC); + if (pr.get() == null) { + assert false; + } + stringBufferC = null; + cyd = null; + cNum = 3; + } + + int joinStr() { + try { + sum = cNum + cyd.dNum; + } catch (Exception e) { + } + return sum; + } +} + +class Cycle_D { + String string; + Cycle_A cya; + int dNum; + int sum; + + Cycle_D() { + string = new String("ref_processor_cycle_D"); + cya = null; + dNum = 4; + } + + int joinStr() { + try { + int sum = dNum + cya.aNum; + } catch (Exception e) { + } + return sum; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0341-rc-rp-mutator/Ref_Processor_Mutator_Ref.java b/test/testsuite/ouroboros/rc_test/RC0341-rc-rp-mutator/Ref_Processor_Mutator_Ref.java new file mode 100755 index 0000000000000000000000000000000000000000..f388259769067bb6a200668c0258e490a4d7d93e --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0341-rc-rp-mutator/Ref_Processor_Mutator_Ref.java @@ -0,0 +1,138 @@ +/* + *- @TestCaseID: maple/runtime/rc/function/Ref_Processor_Mutator_Ref.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Reference Processor and Mutator threads are called simultaneously (test work queue) + *- @Condition: no + *- @Brief:functionTest + * -#step1: 创建三个ReferenceQueue类的对象,并令其分别等于wrq、srq、prq;声明三个StringBuffer类型的变量stringBuffer1、 + * stringBuffer2、stringBuffer3并分别赋值为weak、soft、phantom; + * -#step2: 以stringBuffer1、wrq为参数,创建一个WeakReference类的对象wr;同理,以stringBuffer2、srq为参数,创建一个 + * WeakReference类的对象sr;以stringBuffer3、prq为参数,创建一个PhantomReference类的对象pr; + * -#step3: 通过wr.get()、sr.get()、pr.get()方法分别获取各自的referent对象,经判断获取到的referent对象均不为null; + * -#step4: 令变量stringBuffer1、stringBuffer2、stringBuffer3等于null; + * -#step5: 让当前线程休眠2000ms; + * -#step6: 经判断通过wr.get()方法获取的referent对象为null;同理,通过sr.get()方法获取的referent对象为null; + * -#step7: wrq、srq、prq引用队列判断它们均为null; + * -#step8: 调用Runtime.getRuntime().gc()进行垃圾回收; + * -#step9: 重复步骤1~8三次; + * -#step10: 重复步骤1~7; + *- @Expect: ExpectResult\n + *- @Priority: High + *- @Source: Ref_Processor_Mutator_Ref.java + *- @ExecuteClass: Ref_Processor_Mutator_Ref + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.*; + +public class Ref_Processor_Mutator_Ref { + static int check_count = 0; + static final int TEST_NUM = 1; + static Reference wr, sr, pr; + static ReferenceQueue wrq, srq, prq; + static StringBuffer stringBuffer1 = new StringBuffer("weak"); + static StringBuffer stringBuffer2 = new StringBuffer("soft"); + static StringBuffer stringBuffer3 = new StringBuffer("phantom"); + + public static void main(String[] args) { + test(); + Runtime.getRuntime().gc(); + test(); + Runtime.getRuntime().gc(); + test(); + Runtime.getRuntime().gc(); + test(); + Runtime.getRuntime().gc(); + test(); + + if (check_count == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("error,check_count: " + check_count); + } + } + + private static void test() { + for (int i = 0; i < TEST_NUM; i++) { + test_01(); + sleep(2000); + if (wr.get() != null) { + check_count++; + } + if (sr.get() != null) { + check_count++; + } + } + + Reference wrqPoll, srqPoll, prqPoll; + while ((wrqPoll = wrq.poll()) != null) { + if (!wrqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + check_count++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ErrorResult in " + + "wrq.poll()"); + } + } + while ((srqPoll = srq.poll()) != null) { + if (!srqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + check_count++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ErrorResult in " + + "srq.poll()"); + } + } + while ((prqPoll = prq.poll()) != null) { + if (!prqPoll.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + check_count++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ErrorResult in " + + "prq.poll()"); + } + } + } + + public static void test_01() { + wrq = new ReferenceQueue(); + srq = new ReferenceQueue(); + prq = new ReferenceQueue(); + stringBuffer1 = new StringBuffer("weak"); + stringBuffer2 = new StringBuffer("soft"); + stringBuffer3 = new StringBuffer("phantom"); + wr = new WeakReference(stringBuffer1, wrq); + if (wr.get() == null) { + check_count++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ----------------------" + + "check_count: " + check_count); + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ErrorResult in wr"); + } + + sr = new WeakReference(stringBuffer2, srq); + if (sr.get() == null) { + check_count++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ----------------------" + + "check_count: " + check_count); + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ErrorResult in sr"); + } + + pr = new PhantomReference(stringBuffer3, prq); + if (pr.get() != null) { + check_count++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ----------------------" + + "check_count: " + check_count); + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ErrorResult in pr"); + } + stringBuffer1 = null; + stringBuffer2 = null; + stringBuffer3 = null; + } + + + private static void sleep(int sleepNum) { + try { + Thread.sleep(sleepNum); + } catch (InterruptedException e) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " sleep was Interrupted"); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0342-rc-rp-weak_ref_boundary/Ref_Processor_Weak_Ref_Boundary.java b/test/testsuite/ouroboros/rc_test/RC0342-rc-rp-weak_ref_boundary/Ref_Processor_Weak_Ref_Boundary.java new file mode 100755 index 0000000000000000000000000000000000000000..a6db428a0f37701a93c670a2df593b21e27ce471 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0342-rc-rp-weak_ref_boundary/Ref_Processor_Weak_Ref_Boundary.java @@ -0,0 +1,200 @@ +/* + *- @TestCaseID: maple/runtime/rc/function/Ref_Processor_Weak_Ref_Boundary.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Reference Processor: 1.14 mix weak references + * 2.15 mix weak references + * 3.16 mix weak references + *- @Condition: no + *- @Brief:functionTest + * -#step1: 声明一个ReferenceQueue类的实例对象srq,以stringBuffer1和srq为参数,创建一个WeakReference类的实例对象并赋值给sr, + * 判断sr.get()的返回值不为null; + * -#step2: 重复step1四次后,令stringBuffer1等于null; + * -#step3: 让当前线程休眠2000ms,经判断sr不为null; + * -#step4: 判断得出sr.get()的返回值为null; + * -#step5: 重复步骤4四次后,经判断srq.poll()的返回值不为null,并且其是WeakReference类的一个实例对象; + * -#step6: 创建一个StringBuffer类型的变量stringBuffer2,并赋初值为weak,同时声明一个ReferenceQueue类的实例对象wrq,以 + * stringBuffer2和wrq为参数,创建一个WeakReference类的实例对象并赋值给wr,经判断wr.get()的返回值不为null; + * -#step7: 重复step6三次后,令stringBuffer2等于null;让当前线程休眠2000ms,经判断wr不为null; + * -#step8: 判断得出wr.get()的返回值不为null,否则将check_count的值加1,并打印相关信息; + * -#step9: 重复步骤8三次后,经判断wrq.poll()的返回值不为null,并且其是WeakReference类的一个实例对象; + * -#step10: 创建一个StringBuffer类型的变量stringBuffer3,并赋初值为phantom,同时声明一个ReferenceQueue类的实例对象prq, + * 以stringBuffer3和prq为参数,创建一个WeakReference类的实例对象并赋值给pr,经判断pr.get()的返回值不为null; + * -#step11: 重复step10四次后,令stringBuffer3等于null; + * -#step12: 经判断prq.poll()的返回值不为null,并且其是WeakReference类的一个实例对象; + * -#step13: 重复步骤1~12,但是在执行步骤7的时候,由原来的重复步骤step6三次变为四次;同样,在执行步骤9的时候,由原来的 + * 重复步骤8三次变为四次; + * -#step14: 重复步骤1~12,但是在执行步骤7的时候,由原来的重复步骤step6三次变为五次;同样,在执行步骤9的时候,由原来的 + * 重复步骤8三次变为五次; + * -#step15: 让当前线程休眠1000ms; + * -#step16: 调用Runtime.getRuntime().gc()进行垃圾回收; + * -#step17: 重复步骤1~16两次; + * -#step18: 重复步骤1~15一次; + *- @Expect: ExpectResult\n + *- @Priority: High + *- @Source: Ref_Processor_Weak_Ref_Boundary.java + *- @ExecuteClass: Ref_Processor_Weak_Ref_Boundary + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.*; + +public class Ref_Processor_Weak_Ref_Boundary { + static int checkCount = 0; + static final int TEST_NUM = 1; + + static WeakReference wr[] = new WeakReference[14]; + static WeakReference sr[] = new WeakReference[14]; + static PhantomReference pr[] = new PhantomReference[14]; + static ReferenceQueue wrq = new ReferenceQueue(); + static ReferenceQueue srq = new ReferenceQueue(); + static ReferenceQueue prq = new ReferenceQueue(); + + static StringBuffer stringBuffer1 = new StringBuffer("soft"); + static StringBuffer stringBuffer2 = new StringBuffer("weak"); + static StringBuffer stringBuffer3 = new StringBuffer("phantom"); + + public static void main(String[] args) { + test(); + Runtime.getRuntime().gc(); + test(); + Runtime.getRuntime().gc(); + test(); + Runtime.getRuntime().gc(); + test(); + + //Result judgment + if (checkCount == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("errorResult,checkNum: " + checkCount); + } + } + + private static void test() { + //test01: 14 mix weak references + for (int i = 0; i < TEST_NUM; i++) { + test_01(); + } + sleep(1000); + } + + public static void setSoftRef(int times) { + stringBuffer1 = new StringBuffer("soft"); + for (int i = 0; i < times; i++) { + sr[i] = new WeakReference(stringBuffer1, srq); + if (sr[i].get() == null) { + System.out.println(" ---------------error in sr of test01"); + checkCount++; + } + } + stringBuffer1 = null; + } + + public static void setWeakRef(int times) { + stringBuffer2 = new StringBuffer("Weak"); + for (int i = 0; i < times; i++) { + wr[i] = new WeakReference(stringBuffer2, wrq); + if (wr[i].get() == null) { + System.out.println(" ---------------error in wr of test01"); + checkCount++; + } + } + stringBuffer2 = null; + } + + public static void setPhantomRef(int times) { + stringBuffer3 = new StringBuffer("phantom"); + for (int i = 0; i < times; i++) { + pr[i] = new PhantomReference(stringBuffer3, prq); + if (pr[i].get() != null) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ---------------" + + "error in pr of test01"); + checkCount++; + } + } + stringBuffer3 = null; + } + + public static void test_01() { + /* 14 mix weak references */ + setSoftRef(5); + checkSoftRq("soft", 5); + setWeakRef(4); + checkWeakRq("weak", 4); + setPhantomRef(5); + checkPhantomRq("phantom"); + + setSoftRef(5); + checkSoftRq("soft", 5); + setWeakRef(5); + checkWeakRq("weak", 5); + setPhantomRef(5); + checkPhantomRq("phantom"); + + setSoftRef(5); + checkSoftRq("soft", 5); + setWeakRef(6); + checkWeakRq("weak", 6); + setPhantomRef(5); + checkPhantomRq("phantom"); + } + + public static void checkSoftRq(String funName, int times) { + Reference srqPoll; + sleep(2000); + if (sr != null) { + for (int i = 0; i < times; i++) { + if (sr[i].get() != null) { + checkCount++; + System.out.println(" ErrorResult in sr " + funName); + } + } + } + while ((srqPoll = srq.poll()) != null) { + if (!srqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + checkCount++; + System.out.println(" ErrorResult in srq.poll()"); + } + } + } + + public static void checkWeakRq(String funName, int times) { + Reference wrqPoll; + sleep(2000); + for (int i = 0; i < times; i++) { + if (wr[i].get() != null) { + checkCount++; + System.out.println(" ErrorResult in wr " + funName + "times:" + i); + } + } + while ((wrqPoll = wrq.poll()) != null) { + if (!wrqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + checkCount++; + System.out.println(" ErrorResult in wrq.poll()"); + } + } + } + + public static void checkPhantomRq(String funName) { + Reference prqPoll; + while ((prqPoll = prq.poll()) != null) { + if (!prqPoll.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + checkCount++; + System.out.println(" ErrorResult in prq.poll()"); + } + } + } + + private static void sleep(int sleepNum) { + try { + Thread.sleep(sleepNum); + } catch (InterruptedException e) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " sleep was Interrupted"); + } + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0343-rc-rp-wcb_test_ref/Ref_Processor_Wcb_Test_Ref.java b/test/testsuite/ouroboros/rc_test/RC0343-rc-rp-wcb_test_ref/Ref_Processor_Wcb_Test_Ref.java new file mode 100755 index 0000000000000000000000000000000000000000..2bf1ee8e5ce13f75653d203bd989f518f76d4da7 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0343-rc-rp-wcb_test_ref/Ref_Processor_Wcb_Test_Ref.java @@ -0,0 +1,136 @@ +/* + *- @TestCaseID: maple/runtime/rc/function/ref_processor_strong_and_weak_ref.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Reference Processor WCB test: 1.if WCB == 0, return object value + * 2.if WCB == 1, return null + * 3.check change WCB 1 to 0 + * 4.check change WCB 0 to 1 + *- @Condition: no + *- @Brief:functionTest + * -#step1: 创建WeakReference类型的引用变量sr,wr和pr,经判断它们均不为null,令变量stringBuffer1、stringBuffer2、 + * stringBuffer3等于null; + * -#step2: 让当前线程休眠1000ms; + * -#step3: 让当前线程休眠2000ms; + * -#step4: 经判断sr.get()的返回值不为null,则令checkCount的值加1;同理,wr.get()的返回值也不为null,令checkCount的值 + * 加1;pr.get()的返回值也不为null,令checkCount的值加1; + * -#step5: 分别令wrq.poll()、srq.poll()、prq.poll()的返回值为wrqPoll、srqPoll、prqPoll,经判断它们均不为null,并且都是 + * WeakReference类的一个实例对象; + * -#step6: 重复步骤1~5; + * -#step7: 调用Runtime.getRuntime().gc()进行垃圾回收; + * -#step8: 重复步骤1~6; + *- @Expect: ExpectResult\n + *- @Priority: High + *- @Source: Ref_Processor_Wcb_Test_Ref.java + *- @ExecuteClass: Ref_Processor_Wcb_Test_Ref + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.*; + +import java.lang.ref.PhantomReference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; + +public class Ref_Processor_Wcb_Test_Ref { + static int checkCount = 0; + static final int TEST_NUM = 1; + static Reference wr, sr, pr; + static ReferenceQueue wrq = new ReferenceQueue(); + static ReferenceQueue srq = new ReferenceQueue(); + static ReferenceQueue prq = new ReferenceQueue(); + static StringBuffer stringBuffer1 = new StringBuffer("soft"); + static StringBuffer stringBuffer2 = new StringBuffer("weak"); + static StringBuffer stringBuffer3 = new StringBuffer("phantom"); + + public static void main(String[] args) { + test(); + Runtime.getRuntime().gc(); + test(); + + if (checkCount == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("errorResult ---- checkcount: " + checkCount); + } + } + + private static void test() { + // test: if WCB == 0, return object value + for (int i = 0; i < TEST_NUM; i++) { + test_01(); + sleep(1000); + } + // test: if WCB == 1, return null + checkRet("test step 2"); + // test: check change WCB 1 to 0 + } + + private static void test_01() { + /*if WCB == 0, return object value except PhantomReference*/ + stringBuffer1 = new StringBuffer("soft"); + stringBuffer2 = new StringBuffer("weak"); + stringBuffer3 = new StringBuffer("phantom"); + + wr = new WeakReference(stringBuffer2, wrq); + if (wr.get() == null) { + checkCount++; + } + + sr = new WeakReference(stringBuffer1, srq); + if (sr.get() == null) { + checkCount++; + } + + pr = new PhantomReference(stringBuffer3, prq); + if (pr.get() != null) { + checkCount++; + } + stringBuffer2 = null; + stringBuffer1 = null; + stringBuffer3 = null; + } + + private static void checkRet(String funName) { + sleep(2000); + Reference wrqPoll, srqPoll, prqPoll; + if (sr.get() != null) { + checkCount++; + } + if (wr.get() != null) { + checkCount++; + } + if (pr.get() != null) { + checkCount++; + } + while ((wrqPoll = wrq.poll()) != null) { + if (!wrqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + checkCount++; + System.out.println(" ErrorResult in wrq.poll()"); + } + } + while ((srqPoll = srq.poll()) != null) { + if (!srqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + checkCount++; + System.out.println(" ErrorResult in srq.poll()"); + } + } + while ((prqPoll = prq.poll()) != null) { + if (!prqPoll.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + checkCount++; + System.out.println(" ErrorResult in prq.poll()"); + } + } + } + + private static void sleep(int sleepNum) { + try { + Thread.sleep(sleepNum); + } catch (InterruptedException e) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " sleep was Interrupted"); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0344-rc-rp-test_aged_ref/Ref_Processor_Aged_Ref.java b/test/testsuite/ouroboros/rc_test/RC0344-rc-rp-test_aged_ref/Ref_Processor_Aged_Ref.java new file mode 100755 index 0000000000000000000000000000000000000000..7f3fe2dd8b838384619c845d121f00a3c945d54b --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0344-rc-rp-test_aged_ref/Ref_Processor_Aged_Ref.java @@ -0,0 +1,161 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/Ref_Processor_Aged_Ref.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Reference Processor: 1. Threshold for Ref object == age - 1 + * 2. Threshold for Ref object == age + * 3. Threshold for Ref object == age + 1 + * 4. Has entered the Aged Ref queue, the number of processing == X-1 + * 5. Has entered the Aged Ref queue, the number of processing == X + * 6. Has entered the Aged Ref queue, the number of processing == X+1 + *- @Condition: no + *- @Brief:functionTest + * -#step1: 创建软引用,弱引用,虚引用,并判断创建后引用不为空。 + * -#step2: 等待一个时间,引用应该被回收为空,引用队列也为空。 + * -#step3: 将步骤1,2的操作分别重复age-1、age、age+1。 + * -#step4: 此时会到达age的引用队列,重复步骤1~3。 + * -#step5: 调用Runtime.getRuntime().gc()进行资源回收。 + * -#step6: 重复步骤1~4。 + *- @Expect: ExpectResult\n + *- @Priority: High + *- @Source: Ref_Processor_Aged_Ref.java + *- @ExecuteClass: Ref_Processor_Aged_Ref + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.*; + +public class Ref_Processor_Aged_Ref { + static int check_count = 0; + static final int TEST_NUM = 1; + static final int AGED_NUM = 3; + static WeakReference sr[] = new WeakReference[AGED_NUM + 1]; + static WeakReference wr[] = new WeakReference[AGED_NUM + 1]; + static PhantomReference pr[] = new PhantomReference[AGED_NUM + 1]; + static ReferenceQueue wrq = new ReferenceQueue(); + static ReferenceQueue srq = new ReferenceQueue(); + static ReferenceQueue prq = new ReferenceQueue(); + static StringBuffer obj1 = new StringBuffer("WeakReference"); + static StringBuffer obj2 = new StringBuffer("WeakReference"); + static StringBuffer obj3 = new StringBuffer("PhantomReference"); + + public static void main(String[] args) { + test(); + Runtime.getRuntime().gc(); + test(); + + if (check_count == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult, check_count : " + check_count); + } + } + + public static void test() { + for (int i = 0; i < TEST_NUM; i++) { + // Threshold for Ref object == age - 1 + obj1 = new StringBuffer("WeakReference"); + obj2 = new StringBuffer("WeakReference"); + obj3 = new StringBuffer("PhantomReference"); + setRef(AGED_NUM - 1); + checkRef(AGED_NUM - 1); + // Threshold for Ref object == age + obj1 = new StringBuffer("WeakReference"); + obj2 = new StringBuffer("WeakReference"); + obj3 = new StringBuffer("PhantomReference"); + setRef(AGED_NUM); + checkRef(AGED_NUM); + // Threshold for Ref object == age + 1 + obj1 = new StringBuffer("WeakReference"); + obj2 = new StringBuffer("WeakReference"); + obj3 = new StringBuffer("PhantomReference"); + setRef(AGED_NUM + 1); + checkRef(AGED_NUM + 1); + // Has entered the Aged Ref queue + // The number of processing == X-1 + obj1 = new StringBuffer("WeakReference"); + obj2 = new StringBuffer("WeakReference"); + obj3 = new StringBuffer("PhantomReference"); + setRef(AGED_NUM - 1); + checkRef(AGED_NUM - 1); + //the number of processing == X + obj1 = new StringBuffer("WeakReference"); + obj2 = new StringBuffer("WeakReference"); + obj3 = new StringBuffer("PhantomReference"); + setRef(AGED_NUM); + checkRef(AGED_NUM); + //the number of processing == X+1 + obj1 = new StringBuffer("WeakReference"); + obj2 = new StringBuffer("WeakReference"); + obj3 = new StringBuffer("PhantomReference"); + setRef(AGED_NUM + 1); + checkRef(AGED_NUM + 1); + } + } + + public static void setRef(int repeat_time) { + /*Threshold for Ref object == age - 1*/ + for (int i = 0; i < repeat_time; i++) { + sr[i] = new WeakReference(obj1, srq); + if (sr[i].get() == null) { + check_count++; + System.out.println("sr in setRef " + i + "repeat_time:" + repeat_time); + } + wr[i] = new WeakReference(obj2, wrq); + if (wr[i].get() == null) { + check_count++; + System.out.println("wr in setRef " + i + "repeat_time:" + repeat_time); + } + pr[i] = new PhantomReference(obj3, prq); + if (pr[i].get() != null) { + check_count++; + System.out.println("pr in setRef"); + } + } + obj1 = null; + obj2 = null; + obj3 = null; + } + + public static void checkRef(int repeat_time) { + sleep(2000); + for (int i = 0; i < repeat_time; i++) { + if (sr[i].get() != null) { + check_count++; + } + if (wr[i].get() != null) { + check_count++; + } + Reference wrqPoll, srqPoll, prqPoll; + while ((wrqPoll = wrq.poll()) != null) { + if (!wrqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + check_count++; + System.out.println(" ErrorResult in wrq.poll()"); + } + } + while ((srqPoll = srq.poll()) != null) { + if (!srqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + check_count++; + System.out.println(" ErrorResult in srq.poll()"); + } + } + while ((prqPoll = prq.poll()) != null) { + if (!prqPoll.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + check_count++; + System.out.println(" ErrorResult in prq.poll()"); + } + } + } + } + + private static void sleep(int sleepNum) { + try { + Thread.sleep(sleepNum); + } catch (InterruptedException e) { + System.out.println(" sleep was Interrupted"); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0345-rc-rp-single_or_more/Ref_Processor_Single_Or_More_Weak_Ref.java b/test/testsuite/ouroboros/rc_test/RC0345-rc-rp-single_or_more/Ref_Processor_Single_Or_More_Weak_Ref.java new file mode 100755 index 0000000000000000000000000000000000000000..8c27870788e185f7f8792c585c83c922b32edadf --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0345-rc-rp-single_or_more/Ref_Processor_Single_Or_More_Weak_Ref.java @@ -0,0 +1,199 @@ +/* + *- @TestCaseID: maple/runtime/rc/function/Ref_Processor_Single_Or_More_Weak_Ref.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Reference Processor: single weak/soft phantom reference. + *- @Condition: no + *- @Brief:functionTest + * -#step1: 创建弱引用,并判断创建后引用不为空, 等待一个时间,引用应该被回收为空,引用队列也为空。 + * -#step2: 创建软引用,并判断创建后引用不为空, 等待一个时间,引用应该被回收为空,引用队列也为空。 + * -#step3: 创建虚引用,并判断创建后引用不为空, 等待一个时间,引用应该被回收为空,引用队列也为空。 + * -#step4: 同时创建弱引用、软引用、虚引用,并判断创建后引用不为空, 等待一个时间,引用应该被回收为空,引用队列也为空。 + * -#step5: 调用Runtime.getRuntime().gc()进行资源回收。 + * -#step6: 重复步骤1~4。 + *- @Expect: ExpectResult\n + *- @Priority: High + *- @Source: Ref_Processor_Single_Or_More_Weak_Ref.java + *- @ExecuteClass: Ref_Processor_Single_Or_More_Weak_Ref + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.*; + +public class Ref_Processor_Single_Or_More_Weak_Ref { + static int check_count = 0; + static final int TEST_NUM = 1; + static Reference wr, sr, pr; + static ReferenceQueue wrq, srq, prq; + + static StringBuffer obj_1 = new StringBuffer("hello"); + static StringBuffer obj_2 = new StringBuffer("kitty"); + static StringBuffer obj_3 = new StringBuffer("mikey"); + static StringBuffer obj4 = new StringBuffer("WeakReference"); + static StringBuffer obj5 = new StringBuffer("WeakReference"); + static StringBuffer obj6 = new StringBuffer("PhantomReference"); + + public static void main(String[] args) { + test(); + Runtime.getRuntime().gc(); + test(); + if (check_count == 0) + System.out.println("ExpectResult"); + else { + System.out.println("ErrorResult, check_count:" + check_count); + } + } + + private static void test() { + Reference wrqPoll, srqPoll, prqPoll; + for (int i = 0; i < TEST_NUM; i++) { + weakRef(); + sleep(2000); + if (wr.get() != null) { + check_count++; + System.out.println(" ErrorResult in weakRef step1"); + } + while ((wrqPoll = wrq.poll()) != null) { + if (!wrqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + check_count++; + System.out.println(" ErrorResult in wrq.poll() step2"); + } + } + } + // check WeakReference + for (int i = 0; i < TEST_NUM; i++) { + softRef(); + sleep(2000); + + if (sr.get() != null) { + check_count++; + System.out.println(" ErrorResult in softRef step2"); + } + while ((srqPoll = srq.poll()) != null) { + if (!srqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + check_count++; + System.out.println(" ErrorResult in srq.poll()"); + } + } + } + // check PhantomReference + for (int i = 0; i < TEST_NUM; i++) { + phantomRef(); + sleep(2000); + while ((prqPoll = prq.poll()) != null) { + if (!prqPoll.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + check_count++; + System.out.println(" ErrorResult in prq.poll()"); + } + } + } + // more than one reference + for (int i = 0; i < TEST_NUM; i++) { + mixRef(); + sleep(2000); + if (wr.get() != null) { + check_count++; + System.out.println(" ErrorResult in mixRef step2:weakRef"); + } + if (sr.get() != null) { + check_count++; + System.out.println(" ErrorResult in mixRef step2:softRef"); + } + if (pr.get() != null) { + check_count++; + System.out.println(" ErrorResult in mixRef step2:phantomRef"); + } + + while ((wrqPoll = wrq.poll()) != null) { + if (!wrqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + check_count++; + System.out.println(" ErrorResult in wrq.poll()"); + } + } + while ((srqPoll = srq.poll()) != null) { + if (!srqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + check_count++; + System.out.println(" ErrorResult in srq.poll()"); + } + } + while ((prqPoll = prq.poll()) != null) { + if (!prqPoll.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + check_count++; + System.out.println(" ErrorResult in prq.poll()"); + } + } + } + } + + private static void weakRef() { + wrq = new ReferenceQueue(); + obj_1 = new StringBuffer("hello"); + wr = new WeakReference(obj_1, wrq); + if (wr.get() == null) { + check_count++; + System.out.println(" ErrorResult in weakRef step1"); + } + obj_1 = null; + } + + private static void softRef() { + srq = new ReferenceQueue(); + obj_2 = new StringBuffer("kitty"); + sr = new WeakReference(obj_2, srq); + if (sr.get() == null) { + check_count++; + System.out.println(" ErrorResult in softRef step1"); + } + obj_2 = null; + } + + private static void phantomRef() { + obj_3 = new StringBuffer("mikey"); + prq = new ReferenceQueue(); + pr = new PhantomReference(obj_3, prq); + if (pr.get() != null) { + check_count++; + System.out.println(" ErrorResult in phantomRef step1"); + } + obj_3 = null; + } + + private static void mixRef() { + wrq = new ReferenceQueue(); + srq = new ReferenceQueue(); + prq = new ReferenceQueue(); + obj4 = new StringBuffer("WeakReference"); + obj5 = new StringBuffer("WeakReference"); + obj6 = new StringBuffer("PhantomReference"); + wr = new WeakReference(obj4, wrq); + if (wr.get() == null) { + check_count++; + System.out.println(" ErrorResult of wr in mixRef step1"); + } + sr = new WeakReference(obj5, srq); + if (sr.get() == null) { + check_count++; + System.out.println(" ErrorResult of sr in mixRef step2"); + } + pr = new PhantomReference(obj6, prq); + if (pr.get() != null) { + check_count++; + System.out.println(" ErrorResult of pr in mixRef step3"); + } + obj4 = null; + obj5 = null; + obj6 = null; + } + + private static void sleep(int sleepNum) { + try { + Thread.sleep(sleepNum); + } catch (InterruptedException e) { + System.out.println(" sleep was Interrupted"); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f + diff --git a/test/testsuite/ouroboros/rc_test/RC0346-rc-rp-strong_and_weak/Ref_Processor_Strong_And_Weak_Ref.java b/test/testsuite/ouroboros/rc_test/RC0346-rc-rp-strong_and_weak/Ref_Processor_Strong_And_Weak_Ref.java new file mode 100755 index 0000000000000000000000000000000000000000..90776ca5903f6624f17fcf8014a12166a0577381 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0346-rc-rp-strong_and_weak/Ref_Processor_Strong_And_Weak_Ref.java @@ -0,0 +1,131 @@ +/* + *- @TestCaseID: maple/runtime/rc/function/Ref_Processor_Strong_And_Weak_Ref.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Reference Processor: strong and weak reference, first free strong, next free weak + * + *- @Condition: no + *- @Brief:functionTest + * -#step1: 创建弱引用,软引用,虚引用,判断这些引用不为空。 + * -#step2: 将弱引用,软引用,虚引用的引用的对象置为NULL,释放强引用。 + * -#step3: 等待一个时间周期,检查引用,软引用,虚引用及对应引用队列被释放。 + *- @Expect: ExpectResult\n + *- @Priority: High + *- @Source: Ref_Processor_Strong_And_Weak_Ref.java + *- @ExecuteClass: Ref_Processor_Strong_And_Weak_Ref + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.*; + +public class Ref_Processor_Strong_And_Weak_Ref { + static int check_count = 0; + static final int TEST_NUM = 1; + static String rf = new String("test"); + static Reference wr, sr, pr; + static ReferenceQueue wrq = new ReferenceQueue(); + static ReferenceQueue srq = new ReferenceQueue(); + static ReferenceQueue prq = new ReferenceQueue(); + static StringBuffer obj1 = new StringBuffer("weak"); + static StringBuffer obj2 = new StringBuffer("soft"); + static StringBuffer obj3 = new StringBuffer("phantom"); + + public static void main(String[] args) { + test(); + Runtime.getRuntime().gc(); + test(); + + if (check_count == 0){ + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult check_count : " + check_count); + } + } + + private static void test() { + // strong and weak reference, first free strong, next free weak + for (int i = 0; i < TEST_NUM; i++) { + test_01(); + } + checkRq("test_01_02"); + } + + private static void test_01() { + /* strong and weak reference, first free strong, next free weak */ + obj1 = new StringBuffer("weak"); + obj2 = new StringBuffer("soft"); + obj3 = new StringBuffer("phantom"); + wr = new WeakReference(obj1, wrq); + if (wr.get() == null) { + check_count++; + System.out.println("error in test01---------------wr"); + } + + sr = new WeakReference(obj2, srq); + if (sr.get() == null) { + check_count++; + System.out.println("error in test01----------------sr"); + } + + pr = new PhantomReference(obj3, prq); + if (pr.get() != null) { + check_count++; + System.out.println("error in test01----------------pr"); + } + + obj1 = null; + obj2 = null; + obj3 = null; + if (rf == null) { + check_count++; + System.out.println("error in test01-----------rf"); + } + } + + private static void checkRq(String funName) { + Reference wrqPoll, srqPoll, prqPoll; + sleep(2000); + if (wr.get() != null) { + System.out.println("error in checkRq---------------wr"); + check_count++; + } + if (sr.get() != null) { + System.out.println("error in checkRq--------------sr"); + check_count++; + } + if (rf == null || (!rf.equals("test"))) { + System.out.println("error in checkRq---------------rf"); + check_count++; + } + while ((wrqPoll = wrq.poll()) != null) { + if (!wrqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + check_count++; + System.out.println("ErrorResult in wrq.poll()"); + } + } + while ((srqPoll = srq.poll()) != null) { + if (!srqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + check_count++; + System.out.println("ErrorResult in srq.poll()"); + } + } + while ((prqPoll = prq.poll()) != null) { + if (!prqPoll.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + check_count++; + System.out.println("ErrorResult in prq.poll()"); + } + } + } + + private static void sleep(int sleepNum) { + try { + Thread.sleep(sleepNum); + } catch (InterruptedException e) { + System.out.println("sleep was Interrupted"); + } + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0347-rc-rp-simulthread/SimulThreadInRef.java b/test/testsuite/ouroboros/rc_test/RC0347-rc-rp-simulthread/SimulThreadInRef.java new file mode 100755 index 0000000000000000000000000000000000000000..1cb25ee6f7b9cf328ba10a2fc45a68a3c4c9eb36 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0347-rc-rp-simulthread/SimulThreadInRef.java @@ -0,0 +1,255 @@ +/* + *- @TestCaseID: maple/runtime/rc/function/SimulThreadInRef.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: RefTest basic testcase. + *- @Condition: no + *- @Brief:functionTest + * -#step1: 创建线程来设置软引用,等待一个时间周期,确认软引用被释放,软引用队列为空。 + * -#step2: 调用Runtime.getRuntime().gc(),重复步骤1; + * -#step3: 创建线程来设置弱引用,等待一个时间周期,确认弱引用被释放,弱引用队列为空。 + * -#step4: 调用Runtime.getRuntime().gc(),重复步骤3; + * -#step5: 创建线程来设置虚引用,等待一个时间周期,确认虚引用被释放,虚引用队列为空。 + * -#step6: 调用Runtime.getRuntime().gc(),重复步骤5; + * -#step7: 创建线程来设置其他引用,调用Runtime.getRuntime().gc()。 + * -#step8: 调用Runtime.getRuntime().gc(),重复步骤1~7。 + *- @Expect: ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: SimulThreadInRef.java + *- @ExecuteClass: SimulThreadInRef + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.*; + +public class SimulThreadInRef { + public static void main(String[] args) { + test(); + Runtime.getRuntime().gc(); + test(); + } + + static void test() { + int soft, weak, phantom; + soft = testExecuteSoft(); + Runtime.getRuntime().gc(); + soft = testExecuteSoft(); + + weak = testExecuteWeak(); + Runtime.getRuntime().gc(); + weak = testExecuteWeak(); + + phantom = testExecutePhantom(); + Runtime.getRuntime().gc(); + phantom = testExecutePhantom(); + + testExecuteOther(); + Runtime.getRuntime().gc(); + + if ((soft == 0) && (weak == 0) && (phantom == 0)) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } + + static int testExecuteSoft() { + MultiRef multiRef = new MultiRef(); + ThreadTestSoftRef threadTestSoftRef = new ThreadTestSoftRef(multiRef); + int N = 1; + for (int i = 0; i < N; i++) { + threadTestSoftRef.run(); + } + return threadTestSoftRef.count1; + } + + static int testExecuteWeak() { + MultiRef multiRef = new MultiRef(); + ThreadTestWeakRef threadTestWeakRef = new ThreadTestWeakRef(multiRef); + int N = 1; + for (int i = 0; i < N; i++) { + threadTestWeakRef.run(); + } + return threadTestWeakRef.count2; + } + + static int testExecutePhantom() { + MultiRef multiRef = new MultiRef(); + ThreadTestPhantomRef threadTestPhantomRef = new ThreadTestPhantomRef(multiRef); + int N = 1; + for (int i = 0; i < N; i++) { + threadTestPhantomRef.run(); + } + return threadTestPhantomRef.count3; + } + + static void testExecuteOther() { + MultiRef multiRef = new MultiRef(); + ThreadTestOtherRef threadTestOtherRef = new ThreadTestOtherRef(multiRef); + int N = 1; + for (int i = 0; i < N; i++) { + threadTestOtherRef.run(); + } + } +} + +class MultiRef { + static Reference sr, wr, pr, osr; + static StringBuffer obj1 = new StringBuffer("Soft"); + static StringBuffer obj2 = new StringBuffer("weak"); + static StringBuffer obj3 = new StringBuffer("Phantom"); + ReferenceQueue srq = new ReferenceQueue(); + ReferenceQueue wrq = new ReferenceQueue(); + ReferenceQueue prq = new ReferenceQueue(); + static int srValue, wrValue, prValue; + + void setSoftRef() { + obj1 = new StringBuffer("Soft"); + sr = new WeakReference(obj1, srq); + if (sr.get() == null) { + srValue++; + } + obj1 = null; + } + + void setWeakRef() { + obj2 = new StringBuffer("weak"); + wr = new WeakReference(obj2, wrq); + if (wr.get() == null) { + wrValue++; + } + obj2 = null; + } + + void setPhantomRef() { + obj3 = new StringBuffer("Phantom"); + pr = new PhantomReference(obj3, prq); + if (pr.get() != null) { + prValue++; + } + obj3 = null; + } + + void setOtherSoftRef() { + osr = new WeakReference(new Object()); + } + + int freeSoftRef() throws InterruptedException { + Reference r1; + setSoftRef(); + Thread.sleep(2000); + if (sr.get() != null) { + srValue++; + System.out.println("error in soft"); + } + while ((r1 = srq.poll()) != null) { + if (!r1.getClass().toString().equals("class java.lang.ref.WeakReference")) { + srValue++; + } + } + return srValue; + } + + int freeWeakRef() throws InterruptedException { + Reference r2; + setWeakRef(); + Thread.sleep(2000); + if (wr.get() != null) { + wrValue++; + System.out.println("error in weak"); + } + while ((r2 = wrq.poll()) != null) { + if (!r2.getClass().toString().equals("class java.lang.ref.WeakReference")) { + wrValue++; + } + } + return wrValue; + } + + int freePhantomRef() throws InterruptedException { + Reference r1; + setPhantomRef(); + Thread.sleep(2000); + while ((r1 = prq.poll()) != null) { + if (!r1.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + prValue++; + } + } + return prValue; + } +} + +// 线程1,设置软引用 +class ThreadTestSoftRef implements Runnable { + MultiRef multiRef; + int count1; + + public ThreadTestSoftRef(MultiRef multiRef) { + this.multiRef = multiRef; + } + + @Override + public void run() { + try { + count1 = multiRef.freeSoftRef(); + } catch (Exception e) { + e.printStackTrace(); + } + } +} + +// 线程2,设置弱引用 +class ThreadTestWeakRef implements Runnable { + MultiRef multiRef; + int count2; + + public ThreadTestWeakRef(MultiRef multiRef) { + this.multiRef = multiRef; + } + + @Override + public void run() { + try { + count2 = multiRef.freeWeakRef(); + } catch (Exception e) { + e.printStackTrace(); + } + } +} + +// 线程3,设置虚引用 +class ThreadTestPhantomRef implements Runnable { + MultiRef multiRef; + int count3; + + public ThreadTestPhantomRef(MultiRef multiRef) { + this.multiRef = multiRef; + } + + @Override + public void run() { + try { + count3 = multiRef.freePhantomRef(); + } catch (Exception e) { + e.printStackTrace(); + } + } +} + +// 线程4,设置其他引用 +class ThreadTestOtherRef implements Runnable { + MultiRef multiRef; + + public ThreadTestOtherRef(MultiRef multiRef) { + this.multiRef = multiRef; + } + + @Override + public void run() { + multiRef.setOtherSoftRef(); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0348-rc-rp-simpleweakref_01/DeadReferenceTest.java b/test/testsuite/ouroboros/rc_test/RC0348-rc-rp-simpleweakref_01/DeadReferenceTest.java new file mode 100755 index 0000000000000000000000000000000000000000..fb035a61f7906970dbb61c48ed594747eaec3f26 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0348-rc-rp-simpleweakref_01/DeadReferenceTest.java @@ -0,0 +1,73 @@ +/* + *- @TestCaseID: RefProCase/RefProcessor/src/DeadReferenceTest.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: RefProcessor testcase:处理对象为死对象的弱引用 + *- @Condition: no + *- @Brief:functionTest + * -#step1:创建一个ReferenceQueue类的实例对象rq,并已null和rq为参数创建一个WeakReference的实例对象weakRp; + * -#step2:新建一个ThreadRf线程,并开启此线程; + * -#step3:让当前线程休眠2000ms; + * -#step4:经判断得出weakRp.get()的返回值为null; + * -#step5:判断rq.poll()的返回值为reference,直至全部判断完成; + *- @Expect: ExpectResult\n + *- @Priority: High + *- @Source: DeadReferenceTest.java + *- @ExecuteClass: DeadReferenceTest + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.*; + +public class DeadReferenceTest { + static int TEST_NUM = 1; + static int judgeNum = 0; + static Reference weakRp; + static ReferenceQueue rq = new ReferenceQueue(); + + public static void main(String[] args) throws Exception { + judgeNum = 0; + for (int i = 0; i < TEST_NUM; i++) { + deadReferenceTest(); + } + if (judgeNum == 0) { + System.out.println("ExpectResult"); + } + } + + static void setWeakRef() { + weakRp = new WeakReference(null, rq); + } + + static void deadReferenceTest() throws InterruptedException { + Reference reference; + + setWeakRef(); + new Thread(new ThreadRf()).start(); + Thread.sleep(2000); + if (weakRp.get() != null) { + judgeNum++; + } + while ((reference = rq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.WeakReference")) { + judgeNum++; + } + } + } +} + +class ThreadRf implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + WeakReference wr = new WeakReference(new Object()); + try { + Thread.sleep(100); + } catch (Exception e) { + System.out.println(" sleep was Interrupted"); + } + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0349-rc-rp-simpleweakref_02/IsCleanerInDeadCycle.java b/test/testsuite/ouroboros/rc_test/RC0349-rc-rp-simpleweakref_02/IsCleanerInDeadCycle.java new file mode 100755 index 0000000000000000000000000000000000000000..76e8a7a496c2efe1a60d367dd0ef1a29d407b53d --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0349-rc-rp-simpleweakref_02/IsCleanerInDeadCycle.java @@ -0,0 +1,141 @@ +/* + *- @TestCaseID: RefProCase/RefProcessor/src/IsCleanerInDeadCycle.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: RefProcessor testcase: 处理对象为cleaner对象,且在一个不可达的环中 + *- @Condition: no + *- @Brief:functionTest + * -#step1:分别创建Cycle_BDec_00010_A1_Cleaner类的实例对象cycleBA1,InCycle类的实例对象cycleA; + * -#step2:调用System.gc()进行垃圾回收; + * -#step3:以cycleBA1为参数,执行cycleA的setCleanerCycle()方法,并记其返回值为result; + * -#step4:创建一个Cycle_BDec_00010_A2_Cleaner的实例对象cycleBA2,并令cycleBA1.cycleBA2和cycleBA1均为null; + * -#step5:经判断得知result为true,并令当前线程休眠2000ms,并判断得出cycleBA1.cleaner、cycleBA1.cycleBA2.cleaner、 + * cycleBA1、cycleBA1.cycleBA2至少有一个为null; + * -#step6:调用Runtime.getRuntime().gc()进行垃圾回收; + * -#step7:重复步骤1~5; + *- @Expect: ExpectResult\n + *- @Priority: High + *- @Source: IsCleanerInDeadCycle.java + *- @ExecuteClass: IsCleanerInDeadCycle + *- @ExecuteArgs: + *- @Remark: + */ + +import sun.misc.Cleaner; + +public class IsCleanerInDeadCycle { + static int TEST_NUM = 1; + static int judgeNum = 0; + + public static void main(String[] args) throws Exception { + judgeNum = 0; + for (int i = 0; i < TEST_NUM; i++) { + isCleanerInDeadCycle(); + Runtime.getRuntime().gc(); + isCleanerInDeadCycle(); + } + if (judgeNum == 0) { + System.out.println("ExpectResult"); + } + } + + static void isCleanerInDeadCycle() throws InterruptedException { + judgeNum = 0; + Cycle_BDec_00010_A1_Cleaner cycleBA1 = new Cycle_BDec_00010_A1_Cleaner(); + InCycle cycleA = new InCycle(); + System.gc(); + boolean result = cycleA.setCleanerCycle(cycleBA1); + cycleBA1.cycleBA2 = null; + cycleBA1 = null; + if (result == true) { + Thread.sleep(2000); + if (cycleBA1.cleaner == null || cycleBA1.cycleBA2.cleaner == null) { + } else { + judgeNum++; + } + } else { + judgeNum++; + } + } +} + +class Cycle_BDec_00010_A1_Cleaner { + static Cleaner cleaner; + Cycle_BDec_00010_A2_Cleaner cycleBA2; + int num; + int sum; + static int value; + + Cycle_BDec_00010_A1_Cleaner() { + cleaner.create(cycleBA2, null); + cycleBA2 = null; + num = 1; + sum = 0; + value = 100; + } + + void add() { + sum = num + cycleBA2.num; + } +} + +class Cycle_BDec_00010_A2_Cleaner { + Cleaner cleaner; + Cycle_BDec_00010_A1_Cleaner cycleBA1Cleaner; + int num; + int sum; + static int value; + + Cycle_BDec_00010_A2_Cleaner() { + cleaner.create(cycleBA1Cleaner, null); + cycleBA1Cleaner = null; + num = 2; + sum = 0; + value = 100; + } + + void add() { + sum = num + cycleBA1Cleaner.num; + } +} + +class InCycle { + /** + * 确认环是正确的 + * + * @param cycleBDA 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + public static boolean ModifyCleanerA1(Cycle_BDec_00010_A1_Cleaner cycleBDA) { + cycleBDA.add(); + cycleBDA.cycleBA2.add(); + int nSum = cycleBDA.sum + cycleBDA.cycleBA2.sum; + if (nSum == 6) { + return true; + } else { + return false; + } + } + + /** + * 设置一个带Cleaner的环 + * + * @param cycleBDA1Cleaner 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + public static boolean setCleanerCycle(Cycle_BDec_00010_A1_Cleaner cycleBDA1Cleaner) { + cycleBDA1Cleaner.cycleBA2 = new Cycle_BDec_00010_A2_Cleaner(); + cycleBDA1Cleaner.cycleBA2.cycleBA1Cleaner = cycleBDA1Cleaner; + boolean ret; + ret = ModifyCleanerA1(cycleBDA1Cleaner); + // 环正确,且reference都没释放 + if (ret == true && cycleBDA1Cleaner.cleaner == null && cycleBDA1Cleaner.cycleBA2.cleaner == null + && cycleBDA1Cleaner != null && cycleBDA1Cleaner.cycleBA2 != null) { + return true; + } else { + return false; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0350-rc-rp-simpleweakref_03/IsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB.java b/test/testsuite/ouroboros/rc_test/RC0350-rc-rp-simpleweakref_03/IsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB.java new file mode 100755 index 0000000000000000000000000000000000000000..1da0252daa59cb385442725b400987bd1585f3fa --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0350-rc-rp-simpleweakref_03/IsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB.java @@ -0,0 +1,419 @@ +/* + *- @TestCaseID: RefProCase/RefProcessor/src/IsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: RefProcessor basic testcase: cleaner对象,在可达的环中,referent没有释放,无法设置WCB, + * 无法atomic设置WCB,环变成不可达 + *- @Condition: no + *- @Brief:functionTest + * -#step1: 分别创建Cycle_BDec_00010_A1_Cleaner类、InCycle类的实例对象cycleBDA1Cleaner、cycleA; + * -#step2: 以cycleBDA1为参数,执行cycleA的setCleanerCycle()方法,并记返回值为result; + * -#step3: 调用Runtime.getRuntime().gc()进行垃圾回收; + * -#step4: 经判断得知result为true,并对cycleBDA1Cleaner对象清除软引用、弱引用、NoFinalizePhantomReference、 + * FinalizePhantomReference、FinalizeCleaner、NoFinalizeCleaner,并且都返回true,证明都清除成功; + * -#step5: 调用Runtime.getRuntime().gc()进行垃圾回收; + * -#step6: 重复步骤1~5; + *- @Expect: ExpectResult\n + *- @Priority: High + *- @Source: IsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB.java + *- @ExecuteClass: IsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB + *- @ExecuteArgs: + *- @Remark: + */ + +import sun.misc.Cleaner; + +import java.lang.ref.*; + +public class IsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB { + static int TEST_NUM = 1; + static int judgeNum = 0; + + public static void main(String[] args) throws Throwable { + judgeNum = 0; + for (int i = 0; i < TEST_NUM; i++) { + isCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB(); + Runtime.getRuntime().gc(); + isCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB(); + } + if (judgeNum == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("error,judgeNum:" + judgeNum); + } + } + + static boolean resultSetCycle(Cycle_BDec_00010_A1_Cleaner cycleBDA1) { + InCycle cycleA = new InCycle(); + boolean result = cycleA.setCleanerCycle(cycleBDA1); + Runtime.getRuntime().gc(); + return result; + } + + static void isCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB() throws Throwable { + Cycle_BDec_00010_A1_Cleaner cycleBDA1Cleaner = new Cycle_BDec_00010_A1_Cleaner(); + boolean result = resultSetCycle(cycleBDA1Cleaner); + if (result == true) { + cycleBDA1Cleaner.cycleBDA2Cleaner = null; + cycleBDA1Cleaner = null; + if (result == true) { + if (cycleBDA1Cleaner.clearSoftReference() == true) { + if (cycleBDA1Cleaner.clearWeakReference() == true) { + if (cycleBDA1Cleaner.clearFinalizePhantomReference() == true) { + if (cycleBDA1Cleaner.clearNoFinalizePhantomReference() == true) { + if (cycleBDA1Cleaner.clearFinalizeCleaner() == true) { + if (cycleBDA1Cleaner.clearNoFinalizeCleaner() == true) { + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearNoFinalizeCleaner--------------" + + "isCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " " + + "ErrorResult in clearFinalizeCleaner------------------" + + "isCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " " + + "ErrorResult in clearNoFinalizePhantomReference---------------" + + "isCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearFinalizePhantomReference-----------------------" + + "isCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ErrorResult " + + "in clearWeakReference------------------" + + "isCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ErrorResult in " + + "clearSoftReference-----------------isCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ErrorResult in " + + "isCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } + } +} + +class Cycle_BDec_00010_A1_Cleaner { + static Cleaner cleaner; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A2_Cleaner cycleBDA2Cleaner; + int num; + int sum; + static int value; + + Cycle_BDec_00010_A1_Cleaner() { + cleaner.create(cycleBDA2Cleaner, null); + cycleBDA2Cleaner = null; + num = 1; + sum = 0; + value = 100; + } + + void add() { + sum = num + cycleBDA2Cleaner.num; + } + + /** + * 设置软引用,clear and enqueue + */ + static Reference srp, wrp, prp; + static ReferenceQueue srq = new ReferenceQueue(); + static ReferenceQueue wrq = new ReferenceQueue(); + static ReferenceQueue prq = new ReferenceQueue(); + static ReferenceQueue crq = new ReferenceQueue(); + static StringBuffer stringBuffer1 = new StringBuffer("soft"); + static StringBuffer stringBuffer2 = new StringBuffer("weak"); + static StringBuffer stringBuffer3 = new StringBuffer("phantom"); + + static void setSoftReference() { + stringBuffer1 = new StringBuffer("soft"); + srp = new WeakReference(stringBuffer1, srq); + if (srp.get() == null) { + value++; + } + stringBuffer1 = null; + } + + static boolean clearSoftReference() throws InterruptedException { + int value = 100; + Reference r; + setSoftReference(); + new Thread(new ThreadRf()).start(); + System.gc(); + Thread.sleep(2000); + // 释放,应该为空 + if (srp.get() != null) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " --------------------" + + "srp.get():" + srp.get()); + value++; + } + while ((r = srq.poll()) != null) { + if (!r.getClass().toString().equals("class java.lang.ref.WeakReference")) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " --------------------" + + "srp.while"); + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + + /** + * 设置弱引用, clear and enqueue + */ + static void setWeakReference() { + stringBuffer2 = new StringBuffer("weak"); + wrp = new WeakReference(stringBuffer2, wrq); + if (wrp.get() == null) { + value++; + } + stringBuffer2 = null; + } + + static boolean clearWeakReference() throws InterruptedException { + value = 100; + Reference reference; + setWeakReference(); + new Thread(new ThreadRf()).start(); + System.gc(); + Thread.sleep(2000); + // 释放,应该为空 + if (wrp.get() != null) { + value++; + } + while ((reference = wrq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.WeakReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + + /** + * 设置虚引用, 没有Referent finalized,clear and enqueue + */ + static void setPhantomReference() { + stringBuffer3 = new StringBuffer("phantom"); + prp = new PhantomReference(stringBuffer3, prq); + if (prp.get() != null) { + value++; + } + stringBuffer3 = null; + } + + static boolean clearNoFinalizePhantomReference() throws InterruptedException { + value = 100; + Reference reference; + setPhantomReference(); + new Thread(new ThreadRf()).start(); + Thread.sleep(2000); + while ((reference = prq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + + /** + * 设置虚引用, 经过Referent finalized,clear and enqueue + */ + static boolean clearFinalizePhantomReference() throws Throwable { + value = 100; + int valueFinal = finalSet(); + Runtime.getRuntime().gc(); + valueFinal = finalSet(); + Reference reference; + setPhantomReference(); + + Thread.sleep(5000); + if (valueFinal == 200) { + value = value + 100; + } + while ((reference = prq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + value++; + } + } + if (value == 200) { + return true; + } else { + return false; + } + } + + /** + * 设置cleaner, 没有Referent finalized,clear and enqueue + */ + static void setCleaner() { + Cleaner crp = null; + String str = new String("test"); + crp.create(str, null); + try { + if (crp.get() != null) { + value++; + } + } catch (NullPointerException e) { + } + } + + static boolean clearNoFinalizeCleaner() throws InterruptedException { + Reference reference; + value = 100; + setCleaner(); + new Thread(new ThreadRf()).start(); + Thread.sleep(2000); + while ((reference = crq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.Cleaner")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + + /** + * 设置cleaner, 经过Referent finalized,clear and enqueue + */ + static int finalSet() { + RC_Finalize testClass1 = new RC_Finalize(); + System.runFinalization(); + return testClass1.value; + } + + static boolean clearFinalizeCleaner() throws InterruptedException { + Reference reference; + value = 100; + int finalValue = finalSet(); + Runtime.getRuntime().gc(); + if (finalValue == 200) { + value = value + 100; + } + setCleaner(); + // 初次调用, Cleaner即为空 + new Thread(new ThreadRf()).start(); + Thread.sleep(2000); + while ((reference = rq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.Cleaner")) { + value++; + } + } + if (value == 200) { + return true; + } else { + return false; + } + } +} + +class InCycle { + /** + * 确认环是正确的 + * + * @param cycleB 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + public static boolean ModifyCleanerA1(Cycle_BDec_00010_A1_Cleaner cycleB) { + cycleB.add(); + cycleB.cycleBDA2Cleaner.add(); + int nSum = cycleB.sum + cycleB.cycleBDA2Cleaner.sum; + if (nSum == 6) { + return true; + } else { + return false; + } + } + + /** + * 设置一个带Cleaner的环 + * + * @param cycleBDA1Cleaner 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + public static boolean setCleanerCycle(Cycle_BDec_00010_A1_Cleaner cycleBDA1Cleaner) { + cycleBDA1Cleaner.cycleBDA2Cleaner = new Cycle_BDec_00010_A2_Cleaner(); + cycleBDA1Cleaner.cycleBDA2Cleaner.cycleBD = cycleBDA1Cleaner; + boolean ret; + ret = ModifyCleanerA1(cycleBDA1Cleaner); + // 环正确,且reference都没释放 + if (ret == true && cycleBDA1Cleaner.cleaner == null && cycleBDA1Cleaner.cycleBDA2Cleaner.cleaner == null + && cycleBDA1Cleaner != null && cycleBDA1Cleaner.cycleBDA2Cleaner != null) { + return true; + } else { + return false; + } + } +} + +class Cycle_BDec_00010_A2_Cleaner { + Cleaner cleaner; + Cycle_BDec_00010_A1_Cleaner cycleBD; + int num; + int sum; + static int value; + + Cycle_BDec_00010_A2_Cleaner() { + cleaner.create(cycleBD, null); + cycleBD = null; + num = 2; + sum = 0; + value = 100; + } + + void add() { + sum = num + cycleBD.num; + } +} + +class RC_Finalize { + static int value = 0; + + protected void finalize() throws Throwable { + super.finalize(); + value = 200; + } +} + +class ThreadRf implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + WeakReference wr = new WeakReference(new Object()); + try { + Thread.sleep(100); + } catch (Exception e) { + System.out.println(" sleep was Interrupted"); + } + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0351-rc-rp-simpleweakref_04/IsCleanerNotInDeadCycleFreeRef.java b/test/testsuite/ouroboros/rc_test/RC0351-rc-rp-simpleweakref_04/IsCleanerNotInDeadCycleFreeRef.java new file mode 100755 index 0000000000000000000000000000000000000000..c959a641fc77aad382e95e99e1d0b138d0f6b827 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0351-rc-rp-simpleweakref_04/IsCleanerNotInDeadCycleFreeRef.java @@ -0,0 +1,151 @@ +/* + *- @TestCaseID: RefProCase/RefProcessor/src/IsCleanerNotInDeadCycleFreeRef.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: RefProcessor basic testcase:在一个对象是cleaner的环中释放reference + *- @Condition: no + *- @Brief:functionTest + * -#step1: 分别创建Cycle_BDec_00010_A1_Cleaner类的实例对象cycleBDA1Cleaner,InCycle类的实例对象cycleA; + * -#step2: 调用System.gc()进行垃圾回收; + * -#step3: 以cycleBDA1Cleaner为参数,执行cycleA的setCleanerCycle()方法,并记其返回值为result; + * -#step4: 令cycleBDA1Cleaner.cycleBDA2Cleaner的值为null,经判断result为true,并让当前线程休眠2000ms; + * -#step5: 经判断,cycleBDA1Cleaner.cleaner为null、cycleBDA1Cleaner.cycleBDA2Cleaner.cleaner为null、cycleBDA1Cleaner + * 不为null这三个条件至少有一个为真; + * -#step6: 创建一个ReferenceQueue类的实例对象rq,并且通过cycleBDA1Cleaner.rq.poll()方法返回的cleaner对象等于null; + * -#step7: 调用Runtime.getRuntime().gc()进行垃圾回收; + * -#step8: 重复步骤1~6; + *- @Expect: ExpectResult\n + *- @Priority: High + *- @Source: IsCleanerNotInDeadCycleFreeRef.java + *- @ExecuteClass: IsCleanerNotInDeadCycleFreeRef + *- @ExecuteArgs: + *- @Remark: + */ + +import sun.misc.Cleaner; + +import java.lang.ref.*; + +public class IsCleanerNotInDeadCycleFreeRef { + static int TEST_NUM = 1; + static int judgeNum = 0; + + public static void main(String[] args) throws Exception { + judgeNum = 0; + for (int i = 0; i < TEST_NUM; i++) { + isCleanerNotInDeadCycleFreeRef(); + Runtime.getRuntime().gc(); + isCleanerNotInDeadCycleFreeRef(); + } + if (judgeNum == 0) { + System.out.println("ExpectResult"); + } + } + + static void isCleanerNotInDeadCycleFreeRef() throws InterruptedException { + Cleaner cleaner; + Cycle_BDec_00010_A1_Cleaner cycleBDA1Cleaner = new Cycle_BDec_00010_A1_Cleaner(); + InCycle cycleA = new InCycle(); + System.gc(); + boolean result = cycleA.setCleanerCycle(cycleBDA1Cleaner); + cycleBDA1Cleaner.cycleBDA2Cleaner = null; + if (result == true) { + Thread.sleep(2000); + if ((cycleBDA1Cleaner.cleaner == null) || (cycleBDA1Cleaner.cycleBDA2Cleaner.cleaner == null) + || (cycleBDA1Cleaner != null)) { + while ((cleaner = (Cleaner) cycleBDA1Cleaner.rq.poll()) != null) { + if (!cleaner.getClass().toString().equals("class sun.misc.Cleaner")) { + judgeNum++; + } + } + } else { + judgeNum++; + } + } else { + judgeNum++; + } + } +} + +class Cycle_BDec_00010_A1_Cleaner { + static Cleaner cleaner; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A2_Cleaner cycleBDA2Cleaner; + int num; + int sum; + static int value; + + Cycle_BDec_00010_A1_Cleaner() { + cleaner.create(cycleBDA2Cleaner, null); + cycleBDA2Cleaner = null; + num = 1; + sum = 0; + value = 100; + } + + void add() { + sum = num + cycleBDA2Cleaner.num; + } +} + +class Cycle_BDec_00010_A2_Cleaner { + Cleaner cleaner; + Cycle_BDec_00010_A1_Cleaner cycleBDA1; + int num; + int sum; + static int value; + + Cycle_BDec_00010_A2_Cleaner() { + cleaner.create(cycleBDA1, null); + cycleBDA1 = null; + num = 2; + sum = 0; + value = 100; + } + + void add() { + sum = num + cycleBDA1.num; + } +} + +class InCycle { + /** + * 确认环是正确的 + * + * @param cycleBD 传入的是带有Referent的类实例 + * @return 传入的是带有Referent的类实例 + */ + public static boolean ModifyCleanerA1(Cycle_BDec_00010_A1_Cleaner cycleBD) { + cycleBD.add(); + cycleBD.cycleBDA2Cleaner.add(); + int nSum = cycleBD.sum + cycleBD.cycleBDA2Cleaner.sum; + if (nSum == 6) { + return true; + } else { + return false; + } + } + + /** + * 设置一个带Cleaner的环 + * + * @param cycleB + * @return + */ + public static boolean setCleanerCycle(Cycle_BDec_00010_A1_Cleaner cycleB) { + cycleB.cycleBDA2Cleaner = new Cycle_BDec_00010_A2_Cleaner(); + cycleB.cycleBDA2Cleaner.cycleBDA1 = cycleB; + boolean ret; + ret = ModifyCleanerA1(cycleB); + // 环正确,且reference都没释放 + if (ret == true && cycleB.cleaner == null && cycleB.cycleBDA2Cleaner.cleaner == null && cycleB != null + && cycleB.cycleBDA2Cleaner != null) { + return true; + } else { + return false; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0352-rc-rp-simpleweakref_05/IsCleanerNotInDeadCycleNotFreeRefFailSetWCBSetAtomicWCB.java b/test/testsuite/ouroboros/rc_test/RC0352-rc-rp-simpleweakref_05/IsCleanerNotInDeadCycleNotFreeRefFailSetWCBSetAtomicWCB.java new file mode 100755 index 0000000000000000000000000000000000000000..788f383ad225222acdafc94aa7d26ea50bece9a2 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0352-rc-rp-simpleweakref_05/IsCleanerNotInDeadCycleNotFreeRefFailSetWCBSetAtomicWCB.java @@ -0,0 +1,468 @@ +/* + *- @TestCaseID: RefProCase/RefProcessor/src/IsCleanerNotInDeadCycleNotFreeRefFailSetWCBSetAtomicWCB.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: RefProcessor basic testcase: 不是死对象,是cleaner对象,在可达的环中,referent没有释放, + * 没有设置WCB,atomic设置WCB,线程处理,一个线程负责Referent的释放,另外一个负责相关设置 + *- @Condition: no + *- @Brief:functionTest + * -#step1: 创建一个SetReferentNull类的实例对象setReferentNull,分别创建Cycle_BDec_00010_A1_Cleaner类、 + * Cycle_BDec_00010_A2_Cleaner类的实例对象a1_cleaner、a2_cleaner,并设初值为null; + * -#step2: 创建一个IsCleanerNotInDeadCycleNotFreeRefFailSetWCB类的实例对象isCleanerNotInDeadCycleNotFreeRefFailSetWCB, + * 并令其执行所属类的run()方法; + * -#step3: 创建Cycle_BDec_00010_A1_Cleaner类的实例对象cycleB,以cycleB为参数,执行resultSetCycle()方法,即创建一个 + * InCycle类的实例对象cycleA,以cycleBDA为参数,执行cycleA的setCleanerCycle()方法,并得其返回值为result; + * -#step4: 调用Runtime.getRuntime().gc()进行垃圾回收; + * -#step5: 经判断得知result为true,并且cycleB在执行clearSoftReference()方法时返回false,并将返回值赋值给check,由此得知 + * 此处清除软引用失败; + * -#step6: 因check的值为false,则将judgeNum的值加1; + * -#step7: 调用Runtime.getRuntime().gc()进行垃圾回收; + * -#step8: 重复步骤1~6; + *- @Expect: ExpectResult\n + *- @Priority: High + *- @Source: IsCleanerNotInDeadCycleNotFreeRefFailSetWCBSetAtomicWCB.java + *- @ExecuteClass: IsCleanerNotInDeadCycleNotFreeRefFailSetWCBSetAtomicWCB + *- @ExecuteArgs: + *- @Remark: + */ + +import sun.misc.Cleaner; + +import java.io.PrintStream; +import java.lang.ref.*; + +public class IsCleanerNotInDeadCycleNotFreeRefFailSetWCBSetAtomicWCB { + static int TEST_NUM = 1; + static int judgeNum = 0; + + public static void main(String[] args) throws Exception { + judgeNum = 0; + for (int i = 0; i < TEST_NUM; i++) { + isCleanerNotInDeadCycleNotFreeRefFailSetWCBSetAtomicWCB(); + Runtime.getRuntime().gc(); + isCleanerNotInDeadCycleNotFreeRefFailSetWCBSetAtomicWCB(); + } + if (judgeNum == 0) { + System.out.println("ExpectResult"); + } + } + + static void isCleanerNotInDeadCycleNotFreeRefFailSetWCBSetAtomicWCB() throws Exception { + SetReferentNull setReferentNull = new SetReferentNull(); + setReferentNull.run(); + IsCleanerNotInDeadCycleNotFreeRefFailSetWCB isCleanerNotInDeadCycleNotFreeRefFailSetWCB = + new IsCleanerNotInDeadCycleNotFreeRefFailSetWCB(); + isCleanerNotInDeadCycleNotFreeRefFailSetWCB.run(); + if (isCleanerNotInDeadCycleNotFreeRefFailSetWCB.check == false) { + judgeNum++; + } + } +} + +class SetReferentNull implements Runnable { + Cycle_BDec_00010_A1_Cleaner a1_cleaner; + Cycle_BDec_00010_A2_Cleaner a2_cleaner; + + @Override + public void run() { + a2_cleaner = null; + a1_cleaner = null; + } +} + +class IsCleanerNotInDeadCycleNotFreeRefFailSetWCB implements Runnable { + boolean check; + + @Override + public void run() { + check = isCleanerNotInDeadCycleNotFreeRefFailSetWCB(); + } + + static boolean resultSetCycle(Cycle_BDec_00010_A1_Cleaner cycleBDA) { + InCycle cycleA = new InCycle(); + boolean result = cycleA.setCleanerCycle(cycleBDA); + Runtime.getRuntime().gc(); + return result; + } + + public boolean isCleanerNotInDeadCycleNotFreeRefFailSetWCB() { + Cycle_BDec_00010_A1_Cleaner cycleB = new Cycle_BDec_00010_A1_Cleaner(); + boolean result = resultSetCycle(cycleB); + if (result == true) { + try { + if (result == true) { + if (cycleB.clearSoftReference() == true) { + if (cycleB.clearWeakReference() == true) { + if (cycleB.clearFinalizePhantomReference() == true) { + if (cycleB.clearNoFinalizePhantomReference() == true) { + if (cycleB.clearFinalizeCleaner() == true) { + if (cycleB.clearNoFinalizeCleaner() == true) { + return true; + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearNoFinalizeCleaner"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearFinalizeCleaner"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearNoFinalizePhantomReference"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearFinalizePhantomReference"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearWeakReference"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearSoftReference"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in NotIsCleanerNotInDeadCycleNotFreeRef"); + return false; + } + } catch (Exception e) { + return false; + } + } else { + return false; + } + } +} + +class InCycle { + /** + * 确认环是正确的 + * + * @param cycleBDA1Cleaner 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + public static boolean ModifyCleanerA1(Cycle_BDec_00010_A1_Cleaner cycleBDA1Cleaner) { + cycleBDA1Cleaner.add(); + cycleBDA1Cleaner.cycleBDA2Cleaner.add(); + int nsum = cycleBDA1Cleaner.sum + cycleBDA1Cleaner.cycleBDA2Cleaner.sum; + if (nsum == 6) return true; + else return false; + } + + /** + * 设置一个带Cleaner的环 + * + * @param cycleBDA1 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + public static boolean setCleanerCycle(Cycle_BDec_00010_A1_Cleaner cycleBDA1) { + cycleBDA1.cycleBDA2Cleaner = new Cycle_BDec_00010_A2_Cleaner(); + cycleBDA1.cycleBDA2Cleaner.cycleBD = cycleBDA1; + boolean ret; + + ret = ModifyCleanerA1(cycleBDA1); + // 环正确,且reference都没释放 + if (ret == true && cycleBDA1.cleaner == null && cycleBDA1.cycleBDA2Cleaner.cleaner == null + && cycleBDA1 != null && cycleBDA1.cycleBDA2Cleaner != null) { + return true; + } else { + return false; + } + } +} + +class Cycle_BDec_00010_A2_Cleaner { + Cleaner cleaner; + Cycle_BDec_00010_A1_Cleaner cycleBD; + int num; + int sum; + static int value; + + Cycle_BDec_00010_A2_Cleaner() { + cleaner.create(cycleBD, null); + cycleBD = null; + num = 2; + sum = 0; + value = 100; + } + + void add() { + sum = num + cycleBD.num; + } +} + +class Cycle_BDec_00010_A1_Cleaner { + static Cleaner cleaner; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A2_Cleaner cycleBDA2Cleaner; + int num; + int sum; + static int value; + + Cycle_BDec_00010_A1_Cleaner() { + cleaner.create(cycleBDA2Cleaner, null); + cycleBDA2Cleaner = null; + num = 1; + sum = 0; + value = 100; + } + + void add() { + sum = num + cycleBDA2Cleaner.num; + } + + /** + * 设置软引用,clear and enqueue + */ + static Reference srp, wrp, prp, crp; + static ReferenceQueue srq = new ReferenceQueue(); + static ReferenceQueue wrq = new ReferenceQueue(); + static ReferenceQueue prq = new ReferenceQueue(); + static ReferenceQueue crq = new ReferenceQueue(); + static StringBuffer stringBuffer1 = new StringBuffer("soft"); + static StringBuffer stringBuffer2 = new StringBuffer("weak"); + static StringBuffer stringBuffer3 = new StringBuffer("phantom"); + + static void setSoftReference() { + stringBuffer1 = new StringBuffer("soft"); + srp = new WeakReference(stringBuffer1, srq); + if (srp.get() == null) { + value++; + } + stringBuffer1 = null; + } + + static boolean clearSoftReference() throws InterruptedException { + int value = 100; + Reference r; + setSoftReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + // 释放,应该为空 + if (srp.get() != null) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " --------------------" + + "srp.get():" + srp.get()); + value++; + } + while ((r = srq.poll()) != null) { + if (!r.getClass().toString().equals("class java.lang.ref.WeakReference")) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " --------------------" + + "srp.while"); + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + + /** + * 设置弱引用, clear and enqueue + */ + static void setWeakReference() { + stringBuffer2 = new StringBuffer("weak"); + wrp = new WeakReference(stringBuffer2, wrq); + if (wrp.get() == null) { + value++; + } + stringBuffer2 = null; + } + + static boolean clearWeakReference() throws InterruptedException { + value = 100; + Reference reference; + setWeakReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + // 释放,应该为空 + if (wrp.get() != null) { + value++; + } + while ((reference = wrq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.WeakReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + + /** + * 设置虚引用, 没有Referent finalized,clear and enqueue + */ + static void setPhantomReference() { + stringBuffer3 = new StringBuffer("phantom"); + prp = new PhantomReference(stringBuffer3, prq); + if (prp.get() != null) { + value++; + } + stringBuffer3 = null; + } + + static boolean clearNoFinalizePhantomReference() throws InterruptedException { + value = 100; + Reference reference; + setPhantomReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + while ((reference = prq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + + static int finalSet() { + RC_Finalize testClass1 = new RC_Finalize(); + System.runFinalization(); + return testClass1.value; + } + + /** + * 设置虚引用,经过Referent finalized,clear and enqueue + */ + static boolean clearFinalizePhantomReference() throws InterruptedException { + value = 100; + int valueFinal = finalSet(); + Runtime.getRuntime().gc(); + valueFinal = finalSet(); + + Reference reference; + setPhantomReference(); + Thread.sleep(5000); + if (valueFinal == 200) { + value = value + 100; + } + while ((reference = prq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + value++; + } + } + if (value == 200) { + return true; + } else { + return false; + } + } + + /** + * 设置cleaner,没有Referent finalized,clear and enqueue + */ + static void setCleaner() { + Cleaner crp = null; + StringBuffer stringBuffer = new StringBuffer("test"); + crp.create(stringBuffer, null); + try { + if (crp.get() != null) { + value++; + } + } catch (NullPointerException e) { + e.printStackTrace(); + } + } + + static boolean clearNoFinalizeCleaner() throws InterruptedException { + Reference reference; + value = 100; + setCleaner(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + while ((reference = crq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.Cleaner")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + + /** + * 设置cleaner,经过Referent finalized,clear and enqueue + */ + static boolean clearFinalizeCleaner() throws InterruptedException { + Reference reference; + value = 100; + int finalValue = finalSet(); + Runtime.getRuntime().gc(); + if (finalValue == 200) { + value = value + 100; + } + setCleaner(); + // 初次调用,Cleaner即为空 + try { + if (crp.get() != null) { + value++; + } + } catch (NullPointerException e) { + e.printStackTrace(); + } + + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + while ((reference = rq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.Cleaner")) { + value++; + } + } + if (value == 200) { + return true; + } else { + return false; + } + } +} + +class RC_Finalize { + static int value = 0; + + static void rcFinalize() throws InterruptedException { + RC_Finalize rc_finalize = new RC_Finalize(); + Thread.sleep(2000); + System.runFinalization(); + } + + protected void finalize() throws Throwable { + super.finalize(); + value = 200; + } + + public static int run(String argv[], PrintStream out) { + return 0; + } +} + +class ThreadRef implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + WeakReference wr = new WeakReference(new Object()); + try { + Thread.sleep(100); + } catch (Exception e) { + System.out.println(" sleep was Interrupted"); + } + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0353-rc-rp-simpleweakref_06/IsCleanerNotInDeadCycleNotFreeRefSetWCB.java b/test/testsuite/ouroboros/rc_test/RC0353-rc-rp-simpleweakref_06/IsCleanerNotInDeadCycleNotFreeRefSetWCB.java new file mode 100755 index 0000000000000000000000000000000000000000..175270aca0213e87af3c4b38609cd7a7f3650c4f --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0353-rc-rp-simpleweakref_06/IsCleanerNotInDeadCycleNotFreeRefSetWCB.java @@ -0,0 +1,419 @@ +/* + *- @TestCaseID: RefProCase/RefProcessor/src/IsCleanerNotInDeadCycleNotFreeRefSetWCB.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: RefProcessor basic testcase:构建可达的环,为cleaner对象,不释放对象,设置WCB + *- @Condition: no + *- @Brief:functionTest + * -#step1: 创建一个Cycle_BDec_00010_A1_Cleaner类的实例对象cycleBDA1Cleaner,以cycleBDA1Cleaner为参数,执行 + * resultSetCycle()方法 ,即创建一个InCycle类的实例对象cycleA,以Cycle_BDec_00010_A1_Cleaner类的实例对象 + * cycleBDA为参数,执行cycleA的setCleanerCycle()方法,得到返回值result; + * -#step2: 调用Runtime.getRuntime().gc()执行垃圾回收; + * -#step3: 令cycleBDA1Cleaner.cycleBDA2Cleaner的值为null; + * -#step4: 经判断得知result为true,并且cycleBDA1Cleaner在执行clearSoftReference()方法时返回为false,得知 + * cycleBDA1Cleaner在清除软引用时失败; + * -#step5: 调用Runtime.getRuntime().gc()进行垃圾回收; + * -#step6: 重复步骤1~4; + *- @Expect: ExpectResult\n + *- @Priority: High + *- @Source: IsCleanerNotInDeadCycleNotFreeRefSetWCB.java + *- @ExecuteClass: IsCleanerNotInDeadCycleNotFreeRefSetWCB + *- @ExecuteArgs: + *- @Remark: + */ + +import sun.misc.Cleaner; + +import java.lang.ref.*; + +public class IsCleanerNotInDeadCycleNotFreeRefSetWCB { + static int TEST_NUM = 1; + static int judgeNum = 0; + + public static void main(String[] args) throws Exception { + judgeNum = 0; + for (int i = 0; i < TEST_NUM; i++) { + isCleanerNotInDeadCycleNotFreeRefSetWCB(); + Runtime.getRuntime().gc(); + isCleanerNotInDeadCycleNotFreeRefSetWCB(); + } + if (judgeNum == 0) { + System.out.println("ExpectResult"); + } + } + + static boolean resultSetCycle(Cycle_BDec_00010_A1_Cleaner cycleBDA) { + InCycle cycleA = new InCycle(); + boolean result = cycleA.setCleanerCycle(cycleBDA); + Runtime.getRuntime().gc(); + return result; + } + + static void isCleanerNotInDeadCycleNotFreeRefSetWCB() throws InterruptedException { + Cycle_BDec_00010_A1_Cleaner cycleBDA1Cleaner = new Cycle_BDec_00010_A1_Cleaner(); + boolean result = resultSetCycle(cycleBDA1Cleaner); + cycleBDA1Cleaner.cycleBDA2Cleaner = null; + + if (result == true) { + if (cycleBDA1Cleaner.clearSoftReference() == true) { + if (cycleBDA1Cleaner.clearWeakReference() == true) { + if (cycleBDA1Cleaner.clearFinalizePhantomReference() == true) { + if (cycleBDA1Cleaner.clearNoFinalizePhantomReference() == true) { + if (cycleBDA1Cleaner.clearFinalizeCleaner() == true) { + if (cycleBDA1Cleaner.clearNoFinalizeCleaner() == true) { + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearNoFinalizeCleaner------------" + + "isCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearFinalizeCleaner------------" + + "isCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearNoFinalizePhantomReference------------" + + "isCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearFinalizePhantomReference------------" + + "isCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearWeakReference------------isCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearSoftReference------------isCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in isCleanerNotInDeadCycleNotFreeRefSetWCB------------" + + "isCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } +} + +class Cycle_BDec_00010_A2_Cleaner { + Cleaner cleaner; + Cycle_BDec_00010_A1_Cleaner cycleBDA1; + int num; + int sum; + static int value; + + Cycle_BDec_00010_A2_Cleaner() { + cleaner.create(cycleBDA1, null); + cycleBDA1 = null; + num = 2; + sum = 0; + value = 100; + } + + void add() { + sum = num + cycleBDA1.num; + } +} + +class Cycle_BDec_00010_A1_Cleaner { + static Cleaner cleaner; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A2_Cleaner cycleBDA2Cleaner; + int num; + int sum; + static int value; + + Cycle_BDec_00010_A1_Cleaner() { + cleaner.create(cycleBDA2Cleaner, null); + cycleBDA2Cleaner = null; + num = 1; + sum = 0; + value = 100; + } + + void add() { + sum = num + cycleBDA2Cleaner.num; + } + + /** + * 设置软引用,clear and enqueue + */ + static Reference srp, wrp, prp, crp; + static ReferenceQueue srq = new ReferenceQueue(); + static ReferenceQueue wrq = new ReferenceQueue(); + static ReferenceQueue prq = new ReferenceQueue(); + static ReferenceQueue crq = new ReferenceQueue(); + static StringBuffer obj = new StringBuffer("soft"); + static StringBuffer obj1 = new StringBuffer("weak"); + static StringBuffer obj2 = new StringBuffer("phantom"); + + static void setSoftReference() { + obj = new StringBuffer("soft"); + srp = new WeakReference(obj, srq); + if (srp.get() == null) { + value++; + } + obj = null; + } + + static boolean clearSoftReference() throws InterruptedException { + int value = 100; + Reference r; + setSoftReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + // 释放,应该为空 + if (srp.get() != null) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " --------------------srp.get():" + srp.get()); + value++; + } + while ((r = srq.poll()) != null) { + if (!r.getClass().toString().equals("class java.lang.ref.WeakReference")) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " --------------------srp.while"); + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + + /** + * 设置弱引用,clear and enqueue + */ + static void setWeakReference() { + obj1 = new StringBuffer("weak"); + wrp = new WeakReference(obj1, wrq); + if (wrp.get() == null) { + value++; + } + obj1 = null; + } + + static boolean clearWeakReference() throws InterruptedException { + value = 100; + Reference reference; + setWeakReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + // 释放,应该为空 + if (wrp.get() != null) { + value++; + } + while ((reference = wrq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.WeakReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + + /** + * 设置虚引用, 没有Referent finalized,clear and enqueue + */ + static void setPhantomReference() { + prp = new PhantomReference(obj2, prq); + if (prp.get() != null) { + value++; + } + obj2 = null; + } + + static boolean clearNoFinalizePhantomReference() throws InterruptedException { + value = 100; + Reference reference; + setPhantomReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + while ((reference = prq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + + /** + * 设置虚引用, 经过Referent finalized,clear and enqueue + */ + static boolean clearFinalizePhantomReference() throws InterruptedException { + value = 100; + int valueFinal = finalSet(); + Runtime.getRuntime().gc(); + valueFinal = finalSet(); + + Reference reference; + setPhantomReference(); + Thread.sleep(5000); + if (valueFinal == 200) { + value = value + 100; + } + while ((reference = prq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + value++; + } + } + if (value == 200) { + return true; + } else { + return false; + } + } + + /** + * 设置cleaner, 没有Referent finalized,clear and enqueue + */ + static void setCleaner() { + Cleaner crp = null; + StringBuffer str = new StringBuffer("test"); + crp.create(str, null); + try { + if (crp.get() != null) { + value++; + } + } catch (NullPointerException e) { + } + } + + static boolean clearNoFinalizeCleaner() throws InterruptedException { + Reference reference; + value = 100; + setCleaner(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + while ((reference = crq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.Cleaner")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + + static int finalSet() { + RC_Finalize testClass1 = new RC_Finalize(); + System.runFinalization(); + return testClass1.value; + } + + /** + * 设置cleaner, 经过Referent finalized,clear and enqueue + */ + static boolean clearFinalizeCleaner() throws InterruptedException { + Reference reference; + value = 100; + int finalValue = finalSet(); + Runtime.getRuntime().gc(); + if (finalValue == 200) { + value = value + 100; + } + setCleaner(); + // 初次调用, Cleaner即为空 + try { + if (crp.get() != null) { + value++; + } + } catch (NullPointerException e) { + e.printStackTrace(); + } + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + while ((reference = rq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.Cleaner")) { + value++; + } + } + if (value == 200) { + return true; + } else { + return false; + } + } +} + +class InCycle { + /** + * 确认环是正确的 + * + * @param cycleB 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + public static boolean ModifyCleanerA1(Cycle_BDec_00010_A1_Cleaner cycleB) { + cycleB.add(); + cycleB.cycleBDA2Cleaner.add(); + int nSum = cycleB.sum + cycleB.cycleBDA2Cleaner.sum; + if (nSum == 6) { + return true; + } else { + return false; + } + } + + /** + * 设置一个带Cleaner的环 + * + * @param cycleBD 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + public static boolean setCleanerCycle(Cycle_BDec_00010_A1_Cleaner cycleBD) { + cycleBD.cycleBDA2Cleaner = new Cycle_BDec_00010_A2_Cleaner(); + cycleBD.cycleBDA2Cleaner.cycleBDA1 = cycleBD; + boolean ret; + ret = ModifyCleanerA1(cycleBD); + //环正确,且reference都没释放 + if (ret == true && cycleBD.cleaner == null && cycleBD.cycleBDA2Cleaner.cleaner == null + && cycleBD != null && cycleBD.cycleBDA2Cleaner != null) { + return true; + } else { + return false; + } + } +} + +class ThreadRef implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + try { + Thread.sleep(100); + } catch (Exception e) { + e.printStackTrace(); + } + } + } +} + +class RC_Finalize { + static int value = 0; + + protected void finalize() throws Throwable { + super.finalize(); + value = 200; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0354-rc-rp-simpleweakref_07/IsCleanerNotInDeadCycleNotSetWCBFailAtomic.java b/test/testsuite/ouroboros/rc_test/RC0354-rc-rp-simpleweakref_07/IsCleanerNotInDeadCycleNotSetWCBFailAtomic.java new file mode 100755 index 0000000000000000000000000000000000000000..c559aa29c85488d195fd7c2dbbc7ed6e929b791b --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0354-rc-rp-simpleweakref_07/IsCleanerNotInDeadCycleNotSetWCBFailAtomic.java @@ -0,0 +1,139 @@ +/* + *- @TestCaseID: RefProCase/RefProcessor/src/IsCleanerNotInDeadCycleNotSetWCBFailAtomic.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: RefProcessor basic testcase:在可达的环中构造cleaner对象,并不设置WCB。 + *- @Condition: no + *- @Brief:functionTest + * -#step1:创建两个带有Cleaner 对象的class,并相互声明了对方作为自己的Field。 + * -#step2:创建第三个类InCycle,将上两个类连成一个可达的环。 + * -#step3:创建InCycle的实例,调用方法一给第一个类对象关于第二个类的Field初始化对象,再将该对象关于第一个类Field赋值为第一个类, + * 从而形成一个带Cleaner的环。 + * -#step4:方法一调用方法二执行前两个类对象的add方法进行Field的运算,相当于对对象进行了引用,判断运算结果是否正确。 + * -#step5:调用System.gc()进行系统回收,重复步骤4,判断环正确且reference都没释放。 + * -#step6:调用System.gc()进行系统回收,重复步骤3~5。 + * -#step7:调用Runtime.getRuntime().gc()进行系统回收,重复步骤1~6。 + *- @Expect: ExpectResult\n + *- @Priority: High + *- @Source:IsCleanerNotInDeadCycleNotSetWCBFailAtomic.java + *- @ExecuteClass: IsCleanerNotInDeadCycleNotSetWCBFailAtomic + *- @ExecuteArgs: + *- @Remark: + */ + +import sun.misc.Cleaner; + +import java.lang.ref.*; + +public class IsCleanerNotInDeadCycleNotSetWCBFailAtomic { + static int TEST_NUM = 1; + static int judgeNum = 0; + + public static void main(String[] args) throws Exception { + judgeNum = 0; + for (int i = 0; i < TEST_NUM; i++) { + isCleanerNotInDeadCycleNotSetWCBFailAtomic(); + Runtime.getRuntime().gc(); + isCleanerNotInDeadCycleNotSetWCBFailAtomic(); + } + if (judgeNum == 0) { + System.out.println("ExpectResult"); + } + } + + static void isCleanerNotInDeadCycleNotSetWCBFailAtomic() throws InterruptedException { + Cycle_BDec_00010_A1_Cleaner cleanerClass1 = new Cycle_BDec_00010_A1_Cleaner(); + InCycle cycleA = new InCycle(); + cycleA.setCleanerCycle(cleanerClass1); + System.gc(); + boolean result = cycleA.setCleanerCycle(cleanerClass1); + if (result == false) { + judgeNum++; + } + } +} + +class Cycle_BDec_00010_A1_Cleaner { + static Cleaner cleaner; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A2_Cleaner cleanerClass2; + int num; + int sum; + static int value; + + Cycle_BDec_00010_A1_Cleaner() { + cleaner.create(cleanerClass2, null); + cleanerClass2 = null; + num = 1; + sum = 0; + value = 100; + } + + void add() { + sum = num + cleanerClass2.num; + } +} + +class Cycle_BDec_00010_A2_Cleaner { + Cleaner cleaner; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A1_Cleaner cleanerClass1; + int num; + int sum; + static int value; + + Cycle_BDec_00010_A2_Cleaner() { + cleaner.create(cleanerClass1, null); + cleanerClass1 = null; + num = 2; + sum = 0; + value = 100; + } + + void add() { + sum = num + cleanerClass1.num; + } +} + +class InCycle { + /** + * 确认环是正确的 + * + * @param cleaner 传入的是带有Referent的类实例 + * @return 返回布尔值,判断运算的结果正确 + */ + public static boolean ModifyCleanerA1(Cycle_BDec_00010_A1_Cleaner cleaner) { + cleaner.add(); + cleaner.cleanerClass2.add(); + int nSum = cleaner.sum + cleaner.cleanerClass2.sum; + if (nSum == 6) { + return true; + } else { + return false; + } + } + + /** + * 设置一个带Cleaner的环 + * + * @param cleaner 传入的是带有Referent的类实例 + * @return 返回布尔值,判断reference没释放 + */ + public static boolean setCleanerCycle(Cycle_BDec_00010_A1_Cleaner cleaner) { + cleaner.cleanerClass2 = new Cycle_BDec_00010_A2_Cleaner(); + cleaner.cleanerClass2.cleanerClass1 = cleaner; + boolean ret; + ret = ModifyCleanerA1(cleaner); + System.gc(); + ret = ModifyCleanerA1(cleaner); + // 环正确,且reference都没释放 + if (ret == true && cleaner.cleaner == null && cleaner.cleanerClass2.cleaner == null && cleaner != null + && cleaner.cleanerClass2 != null) { + return true; + } else { + return false; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0355-rc-rp-simpleweakref_08/NotIsCleanerNotInDeadCycleNotSetWCBFailAtomic.java b/test/testsuite/ouroboros/rc_test/RC0355-rc-rp-simpleweakref_08/NotIsCleanerNotInDeadCycleNotSetWCBFailAtomic.java new file mode 100755 index 0000000000000000000000000000000000000000..03d772976cd71a9b958a2cf6971344c77812aec9 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0355-rc-rp-simpleweakref_08/NotIsCleanerNotInDeadCycleNotSetWCBFailAtomic.java @@ -0,0 +1,145 @@ +/* + *- @TestCaseID: RefProCase/RefProcessor/src/NotIsCleanerNotInDeadCycleNotSetWCBFailAtomic.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: RefProcessor basic testcase: 在可达的环中,构造对象,不设置WCB + *- @Condition: no + *- @Brief:functionTest + * -#step1:创建两个带有弱引用对象的class,弱引用申请后通过get方法判断非空,并相互声明对方类作为自己的Field。 + * -#step2:创建第三个类InCycle,将上两个类连成一个可达的环。 + * -#step3:创建InCycle的实例,调用方法一给第一个类对象关于第二个类的Field初始化对象,再将该对象关于第一个类Field赋值为第一个类, + * 从而形成一个环。 + * -#step4:方法一调用方法二执行前两个类对象的add方法进行Field的运算,相当于对对象进行了引用,判断运算结果是否正确。 + * -#step5:调用System.gc()进行系统回收,重复步骤3~4。 + * -#step6:调用Runtime.getRuntime().gc()进行系统回收,重复步骤1~5。 + *- @Expect: ExpectResult\n + *- @Priority: High + *- @Source:NotIsCleanerNotInDeadCycleNotSetWCBFailAtomic.java + *- @ExecuteClass: NotIsCleanerNotInDeadCycleNotSetWCBFailAtomic + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.*; + +public class NotIsCleanerNotInDeadCycleNotSetWCBFailAtomic { + static int TEST_NUM = 1; + static int judgeNum = 0; + + public static void main(String[] args) throws Exception { + judgeNum = 0; + for (int i = 0; i < TEST_NUM; i++) { + notIsCleanerNotInDeadCycleNotSetWCBFailAtomic(); + Runtime.getRuntime().gc(); + notIsCleanerNotInDeadCycleNotSetWCBFailAtomic(); + } + if (judgeNum == 0) { + System.out.println("ExpectResult"); + } + } + + static void notIsCleanerNotInDeadCycleNotSetWCBFailAtomic() throws InterruptedException { + Cycle_BDec_00010_A1 cycleMember = new Cycle_BDec_00010_A1(); + InCycle cycleA = new InCycle(); + cycleA.setCycle(cycleMember); + System.gc(); + boolean result = cycleA.setCycle(cycleMember); + if (result == false) { + judgeNum++; + } + } +} + +class Cycle_BDec_00010_A1 { + Reference memberRef1; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A2 partner2; + int num; + int sum; + static int value; + static StringBuffer obj = new StringBuffer("weak"); + + Cycle_BDec_00010_A1() { + obj = new StringBuffer("weak"); + memberRef1 = new WeakReference(obj, rq); + if (memberRef1.get() == null) { + assert false; + } + obj = null; + partner2 = null; + num = 1; + sum = 0; + value = 100; + } + + void add() { + sum = num + partner2.num; + } +} + +class Cycle_BDec_00010_A2 { + Reference memberRef2; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A1 partner1; + int num; + int sum; + static int value; + static StringBuffer obj = new StringBuffer("weak"); + + Cycle_BDec_00010_A2() { + obj = new StringBuffer("weak"); + memberRef2 = new WeakReference(obj, rq); + if (memberRef2.get() == null) { + assert false; + } + obj = null; + partner1 = null; + num = 2; + sum = 0; + value = 100; + } + + void add() { + sum = num + partner1.num; + } +} + +class InCycle { + /** + * 确认环是正确的 + * + * @param refInstance 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + public static boolean ModifyA1(Cycle_BDec_00010_A1 refInstance) { + refInstance.add(); + refInstance.partner2.add(); + int nSum = refInstance.sum + refInstance.partner2.sum; + if (nSum == 6) { + return true; + } else { + return false; + } + } + + /** + * 设置一个带Referent的环 + * + * @param refInstance 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + public static boolean setCycle(Cycle_BDec_00010_A1 refInstance) { + refInstance.partner2 = new Cycle_BDec_00010_A2(); + refInstance.partner2.partner1 = refInstance; + boolean ret; + ret = ModifyA1(refInstance); + if (ret == true) { + return true; + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ret != true"); + return false; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0356-rc-rp-simpleweakref_09/NotIsCleanerNotInDeadCycleNotFreeRefSetWCB.java b/test/testsuite/ouroboros/rc_test/RC0356-rc-rp-simpleweakref_09/NotIsCleanerNotInDeadCycleNotFreeRefSetWCB.java new file mode 100755 index 0000000000000000000000000000000000000000..28f1a6efb4cc29c32b526ccf3a2b77db97b30741 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0356-rc-rp-simpleweakref_09/NotIsCleanerNotInDeadCycleNotFreeRefSetWCB.java @@ -0,0 +1,379 @@ +/* + *- @TestCaseID: RefProCase/RefProcessor/src/NotIsCleanerNotInDeadCycleNotFreeRefSetWCB.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: RefProcessor basic testcase: 在可达的环中,设置非cleaner对象,且不释放对象,之后设置WCB + *- @Condition: no + *- @Brief:functionTest + * -#step1:创建两个带有弱引用对象的class,弱引用申请后通过get方法判断非空,并相互声明对方类作为自己的Field。 + * -#step2:其中class A1会分别对软引用、弱引用、虚引用进行clear和enqueue,其中虚引用分为没有Referent finalized的clear和enqueue + * 和有Referent finalized的clear和enqueue。 + * -#step3:创建第三个类InCycle,将上两个类连成一个可达的环。 + * -#step4:创建InCycle的实例,调用方法setCycle给第一个类对象关于第二个类的Field初始化对象,再将该对象关于第一个类Field赋值为第一 + * 个类,从而形成一个环。 + * -#step5:方法setCycle调用方法ModifyA1执行前两个类对象的add方法进行Field的运算,相当于对对象进行了引用,判断运算结果是否正确。 + * -#step6:确认两个类的软引用、弱引用、虚引用对象为NULL。 + * -#step7:调用Runtime.getRuntime().gc()进行资源回收,重复步骤3~6。 + * -#step8:确认class A1的软引用、弱引用、虚引用都应该为空。 + *- @Expect: ExpectResult\n + *- @Priority: High + *- @Source:NotIsCleanerNotInDeadCycleNotFreeRefSetWCB.java + *- @ExecuteClass: NotIsCleanerNotInDeadCycleNotFreeRefSetWCB + *- @ExecuteArgs: + *- @Remark: + * + */ + +import java.io.PrintStream; +import java.lang.ref.*; + +public class NotIsCleanerNotInDeadCycleNotFreeRefSetWCB { + static int TEST_NUM = 1; + static int judgeNum = 0; + + public static void main(String[] args) throws Exception { + judgeNum = 0; + for (int i = 0; i < TEST_NUM; i++) { + notIsCleanerNotInDeadCycleNotFreeRefSetWCB(); + } + if (judgeNum == 0) { + System.out.println("ExpectResult"); + } + } + + static boolean resultSetCycle(Cycle_BDec_00010_A1 a1) throws InterruptedException { + InCycle cycleA = new InCycle(); + cycleA.setCycle(a1); + Runtime.getRuntime().gc(); + boolean result = cycleA.setCycle(a1); + return result; + } + + static void notIsCleanerNotInDeadCycleNotFreeRefSetWCB() throws InterruptedException { + Cycle_BDec_00010_A1 cycleA = new Cycle_BDec_00010_A1(); + boolean result = resultSetCycle(cycleA); + cycleA.partner2 = null; + if (result == true) { + if (cycleA.clearSoftReference() == true) { + if (cycleA.clearWeakReference() == true) { + if (cycleA.clearFinalizePhantomReference() == true) { + if (cycleA.clearNoFinalizePhantomReference() == true) { + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearNoFinalizePhantomReference--------------" + + "NotIsCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearFinalizePhantomReference------------------" + + "NotIsCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearWeakReference---------------------" + + "NotIsCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearSoftReference-------------------" + + "NotIsCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in isCleanerNotInDeadCycleNotFreeRefSetWCB---------------------" + + "NotIsCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } +} + +class Cycle_BDec_00010_A1 { + Reference a1Ref; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A2 partner2; + int num; + int sum; + static int value; + static StringBuffer obj = new StringBuffer("weak"); + + Cycle_BDec_00010_A1() throws InterruptedException { + obj = new StringBuffer("weak"); + a1Ref = new WeakReference(obj, rq); + if (a1Ref.get() == null) { + System.out.println("error in a1Ref.get"); + } + obj = null; + partner2 = null; + num = 1; + sum = 0; + value = 100; + } + + void add() { + sum = num + partner2.num; + } + + /** + * 设置软引用, clear and enqueue + */ + static Reference srp, wrp, prp; + static ReferenceQueue srq = new ReferenceQueue(); + static ReferenceQueue wrq = new ReferenceQueue(); + static ReferenceQueue prq = new ReferenceQueue(); + static StringBuffer obj1 = new StringBuffer("soft"); + static StringBuffer obj2 = new StringBuffer("weak"); + static StringBuffer obj3 = new StringBuffer("obj"); + + static void setSoftReference() { + obj1 = new StringBuffer("soft"); + srp = new WeakReference(obj1, srq); + if (srp.get() == null) { + value++; + } + obj1 = null; + } + + static boolean clearSoftReference() throws InterruptedException { + int value = 100; + Reference ref; + setSoftReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + // 释放,应该为空 + if (srp.get() != null) { + value++; + } + while ((ref = srq.poll()) != null) { + if (!ref.getClass().toString().equals("class java.lang.ref.WeakReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + + /** + * 设置弱引用, clear and enqueue + */ + static void setWeakReference() { + obj2 = new StringBuffer("weak"); + wrp = new WeakReference(obj2, wrq); + if (wrp.get() == null) { + value++; + } + obj2 = null; + } + + static boolean clearWeakReference() throws InterruptedException { + value = 100; + Reference reference; + setWeakReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + // 释放,应该为空 + if (wrp.get() != null) { + value++; + } + while ((reference = wrq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.WeakReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + + /** + * 设置虚引用, 没有Referent finalized, clear and enqueue. + */ + static void setPhantomReference() { + obj3 = new StringBuffer("obj"); + prp = new PhantomReference(obj3, prq); + if (prp.get() != null) { + value++; + } + obj3 = null; + } + + static boolean clearNoFinalizePhantomReference() throws InterruptedException { + value = 100; + Reference reference; + setPhantomReference(); + Thread.sleep(2000); + while ((reference = prq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + + static int finalSet() { + RC_Finalize testClass1 = new RC_Finalize(); + System.runFinalization(); + return testClass1.value; + } + + /** + * 设置虚引用, 经过Referent finalized,clear and enqueue + */ + static boolean clearFinalizePhantomReference() throws InterruptedException { + value = 100; + int valueFinal = finalSet(); + Runtime.getRuntime().gc(); + valueFinal = finalSet(); + Reference reference; + setPhantomReference(); + Thread.sleep(5000); + if (valueFinal == 200) { + value = value + 100; + } + while ((reference = prq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + value++; + } + } + if (value == 200) { + return true; + } else { + return false; + } + } +} + +class Cycle_BDec_00010_A2 { + Reference a2Ref; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A1 partner1; + int num; + int sum; + static int value; + static StringBuffer obj = new StringBuffer("weak"); + + Cycle_BDec_00010_A2() throws InterruptedException { + obj = new StringBuffer("weak"); + a2Ref = new WeakReference(obj, rq); + if (a2Ref.get() == null) { + assert false; + } + obj = null; + + partner1 = null; + num = 2; + sum = 0; + value = 100; + } + + void add() { + sum = num + partner1.num; + } +} + +class RC_Finalize { + static int value = 0; + + static void rc_Finalize() throws InterruptedException { + RC_Finalize a = new RC_Finalize(); + Thread.sleep(2000); + System.runFinalization(); + } + + protected void finalize() throws Throwable { + super.finalize(); + value = 200; + } + + public static int run(String argv[], PrintStream out) { + return 0; + } +} + +class ThreadRef implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + WeakReference wr = new WeakReference(new Object()); + try { + Thread.sleep(100); + } catch (Exception e) { + e.printStackTrace(); + } + } + } +} + +class InCycle { + /** + * 确认环是正确的 + * + * @param refInstance 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + public static boolean ModifyA1(Cycle_BDec_00010_A1 refInstance) { + refInstance.add(); + refInstance.partner2.add(); + int nSum = refInstance.sum + refInstance.partner2.sum; + if (nSum == 6) { + return true; + } else { + return false; + } + } + + /** + * 设置一个带Referent的环 + * + * @param refInstance 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + public static boolean setCycle(Cycle_BDec_00010_A1 refInstance) throws InterruptedException { + refInstance.partner2 = new Cycle_BDec_00010_A2(); + refInstance.partner2.partner1 = refInstance; + refInstance.obj = null; + refInstance.partner2.obj = null; + Thread.sleep(2000); + boolean ret; + ret = ModifyA1(refInstance); + + if (ret == true) { + if (refInstance.a1Ref.get() == null) { + if (refInstance.partner2.a2Ref.get() == null) { + if (refInstance != null && refInstance.partner2 != null) { + return true; + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " a1_0 == null || a1_0.a2_0 == null"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " a2Ref.get() == null"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " a1_0.a1Ref.get() == null"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ret != true"); + return false; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0357-rc-rp-simpleweakref_10/NotIsCleanerNotFreeRefFailSetWCBSetAtomicWCB.java b/test/testsuite/ouroboros/rc_test/RC0357-rc-rp-simpleweakref_10/NotIsCleanerNotFreeRefFailSetWCBSetAtomicWCB.java new file mode 100755 index 0000000000000000000000000000000000000000..de39a2dd0c7edc6f0373d2ea1b67c76371575a98 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0357-rc-rp-simpleweakref_10/NotIsCleanerNotFreeRefFailSetWCBSetAtomicWCB.java @@ -0,0 +1,408 @@ +/* + *- @TestCaseID: RefProCase/RefProcessor/src/NotIsCleanerNotFreeRefFailSetWCBSetAtomicWCB.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: RefProcessor basic testcase: 不是cleaner对象,referent没有释放,没有设置WCB,atomic设置WCB + *- @Condition: no + *- @Brief:functionTest + * -#step1:创建两个带有弱引用对象的class,弱引用申请后通过get方法判断非空,并相互声明对方类作为自己的Field。 + * -#step2:其中class A1会分别对软引用、弱引用、虚引用进行clear和enqueue, 其中虚引用分为没有Referent finalized的clear和enqueue + * 和有Referent finalized的clear和enqueue。 + * -#step3:创建第三个类InCycle,将上两个类连成一个可达的环。 + * -#step4:通过线程将A1,A2两个类对象初始化为空。 + * -#step5:创建InCycle的实例,调用方法setCycle给第一个类对象关于第二个类的Field初始化对象,再将该对象关于第一个类Field赋值为第一 + * 个类,从而形成一个环。 + * -#step6:方法setCycle调用方法ModifyA1执行前两个类对象的add方法进行Field的运算,相当于对对象进行了引用,判断运算结果是否正确。 + * -#step7:将环中A1和A2的第一个被引用的对象都置为NULL,等待一个回收周期,确认两个类的软引用、弱引用、虚引用对象为NULL。 + * -#step8:调用Runtime.getRuntime().gc()进行资源回收,重复步骤4~7。 + * -#step9:确认class A1的软引用、弱引用、虚引用都应该为空。 + *- @Expect: ExpectResult\n + *- @Priority: High + *- @Source: NotIsCleanerNotFreeRefFailSetWCBSetAtomicWCB.java + *- @ExecuteClass: NotIsCleanerNotFreeRefFailSetWCBSetAtomicWCB + *- @ExecuteArgs: + *- @Remark: + */ + +import java.io.PrintStream; +import java.lang.ref.*; + +public class NotIsCleanerNotFreeRefFailSetWCBSetAtomicWCB { + static int TEST_NUM = 1; + static int judgeNum = 0; + + public static void main(String[] args) throws Exception { + judgeNum = 0; + for (int i = 0; i < TEST_NUM; i++) { + notIsCleanerNotFreeRefFailSetWCBSetAtomicWCB(); + Runtime.getRuntime().gc(); + notIsCleanerNotFreeRefFailSetWCBSetAtomicWCB(); + } + if (judgeNum == 0) { + System.out.println("ExpectResult"); + } + } + + static void notIsCleanerNotFreeRefFailSetWCBSetAtomicWCB() throws Exception { + SetReferentNull setReferentNull = new SetReferentNull(); + setReferentNull.run(); + NotIsCleanerNotInDeadCycleNotFreeRef notIsCleanerNotInDeadCycleNotFreeRef = new + NotIsCleanerNotInDeadCycleNotFreeRef(); + notIsCleanerNotInDeadCycleNotFreeRef.run(); + if (notIsCleanerNotInDeadCycleNotFreeRef.check == false) { + judgeNum++; + } + } +} + +class SetReferentNull implements Runnable { + Cycle_BDec_00010_A1 cycle1; + Cycle_BDec_00010_A2 cycle2; + + @Override + public void run() { + cycle2 = null; + cycle1 = null; + } +} + +class NotIsCleanerNotInDeadCycleNotFreeRef implements Runnable { + boolean check; + + @Override + public void run() { + try { + check = notIsCleanerNotInDeadCycleNotFreeRef(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + static boolean resultSetCycle(Cycle_BDec_00010_A1 cycle1) throws InterruptedException { + InCycle cycleA = new InCycle(); + cycleA.setCycle(cycle1); + Runtime.getRuntime().gc(); + boolean result = cycleA.setCycle(cycle1); + return result; + } + + boolean notIsCleanerNotInDeadCycleNotFreeRef() throws InterruptedException { + Cycle_BDec_00010_A1 a1 = new Cycle_BDec_00010_A1(); + boolean result = resultSetCycle(a1); + try { + if (result == true) { + if (a1.clearSoftReference() == true) { + if (a1.clearWeakReference() == true) { + if (a1.clearFinalizePhantomReference() == true) { + if (a1.clearNoFinalizePhantomReference() == true) { + return true; + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearNoFinalizePhantomReference"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearFinalizePhantomReference"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearWeakReference"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearSoftReference"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in NotIsCleanerNotInDeadCycleNotFreeRef"); + return false; + } + } catch (Exception e) { + return false; + } + } +} + +class Cycle_BDec_00010_A2 { + Reference a2Ref; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A1 partner1; + int num; + int sum; + static int value; + static StringBuffer obj = new StringBuffer("weak"); + + Cycle_BDec_00010_A2() { + a2Ref = new WeakReference(obj, rq); + if (a2Ref.get() == null) { + assert false; + } + partner1 = null; + num = 2; + sum = 0; + value = 100; + } + + void add() { + sum = num + partner1.num; + } +} + +class Cycle_BDec_00010_A1 { + Reference a1Ref; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A2 partner2; + int num; + int sum; + static int value; + static StringBuffer obj = new StringBuffer("weak"); + + Cycle_BDec_00010_A1() { + a1Ref = new WeakReference(obj, rq); + if (a1Ref.get() == null) { + assert false; + } + partner2 = null; + num = 1; + sum = 0; + value = 100; + } + + void add() { + sum = num + partner2.num; + } + + /** + * 设置软引用, clear and enqueue + */ + static Reference srp, wrp, prp; + static ReferenceQueue srq = new ReferenceQueue(); + static ReferenceQueue wrq = new ReferenceQueue(); + static ReferenceQueue prq = new ReferenceQueue(); + static StringBuffer obj1 = new StringBuffer("soft"); + static StringBuffer obj2 = new StringBuffer("weak"); + static StringBuffer obj3 = new StringBuffer("phantom"); + + static void setSoftReference() { + obj1 = new StringBuffer("soft"); + srp = new WeakReference(obj1, srq); + if (srp.get() == null) { + value++; + } + obj1 = null; + } + + static boolean clearSoftReference() throws InterruptedException { + int value = 100; + Reference r; + setSoftReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + // 释放,应该为空 + if (srp.get() != null) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " --------------------srp.get():" + srp.get()); + value++; + } + while ((r = srq.poll()) != null) { + if (!r.getClass().toString().equals("class java.lang.ref.WeakReference")) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " --------------------srp.while"); + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + + /** + * 设置弱引用,clear and enqueue + */ + static void setWeakReference() { + obj2 = new StringBuffer("weak"); + wrp = new WeakReference(obj2, wrq); + if (wrp.get() == null) { + value++; + } + obj2 = null; + } + + static boolean clearWeakReference() throws InterruptedException { + value = 100; + Reference reference; + setWeakReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + //释放,应该为空 + if (wrp.get() != null) { + value++; + } + while ((reference = wrq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.WeakReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + + /** + * 设置虚引用,没有Referent finalized,clear and enqueue + */ + static void setPhantomReference() { + obj3 = new StringBuffer("phantom"); + prp = new PhantomReference(obj3, prq); + if (prp.get() != null) { + value++; + } + obj3 = null; + } + + static boolean clearNoFinalizePhantomReference() throws InterruptedException { + value = 100; + Reference reference; + setPhantomReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + while ((reference = prq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + + static int finalSet() { + RC_Finalize testClass1 = new RC_Finalize(); + System.runFinalization(); + return testClass1.value; + } + + /** + * 设置虚引用, 经过Referent finalized,clear and enqueue + */ + static boolean clearFinalizePhantomReference() throws InterruptedException { + value = 100; + int valueFinal = finalSet(); + Runtime.getRuntime().gc(); + valueFinal = finalSet(); + Reference reference; + setPhantomReference(); + Thread.sleep(5000); + if (valueFinal == 200) { + value = value + 100; + } + while ((reference = prq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + value++; + } + } + if (value == 200) { + return true; + } else { + return false; + } + } +} + +class InCycle { + /** + * 确认环是正确的 + * + * @param refInstance 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + public static boolean ModifyA1(Cycle_BDec_00010_A1 refInstance) { + refInstance.add(); + refInstance.partner2.add(); + int nSum = refInstance.sum + refInstance.partner2.sum; + if (nSum == 6) { + return true; + } else { + return false; + } + } + + /** + * 设置一个带Referent的环 + * + * @param refInstance 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + public static boolean setCycle(Cycle_BDec_00010_A1 refInstance) throws InterruptedException { + refInstance.partner2 = new Cycle_BDec_00010_A2(); + refInstance.partner2.partner1 = refInstance; + boolean ret; + ret = ModifyA1(refInstance); + refInstance.obj = null; + refInstance.partner2.obj = null; + Thread.sleep(2000); + if (ret == true) { + if (refInstance.a1Ref.get() == null && refInstance.partner2.a2Ref.get() == null) { + if (refInstance != null && refInstance.partner2 != null) { + return true; + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " a1_0==null||a1_0.a2_0==nulll"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " a1_0.a1Ref.get() != null"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ret != true"); + return false; + } + } +} + +class RC_Finalize { + static int value = 0; + + static void rc_Finalize() throws InterruptedException { + RC_Finalize a = new RC_Finalize(); + Thread.sleep(2000); + System.runFinalization(); + } + + protected void finalize() throws Throwable { + super.finalize(); + value = 200; + } + + public static int run(String argv[], PrintStream out) { + return 0; + } +} + +class ThreadRef implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + WeakReference wr = new WeakReference(new Object()); + try { + Thread.sleep(100); + } catch (InterruptedException e) { + System.out.println(" sleep was Interrupted"); + } + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0358-rc-rp-simpleweakref_11/NotIsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB.java b/test/testsuite/ouroboros/rc_test/RC0358-rc-rp-simpleweakref_11/NotIsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB.java new file mode 100755 index 0000000000000000000000000000000000000000..969c47246a50f9474b8b521462af07f978c38d33 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0358-rc-rp-simpleweakref_11/NotIsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB.java @@ -0,0 +1,377 @@ +/* + *- @TestCaseID: RefProCase/RefProcessor/src/NotIsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: RefProcessor basic testcase: 在不可达的环中,不是cleaner对象,不释放对象,不设置WCB + *- @Condition: no + *- @Brief:functionTest + * -#step1:创建两个带有弱引用对象的class,弱引用申请后通过get方法判断非空,并相互声明对方类作为自己的Field。 + * -#step2:其中class A1会分别对软引用、弱引用、虚引用进行clear和enqueue, 其中虚引用分为没有Referent finalized的clear和enqueue + * 和有Referent finalized的clear和enqueue。 + * -#step3:创建第三个类InCycle,将上两个类连成一个可达的环。 + * -#step4:通过线程将A1,A2两个类对象初始化为空。 + * -#step5:创建InCycle的实例,调用方法setCycle给第一个类对象关于第二个类的Field初始化对象,判断对象的引用不为空,再将该对象关于 + * 第一个类Field赋值为第一个类,从而形成一个环。 + * -#step6:方法setCycle调用方法ModifyA1执行前两个类对象的add方法进行Field的运算,相当于对对象进行了引用,判断运算结果是否正确。 + * -#step7:等待一个回收周期,确认两个类的软引用、弱引用、虚引用对象为NULL。 + * -#step8:调用Runtime.getRuntime().gc()进行资源回收,重复步骤4~7。 + * -#step9:确认class A1的软引用、弱引用、虚引用都应该为空。 + *- @Expect: ExpectResult\n + *- @Priority: High + *- @Source:NotIsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB.java + *- @ExecuteClass: NotIsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB + *- @ExecuteArgs: + *- @Remark: + */ + +import java.io.PrintStream; +import java.lang.ref.*; + +public class NotIsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB { + static int TEST_NUM = 1; + static int judgeNum = 0; + + public static void main(String[] args) throws Exception { + judgeNum = 0; + for (int i = 0; i < TEST_NUM; i++) { + notIsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB(); + Runtime.getRuntime().gc(); + notIsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB(); + } + if (judgeNum == 0) { + System.out.println("ExpectResult"); + } + } + + static boolean resultSetCycle(Cycle_BDec_00010_A1 cycle1) throws InterruptedException { + InCycle cycleA = new InCycle(); + cycleA.setCycle(cycle1); + Runtime.getRuntime().gc(); + boolean result = cycleA.setCycle(cycle1); + return result; + } + + static void notIsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB() throws InterruptedException { + Cycle_BDec_00010_A1 cycle1 = new Cycle_BDec_00010_A1(); + boolean result = resultSetCycle(cycle1); + if (result == true) { + cycle1.partner2 = null; + cycle1 = null; + if (cycle1.clearSoftReference() == true) { + if (cycle1.clearWeakReference() == true) { + if (cycle1.clearFinalizePhantomReference() == true) { + if (cycle1.clearNoFinalizePhantomReference() == true) { + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearNoFinalizePhantomReference--------------" + + "notIsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearFinalizePhantomReference-------------" + + "notIsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearWeakReference"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearSoftReference"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in isCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } +} + +class Cycle_BDec_00010_A1 { + Reference a1Ref; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A2 partner2; + int num; + int sum; + static int value; + static StringBuffer obj = new StringBuffer("weak"); + + Cycle_BDec_00010_A1() { + obj = new StringBuffer("weak"); + a1Ref = new WeakReference(obj, rq); + if (a1Ref.get() == null) { + assert false; + } + obj = null; + partner2 = null; + num = 1; + sum = 0; + value = 100; + } + + void add() { + sum = num + partner2.num; + } + + /** + * 设置软引用,clear and enqueue + */ + static Reference srp, wrp, prp; + static ReferenceQueue srq = new ReferenceQueue(); + static ReferenceQueue wrq = new ReferenceQueue(); + static ReferenceQueue prq = new ReferenceQueue(); + static StringBuffer obj1 = new StringBuffer("soft"); + static StringBuffer obj2 = new StringBuffer("weak"); + static StringBuffer obj3 = new StringBuffer("phantom"); + + static void setSoftReference() { + obj1 = new StringBuffer("soft"); + srp = new WeakReference(obj1, srq); + if (srp.get() == null) { + value++; + } + obj1 = null; + } + + static boolean clearSoftReference() throws InterruptedException { + int value = 100; + Reference r; + setSoftReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + //释放,应该为空 + if (srp.get() != null) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " --------------------srp.get():" + srp.get()); + value++; + } + while ((r = srq.poll()) != null) { + if (!r.getClass().toString().equals("class java.lang.ref.WeakReference")) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " --------------------srp.while"); + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + + /** + * 设置弱引用,clear and enqueue + */ + static void setWeakReference() { + obj2 = new StringBuffer("weak"); + wrp = new WeakReference(obj2, wrq); + if (wrp.get() == null) { + value++; + } + obj2 = null; + } + + static boolean clearWeakReference() throws InterruptedException { + value = 100; + Reference reference; + setWeakReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + // 释放,应该为空 + if (wrp.get() != null) { + value++; + } + while ((reference = wrq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.WeakReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + + /** + * 设置虚引用, 没有Referent finalized, clear and enqueue + */ + static void setPhantomReference() { + obj3 = new StringBuffer("phantom"); + prp = new PhantomReference(obj3, prq); + if (prp.get() != null) { + value++; + } + obj3 = null; + } + + static boolean clearNoFinalizePhantomReference() throws InterruptedException { + value = 100; + Reference reference; + setPhantomReference(); + Thread.sleep(2000); + while ((reference = prq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + + static int finalSet() { + RC_Finalize testClass1 = new RC_Finalize(); + System.runFinalization(); + return testClass1.value; + } + + /** + * 设置虚引用, 经过Referent finalized,clear and enqueue + */ + static boolean clearFinalizePhantomReference() throws InterruptedException { + value = 100; + int valueFinal = finalSet(); + Runtime.getRuntime().gc(); + valueFinal = finalSet(); + Reference reference; + setPhantomReference(); + Thread.sleep(5000); + if (valueFinal == 200) { + value = value + 100; + } + while ((reference = prq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + value++; + } + } + if (value == 200) { + return true; + } else { + return false; + } + } +} + +class Cycle_BDec_00010_A2 { + Reference a2Ref; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A1 partner1; + int num; + int sum; + static int value; + static StringBuffer obj = new StringBuffer("weak"); + + Cycle_BDec_00010_A2() { + obj = new StringBuffer("weak"); + a2Ref = new WeakReference(obj, rq); + if (a2Ref.get() == null) { + assert false; + } + obj = null; + partner1 = null; + num = 2; + sum = 0; + value = 100; + } + + void add() { + sum = num + partner1.num; + } +} + +class InCycle { + /** + * 确认环是正确的 + * + * @param refInstance 传入的是带有Referent的类实例 + * @return true: 正确;false:错误 + */ + public static boolean ModifyA1(Cycle_BDec_00010_A1 refInstance) { + refInstance.add(); + refInstance.partner2.add(); + int nSum = refInstance.sum + refInstance.partner2.sum; + if (nSum == 6) { + return true; + } else { + return false; + } + } + + /** + * 设置一个带Referent的环 + * + * @param refInstance 传入的是带有Referent的类实例 + * @return true: 正确;false:错误 + */ + public static boolean setCycle(Cycle_BDec_00010_A1 refInstance) throws InterruptedException { + refInstance.partner2 = new Cycle_BDec_00010_A2(); + if (refInstance.partner2.a2Ref.get() == null) { + return false; + } + refInstance.partner2.partner1 = refInstance; + boolean ret; + ret = ModifyA1(refInstance); + if (ret == true) { + Thread.sleep(2000); + if (refInstance.a1Ref.get() == null) { + if (refInstance != null && refInstance.partner2 != null) { + return true; + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " a1_0==null||a1_0.a2_0==nulll"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " a1_0.a1Ref.get() != null"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ret != true"); + return false; + } + } +} + +class RC_Finalize { + static int value = 0; + + static void rc_Finalize() throws InterruptedException { + RC_Finalize rc = new RC_Finalize(); + Thread.sleep(2000); + System.runFinalization(); + } + + protected void finalize() throws Throwable { + super.finalize(); + value = 200; + } + + public static int run(String argv[], PrintStream out) { + return 0; + } +} + +class ThreadRef implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + WeakReference wr = new WeakReference(new Object()); + try { + Thread.sleep(100); + } catch (InterruptedException e) { + System.out.println(" sleep was Interrupted"); + } + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f + diff --git a/test/testsuite/ouroboros/rc_test/RC0359-rc-rp-simpleweakref_12/NotIsCleanerFreeRef.java b/test/testsuite/ouroboros/rc_test/RC0359-rc-rp-simpleweakref_12/NotIsCleanerFreeRef.java new file mode 100755 index 0000000000000000000000000000000000000000..6ece77b975097606bc4ea7178741fb8bcd7b743a --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0359-rc-rp-simpleweakref_12/NotIsCleanerFreeRef.java @@ -0,0 +1,82 @@ +/* + *- @TestCaseID: RefProCase/RefProcessor/src/NotIsCleanerFreeRef.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: RefProcessor testcase: 不是cleaner对象,并且释放对象 + *- @Condition: no + *- @Brief:functionTest + * -#step1: 构造一个弱引用, 确认引用不为空。 + * -#step2: 等待一个周期,确认弱引用被释放 + *- @Expect: ExpectResult\n + *- @Priority: High + *- @Source: NotIsCleanerFreeRef.java + *- @ExecuteClass: NotIsCleanerFreeRef + *- @ExecuteArgs: + *- @Remark: + * + */ + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; + +public class NotIsCleanerFreeRef { + static int TEST_NUM = 1; + static int judgeNum = 0; + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static StringBuffer obj = new StringBuffer("soft"); + + static void setSoftRef() { + obj = new StringBuffer("soft"); + rp = new WeakReference(obj, rq); + if (rp.get() == null) { + judgeNum++; + } + obj = null; + } + + public static void main(String[] args) throws Exception { + judgeNum = 0; + for (int i = 0; i < TEST_NUM; i++) { + notIsCleanerFreeRef(); + Runtime.getRuntime().gc(); + notIsCleanerFreeRef(); + } + if (judgeNum == 0) { + System.out.println("ExpectResult"); + } + } + + static void notIsCleanerFreeRef() throws InterruptedException { + Reference ref; + setSoftRef(); + + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + if (rp.get() != null) { + judgeNum++; + } + while ((ref = rq.poll()) != null) { + if (!ref.getClass().toString().equals("class java.lang.ref.WeakReference")) { + judgeNum++; + } + } + } +} + +class ThreadRef implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + WeakReference wr = new WeakReference(new Object()); + try { + Thread.sleep(100); + } catch (InterruptedException e) { + System.out.println(" sleep was Interrupted"); + } + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0360-rc-Memory-leaktestsupplycase-01/BackupTracingAndRefPro.java b/test/testsuite/ouroboros/rc_test/RC0360-rc-Memory-leaktestsupplycase-01/BackupTracingAndRefPro.java new file mode 100755 index 0000000000000000000000000000000000000000..01da410d3f2f18102e3eebbbd8add49ce7b9869d --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0360-rc-Memory-leaktestsupplycase-01/BackupTracingAndRefPro.java @@ -0,0 +1,125 @@ +/* + *- @TestCaseID: maple/runtime/rc/function/BackupTracingAndRefPro.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Condition: no + *- @Brief:functionTest + * -#step1: 创建弱引用,确认创建成功 + * -#step2: 等待一个时间周期,确认引用和引用队列被释放 + * -#step3: 调用Runtime.getRuntime().gc()进行垃圾回收,重复步骤1~2; + * -#step4: 创建类的引用,并对类的变量进行运算,确认运算结果正确。 + * -#step5: 调用Runtime.getRuntime().gc()进行垃圾回收,重复步骤4; + *- @Expect: + *- @Priority: High + *- @Source: BackupTracingAndRefPro.java + *- @ExecuteClass: BackupTracingAndRefPro + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; + +public class BackupTracingAndRefPro { + static int NUM = 2; + + public static void main(String[] args) { + runRefPro(); + Runtime.getRuntime().gc(); + runRefPro(); + + runBackupTracing(); + Runtime.getRuntime().gc(); + runBackupTracing(); + System.out.println("ExpectResult"); + } + + static void runRefPro() { + ThreadRefPro threadRefPro = new ThreadRefPro(); + for (int i = 0; i < NUM; i++) { + threadRefPro.run(); + } + } + + static void runBackupTracing() { + ThreadBackupTracing threadBackupTracing = new ThreadBackupTracing(); + for (int i = 0; i < NUM; i++) { + threadBackupTracing.run(); + } + } +} + +class ThreadBackupTracing implements Runnable { + int result = 0; + + void versify() { + ReferenceOperation ref = new ReferenceOperation(); + ref.referenceOperation = ref; + ref.add(); + result = ref.sum; + } + + @Override + public void run() { + versify(); + if (result != 20) { + System.out.println("error result ==" + result); + } + } +} + +class ReferenceOperation { + ReferenceOperation referenceOperation; + int num; + int sum; + + ReferenceOperation() { + referenceOperation = null; + num = 10; + sum = 0; + } + + void add() { + sum = num + referenceOperation.num; + } +} + +class ThreadRefPro implements Runnable { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static StringBuffer obj = new StringBuffer("weak"); + + static void setWeakRef() { + obj = new StringBuffer("weak"); + rp = new WeakReference(obj, rq); + if (rp.get() == null) { + System.out.println("error"); + } + obj = null; + } + + @Override + public void run() { + Reference reference; + setWeakRef(); + + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + if (rp.get() != null) { + System.out.println("error in rp.get()"); + } + while ((reference = rq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.WeakReference")) { + System.out.println("error in rq"); + } + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0361-rc-Memory-leaktestsupplycase-02/FinalizerRef.java b/test/testsuite/ouroboros/rc_test/RC0361-rc-Memory-leaktestsupplycase-02/FinalizerRef.java new file mode 100755 index 0000000000000000000000000000000000000000..190b4efa808c67f6a3597409d3a1fb36f8066ffa --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0361-rc-Memory-leaktestsupplycase-02/FinalizerRef.java @@ -0,0 +1,132 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/FinalizerRef.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Condition: no + *- @Brief:functionTest + * -#step1: 创建弱引用,确认创建成功,释放强引用。 + * -#step2: 创建5个线程调用finalize。 + * -#step3: 调用Runtime.getRuntime().gc()进行垃圾回收。 + * -#step4: 重复步骤1~2。 + *- @Expect: + *- @Priority: High + *- @Source: FinalizerRef.java + *- @ExecuteClass: FinalizerRef + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; + +public class FinalizerRef { + static int NUM = 1; + + public static void main(String[] args) { + test(); + Runtime.getRuntime().gc(); + test(); + System.out.println("ExpectResult"); + } + + public static void test() { + SetWeakRef setWeakRef = new SetWeakRef(); + setWeakRef.setWeakRef(); + ThreadWeakRef_01 threadWeakRef_01 = new ThreadWeakRef_01(); + ThreadWeakRef_02 threadWeakRef_02 = new ThreadWeakRef_02(); + ThreadWeakRef_03 threadWeakRef_03 = new ThreadWeakRef_03(); + ThreadWeakRef_04 threadWeakRef_04 = new ThreadWeakRef_04(); + ThreadWeakRef_05 threadWeakRef_05 = new ThreadWeakRef_05(); + for (int i = 0; i < NUM; i++) { + threadWeakRef_01.run(); + threadWeakRef_02.run(); + threadWeakRef_03.run(); + threadWeakRef_04.run(); + threadWeakRef_05.run(); + } + } +} + +class SetWeakRef { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static StringBuffer obj = new StringBuffer("weak"); + + static void setWeakRef() { + obj = new StringBuffer("weak"); + rp = new WeakReference(obj, rq); + if (rp.get() == null) { + System.out.println("error"); + } + obj = null; + } +} + +class ThreadWeakRef_01 implements Runnable { + @Override + public void run() { + System.gc(); + ThreadWeakRef_01 threadWeakRef_01 = new ThreadWeakRef_01(); + System.runFinalization(); + } + + protected void finalize() throws Throwable { + super.finalize(); + } +} + +class ThreadWeakRef_02 implements Runnable { + @Override + public void run() { + System.gc(); + ThreadWeakRef_02 threadWeakRef_02 = new ThreadWeakRef_02(); + System.runFinalization(); + } + + protected void finalize() throws Throwable { + super.finalize(); + } +} + +class ThreadWeakRef_03 implements Runnable { + @Override + public void run() { + System.gc(); + ThreadWeakRef_03 threadWeakRef_03 = new ThreadWeakRef_03(); + System.runFinalization(); + } + + protected void finalize() throws Throwable { + super.finalize(); + } +} + +class ThreadWeakRef_04 implements Runnable { + @Override + public void run() { + System.gc(); + ThreadWeakRef_04 threadWeakRef_04 = new ThreadWeakRef_04(); + System.runFinalization(); + } + + protected void finalize() throws Throwable { + super.finalize(); + } +} + +class ThreadWeakRef_05 implements Runnable { + @Override + public void run() { + System.gc(); + ThreadWeakRef_05 threadWeakRef_05 = new ThreadWeakRef_05(); + System.runFinalization(); + } + + protected void finalize() throws Throwable { + super.finalize(); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0362-rc-Memory-leaktestsupplycase-03/FinalizerTest.java b/test/testsuite/ouroboros/rc_test/RC0362-rc-Memory-leaktestsupplycase-03/FinalizerTest.java new file mode 100755 index 0000000000000000000000000000000000000000..fd00d72520302d65ebdc06ebb32cf343c82a2ba8 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0362-rc-Memory-leaktestsupplycase-03/FinalizerTest.java @@ -0,0 +1,88 @@ +/* + *- @TestCaseID: maple/runtime/rc/function/FinalizerTest.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + * 等finalizer队列中所有对象执行finalize()方法,确认所有finalize资源顺利释放 + *- @Condition: no + *- @Brief:functionTest + * -#step1: 创建一个FinalizerTest类的实例对象finalizerTest,对其调用newFinalizeObject()方法,即先创建一个WeakReference类的对 + * 象并赋值给rp[i](此处i < finalizeNum = 10),经判断得知rp[i].get()的返回值不为null,最后令stringBuffer等于null; + * -#step2: 重复步骤1九次; + * -#step3: 令静态的全局变量finalizerTest等于null; + * -#step4: 使当前线程休眠2000ms; + * -#step5: 调用System.gc()进行垃圾回收; + * -#step6: 调用System.runFinalization()方法,即强制调用失去引用的对象的finalize()方法进行资源的释放; + * -#step7: 经判断得出rp[i].get()(此处i < finalizeNum = 10)的返回值均为null,证实对象已经完全释放; + * -#step8: 调用Runtime.getRuntime().gc()进行垃圾回收; + * -#step9: 重复步骤1~7; + *- @Expect: ExpectResult\n + *- @Priority: High + *- @Source: FinalizerTest.java + *- @ExecuteClass: FinalizerTest + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; + +public class FinalizerTest extends Object { + static int finalizeNum = 10; + static Reference rp[] = new Reference[finalizeNum]; + static ReferenceQueue rq = new ReferenceQueue(); + static int checkNum = 0; + static StringBuffer stringBuffer; + static FinalizerTest finalizerTest = null; + + static void newFinalizeObject() throws InterruptedException { + stringBuffer = new StringBuffer("weak"); + for (int i = 0; i < finalizeNum; i++) { + rp[i] = new WeakReference(stringBuffer, rq); + if (rp[i].get() == null) { + checkNum--; + } + } + stringBuffer = null; + } + + protected void finalize() throws Throwable { + super.finalize(); + checkNum++; + } + + static void newFinalizeTest() throws InterruptedException { + for (int i = 0; i < finalizeNum; i++) { + FinalizerTest finalizerTest = new FinalizerTest(); + finalizerTest.newFinalizeObject(); + } + finalizerTest = null; + } + + static void finalizeTest() throws InterruptedException { + newFinalizeTest(); + Thread.sleep(2000); + System.gc(); + System.runFinalization(); + for (int i = 0; i < finalizeNum; i++) { + if (rp[i].get() != null) { + checkNum--; + } + } + } + + public static void main(String[] args) throws InterruptedException { + finalizeTest(); + Runtime.getRuntime().gc(); + finalizeTest(); + + if (checkNum == (finalizeNum * 2)) { + System.out.println("ExpectResult"); + } else { + System.out.println("checkNum = " + checkNum); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0363-rc-Memory-leaktestsupplycase-04/FrequentGCAndFinalize.java b/test/testsuite/ouroboros/rc_test/RC0363-rc-Memory-leaktestsupplycase-04/FrequentGCAndFinalize.java new file mode 100755 index 0000000000000000000000000000000000000000..ee03f40f02f5bab0a3d91173d13a74d2af1cc258 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0363-rc-Memory-leaktestsupplycase-04/FrequentGCAndFinalize.java @@ -0,0 +1,84 @@ +/* + *- @TestCaseID: maple/runtime/rc/function/FrequentGCAndFinalize.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Condition: no + *- @Brief:functionTest + * -#step1: 创建一个WeakReference类的对象rp,经判断rp.get()的返回值不为null; + * -#step2: 令stringBuffer等于null; + * -#step3: 创建一个ThreadFinalize类的实例对象threadFinalize,对于i < num = 10成立时,对其调用run()方法,即调用 + * System.runFinalization()方法,对失去引用的对象调用finalize()方法进行资源的释放; + * -#step4: 创建一个ThreadGC类的实例对象threadGC,对于i < num = 10成立时,对其调用run()方法,即调用 + * Runtime.getRuntime().gc()进行垃圾回收; + * -#step5: 重复step3; + *- @Expect: ExpectResult\n + *- @Priority: High + *- @Source: FrequentGCAndFinalize.java + *- @ExecuteClass: FrequentGCAndFinalize + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; + +public class FrequentGCAndFinalize { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static int num = 10; + static StringBuffer stringBuffer = new StringBuffer("weak"); + + static void setWeakRef() { + stringBuffer = new StringBuffer("weak"); + rp = new WeakReference(stringBuffer, rq); + if (rp.get() == null) { + System.out.println("error"); + } + stringBuffer = null; + } + + static void executeThreadGC() { + ThreadGC threadGC = new ThreadGC(); + for (int i = 0; i < num; i++) { + threadGC.run(); + } + } + + static void executeThreadFinalize() { + ThreadFinalize threadFinalize = new ThreadFinalize(); + for (int i = 0; i < num; i++) { + threadFinalize.run(); + } + } + + public static void main(String[] args) { + setWeakRef(); + executeThreadFinalize(); + executeThreadGC(); + executeThreadFinalize(); + System.out.println("ExpectResult"); + } +} + +class ThreadGC implements Runnable { + @Override + public void run() { + Runtime.getRuntime().gc(); + } +} + +class ThreadFinalize implements Runnable { + @Override + public void run() { + ThreadFinalize threadFinalize = new ThreadFinalize(); + System.runFinalization(); + } + + protected void finalize() throws Throwable { + super.finalize(); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0364-rc-Memory-leaktestsupplycase-05/RaceInLoadAndWriteWeakRef.java b/test/testsuite/ouroboros/rc_test/RC0364-rc-Memory-leaktestsupplycase-05/RaceInLoadAndWriteWeakRef.java new file mode 100755 index 0000000000000000000000000000000000000000..eb47fcd003adc491e62982a871826004dadcab61 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0364-rc-Memory-leaktestsupplycase-05/RaceInLoadAndWriteWeakRef.java @@ -0,0 +1,106 @@ +/* + *- @TestCaseID: maple/runtime/rc/function/RaceInLoadAndWriteWeakRef.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Condition: no + *- @Brief:functionTest + * -#step1: 创建一个WeakReference类的对象并赋值给rp,经判断rp.get()不为null,最后令stringBuffer等于null; + * -#step2: 以setWeakRef为参数,分别创建ThreadLoadWeakRef、ThreadWriteWeakRef类的实例对象threadLoadWeakRef和 + * threadWriteWeakRef; + * -#step3: 调用threadLoadWeakRef的run()方法,即将setWeakRef.rp的值赋值给rp_load; + * -#step4: 调用Runtime.getRuntime().gc()进行垃圾回收; + * -#step5: 重复执行step3~step4一次; + * -#step6: 再次执行step3一次; + * -#step7: 调用threadWriteWeakRef的run()方法,即将rp_write的值赋值给setWeakRef.rp; + * -#step8: 调用Runtime.getRuntime().gc()进行垃圾回收; + * -#step9: 重复执行step7一次; + * -#step10: 调用Runtime.getRuntime().gc()进行垃圾回收; + * -#step11: 重复执行步骤1~9一次; + *- @Expect: + *- @Priority: High + *- @Source: RaceInLoadAndWriteWeakRef.java + *- @ExecuteClass: RaceInLoadAndWriteWeakRef + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; + +public class RaceInLoadAndWriteWeakRef { + static int NUM = 100; + + public static void main(String[] args) { + test(); + Runtime.getRuntime().gc(); + test(); + System.out.println("ExpectResult"); + } + + static void test(){ + SetWeakRef setWeakRef = new SetWeakRef(); + setWeakRef.setWeakRef(); + ThreadLoadWeakRef threadLoadWeakRef = new ThreadLoadWeakRef(setWeakRef); + ThreadWriteWeakRef threadWriteWeakRef = new ThreadWriteWeakRef(setWeakRef); + for (int i = 0; i < NUM; i++) { + threadLoadWeakRef.run(); + Runtime.getRuntime().gc(); + threadLoadWeakRef.run(); + Runtime.getRuntime().gc(); + threadLoadWeakRef.run(); + + threadWriteWeakRef.run(); + Runtime.getRuntime().gc(); + threadWriteWeakRef.run(); + } + } +} + +class SetWeakRef { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static StringBuffer stringBuffer = new StringBuffer("Weak"); + + static void setWeakRef() { + stringBuffer = new StringBuffer("Weak"); + rp = new WeakReference(stringBuffer, rq); + if (rp.get() == null) { + System.out.println("error"); + } + stringBuffer = null; + } +} + +class ThreadLoadWeakRef implements Runnable { + SetWeakRef setWeakRef; + + public ThreadLoadWeakRef(SetWeakRef setWeakRef) { + this.setWeakRef = setWeakRef; + } + + static Reference rp_load; + + @Override + public void run() { + rp_load = setWeakRef.rp; + } +} + +class ThreadWriteWeakRef implements Runnable { + SetWeakRef setWeakRef; + + public ThreadWriteWeakRef(SetWeakRef setWeakRef) { + this.setWeakRef = setWeakRef; + } + + static WeakReference rp_write; + + @Override + public void run() { + setWeakRef.rp = rp_write; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f + diff --git a/test/testsuite/ouroboros/rc_test/RC0365-rc-Memory-leaktestsupplycase-06/WeakAndCleanerRef.java b/test/testsuite/ouroboros/rc_test/RC0365-rc-Memory-leaktestsupplycase-06/WeakAndCleanerRef.java new file mode 100755 index 0000000000000000000000000000000000000000..8931453e69680d39699ef9fb9ec03411087cd269 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0365-rc-Memory-leaktestsupplycase-06/WeakAndCleanerRef.java @@ -0,0 +1,57 @@ +/* + *- @TestCaseID: maple/runtime/rc/function/WeakAndCleanerRef.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Condition: no + *- @Brief:functionTest + * -#step1: 创建一个ThreadCleaner类的实例对象threadCleaner,创建一个StringBuffer类的变量stringBuffer并赋值为test; + * -#step2: 以step1中的threadCleaner和stringBuffer为参数,调用Cleaner类的create()方法创建一个实例对象cleaner; + * -#step3: 以ReferenceQueue类的实例对象rq和stringBuffer为参数,创建一个WeakReference类的对象并赋值给rp; + * -#step4: 令stringBuffer等于null, 释放强引用; + * -#step5: 调用cleaner的clean()方法,进行对象的清除和资源的释放; + * -#step6: 让当前线程休眠2000ms; + * -#step7: 重复执行step3一次; + *- @Expect: ExpectResult\n + *- @Priority: High + *- @Source: WeakAndCleanerRef.java + *- @ExecuteClass: WeakAndCleanerRef + *- @ExecuteArgs: + *- @Remark: + */ + +import sun.misc.Cleaner; + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; + +public class WeakAndCleanerRef { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static StringBuffer stringBuffer = new StringBuffer("test"); + + static void addWeakAndCleanerRef() { + rp = new WeakReference(stringBuffer, rq); + } + + public static void main(String[] args) throws InterruptedException { + ThreadCleaner threadCleaner = new ThreadCleaner(); + Cleaner cleaner = Cleaner.create(stringBuffer, threadCleaner); + addWeakAndCleanerRef(); + stringBuffer = null; + cleaner.clean(); + Thread.sleep(2000); + addWeakAndCleanerRef(); + if (rp.get() == null) { + System.out.println("ExpectResult"); + } + } +} + +class ThreadCleaner implements Runnable { + @Override + public void run() { + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0366-rc-ArrayOptimization-RC_Array_01/RC_Array_01.java b/test/testsuite/ouroboros/rc_test/RC0366-rc-ArrayOptimization-RC_Array_01/RC_Array_01.java new file mode 100755 index 0000000000000000000000000000000000000000..181cdf013b04264884471e137c4791ea9c0ef074 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0366-rc-ArrayOptimization-RC_Array_01/RC_Array_01.java @@ -0,0 +1,434 @@ +/* + *- @TestCaseID:maple/runtime/rc/optimization/RC_Array_01.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Scenario testing for RC optimization: testing various scenes of 1D, 2D, 3D int array objects,including: + * 1.Parameter modification / parameter has not been modified + * 2.final、static + * 3.As a constructor fun + * 4.Function call + * 5.Object Passing + * 6.return constant; variable; function call + * 7.Inherited as a parent class; child class inherits the parent class; interface call; + * 8.Exception + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Array_01.java + *- @ExecuteClass: RC_Array_01 + *- @ExecuteArgs: + *- @Remark: + */ +import java.lang.reflect.Array; +import java.util.Arrays; + +class Base_001{ + //Parent interface + volatile int[] base1; + int[][] base2; + int[][] base21; + int[][][] base3; +} + +public class RC_Array_01 extends Base_001{ + static int check_count = 0; + static int[] arr1 = {10,20,30,40}; + static int[][] arr2 = {{10,20,30,40},{40,50},{60}}; + static int[][] arr21 = {{40,50,60,30},{70,80},{90}}; + static int[][][] arr3 = {arr2,arr21}; + + private RC_Array_01(){ + base1 = new int[]{10,20,30,40}; + base2 = new int[][]{{10,20,30,40},{40,50},{60}}; + base21 = new int[][]{{40,50,60,30},{70,80},{90}}; + base3 = new int[][][]{{{10,20,30,40},{40,50},{60}},{{40,50,60,30},{70,80},{90}}}; + } + + private RC_Array_01(int[] intar){ + base1 = intar; + } + + private RC_Array_01(int[][] intarr){ + base2 = intarr; + } + + private RC_Array_01(int[][][] intarrr){ + base3 = intarrr; + } + + private RC_Array_01(int[] intar, int[][] intarr, int[][][] intarrr){ + base1 = intar; + base2 = intarr; + base3 = intarrr; + } + + public static void main(String [] args) { + final int[] TEST1 = {10,20,30,40}; + final int[][] TEST2 = {TEST1,{40,50},{60}}; + final int[][] TEST21 = {{40,50,60,30},{70,80},{90}}; + final int[][][] TEST3 = {TEST2,TEST21}; + //Initialization check + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step1"); + + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + test01(4,TEST1,TEST2,TEST3); + test01(4,arr1,arr2,arr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step2"); + + //test02 interface call, call function change to modify the parameter value and judge + test02(4,TEST1,TEST2,TEST3); + test02(4,arr1,arr2,arr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step3"); + + //The test03 interface call, call the RC_Array_01_test01 function return value to the parameter third and judged. + //RC_Array_01_test01,return 2D array,Call the multi-parameter constructor of RC_Array_01, and assign a value to + //the newly created object field, and judge the result + test03(TEST2); + test03(arr2); + if(TEST2.length == 3 && arr2.length == 3) + check_count++; + else + System.out.println("ErrorResult in step4"); + + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_01 () no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + //Test points: inheritance, constructor, return function call, constant, variable, do not receive return value + RC_Array_01_test02(); + + //Get an array object by returning a function call + int[] getarr1 = RC_Array_get01(); + int[][] getarr2 = RC_Array_get02(); + int[][][] getarr3 = RC_Array_get03(); + if(getarr1.length == 4 && getarr2.length == 3 && getarr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step5"); + + //Exception testing + Boolean ret = RC_Array_Exception(); + if (ret == true) + check_count++; + else + System.out.println("RC_Array_Exception ErrorResult"); + + //Result judgment + //System.out.println(check_count); + if(check_count == 24) + System.out.println("ExpectResult"); + + } + + private static void test01(int first, int[] second, int[][] third, int[][][] four) { + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + int [] xyz = {23,24,25,26}; + int[][] xyz2 = {{23,24,25,26},{23,24},{23}}; + int[][][] xyz3 = {xyz2,xyz2}; + if(second.length == 4 && third.length == 3 && four.length == 2 + && xyz.length == 4 && xyz2.length == 3 && xyz3.length == 2) + check_count++; + else + System.out.println("ErrorResult in test01"); + } + + private static Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + + private static void test02(int first, int[] second, int[][] third, int[][][] four) { + //test02 interface call, call function change to modify the parameter value and judge + int [] xyz = {23,24,25,26}; + int[][] xyz2 = {{23,24,25,26},{23,24},{23}}; + int[][][] xyz3 = {xyz2,xyz2}; + second = (int[]) change(second,xyz); + third = (int[][])change(third,xyz2); + four = (int[][][]) change(four,xyz3); + if(second.length == 4 && third.length == 3 && four.length == 2) + check_count++; + else + System.out.println("ErrorResult in test02"); + } + + private static void test03(int[][] third) { + //The test03 interface is called, and the RC_Array_01_test01 function call is assigned as the return value to + // the parameter third and judged. + third = RC_Array_01_test01(); + if(third.length == 3) + check_count++; + else + System.out.println("ErrorResult in test03"); + } + + private static int[] RC_Array_get01() + { + //Call the 1D array returned by RC_Array_set01 + return RC_Array_set01(); + } + + private static int[][] RC_Array_get02() + { + //Call the 2D array returned by RC_Array_set02 + return RC_Array_set02(); + } + + private static int[][][] RC_Array_get03() + { + //Call the 3D array returned by RC_Array_set03 + return RC_Array_set03(); + } + + private static int[] RC_Array_set01() + { + //return 1D array,Call the constructor of the 1D array parameter of RC_Array_set01, and assign a value to the + // field of the newly created object, and judge the result + int [] value1 = {23,24,25,26}; + RC_Array_01 rctest=new RC_Array_01(value1); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new int[] {88,10,02,11}; + if(rctest.base1.length == 4) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set01"); + return rctest.base1; + } + + private static int[][] RC_Array_set02() + { + //return 2D array,Call the constructor of the 2D array parameter of RC_Array_set02, and assign a + // value to the domain of the newly created object, and judge the result + int[][] value2 = {{23,24,25,26},{23,24},{23}}; + RC_Array_01 rctest=new RC_Array_01(value2); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base2 = new int[][] {{88,10,02,11},{10,92},{16}}; + if(rctest.base2.length == 3) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set02"); + return rctest.base2; + } + + private static int[][][] RC_Array_set03() + { + //return 3D array,Call the constructor of the 3D array parameter of RC_Array_set03, and assign a value to the + // field of the newly created object, and judge the result + int[][][] value3 = {{{10,20,30,40},{40,50},{60}},{{40,50,60,30},{70,80},{90}}}; + RC_Array_01 rctest=new RC_Array_01(value3); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base3 = new int[][][]{{{88,10,02,11},{10,92},{12}},{{88,10,02,11},{10,92},{16}}}; + if(rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set03"); + return rctest.base3; + } + + private static int[][] RC_Array_01_test01() + { + //return 2D array,Call the multi-parameter constructor of RC_Array_01, and assign a value to the newly created + // object field, and judge the result + int [] value1 = {23,24,25,26}; + int[][] value2 = {{23,24,25,26},{23,24},{23}}; + int[][][] value3 = {value2,value2}; + RC_Array_01 rctest=new RC_Array_01(value1,value2,value3); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new int[] {88,10,02,11}; + rctest.base2 = new int[][] {{88,10,02,11},{10,92},{16}}; + rctest.base21 = new int[][] {{88,10,02,11},{10,92},{12}}; + rctest.base3 = new int[][][]{{{88,10,02,11},{10,92},{12}},{{88,10,02,11},{10,92},{16}}}; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_01_test01"); + return rctest.base21; + } + + private static int[] RC_Array_final01() + { + final int [] VALUE1 = {23,24,25,26}; + return VALUE1; + } + private static int[][] RC_Array_final02() + { + final int[][] VALUE2 = {{23,24,25,26},{23,24},{23}}; + return VALUE2; + } + private static int[][][] RC_Array_final03() + { + final int[][][] VALUE3 = {{{10,20,30,40},{40,50},{60}},{{40,50,60,30},{70,80},{90}}}; + return VALUE3; + } + private static int[][] RC_Array_01_test02() + { + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_01 () no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + final int [] VALUE1 = RC_Array_final01(); + final int[][] VALUE2 = RC_Array_final02(); + final int[][][] VALUE3 = RC_Array_final03(); + RC_Array_01 rctest=new RC_Array_01(); + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_01_test02"); + rctest.base1 = VALUE1; + rctest.base2 = VALUE2; + rctest.base21 = VALUE2; + rctest.base3 = VALUE3; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_01_test02_2"); + return VALUE2; + } + + private static Boolean RC_Array_Exception() + { + //Exception test,exclude NullPointerException,ArrayIndexOutOfBoundsException and so on + int check = 0; + int [] value1 = RC_Array_final01(); + int[][] value2 = RC_Array_final02(); + int[][][] value3 = RC_Array_final03(); + //Is the value as expect after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——1"); + //ArrayIndexOutOfBoundsException + try { + Array.getInt(value1,5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value1[5] = 23; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.setInt(value1,5,10); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getInt(RC_Array_final01(),5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getInt(value2[5],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getInt(value2[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getInt(RC_Array_final02()[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getInt(value3[0][3],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getInt(value3[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getInt(RC_Array_final03()[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + //IllegalArgumentException + try { + Array.getInt(value2,1); + }catch (IllegalArgumentException e){ + check++; + } + try { + Array.getInt(value3,1); + }catch (IllegalArgumentException e){ + check++; + } + //NumberFormatException + try{ + Integer i = new Integer(10); + Array.setInt(value1,0,i.decode("abc")); + }catch (NumberFormatException e) + { + check++; + } + //ClassCastException + RC_Array_01 rc1 = new RC_Array_01(); + try{ + Base_001 bs1 = new Base_001(); + rc1 = (RC_Array_01)bs1; + rc1.base1[0] = 123; + }catch (ClassCastException e) + { + if (rc1.base1[0] != 123) + check++; + } + + //Whether the judgment value is normal after Exception + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——2"); + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.getInt(value1,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getInt(value2,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getInt(value3,1); + }catch (NullPointerException e){ + check++; + } + if (check == 19) + return true; + else + return false; + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0367-rc-ArrayOptimization-RC_Array_02/RC_Array_02.java b/test/testsuite/ouroboros/rc_test/RC0367-rc-ArrayOptimization-RC_Array_02/RC_Array_02.java new file mode 100755 index 0000000000000000000000000000000000000000..db65f4b0964d7f337934f470c4ead05cd2f66631 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0367-rc-ArrayOptimization-RC_Array_02/RC_Array_02.java @@ -0,0 +1,447 @@ +/* + *- @TestCaseID:maple/runtime/rc/optimization/RC_Array_02.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Scenario testing for RC optimization: testing various scenes of 1D, 2D, 3D String array objects,including: + * 1.Parameter modification / parameter has not been modified + * 2.final、static、literial + * 3.As a constructor fun + * 4.Function call + * 5.Object Passing + * 6.return constant; variable; function call + * 7.Inherited as a parent class; child class inherits the parent class; interface call; + * 8.Exception + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Array_02.java + *- @ExecuteClass: RC_Array_02 + *- @ExecuteArgs: + *- @Remark: + */ +import java.lang.reflect.Array; +import java.util.Arrays; +import java.util.regex.PatternSyntaxException; + +class Base_002{ + //Parent interface + volatile String[] base1; + String[][] base2; + String[][] base21; + String[][][] base3; +} + +public class RC_Array_02 extends Base_002{ + static int check_count = 0; + static String[] arr1 = {"10","20","30","40"}; + static String[][] arr2 = {{"10","20","30","40"},{"40","50"},{"60"}}; + static String[][] arr21 = {{"40","50","60","30"},{"70","80"},{"90"}}; + static String[][][] arr3 = {arr2,arr21}; + //literial type data + static String literial_v = "abc"; + static String[] arstr1 = {literial_v,literial_v,literial_v,literial_v}; + static String[][] arstr2 = {{"abc","abc","abc","abc"},{"abc","abc"},{literial_v}}; + static String[][][] arstr3 = {arstr2,arstr2}; + + private RC_Array_02(){ + base1 = new String[]{"10","20","30","40"}; + base2 = new String[][]{{"10","20","30","40"},{"40","50"},{"60"}}; + base21 = new String[][]{{"40","50","60","30"},{"70","80"},{"90"}}; + base3 = new String[][][]{{{"10","20","30","40"},{"40","50"},{"60"}},{{"40","50","60","30"},{"70","80"},{"90"}}}; + } + + private RC_Array_02(String[] Stringar){ + base1 = Stringar; + } + + private RC_Array_02(String[][] Stringarr){ + base2 = Stringarr; + } + + private RC_Array_02(String[][][] Stringarrr){ + base3 = Stringarrr; + } + + private RC_Array_02(String[] Stringar, String[][] Stringarr, String[][][] Stringarrr){ + base1 = Stringar; + base2 = Stringarr; + base3 = Stringarrr; + } + + public static void main(String [] args) { + final String[] TEST1 = {"10","20","30","40"}; + final String[][] TEST2 = {TEST1,{"40","50"},{"60"}}; + final String[][] TEST21 = {{"40","50","60","30"},{"70","80"},{"90"}}; + final String[][][] TEST3 = {TEST2,TEST21}; + //literial type data + final String literial_v = "abc"; + final String[] arstrr1 = {literial_v,literial_v,literial_v,literial_v}; + final String[][] arstrr2 = {{"abc","abc","abc","abc"},{"abc","abc"},{literial_v}}; + final String[][][] arstrr3 = {arstrr2,arstrr2}; + + //Initialization check + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2 + && arstrr1.length == 4 && arstrr2.length == 3 && arstrr3.length == 2 + && arstr1.length == 4 && arstr2.length == 3 && arstr3.length == 2) + check_count++; + else + System.out.println("ErrorResult String step1"); + + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + test01(4,TEST1,TEST2,TEST3); + test01(4,arr1,arr2,arr3); + test01(4,arstr1,arstr2,arstr3); + test01(4,arstrr1,arstrr2,arstrr3); + + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2 + && arstrr1.length == 4 && arstrr2.length == 3 && arstrr3.length == 2 + && arstr1.length == 4 && arstr2.length == 3 && arstr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step2"); + + //test02 interface call, call function change to modify the parameter value and judge + test02(4,TEST1,TEST2,TEST3); + test02(4,arr1,arr2,arr3); + test02(4,arstr1,arstr2,arstr3); + test02(4,arstrr1,arstrr2,arstrr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2 + && arstrr1.length == 4 && arstrr2.length == 3 && arstrr3.length == 2 + && arstr1.length == 4 && arstr2.length == 3 && arstr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step3"); + + //The test03 interface call, call the RC_Array_02_test01 function return value to the parameter third and judged. + //RC_Array_02_test01,return 2D array,Call the multi-parameter constructor of RC_Array_01, and assign a value to + //the newly created object field, and judge the result + test03(TEST2); + test03(arr2); + if(TEST2.length == 3 && arr2.length == 3) + check_count++; + else + System.out.println("ErrorResult in step4"); + + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_02() no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + //Test points: inheritance, constructor, return function call, constant, variable, do not receive return value + RC_Array_02_test02(); + + //Get an array object by returning a function call + String[] getarr1 = RC_Array_get01(); + String[][] getarr2 = RC_Array_get02(); + String[][][] getarr3 = RC_Array_get03(); + if(getarr1.length == 4 && getarr2.length == 3 && getarr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step5"); + + //Exception testing + Boolean ret = RC_Array_Exception(); + if (ret == true) + check_count++; + else + System.out.println("RC_Array_Exception ErrorResult"); + + //Result judgment + //System.out.println(check_count); + if(check_count == 28) + System.out.println("ExpectResult"); + + } + + private static void test01(int first, String[] second, String[][] third, String[][][] four) { + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + String [] xyz = {"23","24","25","26"}; + String[][] xyz2 = {{"23","24","25","26"},{"23","24"},{"23"}}; + String[][][] xyz3 = {xyz2,xyz2}; + if(second.length == 4 && third.length == 3 && four.length == 2 + && xyz.length == 4 && xyz2.length == 3 && xyz3.length == 2) + check_count++; + else + System.out.println("ErrorResult in test01"); + } + + private static Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + + private static void test02(int first, String[] second, String[][] third, String[][][] four) { + //test02 interface call, call function change to modify the parameter value and judge + String [] xyz = {"23","24","25","26"}; + String[][] xyz2 = {{"23","24","25","26"},{"23","24"},{"23"}}; + String[][][] xyz3 = {xyz2,xyz2}; + second = (String[]) change(second,xyz); + third = (String[][])change(third,xyz2); + four = (String[][][]) change(four,xyz3); + if(second.length == 4 && third.length == 3 && four.length == 2) + check_count++; + else + System.out.println("ErrorResult in test02"); + } + + private static void test03(String[][] third) { + //The test03 interface is called, and the RC_Array_02_test01 function call is assigned as the return value to + // the parameter third and judged. + third = RC_Array_02_test01(); + if(third.length == 3) + check_count++; + else + System.out.println("ErrorResult in test03"); + } + + private static String[] RC_Array_get01() + { + //Call the 1D array returned by RC_Array_set01 + return RC_Array_set01(); + } + + private static String[][] RC_Array_get02() + { + //Call the 2D array returned by RC_Array_set02 + return RC_Array_set02(); + } + + private static String[][][] RC_Array_get03() + { + //Call the 3D array returned by RC_Array_set03 + return RC_Array_set03(); + } + + private static String[] RC_Array_set01() + { + //return 1D array,Call the constructor of the 1D array parameter of RC_Array_set01, and assign a value to the + // field of the newly created object, and judge the result + String [] value1 = {"23","24","25","26"}; + RC_Array_02 rctest=new RC_Array_02(value1); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new String[] {"88","10","02","11"}; + if(rctest.base1.length == 4) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set01"); + return rctest.base1; + } + + private static String[][] RC_Array_set02() + { + //return 2D array,Call the constructor of the 2D array parameter of RC_Array_set02, and assign a + // value to the domain of the newly created object, and judge the result + String[][] value2 = {{"23","24","25","26"},{"23","24"},{"23"}}; + RC_Array_02 rctest=new RC_Array_02(value2); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base2 = new String[][] {{"88","10","02","11"},{"10","92"},{"16"}}; + if(rctest.base2.length == 3) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set02"); + return rctest.base2; + } + + private static String[][][] RC_Array_set03() + { + //return 3D array,Call the constructor of the 3D array parameter of RC_Array_set03, and assign a value to the + // field of the newly created object, and judge the result + String[][][] value3 = {{{"10","20","30","40"},{"40","50"},{"60"}},{{"40","50","60","30"},{"70","80"},{"90"}}}; + RC_Array_02 rctest=new RC_Array_02(value3); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base3 = new String[][][]{{{"88","10","02","11"},{"10","92"},{"12"}},{{"88","10","02","11"},{"10","92"},{"16"}}}; + if(rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set03"); + return rctest.base3; + } + + private static String[][] RC_Array_02_test01() + { + //return 2D array,Call the multi-parameter constructor of RC_Array_02, and assign a value to the newly created + // object field, and judge the result + String [] value1 = {"23","24","25","26"}; + String[][] value2 = {{"23","24","25","26"},{"23","24"},{"23"}}; + String[][][] value3 = {value2,value2}; + RC_Array_02 rctest=new RC_Array_02(value1,value2,value3); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new String[] {"88","10","02","11"}; + rctest.base2 = new String[][] {{"88","10","02","11"},{"10","92"},{"16"}}; + rctest.base21 = new String[][] {{"88","10","02","11"},{"10","92"},{"12"}}; + rctest.base3 = new String[][][]{{{"88","10","02","11"},{"10","92"},{"12"}},{{"88","10","02","11"},{"10","92"},{"16"}}}; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_02_test01"); + return rctest.base21; + } + + private static String[] RC_Array_final01() + { + final String [] VALUE1 = {"23","24","25","26"}; + return VALUE1; + } + private static String[][] RC_Array_final02() + { + final String[][] VALUE2 = {{"23","24","25","26"},{"23","24"},{"23"}}; + return VALUE2; + } + private static String[][][] RC_Array_final03() + { + final String[][][] VALUE3 = {{{"10","20","30","40"},{"40","50"},{"60"}},{{"40","50","60","30"},{"70","80"},{"90"}}}; + return VALUE3; + } + private static String[][] RC_Array_02_test02() + { + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_02 () no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + final String [] VALUE1 = RC_Array_final01(); + final String[][] VALUE2 = RC_Array_final02(); + final String[][][] VALUE3 = RC_Array_final03(); + RC_Array_02 rctest=new RC_Array_02(); + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_02_test02"); + rctest.base1 = VALUE1; + rctest.base2 = VALUE2; + rctest.base21 = VALUE2; + rctest.base3 = VALUE3; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_02_test02_2"); + return VALUE2; + } + + private static Boolean RC_Array_Exception() + { + //Exception test,exclude NullPointerException,ArrayIndexOutOfBoundsException and so on + int check = 0; + String [] value1 = RC_Array_final01(); + String[][] value2 = RC_Array_final02(); + String[][][] value3 = RC_Array_final03(); + //Is the value as expect after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——1"); + //ArrayIndexOutOfBoundsException + try { + Array.get(value1,5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value1[5] = "error"; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.set(value1,5,"10"); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.get(RC_Array_final01(),5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.get(value2[5],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.get(value2[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.get(RC_Array_final02()[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.get(value3[0][3],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.get(value3[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.get(RC_Array_final03()[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + + //IndexOutOfBoundsException + try { + char[] ch1 = {'h','x','c','t'}; + Array.set(RC_Array_final03()[0][0],0,String.valueOf(ch1, 5, 2)); + }catch (IndexOutOfBoundsException e){ + check++; + } + //ClassCastException + RC_Array_02 rc1 = new RC_Array_02(); + try{ + Base_002 bs1 = new Base_002(); + rc1 = (RC_Array_02)bs1; + rc1.base1[0] = "kitty"; + }catch (ClassCastException e) + { + if (rc1.base1[0] != "kitty") + check++; + } + //Whether the judgment value is normal after Exception + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——2"); + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.get(value1,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.get(value2,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.get(value3,1); + }catch (NullPointerException e){ + check++; + } + //System.out.println(check); + if (check == 17) + return true; + else + return false; + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0368-rc-ArrayOptimization-RC_Array_03/RC_Array_03.java b/test/testsuite/ouroboros/rc_test/RC0368-rc-ArrayOptimization-RC_Array_03/RC_Array_03.java new file mode 100755 index 0000000000000000000000000000000000000000..1b58056b5e307c43fec7df282807ca1047d8dd29 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0368-rc-ArrayOptimization-RC_Array_03/RC_Array_03.java @@ -0,0 +1,428 @@ +/* + *- @TestCaseID:maple/runtime/rc/optimization/RC_Array_03.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Scenario testing for RC optimization: testing various scenes of 1D, 2D, 3D Char array objects,including: + * 1.Parameter modification / parameter has not been modified + * 2.final、static + * 3.As a constructor fun + * 4.Function call + * 5.Object Passing + * 6.return constant; variable; function call + * 7.Inherited as a parent class; child class inherits the parent class; interface call; + * 8.Exception + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Array_03.java + *- @ExecuteClass: RC_Array_03 + *- @ExecuteArgs: + *- @Remark: + */ +import java.lang.reflect.Array; +import java.util.Arrays; + +class Base_003{ + //Parent interface + volatile char[] base1; + char[][] base2; + char[][] base21; + char[][][] base3; +} + +public class RC_Array_03 extends Base_003{ + static int check_count = 0; + static char[] arr1 = {'a','b','c','d'}; + static char[][] arr2 = {{'a','b','c','d'},{'e','f'},{'g'}}; + static char[][] arr21 = {{'h','i','j','k'},{'l','m'},{'n'}}; + static char[][][] arr3 = {arr2,arr21}; + + private RC_Array_03(){ + base1 = new char[]{'a','b','c','d'}; + base2 = new char[][]{{'a','b','c','d'},{'e','f'},{'g'}}; + base21 = new char[][]{{'h','i','j','k'},{'l','m'},{'n'}}; + base3 = new char[][][]{{{'a','b','c','d'},{'e','f'},{'g'}},{{'h','i','j','k'},{'l','m'},{'n'}}}; + } + + private RC_Array_03(char[] charar){ + base1 = charar; + } + + private RC_Array_03(char[][] chararr){ + base2 = chararr; + } + + private RC_Array_03(char[][][] chararrr){ + base3 = chararrr; + } + + private RC_Array_03(char[] charar, char[][] chararr, char[][][] chararrr){ + base1 = charar; + base2 = chararr; + base3 = chararrr; + } + + public static void main(String[] args) { + final char[] TEST1 = {'1','2','3','4'}; + final char[][] TEST2 = {TEST1,{'4','5'},{'6'}}; + final char[][] TEST21 = {{'4','5','6','3'},{'7','8'},{'9'}}; + final char[][][] TEST3 = {TEST2,TEST21}; + + //Initialization check + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult char step1"); + + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + test01(4,TEST1,TEST2,TEST3); + test01(4,arr1,arr2,arr3); + + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step2"); + + //test02 interface call, call function change to modify the parameter value and judge + test02(4,TEST1,TEST2,TEST3); + test02(4,arr1,arr2,arr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step3"); + + //The test03 interface call, call the RC_Array_03_test01 function return value to the parameter third and judged. + //RC_Array_03_test01,return 2D array,Call the multi-parameter constructor of RC_Array_01, and assign a value to + //the newly created object field, and judge the result + test03(TEST2); + test03(arr2); + if(TEST2.length == 3 && arr2.length == 3) + check_count++; + else + System.out.println("ErrorResult in step4"); + + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_03() no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + //Test points: inheritance, constructor, return function call, constant, variable, do not receive return value + RC_Array_03_test02(); + + //Get an array object by returning a function call + char[] getarr1 = RC_Array_get01(); + char[][] getarr2 = RC_Array_get02(); + char[][][] getarr3 = RC_Array_get03(); + if(getarr1.length == 4 && getarr2.length == 3 && getarr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step5"); + + //Exception testing + Boolean ret = RC_Array_Exception(); + if (ret == true) + check_count++; + else + System.out.println("RC_Array_Exception ErrorResult"); + + //Result judgment + //System.out.println(check_count); + if(check_count == 24) + System.out.println("ExpectResult"); + + } + + private static void test01(int first, char[] second, char[][] third, char[][][] four) { + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + char [] xyz = {'h','x','w','g'}; + char[][] xyz2 = {{'h','x','w','g'},{'w','g'},{'q'}}; + char[][][] xyz3 = {xyz2,xyz2}; + if(second.length == 4 && third.length == 3 && four.length == 2 + && xyz.length == 4 && xyz2.length == 3 && xyz3.length == 2) + check_count++; + else + System.out.println("ErrorResult in test01"); + } + + private static Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + + private static void test02(int first, char[] second, char[][] third, char[][][] four) { + //test02 interface call, call function change to modify the parameter value and judge + char [] xyz = {'h','x','w','g'}; + char[][] xyz2 = {{'h','x','w','g'},{'w','g'},{'q'}}; + char[][][] xyz3 = {xyz2,xyz2}; + second = (char[]) change(second,xyz); + third = (char[][])change(third,xyz2); + four = (char[][][]) change(four,xyz3); + if(second.length == 4 && third.length == 3 && four.length == 2) + check_count++; + else + System.out.println("ErrorResult in test02"); + } + + private static void test03(char[][] third) { + //The test03 interface is called, and the RC_Array_03_test01 function call is assigned as the return value to + // the parameter third and judged. + third = RC_Array_03_test01(); + if(third.length == 3) + check_count++; + else + System.out.println("ErrorResult in test03"); + } + + private static char[] RC_Array_get01() + { + //Call the 1D array returned by RC_Array_set01 + return RC_Array_set01(); + } + + private static char[][] RC_Array_get02() + { + //Call the 2D array returned by RC_Array_set02 + return RC_Array_set02(); + } + + private static char[][][] RC_Array_get03() + { + //Call the 3D array returned by RC_Array_set03 + return RC_Array_set03(); + } + + private static char[] RC_Array_set01() + { + //return 1D array,Call the constructor of the 1D array parameter of RC_Array_set01, and assign a value to the + // field of the newly created object, and judge the result + char [] value1 = {'h','x','w','g'}; + RC_Array_03 rctest=new RC_Array_03(value1); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new char[] {'8','0','2','3'}; + if(rctest.base1.length == 4) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set01"); + return rctest.base1; + } + + private static char[][] RC_Array_set02() + { + //return 2D array,Call the constructor of the 2D array parameter of RC_Array_set02, and assign a + // value to the domain of the newly created object, and judge the result + char[][] value2 = {{'h','x','w','g'},{'w','g'},{'q'}}; + RC_Array_03 rctest=new RC_Array_03(value2); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base2 = new char[][] {{'8','0','2','3'},{'w','g'},{'q'}}; + if(rctest.base2.length == 3) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set02"); + return rctest.base2; + } + + private static char[][][] RC_Array_set03() + { + //return 3D array,Call the constructor of the 3D array parameter of RC_Array_set03, and assign a value to the + // field of the newly created object, and judge the result + char[][][] value3 = {{{'1','2','3','4'},{'4','5'},{'6'}},{{'4','5','6','3'},{'7','8'},{'9'}}}; + RC_Array_03 rctest=new RC_Array_03(value3); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base3 = new char[][][]{{{'w','a','n','g'},{'s','u'},{'n'}},{{'w','a','n','g'},{'w','g'},{'q'}}}; + if(rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set03"); + return rctest.base3; + } + + private static char[][] RC_Array_03_test01() + { + //return 2D array,Call the multi-parameter constructor of RC_Array_03, and assign a value to the newly created + // object field, and judge the result + char [] value1 = {'h','x','w','g'}; + char[][] value2 = {{'h','x','w','g'},{'w','g'},{'q'}}; + char[][][] value3 = {value2,value2}; + RC_Array_03 rctest=new RC_Array_03(value1,value2,value3); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new char[] {'w','a','n','g'}; + rctest.base2 = new char[][] {{'w','a','n','g'},{'w','g'},{'q'}}; + rctest.base21 = new char[][] {{'w','a','n','g'},{'s','u'},{'n'}}; + rctest.base3 = new char[][][]{{{'w','a','n','g'},{'s','u'},{'n'}},{{'w','a','n','g'},{'w','g'},{'q'}}}; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_03_test01"); + return rctest.base21; + } + + private static char[] RC_Array_final01() + { + final char [] VALUE1 = {'h','x','w','g'}; + return VALUE1; + } + private static char[][] RC_Array_final02() + { + final char[][] VALUE2 = {{'h','x','w','g'},{'w','g'},{'q'}}; + return VALUE2; + } + private static char[][][] RC_Array_final03() + { + final char[][][] VALUE3 = {{{'1','2','3','4'},{'4','5'},{'6'}},{{'4','5','6','3'},{'7','8'},{'9'}}}; + return VALUE3; + } + private static char[][] RC_Array_03_test02() + { + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_03 () no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + final char [] VALUE1 = RC_Array_final01(); + final char[][] VALUE2 = RC_Array_final02(); + final char[][][] VALUE3 = RC_Array_final03(); + RC_Array_03 rctest=new RC_Array_03(); + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_03_test02"); + rctest.base1 = VALUE1; + rctest.base2 = VALUE2; + rctest.base21 = VALUE2; + rctest.base3 = VALUE3; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_03_test02_2"); + return VALUE2; + } + + private static Boolean RC_Array_Exception() + { + //Exception test,exclude NullPointerException,ArrayIndexOutOfBoundsException and so on + int check = 0; + char[] value1 = RC_Array_final01(); + char[][] value2 = RC_Array_final02(); + char[][][] value3 = RC_Array_final03(); + //Is the value as expect after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——1"); + //ArrayIndexOutOfBoundsException + try { + Array.getChar(value1,5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value1[5] = 'e'; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.setChar(value1,5,'1'); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getChar(RC_Array_final01(),5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getChar(value2[5],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getChar(value2[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getChar(RC_Array_final02()[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getChar(value3[0][3],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getChar(value3[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getChar(RC_Array_final03()[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + //IllegalArgumentException + try { + Array.getChar(value2,1); + }catch (IllegalArgumentException e){ + check++; + } + try { + Array.getChar(value3,1); + }catch (IllegalArgumentException e){ + check++; + } + //ClassCastException + RC_Array_03 rc1 = new RC_Array_03(); + try{ + Base_003 bs1 = new Base_003(); + rc1 = (RC_Array_03)bs1; + rc1.base1[0] = 'p'; + }catch (ClassCastException e) + { + if (rc1.base1[0] != 'p') + check++; + } + //Whether the judgment value is normal after Exception + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——2"); + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.getChar(value1,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getChar(value2,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getChar(value3,1); + }catch (NullPointerException e){ + check++; + } + if (check == 18) + return true; + else + return false; + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0369-rc-ArrayOptimization-RC_Array_04/RC_Array_04.java b/test/testsuite/ouroboros/rc_test/RC0369-rc-ArrayOptimization-RC_Array_04/RC_Array_04.java new file mode 100755 index 0000000000000000000000000000000000000000..6d12e42221c4501aec33a1fddcbbc856c2131d6f --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0369-rc-ArrayOptimization-RC_Array_04/RC_Array_04.java @@ -0,0 +1,428 @@ +/* + *- @TestCaseID:maple/runtime/rc/optimization/RC_Array_04.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Scenario testing for RC optimization: testing various scenes of 1D, 2D, 3D boolean array objects,including: + * 1.Parameter modification / parameter has not been modified + * 2.final、static + * 3.As a constructor fun + * 4.Function call + * 5.Object Passing + * 6.return constant; variable; function call + * 7.Inherited as a parent class; child class inherits the parent class; interface call; + * 8.Exception + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Array_04.java + *- @ExecuteClass: RC_Array_04 + *- @ExecuteArgs: + *- @Remark: + */ +import java.lang.reflect.Array; +import java.util.Arrays; + +class Base_004{ + //Parent interface + volatile boolean[] base1; + boolean[][] base2; + boolean[][] base21; + boolean[][][] base3; +} + +public class RC_Array_04 extends Base_004{ + static int check_count = 0; + static boolean[] arr1 = {true,false,false,true}; + static boolean[][] arr2 = {{true,false,false,true},{false,false},{true,true}}; + static boolean[][] arr21 = {{false,true,false,true},{true,false},{false,true}}; + static boolean[][][] arr3 = {arr2,arr21}; + + private RC_Array_04(){ + base1 = new boolean[]{true,true,true,true}; + base2 = new boolean[][]{{true,true,true,true},{false,false},{true,true}}; + base21 = new boolean[][]{{false,true,true,true},{false,true},{true,true}}; + base3 = new boolean[][][]{{{true,true,true,true},{false,false},{true,true}},{{false,true,true,true},{false,true},{true,true}}}; + } + + private RC_Array_04(boolean[] booleanar){ + base1 = booleanar; + } + + private RC_Array_04(boolean[][] booleanarr){ + base2 = booleanarr; + } + + private RC_Array_04(boolean[][][] booleanarrr){ + base3 = booleanarrr; + } + + private RC_Array_04(boolean[] booleanar, boolean[][] booleanarr, boolean[][][] booleanarrr){ + base1 = booleanar; + base2 = booleanarr; + base3 = booleanarrr; + } + + public static void main(String[] args) { + final boolean[] TEST1 = {true,true,true,true}; + final boolean[][] TEST2 = {TEST1,{false,false},{true,true}}; + final boolean[][] TEST21 = {{false,true,true,true},{false,true},{true,true}}; + final boolean[][][] TEST3 = {TEST2,TEST21}; + + //Initialization check + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult boolean step1"); + + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + test01(4,TEST1,TEST2,TEST3); + test01(4,arr1,arr2,arr3); + + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step2"); + + //test02 interface call, call function change to modify the parameter value and judge + test02(4,TEST1,TEST2,TEST3); + test02(4,arr1,arr2,arr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step3"); + + //The test03 interface call, call the RC_Array_04_test01 function return value to the parameter third and judged. + //RC_Array_04_test01,return 2D array,Call the multi-parameter constructor of RC_Array_01, and assign a value to + //the newly created object field, and judge the result + test03(TEST2); + test03(arr2); + if(TEST2.length == 3 && arr2.length == 3) + check_count++; + else + System.out.println("ErrorResult in step4"); + + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_04() no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + //Test points: inheritance, constructor, return function call, constant, variable, do not receive return value + RC_Array_04_test02(); + + //Get an array object by returning a function call + boolean[] getarr1 = RC_Array_get01(); + boolean[][] getarr2 = RC_Array_get02(); + boolean[][][] getarr3 = RC_Array_get03(); + if(getarr1.length == 4 && getarr2.length == 3 && getarr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step5"); + + //Exception testing + boolean ret = RC_Array_Exception(); + if (ret == true) + check_count++; + else + System.out.println("RC_Array_Exception ErrorResult"); + + //Result judgment + //System.out.println(check_count); + if(check_count == 24) + System.out.println("ExpectResult"); + + } + + private static void test01(int first, boolean[] second, boolean[][] third, boolean[][][] four) { + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + boolean [] xyz = {false,true,false,true}; + boolean[][] xyz2 = {{true,true,true,true},{false,false},{true}}; + boolean[][][] xyz3 = {xyz2,xyz2}; + if(second.length == 4 && third.length == 3 && four.length == 2 + && xyz.length == 4 && xyz2.length == 3 && xyz3.length == 2) + check_count++; + else + System.out.println("ErrorResult in test01"); + } + + private static Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + + private static void test02(int first, boolean[] second, boolean[][] third, boolean[][][] four) { + //test02 interface call, call function change to modify the parameter value and judge + boolean [] xyz = {false,true,false,true}; + boolean[][] xyz2 = {{true,true,true,true},{false,false},{true}}; + boolean[][][] xyz3 = {xyz2,xyz2}; + second = (boolean[]) change(second,xyz); + third = (boolean[][])change(third,xyz2); + four = (boolean[][][]) change(four,xyz3); + if(second.length == 4 && third.length == 3 && four.length == 2) + check_count++; + else + System.out.println("ErrorResult in test02"); + } + + private static void test03(boolean[][] third) { + //The test03 interface is called, and the RC_Array_04_test01 function call is assigned as the return value to + // the parameter third and judged. + third = RC_Array_04_test01(); + if(third.length == 3) + check_count++; + else + System.out.println("ErrorResult in test03"); + } + + private static boolean[] RC_Array_get01() + { + //Call the 1D array returned by RC_Array_set01 + return RC_Array_set01(); + } + + private static boolean[][] RC_Array_get02() + { + //Call the 2D array returned by RC_Array_set02 + return RC_Array_set02(); + } + + private static boolean[][][] RC_Array_get03() + { + //Call the 3D array returned by RC_Array_set03 + return RC_Array_set03(); + } + + private static boolean[] RC_Array_set01() + { + //return 1D array,Call the constructor of the 1D array parameter of RC_Array_set01, and assign a value to the + // field of the newly created object, and judge the result + boolean [] value1 = {false,false,false,false}; + RC_Array_04 rctest=new RC_Array_04(value1); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new boolean[] {true,true,true,true}; + if(rctest.base1.length == 4) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set01"); + return rctest.base1; + } + + private static boolean[][] RC_Array_set02() + { + //return 2D array,Call the constructor of the 2D array parameter of RC_Array_set02, and assign a + // value to the domain of the newly created object, and judge the result + boolean[][] value2 = {{true,true,true,true},{false,false},{true}}; + RC_Array_04 rctest=new RC_Array_04(value2); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base2 = new boolean[][] {{false,false,false,false},{false,false},{true}}; + if(rctest.base2.length == 3) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set02"); + return rctest.base2; + } + + private static boolean[][][] RC_Array_set03() + { + //return 3D array,Call the constructor of the 3D array parameter of RC_Array_set03, and assign a value to the + // field of the newly created object, and judge the result + boolean[][][] value3 = {{{true,true,true,true},{false,false},{true}},{{false,false,false,false},{false,false},{true}}}; + RC_Array_04 rctest=new RC_Array_04(value3); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base3 = new boolean[][][]{{{false,false,false,false},{false,false},{true}},{{true,true,true,true},{false,false},{true}}}; + if(rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set03"); + return rctest.base3; + } + + private static boolean[][] RC_Array_04_test01() + { + //return 2D array,Call the multi-parameter constructor of RC_Array_04, and assign a value to the newly created + // object field, and judge the result + boolean [] value1 = {true,true,true,true}; + boolean[][] value2 = {{true,true,true,true},{false,false},{true}}; + boolean[][][] value3 = {value2,value2}; + RC_Array_04 rctest=new RC_Array_04(value1,value2,value3); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new boolean[] {false,false,false,false}; + rctest.base2 = new boolean[][] {{false,false,false,false},{false,false},{true}}; + rctest.base21 = new boolean[][] {{false,true,true,false},{false,false},{true}}; + rctest.base3 = new boolean[][][]{{{false,false,false,false},{false,false},{true}},{{false,true,true,false},{false,false},{true}}}; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_04_test01"); + return rctest.base21; + } + + private static boolean[] RC_Array_final01() + { + final boolean[] VALUE1 = {true,true,true,true}; + return VALUE1; + } + private static boolean[][] RC_Array_final02() + { + final boolean[][] VALUE2 = {{false,false,false,false},{false,false},{true}}; + return VALUE2; + } + private static boolean[][][] RC_Array_final03() + { + final boolean[][][] VALUE3 = {{{false,true,true,false},{false,false},{true}},{{false,false,false,false},{false,false},{true}}}; + return VALUE3; + } + private static boolean[][] RC_Array_04_test02() + { + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_04 () no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + final boolean[] VALUE1 = RC_Array_final01(); + final boolean[][] VALUE2 = RC_Array_final02(); + final boolean[][][] VALUE3 = RC_Array_final03(); + RC_Array_04 rctest=new RC_Array_04(); + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_04_test02"); + rctest.base1 = VALUE1; + rctest.base2 = VALUE2; + rctest.base21 = VALUE2; + rctest.base3 = VALUE3; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_04_test02_2"); + return VALUE2; + } + + private static boolean RC_Array_Exception() + { + //Exception test,exclude NullPointerException,ArrayIndexOutOfBoundsException and so on + int check = 0; + boolean[] value1 = RC_Array_final01(); + boolean[][] value2 = RC_Array_final02(); + boolean[][][] value3 = RC_Array_final03(); + //Is the value as expect after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——1"); + //ArrayIndexOutOfBoundsException + try { + Array.getBoolean(value1,5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value1[5] = false; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.setBoolean(value1,5,true); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getBoolean(RC_Array_final01(),5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getBoolean(value2[5],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getBoolean(value2[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getBoolean(RC_Array_final02()[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getBoolean(value3[0][3],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getBoolean(value3[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getBoolean(RC_Array_final03()[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + //IllegalArgumentException + try { + Array.getBoolean(value2,1); + }catch (IllegalArgumentException e){ + check++; + } + try { + Array.getBoolean(value3,1); + }catch (IllegalArgumentException e){ + check++; + } + //ClassCastException + RC_Array_04 rc1 = new RC_Array_04(); + try{ + Base_004 bs1 = new Base_004(); + rc1 = (RC_Array_04)bs1; + rc1.base1[0] = false; + }catch (ClassCastException e) + { + if (rc1.base1[0] != false) + check++; + } + //Whether the judgment value is normal after Exception + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——2"); + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.getBoolean(value1,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getBoolean(value2,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getBoolean(value3,1); + }catch (NullPointerException e){ + check++; + } + //System.out.println(check); + if (check == 18) + return true; + else + return false; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0370-rc-ArrayOptimization-RC_Array_05/RC_Array_05.java b/test/testsuite/ouroboros/rc_test/RC0370-rc-ArrayOptimization-RC_Array_05/RC_Array_05.java new file mode 100755 index 0000000000000000000000000000000000000000..fd54b09ffcdae98f87aba5eb89d7955fa44ea818 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0370-rc-ArrayOptimization-RC_Array_05/RC_Array_05.java @@ -0,0 +1,429 @@ +/* + *- @TestCaseID:maple/runtime/rc/optimization/RC_Array_05.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Scenario testing for RC optimization: testing various scenes of 1D, 2D, 3D byte array objects,including: + * 1.Parameter modification / parameter has not been modified + * 2.final、static + * 3.As a constructor fun + * 4.Function call + * 5.Object Passing + * 6.return constant; variable; function call + * 7.Inherited as a parent class; child class inherits the parent class; interface call; + * 8.Exception + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Array_05.java + *- @ExecuteClass: RC_Array_05 + *- @ExecuteArgs: + *- @Remark: + */ +import java.lang.reflect.Array; +import java.util.Arrays; + +class Base_005{ + //Parent interface + volatile byte[] base1; + byte[][] base2; + byte[][] base21; + byte[][][] base3; +} + +public class RC_Array_05 extends Base_005{ + static int check_count = 0; + static byte[] arr1 = {1,2,3,4}; + static byte[][] arr2 = {{1,2,3,4},{5,6},{7,8}}; + static byte[][] arr21 = {{4,5,6,7},{8,9},{10,11}}; + static byte[][][] arr3 = {arr2,arr21}; + + private RC_Array_05(){ + base1 = new byte[]{1,2,3,4}; + base2 = new byte[][]{{1,2,3,4},{5,6},{7,8}}; + base21 = new byte[][]{{4,5,6,7},{8,9},{10,11}}; + base3 = new byte[][][]{{{1,2,3,4},{5,6},{7,8}},{{4,5,6,7},{8,9},{10,11}}}; + } + + private RC_Array_05(byte[] bytear){ + base1 = bytear; + } + + private RC_Array_05(byte[][] bytearr){ + base2 = bytearr; + } + + private RC_Array_05(byte[][][] bytearrr){ + base3 = bytearrr; + } + + private RC_Array_05(byte[] bytear, byte[][] bytearr, byte[][][] bytearrr){ + base1 = bytear; + base2 = bytearr; + base3 = bytearrr; + } + + public static void main(String[] args) { + final byte[] TEST1 = {1,2,3,4}; + final byte[][] TEST2 = {TEST1,{5,6},{7,8}}; + final byte[][] TEST21 = {{4,5,6,7},{8,9},{10,11}}; + final byte[][][] TEST3 = {TEST2,TEST21}; + + //Initialization check + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult byte step1"); + + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + test01(4,TEST1,TEST2,TEST3); + test01(4,arr1,arr2,arr3); + + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step2"); + + //test02 interface call, call function change to modify the parameter value and judge + test02(4,TEST1,TEST2,TEST3); + test02(4,arr1,arr2,arr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step3"); + + //The test03 interface call, call the RC_Array_05_test01 function return value to the parameter third and judged. + //RC_Array_05_test01,return 2D array,Call the multi-parameter constructor of RC_Array_01, and assign a value to + //the newly created object field, and judge the result + test03(TEST2); + test03(arr2); + if(TEST2.length == 3 && arr2.length == 3) + check_count++; + else + System.out.println("ErrorResult in step4"); + + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_05() no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + //Test points: inheritance, constructor, return function call, constant, variable, do not receive return value + RC_Array_05_test02(); + + //Get an array object by returning a function call + byte[] getarr1 = RC_Array_get01(); + byte[][] getarr2 = RC_Array_get02(); + byte[][][] getarr3 = RC_Array_get03(); + if(getarr1.length == 4 && getarr2.length == 3 && getarr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step5"); + + //Exception testing + boolean ret = RC_Array_Exception(); + if (ret == true) + check_count++; + else + System.out.println("RC_Array_Exception ErrorResult"); + + //Result judgment + //System.out.println(check_count); + if(check_count == 24) + System.out.println("ExpectResult"); + + } + + private static void test01(int first, byte[] second, byte[][] third, byte[][][] four) { + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + byte [] xyz = {8,8,1,0}; + byte[][] xyz2 = {{1,2,3,4},{1,1},{0}}; + byte[][][] xyz3 = {xyz2,xyz2}; + if(second.length == 4 && third.length == 3 && four.length == 2 + && xyz.length == 4 && xyz2.length == 3 && xyz3.length == 2) + check_count++; + else + System.out.println("ErrorResult in test01"); + } + + private static Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + + private static void test02(int first, byte[] second, byte[][] third, byte[][][] four) { + //test02 interface call, call function change to modify the parameter value and judge + byte [] xyz = {8,8,1,0}; + byte[][] xyz2 = {{1,2,3,4},{1,1},{0}}; + byte[][][] xyz3 = {xyz2,xyz2}; + second = (byte[]) change(second,xyz); + third = (byte[][])change(third,xyz2); + four = (byte[][][]) change(four,xyz3); + if(second.length == 4 && third.length == 3 && four.length == 2) + check_count++; + else + System.out.println("ErrorResult in test02"); + } + + private static void test03(byte[][] third) { + //The test03 interface is called, and the RC_Array_05_test01 function call is assigned as the return value to + // the parameter third and judged. + third = RC_Array_05_test01(); + if(third.length == 3) + check_count++; + else + System.out.println("ErrorResult in test03"); + } + + private static byte[] RC_Array_get01() + { + //Call the 1D array returned by RC_Array_set01 + return RC_Array_set01(); + } + + private static byte[][] RC_Array_get02() + { + //Call the 2D array returned by RC_Array_set02 + return RC_Array_set02(); + } + + private static byte[][][] RC_Array_get03() + { + //Call the 3D array returned by RC_Array_set03 + return RC_Array_set03(); + } + + private static byte[] RC_Array_set01() + { + //return 1D array,Call the constructor of the 1D array parameter of RC_Array_set01, and assign a value to the + // field of the newly created object, and judge the result + byte [] value1 = {9,2,8,8}; + RC_Array_05 rctest=new RC_Array_05(value1); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new byte[] {1,2,3,4}; + if(rctest.base1.length == 4) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set01"); + return rctest.base1; + } + + private static byte[][] RC_Array_set02() + { + //return 2D array,Call the constructor of the 2D array parameter of RC_Array_set02, and assign a + // value to the domain of the newly created object, and judge the result + byte[][] value2 = {{1,2,3,4},{1,1},{0}}; + RC_Array_05 rctest=new RC_Array_05(value2); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base2 = new byte[][] {{9,2,8,8},{1,1},{0}}; + if(rctest.base2.length == 3) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set02"); + return rctest.base2; + } + + private static byte[][][] RC_Array_set03() + { + //return 3D array,Call the constructor of the 3D array parameter of RC_Array_set03, and assign a value to the + // field of the newly created object, and judge the result + byte[][][] value3 = {{{1,2,3,4},{1,1},{0}},{{9,2,8,8},{1,1},{0}}}; + RC_Array_05 rctest=new RC_Array_05(value3); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base3 = new byte[][][]{{{9,2,8,8},{1,1},{0}},{{1,2,3,4},{1,1},{0}}}; + if(rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set03"); + return rctest.base3; + } + + private static byte[][] RC_Array_05_test01() + { + //return 2D array,Call the multi-parameter constructor of RC_Array_05, and assign a value to the newly created + // object field, and judge the result + byte [] value1 = {1,2,3,4}; + byte[][] value2 = {{1,2,3,4},{1,1},{0}}; + byte[][][] value3 = {value2,value2}; + RC_Array_05 rctest=new RC_Array_05(value1,value2,value3); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new byte[] {9,2,8,8}; + rctest.base2 = new byte[][] {{9,2,8,8},{1,1},{0}}; + rctest.base21 = new byte[][] {{6,6,6,5},{1,1},{0}}; + rctest.base3 = new byte[][][]{{{9,2,8,8},{1,1},{0}},{{6,6,6,5},{1,1},{0}}}; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_05_test01"); + return rctest.base21; + } + + private static byte[] RC_Array_final01() + { + final byte[] VALUE1 = {1,2,3,4}; + return VALUE1; + } + private static byte[][] RC_Array_final02() + { + final byte[][] VALUE2 = {{9,2,8,8},{1,1},{0}}; + return VALUE2; + } + private static byte[][][] RC_Array_final03() + { + final byte[][][] VALUE3 = {{{6,6,6,5},{1,1},{0}},{{9,2,8,8},{1,1},{0}}}; + return VALUE3; + } + private static byte[][] RC_Array_05_test02() + { + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_05 () no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + final byte[] VALUE1 = RC_Array_final01(); + final byte[][] VALUE2 = RC_Array_final02(); + final byte[][][] VALUE3 = RC_Array_final03(); + RC_Array_05 rctest=new RC_Array_05(); + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_05_test02"); + rctest.base1 = VALUE1; + rctest.base2 = VALUE2; + rctest.base21 = VALUE2; + rctest.base3 = VALUE3; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_05_test02_2"); + return VALUE2; + } + + private static boolean RC_Array_Exception() + { + //Exception test,exclude NullPointerException,ArrayIndexOutOfBoundsException and so on + int check = 0; + byte[] value1 = RC_Array_final01(); + byte[][] value2 = RC_Array_final02(); + byte[][][] value3 = RC_Array_final03(); + //Is the value as expect after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——1"); + //ArrayIndexOutOfBoundsException + try { + Array.getByte(value1,5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value1[5] = 'h'; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.setByte(value1,5,(byte)0x19); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getByte(RC_Array_final01(),5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getByte(value2[5],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getByte(value2[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getByte(RC_Array_final02()[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getByte(value3[0][3],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getByte(value3[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getByte(RC_Array_final03()[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + //IllegalArgumentException + try { + Array.getByte(value2,1); + }catch (IllegalArgumentException e){ + check++; + } + try { + Array.getByte(value3,1); + }catch (IllegalArgumentException e){ + check++; + } + //ClassCastException + RC_Array_05 rc1 = new RC_Array_05(); + try{ + Base_005 bs1 = new Base_005(); + rc1 = (RC_Array_05)bs1; + rc1.base1[0] = 8; + }catch (ClassCastException e) + { + if (rc1.base1[0] != 8) + check++; + } + //Whether the judgment value is normal after Exception + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——2"); + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.getByte(value1,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getByte(value2,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getByte(value3,1); + }catch (NullPointerException e){ + check++; + } + //System.out.println(check); + if (check == 18) + return true; + else + return false; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0371-rc-ArrayOptimization-RC_Array_06/RC_Array_06.java b/test/testsuite/ouroboros/rc_test/RC0371-rc-ArrayOptimization-RC_Array_06/RC_Array_06.java new file mode 100755 index 0000000000000000000000000000000000000000..424e5c7fbd5d9abc118f2e3eac354ca9c332d5e2 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0371-rc-ArrayOptimization-RC_Array_06/RC_Array_06.java @@ -0,0 +1,429 @@ +/* + *- @TestCaseID:maple/runtime/rc/optimization/RC_Array_06.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Scenario testing for RC optimization: testing various scenes of 1D, 2D, 3D short array objects,including: + * 1.Parameter modification / parameter has not been modified + * 2.final、static + * 3.As a constructor fun + * 4.Function call + * 5.Object Passing + * 6.return constant; variable; function call + * 7.Inherited as a parent class; child class inherits the parent class; interface call; + * 8.Exception + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Array_06.java + *- @ExecuteClass: RC_Array_06 + *- @ExecuteArgs: + *- @Remark: + */ +import java.lang.reflect.Array; +import java.util.Arrays; + +class Base_006{ + //Parent interface + volatile short[] base1; + short[][] base2; + short[][] base21; + short[][][] base3; +} + +public class RC_Array_06 extends Base_006{ + static int check_count = 0; + static short[] arr1 = {1,2,3,4}; + static short[][] arr2 = {{1,2,3,4},{5,6},{7,8}}; + static short[][] arr21 = {{4,5,6,7},{8,9},{10,11}}; + static short[][][] arr3 = {arr2,arr21}; + + private RC_Array_06(){ + base1 = new short[]{1,2,3,4}; + base2 = new short[][]{{1,2,3,4},{5,6},{7,8}}; + base21 = new short[][]{{4,5,6,7},{8,9},{10,11}}; + base3 = new short[][][]{{{1,2,3,4},{5,6},{7,8}},{{4,5,6,7},{8,9},{10,11}}}; + } + + private RC_Array_06(short[] shortar){ + base1 = shortar; + } + + private RC_Array_06(short[][] shortarr){ + base2 = shortarr; + } + + private RC_Array_06(short[][][] shortarrr){ + base3 = shortarrr; + } + + private RC_Array_06(short[] shortar, short[][] shortarr, short[][][] shortarrr){ + base1 = shortar; + base2 = shortarr; + base3 = shortarrr; + } + + public static void main(String[] args) { + final short[] TEST1 = {1,2,3,4}; + final short[][] TEST2 = {TEST1,{5,6},{7,8}}; + final short[][] TEST21 = {{4,5,6,7},{8,9},{10,11}}; + final short[][][] TEST3 = {TEST2,TEST21}; + + //Initialization check + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult short step1"); + + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + test01(4,TEST1,TEST2,TEST3); + test01(4,arr1,arr2,arr3); + + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step2"); + + //test02 interface call, call function change to modify the parameter value and judge + test02(4,TEST1,TEST2,TEST3); + test02(4,arr1,arr2,arr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step3"); + + //The test03 interface call, call the RC_Array_06_test01 function return value to the parameter third and judged. + //RC_Array_06_test01,return 2D array,Call the multi-parameter constructor of RC_Array_01, and assign a value to + //the newly created object field, and judge the result + test03(TEST2); + test03(arr2); + if(TEST2.length == 3 && arr2.length == 3) + check_count++; + else + System.out.println("ErrorResult in step4"); + + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_06() no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + //Test points: inheritance, constructor, return function call, constant, variable, do not receive return value + RC_Array_06_test02(); + + //Get an array object by returning a function call + short[] getarr1 = RC_Array_get01(); + short[][] getarr2 = RC_Array_get02(); + short[][][] getarr3 = RC_Array_get03(); + if(getarr1.length == 4 && getarr2.length == 3 && getarr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step5"); + + //Exception testing + boolean ret = RC_Array_Exception(); + if (ret == true) + check_count++; + else + System.out.println("RC_Array_Exception ErrorResult"); + + //Result judgment + //System.out.println(check_count); + if(check_count == 24) + System.out.println("ExpectResult"); + + } + + private static void test01(int first, short[] second, short[][] third, short[][][] four) { + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + short [] xyz = {8,8,1,0}; + short[][] xyz2 = {{1,2,3,4},{1,1},{0}}; + short[][][] xyz3 = {xyz2,xyz2}; + if(second.length == 4 && third.length == 3 && four.length == 2 + && xyz.length == 4 && xyz2.length == 3 && xyz3.length == 2) + check_count++; + else + System.out.println("ErrorResult in test01"); + } + + private static Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + + private static void test02(int first, short[] second, short[][] third, short[][][] four) { + //test02 interface call, call function change to modify the parameter value and judge + short [] xyz = {8,8,1,0}; + short[][] xyz2 = {{1,2,3,4},{1,1},{0}}; + short[][][] xyz3 = {xyz2,xyz2}; + second = (short[]) change(second,xyz); + third = (short[][])change(third,xyz2); + four = (short[][][]) change(four,xyz3); + if(second.length == 4 && third.length == 3 && four.length == 2) + check_count++; + else + System.out.println("ErrorResult in test02"); + } + + private static void test03(short[][] third) { + //The test03 interface is called, and the RC_Array_06_test01 function call is assigned as the return value to + // the parameter third and judged. + third = RC_Array_06_test01(); + if(third.length == 3) + check_count++; + else + System.out.println("ErrorResult in test03"); + } + + private static short[] RC_Array_get01() + { + //Call the 1D array returned by RC_Array_set01 + return RC_Array_set01(); + } + + private static short[][] RC_Array_get02() + { + //Call the 2D array returned by RC_Array_set02 + return RC_Array_set02(); + } + + private static short[][][] RC_Array_get03() + { + //Call the 3D array returned by RC_Array_set03 + return RC_Array_set03(); + } + + private static short[] RC_Array_set01() + { + //return 1D array,Call the constructor of the 1D array parameter of RC_Array_set01, and assign a value to the + // field of the newly created object, and judge the result + short [] value1 = {9,2,8,8}; + RC_Array_06 rctest=new RC_Array_06(value1); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new short[] {1,2,3,4}; + if(rctest.base1.length == 4) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set01"); + return rctest.base1; + } + + private static short[][] RC_Array_set02() + { + //return 2D array,Call the constructor of the 2D array parameter of RC_Array_set02, and assign a + // value to the domain of the newly created object, and judge the result + short[][] value2 = {{1,2,3,4},{1,1},{0}}; + RC_Array_06 rctest=new RC_Array_06(value2); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base2 = new short[][] {{9,2,8,8},{1,1},{0}}; + if(rctest.base2.length == 3) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set02"); + return rctest.base2; + } + + private static short[][][] RC_Array_set03() + { + //return 3D array,Call the constructor of the 3D array parameter of RC_Array_set03, and assign a value to the + // field of the newly created object, and judge the result + short[][][] value3 = {{{1,2,3,4},{1,1},{0}},{{9,2,8,8},{1,1},{0}}}; + RC_Array_06 rctest=new RC_Array_06(value3); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base3 = new short[][][]{{{9,2,8,8},{1,1},{0}},{{1,2,3,4},{1,1},{0}}}; + if(rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set03"); + return rctest.base3; + } + + private static short[][] RC_Array_06_test01() + { + //return 2D array,Call the multi-parameter constructor of RC_Array_06, and assign a value to the newly created + // object field, and judge the result + short [] value1 = {1,2,3,4}; + short[][] value2 = {{1,2,3,4},{1,1},{0}}; + short[][][] value3 = {value2,value2}; + RC_Array_06 rctest=new RC_Array_06(value1,value2,value3); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new short[] {9,2,8,8}; + rctest.base2 = new short[][] {{9,2,8,8},{1,1},{0}}; + rctest.base21 = new short[][] {{6,6,6,5},{1,1},{0}}; + rctest.base3 = new short[][][]{{{9,2,8,8},{1,1},{0}},{{6,6,6,5},{1,1},{0}}}; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_06_test01"); + return rctest.base21; + } + + private static short[] RC_Array_final01() + { + final short[] VALUE1 = {1,2,3,4}; + return VALUE1; + } + private static short[][] RC_Array_final02() + { + final short[][] VALUE2 = {{9,2,8,8},{1,1},{0}}; + return VALUE2; + } + private static short[][][] RC_Array_final03() + { + final short[][][] VALUE3 = {{{6,6,6,5},{1,1},{0}},{{9,2,8,8},{1,1},{0}}}; + return VALUE3; + } + private static short[][] RC_Array_06_test02() + { + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_06() no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + final short[] VALUE1 = RC_Array_final01(); + final short[][] VALUE2 = RC_Array_final02(); + final short[][][] VALUE3 = RC_Array_final03(); + RC_Array_06 rctest=new RC_Array_06(); + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_06_test02"); + rctest.base1 = VALUE1; + rctest.base2 = VALUE2; + rctest.base21 = VALUE2; + rctest.base3 = VALUE3; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_06_test02_2"); + return VALUE2; + } + + private static boolean RC_Array_Exception() + { + //Exception test,exclude NullPointerException,ArrayIndexOutOfBoundsException and so on + int check = 0; + short[] value1 = RC_Array_final01(); + short[][] value2 = RC_Array_final02(); + short[][][] value3 = RC_Array_final03(); + //Is the value as expect after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——1"); + //ArrayIndexOutOfBoundsException + try { + Array.getShort(value1,5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value1[5] = 88; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.setShort(value1,5,(short)12); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getShort(RC_Array_final01(),5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getShort(value2[5],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getShort(value2[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getShort(RC_Array_final02()[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getShort(value3[0][3],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getShort(value3[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getShort(RC_Array_final03()[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + //IllegalArgumentException + try { + Array.getShort(value2,1); + }catch (IllegalArgumentException e){ + check++; + } + try { + Array.getShort(value3,1); + }catch (IllegalArgumentException e){ + check++; + } + //ClassCastException + RC_Array_06 rc1 = new RC_Array_06(); + try{ + Base_006 bs1 = new Base_006(); + rc1 = (RC_Array_06)bs1; + rc1.base1[0] = 8; + }catch (ClassCastException e) + { + if (rc1.base1[0] != 8) + check++; + } + //Whether the judgment value is normal after Exception + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——2"); + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.getShort(value1,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getShort(value2,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getShort(value3,1); + }catch (NullPointerException e){ + check++; + } + //System.out.println(check); + if (check == 18) + return true; + else + return false; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0372-rc-ArrayOptimization-RC_Array_07/RC_Array_07.java b/test/testsuite/ouroboros/rc_test/RC0372-rc-ArrayOptimization-RC_Array_07/RC_Array_07.java new file mode 100755 index 0000000000000000000000000000000000000000..7a58a00eb81ba90ace94007fa8a372285d3a98b9 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0372-rc-ArrayOptimization-RC_Array_07/RC_Array_07.java @@ -0,0 +1,432 @@ +/* + *- @TestCaseID:maple/runtime/rc/optimization/RC_Array_07.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Scenario testing for RC optimization: testing various scenes of 1D, 2D, 3D long array objects,including: + * 1.Parameter modification / parameter has not been modified + * 2.final、static + * 3.As a constructor fun + * 4.Function call + * 5.Object Passing + * 6.return constant; variable; function call + * 7.Inherited as a parent class; child class inherits the parent class; interface call; + * 8.Exception + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Array_07.java + *- @ExecuteClass: RC_Array_07 + *- @ExecuteArgs: + *- @Remark: + */ +import java.lang.reflect.Array; +import java.util.Arrays; + +class Base_007{ + //Parent interface + volatile long[] base1; + long[][] base2; + long[][] base21; + long[][][] base3; +} + +public class RC_Array_07 extends Base_007{ + static int check_count = 0; + static long[] arr1 = {1,2,3,4}; + static long[][] arr2 = {{1,2,3,4},{5,6},{7,8}}; + static long[][] arr21 = {{4,5,6,7},{8,9},{10,11}}; + static long[][][] arr3 = {arr2,arr21}; + + private RC_Array_07(){ + base1 = new long[]{1,2,3,4}; + base2 = new long[][]{{1,2,3,4},{5,6},{7,8}}; + base21 = new long[][]{{4,5,6,7},{8,9},{10,11}}; + base3 = new long[][][]{{{1,2,3,4},{5,6},{7,8}},{{4,5,6,7},{8,9},{10,11}}}; + } + + private RC_Array_07(long[] longar){ + base1 = longar; + } + + private RC_Array_07(long[][] longarr){ + base2 = longarr; + } + + private RC_Array_07(long[][][] longarrr){ + base3 = longarrr; + } + + private RC_Array_07(long[] longar, long[][] longarr, long[][][] longarrr){ + base1 = longar; + base2 = longarr; + base3 = longarrr; + } + + public static void main(String[] args) { + final long[] TEST1 = {1,2,3,4}; + final long[][] TEST2 = {TEST1,{5,6},{7,8}}; + final long[][] TEST21 = {{4,5,6,7},{8,9},{10,11}}; + final long[][][] TEST3 = {TEST2,TEST21}; + + //Initialization check + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult long step1"); + + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + test01(4,TEST1,TEST2,TEST3); + test01(4,arr1,arr2,arr3); + + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step2"); + + //test02 interface call, call function change to modify the parameter value and judge + test02(4,TEST1,TEST2,TEST3); + test02(4,arr1,arr2,arr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step3"); + + //The test03 interface call, call the RC_Array_07_test01 function return value to the parameter third and judged. + //RC_Array_07_test01,return 2D array,Call the multi-parameter constructor of RC_Array_01, and assign a value to + //the newly created object field, and judge the result + test03(TEST2); + test03(arr2); + if(TEST2.length == 3 && arr2.length == 3) + check_count++; + else + System.out.println("ErrorResult in step4"); + + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_07() no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + //Test points: inheritance, constructor, return function call, constant, variable, do not receive return value + RC_Array_07_test02(); + + //Get an array object by returning a function call + long[] getarr1 = RC_Array_get01(); + long[][] getarr2 = RC_Array_get02(); + long[][][] getarr3 = RC_Array_get03(); + if(getarr1.length == 4 && getarr2.length == 3 && getarr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step5"); + + //Exception testing + boolean ret = RC_Array_Exception(); + if (ret == true) + check_count++; + else + System.out.println("RC_Array_Exception ErrorResult"); + + //Result judgment + //System.out.println(check_count); + if(check_count == 24) + System.out.println("ExpectResult"); + + } + + private static void test01(int first, long[] second, long[][] third, long[][][] four) { + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + long [] xyz = {8,8,1,0}; + long[][] xyz2 = {{1,2,3,4},{1,1},{0}}; + long[][][] xyz3 = {xyz2,xyz2}; + if(second.length == 4 && third.length == 3 && four.length == 2 + && xyz.length == 4 && xyz2.length == 3 && xyz3.length == 2) + check_count++; + else + System.out.println("ErrorResult in test01"); + } + + private static Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + + private static void test02(int first, long[] second, long[][] third, long[][][] four) { + //test02 interface call, call function change to modify the parameter value and judge + long [] xyz = {8,8,1,0}; + long[][] xyz2 = {{1,2,3,4},{1,1},{0}}; + long[][][] xyz3 = {xyz2,xyz2}; + second = (long[]) change(second,xyz); + third = (long[][])change(third,xyz2); + four = (long[][][]) change(four,xyz3); + if(second.length == 4 && third.length == 3 && four.length == 2) + check_count++; + else + System.out.println("ErrorResult in test02"); + } + + private static void test03(long[][] third) { + //The test03 interface is called, and the RC_Array_07_test01 function call is assigned as the return value to + // the parameter third and judged. + third = RC_Array_07_test01(); + if(third.length == 3) + check_count++; + else + System.out.println("ErrorResult in test03"); + } + + private static long[] RC_Array_get01() + { + //Call the 1D array returned by RC_Array_set01 + return RC_Array_set01(); + } + + private static long[][] RC_Array_get02() + { + //Call the 2D array returned by RC_Array_set02 + return RC_Array_set02(); + } + + private static long[][][] RC_Array_get03() + { + //Call the 3D array returned by RC_Array_set03 + return RC_Array_set03(); + } + + private static long[] RC_Array_set01() + { + //return 1D array,Call the constructor of the 1D array parameter of RC_Array_set01, and assign a value to the + // field of the newly created object, and judge the result + long [] value1 = {9,2,8,8}; + RC_Array_07 rctest=new RC_Array_07(value1); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new long[] {1,2,3,4}; + if(rctest.base1.length == 4) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set01"); + return rctest.base1; + } + + private static long[][] RC_Array_set02() + { + //return 2D array,Call the constructor of the 2D array parameter of RC_Array_set02, and assign a + // value to the domain of the newly created object, and judge the result + long[][] value2 = {{1,2,3,4},{1,1},{0}}; + RC_Array_07 rctest=new RC_Array_07(value2); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base2 = new long[][] {{9,2,8,8},{1,1},{0}}; + if(rctest.base2.length == 3) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set02"); + return rctest.base2; + } + + private static long[][][] RC_Array_set03() + { + //return 3D array,Call the constructor of the 3D array parameter of RC_Array_set03, and assign a value to the + // field of the newly created object, and judge the result + long[][][] value3 = {{{1,2,3,4},{1,1},{0}},{{9,2,8,8},{1,1},{0}}}; + RC_Array_07 rctest=new RC_Array_07(value3); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base3 = new long[][][]{{{9,2,8,8},{1,1},{0}},{{1,2,3,4},{1,1},{0}}}; + if(rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set03"); + return rctest.base3; + } + + private static long[][] RC_Array_07_test01() + { + //return 2D array,Call the multi-parameter constructor of RC_Array_07, and assign a value to the newly created + // object field, and judge the result + long [] value1 = {1,2,3,4}; + long[][] value2 = {{1,2,3,4},{1,1},{0}}; + long[][][] value3 = {value2,value2}; + RC_Array_07 rctest=new RC_Array_07(value1,value2,value3); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new long[] {9,2,8,8}; + rctest.base2 = new long[][] {{9,2,8,8},{1,1},{0}}; + rctest.base21 = new long[][] {{6,6,6,5},{1,1},{0}}; + rctest.base3 = new long[][][]{{{9,2,8,8},{1,1},{0}},{{6,6,6,5},{1,1},{0}}}; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_07_test01"); + return rctest.base21; + } + + private static long[] RC_Array_final01() + { + final long[] VALUE1 = {1,2,3,4}; + return VALUE1; + } + private static long[][] RC_Array_final02() + { + final long[][] VALUE2 = {{9,2,8,8},{1,1},{0}}; + return VALUE2; + } + private static long[][][] RC_Array_final03() + { + final long[][][] VALUE3 = {{{6,6,6,5},{1,1},{0}},{{9,2,8,8},{1,1},{0}}}; + return VALUE3; + } + private static long[][] RC_Array_07_test02() + { + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_07() no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + final long[] VALUE1 = RC_Array_final01(); + final long[][] VALUE2 = RC_Array_final02(); + final long[][][] VALUE3 = RC_Array_final03(); + RC_Array_07 rctest=new RC_Array_07(); + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_07_test02"); + rctest.base1 = VALUE1; + rctest.base2 = VALUE2; + rctest.base21 = VALUE2; + rctest.base3 = VALUE3; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_07_test02_2"); + return VALUE2; + } + + private static boolean RC_Array_Exception() + { + //Exception test,exclude NullPointerException,ArrayIndexOutOfBoundsException and so on + int check = 0; + long[] value1 = RC_Array_final01(); + long[][] value2 = RC_Array_final02(); + long[][][] value3 = RC_Array_final03(); + + //Is the value as expect after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——1"); + + //ArrayIndexOutOfBoundsException + try { + Array.getLong(value1,5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value1[5] = 92; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.setLong(value1,5,(long)12); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getLong(RC_Array_final01(),5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getLong(value2[5],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getLong(value2[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getLong(RC_Array_final02()[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getLong(value3[0][3],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getLong(value3[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getLong(RC_Array_final03()[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + //IllegalArgumentException + try { + Array.getLong(value2,1); + }catch (IllegalArgumentException e){ + check++; + } + try { + Array.getLong(value3,1); + }catch (IllegalArgumentException e){ + check++; + } + //ClassCastException + RC_Array_07 rc1 = new RC_Array_07(); + try{ + Base_007 bs1 = new Base_007(); + rc1 = (RC_Array_07)bs1; + rc1.base1[0] = 8; + }catch (ClassCastException e) + { + if (rc1.base1[0] != 8) + check++; + } + //Whether the judgment value is normal after Exception + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——2"); + + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.getLong(value1,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getLong(value2,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getLong(value3,1); + }catch (NullPointerException e){ + check++; + } + //System.out.println(check); + if (check == 18) + return true; + else + return false; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0373-rc-ArrayOptimization-RC_Array_08/RC_Array_08.java b/test/testsuite/ouroboros/rc_test/RC0373-rc-ArrayOptimization-RC_Array_08/RC_Array_08.java new file mode 100755 index 0000000000000000000000000000000000000000..3d47c72ff43810ae5c6af05f81e22ed18d53830d --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0373-rc-ArrayOptimization-RC_Array_08/RC_Array_08.java @@ -0,0 +1,432 @@ +/* + *- @TestCaseID:maple/runtime/rc/optimization/RC_Array_08.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Scenario testing for RC optimization: testing various scenes of 1D, 2D, 3D float array objects,including: + * 1.Parameter modification / parameter has not been modified + * 2.final、static + * 3.As a constructor fun + * 4.Function call + * 5.Object Passing + * 6.return constant; variable; function call + * 7.Inherited as a parent class; child class inherits the parent class; interface call; + * 8.Exception + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Array_08.java + *- @ExecuteClass: RC_Array_08 + *- @ExecuteArgs: + *- @Remark: + */ +import java.lang.reflect.Array; +import java.util.Arrays; + +class Base_008{ + //Parent interface + volatile float[] base1; + float[][] base2; + float[][] base21; + float[][][] base3; +} + +public class RC_Array_08 extends Base_008{ + static int check_count = 0; + static float[] arr1 = {1.1f,2.2f,3.3f,4.4f}; + static float[][] arr2 = {{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f,8.8f}}; + static float[][] arr21 = {{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f,11.10f}}; + static float[][][] arr3 = {arr2,arr21}; + + private RC_Array_08(){ + base1 = new float[]{1.1f,2.2f,3.3f,4.4f}; + base2 = new float[][]{{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f,8.8f}}; + base21 = new float[][]{{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f,11.10f}}; + base3 = new float[][][]{{{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f,8.8f}},{{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f,11.10f}}}; + } + + private RC_Array_08(float[] floatar){ + base1 = floatar; + } + + private RC_Array_08(float[][] floatarr){ + base2 = floatarr; + } + + private RC_Array_08(float[][][] floatarrr){ + base3 = floatarrr; + } + + private RC_Array_08(float[] floatar, float[][] floatarr, float[][][] floatarrr){ + base1 = floatar; + base2 = floatarr; + base3 = floatarrr; + } + + public static void main(String[] args) { + final float[] TEST1 = {1.1f,2.2f,3.3f,4.4f}; + final float[][] TEST2 = {TEST1,{5.5f,6.6f},{7.7f,8.8f}}; + final float[][] TEST21 = {{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f,11.10f}}; + final float[][][] TEST3 = {TEST2,TEST21}; + + //Initialization check + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult float step1"); + + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + test01(4,TEST1,TEST2,TEST3); + test01(4,arr1,arr2,arr3); + + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step2"); + + //test02 interface call, call function change to modify the parameter value and judge + test02(4,TEST1,TEST2,TEST3); + test02(4,arr1,arr2,arr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step3"); + + //The test03 interface call, call the RC_Array_08_test01 function return value to the parameter third and judged. + //RC_Array_08_test01,return 2D array,Call the multi-parameter constructor of RC_Array_01, and assign a value to + //the newly created object field, and judge the result + test03(TEST2); + test03(arr2); + if(TEST2.length == 3 && arr2.length == 3) + check_count++; + else + System.out.println("ErrorResult in step4"); + + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_08() no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + //Test points: inheritance, constructor, return function call, constant, variable, do not receive return value + RC_Array_08_test02(); + + //Get an array object by returning a function call + float[] getarr1 = RC_Array_get01(); + float[][] getarr2 = RC_Array_get02(); + float[][][] getarr3 = RC_Array_get03(); + if(getarr1.length == 4 && getarr2.length == 3 && getarr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step5"); + + //Exception testing + boolean ret = RC_Array_Exception(); + if (ret == true) + check_count++; + else + System.out.println("RC_Array_Exception ErrorResult"); + + //Result judgment + //System.out.println(check_count); + if(check_count == 24) + System.out.println("ExpectResult"); + + } + + private static void test01(int first, float[] second, float[][] third, float[][][] four) { + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + float [] xyz = {8.5f,8.3f,1.2f,0.5f}; + float[][] xyz2 = {{1.1f,2.2f,3.3f,4.4f},{1.3f,1.1f},{0.5f}}; + float[][][] xyz3 = {xyz2,xyz2}; + if(second.length == 4 && third.length == 3 && four.length == 2 + && xyz.length == 4 && xyz2.length == 3 && xyz3.length == 2) + check_count++; + else + System.out.println("ErrorResult in test01"); + } + + private static Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + + private static void test02(int first, float[] second, float[][] third, float[][][] four) { + //test02 interface call, call function change to modify the parameter value and judge + float [] xyz = {8.5f,8.3f,1.2f,0.5f}; + float[][] xyz2 = {{1.1f,2.2f,3.3f,4.4f},{1.3f,1.1f},{0.5f}}; + float[][][] xyz3 = {xyz2,xyz2}; + second = (float[]) change(second,xyz); + third = (float[][])change(third,xyz2); + four = (float[][][]) change(four,xyz3); + if(second.length == 4 && third.length == 3 && four.length == 2) + check_count++; + else + System.out.println("ErrorResult in test02"); + } + + private static void test03(float[][] third) { + //The test03 interface is called, and the RC_Array_08_test01 function call is assigned as the return value to + // the parameter third and judged. + third = RC_Array_08_test01(); + if(third.length == 3) + check_count++; + else + System.out.println("ErrorResult in test03"); + } + + private static float[] RC_Array_get01() + { + //Call the 1D array returned by RC_Array_set01 + return RC_Array_set01(); + } + + private static float[][] RC_Array_get02() + { + //Call the 2D array returned by RC_Array_set02 + return RC_Array_set02(); + } + + private static float[][][] RC_Array_get03() + { + //Call the 3D array returned by RC_Array_set03 + return RC_Array_set03(); + } + + private static float[] RC_Array_set01() + { + //return 1D array,Call the constructor of the 1D array parameter of RC_Array_set01, and assign a value to the + // field of the newly created object, and judge the result + float [] value1 = {9.2f,2.2f,8.8f,8.8f}; + RC_Array_08 rctest=new RC_Array_08(value1); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new float[] {1.1f,2.2f,3.3f,4.4f}; + if(rctest.base1.length == 4) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set01"); + return rctest.base1; + } + + private static float[][] RC_Array_set02() + { + //return 2D array,Call the constructor of the 2D array parameter of RC_Array_set02, and assign a + // value to the domain of the newly created object, and judge the result + float[][] value2 = {{1.1f,2.2f,3.3f,4.4f},{1.3f,1.1f},{0.5f}}; + RC_Array_08 rctest=new RC_Array_08(value2); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base2 = new float[][] {{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}}; + if(rctest.base2.length == 3) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set02"); + return rctest.base2; + } + + private static float[][][] RC_Array_set03() + { + //return 3D array,Call the constructor of the 3D array parameter of RC_Array_set03, and assign a value to the + // field of the newly created object, and judge the result + float[][][] value3 = {{{1.1f,2.2f,3.3f,4.4f},{1.3f,1.1f},{0.5f}},{{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}}}; + RC_Array_08 rctest=new RC_Array_08(value3); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base3 = new float[][][]{{{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}},{{1.1f,2.2f,3.3f,4.4f},{1.3f,1.1f},{0.5f}}}; + if(rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set03"); + return rctest.base3; + } + + private static float[][] RC_Array_08_test01() + { + //return 2D array,Call the multi-parameter constructor of RC_Array_08, and assign a value to the newly created + // object field, and judge the result + float [] value1 = {1.1f,2.2f,3.3f,4.4f}; + float[][] value2 = {{1.1f,2.2f,3.3f,4.4f},{1.3f,1.1f},{0.5f}}; + float[][][] value3 = {value2,value2}; + RC_Array_08 rctest=new RC_Array_08(value1,value2,value3); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new float[] {9.2f,2.2f,8.8f,8.8f}; + rctest.base2 = new float[][] {{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}}; + rctest.base21 = new float[][] {{6,6,6,5},{1.3f,1.1f},{0.5f}}; + rctest.base3 = new float[][][]{{{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}},{{6,6,6,5},{1.3f,1.1f},{0.5f}}}; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_08_test01"); + return rctest.base21; + } + + private static float[] RC_Array_final01() + { + final float[] VALUE1 = {1.1f,2.2f,3.3f,4.4f}; + return VALUE1; + } + private static float[][] RC_Array_final02() + { + final float[][] VALUE2 = {{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}}; + return VALUE2; + } + private static float[][][] RC_Array_final03() + { + final float[][][] VALUE3 = {{{6.4f,6.1f,6.3f,5.5f},{1.3f,1.1f},{0.5f}},{{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}}}; + return VALUE3; + } + private static float[][] RC_Array_08_test02() + { + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_08() no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + final float[] VALUE1 = RC_Array_final01(); + final float[][] VALUE2 = RC_Array_final02(); + final float[][][] VALUE3 = RC_Array_final03(); + RC_Array_08 rctest=new RC_Array_08(); + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_08_test02"); + rctest.base1 = VALUE1; + rctest.base2 = VALUE2; + rctest.base21 = VALUE2; + rctest.base3 = VALUE3; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_08_test02_2"); + return VALUE2; + } + + private static boolean RC_Array_Exception() + { + //Exception test,exclude NullPointerException,ArrayIndexOutOfBoundsException and so on + int check = 0; + float[] value1 = RC_Array_final01(); + float[][] value2 = RC_Array_final02(); + float[][][] value3 = RC_Array_final03(); + + //Is the value as expect after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——1"); + + //ArrayIndexOutOfBoundsException + try { + Array.getFloat(value1,5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value1[5] = 88.10f; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.setFloat(value1,5,12.5f); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getFloat(RC_Array_final01(),5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getFloat(value2[5],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getFloat(value2[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getFloat(RC_Array_final02()[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getFloat(value3[0][3],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getFloat(value3[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getFloat(RC_Array_final03()[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + //IllegalArgumentException + try { + Array.getFloat(value2,1); + }catch (IllegalArgumentException e){ + check++; + } + try { + Array.getFloat(value3,1); + }catch (IllegalArgumentException e){ + check++; + } + //ClassCastException + RC_Array_08 rc1 = new RC_Array_08(); + try{ + Base_008 bs1 = new Base_008(); + rc1 = (RC_Array_08)bs1; + rc1.base1[0] = 8.9f; + }catch (ClassCastException e) + { + if (rc1.base1[0] != 8.9f) + check++; + } + //Whether the judgment value is normal after Exception + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——2"); + + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.getFloat(value1,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getFloat(value2,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getFloat(value3,1); + }catch (NullPointerException e){ + check++; + } + //System.out.println(check); + if (check == 18) + return true; + else + return false; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0374-rc-ArrayOptimization-RC_Array_09/RC_Array_09.java b/test/testsuite/ouroboros/rc_test/RC0374-rc-ArrayOptimization-RC_Array_09/RC_Array_09.java new file mode 100755 index 0000000000000000000000000000000000000000..0c41465ffa748d0784ce242ebca7264d914ea6ee --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0374-rc-ArrayOptimization-RC_Array_09/RC_Array_09.java @@ -0,0 +1,418 @@ +/* + *- @TestCaseID:maple/runtime/rc/optimization/RC_Array_09.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Scenario testing for RC optimization: testing various scenes of 1D, 2D, 3D double array objects,including: + * 1.Parameter modification / parameter has not been modified + * 2.final、static + * 3.As a constructor fun + * 4.Function call + * 5.Object Passing + * 6.return constant; variable; function call + * 7.Inherited as a parent class; child class inherits the parent class; interface call; + * 8.Exception + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Array_09.java + *- @ExecuteClass: RC_Array_09 + *- @ExecuteArgs: + *- @Remark: + */ +import java.lang.reflect.Array; +import java.util.Arrays; + +class Base_009{ + //Parent interface + volatile double[] base1; + double[][] base2; + double[][] base21; + double[][][] base3; +} + +public class RC_Array_09 extends Base_009{ + static int check_count = 0; + static double[] arr1 = {1.1f,2.2f,3.3f,4.4f}; + static double[][] arr2 = {{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f,8.8f}}; + static double[][] arr21 = {{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f,11.10f}}; + static double[][][] arr3 = {arr2,arr21}; + + private RC_Array_09(){ + base1 = new double[]{1.1f,2.2f,3.3f,4.4f}; + base2 = new double[][]{{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f,8.8f}}; + base21 = new double[][]{{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f,11.10f}}; + base3 = new double[][][]{{{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f,8.8f}},{{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f,11.10f}}}; + } + + private RC_Array_09(double[] doublear){ + base1 = doublear; + } + + private RC_Array_09(double[][] doublearr){ + base2 = doublearr; + } + + private RC_Array_09(double[][][] doublearrr){ + base3 = doublearrr; + } + + private RC_Array_09(double[] doublear, double[][] doublearr, double[][][] doublearrr){ + base1 = doublear; + base2 = doublearr; + base3 = doublearrr; + } + + public static void main(String[] args) { + final double[] TEST1 = {1.1f,2.2f,3.3f,4.4f}; + final double[][] TEST2 = {{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f,8.8f}}; + final double[][] TEST21 = {{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f,11.10f}}; + final double[][][] TEST3 = {TEST2,TEST21}; + + //Initialization check + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult double step1"); + + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + test01(4,TEST1,TEST2,TEST3); + test01(4,arr1,arr2,arr3); + + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step2"); + + //test02 interface call, call function change to modify the parameter value and judge + test02(4,TEST1,TEST2,TEST3); + test02(4,arr1,arr2,arr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step3"); + + //The test03 interface call, call the RC_Array_09_test01 function return value to the parameter third and judged. + //RC_Array_09_test01,return 2D array,Call the multi-parameter constructor of RC_Array_01, and assign a value to + //the newly created object field, and judge the result + test03(TEST2); + test03(arr2); + if(TEST2.length == 3 && arr2.length == 3) + check_count++; + else + System.out.println("ErrorResult in step4"); + + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_09() no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + //Test points: inheritance, constructor, return function call, constant, variable, do not receive return value + RC_Array_09_test02(); + + //Get an array object by returning a function call + double[] getarr1 = RC_Array_get01(); + double[][] getarr2 = RC_Array_get02(); + double[][][] getarr3 = RC_Array_get03(); + if(getarr1.length == 4 && getarr2.length == 3 && getarr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step5"); + + //Exception testing + boolean ret = RC_Array_Exception(); + if (ret == true) + check_count++; + else + System.out.println("RC_Array_Exception ErrorResult"); + + //Result judgment + //System.out.println(check_count); + if(check_count == 24) + System.out.println("ExpectResult"); + + } + + private static void test01(int first, double[] second, double[][] third, double[][][] four) { + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + double [] xyz = {8.5f,8.3f,1.2f,0.5f}; + double[][] xyz2 = {{1.1f,2.2f,3.3f,4.4f},{1.3f,1.1f},{0.5f}}; + double[][][] xyz3 = {xyz2,xyz2}; + if(second.length == 4 && third.length == 3 && four.length == 2 + && xyz.length == 4 && xyz2.length == 3 && xyz3.length == 2) + check_count++; + else + System.out.println("ErrorResult in test01"); + } + + private static Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + + private static void test02(int first, double[] second, double[][] third, double[][][] four) { + //test02 interface call, call function change to modify the parameter value and judge + double [] xyz = {8.5f,8.3f,1.2f,0.5f}; + double[][] xyz2 = {{1.1f,2.2f,3.3f,4.4f},{1.3f,1.1f},{0.5f}}; + double[][][] xyz3 = {xyz2,xyz2}; + second = (double[]) change(second,xyz); + third = (double[][])change(third,xyz2); + four = (double[][][]) change(four,xyz3); + if(second.length == 4 && third.length == 3 && four.length == 2) + check_count++; + else + System.out.println("ErrorResult in test02"); + } + + private static void test03(double[][] third) { + //The test03 interface is called, and the RC_Array_09_test01 function call is assigned as the return value to + // the parameter third and judged. + third = RC_Array_09_test01(); + if(third.length == 3) + check_count++; + else + System.out.println("ErrorResult in test03"); + } + + private static double[] RC_Array_get01() + { + //Call the 1D array returned by RC_Array_set01 + return RC_Array_set01(); + } + + private static double[][] RC_Array_get02() + { + //Call the 2D array returned by RC_Array_set02 + return RC_Array_set02(); + } + + private static double[][][] RC_Array_get03() + { + //Call the 3D array returned by RC_Array_set03 + return RC_Array_set03(); + } + + private static double[] RC_Array_set01() + { + //return 1D array,Call the constructor of the 1D array parameter of RC_Array_set01, and assign a value to the + // field of the newly created object, and judge the result + double [] value1 = {9.2f,2.2f,8.8f,8.8f}; + RC_Array_09 rctest=new RC_Array_09(value1); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new double[] {1.1f,2.2f,3.3f,4.4f}; + if(rctest.base1.length == 4) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set01"); + return rctest.base1; + } + + private static double[][] RC_Array_set02() + { + //return 2D array,Call the constructor of the 2D array parameter of RC_Array_set02, and assign a + // value to the domain of the newly created object, and judge the result + double[][] value2 = {{1.1f,2.2f,3.3f,4.4f},{1.3f,1.1f},{0.5f}}; + RC_Array_09 rctest=new RC_Array_09(value2); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base2 = new double[][] {{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}}; + if(rctest.base2.length == 3) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set02"); + return rctest.base2; + } + + private static double[][][] RC_Array_set03() + { + //return 3D array,Call the constructor of the 3D array parameter of RC_Array_set03, and assign a value to the + // field of the newly created object, and judge the result + double[][][] value3 = {{{1.1f,2.2f,3.3f,4.4f},{1.3f,1.1f},{0.5f}},{{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}}}; + RC_Array_09 rctest=new RC_Array_09(value3); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base3 = new double[][][]{{{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}},{{1.1f,2.2f,3.3f,4.4f},{1.3f,1.1f},{0.5f}}}; + if(rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set03"); + return rctest.base3; + } + + private static double[][] RC_Array_09_test01() + { + //return 2D array,Call the multi-parameter constructor of RC_Array_09, and assign a value to the newly created + // object field, and judge the result + double [] value1 = {1.1f,2.2f,3.3f,4.4f}; + double[][] value2 = {{1.1f,2.2f,3.3f,4.4f},{1.3f,1.1f},{0.5f}}; + double[][][] value3 = {value2,value2}; + RC_Array_09 rctest=new RC_Array_09(value1,value2,value3); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new double[] {9.2f,2.2f,8.8f,8.8f}; + rctest.base2 = new double[][] {{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}}; + rctest.base21 = new double[][] {{6,6,6,5},{1.3f,1.1f},{0.5f}}; + rctest.base3 = new double[][][]{{{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}},{{6,6,6,5},{1.3f,1.1f},{0.5f}}}; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_09_test01"); + return rctest.base21; + } + + private static double[] RC_Array_final01() + { + final double[] VALUE1 = {1.1f,2.2f,3.3f,4.4f}; + return VALUE1; + } + private static double[][] RC_Array_final02() + { + final double[][] VALUE2 = {{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}}; + return VALUE2; + } + private static double[][][] RC_Array_final03() + { + final double[][][] VALUE3 = {{{6.4f,6.1f,6.3f,5.5f},{1.3f,1.1f},{0.5f}},{{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}}}; + return VALUE3; + } + private static double[][] RC_Array_09_test02() + { + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_09() no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + final double[] VALUE1 = RC_Array_final01(); + final double[][] VALUE2 = RC_Array_final02(); + final double[][][] VALUE3 = RC_Array_final03(); + RC_Array_09 rctest=new RC_Array_09(); + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_09_test02"); + rctest.base1 = VALUE1; + rctest.base2 = VALUE2; + rctest.base21 = VALUE2; + rctest.base3 = VALUE3; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_09_test02_2"); + return VALUE2; + } + + private static boolean RC_Array_Exception() + { + //Exception test,exclude NullPointerException,ArrayIndexOutOfBoundsException and so on + int check = 0; + double[] value1 = RC_Array_final01(); + double[][] value2 = RC_Array_final02(); + double[][][] value3 = RC_Array_final03(); + + //Is the value as expect after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——1"); + + //ArrayIndexOutOfBoundsException + try { + Array.getDouble(value1,5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value1[5] = 10.16f; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.setDouble(value1,5,12.5f); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getDouble(value2[5],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getDouble(value2[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getDouble(value3[0][3],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getDouble(value3[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + //IllegalArgumentException + try { + Array.getDouble(value2,1); + }catch (IllegalArgumentException e){ + check++; + } + try { + Array.getDouble(value3,1); + }catch (IllegalArgumentException e){ + check++; + } + //ClassCastException + RC_Array_09 rc1 = new RC_Array_09(); + try{ + Base_009 bs1 = new Base_009(); + rc1 = (RC_Array_09)bs1; + rc1.base1[0] = 8.9f; + }catch (ClassCastException e) + { + if (rc1.base1[0] != 8.9f) + check++; + } + //Whether the judgment value is normal after Exception + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——2"); + + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.getDouble(value1,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getDouble(value2,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getDouble(value3,1); + }catch (NullPointerException e){ + check++; + } + + //System.out.println(check); + if (check == 15) + return true; + else + return false; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0375-rc-ArrayOptimization-RC_Array_10/RC_Array_10.java b/test/testsuite/ouroboros/rc_test/RC0375-rc-ArrayOptimization-RC_Array_10/RC_Array_10.java new file mode 100755 index 0000000000000000000000000000000000000000..8c9f68af3b318e914a38b599f871469f5b551a23 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0375-rc-ArrayOptimization-RC_Array_10/RC_Array_10.java @@ -0,0 +1,405 @@ +/* + *- @TestCaseID:maple/runtime/rc/optimization/RC_Array_10.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Scenario test for RC optimization: test array copy object various scenarios, including: + * 1.One, two, three-dimensional array type cyclic assignment + * 2.One, two, three-dimensional array type System.arraycopy () assignment + * 3.One, two, three-dimensional array type Arrays.copyOf() assignment + * 4.One, two, three-dimensional array type Arrays.copyOfRange() assignment + * 5.One, two, three-dimensional array type clone() assignment + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Array_10.java + *- @ExecuteClass: RC_Array_10 + *- @ExecuteArgs: + *- @Remark: + */ +import java.util.Arrays; + +public class RC_Array_10 { + static int check_count = 0; + //Nine definitions:int、string、char、boolean、byte、short、long、float、double + static int[] intr1 = {10,20,30,40}; + static int[][] intr2 = {{10,20,30,40},{40,50},{60}}; + static int[][] intr21 = {{40,50,60,30},{70,80},{90}}; + static int[][][] intr3 = {{{10,20,30,40},{40,50},{60}},{{40,50,60,30},{70,80},{90}}}; + static String[] strr1 = {"hello","test","for","array"}; + static String[][] strr2 = {{"hello","test","for","array"},{"2018","11"},{"26"}}; + static String[][] strr21 = {{"huawei","test","for","array"},{"2018","11"},{"26"}}; + static String[][][] strr3 = {{{"hello","test","for","array"},{"2018","11"},{"26"}},{{"huawei","test","for","array"},{"2018","11"},{"26"}}}; + static char[] charr1 = {'a','b','c','d'}; + static char[][] charr2 = {{'a','b','c','d'},{'e','f'},{'g'}}; + static char[][] charr21 = {{'h','i','j','k'},{'l','m'},{'n'}}; + static char[][][] charr3 = {{{'a','b','c','d'},{'e','f'},{'g'}},{{'h','i','j','k'},{'l','m'},{'n'}}}; + static boolean[] boolr1 = {true,false,false,true}; + static boolean[][] boolr2 = {{true,false,false,true},{false,false},{true}}; + static boolean[][] boolr21 = {{false,true,false,true},{true,false},{false}}; + static boolean[][][] boolr3 = {{{true,false,false,true},{false,false},{true}},{{false,true,false,true},{true,false},{false}}}; + static byte[] byter1 = {1,2,3,4}; + static byte[][] byter2 = {{1,2,3,4},{5,6},{7}}; + static byte[][] byter21 = {{4,5,6,7},{8,9},{10}}; + static byte[][][] byter3 = {{{1,2,3,4},{5,6},{7}},{{4,5,6,7},{8,9},{10}}}; + static short[] shortr1 = {1,2,3,4}; + static short[][] shortr2 = {{1,2,3,4},{5,6},{7}}; + static short[][] shortr21 = {{4,5,6,7},{8,9},{10}}; + static short[][][] shortr3 = {{{1,2,3,4},{5,6},{7}},{{4,5,6,7},{8,9},{10}}}; + static long[] longr1 = {1,2,3,4}; + static long[][] longr2 = {{1,2,3,4},{5,6},{7}}; + static long[][] longr21 = {{4,5,6,7},{8,9},{10}}; + static long[][][] longr3 = {{{1,2,3,4},{5,6},{7}},{{4,5,6,7},{8,9},{10}}}; + static float[] floatr1 = {1.1f,2.2f,3.3f,4.4f}; + static float[][] floatr2 = {{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f}}; + static float[][] floatr21 = {{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f}}; + static float[][][] floatr3 = {{{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f}},{{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f}}}; + static double[] doubler1 = {1.1f,2.2f,3.3f,4.4f}; + static double[][] doubler2 = {{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f}}; + static double[][] doubler21 = {{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f}}; + static double[][][] doubler3 = {{{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f}},{{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f}}}; + + public static void main(String [] args) { + //Initialization check + check("initialization"); + + //Copy scene1:One, two, three-dimensional array type cyclic assignment + test01(); + check("test01"); + + //Copy scene2:One, two, three-dimensional array type System.arraycopy () assignment + test02(); + check("test02"); + + //Copy scene3:One, two, three-dimensional array type Arrays.copyOf() assignment + test03(); + check("test03"); + + //Copy scene4:One, two, three-dimensional array type Arrays.copyOfRange() assignment + test04(); + check("test04"); + + //Copy scene5:One, two, three-dimensional array type clone() assignment + test05(); + check("test05"); + + //Result judgment + //System.out.println(check_count); + if(check_count == 11) + System.out.println("ExpectResult"); + } + + private static void check(String test_method) + { + /*Public function: Check if the length of the assignment source array is as expected to determine whether the resource is recycled*/ + if(intr1.length == 4 && intr2.length == 3 && intr21.length == 3 && intr3.length == 2 + && strr1.length == 4 && strr2.length == 3 && strr21.length == 3 && strr3.length == 2 + && charr1.length == 4 && charr2.length == 3 && charr21.length == 3 && charr3.length == 2 + && boolr1.length == 4 && boolr2.length == 3 && boolr21.length == 3 && boolr3.length == 2 + && byter1.length == 4 && byter2.length == 3 && byter21.length == 3 && byter3.length == 2 + && shortr1.length == 4 && shortr2.length == 3 && shortr21.length == 3 && shortr3.length == 2 + && longr1.length == 4 && longr2.length == 3 && longr21.length == 3 && longr3.length == 2 + && floatr1.length == 4 && floatr2.length == 3 && floatr21.length == 3 && floatr3.length == 2 + && doubler1.length == 4 && doubler2.length == 3 && doubler21.length == 3 && doubler3.length == 2) + check_count++; + else + System.out.println("ErrorResult in check: " + test_method); + } + + private static void test01() { + /*test01:One, two, three-dimensional array type cyclic assignment*/ + int [] tmp_int1 = new int[4]; + int [][] tmp_int2 = new int [3][4]; + int [][][] tmp_int3 = new int [2][3][4]; + String [] tmp_String1 = new String[4]; + String [][] tmp_String2 = new String [3][4]; + String [][][] tmp_String3 = new String [2][3][4]; + char [] tmp_char1 = new char[4]; + char [][] tmp_char2 = new char [3][4]; + char [][][] tmp_char3 = new char [2][3][4]; + boolean [] tmp_boolean1 = new boolean[4]; + boolean [][] tmp_boolean2 = new boolean [3][4]; + boolean [][][] tmp_boolean3 = new boolean [2][3][4]; + byte [] tmp_byte1 = new byte[4]; + byte [][] tmp_byte2 = new byte [3][4]; + byte [][][] tmp_byte3 = new byte [2][3][4]; + short [] tmp_short1 = new short[4]; + short [][] tmp_short2 = new short [3][4]; + short [][][] tmp_short3 = new short [2][3][4]; + long [] tmp_long1 = new long[4]; + long [][] tmp_long2 = new long [3][4]; + long [][][] tmp_long3 = new long [2][3][4]; + float [] tmp_float1 = new float[4]; + float [][] tmp_float2 = new float [3][4]; + float [][][] tmp_float3 = new float [2][3][4]; + double [] tmp_double1 = new double[4]; + double [][] tmp_double2 = new double [3][4]; + double [][][] tmp_double3 = new double [2][3][4]; + //1D array + for (int i = 0; i < intr1.length; i++) { + tmp_int1[i] = intr1[i]; + tmp_String1[i] = strr1[i]; + tmp_char1[i] = charr1[i]; + tmp_boolean1[i] = boolr1[i]; + tmp_byte1[i] = byter1[i]; + tmp_short1[i] = shortr1[i]; + tmp_long1[i] = longr1[i]; + tmp_float1[i] = floatr1[i]; + tmp_double1[i] = doubler1[i]; + } + //2D array + for (int i = 0; i < intr2.length; i++) + for(int j = 0; j < intr2[i].length; j++) + { + tmp_int2[i][j] = intr2[i][j]; + tmp_String2[i][j] = strr2[i][j]; + tmp_char2[i][j] = charr2[i][j]; + tmp_boolean2[i][j] = boolr2[i][j]; + tmp_byte2[i][j] = byter2[i][j]; + tmp_short2[i][j] = shortr2[i][j]; + tmp_long2[i][j] = longr2[i][j]; + tmp_float2[i][j] = floatr2[i][j]; + tmp_double2[i][j] = doubler2[i][j]; + } + //3D array + for (int i = 0; i < intr3.length; i++) + for(int j = 0; j < intr3[i].length; j++) + for(int k = 0; k < intr3[i][j].length; k++) + { + tmp_int3[i][j][k] = intr3[i][j][k]; + tmp_String3[i][j][k] = strr3[i][j][k]; + tmp_char3[i][j][k] = charr3[i][j][k]; + tmp_boolean3[i][j][k] = boolr3[i][j][k]; + tmp_byte3[i][j][k] = byter3[i][j][k]; + tmp_short3[i][j][k] = shortr3[i][j][k]; + tmp_long3[i][j][k] = longr3[i][j][k]; + tmp_float3[i][j][k] = floatr3[i][j][k]; + tmp_double3[i][j][k] = doubler3[i][j][k]; + } + //Compare the last value of the array correctly + if(tmp_int1[3] == 40 && tmp_int2[2][0] == 60 && tmp_int3[1][2][0] == 90 + && tmp_String1[3] == "array" && tmp_String2[2][0] == "26" && tmp_String3[1][2][0]== "26" + && tmp_char1[3] == 'd' && tmp_char2[2][0]== 'g' && tmp_char3[1][2][0] == 'n' + && tmp_boolean1[3] == true && tmp_boolean2[2][0] == true && tmp_boolean3[1][2][0] == false + && tmp_byte1[3] == (byte)4 && tmp_byte2[2][0] == (byte)7 && tmp_byte3[1][2][0] == (byte)10 + && tmp_short1[3] == (short)4 && tmp_short2[2][0] == (short)7 && tmp_short3[1][2][0] == (short)10 + && tmp_long1[3] == (long)4 && tmp_long2[2][0] == (long)7 && tmp_long3[1][2][0] == (long)10 + && tmp_float1[3] == 4.4f && tmp_float2[2][0] == 7.7f && tmp_float3[1][2][0] == 10.3f + && tmp_double1[3] == (double) 4.4f && tmp_double2[2][0] == (double)7.7f && tmp_double3[1][2][0] == (double)10.3f) + check_count++; + else + System.out.println("ErrorResult in test01"); + } + + private static void test02() { + /*test02:One, two, three-dimensional array type System.arraycopy () assignment*/ + int [] tmp_int1 = new int[4]; + int [][] tmp_int2 = new int [3][4]; + int [][][] tmp_int3 = new int [2][3][4]; + String [] tmp_String1 = new String[4]; + String [][] tmp_String2 = new String [3][4]; + String [][][] tmp_String3 = new String [2][3][4]; + char [] tmp_char1 = new char[4]; + char [][] tmp_char2 = new char [3][4]; + char [][][] tmp_char3 = new char [2][3][4]; + boolean [] tmp_boolean1 = new boolean[4]; + boolean [][] tmp_boolean2 = new boolean [3][4]; + boolean [][][] tmp_boolean3 = new boolean [2][3][4]; + byte [] tmp_byte1 = new byte[4]; + byte [][] tmp_byte2 = new byte [3][4]; + byte [][][] tmp_byte3 = new byte [2][3][4]; + short [] tmp_short1 = new short[4]; + short [][] tmp_short2 = new short [3][4]; + short [][][] tmp_short3 = new short [2][3][4]; + long [] tmp_long1 = new long[4]; + long [][] tmp_long2 = new long [3][4]; + long [][][] tmp_long3 = new long [2][3][4]; + float [] tmp_float1 = new float[4]; + float [][] tmp_float2 = new float [3][4]; + float [][][] tmp_float3 = new float [2][3][4]; + double [] tmp_double1 = new double[4]; + double [][] tmp_double2 = new double [3][4]; + double [][][] tmp_double3 = new double [2][3][4]; + System.arraycopy(intr1,0,tmp_int1,0,intr1.length); + System.arraycopy(intr2,0,tmp_int2,0,intr2.length); + System.arraycopy(intr3,0,tmp_int3,0,intr3.length); + System.arraycopy(strr1,0,tmp_String1,0,strr1.length); + System.arraycopy(strr2,0,tmp_String2,0,strr2.length); + System.arraycopy(strr3,0,tmp_String3,0,strr3.length); + System.arraycopy(charr1,0,tmp_char1,0,charr1.length); + System.arraycopy(charr2,0,tmp_char2,0,charr2.length); + System.arraycopy(charr3,0,tmp_char3,0,charr3.length); + System.arraycopy(boolr1,0,tmp_boolean1,0,boolr1.length); + System.arraycopy(boolr2,0,tmp_boolean2,0,boolr2.length); + System.arraycopy(boolr3,0,tmp_boolean3,0,boolr3.length); + System.arraycopy(byter1,0,tmp_byte1,0,byter1.length); + System.arraycopy(byter2,0,tmp_byte2,0,byter2.length); + System.arraycopy(byter3,0,tmp_byte3,0,byter3.length); + System.arraycopy(shortr1,0,tmp_short1,0,shortr1.length); + System.arraycopy(shortr2,0,tmp_short2,0,shortr2.length); + System.arraycopy(shortr3,0,tmp_short3,0,shortr3.length); + System.arraycopy(longr1,0,tmp_long1,0,longr1.length); + System.arraycopy(longr2,0,tmp_long2,0,longr2.length); + System.arraycopy(longr3,0,tmp_long3,0,longr3.length); + System.arraycopy(floatr1,0,tmp_float1,0,floatr1.length); + System.arraycopy(floatr2,0,tmp_float2,0,floatr2.length); + System.arraycopy(floatr3,0,tmp_float3,0,floatr3.length); + System.arraycopy(doubler1,0,tmp_double1,0,doubler1.length); + System.arraycopy(doubler2,0,tmp_double2,0,doubler2.length); + System.arraycopy(doubler3,0,tmp_double3,0,doubler3.length); + //Compare the last value of the array correctly + if(tmp_int1[3] == 40 && tmp_int2[2][0] == 60 && tmp_int3[1][2][0] == 90 + && tmp_String1[3] == "array" && tmp_String2[2][0] == "26" && tmp_String3[1][2][0]== "26" + && tmp_char1[3] == 'd' && tmp_char2[2][0]== 'g' && tmp_char3[1][2][0] == 'n' + && tmp_boolean1[3] == true && tmp_boolean2[2][0] == true && tmp_boolean3[1][2][0] == false + && tmp_byte1[3] == (byte)4 && tmp_byte2[2][0] == (byte)7 && tmp_byte3[1][2][0] == (byte)10 + && tmp_short1[3] == (short)4 && tmp_short2[2][0] == (short)7 && tmp_short3[1][2][0] == (short)10 + && tmp_long1[3] == (long)4 && tmp_long2[2][0] == (long)7 && tmp_long3[1][2][0] == (long)10 + && tmp_float1[3] == 4.4f && tmp_float2[2][0] == 7.7f && tmp_float3[1][2][0] == 10.3f + && tmp_double1[3] == (double) 4.4f && tmp_double2[2][0] == (double)7.7f && tmp_double3[1][2][0] == (double)10.3f) + check_count++; + else + System.out.println("ErrorResult in test02"); + } + + private static void test03() + { + /*test03:One, two, three-dimensional array type Arrays.copyOf() assignment*/ + int [] tmp_int1 = Arrays.copyOf(intr1,intr1.length); + int [][] tmp_int2 = Arrays.copyOf(intr2,intr2.length); + int [][][] tmp_int3 = Arrays.copyOf(intr3,intr3.length); + String [] tmp_String1 = Arrays.copyOf(strr1,strr1.length); + String [][] tmp_String2 = Arrays.copyOf(strr2,strr2.length); + String [][][] tmp_String3 = Arrays.copyOf(strr3,strr3.length); + char [] tmp_char1 = Arrays.copyOf(charr1,charr1.length); + char [][] tmp_char2 = Arrays.copyOf(charr2,charr2.length); + char [][][] tmp_char3 = Arrays.copyOf(charr3,charr3.length); + boolean [] tmp_boolean1 = Arrays.copyOf(boolr1,boolr1.length); + boolean [][] tmp_boolean2 = Arrays.copyOf(boolr2,boolr2.length); + boolean [][][] tmp_boolean3 = Arrays.copyOf(boolr3,boolr3.length); + byte [] tmp_byte1 = Arrays.copyOf(byter1,byter1.length); + byte [][] tmp_byte2 = Arrays.copyOf(byter2,byter2.length); + byte [][][] tmp_byte3 = Arrays.copyOf(byter3,byter3.length); + short [] tmp_short1 = Arrays.copyOf(shortr1,shortr1.length); + short [][] tmp_short2 = Arrays.copyOf(shortr2,shortr2.length); + short [][][] tmp_short3 = Arrays.copyOf(shortr3,shortr3.length); + long [] tmp_long1 = Arrays.copyOf(longr1,longr1.length); + long [][] tmp_long2 = Arrays.copyOf(longr2,longr2.length); + long [][][] tmp_long3 = Arrays.copyOf(longr3,longr3.length); + float [] tmp_float1 = Arrays.copyOf(floatr1,floatr1.length); + float [][] tmp_float2 = Arrays.copyOf(floatr2,floatr2.length); + float [][][] tmp_float3 = Arrays.copyOf(floatr3,floatr3.length); + double [] tmp_double1 = Arrays.copyOf(doubler1,doubler1.length); + double [][] tmp_double2 = Arrays.copyOf(doubler2,doubler2.length); + double [][][] tmp_double3 = Arrays.copyOf(doubler3,doubler3.length); + //Compare the last value of the array correctly + if(tmp_int1[3] == 40 && tmp_int2[2][0] == 60 && tmp_int3[1][2][0] == 90 + && tmp_String1[3] == "array" && tmp_String2[2][0] == "26" && tmp_String3[1][2][0]== "26" + && tmp_char1[3] == 'd' && tmp_char2[2][0]== 'g' && tmp_char3[1][2][0] == 'n' + && tmp_boolean1[3] == true && tmp_boolean2[2][0] == true && tmp_boolean3[1][2][0] == false + && tmp_byte1[3] == (byte)4 && tmp_byte2[2][0] == (byte)7 && tmp_byte3[1][2][0] == (byte)10 + && tmp_short1[3] == (short)4 && tmp_short2[2][0] == (short)7 && tmp_short3[1][2][0] == (short)10 + && tmp_long1[3] == (long)4 && tmp_long2[2][0] == (long)7 && tmp_long3[1][2][0] == (long)10 + && tmp_float1[3] == 4.4f && tmp_float2[2][0] == 7.7f && tmp_float3[1][2][0] == 10.3f + && tmp_double1[3] == (double) 4.4f && tmp_double2[2][0] == (double)7.7f && tmp_double3[1][2][0] == (double)10.3f) + check_count++; + else + System.out.println("ErrorResult in test03"); + } + + private static void test04() + { + /*test04:One, two, three-dimensional array type Arrays.copyOfRange() assignment*/ + int [] tmp_int1 = Arrays.copyOfRange(intr1,0,intr1.length); + int [][] tmp_int2 = Arrays.copyOfRange(intr2,0,intr2.length); + int [][][] tmp_int3 = Arrays.copyOfRange(intr3,0,intr3.length); + String [] tmp_String1 = Arrays.copyOfRange(strr1,0,strr1.length); + String [][] tmp_String2 = Arrays.copyOfRange(strr2,0,strr2.length); + String [][][] tmp_String3 = Arrays.copyOfRange(strr3,0,strr3.length); + char [] tmp_char1 = Arrays.copyOfRange(charr1,0,charr1.length); + char [][] tmp_char2 = Arrays.copyOfRange(charr2,0,charr2.length); + char [][][] tmp_char3 = Arrays.copyOfRange(charr3,0,charr3.length); + boolean [] tmp_boolean1 = Arrays.copyOfRange(boolr1,0,boolr1.length); + boolean [][] tmp_boolean2 = Arrays.copyOfRange(boolr2,0,boolr2.length); + boolean [][][] tmp_boolean3 = Arrays.copyOfRange(boolr3,0,boolr3.length); + byte [] tmp_byte1 = Arrays.copyOfRange(byter1,0,byter1.length); + byte [][] tmp_byte2 = Arrays.copyOfRange(byter2,0,byter2.length); + byte [][][] tmp_byte3 = Arrays.copyOfRange(byter3,0,byter3.length); + short [] tmp_short1 = Arrays.copyOfRange(shortr1,0,shortr1.length); + short [][] tmp_short2 = Arrays.copyOfRange(shortr2,0,shortr2.length); + short [][][] tmp_short3 = Arrays.copyOfRange(shortr3,0,shortr3.length); + long [] tmp_long1 = Arrays.copyOfRange(longr1,0,longr1.length); + long [][] tmp_long2 = Arrays.copyOfRange(longr2,0,longr2.length); + long [][][] tmp_long3 = Arrays.copyOfRange(longr3,0,longr3.length); + float [] tmp_float1 = Arrays.copyOfRange(floatr1,0,floatr1.length); + float [][] tmp_float2 = Arrays.copyOfRange(floatr2,0,floatr2.length); + float [][][] tmp_float3 = Arrays.copyOfRange(floatr3,0,floatr3.length); + double [] tmp_double1 = Arrays.copyOfRange(doubler1,0,doubler1.length); + double [][] tmp_double2 = Arrays.copyOfRange(doubler2,0,doubler2.length); + double [][][] tmp_double3 = Arrays.copyOfRange(doubler3,0,doubler3.length); + //Compare the last value of the array correctly + if(tmp_int1[3] == 40 && tmp_int2[2][0] == 60 && tmp_int3[1][2][0] == 90 + && tmp_String1[3] == "array" && tmp_String2[2][0] == "26" && tmp_String3[1][2][0]== "26" + && tmp_char1[3] == 'd' && tmp_char2[2][0]== 'g' && tmp_char3[1][2][0] == 'n' + && tmp_boolean1[3] == true && tmp_boolean2[2][0] == true && tmp_boolean3[1][2][0] == false + && tmp_byte1[3] == (byte)4 && tmp_byte2[2][0] == (byte)7 && tmp_byte3[1][2][0] == (byte)10 + && tmp_short1[3] == (short)4 && tmp_short2[2][0] == (short)7 && tmp_short3[1][2][0] == (short)10 + && tmp_long1[3] == (long)4 && tmp_long2[2][0] == (long)7 && tmp_long3[1][2][0] == (long)10 + && tmp_float1[3] == 4.4f && tmp_float2[2][0] == 7.7f && tmp_float3[1][2][0] == 10.3f + && tmp_double1[3] == (double) 4.4f && tmp_double2[2][0] == (double)7.7f && tmp_double3[1][2][0] == (double)10.3f) + check_count++; + else + System.out.println("ErrorResult in test04"); + } + + private static void test05() + { + /*test05:One, two, three-dimensional array type clone() assignment*/ + int [] tmp_int1 = intr1.clone(); + int [][] tmp_int2 = intr2.clone(); + int [][][] tmp_int3 = intr3.clone(); + String [] tmp_String1 = strr1.clone(); + String [][] tmp_String2 = strr2.clone(); + String [][][] tmp_String3 = strr3.clone(); + char [] tmp_char1 = charr1.clone(); + char [][] tmp_char2 = charr2.clone(); + char [][][] tmp_char3 = charr3.clone(); + boolean [] tmp_boolean1 = boolr1.clone(); + boolean [][] tmp_boolean2 = boolr2.clone(); + boolean [][][] tmp_boolean3 = boolr3.clone(); + byte [] tmp_byte1 = byter1.clone(); + byte [][] tmp_byte2 = byter2.clone(); + byte [][][] tmp_byte3 = byter3.clone(); + short [] tmp_short1 = shortr1.clone(); + short [][] tmp_short2 = shortr2.clone(); + short [][][] tmp_short3 = shortr3.clone(); + long [] tmp_long1 = longr1.clone(); + long [][] tmp_long2 = longr2.clone(); + long [][][] tmp_long3 = longr3.clone(); + float [] tmp_float1 = floatr1.clone(); + float [][] tmp_float2 = floatr2.clone(); + float [][][] tmp_float3 = floatr3.clone(); + double [] tmp_double1 = doubler1.clone(); + double [][] tmp_double2 = doubler2.clone(); + double [][][] tmp_double3 = doubler3.clone(); + //Compare the last value of the array correctly + if(tmp_int1[3] == 40 && tmp_int2[2][0] == 60 && tmp_int3[1][2][0] == 90 + && tmp_String1[3] == "array" && tmp_String2[2][0] == "26" && tmp_String3[1][2][0]== "26" + && tmp_char1[3] == 'd' && tmp_char2[2][0]== 'g' && tmp_char3[1][2][0] == 'n' + && tmp_boolean1[3] == true && tmp_boolean2[2][0] == true && tmp_boolean3[1][2][0] == false + && tmp_byte1[3] == (byte)4 && tmp_byte2[2][0] == (byte)7 && tmp_byte3[1][2][0] == (byte)10 + && tmp_short1[3] == (short)4 && tmp_short2[2][0] == (short)7 && tmp_short3[1][2][0] == (short)10 + && tmp_long1[3] == (long)4 && tmp_long2[2][0] == (long)7 && tmp_long3[1][2][0] == (long)10 + && tmp_float1[3] == 4.4f && tmp_float2[2][0] == 7.7f && tmp_float3[1][2][0] == 10.3f + && tmp_double1[3] == (double) 4.4f && tmp_double2[2][0] == (double)7.7f && tmp_double3[1][2][0] == (double)10.3f) + check_count++; + else + System.out.println("ErrorResult in test05"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0376-rc-ArrayOptimization-RC_Array_11/RC_Array_11.java b/test/testsuite/ouroboros/rc_test/RC0376-rc-ArrayOptimization-RC_Array_11/RC_Array_11.java new file mode 100755 index 0000000000000000000000000000000000000000..b8b4913c6ab2258a38293fd5790a93686d1dbc06 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0376-rc-ArrayOptimization-RC_Array_11/RC_Array_11.java @@ -0,0 +1,381 @@ +/* + *- @TestCaseID:maple/runtime/rc/optimization/RC_Array_11.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Scenario test for RC optimization: Test String array multi-threaded various scenarios, including: + * 1.Five copy scenarios: loop assignment, System.arraycopy(), Arrays.copyOf(), Arrays.copyOfRange(), clone() + * 2.Parameter modification / parameter has not been modified + * 3.final、static + * 4.As a constructor fun + * 5.Function call + * 6.Object Passing param + * 7.return constant; variable; function call + * 8.Exception + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Array_11.java + *- @ExecuteClass: RC_Array_11 + *- @ExecuteArgs: + *- @Remark: + */ +import java.lang.reflect.Array; +import java.util.Arrays; +import java.io.PrintStream; + +public class RC_Array_11 { + static int check_count = 0; + Thread sb = new Thread(); + String[] str_base1; + String[][] str_base2; + String[][][] str_base3; + static String[] strr1 = {"'h''e''l''l''o'","'t''e''s''t'","'f''o''r'","'a''r''r''a''y'"}; + static String[][] strr2 = {{"'h''e''l''l''o'","'t''e''s''t'","'f''o''r'","'a''r''r''a''y'"},{"'2''0''1''8'","'1''1'"},{"'2''6'"}}; + static String[][][] strr3 = {{{"'h''e''l''l''o'","'t''e''s''t'","'f''o''r'","'a''r''r''a''y'"},{"'2''0''1''8'","'1''1'"},{"'2''6'"}}, + {{"'h''u''a''w''e''i'","'t''e''s''t'","'f''o''r'","'a''r''r''a''y'"},{"'2''0''1''8'","'1''1'"},{"'2''6'"}}}; + + private static synchronized void intCheckCount() { + check_count++; + } + + /*The calling function returns a constant value as the assignment of the constant of this function.*/ + private String[] RC_Array_final01() + { + final String [] VALUE1 = {"'h''h''l''l''o'","'t''e''s''t'","'f''o''r'","'h''a''l''l''y'"}; + return VALUE1; + } + private String[][] RC_Array_final02() + { + final String[][] VALUE2 = {{"'h''h''l''l''o'","'t''e''s''t'","'f''o''r'","'h''a''l''l''y'"}, {"'2''0''1''8'","'1''1'"},{"'2''7'"}}; + return VALUE2; + } + private String[][][] RC_Array_final03() + { + final String[][][] VALUE3 = {{{"'h''h''l''l''o'","'t''e''s''t'","'f''o''r'","'h''a''l''l''y'"}, {"'2''0''1''8'","'1''1'"}, {"'2''7'"}}, + {{"'h''u''a''w''e''i'","'t''e''s''t'","'f''o''r'","'a''r''r''a''y'"},{"'2''0''1''8'","'1''1'"},{"'2''7'"}}}; + return VALUE3; + } + + private static void check(String test_method) + { + /*Public function: Check if the length of the assignment source array is as expected to determine whether the resource is recycled.*/ + if(strr1.length == 4 && strr2.length == 3 && strr3.length == 2) + intCheckCount(); + else + System.out.println("ErrorResult in check: " + test_method); + } + + public String run(String argv[],PrintStream out) throws InterruptedException { + String result = "Error"; /*STATUS_FAILED*/ + //Initialization check + check("initialization"); + //Scene test + Thread t1 = new Thread(new test01()); + Thread t2 = new Thread(new test02()); + Thread t3 = new Thread(new test03()); + Thread t4 = new Thread(new test04()); + Thread t5 = new Thread(new test05()); + Thread t6 = new Thread(new test06()); + Thread t7 = new Thread(new test07()); + Thread t8 = new Thread(new test08()); + Thread t9 = new Thread(new test09()); + //Copy scene multithreading + t1.start();t2.start();t3.start();t4.start();t5.start(); + t1.join();t2.join();t3.join();t4.join();t5.join(); + //Other scene + t6.start();t7.start();t8.start(); + t6.join();t7.join();t8.join(); + //Exception scene + t9.start(); + t9.join(); + + check("End"); + //Result judgment + //System.out.println(check_count); + if(check_count == 14) + result = "ExpectResult"; + return result; + } + + public static void main(String argv[]) { + try { + System.out.println(new RC_Array_11().run(argv, System.out)); + }catch (Exception e) + { + System.out.println(e); + } + } + + private class test01 implements Runnable{ + /*test01:One, two, three-dimensional array type cyclic assignment*/ + private void method01() { + String [] tmp_String1 = new String[4]; + String [][] tmp_String2 = new String [3][4]; + String [][][] tmp_String3 = new String [2][3][4]; + //1D array + for (int i = 0; i < strr1.length; i++) { + tmp_String1[i] = strr1[i]; + } + //2D array + for (int i = 0; i < strr2.length; i++) + for(int j = 0; j < strr2[i].length; j++) + { + tmp_String2[i][j] = strr2[i][j]; + } + //3D array + for (int i = 0; i < strr3.length; i++) + for(int j = 0; j < strr3[i].length; j++) + for(int k = 0; k < strr3[i][j].length; k++) + { + tmp_String3[i][j][k] = strr3[i][j][k]; + } + //Compare the last value of the array correctly + if(tmp_String1[3] == "'a''r''r''a''y'" && tmp_String2[2][0] == "'2''6'" && tmp_String3[1][2][0]== "'2''6'") + intCheckCount(); + else + System.out.println("ErrorResult in test01"); + } + public void run() + { + method01(); + } + } + + private class test02 implements Runnable{ + /*test02:One, two, three-dimensional array type System.arraycopy () assignment*/ + private void method02() { + String [] tmp_String1 = new String[4]; + String [][] tmp_String2 = new String [3][4]; + String [][][] tmp_String3 = new String [2][3][4]; + System.arraycopy(strr1,0,tmp_String1,0,strr1.length); + System.arraycopy(strr2,0,tmp_String2,0,strr2.length); + System.arraycopy(strr3,0,tmp_String3,0,strr3.length); + //Compare the last value of the array correctly + if(tmp_String1[3] == "'a''r''r''a''y'" && tmp_String2[2][0] == "'2''6'" && tmp_String3[1][2][0]== "'2''6'") + intCheckCount(); + else + System.out.println("ErrorResult in test02"); + } + public void run() + { + method02(); + } + } + + private class test03 implements Runnable{ + /*test03:One, two, three-dimensional array type Arrays.copyOf() assignment*/ + private void method03() + { + String [] tmp_String1 = Arrays.copyOf(strr1,strr1.length); + String [][] tmp_String2 = Arrays.copyOf(strr2,strr2.length); + String [][][] tmp_String3 = Arrays.copyOf(strr3,strr3.length); + //Compare the last value of the array correctly + if(tmp_String1[3] == "'a''r''r''a''y'" && tmp_String2[2][0] == "'2''6'" && tmp_String3[1][2][0]== "'2''6'") + intCheckCount(); + else + System.out.println("ErrorResult in test03"); + } + public void run() + { + method03(); + } + } + + private class test04 implements Runnable{ + /*test04:One, two, three-dimensional array type Arrays.copyOfRange() assignment*/ + private void method04() + { + String [] tmp_String1 = Arrays.copyOfRange(strr1,0,strr1.length); + String [][] tmp_String2 = Arrays.copyOfRange(strr2,0,strr2.length); + String [][][] tmp_String3 = Arrays.copyOfRange(strr3,0,strr3.length); + //Compare the last value of the array correctly + if(tmp_String1[3] == "'a''r''r''a''y'" && tmp_String2[2][0] == "'2''6'" && tmp_String3[1][2][0]== "'2''6'") + intCheckCount(); + else + System.out.println("ErrorResult in test04"); + } + public void run() + { + method04(); + } + } + + private class test05 implements Runnable{ + /*test05:One, two, three-dimensional array type clone() assignment*/ + private void method05() + { + String [] tmp_String1 = strr1.clone(); + String [][] tmp_String2 = strr2.clone(); + String [][][] tmp_String3 = strr3.clone(); + //Compare the last value of the array correctly + if(tmp_String1[3] == "'a''r''r''a''y'" && tmp_String2[2][0] == "'2''6'" && tmp_String3[1][2][0]== "'2''6'") + intCheckCount(); + else + System.out.println("ErrorResult in test05"); + } + public void run() + { + method05(); + } + } + + private class test06 implements Runnable{ + /*test06Interface call, internal initialization array, do not modify parameter values, only judge*/ + private void method06(String[] arr_str1, String[][] arr_str2, String[][][] arr_str3) + { + String[] tmp_String1 = {"'h''h''l''l''o'","'t''e''s''t'","'f''o''r'","'h''a''l''l''y'"}; + String[][] tmp_String2 = {{"'h''h''l''l''o'","'t''e''s''t'","'f''o''r'","'h''a''l''l''y'"}, {"'2''0''1''8'","'1''1'"},{"'2''7'"}}; + String[][][] tmp_String3 = {{{"'h''h''l''l''o'","'t''e''s''t'","'f''o''r'","'h''a''l''l''y'"}, {"'2''0''1''8'","'1''1'"}, {"'2''7'"}}, + {{"'h''u''a''w''e''i'","'t''e''s''t'","'f''o''r'","'a''r''r''a''y'"},{"'2''0''1''8'","'1''1'"},{"'2''7'"}}}; + //Check the values defined in the function + if(tmp_String1[3] == "'h''a''l''l''y'" && tmp_String2[2][0] == "'2''7'" && tmp_String3[1][2][0] == "'2''7'") + intCheckCount(); + else + System.out.println("ErrorResult in test06 step1"); + //Check unmodified parameter values + if(arr_str1[3]== "'a''r''r''a''y'" && arr_str2[2][0] == "'2''6'" && arr_str3[1][2][0] == "'2''6'") + intCheckCount(); + else + System.out.println("ErrorResult in test06 step2"); + } + public void run() + { + method06(strr1, strr2, strr3); + } + } + + private class test07 implements Runnable{ + /*test07 Interface call, call function change to modify the parameter value and judge*/ + private Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + + private void method07(String[] arr_str1, String[][] arr_str2, String[][][] arr_str3) { + String[] strr1 = {"'h''h''l''l''o'","'t''e''s''t'","'f''o''r'","'h''a''l''l''y'"}; + String[][] strr2 = {{"'h''h''l''l''o'","'t''e''s''t'","'f''o''r'","'h''a''l''l''y'"}, {"'2''0''1''8'","'1''1'"},{"'2''7'"}}; + String[][][] strr3 = {{{"'h''h''l''l''o'","'t''e''s''t'","'f''o''r'","'h''a''l''l''y'"}, {"'2''0''1''8'","'1''1'"}, {"'2''7'"}}, + {{"'h''u''a''w''e''i'","'t''e''s''t'","'f''o''r'","'a''r''r''a''y'"},{"'2''0''1''8'","'1''1'"},{"'2''7'"}}}; + arr_str1 = (String[]) change(arr_str1,strr1); + arr_str2 = (String[][])change(arr_str2,strr2); + arr_str3 = (String[][][]) change(arr_str3,strr3); + //Check the values defined in the function + if(strr1[3] == "'h''a''l''l''y'" && strr2[2][0] == "'2''7'" && strr3[1][2][0] == "'2''7'") + intCheckCount(); + else + System.out.println("ErrorResult in test07 step1"); + //Check the modified parameter values + if(arr_str1[3]== "'h''a''l''l''y'" && arr_str2[2][0] == "'2''7'" && arr_str3[1][2][0] == "'2''7'") + intCheckCount(); + else + System.out.println("ErrorResult in test07 step2"); + } + public void run() + { + method07(strr1,strr2,strr3); + } + } + + private class test08 implements Runnable{ + /*Call the no-argument constructor, initialize the variables of the parent class, and assign values to the + fields of the newly created object, and judge the result*/ + private void method08() { + final String [] VALUE1 = RC_Array_final01(); + final String[][] VALUE2 = RC_Array_final02(); + final String[][][] VALUE3 = RC_Array_final03(); + RC_Array_11 rctest = new RC_Array_11(); + rctest.str_base1 = VALUE1; + rctest.str_base2 = VALUE2; + rctest.str_base3 = VALUE3; + //Check the values defined in the function + if(VALUE1[3] == "'h''a''l''l''y'" && VALUE2[2][0] == "'2''7'" && VALUE3[1][2][0] == "'2''7'") + intCheckCount(); + else + System.out.println("ErrorResult in test08 step1"); + //Check the modified parameter values + if(rctest.str_base1[3]== "'h''a''l''l''y'" && rctest.str_base2[2][0] == "'2''7'" && rctest.str_base3[1][2][0] == "'2''7'") + intCheckCount(); + else + System.out.println("ErrorResult in test08 step2"); + + } + public void run() + { + method08(); + } + } + + private class test09 implements Runnable{ + /*Exception test*/ + private synchronized void method09(){ + int check = 0; + String [] value1 = RC_Array_final01(); + String[][] value2 = RC_Array_final02(); + String[][][] value3 = RC_Array_final03(); + //Is the value judged after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in test09——2"); + + //ArrayIndexOutOfBoundsException + try { + value1[5] = "error"; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value2[5][0] = "error"; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value3[3][3][0] = "error"; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + //Whether the judgment value is normal after the abnormality + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in test09——2"); + + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.get(value1, 1); + } catch (NullPointerException e) { + check++; + } + try { + Array.get(value2, 1); + } catch (NullPointerException e) { + check++; + } + try { + Array.get(value3, 1); + } catch (NullPointerException e) { + check++; + } + + //System.out.println(check); + if (check == 8) + intCheckCount(); + else + System.out.println("End: ErrorResult in test09"); + } + public void run() + { + method09(); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0377-rc-ArrayOptimization-RC_Array_12/RC_Array_12.java b/test/testsuite/ouroboros/rc_test/RC0377-rc-ArrayOptimization-RC_Array_12/RC_Array_12.java new file mode 100755 index 0000000000000000000000000000000000000000..9b8308fb52836f2136448ac3788cf85db86504ed --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0377-rc-ArrayOptimization-RC_Array_12/RC_Array_12.java @@ -0,0 +1,382 @@ +/* + *- @TestCaseID:maple/runtime/rc/optimization/RC_Array_12.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Scenario test for RC optimization: Test Object array multi-threaded various scenarios, including: + * 1.Five copy scenarios: loop assignment, System.arraycopy(), Arrays.copyOf(), Arrays.copyOfRange(), clone() + * 2.Parameter modification / parameter has not been modified + * 3.final、static + * 4.As a constructor fun + * 5.Function call + * 6.Object Passing param + * 7.return constant; variable; function call + * 8.Exception + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Array_12.java + *- @ExecuteClass: RC_Array_12 + *- @ExecuteArgs: + *- @Remark: + */ +import java.lang.reflect.Array; +import java.util.Arrays; +import java.io.PrintStream; + +public class RC_Array_12 { + static int check_count = 0; + Thread sb = new Thread(); + Object[] obj_base1; + Object[][] obj_base2; + Object[][][] obj_base3; + static Object[] objr1 = {'a','b','c','d'}; + static Object[][] objr2 = {{'a','b','c','d'},{'e','f'},{'g'}}; + static Object[][][] objr3 = {{{'a','b','c','d'},{'e','f'},{'g'}},{{'h','i','j','k'},{'l','m'},{'n'}}}; + + private static synchronized void incCheckCount() { + check_count++; + } + + /*The calling function returns a constant value as the assignment of the constant of this function.*/ + private Object[] RC_Array_final04() + { + final Object [] VALUE4 = {'b','s','d','g'}; + return VALUE4; + } + private Object[][] RC_Array_final05() + { + final Object[][] VALUE5 = {{'b','s','d','g'},{'e','f'},{'s'}}; + return VALUE5; + } + private Object[][][] RC_Array_final06() + { + final Object[][][] VALUE6 = {{{'b','s','d','g'},{'e','f'},{'s'}},{{'h','i','j','k'},{'l','m'},{'a'}}}; + return VALUE6; + } + + private static void check(String test_method) + { + /*Public function: Check if the length of the assignment source array is as expected to determine whether the resource is recycled.*/ + if(objr1.length == 4 && objr2.length == 3 && objr3.length == 2) + incCheckCount(); + else + System.out.println("ErrorResult in check: " + test_method); + } + + public String run(String argv[],PrintStream out) throws InterruptedException { + String result = "Error"; /*STATUS_FAILED*/ + //Initialization check + check("initialization"); + //Scene test + Thread t1 = new Thread(new test01()); + Thread t2 = new Thread(new test02()); + Thread t3 = new Thread(new test03()); + Thread t4 = new Thread(new test04()); + Thread t5 = new Thread(new test05()); + Thread t6 = new Thread(new test06()); + Thread t7 = new Thread(new test07()); + Thread t8 = new Thread(new test08()); + Thread t9 = new Thread(new test09()); + //Copy scene multithreading + t1.start();t2.start();t3.start();t4.start();t5.start(); + t1.join();t2.join();t3.join();t4.join();t5.join(); + //Other scene + t6.start();t7.start();t8.start(); + t6.join();t7.join();t8.join(); + //Exception scene + t9.start(); + t9.join(); + + check("End"); + //Result judgment + //System.out.println(check_count); + if(check_count == 14) + result = "ExpectResult"; + return result; + } + + public static void main(String argv[]) { + try { + System.out.println(new RC_Array_12().run(argv, System.out)); + }catch (Exception e) + { + System.out.println(e); + } + } + + private class test01 implements Runnable{ + /*test01:One, two, three-dimensional array type cyclic assignment*/ + private void method01() { + Object [] tmp_obj1 = new Object[4]; + Object [][] tmp_obj2 = new Object [3][4]; + Object [][][] tmp_obj3 = new Object [2][3][4]; + //1D array + for (int i = 0; i < objr1.length; i++) { + tmp_obj1[i] = objr1[i]; + } + //2D array + for (int i = 0; i < objr2.length; i++) + for(int j = 0; j < objr2[i].length; j++) + { + tmp_obj2[i][j] = objr2[i][j]; + } + //3D array + for (int i = 0; i < objr3.length; i++) + for(int j = 0; j < objr3[i].length; j++) + for(int k = 0; k < objr3[i][j].length; k++) + { + tmp_obj3[i][j][k] = objr3[i][j][k]; + } + //Compare the last value of the array correctly + if(tmp_obj1[3] == (Object)'d' && tmp_obj2[2][0] == (Object)'g' && tmp_obj3[1][2][0] == (Object)'n') + incCheckCount(); + else + System.out.println("ErrorResult in test01"); + } + + public void run() + { + method01(); + } + } + + private class test02 implements Runnable{ + /*test02:One, two, three-dimensional array type System.arraycopy () assignment*/ + private void method02() { + Object [] tmp_obj1 = new Object[4]; + Object [][] tmp_obj2 = new Object [3][4]; + Object [][][] tmp_obj3 = new Object [2][3][4]; + System.arraycopy(objr1,0,tmp_obj1,0,objr1.length); + System.arraycopy(objr2,0,tmp_obj2,0,objr2.length); + System.arraycopy(objr3,0,tmp_obj3,0,objr3.length); + //Compare the last value of the array correctly + if(tmp_obj1[3] == (Object)'d' && tmp_obj2[2][0] == (Object)'g' && tmp_obj3[1][2][0] == (Object)'n') + incCheckCount(); + else + System.out.println("ErrorResult in test02"); + } + + public void run() + { + method02(); + } + } + + private class test03 implements Runnable{ + /*test03:One, two, three-dimensional array type Arrays.copyOf() assignment*/ + private void method03() + { + Object [] tmp_obj1 = Arrays.copyOf(objr1,objr1.length); + Object [][] tmp_obj2 = Arrays.copyOf(objr2,objr2.length); + Object [][][] tmp_obj3 = Arrays.copyOf(objr3,objr3.length); + //Compare the last value of the array correctly + if(tmp_obj1[3] == (Object)'d' && tmp_obj2[2][0] == (Object)'g' && tmp_obj3[1][2][0] == (Object)'n') + incCheckCount(); + else + System.out.println("ErrorResult in test03"); + } + public void run() + { + method03(); + } + } + + private class test04 implements Runnable{ + /*test04:One, two, three-dimensional array type Arrays.copyOfRange() assignment*/ + private void method04() + { + Object [] tmp_obj1 = Arrays.copyOfRange(objr1,0,objr1.length); + Object [][] tmp_obj2 = Arrays.copyOfRange(objr2,0,objr2.length); + Object [][][] tmp_obj3 = Arrays.copyOfRange(objr3,0,objr3.length); + //Compare the last value of the array correctly + if(tmp_obj1[3] == (Object)'d' && tmp_obj2[2][0] == (Object)'g' && tmp_obj3[1][2][0] == (Object)'n') + incCheckCount(); + else + System.out.println("ErrorResult in test04"); + } + + public void run() + { + method04(); + } + } + + private class test05 implements Runnable{ + /*test05:One, two, three-dimensional array type clone() assignment*/ + private void method05() + { + Object [] tmp_obj1 = objr1.clone(); + Object [][] tmp_obj2 = objr2.clone(); + Object [][][] tmp_obj3 = objr3.clone(); + //Compare the last value of the array correctly + if(tmp_obj1[3] == (Object)'d' && tmp_obj2[2][0] == (Object)'g' && tmp_obj3[1][2][0] == (Object)'n') + incCheckCount(); + else + System.out.println("ErrorResult in test05"); + } + public void run() + { + method05(); + } + } + + private class test06 implements Runnable{ + /*test06Interface call, internal initialization array, do not modify parameter values, only judge*/ + private void method06(Object[] arr_obj1, Object[][] arr_obj2, Object[][][] arr_obj3) + { + Object[] tmp_obj1 = {'b','s','d','g'}; + Object[][] tmp_obj2 = {{'b','s','d','g'},{'e','f'},{'s'}}; + Object[][][] tmp_obj3 = {{{'b','s','d','g'},{'e','f'},{'s'}},{{'h','i','j','k'},{'l','m'},{'a'}}}; + //Check the values defined in the function + if(tmp_obj1[3] == (Object)'g' && tmp_obj2[2][0] == (Object)'s' && tmp_obj3[1][2][0] == (Object)'a') + incCheckCount(); + else + System.out.println("ErrorResult in test06 step1"); + //Check unmodified parameter values + if(arr_obj1[3] == (Object)'d' && arr_obj2[2][0] == (Object)'g' && arr_obj3[1][2][0] == (Object)'n') + incCheckCount(); + else + System.out.println("ErrorResult in test06 step2"); + } + public void run() + { + method06(objr1,objr2,objr3); + } + } + + private class test07 implements Runnable{ + /*test07 Interface call, call function change to modify the parameter value and judge*/ + private Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + + private void method07(Object[] arr_obj1, Object[][] arr_obj2, Object[][][] arr_obj3) { + Object[] objr1 = {'b','s','d','g'}; + Object[][] objr2 = {{'b','s','d','g'},{'e','f'},{'s'}}; + Object[][][] objr3 = {{{'b','s','d','g'},{'e','f'},{'s'}},{{'h','i','j','k'},{'l','m'},{'a'}}}; + arr_obj1 = (Object[]) change(arr_obj1,objr1); + arr_obj2 = (Object[][])change(arr_obj2,objr2); + arr_obj3 = (Object[][][]) change(arr_obj3,objr3); + //Check the values defined in the function + if(objr1[3] == (Object)'g' && objr2[2][0] == (Object)'s' && objr3[1][2][0] == (Object)'a') + incCheckCount(); + else + System.out.println("ErrorResult in test07 step1"); + //Check the modified parameter values + if(arr_obj1[3] == (Object)'g' && arr_obj2[2][0] == (Object)'s' && arr_obj3[1][2][0] == (Object)'a') + incCheckCount(); + else + System.out.println("ErrorResult in test07 step2"); + } + public void run() + { + method07(objr1,objr2,objr3); + } + } + + private class test08 implements Runnable{ + /*Call the no-argument constructor, initialize the variables of the parent class, and assign values to the + fields of the newly created object, and judge the result*/ + private void method08() { + final Object [] VALUE4 = RC_Array_final04(); + final Object[][] VALUE5 = RC_Array_final05(); + final Object[][][] VALUE6 = RC_Array_final06(); + RC_Array_12 rctest = new RC_Array_12(); + rctest.obj_base1 = VALUE4; + rctest.obj_base2 = VALUE5; + rctest.obj_base3 = VALUE6; + //Check the values defined in the function + if(VALUE4[3] == (Object)'g' && VALUE5[2][0] == (Object)'s' && VALUE6[1][2][0] == (Object)'a') + incCheckCount(); + else + System.out.println("ErrorResult in test08 step1"); + //Check the modified parameter values + if(rctest.obj_base1[3] == (Object)'g' && rctest.obj_base2[2][0] == (Object)'s' && rctest.obj_base3[1][2][0] == (Object)'a') + incCheckCount(); + else + System.out.println("ErrorResult in test08 step2"); + + } + public void run() + { + method08(); + } + } + + private class test09 implements Runnable{ + /*Exception test*/ + private void method09(){ + int check = 0; + Object [] value1 = RC_Array_final04(); + Object[][] value2 = RC_Array_final05(); + Object[][][] value3 = RC_Array_final06(); + //Is the value judged after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in test09——2"); + + //ArrayIndexOutOfBoundsException + try { + value1[5] = "error"; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value2[5][0] = "error"; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value3[3][3][0] = "error"; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + //Whether the judgment value is normal after the abnormality + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in test09——2"); + + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.get(value1, 1); + } catch (NullPointerException e) { + check++; + } + try { + Array.get(value2, 1); + } catch (NullPointerException e) { + check++; + } + try { + Array.get(value3, 1); + } catch (NullPointerException e) { + check++; + } + + //System.out.println(check); + if (check == 8) + incCheckCount(); + else + System.out.println("End: ErrorResult in test09"); + } + + public void run() + { + method09(); + } + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0378-rc-ArrayOptimization-RC_Array_13/RC_Array_13.java b/test/testsuite/ouroboros/rc_test/RC0378-rc-ArrayOptimization-RC_Array_13/RC_Array_13.java new file mode 100755 index 0000000000000000000000000000000000000000..2e9ea4e9316b072ab2576cda80ad1fcca66679a6 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0378-rc-ArrayOptimization-RC_Array_13/RC_Array_13.java @@ -0,0 +1,388 @@ +/* + *- @TestCaseID:maple/runtime/rc/optimization/RC_Array_13.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Scenario test for RC optimization: Test boolean array multi-threaded various scenarios, including: + * 1.Five copy scenarios: loop assignment, System.arraycopy(), Arrays.copyOf(), Arrays.copyOfRange(), clone() + * 2.Parameter modification / parameter has not been modified + * 3.final、static + * 4.As a constructor fun + * 5.Function call + * 6.Object Passing param + * 7.return constant; variable; function call + * 8.Exception + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Array_13.java + *- @ExecuteClass: RC_Array_13 + *- @ExecuteArgs: + *- @Remark: + */ +import java.lang.reflect.Array; +import java.util.Arrays; +import java.io.PrintStream; + +public class RC_Array_13 { + static int check_count = 0; + Thread sb = new Thread(); + boolean[] bool_base1; + boolean[][] bool_base2; + boolean[][][] bool_base3; + static boolean[] boolr1 = {true,false,false,true}; + static boolean[][] boolr2 = {{true,false,false,true},{false,false},{true}}; + static boolean[][][] boolr3 = {{{true,false,false,true},{false,false},{true}},{{false,true,false,true},{true,false},{false}}}; + + private static synchronized void incCheckCount() { + check_count++; + } + + /*The calling function returns a constant value as the assignment of the constant of this function.*/ + private boolean[] RC_Array_final07() + { + final boolean [] VALUE7 = {true,false,false,false}; + return VALUE7; + } + private boolean[][] RC_Array_final08() + { + final boolean[][] VALUE8 = {{true,false,false,true},{false,false},{false}}; + return VALUE8; + } + private boolean[][][] RC_Array_final09() + { + final boolean[][][] VALUE9 = {{{true,false,false,true},{false,false},{true}},{{false,true,false,true},{true,false},{true}}}; + return VALUE9; + } + + private static void check(String test_method) + { + /*Public function: Check if the length of the assignment source array is as expected to determine whether the resource is recycled.*/ + if(boolr1.length == 4 && boolr2.length == 3 && boolr3.length == 2) + incCheckCount(); + else + System.out.println("ErrorResult in check: " + test_method); + } + + public String run(String argv[],PrintStream out) throws InterruptedException { + String result = "Error"; /*STATUS_FAILED*/ + //Initialization check + check("initialization"); + //Scene test + Thread t1 = new Thread(new test01()); + Thread t2 = new Thread(new test02()); + Thread t3 = new Thread(new test03()); + Thread t4 = new Thread(new test04()); + Thread t5 = new Thread(new test05()); + Thread t6 = new Thread(new test06()); + Thread t7 = new Thread(new test07()); + Thread t8 = new Thread(new test08()); + Thread t9 = new Thread(new test09()); + //Copy scene multithreading + t1.start();t2.start();t3.start();t4.start();t5.start(); + t1.join();t2.join();t3.join();t4.join();t5.join(); + //Other scene + t6.start();t7.start();t8.start(); + t6.join();t7.join();t8.join(); + //Exception scene + t9.start(); + t9.join(); + + check("End"); + //Result judgment + if(check_count == 14) + result = "ExpectResult"; + return result; + } + + public static void main(String argv[]) { + try { + System.out.println(new RC_Array_13().run(argv, System.out)); + }catch (Exception e) + { + System.out.println(e); + } + } + + private class test01 implements Runnable{ + /*test01:One, two, three-dimensional array type cyclic assignment*/ + private void method01() { + boolean [] tmp_boolean1 = new boolean[4]; + boolean [][] tmp_boolean2 = new boolean [3][4]; + boolean [][][] tmp_boolean3 = new boolean [2][3][4]; + //1D array + for (int i = 0; i < boolr1.length; i++) { + tmp_boolean1[i] = boolr1[i]; + } + //2D array + for (int i = 0; i < boolr2.length; i++) + for(int j = 0; j < boolr2[i].length; j++) + { + tmp_boolean2[i][j] = boolr2[i][j]; + } + //3D array + for (int i = 0; i < boolr3.length; i++) + for(int j = 0; j < boolr3[i].length; j++) + for(int k = 0; k < boolr3[i][j].length; k++) + { + tmp_boolean3[i][j][k] = boolr3[i][j][k]; + } + //Compare the last value of the array correctly + if(tmp_boolean1[3] == true && tmp_boolean2[2][0] == true && tmp_boolean3[1][2][0] == false) { + incCheckCount(); + } + else + System.out.println("ErrorResult in test01"); + } + public void run() + { + method01(); + } + } + + private class test02 implements Runnable{ + /*test02:One, two, three-dimensional array type System.arraycopy () assignment*/ + private void method02() { + boolean [] tmp_boolean1 = new boolean[4]; + boolean [][] tmp_boolean2 = new boolean [3][4]; + boolean [][][] tmp_boolean3 = new boolean [2][3][4]; + System.arraycopy(boolr1,0,tmp_boolean1,0,boolr1.length); + System.arraycopy(boolr2,0,tmp_boolean2,0,boolr2.length); + System.arraycopy(boolr3,0,tmp_boolean3,0,boolr3.length); + //Compare the last value of the array correctly + if(tmp_boolean1[3] == true && tmp_boolean2[2][0] == true && tmp_boolean3[1][2][0] == false) + incCheckCount(); + else + System.out.println("ErrorResult in test02"); + } + public void run() + { + method02(); + } + } + + private class test03 implements Runnable{ + /*test03:One, two, three-dimensional array type Arrays.copyOf() assignment*/ + private void method03() + { + boolean [] tmp_boolean1 = Arrays.copyOf(boolr1,boolr1.length); + boolean [][] tmp_boolean2 = Arrays.copyOf(boolr2,boolr2.length); + boolean [][][] tmp_boolean3 = Arrays.copyOf(boolr3,boolr3.length); + //Compare the last value of the array correctly + if(tmp_boolean1[3] == true && tmp_boolean2[2][0] == true && tmp_boolean3[1][2][0] == false) + incCheckCount(); + else + System.out.println("ErrorResult in test03"); + } + public void run() + { + method03(); + } + } + + private class test04 implements Runnable{ + /*test04:One, two, three-dimensional array type Arrays.copyOfRange() assignment*/ + private void method04() + { + boolean [] tmp_boolean1 = Arrays.copyOfRange(boolr1,0,boolr1.length); + boolean [][] tmp_boolean2 = Arrays.copyOfRange(boolr2,0,boolr2.length); + boolean [][][] tmp_boolean3 = Arrays.copyOfRange(boolr3,0,boolr3.length); + //Compare the last value of the array correctly + if(tmp_boolean1[3] == true && tmp_boolean2[2][0] == true && tmp_boolean3[1][2][0] == false) + incCheckCount(); + else + System.out.println("ErrorResult in test04"); + } + public void run() + { + method04(); + } + } + + private class test05 implements Runnable{ + /*test05:One, two, three-dimensional array type clone() assignment*/ + private void method05() + { + boolean [] tmp_boolean1 = boolr1.clone(); + boolean [][] tmp_boolean2 = boolr2.clone(); + boolean [][][] tmp_boolean3 = boolr3.clone(); + //Compare the last value of the array correctly + if(tmp_boolean1[3] == true && tmp_boolean2[2][0] == true && tmp_boolean3[1][2][0] == false) + incCheckCount(); + else + System.out.println("ErrorResult in test05"); + } + public void run() + { + method05(); + } + } + + private class test06 implements Runnable{ + /*test06Interface call, internal initialization array, do not modify parameter values, only judge*/ + private void method06(boolean[] arr_bool1, boolean[][] arr_bool2, boolean[][][] arr_bool3) + { + boolean[] tmp_boolean1 = {true,false,false,false}; + boolean[][] tmp_boolean2 = {{true,false,false,true},{false,false},{false}}; + boolean[][][] tmp_boolean3 = {{{true,false,false,true},{false,false},{true}},{{false,true,false,true},{true,false},{true}}}; + //Check the values defined in the function + if(tmp_boolean1[3] == false && tmp_boolean2[2][0] == false && tmp_boolean3[1][2][0] == true) + incCheckCount(); + else + System.out.println("ErrorResult in test06 step1"); + //Check unmodified parameter values + if(arr_bool1[3] == true && arr_bool2[2][0] == true && arr_bool3[1][2][0] == false) + incCheckCount(); + else + System.out.println("ErrorResult in test06 step2"); + } + public void run() + { + method06(boolr1, boolr2, boolr3); + } + } + + private class test07 implements Runnable{ + /*test07 Interface call, call function change to modify the parameter value and judge*/ + private Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + + private void method07(boolean[] arr_bool1, boolean[][] arr_bool2,boolean[][][] arr_bool3) { + boolean[] boolr1 = {true,false,false,false}; + boolean[][] boolr2 = {{true,false,false,true},{false,false},{false}}; + boolean[][][] boolr3 = {{{true,false,false,true},{false,false},{true}},{{false,true,false,true},{true,false},{true}}}; + arr_bool1 = (boolean[]) change(arr_bool1,boolr1); + arr_bool2 = (boolean[][])change(arr_bool2,boolr2); + arr_bool3 = (boolean[][][]) change(arr_bool3,boolr3); + //Check the values defined in the function + if(boolr1[3] == false && boolr2[2][0] == false && boolr3[1][2][0] == true) + incCheckCount(); + else + System.out.println("ErrorResult in test07 step1"); + //Check the modified parameter values + if(arr_bool1[3] == false && arr_bool2[2][0] == false && arr_bool3[1][2][0] == true) + incCheckCount(); + else + System.out.println("ErrorResult in test07 step2"); + } + public void run() + { + method07(boolr1,boolr2,boolr3); + } + } + + private class test08 implements Runnable{ + /*Call the no-argument constructor, initialize the variables of the parent class, and assign values to the + fields of the newly created object, and judge the result*/ + private void method08() { + final boolean [] VALUE7 = RC_Array_final07(); + final boolean[][] VALUE8 = RC_Array_final08(); + final boolean[][][] VALUE9 = RC_Array_final09(); + RC_Array_13 rctest = new RC_Array_13(); + rctest.bool_base1 = VALUE7; + rctest.bool_base2 = VALUE8; + rctest.bool_base3 = VALUE9; + //Check the values defined in the function + if(VALUE7[3] == false && VALUE8[2][0] == false && VALUE9[1][2][0] == true) + incCheckCount(); + else + System.out.println("ErrorResult in test08 step1"); + //Check the modified parameter values + if(rctest.bool_base1[3] == false && rctest.bool_base2[2][0] == false && rctest.bool_base3[1][2][0] == true) + incCheckCount(); + else + System.out.println("ErrorResult in test08 step2"); + + } + public void run() + { + method08(); + } + } + + private class test09 implements Runnable{ + /*Exception test*/ + private synchronized void method09(){ + int check = 0; + boolean [] value1 = RC_Array_final07(); + boolean[][] value2 = RC_Array_final08(); + boolean[][][] value3 = RC_Array_final09(); + //Is the value judged after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in test09——2"); + + //ArrayIndexOutOfBoundsException + try { + value1[5] = true; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value2[5][0] = true; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value3[3][3][0] = true; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + //IllegalArgumentException + try { + Array.getBoolean(value2,1); + }catch (IllegalArgumentException e){ + check++; + } + try { + Array.getBoolean(value3,1); + }catch (IllegalArgumentException e){ + check++; + } + //Whether the judgment value is normal after the abnormality + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in test09——2"); + + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.getBoolean(value1, 1); + } catch (NullPointerException e) { + check++; + } + try { + Array.getBoolean(value2, 1); + } catch (NullPointerException e) { + check++; + } + try { + Array.getBoolean(value3, 1); + } catch (NullPointerException e) { + check++; + } + + //System.out.println(check); + if (check == 10) + incCheckCount(); + else + System.out.println("End: ErrorResult in test09"); + } + public void run() + { + method09(); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0379-rc-ArrayOptimization-RC_Array_14/RC_Array_14.java b/test/testsuite/ouroboros/rc_test/RC0379-rc-ArrayOptimization-RC_Array_14/RC_Array_14.java new file mode 100755 index 0000000000000000000000000000000000000000..bb23ac1fbf7a5ba4fa503599d2cee687cc6735a0 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0379-rc-ArrayOptimization-RC_Array_14/RC_Array_14.java @@ -0,0 +1,388 @@ +/* + *- @TestCaseID:maple/runtime/rc/optimization/RC_Array_14.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Scenario test for RC optimization: Test double array multi-threaded various scenarios, including: + * 1.Five copy scenarios: loop assignment, System.arraycopy(), Arrays.copyOf(), Arrays.copyOfRange(), clone() + * 2.Parameter modification / parameter has not been modified + * 3.final、static + * 4.As a constructor fun + * 5.Function call + * 6.Object Passing param + * 7.return constant; variable; function call + * 8.Exception + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RC_Array_14.java + *- @ExecuteClass: RC_Array_14 + *- @ExecuteArgs: + *- @Remark: + */ +import java.lang.reflect.Array; +import java.util.Arrays; +import java.io.PrintStream; + +public class RC_Array_14 { + static int check_count = 0; + Thread sb = new Thread(); + double[] double_base1; + double[][] double_base2; + double[][][] double_base3; + static double[] doubler1 = {1.1f,2.2f,3.3f,4.4f}; + static double[][] doubler2 = {{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f}}; + static double[][][] doubler3 = {{{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f}},{{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f}}}; + + private static synchronized void incCheckCount() { + check_count++; + } + + /*The calling function returns a constant value as the assignment of the constant of this function.*/ + private double[] RC_Array_final10() + { + final double [] VALUE7 = {1.1f,2.2f,3.3f,4.8f}; + return VALUE7; + } + private double[][] RC_Array_final11() + { + final double[][] VALUE8 = {{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{2.7f}}; + return VALUE8; + } + private double[][][] RC_Array_final12() + { + final double[][][] VALUE9 = {{{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f}},{{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.9f}}}; + return VALUE9; + } + + private static void check(String test_method) + { + /*Public function: Check if the length of the assignment source array is as expected to determine whether the resource is recycled.*/ + if(doubler1.length == 4 && doubler2.length == 3 && doubler3.length == 2) + incCheckCount(); + else + System.out.println("ErrorResult in check: " + test_method); + } + + public String run(String argv[],PrintStream out) throws InterruptedException { + String result = "Error"; /*STATUS_FAILED*/ + //Initialization check + check("initialization"); + //Scene test + Thread t1 = new Thread(new test01()); + Thread t2 = new Thread(new test02()); + Thread t3 = new Thread(new test03()); + Thread t4 = new Thread(new test04()); + Thread t5 = new Thread(new test05()); + Thread t6 = new Thread(new test06()); + Thread t7 = new Thread(new test07()); + Thread t8 = new Thread(new test08()); + Thread t9 = new Thread(new test09()); + //Copy scene multithreading + t1.start();t2.start();t3.start();t4.start();t5.start(); + t1.join();t2.join();t3.join();t4.join();t5.join(); + //Other scene + t6.start();t7.start();t8.start(); + t6.join();t7.join();t8.join(); + //Exception scene + t9.start(); + t9.join(); + + check("End"); + //Result judgment + //System.out.println(check_count); + if(check_count == 14) + result = "ExpectResult"; + return result; + } + + public static void main(String argv[]) { + try { + System.out.println(new RC_Array_14().run(argv, System.out)); + }catch (Exception e) + { + System.out.println(e); + } + } + + private class test01 implements Runnable{ + /*test01:One, two, three-dimensional array type cyclic assignment*/ + private void method01() { + double [] tmp_double1 = new double[4]; + double [][] tmp_double2 = new double [3][4]; + double [][][] tmp_double3 = new double [2][3][4]; + //1D array + for (int i = 0; i < doubler1.length; i++) { + tmp_double1[i] = doubler1[i]; + } + //2D array + for (int i = 0; i < doubler2.length; i++) + for(int j = 0; j < doubler2[i].length; j++) + { + tmp_double2[i][j] = doubler2[i][j]; + } + //3D array + for (int i = 0; i < doubler3.length; i++) + for(int j = 0; j < doubler3[i].length; j++) + for(int k = 0; k < doubler3[i][j].length; k++) + { + tmp_double3[i][j][k] = doubler3[i][j][k]; + } + //Compare the last value of the array correctly + if(tmp_double1[3] == (double) 4.4f && tmp_double2[2][0] == (double)7.7f && tmp_double3[1][2][0] == (double)10.3f) + incCheckCount(); + else + System.out.println("ErrorResult in test01"); + } + public void run() + { + method01(); + } + } + + private class test02 implements Runnable{ + /*test02:One, two, three-dimensional array type System.arraycopy () assignment*/ + private void method02() { + double [] tmp_double1 = new double[4]; + double [][] tmp_double2 = new double [3][4]; + double [][][] tmp_double3 = new double [2][3][4]; + System.arraycopy(doubler1,0,tmp_double1,0,doubler1.length); + System.arraycopy(doubler2,0,tmp_double2,0,doubler2.length); + System.arraycopy(doubler3,0,tmp_double3,0,doubler3.length); + //Compare the last value of the array correctly + if(tmp_double1[3] == (double) 4.4f && tmp_double2[2][0] == (double)7.7f && tmp_double3[1][2][0] == (double)10.3f) + incCheckCount(); + else + System.out.println("ErrorResult in test02"); + } + public void run() + { + method02(); + } + } + + private class test03 implements Runnable{ + /*test03:One, two, three-dimensional array type Arrays.copyOf() assignment*/ + private void method03() + { + double [] tmp_double1 = Arrays.copyOf(doubler1,doubler1.length); + double [][] tmp_double2 = Arrays.copyOf(doubler2,doubler2.length); + double [][][] tmp_double3 = Arrays.copyOf(doubler3,doubler3.length); + //Compare the last value of the array correctly + if(tmp_double1[3] == (double) 4.4f && tmp_double2[2][0] == (double)7.7f && tmp_double3[1][2][0] == (double)10.3f) + incCheckCount(); + else + System.out.println("ErrorResult in test03"); + } + public void run() + { + method03(); + } + } + + private class test04 implements Runnable{ + /*test04:One, two, three-dimensional array type Arrays.copyOfRange() assignment*/ + private void method04() + { + double [] tmp_double1 = Arrays.copyOfRange(doubler1,0,doubler1.length); + double [][] tmp_double2 = Arrays.copyOfRange(doubler2,0,doubler2.length); + double [][][] tmp_double3 = Arrays.copyOfRange(doubler3,0,doubler3.length); + //Compare the last value of the array correctly + if(tmp_double1[3] == (double) 4.4f && tmp_double2[2][0] == (double)7.7f && tmp_double3[1][2][0] == (double)10.3f) + incCheckCount(); + else + System.out.println("ErrorResult in test04"); + } + public void run() + { + method04(); + } + } + + private class test05 implements Runnable{ + /*test05:One, two, three-dimensional array type clone() assignment*/ + private void method05() + { + double [] tmp_double1 = doubler1.clone(); + double [][] tmp_double2 = doubler2.clone(); + double [][][] tmp_double3 = doubler3.clone(); + //Compare the last value of the array correctly + if(tmp_double1[3] == (double) 4.4f && tmp_double2[2][0] == (double)7.7f && tmp_double3[1][2][0] == (double)10.3f) + incCheckCount(); + else + System.out.println("ErrorResult in test05"); + } + public void run() + { + method05(); + } + } + + private class test06 implements Runnable{ + /*test06Interface call, internal initialization array, do not modify parameter values, only judge*/ + private void method06(double[] arr_dou1, double[][] arr_dou2, double[][][] arr_dou3) + { + double[] tmp_double1 = {1.1f,2.2f,3.3f,4.8f}; + double[][] tmp_double2 = {{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{2.7f}}; + double[][][] tmp_double3 = {{{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f}},{{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.9f}}}; + //Check the values defined in the function + if(tmp_double1[3] == 4.8f && tmp_double2[2][0] == 2.7f && tmp_double3[1][2][0] == 10.9f) + incCheckCount(); + else + System.out.println("ErrorResult in test06 step1"); + //Check unmodified parameter values + if(arr_dou1[3] == 4.4f && arr_dou2[2][0] == 7.7f && arr_dou3[1][2][0] == 10.3f) + incCheckCount(); + else + System.out.println("ErrorResult in test06 step2"); + } + public void run() + { + method06(doubler1, doubler2, doubler3); + } + } + + private class test07 implements Runnable{ + /*test07 Interface call, call function change to modify the parameter value and judge*/ + private Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + + private void method07(double[] arr_dou1, double[][] arr_dou2, double[][][] arr_dou3) { + double[] doubler1 = {1.1f,2.2f,3.3f,4.8f}; + double[][] doubler2 = {{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{2.7f}}; + double[][][] doubler3 = {{{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f}},{{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.9f}}}; + arr_dou1 = (double[]) change(arr_dou1,doubler1); + arr_dou2 = (double[][])change(arr_dou2,doubler2); + arr_dou3 = (double[][][]) change(arr_dou3,doubler3); + //Check the values defined in the function + if(doubler1[3] == 4.8f && doubler2[2][0] == 2.7f && doubler3[1][2][0] == 10.9f) + incCheckCount(); + else + System.out.println("ErrorResult in test07 step1"); + //Check the modified parameter values + if(arr_dou1[3] == 4.8f && arr_dou2[2][0] == 2.7f && arr_dou3[1][2][0] == 10.9f) + incCheckCount(); + else + System.out.println("ErrorResult in test07 step2"); + } + public void run() + { + method07(doubler1,doubler2,doubler3); + } + } + + private class test08 implements Runnable{ + /*Call the no-argument constructor, initialize the variables of the parent class, and assign values to the + fields of the newly created object, and judge the result*/ + private void method08() { + final double [] VALUE10 = RC_Array_final10(); + final double[][] VALUE11 = RC_Array_final11(); + final double[][][] VALUE12 = RC_Array_final12(); + RC_Array_14 rctest = new RC_Array_14(); + rctest.double_base1 = VALUE10; + rctest.double_base2 = VALUE11; + rctest.double_base3 = VALUE12; + //Check the values defined in the function + if(VALUE10[3] == 4.8f && VALUE11[2][0] == 2.7f && VALUE12[1][2][0] == 10.9f) + incCheckCount(); + else + System.out.println("ErrorResult in test08 step1"); + //Check the modified parameter values + if(rctest.double_base1[3] == 4.8f && rctest.double_base2[2][0] == 2.7f && rctest.double_base3[1][2][0] == 10.9f) + incCheckCount(); + else + System.out.println("ErrorResult in test08 step2"); + + } + public void run() + { + method08(); + } + } + + private class test09 implements Runnable{ + /*Exception test*/ + private synchronized void method09(){ + int check = 0; + double [] value1 = RC_Array_final10(); + double[][] value2 = RC_Array_final11(); + double[][][] value3 = RC_Array_final12(); + //Is the value judged after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in test09——2"); + + //ArrayIndexOutOfBoundsException + try { + value1[5] = 4.8f; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value2[5][0] = 4.8f; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value3[3][3][0] = 4.8f; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + //IllegalArgumentException + try { + Array.getDouble(value2,1); + }catch (IllegalArgumentException e){ + check++; + } + try { + Array.getDouble(value3,1); + }catch (IllegalArgumentException e){ + check++; + } + //Whether the judgment value is normal after the abnormality + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in test09——2"); + + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.getDouble(value1, 1); + } catch (NullPointerException e) { + check++; + } + try { + Array.getDouble(value2, 1); + } catch (NullPointerException e) { + check++; + } + try { + Array.getDouble(value3, 1); + } catch (NullPointerException e) { + check++; + } + + //System.out.println(check); + if (check == 10) + incCheckCount(); + else + System.out.println("End: ErrorResult in test09"); + } + public void run() + { + method09(); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0380-rc-Annotation-RCWeakRefTest/RCWeakRefTest.java b/test/testsuite/ouroboros/rc_test/RC0380-rc-Annotation-RCWeakRefTest/RCWeakRefTest.java new file mode 100755 index 0000000000000000000000000000000000000000..b9c581cd2b84657732ae84b6254d276bcfdcba43 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0380-rc-Annotation-RCWeakRefTest/RCWeakRefTest.java @@ -0,0 +1,59 @@ +/* + *- @TestCaseID:rc/unownedRef/RCWeakRefTest.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Test the basic function of @Weak + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: RCWeakRefTest.java + *- @ExecuteClass: RCWeakRefTest + *- @ExecuteArgs: + */ + +import com.huawei.ark.annotation.Weak; + +class Test_B { + public void run() { + System.out.println("ExpectResult"); + } +} + +class Test_A { + @Weak + Test_B bb; + Test_B bb2; + + public void test() { + foo(); + try { + Thread.sleep(5000); + } catch (Exception e) { + e.printStackTrace(); + } + try { + bb.run(); + } catch (NullPointerException e) { + System.out.println("ExpectResult"); + } + bb2.run(); + } + + private void foo() { + bb = new Test_B(); + bb2 = new Test_B(); + } +} + +public class RCWeakRefTest { + public static void main(String[] args) { + new Test_A().test(); + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0381-rc-Annotation-RCWeakRefTest2/RCWeakRefTest2.java b/test/testsuite/ouroboros/rc_test/RC0381-rc-Annotation-RCWeakRefTest2/RCWeakRefTest2.java new file mode 100755 index 0000000000000000000000000000000000000000..b300dc821f9698623c6660fed0927b17c51fb6bd --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0381-rc-Annotation-RCWeakRefTest2/RCWeakRefTest2.java @@ -0,0 +1,97 @@ +/* + *- @TestCaseID:rc/unownedRef/RCWeakRefTest2.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Test the basic function of the @Weak + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: RCWeakRefTest2.java + *- @ExecuteClass: RCWeakRefTest2 + *- @ExecuteArgs: + */ + +import java.lang.ref.WeakReference; +import java.lang.reflect.Field; +import com.huawei.ark.annotation.Weak; + +class Test_B { + public void run() { + System.out.println("ExpectResult"); + } +} + +class Test_A { + @Weak + Test_B bb; + @Weak + volatile Test_B bv; + + public void test() { + foo(); + new Thread(new TriggerRef()).start(); + + try { + Thread.sleep(5000); + } catch (Exception e) { + e.printStackTrace(); + } + try { + bb.run(); + } catch (NullPointerException e) { + System.out.println("ExpectResult"); //expect to be null + } + try { + bv.run(); + } catch (NullPointerException e) { + System.out.println("ExpectResult"); //expect to be null + } + } + + private void foo() { + //bb = new Test_B(); + try { + Field m = Test_A.class.getDeclaredField("bb"); + Test_B b1 = new Test_B(); + m.set(this, b1); + Field m1 = Test_A.class.getDeclaredField("bv"); + m1.set(this, b1); + + Test_B temp1 = (Test_B) m.get(this); + if (temp1 != b1) { + System.out.println("error 1"); + } + Test_B temp2 = (Test_B) m1.get(this); + if (temp2 != b1) { + System.out.println("error 1"); + } + } catch (Exception e) { + System.out.println(e); + } + } + + class TriggerRef implements Runnable { + public void run() { + for (int i = 0; i < 100; i++) { + WeakReference ref = new WeakReference(new Object()); + try { + Thread.sleep(50); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } +} + +public class RCWeakRefTest2 { + public static void main(String[] args) { + new Test_A().test(); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0383-rc-Annotation-RCWeakRefTest4/RCWeakRefTest4.java b/test/testsuite/ouroboros/rc_test/RC0383-rc-Annotation-RCWeakRefTest4/RCWeakRefTest4.java new file mode 100755 index 0000000000000000000000000000000000000000..e70bc987d2734a012f15fca760677a94d9d2b9f9 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0383-rc-Annotation-RCWeakRefTest4/RCWeakRefTest4.java @@ -0,0 +1,54 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RCWeakRefTest4.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_1_00010 for @Weak Test + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCWeakRefTest4.java + *- @ExecuteClass: RCWeakRefTest4 + *- @ExecuteArgs: + *- @Remark: Owner Zhang Wenlong 00292413 + */ + +import com.huawei.ark.annotation.Weak; + +class Cycle_B_1_00010_A1 { + @Weak + Cycle_B_1_00010_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00010_A1() { + a1_0 = null; + a = 123; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + +public class RCWeakRefTest4 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00010_A1 a1_0 = new Cycle_B_1_00010_A1(); + a1_0.a1_0 = a1_0; + a1_0.add(); + int nsum = a1_0.sum; + if (nsum == 246) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0384-rc-Annotation-RCWeakRefThreadTest/RCWeakRefThreadTest.java b/test/testsuite/ouroboros/rc_test/RC0384-rc-Annotation-RCWeakRefThreadTest/RCWeakRefThreadTest.java new file mode 100755 index 0000000000000000000000000000000000000000..2b8d497c732878a8458d4df0b82b06a241c39716 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0384-rc-Annotation-RCWeakRefThreadTest/RCWeakRefThreadTest.java @@ -0,0 +1,88 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/RCWeakRefThreadTest.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change RCWeakRefTest4 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCWeakRefThreadTest.java + *- @ExecuteClass: RCWeakRefThreadTest + *- @ExecuteArgs: + *- @Remark: + */ + +import com.huawei.ark.annotation.Weak; + +class ThreadRc_Cycle_Bm_1_00010 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00010_A1 a1_0 = new Cycle_B_1_00010_A1(); + a1_0.a1_0 = a1_0; + a1_0.add(); + int nsum = a1_0.sum; + if (nsum == 246) + checkout = true; + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00010_A1 { + @Weak + Cycle_B_1_00010_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00010_A1() { + a1_0 = null; + a = 123; + sum = 0; + } + + void add() { + sum = a1_0.a + this.a; + } + } +} + +public class RCWeakRefThreadTest { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00010 A1_Cycle_Bm_1_00010 = new ThreadRc_Cycle_Bm_1_00010(); + ThreadRc_Cycle_Bm_1_00010 A2_Cycle_Bm_1_00010 = new ThreadRc_Cycle_Bm_1_00010(); + ThreadRc_Cycle_Bm_1_00010 A3_Cycle_Bm_1_00010 = new ThreadRc_Cycle_Bm_1_00010(); + ThreadRc_Cycle_Bm_1_00010 A4_Cycle_Bm_1_00010 = new ThreadRc_Cycle_Bm_1_00010(); + ThreadRc_Cycle_Bm_1_00010 A5_Cycle_Bm_1_00010 = new ThreadRc_Cycle_Bm_1_00010(); + ThreadRc_Cycle_Bm_1_00010 A6_Cycle_Bm_1_00010 = new ThreadRc_Cycle_Bm_1_00010(); + A1_Cycle_Bm_1_00010.start(); + A2_Cycle_Bm_1_00010.start(); + A3_Cycle_Bm_1_00010.start(); + A4_Cycle_Bm_1_00010.start(); + A5_Cycle_Bm_1_00010.start(); + A6_Cycle_Bm_1_00010.start(); + try { + A1_Cycle_Bm_1_00010.join(); + A2_Cycle_Bm_1_00010.join(); + A3_Cycle_Bm_1_00010.join(); + A4_Cycle_Bm_1_00010.join(); + A5_Cycle_Bm_1_00010.join(); + A6_Cycle_Bm_1_00010.join(); + } catch (InterruptedException e) { + // do nothing + } + if (A1_Cycle_Bm_1_00010.check() && A2_Cycle_Bm_1_00010.check() && A3_Cycle_Bm_1_00010.check() && A4_Cycle_Bm_1_00010.check() && A5_Cycle_Bm_1_00010.check() && A6_Cycle_Bm_1_00010.check()) { + System.out.println("ExpectResult"); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0385-rc-Annotation-RCUnownedRefTest/RCUnownedRefTest.java b/test/testsuite/ouroboros/rc_test/RC0385-rc-Annotation-RCUnownedRefTest/RCUnownedRefTest.java new file mode 100755 index 0000000000000000000000000000000000000000..fd4d70c8fd49da87dc69d7aa16ff5abbee4eeb1b --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0385-rc-Annotation-RCUnownedRefTest/RCUnownedRefTest.java @@ -0,0 +1,71 @@ +/* + *- @TestCaseID:rc/unownedRef/RCUnownedRefTest.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Test the basic function with cycle of the @Unowned + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCUnownedRefTest.java + *- @ExecuteClass: RCUnownedRefTest + *- @ExecuteArgs: + *- @Remark:Owner Zhang Wennlong 00292413 + */ + +import java.lang.reflect.Field; +import com.huawei.ark.annotation.Unowned; + +class Test_B { + @Unowned + Test_A aa; + + // add volatile will crash + // static Test_A a1; + + protected void finalize() { + System.out.println("ExpectResult"); + } +} + +class Test_A { + Test_B bb; + + public void test() { + setReferences(); + System.runFinalization(); + } + + private void setReferences() { + Test_A ta = new Test_A(); + ta.bb = new Test_B(); + //ta.bb.aa = ta; + + try { + Field m = Test_B.class.getDeclaredField("aa"); + m.set(ta.bb, ta); + Test_A a_temp = (Test_A) m.get(ta.bb); + if (a_temp != ta) { + System.out.println("error"); + } + //Field m1 = Test_B.class.getDeclaredField("a1"); + //m1.set(null, ta); + } catch (Exception e) { + System.out.println(e); + } + } +} + + +public class RCUnownedRefTest { + public static void main(String[] args) { + new Test_A().test(); + } +} + + + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0386-rc-Annotation-RCUnownedRefTest2/RCUnownedRefTest2.java b/test/testsuite/ouroboros/rc_test/RC0386-rc-Annotation-RCUnownedRefTest2/RCUnownedRefTest2.java new file mode 100755 index 0000000000000000000000000000000000000000..64e336830a47d66783c115b0cc8d4217075198dd --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0386-rc-Annotation-RCUnownedRefTest2/RCUnownedRefTest2.java @@ -0,0 +1,57 @@ +/* + *- @TestCaseID:rc/unownedRef/RCUnownedRefTest2.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Test the basic function of @Unowned + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: RCUnownedRefTest2.java + *- @ExecuteClass: RCUnownedRefTest2 + *- @ExecuteArgs: + */ + +import com.huawei.ark.annotation.Unowned; + +class Test_B { + @Unowned + Test_B bself; + + protected void run() { + System.out.println("ExpectResult"); + } +} + +class Test_A { + + Test_B bb; + + Test_B bb2; + + public void test() { + foo(); + bb.bself.run(); + bb2.bself.run(); + } + + private void foo() { + bb = new Test_B(); + bb2 = new Test_B(); + bb.bself = bb; + bb2.bself = bb; + } +} + +public class RCUnownedRefTest2 { + public static void main(String[] args) { + new Test_A().test(); + } +} + + + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0387-rc-Annotation-RCUnownedRefUnCycle/RCUnownedRefUnCycle.java b/test/testsuite/ouroboros/rc_test/RC0387-rc-Annotation-RCUnownedRefUnCycle/RCUnownedRefUnCycle.java new file mode 100755 index 0000000000000000000000000000000000000000..0dc1db6a41531af64b28d9cf308562c722c713c9 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0387-rc-Annotation-RCUnownedRefUnCycle/RCUnownedRefUnCycle.java @@ -0,0 +1,125 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RCUnownedRefUnCycle.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Nocycle_a_00150 for @Unowned function Test + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCUnownedRefUnCycle.java + *- @ExecuteClass: RCUnownedRefUnCycle + *- @ExecuteArgs: + */ + +import com.huawei.ark.annotation.Unowned; + +class Nocycle_a_00150_A1 { + Nocycle_a_00150_B1 b1_0; + @Unowned + Nocycle_a_00150_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00150_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } +} + +class Nocycle_a_00150_A2 { + @Unowned + Nocycle_a_00150_B1 b1_0; + Nocycle_a_00150_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00150_A2(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } +} + + +class Nocycle_a_00150_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00150_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class Nocycle_a_00150_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00150_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +public class RCUnownedRefUnCycle { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + + private static void rc_testcase_main_wrapper() { + Nocycle_a_00150_A1 a1_main = new Nocycle_a_00150_A1("a1_main"); + Nocycle_a_00150_A2 a2_main = new Nocycle_a_00150_A2("a2_main"); + a1_main.b1_0 = new Nocycle_a_00150_B1("b1_0"); + a2_main.b2_0 = new Nocycle_a_00150_B2("b2_0"); + a1_main.b2_0 = a2_main.b2_0; + a2_main.b1_0 = a1_main.b1_0; + a1_main.add(); + a2_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a2_main.b1_0.add(); + a2_main.b2_0.add(); + int result = a1_main.sum + a2_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + if (result == 1815) + System.out.println("ExpectResult"); + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0389-rc-Annotation-RCUnownedRefUncycleThread/RCUnownedRefUncycleThread.java b/test/testsuite/ouroboros/rc_test/RC0389-rc-Annotation-RCUnownedRefUncycleThread/RCUnownedRefUncycleThread.java new file mode 100755 index 0000000000000000000000000000000000000000..853b595bd33683a41e64dbe560b695984101fdf0 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0389-rc-Annotation-RCUnownedRefUncycleThread/RCUnownedRefUncycleThread.java @@ -0,0 +1,165 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/RCUnownedRefUncycleThread.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change RCUnownedRefUncycle to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCUnownedRefUncycleThread.java + *- @ExecuteClass: RCUnownedRefUncycleThread + *- @ExecuteArgs: + */ + +import com.huawei.ark.annotation.Unowned; + +class ThreadRc_00150 extends Thread { + private boolean checkout; + + public void run() { + Nocycle_a_00150_A1 a1_main = new Nocycle_a_00150_A1("a1_main"); + Nocycle_a_00150_A2 a2_main = new Nocycle_a_00150_A2("a2_main"); + a1_main.b1_0 = new Nocycle_a_00150_B1("b1_0"); + a2_main.b2_0 = new Nocycle_a_00150_B2("b2_0"); + a2_main.b1_0 = a1_main.b1_0; + a1_main.b2_0 = a2_main.b2_0; + a1_main.add(); + a2_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a2_main.b1_0.add(); + a2_main.b2_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum); + + int result = a1_main.sum + a2_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1815) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Nocycle_a_00150_A1 { + Nocycle_a_00150_B1 b1_0; + @Unowned + Nocycle_a_00150_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00150_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + + class Nocycle_a_00150_A2 { + @Unowned + Nocycle_a_00150_B1 b1_0; + Nocycle_a_00150_B2 b2_0; + int a; + int sum; + String strObjectName; + + Nocycle_a_00150_A2(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + + class Nocycle_a_00150_B1 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00150_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + a; + } + } + + class Nocycle_a_00150_B2 { + int a; + int sum; + String strObjectName; + + Nocycle_a_00150_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + a; + } + } +} + + +public class RCUnownedRefUncycleThread { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_00150 A1_00150 = new ThreadRc_00150(); + ThreadRc_00150 A2_00150 = new ThreadRc_00150(); + ThreadRc_00150 A3_00150 = new ThreadRc_00150(); + ThreadRc_00150 A4_00150 = new ThreadRc_00150(); + ThreadRc_00150 A5_00150 = new ThreadRc_00150(); + ThreadRc_00150 A6_00150 = new ThreadRc_00150(); + + A1_00150.start(); + A2_00150.start(); + A3_00150.start(); + A4_00150.start(); + A5_00150.start(); + A6_00150.start(); + + try { + A1_00150.join(); + A2_00150.join(); + A3_00150.join(); + A4_00150.join(); + A5_00150.join(); + A6_00150.join(); + + } catch (InterruptedException e) { + } + if (A1_00150.check() && A2_00150.check() && A3_00150.check() && A4_00150.check() && A5_00150.check() && A6_00150.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0392-rc-Annotation-RCAnnotationThread02/RCAnnotationThread02.java b/test/testsuite/ouroboros/rc_test/RC0392-rc-Annotation-RCAnnotationThread02/RCAnnotationThread02.java new file mode 100755 index 0000000000000000000000000000000000000000..100d6fc765beacb20d6c16912f3e05a1e20abcee --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0392-rc-Annotation-RCAnnotationThread02/RCAnnotationThread02.java @@ -0,0 +1,205 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread02/RCAnnotationThread02.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Multi Thread reads or writes static para.mofidfy from Cycle_B_1_00180 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCAnnotationThread02.java + *- @ExecuteClass: RCAnnotationThread02 + *- @ExecuteArgs: + *- @Remark: + + * + */ + +import com.huawei.ark.annotation.Weak; +import com.huawei.ark.annotation.Unowned; + +class RCAnnotationThread02_1 extends Thread { + public void run() { + RCAnnotationThread02 rcth01 = new RCAnnotationThread02(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + + } + } +} + +class RCAnnotationThread02_2 extends Thread { + public void run() { + RCAnnotationThread02 rcth01 = new RCAnnotationThread02(); + try { + rcth01.setA4null(); + } catch (NullPointerException e) { + + } + } +} + +class RCAnnotationThread02_3 extends Thread { + public void run() { + RCAnnotationThread02 rcth01 = new RCAnnotationThread02(); + try { + rcth01.setA5null(); + } catch (NullPointerException e) { + + } + + } +} + +public class RCAnnotationThread02 { + private volatile static RCAnnotationThread02_A1 a1_main = null; + private volatile static RCAnnotationThread02_A4 a4_main = null; + private volatile static RCAnnotationThread02_A5 a5_main = null; + + RCAnnotationThread02() { + synchronized (this) { + try { + RCAnnotationThread02_A1 a1 = new RCAnnotationThread02_A1(); + a1.a2_0 = new RCAnnotationThread02_A2(); + a1.a2_0.a3_0 = new RCAnnotationThread02_A3(); + RCAnnotationThread02_A4 a4 = new RCAnnotationThread02_A4(); + RCAnnotationThread02_A5 a5 = new RCAnnotationThread02_A5(); + a4.a1_0 = a1; + a5.a1_0 = a1; + a1.a2_0.a3_0.a1_0 = a1; + a1_main = a1; + a4_main = a4; + a5_main = a5; + } catch (NullPointerException e) { + } + } + } + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + + private static void rc_testcase_main_wrapper() { + RCAnnotationThread02_1 t1=new RCAnnotationThread02_1(); + RCAnnotationThread02_2 t2=new RCAnnotationThread02_2(); + RCAnnotationThread02_3 t3=new RCAnnotationThread02_3(); + t1.start(); + t2.start(); + t3.start(); + + try{ + t1.join(); + t2.join(); + t3.join(); + + }catch(InterruptedException e){} + } + + public void setA1null() { + a1_main = null; + } + + public void setA4null() { + a4_main = null; + } + + public void setA5null() { + a5_main = null; + } + + static class RCAnnotationThread02_A1 { + volatile RCAnnotationThread02_A2 a2_0; + int a; + int sum; + + RCAnnotationThread02_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + + static class RCAnnotationThread02_A2 { + volatile RCAnnotationThread02_A3 a3_0; + int a; + int sum; + + RCAnnotationThread02_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + + static class RCAnnotationThread02_A3 { + @Weak + volatile RCAnnotationThread02_A1 a1_0; + int a; + int sum; + + RCAnnotationThread02_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + static class RCAnnotationThread02_A4 { + @Unowned + volatile RCAnnotationThread02_A1 a1_0; + int a; + int sum; + + RCAnnotationThread02_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + + static class RCAnnotationThread02_A5 { + @Unowned + volatile RCAnnotationThread02_A1 a1_0; + int a; + int sum; + + RCAnnotationThread02_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0394-rc-Annotation-RCAnnotationThread04/RCAnnotationThread04.java b/test/testsuite/ouroboros/rc_test/RC0394-rc-Annotation-RCAnnotationThread04/RCAnnotationThread04.java new file mode 100755 index 0000000000000000000000000000000000000000..0b66b72d95be9ccde5f3e64dbd514a142c0ab421 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0394-rc-Annotation-RCAnnotationThread04/RCAnnotationThread04.java @@ -0,0 +1,264 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread02/RCAnnotationThread04.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Multi Thread reads or writes static para.mofidfy from Cycle_a_00320 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCAnnotationThread04.java + *- @ExecuteClass: RCAnnotationThread04 + *- @ExecuteArgs: + *- @Remark:Owner Zhang Wenlong 00292413 + * + */ + +import com.huawei.ark.annotation.Weak; +import com.huawei.ark.annotation.Unowned; +class RCAnnotationThread04_1 extends Thread { + public void run() { + RCAnnotationThread04 rcth01 = new RCAnnotationThread04(); + try { + rcth01.ModifyA3(); + } catch (NullPointerException e) { + + } + } +} + +class RCAnnotationThread04_2 extends Thread { + public void run() { + RCAnnotationThread04 rcth01 = new RCAnnotationThread04(); + try { + rcth01.checkA3(); + } catch (NullPointerException e) { + + } + } +} + +class RCAnnotationThread04_3 extends Thread { + public void run() { + RCAnnotationThread04 rcth01 = new RCAnnotationThread04(); + try { + rcth01.setA3null(); + } catch (NullPointerException e) { + + } + + } +} + +public class RCAnnotationThread04 { + private volatile static RCAnnotationThread04_A1 a1_main = null; + private volatile static RCAnnotationThread04_A4 a4_main = null; + private volatile static RCAnnotationThread04_A6 a6_main = null; + + RCAnnotationThread04() { + synchronized (this) { + try { + RCAnnotationThread04_A1 a1 = new RCAnnotationThread04_A1("a1"); + RCAnnotationThread04_A4 a4 = new RCAnnotationThread04_A4("a4"); + RCAnnotationThread04_A6 a6 = new RCAnnotationThread04_A6("a6"); + a1.a2_0 = new RCAnnotationThread04_A2("a2_0"); + a1.a2_0.a3_0 = new RCAnnotationThread04_A3("a3_0"); + a1.a2_0.a3_0.a1_0 = a1; + a1.a2_0.a3_0.a5_0 = new RCAnnotationThread04_A5("a5_0"); + a1.a2_0.a3_0.a5_0.a6_0 = a6; + a6.a1_0 = a1; + a6.a3_0 = a1.a2_0.a3_0; + a4.a5_0 = a1.a2_0.a3_0.a5_0; + a6.a4_0 = a4; + a1_main = a1; + a4_main = a4; + a6_main = a6; + } catch (NullPointerException e) { + } + } + } + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + + private static void rc_testcase_main_wrapper() { + RCAnnotationThread04_1 t_00010= new RCAnnotationThread04_1(); + RCAnnotationThread04_2 t_00020= new RCAnnotationThread04_2(); + RCAnnotationThread04_3 t_00030= new RCAnnotationThread04_3(); + t_00010.start(); + t_00020.start(); + t_00030.start(); + try { + t_00010.join(); + t_00020.join(); + t_00030.join(); + + } catch (InterruptedException e) {} + + } + + public void checkA3() { + int[] arr = new int[2]; + try { + arr[0] = a1_main.a2_0.a3_0.a; + arr[1] = a1_main.a2_0.a3_0.sum; + } catch (NullPointerException e) { + + } + } + + public void ModifyA3() { + try { + a1_main.a2_0.a3_0 = new RCAnnotationThread04_A3("new-a3"); + } catch (NullPointerException e) { + + } + } + + public void setA3null() { + RCAnnotationThread04_A3 a3 = new RCAnnotationThread04_A3("test"); + try { + a3 = this.a1_main.a2_0.a3_0; + this.a1_main.a2_0.a3_0 = null; + } catch (NullPointerException e) { + + } + + } + + static class RCAnnotationThread04_A1 { + volatile RCAnnotationThread04_A2 a2_0; + int a; + int sum; + String strObjectName; + + RCAnnotationThread04_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + static class RCAnnotationThread04_A2 { + volatile RCAnnotationThread04_A3 a3_0; + int a; + int sum; + String strObjectName; + + RCAnnotationThread04_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + static class RCAnnotationThread04_A3 { + @Weak + volatile RCAnnotationThread04_A1 a1_0; + volatile RCAnnotationThread04_A5 a5_0; + int a; + int sum; + String strObjectName; + + RCAnnotationThread04_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + + static class RCAnnotationThread04_A4 { + volatile RCAnnotationThread04_A5 a5_0; + int a; + int sum; + String strObjectName; + + RCAnnotationThread04_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } + } + + static class RCAnnotationThread04_A5 { + @Unowned + volatile RCAnnotationThread04_A6 a6_0; + int a; + int sum; + String strObjectName; + + RCAnnotationThread04_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + static class RCAnnotationThread04_A6 { + @Unowned + volatile RCAnnotationThread04_A1 a1_0; + @Unowned + volatile RCAnnotationThread04_A3 a3_0; + @Unowned + volatile RCAnnotationThread04_A4 a4_0; + int a; + int sum; + String strObjectName; + + RCAnnotationThread04_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0395-rc-Annotation-RCAnnotationThread05/RCAnnotationThread05.java b/test/testsuite/ouroboros/rc_test/RC0395-rc-Annotation-RCAnnotationThread05/RCAnnotationThread05.java new file mode 100755 index 0000000000000000000000000000000000000000..19b3847b807e3581c59b149efbca37e1d1e6f860 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0395-rc-Annotation-RCAnnotationThread05/RCAnnotationThread05.java @@ -0,0 +1,268 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread02/RCAnnotationThread05.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Multi Thread reads or writes static para.mofidfy from Cycle_a_00320 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCAnnotationThread05.java + *- @ExecuteClass: RCAnnotationThread05 + *- @ExecuteArgs: + *- @Remark:Owner Zhang Wenlong 00292413 + * + */ + +import com.huawei.ark.annotation.Weak; +import com.huawei.ark.annotation.Unowned; + +class RCAnnotationThread05_1 extends Thread { + public void run() { + RCAnnotationThread05 rcth01 = new RCAnnotationThread05(); + try { + rcth01.ModifyA3(); + } catch (NullPointerException e) { + + } + } +} + +class RCAnnotationThread05_2 extends Thread { + public void run() { + RCAnnotationThread05 rcth01 = new RCAnnotationThread05(); + try { + rcth01.checkA3(); + } catch (NullPointerException e) { + + } + } +} + +class RCAnnotationThread05_3 extends Thread { + public void run() { + RCAnnotationThread05 rcth01 = new RCAnnotationThread05(); + try { + rcth01.setA3null(); + } catch (NullPointerException e) { + + } + + } +} + +public class RCAnnotationThread05 { + private volatile static RCAnnotationThread05_A1 a1_main = null; + private volatile static RCAnnotationThread05_A4 a4_main = null; + private volatile static RCAnnotationThread05_A6 a6_main = null; + private static RCAnnotationThread05_A2 a2=null; + RCAnnotationThread05() { + synchronized (this) { + try { + RCAnnotationThread05_A1 a1 = new RCAnnotationThread05_A1("a1"); + RCAnnotationThread05_A4 a4 = new RCAnnotationThread05_A4("a4"); + RCAnnotationThread05_A6 a6 = new RCAnnotationThread05_A6("a6"); + a2 = new RCAnnotationThread05_A2("a2_0"); + a1.a2_0 = a2; + a1.a2_0.a3_0 = new RCAnnotationThread05_A3("a3_0"); + a1.a2_0.a3_0.a1_0 = a1; + a1.a2_0.a3_0.a5_0 = new RCAnnotationThread05_A5("a5_0"); + a1.a2_0.a3_0.a5_0.a6_0 = a6; + a6.a1_0 = a1; + a6.a3_0 = a1.a2_0.a3_0; + a4.a5_0 = a1.a2_0.a3_0.a5_0; + a6.a4_0 = a4; + a1_main = a1; + a4_main = a4; + a6_main = a6; + } catch (NullPointerException e) { + + } + } + } + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + + private static void rc_testcase_main_wrapper() { + RCAnnotationThread05_1 t_00010= new RCAnnotationThread05_1(); + RCAnnotationThread05_2 t_00020= new RCAnnotationThread05_2(); + RCAnnotationThread05_3 t_00030= new RCAnnotationThread05_3(); + t_00010.start(); + t_00020.start(); + t_00030.start(); + try { + t_00010.join(); + t_00020.join(); + t_00030.join(); + + } catch (InterruptedException e) {} + + } + + public void checkA3() { + int[] arr = new int[2]; + try { + arr[0] = a1_main.a2_0.a3_0.a; + arr[1] = a1_main.a2_0.a3_0.sum; + } catch (NullPointerException e) { + + } + } + + public void ModifyA3() { + try { + a1_main.a2_0.a3_0 = new RCAnnotationThread05_A3("new-a3"); + } catch (NullPointerException e) { + + } + } + + public void setA3null() { + RCAnnotationThread05_A3 a3 = new RCAnnotationThread05_A3("test"); + try { + a3 = this.a1_main.a2_0.a3_0; + this.a1_main.a2_0.a3_0 = null; + } catch (NullPointerException e) { + + } + + } + + static class RCAnnotationThread05_A1 { + volatile RCAnnotationThread05_A2 a2_0; + int a; + int sum; + String strObjectName; + + RCAnnotationThread05_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + static class RCAnnotationThread05_A2 { + volatile RCAnnotationThread05_A3 a3_0; + int a; + int sum; + String strObjectName; + + RCAnnotationThread05_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } + + static class RCAnnotationThread05_A3 { + @Weak + volatile RCAnnotationThread05_A1 a1_0; + volatile RCAnnotationThread05_A5 a5_0; + int a; + int sum; + String strObjectName; + + RCAnnotationThread05_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + + + static class RCAnnotationThread05_A4 { + @Unowned + volatile RCAnnotationThread05_A5 a5_0; + int a; + int sum; + String strObjectName; + + RCAnnotationThread05_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a5_0.a; + } + } + + static class RCAnnotationThread05_A5 { + @Unowned + volatile RCAnnotationThread05_A6 a6_0; + int a; + int sum; + String strObjectName; + + RCAnnotationThread05_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + static class RCAnnotationThread05_A6 { + @Unowned + volatile RCAnnotationThread05_A1 a1_0; + @Unowned + volatile RCAnnotationThread05_A3 a3_0; + @Unowned + volatile RCAnnotationThread05_A4 a4_0; + int a; + int sum; + String strObjectName; + + RCAnnotationThread05_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0396-rc-Annotation-RCAnnotationOneCycle/RCAnnotationOneCycle.java b/test/testsuite/ouroboros/rc_test/RC0396-rc-Annotation-RCAnnotationOneCycle/RCAnnotationOneCycle.java new file mode 100755 index 0000000000000000000000000000000000000000..da9f3103552a17b065c0a6fecdd75756fbb01bee --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0396-rc-Annotation-RCAnnotationOneCycle/RCAnnotationOneCycle.java @@ -0,0 +1,137 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RCAnnotationOneCycle.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Cycle_B_1_00180 for @Weak and @Unowned Test + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCAnnotationOneCycle.java + *- @ExecuteClass: RCAnnotationOneCycle + *- @ExecuteArgs: + *- @Remark:Owner Zhang Wenlong 00292413 + */ + +import com.huawei.ark.annotation.Unowned; +import com.huawei.ark.annotation.Weak; + +class Cycle_B_1_00180_A1 { + Cycle_B_1_00180_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00180_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_1_00180_A2 { + Cycle_B_1_00180_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00180_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_1_00180_A3 { + @Weak + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00180_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + +class Cycle_B_1_00180_A4 { + @Unowned + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00180_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_1_00180_A5 { + @Unowned + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00180_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + +public class RCAnnotationOneCycle { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00180_A1 a1_0 = new Cycle_B_1_00180_A1(); + a1_0.a2_0 = new Cycle_B_1_00180_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00180_A3(); + Cycle_B_1_00180_A4 a4_0 = new Cycle_B_1_00180_A4(); + Cycle_B_1_00180_A5 a5_0 = new Cycle_B_1_00180_A5(); + a4_0.a1_0 = a1_0; + a5_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + //System.out.println(nsum); + if (nsum == 23) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0397-rc-Annotation-RCAnnotationOneCycleThread/RCAnnotationOneCycleThread.java b/test/testsuite/ouroboros/rc_test/RC0397-rc-Annotation-RCAnnotationOneCycleThread/RCAnnotationOneCycleThread.java new file mode 100755 index 0000000000000000000000000000000000000000..d23a0411992ccdc2821ddb3e753029e0f64b6183 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0397-rc-Annotation-RCAnnotationOneCycleThread/RCAnnotationOneCycleThread.java @@ -0,0 +1,173 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/RCAnnotationOneCycleThread.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change RCAnnotationOneCycle to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCAnnotationOneCycleThread.java + *- @ExecuteClass: RCAnnotationOneCycleThread + *- @ExecuteArgs: + *- @Remark:Owner Zhang Wenlong 00292413 + */ + +import com.huawei.ark.annotation.Unowned; +import com.huawei.ark.annotation.Weak; + +class ThreadRc_Cycle_Bm_1_00180 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_1_00180_A1 a1_0 = new Cycle_B_1_00180_A1(); + a1_0.a2_0 = new Cycle_B_1_00180_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00180_A3(); + Cycle_B_1_00180_A4 a4_0 = new Cycle_B_1_00180_A4(); + Cycle_B_1_00180_A5 a5_0 = new Cycle_B_1_00180_A5(); + a4_0.a1_0 = a1_0; + a5_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + //System.out.println(nsum); + + if (nsum == 23) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_1_00180_A1 { + Cycle_B_1_00180_A2 a2_0; + int a; + int sum; + + Cycle_B_1_00180_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_1_00180_A2 { + Cycle_B_1_00180_A3 a3_0; + int a; + int sum; + + Cycle_B_1_00180_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_1_00180_A3 { + @Weak + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00180_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00180_A4 { + @Unowned + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00180_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_1_00180_A5 { + @Unowned + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + + Cycle_B_1_00180_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } +} + + +public class RCAnnotationOneCycleThread { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00180 A1_Cycle_Bm_1_00180 = new ThreadRc_Cycle_Bm_1_00180(); + ThreadRc_Cycle_Bm_1_00180 A2_Cycle_Bm_1_00180 = new ThreadRc_Cycle_Bm_1_00180(); + ThreadRc_Cycle_Bm_1_00180 A3_Cycle_Bm_1_00180 = new ThreadRc_Cycle_Bm_1_00180(); + ThreadRc_Cycle_Bm_1_00180 A4_Cycle_Bm_1_00180 = new ThreadRc_Cycle_Bm_1_00180(); + ThreadRc_Cycle_Bm_1_00180 A5_Cycle_Bm_1_00180 = new ThreadRc_Cycle_Bm_1_00180(); + ThreadRc_Cycle_Bm_1_00180 A6_Cycle_Bm_1_00180 = new ThreadRc_Cycle_Bm_1_00180(); + + A1_Cycle_Bm_1_00180.start(); + A2_Cycle_Bm_1_00180.start(); + A3_Cycle_Bm_1_00180.start(); + A4_Cycle_Bm_1_00180.start(); + A5_Cycle_Bm_1_00180.start(); + A6_Cycle_Bm_1_00180.start(); + + try { + A1_Cycle_Bm_1_00180.join(); + A2_Cycle_Bm_1_00180.join(); + A3_Cycle_Bm_1_00180.join(); + A4_Cycle_Bm_1_00180.join(); + A5_Cycle_Bm_1_00180.join(); + A6_Cycle_Bm_1_00180.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00180.check() && A2_Cycle_Bm_1_00180.check() && A3_Cycle_Bm_1_00180.check() && A4_Cycle_Bm_1_00180.check() && A5_Cycle_Bm_1_00180.check() && A6_Cycle_Bm_1_00180.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0398-rc-Annotation-RCAnnotationTwoCycle/RCAnnotationTwoCycle.java b/test/testsuite/ouroboros/rc_test/RC0398-rc-Annotation-RCAnnotationTwoCycle/RCAnnotationTwoCycle.java new file mode 100755 index 0000000000000000000000000000000000000000..b8334d06d7ab52a7371045bf067ec23d71a361f4 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0398-rc-Annotation-RCAnnotationTwoCycle/RCAnnotationTwoCycle.java @@ -0,0 +1,151 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RCAnnotationTwoCycle.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_2_00080 for @Weak and @Unowned Test. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCAnnotationTwoCycle.java + *- @ExecuteClass: RCAnnotationTwoCycle + *- @ExecuteArgs: + *- @Remark:Owner Zhang Wenlong 00292413 + */ + +import com.huawei.ark.annotation.Unowned; +import com.huawei.ark.annotation.Weak; + +class Cycle_B_2_00080_A1 { + Cycle_B_2_00080_A2 a2_0; + Cycle_B_2_00080_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00080_A1() { + a2_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_2_00080_A2 { + Cycle_B_2_00080_A3 a3_0; + Cycle_B_2_00080_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00080_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00080_A3 { + @Weak + Cycle_B_2_00080_A1 a1_0; + @Unowned + Cycle_B_2_00080_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00080_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } +} + + +class Cycle_B_2_00080_A4 { + @Unowned + Cycle_B_2_00080_A3 a3_0; + @Unowned + Cycle_B_2_00080_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00080_A4() { + a3_0 = null; + a2_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00080_A5 { + @Unowned + Cycle_B_2_00080_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00080_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } +} + +public class RCAnnotationTwoCycle { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00080_A1 a1_0 = new Cycle_B_2_00080_A1(); + a1_0.a2_0 = new Cycle_B_2_00080_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00080_A3(); + Cycle_B_2_00080_A4 a4_0 = new Cycle_B_2_00080_A4(); + a4_0.a2_0 = a1_0.a2_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a5_0 = new Cycle_B_2_00080_A5(); + a1_0.a2_0.a3_0.a5_0 = a1_0.a5_0; + a4_0.a3_0.a5_0 = a1_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a1_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a1_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 28) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0399-rc-Annotation-RCAnnotationTwoCycle2/RCAnnotationTwoCycle2.java b/test/testsuite/ouroboros/rc_test/RC0399-rc-Annotation-RCAnnotationTwoCycle2/RCAnnotationTwoCycle2.java new file mode 100755 index 0000000000000000000000000000000000000000..dded5151cb583314a7a18b8b14c86c016ecdfeac --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0399-rc-Annotation-RCAnnotationTwoCycle2/RCAnnotationTwoCycle2.java @@ -0,0 +1,236 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RCAnnotationTwoCycle2.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_B_2_00230 in RC测试-Cycle-00.vsd. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCAnnotationTwoCycle2.java + *- @ExecuteClass: RCAnnotationTwoCycle2 + *- @ExecuteArgs: + *- @Remark:Owner Zhang Wenlong 00292413 + */ + +import com.huawei.ark.annotation.Unowned; +import com.huawei.ark.annotation.Weak; + +class Cycle_B_2_00230_A1 { + Cycle_B_2_00230_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00230_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_B_2_00230_A2 { + Cycle_B_2_00230_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00230_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } +} + + +class Cycle_B_2_00230_A3 { + Cycle_B_2_00230_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00230_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } +} + + +class Cycle_B_2_00230_A4 { + Cycle_B_2_00230_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00230_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } +} + + +class Cycle_B_2_00230_A5 { + Cycle_B_2_00230_A6 a6_0; + int a; + int sum; + + Cycle_B_2_00230_A5() { + a6_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a6_0.a; + } +} + + +class Cycle_B_2_00230_A6 { + @Weak + Cycle_B_2_00230_A1 a1_0; + @Unowned + Cycle_B_2_00230_A10 a10_0; + int a; + int sum; + + Cycle_B_2_00230_A6() { + a1_0 = null; + a10_0 = null; + a = 6; + sum = 0; + } + + void add() { + sum = a + a1_0.a + a10_0.a; + } +} + +class Cycle_B_2_00230_A8 { + Cycle_B_2_00230_A9 a9_0; + int a; + int sum; + + Cycle_B_2_00230_A8() { + a9_0 = null; + a = 7; + sum = 0; + } + + void add() { + sum = a + a9_0.a; + } +} + + +class Cycle_B_2_00230_A9 { + Cycle_B_2_00230_A7 a7_0; + int a; + int sum; + + Cycle_B_2_00230_A9() { + a7_0 = null; + a = 8; + sum = 0; + } + + void add() { + sum = a + a7_0.a; + } +} + + +class Cycle_B_2_00230_A7 { + @Unowned + Cycle_B_2_00230_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00230_A7() { + a4_0 = null; + a = 9; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } +} + + +class Cycle_B_2_00230_A10 { + Cycle_B_2_00230_A8 a8_0; + int a; + int sum; + + Cycle_B_2_00230_A10() { + a8_0 = null; + a = 10; + sum = 0; + } + + void add() { + sum = a + a8_0.a; + } +} + + +public class RCAnnotationTwoCycle2 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00230_A1 a1_0 = new Cycle_B_2_00230_A1(); + a1_0.a2_0 = new Cycle_B_2_00230_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00230_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00230_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00230_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_B_2_00230_A6(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_0; + + Cycle_B_2_00230_A10 a10_0 = new Cycle_B_2_00230_A10(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a10_0 = a10_0; + a10_0.a8_0 = new Cycle_B_2_00230_A8(); + a10_0.a8_0.a9_0 = new Cycle_B_2_00230_A9(); + a10_0.a8_0.a9_0.a7_0 = new Cycle_B_2_00230_A7(); + a10_0.a8_0.a9_0.a7_0.a4_0 = a1_0.a2_0.a3_0.a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a10_0.a8_0.add(); + a10_0.a8_0.a9_0.add(); + a10_0.a8_0.a9_0.a7_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a10_0.a8_0.sum + a10_0.a8_0.a9_0.sum + a10_0.a8_0.a9_0.a7_0.sum); + + //System.out.println(nsum); + if (nsum == 97) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0400-rc-Annotation-RCAnnotationTwoCycleThread/RCAnnotationTwoCycleThread.java b/test/testsuite/ouroboros/rc_test/RC0400-rc-Annotation-RCAnnotationTwoCycleThread/RCAnnotationTwoCycleThread.java new file mode 100755 index 0000000000000000000000000000000000000000..4a17d9f66dc03788b2e4582f5cf9738cfb5c40ab --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0400-rc-Annotation-RCAnnotationTwoCycleThread/RCAnnotationTwoCycleThread.java @@ -0,0 +1,187 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/RCAnnotationTwoCycleThread.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change RCAnnotationTwoCycle to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCAnnotationTwoCycleThread.java + *- @ExecuteClass: RCAnnotationTwoCycleThread + *- @ExecuteArgs: + *- @Remark:Owner Zhang Wenlong 00292413 + */ + +import com.huawei.ark.annotation.Unowned; +import com.huawei.ark.annotation.Weak; + +class ThreadRc_Cycle_Bm_2_00080 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00080_A1 a1_0 = new Cycle_B_2_00080_A1(); + a1_0.a2_0 = new Cycle_B_2_00080_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00080_A3(); + Cycle_B_2_00080_A4 a4_0 = new Cycle_B_2_00080_A4(); + a4_0.a2_0 = a1_0.a2_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a5_0 = new Cycle_B_2_00080_A5(); + a1_0.a2_0.a3_0.a5_0 = a1_0.a5_0; + a4_0.a3_0.a5_0 = a1_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a1_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a1_0.a5_0.sum); + //System.out.println(nsum); + + if (nsum == 28) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00080_A1 { + Cycle_B_2_00080_A2 a2_0; + Cycle_B_2_00080_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00080_A1() { + a2_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00080_A2 { + Cycle_B_2_00080_A3 a3_0; + Cycle_B_2_00080_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00080_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00080_A3 { + @Weak + Cycle_B_2_00080_A1 a1_0; + @Unowned + Cycle_B_2_00080_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00080_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_B_2_00080_A4 { + @Unowned + Cycle_B_2_00080_A3 a3_0; + @Unowned + Cycle_B_2_00080_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00080_A4() { + a3_0 = null; + a2_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00080_A5 { + @Unowned + Cycle_B_2_00080_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00080_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } +} + + +public class RCAnnotationTwoCycleThread { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00080 A1_Cycle_Bm_2_00080 = new ThreadRc_Cycle_Bm_2_00080(); + ThreadRc_Cycle_Bm_2_00080 A2_Cycle_Bm_2_00080 = new ThreadRc_Cycle_Bm_2_00080(); + ThreadRc_Cycle_Bm_2_00080 A3_Cycle_Bm_2_00080 = new ThreadRc_Cycle_Bm_2_00080(); + ThreadRc_Cycle_Bm_2_00080 A4_Cycle_Bm_2_00080 = new ThreadRc_Cycle_Bm_2_00080(); + ThreadRc_Cycle_Bm_2_00080 A5_Cycle_Bm_2_00080 = new ThreadRc_Cycle_Bm_2_00080(); + ThreadRc_Cycle_Bm_2_00080 A6_Cycle_Bm_2_00080 = new ThreadRc_Cycle_Bm_2_00080(); + + A1_Cycle_Bm_2_00080.start(); + A2_Cycle_Bm_2_00080.start(); + A3_Cycle_Bm_2_00080.start(); + A4_Cycle_Bm_2_00080.start(); + A5_Cycle_Bm_2_00080.start(); + A6_Cycle_Bm_2_00080.start(); + + try { + A1_Cycle_Bm_2_00080.join(); + A2_Cycle_Bm_2_00080.join(); + A3_Cycle_Bm_2_00080.join(); + A4_Cycle_Bm_2_00080.join(); + A5_Cycle_Bm_2_00080.join(); + A6_Cycle_Bm_2_00080.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00080.check() && A2_Cycle_Bm_2_00080.check() && A3_Cycle_Bm_2_00080.check() && A4_Cycle_Bm_2_00080.check() && A5_Cycle_Bm_2_00080.check() && A6_Cycle_Bm_2_00080.check()) + System.out.println("ExpectResult"); + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0401-rc-Annotation-RCAnnotationTwoCycleThread2/RCAnnotationTwoCycleThread2.java b/test/testsuite/ouroboros/rc_test/RC0401-rc-Annotation-RCAnnotationTwoCycleThread2/RCAnnotationTwoCycleThread2.java new file mode 100755 index 0000000000000000000000000000000000000000..ed8e7353592c068c15783ce8ef7550c619d40814 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0401-rc-Annotation-RCAnnotationTwoCycleThread2/RCAnnotationTwoCycleThread2.java @@ -0,0 +1,263 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/RCAnnotationTwoCycleThread2.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change RCAnnotationTwoCycle2 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCAnnotationTwoCycleThread2.java + *- @ExecuteClass: RCAnnotationTwoCycleThread2 + *- @ExecuteArgs: + *- @Remark:Owner Zhang Wenlong 00292413 + */ + +import com.huawei.ark.annotation.Unowned; +import com.huawei.ark.annotation.Weak; + +class ThreadRc_Cycle_Bm_2_00230 extends Thread { + private boolean checkout; + + public void run() { + Cycle_B_2_00230_A1 a1_0 = new Cycle_B_2_00230_A1(); + a1_0.a2_0 = new Cycle_B_2_00230_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00230_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00230_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00230_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_B_2_00230_A6(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_0; + + Cycle_B_2_00230_A10 a10_0 = new Cycle_B_2_00230_A10(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a10_0 = a10_0; + a10_0.a8_0 = new Cycle_B_2_00230_A8(); + a10_0.a8_0.a9_0 = new Cycle_B_2_00230_A9(); + a10_0.a8_0.a9_0.a7_0 = new Cycle_B_2_00230_A7(); + a10_0.a8_0.a9_0.a7_0.a4_0 = a1_0.a2_0.a3_0.a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a10_0.a8_0.add(); + a10_0.a8_0.a9_0.add(); + a10_0.a8_0.a9_0.a7_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a10_0.a8_0.sum + a10_0.a8_0.a9_0.sum + a10_0.a8_0.a9_0.a7_0.sum); + + if (nsum == 97) + checkout = true; + } + + public boolean check() { + return checkout; + } + + class Cycle_B_2_00230_A1 { + Cycle_B_2_00230_A2 a2_0; + int a; + int sum; + + Cycle_B_2_00230_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_B_2_00230_A2 { + Cycle_B_2_00230_A3 a3_0; + int a; + int sum; + + Cycle_B_2_00230_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + + void add() { + sum = a + a3_0.a; + } + } + + class Cycle_B_2_00230_A3 { + Cycle_B_2_00230_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00230_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_B_2_00230_A4 { + Cycle_B_2_00230_A5 a5_0; + int a; + int sum; + + Cycle_B_2_00230_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + + void add() { + sum = a + a5_0.a; + } + } + + class Cycle_B_2_00230_A5 { + Cycle_B_2_00230_A6 a6_0; + int a; + int sum; + + Cycle_B_2_00230_A5() { + a6_0 = null; + a = 5; + sum = 0; + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_B_2_00230_A6 { + @Weak + Cycle_B_2_00230_A1 a1_0; + @Unowned + Cycle_B_2_00230_A10 a10_0; + int a; + int sum; + + Cycle_B_2_00230_A6() { + a1_0 = null; + a10_0 = null; + a = 6; + sum = 0; + } + + void add() { + sum = a + a1_0.a + a10_0.a; + } + } + + class Cycle_B_2_00230_A8 { + Cycle_B_2_00230_A9 a9_0; + int a; + int sum; + + Cycle_B_2_00230_A8() { + a9_0 = null; + a = 7; + sum = 0; + } + + void add() { + sum = a + a9_0.a; + } + } + + class Cycle_B_2_00230_A9 { + Cycle_B_2_00230_A7 a7_0; + int a; + int sum; + + Cycle_B_2_00230_A9() { + a7_0 = null; + a = 8; + sum = 0; + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_B_2_00230_A7 { + @Unowned + Cycle_B_2_00230_A4 a4_0; + int a; + int sum; + + Cycle_B_2_00230_A7() { + a4_0 = null; + a = 9; + sum = 0; + } + + void add() { + sum = a + a4_0.a; + } + } + + class Cycle_B_2_00230_A10 { + Cycle_B_2_00230_A8 a8_0; + int a; + int sum; + + Cycle_B_2_00230_A10() { + a8_0 = null; + a = 10; + sum = 0; + } + + void add() { + sum = a + a8_0.a; + } + } +} + + +public class RCAnnotationTwoCycleThread2 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00230 A1_Cycle_Bm_2_00230 = new ThreadRc_Cycle_Bm_2_00230(); + ThreadRc_Cycle_Bm_2_00230 A2_Cycle_Bm_2_00230 = new ThreadRc_Cycle_Bm_2_00230(); + ThreadRc_Cycle_Bm_2_00230 A3_Cycle_Bm_2_00230 = new ThreadRc_Cycle_Bm_2_00230(); + ThreadRc_Cycle_Bm_2_00230 A4_Cycle_Bm_2_00230 = new ThreadRc_Cycle_Bm_2_00230(); + ThreadRc_Cycle_Bm_2_00230 A5_Cycle_Bm_2_00230 = new ThreadRc_Cycle_Bm_2_00230(); + ThreadRc_Cycle_Bm_2_00230 A6_Cycle_Bm_2_00230 = new ThreadRc_Cycle_Bm_2_00230(); + + A1_Cycle_Bm_2_00230.start(); + A2_Cycle_Bm_2_00230.start(); + A3_Cycle_Bm_2_00230.start(); + A4_Cycle_Bm_2_00230.start(); + A5_Cycle_Bm_2_00230.start(); + A6_Cycle_Bm_2_00230.start(); + + try { + A1_Cycle_Bm_2_00230.join(); + A2_Cycle_Bm_2_00230.join(); + A3_Cycle_Bm_2_00230.join(); + A4_Cycle_Bm_2_00230.join(); + A5_Cycle_Bm_2_00230.join(); + A6_Cycle_Bm_2_00230.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00230.check() && A2_Cycle_Bm_2_00230.check() && A3_Cycle_Bm_2_00230.check() && A4_Cycle_Bm_2_00230.check() && A5_Cycle_Bm_2_00230.check() && A6_Cycle_Bm_2_00230.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0402-rc-Annotation-RCAnnotationMultiCycle/RCAnnotationMultiCycle.java b/test/testsuite/ouroboros/rc_test/RC0402-rc-Annotation-RCAnnotationMultiCycle/RCAnnotationMultiCycle.java new file mode 100755 index 0000000000000000000000000000000000000000..5074e244b7b12741cea2852bde64c1e0dd85cac2 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0402-rc-Annotation-RCAnnotationMultiCycle/RCAnnotationMultiCycle.java @@ -0,0 +1,171 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RCAnnotationMultiCycle.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00280 for @Weak and @Unowned Test + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCAnnotationMultiCycle.java + *- @ExecuteClass: RCAnnotationMultiCycle + *- @ExecuteArgs: + *- @Remark: Owner Zhang Wenlong 00292413 + * A1 depend A2 A3; A6 depend A3 + * A2 depend A1 A3; A3 depend A1 A5; A5 depend A6; + * A1.a=101 A2.a=102 A3.a=103 ... A9.a=109 + * RC-Testing_Result=(101+102+103)+(102+101+103)+(103+101+102+105)+(105+106)+(106+103)=1443 + * + */ + +import com.huawei.ark.annotation.Unowned; +import com.huawei.ark.annotation.Weak; + +class Cycle_a_00280_A1 { + Cycle_a_00280_A2 a2_0; + @Unowned + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00280_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } +} + +class Cycle_a_00280_A2 { + @Weak + Cycle_a_00280_A1 a1_0; + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00280_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } +} + +class Cycle_a_00280_A3 { + @Weak + Cycle_a_00280_A1 a1_0; + @Weak + Cycle_a_00280_A2 a2_0; + Cycle_a_00280_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00280_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a2_0.a + a5_0.a; + } +} + + +class Cycle_a_00280_A5 { + @Unowned + Cycle_a_00280_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00280_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } +} + +class Cycle_a_00280_A6 { + @Unowned + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00280_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } +} + + +public class RCAnnotationMultiCycle { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00280_A1 a1_main = new Cycle_a_00280_A1("a1_main"); + Cycle_a_00280_A6 a6_main = new Cycle_a_00280_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00280_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00280_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00280_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a3_0 = a1_main.a2_0.a3_0; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + if (result == 1443) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0403-rc-Annotation-RCAnnotationMultiCycle2/RCAnnotationMultiCycle2.java b/test/testsuite/ouroboros/rc_test/RC0403-rc-Annotation-RCAnnotationMultiCycle2/RCAnnotationMultiCycle2.java new file mode 100755 index 0000000000000000000000000000000000000000..a33a576ed831e002c8f4f5098ad0dd6fbdc608c1 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0403-rc-Annotation-RCAnnotationMultiCycle2/RCAnnotationMultiCycle2.java @@ -0,0 +1,290 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RCAnnotationMultiCycle2.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: Cycle_a_00370 for @Weak and @Unowned Test + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCAnnotationMultiCycle2.java + *- @ExecuteClass: RCAnnotationMultiCycle2 + *- @ExecuteArgs: + *- @Remark:Owner Zhang Wenlong 00292413 + * A1 depend A2 ; A4 depend A1 ; A6 depend A1 A3; + * A2 depend A3 A4; A3 depend A1 A5 A10; A5 depend A6 A8 + * A7 depend A2 ; A8 depend A7; + * A8 depend A6 ; A10 depend A9; + * A1.a=101 A2.a=102 A3.a=103 ... A9.a=109 A10.a=1001 + * RC-Testing_Result=(101+102)+(102+103+104)+(103+101+105+110)+(104+101)+(105+106+108)+(106+101+103)+(107+102)+(108+107)+(109+106)+(110+109)=2623 + * + */ + +import com.huawei.ark.annotation.Unowned; +import com.huawei.ark.annotation.Weak; + +class Cycle_a_00370_A1 { + Cycle_a_00370_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + +class Cycle_a_00370_A2 { + Cycle_a_00370_A3 a3_0; + @Unowned + Cycle_a_00370_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } +} + +class Cycle_a_00370_A3 { + @Weak + Cycle_a_00370_A1 a1_0; + Cycle_a_00370_A5 a5_0; + Cycle_a_00370_A10 a10_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a10_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a + a10_0.a; + } +} + + +class Cycle_a_00370_A4 { + @Unowned + Cycle_a_00370_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } +} + +class Cycle_a_00370_A5 { + @Unowned + Cycle_a_00370_A6 a6_0; + Cycle_a_00370_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a + a8_0.a; + } +} + +class Cycle_a_00370_A6 { + @Unowned + Cycle_a_00370_A1 a1_0; + @Unowned + Cycle_a_00370_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } +} + + +class Cycle_a_00370_A7 { + @Unowned + Cycle_a_00370_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } +} + + +class Cycle_a_00370_A8 { + Cycle_a_00370_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } +} + + +class Cycle_a_00370_A9 { + @Unowned + Cycle_a_00370_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A9(String strObjectName) { + a6_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } +} + +class Cycle_a_00370_A10 { + @Unowned + Cycle_a_00370_A9 a9_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A10(String strObjectName) { + a9_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + + void add() { + sum = a + a9_0.a; + } +} + +public class RCAnnotationMultiCycle2 { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + + private static void rc_testcase_main_wrapper() { + Cycle_a_00370_A1 a1_main = new Cycle_a_00370_A1("a1_main"); + Cycle_a_00370_A4 a4_main = new Cycle_a_00370_A4("a4_main"); + Cycle_a_00370_A6 a6_main = new Cycle_a_00370_A6("a6_main"); + Cycle_a_00370_A9 a9_main = new Cycle_a_00370_A9("a9_main"); + a1_main.a2_0 = new Cycle_a_00370_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00370_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00370_A5("a5_0"); + a1_main.a2_0.a3_0.a10_0 = new Cycle_a_00370_A10("a10_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00370_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00370_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a10_0.a9_0 = a9_main; + a9_main.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a9_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a10_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a9_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum +a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.sum + a1_main.a2_0.a3_0.a5_0.a8_0.sum + a1_main.a2_0.a3_0.a10_0.sum; + + if (result == 2623) + System.out.println("ExpectResult"); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0404-rc-Annotation-RCAnnotationMultiCycleThread/RCAnnotationMultiCycleThread.java b/test/testsuite/ouroboros/rc_test/RC0404-rc-Annotation-RCAnnotationMultiCycleThread/RCAnnotationMultiCycleThread.java new file mode 100755 index 0000000000000000000000000000000000000000..2bfc4f55e3ab9c06fe433a2df1d26d2a96397293 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0404-rc-Annotation-RCAnnotationMultiCycleThread/RCAnnotationMultiCycleThread.java @@ -0,0 +1,203 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/RCAnnotationMultiCycleThread.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change RCAnnotationMultiCycle to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCAnnotationMultiCycleThread.java + *- @ExecuteClass: RCAnnotationMultiCycleThread + *- @ExecuteArgs: + *- @Remark:Owner Zhang Wenlong 00292413 + */ + +import com.huawei.ark.annotation.Unowned; +import com.huawei.ark.annotation.Weak; + +class ThreadRc_Cycle_am_00280 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00280_A1 a1_main = new Cycle_a_00280_A1("a1_main"); + Cycle_a_00280_A6 a6_main = new Cycle_a_00280_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00280_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00280_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00280_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a3_0 = a1_main.a2_0.a3_0; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + + if (result == 1443) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00280_A1 { + Cycle_a_00280_A2 a2_0; + @Unowned + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00280_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } + } + + class Cycle_a_00280_A2 { + @Weak + Cycle_a_00280_A1 a1_0; + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00280_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_00280_A3 { + @Weak + Cycle_a_00280_A1 a1_0; + @Weak + Cycle_a_00280_A2 a2_0; + Cycle_a_00280_A5 a5_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00280_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a2_0.a + a5_0.a; + } + } + + class Cycle_a_00280_A5 { + @Unowned + Cycle_a_00280_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00280_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00280_A6 { + @Unowned + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00280_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a3_0.a; + } + } +} + + +public class RCAnnotationMultiCycleThread { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00280 A1_Cycle_am_00280 = new ThreadRc_Cycle_am_00280(); + ThreadRc_Cycle_am_00280 A2_Cycle_am_00280 = new ThreadRc_Cycle_am_00280(); + ThreadRc_Cycle_am_00280 A3_Cycle_am_00280 = new ThreadRc_Cycle_am_00280(); + ThreadRc_Cycle_am_00280 A4_Cycle_am_00280 = new ThreadRc_Cycle_am_00280(); + ThreadRc_Cycle_am_00280 A5_Cycle_am_00280 = new ThreadRc_Cycle_am_00280(); + ThreadRc_Cycle_am_00280 A6_Cycle_am_00280 = new ThreadRc_Cycle_am_00280(); + + A1_Cycle_am_00280.start(); + A2_Cycle_am_00280.start(); + A3_Cycle_am_00280.start(); + A4_Cycle_am_00280.start(); + A5_Cycle_am_00280.start(); + A6_Cycle_am_00280.start(); + + try { + A1_Cycle_am_00280.join(); + A2_Cycle_am_00280.join(); + A3_Cycle_am_00280.join(); + A4_Cycle_am_00280.join(); + A5_Cycle_am_00280.join(); + A6_Cycle_am_00280.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00280.check() && A2_Cycle_am_00280.check() && A3_Cycle_am_00280.check() && A4_Cycle_am_00280.check() && A5_Cycle_am_00280.check() && A6_Cycle_am_00280.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0405-rc-Annotation-RCAnnotationMultiCycleThread2/RCAnnotationMultiCycleThread2.java b/test/testsuite/ouroboros/rc_test/RC0405-rc-Annotation-RCAnnotationMultiCycleThread2/RCAnnotationMultiCycleThread2.java new file mode 100755 index 0000000000000000000000000000000000000000..7d7e9a75f0bedbb468c9599b2d352d22acba7060 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0405-rc-Annotation-RCAnnotationMultiCycleThread2/RCAnnotationMultiCycleThread2.java @@ -0,0 +1,316 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/RCAnnotationMultiCycleThread2.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change RCAnnotationMultiCycle2 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect: ExpectResult\n + *- @Priority: High + *- @Source: RCAnnotationMultiCycleThread2.java + *- @ExecuteClass: RCAnnotationMultiCycleThread2 + *- @ExecuteArgs: + *- @Remark:Owner Zhang Wenlong 00292413 + */ + +import com.huawei.ark.annotation.Unowned; +import com.huawei.ark.annotation.Weak; + +class ThreadRc_Cycle_am_00370 extends Thread { + private boolean checkout; + + public void run() { + Cycle_a_00370_A1 a1_main = new Cycle_a_00370_A1("a1_main"); + Cycle_a_00370_A4 a4_main = new Cycle_a_00370_A4("a4_main"); + Cycle_a_00370_A6 a6_main = new Cycle_a_00370_A6("a6_main"); + Cycle_a_00370_A9 a9_main = new Cycle_a_00370_A9("a9_main"); + a1_main.a2_0 = new Cycle_a_00370_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00370_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00370_A5("a5_0"); + a1_main.a2_0.a3_0.a10_0 = new Cycle_a_00370_A10("a10_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00370_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00370_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a10_0.a9_0 = a9_main; + a9_main.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + + + a1_main.add(); + a4_main.add(); + a6_main.add(); + a9_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a10_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + + int result = a1_main.sum + a4_main.sum + a6_main.sum + a9_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.sum + a1_main.a2_0.a3_0.a5_0.a8_0.sum + a1_main.a2_0.a3_0.a10_0.sum; + + if (result == 2623) + checkout = true; + //System.out.println(checkout); + } + + public boolean check() { + return checkout; + } + + class Cycle_a_00370_A1 { + Cycle_a_00370_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00370_A2 { + Cycle_a_00370_A3 a3_0; + @Unowned + Cycle_a_00370_A4 a4_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + + class Cycle_a_00370_A3 { + @Weak + Cycle_a_00370_A1 a1_0; + Cycle_a_00370_A5 a5_0; + Cycle_a_00370_A10 a10_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a10_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a5_0.a + a10_0.a; + } + } + + class Cycle_a_00370_A4 { + @Unowned + Cycle_a_00370_A1 a1_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + a1_0.a; + } + } + + class Cycle_a_00370_A5 { + @Unowned + Cycle_a_00370_A6 a6_0; + Cycle_a_00370_A8 a8_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + + class Cycle_a_00370_A6 { + @Unowned + Cycle_a_00370_A1 a1_0; + @Unowned + Cycle_a_00370_A3 a3_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + + class Cycle_a_00370_A7 { + @Unowned + Cycle_a_00370_A2 a2_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + + void add() { + sum = a + a2_0.a; + } + } + + class Cycle_a_00370_A8 { + Cycle_a_00370_A7 a7_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + + void add() { + sum = a + a7_0.a; + } + } + + class Cycle_a_00370_A9 { + @Unowned + Cycle_a_00370_A6 a6_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A9(String strObjectName) { + a6_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + + void add() { + sum = a + a6_0.a; + } + } + + class Cycle_a_00370_A10 { + @Unowned + Cycle_a_00370_A9 a9_0; + int a; + int sum; + String strObjectName; + + Cycle_a_00370_A10(String strObjectName) { + a9_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + + void add() { + sum = a + a9_0.a; + } + } +} + + +public class RCAnnotationMultiCycleThread2 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00370 A1_Cycle_am_00370 = new ThreadRc_Cycle_am_00370(); + ThreadRc_Cycle_am_00370 A2_Cycle_am_00370 = new ThreadRc_Cycle_am_00370(); + ThreadRc_Cycle_am_00370 A3_Cycle_am_00370 = new ThreadRc_Cycle_am_00370(); + ThreadRc_Cycle_am_00370 A4_Cycle_am_00370 = new ThreadRc_Cycle_am_00370(); + ThreadRc_Cycle_am_00370 A5_Cycle_am_00370 = new ThreadRc_Cycle_am_00370(); + ThreadRc_Cycle_am_00370 A6_Cycle_am_00370 = new ThreadRc_Cycle_am_00370(); + + A1_Cycle_am_00370.start(); + A2_Cycle_am_00370.start(); + A3_Cycle_am_00370.start(); + A4_Cycle_am_00370.start(); + A5_Cycle_am_00370.start(); + A6_Cycle_am_00370.start(); + + try { + A1_Cycle_am_00370.join(); + A2_Cycle_am_00370.join(); + A3_Cycle_am_00370.join(); + A4_Cycle_am_00370.join(); + A5_Cycle_am_00370.join(); + A6_Cycle_am_00370.join(); + + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00370.check() && A2_Cycle_am_00370.check() && A3_Cycle_am_00370.check() && A4_Cycle_am_00370.check() && A5_Cycle_am_00370.check() && A6_Cycle_am_00370.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0406-rc-DTS-stringIntern/stringIntern.java b/test/testsuite/ouroboros/rc_test/RC0406-rc-DTS-stringIntern/stringIntern.java new file mode 100755 index 0000000000000000000000000000000000000000..398fc0ff17328ada5b8e1e0557c5ebaa23b7be40 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0406-rc-DTS-stringIntern/stringIntern.java @@ -0,0 +1,102 @@ +/* + *- @TestCaseID:String_intern.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:test Intern() API of String + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: stringIntern.java + *- @ExecuteClass: stringIntern + *- @ExecuteArgs: + + * + */ +public class stringIntern { + private static int check = 0; + + public static void main(String[] args) { + String s1 = new String("aaa"); + String s2 = "aaa"; + if (s1 != s2) { + check++; //=1 + } + + s1 = new String("bbb").intern(); + s2 = "bbb"; + if (s1 == s2) { + check++; //=2 + } + + s1 = "ccc"; + s2 = "ccc"; + if (s1 == s2) { + check++; //=3 + } + + s1 = new String("ddd").intern(); + s2 = new String("ddd").intern(); + if (s1 == s2) { + check++; //=4 + } + + s1 = "ab" + "cd"; + s2 = "abcd"; + if (s1 == s2) { + check++; //=5 + } + + String temp = "hh"; + s1 = "a" + temp; + s2 = "ahh"; + if (s1 != s2) { + check++; //=6 + } + + temp = "hh".intern(); + s1 = "a" + temp; + s2 = "ahh"; + if (s1 != s2) { + check++; //=7 + } + + temp = "hh".intern(); + s1 = ("a" + temp).intern(); + s2 = "ahh"; + if (s1 == s2) { + check++; //=8 + } + + s1 = new String("1"); + s1.intern(); + s2 = "1"; + if (s1 != s2) { + check++; //=9 + } + + String s3 = new String("1") + new String("1"); + s3.intern(); + String s4 = "11"; + if (s1 != s2) { + check++; //=10 + } + + s3 = new String("2") + new String("2"); + s4 = "22"; + s3.intern(); + if (s1 != s2) { + check++; //=11 + } + if (check == 11) { + System.out.println("ExpectResult"); + } + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0407-rc-DTS-stackAllocField/stackAllocField.java b/test/testsuite/ouroboros/rc_test/RC0407-rc-DTS-stackAllocField/stackAllocField.java new file mode 100755 index 0000000000000000000000000000000000000000..aaf4fd2793b68bc1e0b9a00e45e2ed4aaf2195a5 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0407-rc-DTS-stackAllocField/stackAllocField.java @@ -0,0 +1,60 @@ +/* + *- @TestCaseID:stackAllocField.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:test Intern() API of String + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: stackAllocField.java + *- @ExecuteClass: stackAllocField + *- @ExecuteArgs: + + * + */ +public class stackAllocField { + private static A a1 = new A(); + private static A a2 = new A(); + private static A a3 = new A(); + private static A a4 = new A(); + + public static void main(String[] args) { + wrapper(a1, a2, a3, a4); + } + + public static void wrapper(A tempa1, A tempa2, A tempa3, A tempa4) { + A testa1 = new A(); + testa1.a = tempa1; + A testa2 = new A(); + testa2.a = tempa2; + A testa3 = new A(); + testa3.a = tempa3; + A testa4 = new A(); + testa4.a = tempa4; + tempa1 = null; + tempa2 = null; + tempa3 = null; + tempa4 = null; + a1 = null; + a2 = null; + a3 = null; + a4 = null; + for (int i = 0; i <= 50; i++) { + Runtime.getRuntime().gc(); + } + if (testa1.a != null && testa2.a != null && testa3.a != null && testa4.a != null) { + System.out.println("ExpectResult"); + } + } + + private static class A { + A a; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0408-rc-DTS-OOMtest/OOMtest.java b/test/testsuite/ouroboros/rc_test/RC0408-rc-DTS-OOMtest/OOMtest.java new file mode 100755 index 0000000000000000000000000000000000000000..ab33e898634d40faecf40e1b86a971702d2b7575 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0408-rc-DTS-OOMtest/OOMtest.java @@ -0,0 +1,52 @@ +/* + *- @TestCaseID:OOMtest.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: OOMtest.java + *- @ExecuteClass: OOMtest + *- @ExecuteArgs: + * + */ + +import java.util.ArrayList; + +public class OOMtest { + private static ArrayList store; + + private static int alloc_test() { + int sum = 0; + store = new ArrayList(); + byte[] temp; + + for (int i = 1024 * 1024 * 10; i <= 1024 * 1024 * 10; ) { + temp = new byte[i]; + store.add(temp); + sum += store.size(); + } + return sum; + } + + public static void main(String[] args) { + try { + int result = alloc_test(); + } catch (OutOfMemoryError o) { + System.out.println("ExpectResult"); + } + if (store == null) { + System.out.println("Error"); + } else { + System.out.println("ExpectResult"); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0409-rc-DTS-Ex_eight_arguments/Ex_eight_arguments.java b/test/testsuite/ouroboros/rc_test/RC0409-rc-DTS-Ex_eight_arguments/Ex_eight_arguments.java new file mode 100755 index 0000000000000000000000000000000000000000..fe33c336ede7ce4e5579f238e1bdef049b4cbbe8 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0409-rc-DTS-Ex_eight_arguments/Ex_eight_arguments.java @@ -0,0 +1,267 @@ +/* + *- @TestCaseID:Ex_eight_arguments_static.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: more than 8 arguments method test, include static ,no static, has return value, no return, throw + * Exception,not throw Exception + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: Ex_eight_arguments.java + *- @ExecuteClass: Ex_eight_arguments + *- @ExecuteArgs: + *- @Remark:Owner Zhang Wenlong 00292413 + */ + +import java.lang.reflect.Array; + +public class Ex_eight_arguments { + static int check_count = 0; + + public static void main(String[] args) { + int first = 1988; + byte second = 2; + char third = 'g'; + long four = 19881110; + float five = 601.5f; + double six = 60.15f; + String seven = "huawei"; + boolean eight = true; + Object nine = new String("CC is a cat"); + int[] ten = {2012, 2020, 2019, 2040, 3301}; + Ex_eight_arguments Test = new Ex_eight_arguments(); + + //test static method no return no exception + test01(first, second, third, four, five, six, seven, eight, nine, ten); + + //test no static method no return no exception + Test.test02(first, second, third, four, five, six, seven, eight, nine, ten); + + //test no static method return value no exception + first = Test.test03(first, second, third, four, five, six, seven, eight, nine, ten); + + //test no static method no return throws exception + try { + Test.test04(first, second, third, four, five, six, seven, eight, nine, ten); + System.out.println("ErrorResult in test04 not catch Exception"); + } catch (ArrayIndexOutOfBoundsException e) { + check_count++; + } + + //test static method return value no exception + seven = test05(first, second, third, four, five, six, seven, eight, nine, ten); + + //test static method no return value throws exception + try { + test06(first, second, third, four, five, six, seven, eight, nine, ten); + System.out.println("ErrorResult in test06 not catch Exception"); + } catch (IllegalArgumentException e) { + check_count++; + } + + //test no static method return value throws exception + try { + boolean result7 = Test.test07(first, second, third, four, five, six, seven, eight, nine, ten); + System.out.println("ErrorResult in test07 not catch Exception"); + } catch (ArithmeticException e) { + check_count++; + } + + //test static method return value throws exception + try { + int[] result8 = test08(first, second, third, four, five, six, seven, eight, nine, ten); + System.out.println("ErrorResult in test08 not catch Exception"); + } catch (NegativeArraySizeException e) { + check_count++; + } + + //Result judgment + if (check_count == 12) + System.out.println("ExpectResult"); + //System.out.println(check_count); + } + + private static void test01(int first, byte second, char third, long four, float five, double six, String seven, + boolean eight, Object nine, int[] ten) { + /*test static method no return no exception*/ + first++; + second = 56; + third = (char) second; + four = (long) third; + five = (float) four; + six = (double) five; + seven = "fei fei is not a pig"; + eight = false; + nine = (Object) eight; + ten = ten.clone(); + if (first == 1989 && second == 56 && third == '8' && four == 56 && five == 56f && six == 56f && seven == "fei fei is not a pig" + && eight == false && nine == (Object) false && ten[4] == 3301) + check_count++; + else + System.out.println("ErrorResult in test01"); + } + + private static String test05(int first, byte second, char third, long four, float five, double six, String seven, + Boolean eight, Object nine, int[] ten) { + /*test static method return value no exception*/ + first++; + second = 56; + third = (char) second; + four = (long) third; + five = (float) four; + six = (double) five; + seven = "fei fei is not a pig"; + eight = false; + nine = (Object) eight; + ten = ten.clone(); + + if (first == 1990 && second == 56 && third == '8' && four == 56 && five == 56f && six == 56f && seven == "fei fei is not a pig" + && eight == false && nine == (Object) false && ten[4] == 3301) + check_count++; + else + System.out.println("ErrorResult in test05"); + return new String("test05 is End"); + } + + private static void test06(int first, byte second, char third, long four, float five, double six, String seven, + Boolean eight, Object nine, int[] ten) throws IllegalArgumentException { + /*test static method no return value throws exception*/ + first++; + second = 56; + third = (char) second; + four = (long) third; + five = (float) four; + six = (double) five; + seven = "fei fei is not a pig"; + eight = false; + nine = (Object) eight; + ten = ten.clone(); + int[][] test_ten = {ten, ten, ten, ten, ten, ten}; + + if (first == 1990 && second == 56 && third == '8' && four == 56 && five == 56f && six == 56f && seven == "fei fei is not a pig" + && eight == false && nine == (Object) false && ten[4] == 3301) + check_count++; + else + System.out.println("ErrorResult in test06"); + Array.getInt(test_ten, 5); + } + + private static int[] test08(int first, byte second, char third, long four, float five, double six, String seven, + Boolean eight, Object nine, int[] ten) throws NegativeArraySizeException { + /*test static method return value throws exception*/ + first++; + second = 56; + third = (char) second; + four = (long) third; + five = (float) four; + six = (double) five; + seven = "fei fei is not a pig"; + eight = false; + nine = (Object) eight; + ten = ten.clone(); + int[][] test_ten = {ten, ten, ten, ten, ten, ten}; + + if (first == 1990 && second == 56 && third == '8' && four == 56 && five == 56f && six == 56f && seven == "fei fei is not a pig" + && eight == false && nine == (Object) false && ten[4] == 3301) + check_count++; + else + System.out.println("ErrorResult in test08"); + int[] chck = new int[-1]; + return chck; + } + + private void test02(int first, byte second, char third, long four, float five, double six, String seven, + Boolean eight, Object nine, int[] ten) { + /*test no static method no return no exception*/ + first++; + second = 56; + third = (char) second; + four = (long) third; + five = (float) four; + six = (double) five; + seven = "fei fei is not a pig"; + eight = false; + nine = (Object) eight; + ten = ten.clone(); + if (first == 1989 && second == 56 && third == '8' && four == 56 && five == 56f && six == 56f && seven == "fei fei is not a pig" + && eight == false && nine == (Object) false && ten[4] == 3301) + check_count++; + else + System.out.println("ErrorResult in test02"); + } + + private int test03(int first, byte second, char third, long four, float five, double six, String seven, + Boolean eight, Object nine, int[] ten) { + /*test no static method return value no exception*/ + first++; + second = 56; + third = (char) second; + four = (long) third; + five = (float) four; + six = (double) five; + seven = "fei fei is not a pig"; + eight = false; + nine = (Object) eight; + ten = ten.clone(); + if (first == 1989 && second == 56 && third == '8' && four == 56 && five == 56f && six == 56f && seven == "fei fei is not a pig" + && eight == false && nine == (Object) false && ten[4] == 3301) + check_count++; + else + System.out.println("ErrorResult in test03"); + return first; + } + + private void test04(int first, byte second, char third, long four, float five, double six, String seven, + Boolean eight, Object nine, int[] ten) throws ArrayIndexOutOfBoundsException { + /*test no static method no return throws exception*/ + first++; + second = 56; + third = (char) second; + four = (long) third; + five = (float) four; + six = (double) five; + seven = "fei fei is not a pig"; + eight = false; + nine = (Object) eight; + ten = ten.clone(); + + if (first == 1990 && second == 56 && third == '8' && four == 56 && five == 56f && six == 56f && seven == "fei fei is not a pig" + && eight == false && nine == (Object) false && ten[4] == 3301) + check_count++; + else + System.out.println("ErrorResult in test04"); + ten[5] = 1988; + } + + private boolean test07(int first, byte second, char third, long four, float five, double six, String seven, + Boolean eight, Object nine, int[] ten) throws ArithmeticException { + /*test no static method return value throws exception*/ + first++; + second = 56; + third = (char) second; + four = (long) third; + five = (float) four; + six = (double) five; + seven = "fei fei is not a pig"; + eight = false; + nine = (Object) eight; + ten = ten.clone(); + int[][] test_ten = {ten, ten, ten, ten, ten, ten}; + + if (first == 1990 && second == 56 && third == '8' && four == 56 && five == 56f && six == 56f && seven == "fei fei is not a pig" + && eight == false && nine == (Object) false && ten[4] == 3301) + check_count++; + else + System.out.println("ErrorResult in test07"); + + first = first / 0; + return true; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0410-rc-Memory-stressTestCase29/Memory_stressTestCase29.java b/test/testsuite/ouroboros/rc_test/RC0410-rc-Memory-stressTestCase29/Memory_stressTestCase29.java new file mode 100755 index 0000000000000000000000000000000000000000..d5a8f65c783c9fd8268d48191784434969fc6888 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0410-rc-Memory-stressTestCase29/Memory_stressTestCase29.java @@ -0,0 +1,172 @@ +/* + *- @TestCaseID:rc/stress/Memory_stressTestCase29.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect: + *- @Priority: High + *- @Source: Memory_stressTestCase29.java + *- @ExecuteClass: Memory_stressTestCase29 + *- @ExecuteArgs: + *- @Remark: + *- @Author:从压力测试case中拆解 liuweiqing l00481345 + */ + + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + + +import sun.misc.Cleaner; + +public class Memory_stressTestCase29 { + private static final int INIT_DEFAULT_THREAD_NUM = 100; + private static int DEFAULT_THREAD_NUM = INIT_DEFAULT_THREAD_NUM; + static List> mAllThread = new ArrayList>(); + + public static void main(String[] args) { + testCase29(); + Runtime.getRuntime().gc(); + testCase29(); + Runtime.getRuntime().gc(); + testCase29(); + Runtime.getRuntime().gc(); + testCase29(); + Runtime.getRuntime().gc(); + testCase29(); + System.out.println("ExpectResult"); + } + + public static void testCase29() { + ArrayList list = new ArrayList<>(); + for (int i = 0; i < (DEFAULT_THREAD_NUM / 10); i++) { + list.add(new StopAbleThread(() -> { + ArrayList units = new ArrayList<>(); + Random r = new Random(); + for (int j = 0; j < 100; j++) { + units.add(new Memory_stressTestCase29.AllocUnitwithVerifyCleaner(r.nextInt(512))); + } + trySleep(r.nextInt(500)); + for (Memory_stressTestCase29.AllocUnitwithVerifyCleaner unit : units) { + unit.CanbeFree(); + } + units.clear(); + }, "testCase29_alloc_" + (i + 1))); + } + startAllThread(list); + waitAllThreadFinish(list); + } + + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + removeDeadThread(s); + } + } + } + + public static void removeDeadThread(Thread t) { + if (t == null) { + return; + } + if (!t.isAlive()) { + synchronized (mAllThread) { + mAllThread.remove(t); + } + } + } + + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + + public static class StopAbleThread extends Thread { + public static boolean mRuning = true; + static List> mAllThread = new ArrayList>(); + + public StopAbleThread(Runnable r, String name) { + super(r, name); + + + } + } + + public static class AllocUnit { + public byte unit[]; + + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + + public static class AllocUnitwithVerifyCleaner extends AllocUnit { + static final int FLAG_INUSE = 0x112233; + static final int FLAG_CANBECLEAN = 0xddee; + static final int FLAG_CLEARED = 0xaabb; + public CleanerStatus status; + + public AllocUnitwithVerifyCleaner(int arrayLength) { + super(arrayLength); + status = new CleanerStatus(); + this.cleaner = Cleaner.create(this, new TestCleaner(status)); + } + + private final Cleaner cleaner; + + private static class CleanerStatus { + public int status; + + CleanerStatus() { + status = FLAG_INUSE; + } + } + + public void CanbeFree() { + if (this.status.status != FLAG_INUSE) { + throw new NullPointerException(); + } + this.status.status = FLAG_CANBECLEAN; + } + + private static class TestCleaner implements Runnable { + public CleanerStatus status; + + public TestCleaner(CleanerStatus status) { + this.status = status; + } + + public void run() { + if (this.status.status != FLAG_CANBECLEAN) { + } + this.status.status = FLAG_CLEARED; + } + } + + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0417-rc-Annotation-RCUnownedRefTest3/RCUnownedRefTest3.java b/test/testsuite/ouroboros/rc_test/RC0417-rc-Annotation-RCUnownedRefTest3/RCUnownedRefTest3.java new file mode 100755 index 0000000000000000000000000000000000000000..e2a9538faf7d54ac502abc04763cbaeee7681e57 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0417-rc-Annotation-RCUnownedRefTest3/RCUnownedRefTest3.java @@ -0,0 +1,77 @@ +/* + *- @TestCaseID:maple/runtime/rc/annotation/RCUnownedTest3 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:在匿名类和lambda中使用@Unowned,没有环泄露 + *- @Condition:no + * -#c1: + *- @Brief:functionTest + * -#step1: + * 在匿名类和lambda中使用@Unowned,没有环泄露 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCUnownedRefTest3.java + *- @ExecuteClass: RCUnownedRefTest3 + *- @ExecuteArgs: + *- @Remark: + *- @Author:liuweiqing l00481345 + */ +import com.huawei.ark.annotation.Unowned; + +import java.util.LinkedList; +import java.util.List; + +public class RCUnownedRefTest3 { + public static void main(String[] args) { + UnownedAnnoymous unownedAnnoymous = new UnownedAnnoymous(); + unownedAnnoymous.anonymousCapture("test"); + UnownedLambda unownedLambda = new UnownedLambda(); + List list = new LinkedList<>(); + list.add("test"); + unownedLambda.lambdaCapture(list, "test"); + if (unownedAnnoymous.checkAnnoy == true && unownedLambda.checkLambda == true) { + System.out.println("ExpectResult"); + } + } +} + +class UnownedLambda { + String name; + static boolean checkLambda = false; + + void lambdaCapture(List list, String suffix) { + final @Unowned String capSuffix = suffix; + final @Unowned UnownedLambda self = this; + list.forEach((str) -> { + if ((self.name + str + capSuffix).equals("nulltesttest")) { + checkLambda = true; + } + }); + } +} + +class UnownedAnnoymous { + String name; + static boolean checkAnnoy = false; + + void anonymousCapture(String suffix) { + final @Unowned String capSuffix = suffix; + Runnable r = new Runnable() { + @Override + public void run() { + if ((name + capSuffix).equals("nulltest")) { + checkAnnoy = true; + } + } + }; + r.run(); + } +} + + + + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0418-rc-Annotation-RCUnownedRefThreadTest3/RCUnownedRefThreadTest3.java b/test/testsuite/ouroboros/rc_test/RC0418-rc-Annotation-RCUnownedRefThreadTest3/RCUnownedRefThreadTest3.java new file mode 100755 index 0000000000000000000000000000000000000000..8c7660329466419be9440d18124480bacaebfad8 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0418-rc-Annotation-RCUnownedRefThreadTest3/RCUnownedRefThreadTest3.java @@ -0,0 +1,142 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/RCUnownedRefThreadTest3.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change CaseRC0417 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCUnownedRefThreadTest3.java + *- @ExecuteClass: RCUnownedRefThreadTest3 + *- @ExecuteArgs: + *- @Remark:Owner liuweiqing 00481345 + */ + +import com.huawei.ark.annotation.Unowned; + +import java.util.LinkedList; +import java.util.List; + +class RCUnownedRefTest3 extends Thread { + private boolean checkout; + + public void run() { + UnownedAnnoymous unownedAnnoymous = new UnownedAnnoymous(); + unownedAnnoymous.anonymousCapture("test"); + UnownedLambda unownedLambda = new UnownedLambda(); + List list = new LinkedList<>(); + list.add("test"); + unownedLambda.lambdaCapture(list, "test"); + + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + if (unownedAnnoymous.checkAnnoy == true && unownedLambda.checkLambda == true) { + checkout = true; + } else { + System.out.println("unownedAnnoymous.checkAnnoy:" + unownedAnnoymous.checkAnnoy); + System.out.println("unownedLambda.checkLambda:" + unownedLambda.checkLambda); + System.out.println("555555555555555"); + checkout = false; + } + } + + public boolean check() { + return checkout; + } +} + +class UnownedLambda { + String name; + static boolean checkLambda; + + void lambdaCapture(List list, String suffix) { + checkLambda = false; + final String capSuffix = suffix; + final UnownedLambda self = this; + list.forEach((str) -> { + if ((self.name + str + capSuffix).equals("nulltesttest")) { + checkLambda = true; + } else { + System.out.println("self.name + str + capSuffix:" + self.name + " " + str + " " + capSuffix); + } + }); + } +} + +class UnownedAnnoymous { + String name; + static boolean checkAnnoy; + + void anonymousCapture(String suffix) { + checkAnnoy = false; + final @Unowned String capSuffix = suffix; + Runnable r = new Runnable() { + @Override + public void run() { + if ((name + capSuffix).equals("nulltest")) { + checkAnnoy = true; + } else { + System.out.println("name + capSuffix:" + name + " " + capSuffix); + } + } + }; + r.run(); + } +} + +public class RCUnownedRefThreadTest3 { + + public static void main (String[] args) throws InterruptedException { + rc_testcase_main_wrapper(); + } + + private static void rc_testcase_main_wrapper() throws InterruptedException { + RCUnownedRefTest3 rcTest1 = new RCUnownedRefTest3(); + RCUnownedRefTest3 rcTest2 = new RCUnownedRefTest3(); + RCUnownedRefTest3 rcTest3 = new RCUnownedRefTest3(); + RCUnownedRefTest3 rcTest4 = new RCUnownedRefTest3(); + RCUnownedRefTest3 rcTest5 = new RCUnownedRefTest3(); + RCUnownedRefTest3 rcTest6 = new RCUnownedRefTest3(); + + rcTest1.start(); + rcTest2.start(); + rcTest3.start(); + rcTest4.start(); + rcTest5.start(); + rcTest6.start(); + + try { + rcTest1.join(); + rcTest2.join(); + rcTest3.join(); + rcTest4.join(); + rcTest5.join(); + rcTest6.join(); + + } catch (InterruptedException e) { + } + Thread.sleep(2000); + if (rcTest1.check() && rcTest2.check() && rcTest3.check() && rcTest4.check() && rcTest5.check() && rcTest6.check()) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("rcTest1.check():" + rcTest1.check()); + System.out.println("rcTest2.check():" + rcTest2.check()); + System.out.println("rcTest3.check():" + rcTest3.check()); + System.out.println("rcTest4.check():" + rcTest4.check()); + System.out.println("rcTest5.check():" + rcTest5.check()); + System.out.println("rcTest6.check():" + rcTest6.check()); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0419-rc-Annotation-RCUnownedLocalTest/RCUnownedLocalTest.java b/test/testsuite/ouroboros/rc_test/RC0419-rc-Annotation-RCUnownedLocalTest/RCUnownedLocalTest.java new file mode 100755 index 0000000000000000000000000000000000000000..3cb4759963a4df06ac1374498388edcdf91590ef --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0419-rc-Annotation-RCUnownedLocalTest/RCUnownedLocalTest.java @@ -0,0 +1,57 @@ +/* + *- @TestCaseID:maple/runtime/rc/annotation/RCUnownedLocalTest + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:方法中添加@UnownedLocal,没有环泄露 + *- @Condition:no + * -#c1: + *- @Brief:functionTest + * -#step1: + * 方法中添加@UnownedLocal,没有环泄露 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCUnownedLocalTest.java + *- @ExecuteClass: RCUnownedLocalTest + *- @ExecuteArgs: + *- @Remark: + *- @Author:liuweiqing l00481345 + */ + +import com.huawei.ark.annotation.UnownedLocal; + +import java.util.LinkedList; +import java.util.List; + +public class RCUnownedLocalTest { + static Integer a = new Integer(1); + static Object[] arr = new Object[]{1, 2, 3}; + + @UnownedLocal + static int method(Integer a, Object[] arr) { + int check = 0; + Integer c = a + a; + if (c == 2) { + check++; + } else { + check--; + } + for (Object array : arr) { + //System.out.println(array); + check++; + } + return check; + } + + public static void main(String[] args) { + int result = method(a, arr); + if (result == 4) { + System.out.println("ExpectResult"); + } + } + +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0420-rc-Annotation-RCUnownedLocalThreadTest/RCUnownedLocalThreadTest.java b/test/testsuite/ouroboros/rc_test/RC0420-rc-Annotation-RCUnownedLocalThreadTest/RCUnownedLocalThreadTest.java new file mode 100755 index 0000000000000000000000000000000000000000..be8dbfc573312fac4facf9d01aef3da57b1cad5f --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0420-rc-Annotation-RCUnownedLocalThreadTest/RCUnownedLocalThreadTest.java @@ -0,0 +1,98 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/RC_Thread01/RCUnownedLocalThreadTest.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Change CaseRC0419 to Multi thread testcase. + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCUnownedLocalThreadTest.java + *- @ExecuteClass: RCUnownedLocalThreadTest + *- @ExecuteArgs: + *- @Remark:Owner liuweiqing 00481345 + */ + +import com.huawei.ark.annotation.*; + +import java.util.LinkedList; +import java.util.List; + +class RCUnownedLocalTest extends Thread { + private boolean checkout; + + Integer a = new Integer(1); + Object[] arr = new Object[]{1, 2, 3}; + + @UnownedLocal + int method(Integer a, Object[] arr) { + int check = 0; + Integer c = a + a; + if (c == 2) { + check++; + } else { + check--; + } + for (Object array : arr) { + //System.out.println(array); + check++; + } + return check; + } + + public void run() { + int result = method(a, arr); + if (result == 4) { + checkout = true; + } else { + checkout = false; + System.out.println("result:" + result); + } + } + + public boolean check() { + return checkout; + } +} + +public class RCUnownedLocalThreadTest { + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + + private static void rc_testcase_main_wrapper() { + RCUnownedLocalTest rcTest1 = new RCUnownedLocalTest(); + RCUnownedLocalTest rcTest2 = new RCUnownedLocalTest(); + RCUnownedLocalTest rcTest3 = new RCUnownedLocalTest(); + RCUnownedLocalTest rcTest4 = new RCUnownedLocalTest(); + RCUnownedLocalTest rcTest5 = new RCUnownedLocalTest(); + RCUnownedLocalTest rcTest6 = new RCUnownedLocalTest(); + + rcTest1.start(); + rcTest2.start(); + rcTest3.start(); + rcTest4.start(); + rcTest5.start(); + rcTest6.start(); + + try { + rcTest1.join(); + rcTest2.join(); + rcTest3.join(); + rcTest4.join(); + rcTest5.join(); + rcTest6.join(); + + } catch (InterruptedException e) { + } + if (rcTest1.check() && rcTest2.check() && rcTest3.check() && rcTest4.check() && rcTest5.check() && rcTest6.check()) + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0421-rc-Annotation-RCUnownedOuterTest/RCUnownedOuterTest.java b/test/testsuite/ouroboros/rc_test/RC0421-rc-Annotation-RCUnownedOuterTest/RCUnownedOuterTest.java new file mode 100755 index 0000000000000000000000000000000000000000..50ec5a0fd93700a12609a37ece2dee138448715f --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0421-rc-Annotation-RCUnownedOuterTest/RCUnownedOuterTest.java @@ -0,0 +1,91 @@ +/* + *- @TestCaseID:maple/runtime/rc/annotation/RCUnownedOuterTest + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:在内部类和内部匿名类添加@UnownedOuter,没有环泄露 + *- @Condition:no + * -#c1: + *- @Brief:functionTest + * -#step1: + * 在内部匿名类和内部类添加@UnownedOuter,没有环泄露 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCUnownedOuterTest.java + *- @ExecuteClass: RCUnownedOuterTest + *- @ExecuteArgs: + *- @Remark: + *- @Author:liuweiqing l00481345 + */ + +import com.huawei.ark.annotation.UnownedOuter; + +import java.util.LinkedList; +import java.util.List; + +public class RCUnownedOuterTest { + + + public static void main(String[] args) { + UnownedAnnoymous unownedAnnoymous = new UnownedAnnoymous(); + unownedAnnoymous.anonymousCapture(); + + UnownedInner unownedInner = new UnownedInner(); + unownedInner.method(); + UnownedInner.InnerClass innerClass = unownedInner.new InnerClass(); + innerClass.myName(); + if (unownedAnnoymous.checkAnnoy == 1 && unownedInner.checkInner == 1) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("unownedAnnoymous.checkAnnoy:" + unownedAnnoymous.checkAnnoy); + System.out.println("unownedInner.checkInner:" + unownedInner.checkInner); + } + } + +} + +class UnownedInner { + String name = "test"; + int checkInner = 0; + InnerClass innerClass; + + void method() { + innerClass = new InnerClass(); + } + + @UnownedOuter + class InnerClass { + void myName() { + checkInner = 0; + String myname; + myname = name + name; + if (myname.equals("testtest")) { + checkInner++; + } + } + } +} + +class UnownedAnnoymous { + String name = "test"; + static int checkAnnoy; + + void anonymousCapture() { + Runnable r = new Runnable() { + @UnownedOuter + @Override + public void run() { + checkAnnoy = 0; + String myName = name + name; + if (myName.equals("testtest")) { + checkAnnoy++; + } + } + }; + r.run(); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0431-rc-SoftRef-SoftRefTest/SoftRefTest.java b/test/testsuite/ouroboros/rc_test/RC0431-rc-SoftRef-SoftRefTest/SoftRefTest.java new file mode 100755 index 0000000000000000000000000000000000000000..966dc76ad9e488c19e5264652ea0e755bd62b1b7 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0431-rc-SoftRef-SoftRefTest/SoftRefTest.java @@ -0,0 +1,74 @@ +/* + *- @TestCaseID:SoftRefTest.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: 测试SoftRefernece的基本内存管理方式:在正常情况下,SoftReference对象不会被回收掉 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1:创建一个SoftReference对象,并将其放到ReferneceQueue中,该对象不应该被释放; + * -#step2:封装一个函数生成一下局部的SoftReference对象 + * -#step3:再次确认该对象不应该被释放,且它所在的ReferenceQueue中没有即将回收的Reference对象 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: SoftRefTest.java + *- @ExecuteClass: SoftRefTest + *- @ExecuteArgs: + *- @Remark: + * + */ + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.SoftReference; + +public class SoftRefTest { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static int a = 100; + + static void setSoftReference() { + rp = new SoftReference(new Object(), rq); + if (rp.get() == null) { + System.out.println("Error Result when first check "); + a++; + } + } + + public static void main(String[] args) throws Exception { + setSoftReference(); + new Thread(new TriggerRP()).start(); + + if (rp.get() == null) { + System.out.println("Error Result when second check "); + a++; + } + Reference r = rq.poll(); + if (r != null) { + System.out.println("Error Result when checking ReferenceQueue"); + a++; + } + if (a == 100) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult finally"); + } + + } + + static class TriggerRP implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + SoftReference sr = new SoftReference(new Object()); + try { + Thread.sleep(50); + } catch (Exception e) { + } + } + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0432-rc-SoftRef-SoftRefTest02/SoftRefTest02.java b/test/testsuite/ouroboros/rc_test/RC0432-rc-SoftRef-SoftRefTest02/SoftRefTest02.java new file mode 100755 index 0000000000000000000000000000000000000000..56c6dfb9b76e31036d3e50dffd982d07358b9a0a --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0432-rc-SoftRef-SoftRefTest02/SoftRefTest02.java @@ -0,0 +1,64 @@ +/* + *- @TestCaseID:SoftRefTest02.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: 正常情况下通过system.gc()强制gc时,SoftReference对象不会被回收掉 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1:创建一个SoftReference对象,并将其放到ReferneceQueue中,该对象不应该被释放; + * -#step2:通过System.gc()进行强制GC + * -#step3:再次确认该对象不应该被释放,且它所在的ReferenceQueue中没有即将回收的Reference对象 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: SoftRefTest02.java + *- @ExecuteClass: SoftRefTest02 + *- @ExecuteArgs: + *- @Remark: + * + */ + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.SoftReference; + +public class SoftRefTest02 { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static int a = 100; + + static void setSoftReference() { + rp = new SoftReference(new Object(), rq); + if (rp.get() == null) { + System.out.println("Error Result when first check "); + a++; + } + } + + public static void main(String[] args) throws Exception { + setSoftReference(); + for (int i = 0; i < 3; i++) { + System.gc(); + if (rp.get() == null) { + System.out.println("Error Result when second check "); + a++; + } + } + Reference r = rq.poll(); + if (r != null) { + System.out.println("Error Result when checking ReferenceQueue"); + a++; + } + if (a == 100) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult finally"); + } + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0433-rc-SoftRef-SoftRefTest03/SoftRefTest03.java b/test/testsuite/ouroboros/rc_test/RC0433-rc-SoftRef-SoftRefTest03/SoftRefTest03.java new file mode 100755 index 0000000000000000000000000000000000000000..de62d89730090b2af071dd42731204d59c4676ec --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0433-rc-SoftRef-SoftRefTest03/SoftRefTest03.java @@ -0,0 +1,67 @@ +/* + *- @TestCaseID:SoftRefTest03.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: 内存充足的正常情况下通过Runtime.getRuntime().gc()强制gc时,SoftReference对象不会被回收掉 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1:创建一个SoftReference对象,并将其放到ReferneceQueue中,该对象不应该被释放; + * -#step2:通过Runtime.getRuntime().gc()进行强制GC + * -#step3:再次确认该对象不应该被释放,且它所在的ReferenceQueue中没有即将回收的Reference对象 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: SoftRefTest03.java + *- @ExecuteClass: SoftRefTest03 + *- @ExecuteArgs: + *- @Remark: + * + */ + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.SoftReference; + +public class SoftRefTest03 { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static int a = 100; + + static void setSoftReference() { + rp = new SoftReference(new Object(), rq); + if (rp.get() == null) { + System.out.println("Error Result when first check "); + a++; + } + } + + public static void main(String[] args) throws Exception { + setSoftReference(); + + for (int i = 0; i < 3; i++) { + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + if (rp.get() == null) { + System.out.println("Error Result when second check "); + a++; + break; //rp指向的对象不应该被释放,如果出现释放,则打印、a++;然后break跳出循环 + } + } + + Reference r = rq.poll(); //ReferenceQueue里不应该有对象,poll返回值应该是空指针 + if (r != null) { + System.out.println("Error Result when checking ReferenceQueue"); + a++; + } + if (a == 100) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult finally"); + } + + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0435-rc-SoftRef-SoftRefTest05/SoftRefTest05.java b/test/testsuite/ouroboros/rc_test/RC0435-rc-SoftRef-SoftRefTest05/SoftRefTest05.java new file mode 100755 index 0000000000000000000000000000000000000000..e66dc07c3c68107044b1e96b1861920433a1495a --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0435-rc-SoftRef-SoftRefTest05/SoftRefTest05.java @@ -0,0 +1,190 @@ +/* + *- @TestCaseID:SoftRefTest05.java + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: 环上SoftReference对象在正常情况下不会被释放 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1:创建一个对象环,由四个对象Class_A、Class_B、Class_C和Class_D组成。这四个对象都一个域,关联着一个SoftReference; + * -#step2:执行一次后,进行一遍gc,进行环的自学习; + * -#step3:再执行一次后,判断环关联的软对象不应该被释放。 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: SoftRefTest05.java + *- @ExecuteClass: SoftRefTest05 + *- @ExecuteArgs: + *- @Remark: + * + */ + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; + +public class SoftRefTest05 { + static final int TEST_NUM = 1; + static int check_count = 0; + static int allSum; + + public static void main(String[] args) { + for (int i = 0; i < TEST_NUM; i++) { + test_01(); + Runtime.getRuntime().gc(); + // resultLine = null; + test_01(); + + if (allSum == 20) { + check_count++; + System.out.println("sum is srong"); + } + + if (check_count == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println(" errorResult ----checkcount" + check_count); + } + + } + } + + private static void test_01() { + Cycle_A a1 = new Cycle_A(); + a1.cyb = new Cycle_B(); + a1.cyb.cyc = new Cycle_C(); + a1.cyb.cyc.cyd = new Cycle_D(); + a1.cyb.cyc.cyd.cya = a1; + allSum = a1.sum + a1.cyb.sum + a1.cyb.cyc.sum + a1.cyb.cyc.cyd.sum; + sleep(4000); + if ((a1.sr.get() == null) || (a1.cyb.sr.get() == null) || (a1.cyb.cyc.pr.get() == null) || (a1.cyb.cyc.cyd.str.get() == null)) { + check_count++; + } + + } + + private static void sleep(int sleepnum) { + try { + Thread.sleep(sleepnum); + } catch (InterruptedException e) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " sleep was Interrupted"); + } + } + +} + +class Cycle_A { + static StringBuffer a = new StringBuffer("ref_processor_cycle_A"); + Reference sr; + Cycle_B cyb; + int aNum; + int sum; + + Cycle_A() { + a = new StringBuffer("ref_processor_cycle_A"); + sr = new SoftReference(a); + if (sr.get() == null) { + assert false; + } + a = null; + cyb = null; + aNum = 1; + } + + int joinStr() { + try { + sum = aNum + cyb.bNum; + } catch (Exception e) { + + } + return sum; + } +} + +class Cycle_B { + static StringBuffer b = new StringBuffer("ref_processor_cycle_B"); + Reference sr; + Cycle_C cyc; + int bNum; + int sum; + + Cycle_B() { + b = new StringBuffer("ref_processor_cycle_B"); + sr = new SoftReference<>(b); + if (sr.get() == null) { + assert false; + } + b = null; + cyc = null; + bNum = 2; + } + + + int joinStr() { + try { + sum = bNum + cyc.cNum; + } catch (Exception e) { + + } + return sum; + } + + +} + +class Cycle_C { + Reference pr; + Cycle_D cyd; + StringBuffer c = new StringBuffer("ref_processor_cycle_C"); + int sum; + int cNum; + + Cycle_C() { + c = new StringBuffer("ref_processor_cycle_C"); + pr = new SoftReference<>(c); + if (pr.get() == null) { + assert false; + } + c = null; + cyd = null; + cNum = 3; + } + + int joinStr() { + try { + sum = cNum + cyd.dNum; + } catch (Exception e) { + + } + return sum; + } +} + +class Cycle_D { + Reference str; + Cycle_A cya; + StringBuffer d = new StringBuffer("ref_processor_cycle_D"); + int dNum; + int sum; + + + Cycle_D() { + d = new StringBuffer("ref_processor_cycle_D"); + str = new SoftReference(d); + d = null; + cya = null; + dNum = 4; + + } + + + int joinStr() { + try { + int sum = dNum + cya.aNum; + } catch (Exception e) { + } + return sum; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0440-rc-RCHeader-RCHeaderTest04/RCHeaderTest04.java b/test/testsuite/ouroboros/rc_test/RC0440-rc-RCHeader-RCHeaderTest04/RCHeaderTest04.java new file mode 100755 index 0000000000000000000000000000000000000000..4e16bacf16693cf050867f4da7de96115cd3d656 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0440-rc-RCHeader-RCHeaderTest04/RCHeaderTest04.java @@ -0,0 +1,71 @@ +/* + *- @TestCaseID:RCHeaderTest04.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: 软指针指向的对象声明周期未结束时,同时有cleaner referent和Weak Annotation referent引用的资源和对象是不会释放的 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1:在方法体内为一个具有缓存语义的软引用rcht.sr加上一个Cleaner和一个Weak Annotation指向它; + * -#step2:该软引用生命周期结束后,应该会立刻释放该对象占用的内存(Cleaner和Weak Annotation对象没有缓存语义) + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCHeaderTest04.java + *- @ExecuteClass: RCHeaderTest04 + *- @ExecuteArgs: + *- @Remark: + * + */ + +import sun.misc.Cleaner; + +import java.lang.ref.SoftReference; + +import com.huawei.ark.annotation.Weak; + +class RCRunner04 implements Runnable { + public void run() { + RCHeaderTest04.iArray = null; + } +} + + +public class RCHeaderTest04 { + static int[] iArray; + @Weak + static int[] wr_annotation = null; + static Cleaner c = null; + static SoftReference sr = null; + + public RCHeaderTest04() { + iArray = new int[4]; + int[] temp = {1, 2, 3, 4}; + wr_annotation = temp; + sr = new SoftReference<>(temp); + } + + //方法退出后,实例变量sr声明周期结束,触发对SoftReference的处理,它指向的数组占用空间被释放。 + static void foo() { + RCHeaderTest04 rcht = new RCHeaderTest04(); + c = Cleaner.create(rcht.sr, new RCRunner04()); + if (c == null && wr_annotation.length != 4) { + System.out.println("Cleaner create failly"); + } + } + + public static void main(String[] args) { + foo(); + Runtime.getRuntime().runFinalization(); + if (c != null && wr_annotation != null && sr.get() != null) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } +} + + + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0443-rc-PlacementRC-PlacementRCTest01/PlacementRCTest01.java b/test/testsuite/ouroboros/rc_test/RC0443-rc-PlacementRC-PlacementRCTest01/PlacementRCTest01.java new file mode 100755 index 0000000000000000000000000000000000000000..1bc8b46e0d7c860aed7ff225b2d3873c05bb7ba4 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0443-rc-PlacementRC-PlacementRCTest01/PlacementRCTest01.java @@ -0,0 +1,173 @@ +/* + *- @TestCaseID:PlacementRCTest01.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:检测在循环语句(for, while, do-while)控制流中,生命周期结束的对象,应该会被立即回收 + *- @Condition: no + * -#c1 + *- @Brief:functionTest通过重写finalize()方法对回收的及时性做检测 + * -#step1:函数1测试场景:对象初始化在for循环外,只在for循环内部使用; + * -#step2:函数2测试场景:对象初始化和使用都在for循环内; + * -#step3:函数3测试场景:对象初始化在do-while循环内,循环之后,仍有使用; + * -#step4:函数4测试场景:对象初始化在for循环外,只在for循环内部部分分支(通过if判断)使用; + * -#step5:函数5测试场景:对象初始化在while循环外,while循环后仍然存活;在while循环内有局部对象的初始化和使用 + * -#step6:判断依据:End字符串和Method的位置关系 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: PlacementRCTest01.java + *- @ExecuteClass: PlacementRCTest01 + *- @ExecuteArgs: + *- @Remark: + * + * + */ +class B { + static A a; + + @Override + public void finalize() throws Throwable { + super.finalize(); + } +} + +class A { + public int count = 0; + public String className = "A"; + + public A(String name) { + this.className = name; + } + + public void changeName(String name) { + this.className = name; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); + synchronized (PlacementRCTest01.lock) { + if (this.count % 25 == 0) { + PlacementRCTest01.result += ("End"); + } + } + B.a = this; + } + +} + +public class PlacementRCTest01 { + public volatile static String result = new String(); + public static String lock = ""; + private static volatile int count = 0; + private static A infiniteLoop = null; + private A defInsideUseOutside = null; + + public static void onlyUseInsideLoop() { + A a1 = new A("a1"); + for (count = 0; count < 100; count++) { + a1.changeName("a" + count); + a1.count = count; + if (count == 99) + a1.toString(); + } + Runtime.getRuntime().runFinalization(); + //try{ Thread.sleep(5000); } catch( Exception e ){ } + synchronized (PlacementRCTest01.lock) { + result += "Method1"; + } + } + + public static void defAndUseInsideLoop() { + for (count = 0; count < 100; count++) { + A a2 = new A("a2_i" + count); + a2.count = count; + a2.changeName("null"); + for (int j = 0; j < 5; j++) { + a2 = new A("a2_i" + count + "_j" + j); + } + if (count == 99) { + a2.toString(); + } + } + Runtime.getRuntime().runFinalization(); + synchronized (PlacementRCTest01.lock) { + result += "Method2"; + } + } + + public void defInsideAndUseOutsideLoop() { + count = 0; + do { + this.defInsideUseOutside = new A("a2_i" + count); + this.defInsideUseOutside.count = count; + for (int j = 0; j < 2; j++) + this.defInsideUseOutside = new A("a2_i" + count + "_j" + j); + if (count == 99) + this.defInsideUseOutside.toString(); + count++; + } while (this.defInsideUseOutside.count < 100 && count < 100); + this.defInsideUseOutside.changeName("finish"); + this.defInsideUseOutside = null; + Runtime.getRuntime().runFinalization(); + synchronized (PlacementRCTest01.lock) { + result += "Method3"; + } + } + + public static void defInBranchInsideLoop() { + A a4 = new A("a4"); + for (count = 0; count < 100; count++) { + a4.changeName("a" + count); + a4.count = count; + if (count % 2 == 0) { + a4 = new A("a4_" + count); + } + a4.toString(); + } + a4.changeName("End"); + Runtime.getRuntime().runFinalization(); + synchronized (PlacementRCTest01.lock) { + result += "Method4"; + } + } + + public static void infiniteLoop() { + infiniteLoop = new A("infinite loop"); + count = 0; + while (count < 100) { + A a5 = new A("a2_i" + count); + a5.changeName("null"); + a5.count = count; + infiniteLoop.changeName("infinite loop" + count); + for (int j = 0; j < 2; j++) { + a5 = new A("a2_i" + count + "_j" + j); + } + if (count == 99) { + a5.toString(); + } + count++; + } + Runtime.getRuntime().runFinalization(); + synchronized (PlacementRCTest01.lock) { + result += "Method5"; + } + } + + public static void main(String[] args) { + onlyUseInsideLoop(); + defAndUseInsideLoop(); + new PlacementRCTest01().defInsideAndUseOutsideLoop(); + defInBranchInsideLoop(); + infiniteLoop(); + //System.out.println(result); + if(result.contains("Method1") && result.contains("Method2") && result.contains("Method3") && result.contains("Method4") && result.contains("Method5") && result.contains("End") && infiniteLoop.className.equals("infinite loop99")) + System.out.println("ExpectResult"); + else + System.out.println("ErrorResult"); + } + + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0444-rc-PlacementRC-PlacementRCTest02/PlacementRCTest02.java b/test/testsuite/ouroboros/rc_test/RC0444-rc-PlacementRC-PlacementRCTest02/PlacementRCTest02.java new file mode 100755 index 0000000000000000000000000000000000000000..e3d1441fbb0deaa2a5928cf06591382f0550dde0 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0444-rc-PlacementRC-PlacementRCTest02/PlacementRCTest02.java @@ -0,0 +1,147 @@ +/* + *- @TestCaseID:PlacementRCTest02.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:检测在判断语句(if-then, if-then-else, switch)控制流中,生命周期结束的对象,应该会被立即回收 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1:函数1判断仅有if语句,在if语句中进行对象使用和重新复制,使之前引用的局部对象声明周期结束。 + * -#step2:函数2在if语句中进行对象使用和重新复制,使之前引用的局部对象声明周期结束;在else分支仅做使用,不重新复制。 + * -#step3:函数3在switch控制流中测试,每个case中对对象都有不同的处理,查看是否会立刻释放。 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: PlacementRCTest02.java + *- @ExecuteClass: PlacementRCTest02 + *- @ExecuteArgs: + *- @Remark: + * + * + */ + +class PlacementRC_A2 { + public int count = 0; + public String className = "A"; + + public PlacementRC_A2(String name) { + this.className = name; + } + + public void changeName(String name) { + this.className = name; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); + synchronized (PlacementRCTest02.lock) { + if (this.count % 25 == 0) { + PlacementRCTest02.result += ("End" + count); + } + } + } + +} + +public class PlacementRCTest02 { + public static String result = new String(); + public static String lock = ""; + private volatile static int count = 0; + private PlacementRC_A2 defInsideUseOutside = null; + + public static void onlyUseInsideLoop() { + PlacementRC_A2 a1 = new PlacementRC_A2("a1"); + for (count = 0; count < 100; count++) { + a1.changeName("a" + count); + a1.count = count; + if (count % 11 == 0) { + a1.changeName("a" + 100); + a1 = new PlacementRC_A2("a10"); + a1.toString(); + } + } + Runtime.getRuntime().runFinalization(); + synchronized (PlacementRCTest02.lock) { + result += "Method1"; + } + } + + public static void defAndUseInsideLoop() { + for (count = 0; count < 100; count++) { + PlacementRC_A2 a2 = new PlacementRC_A2("a2_i" + count); + a2.changeName("null"); + a2.count = count; + for (int j = 0; j < 2; j++) + a2 = new PlacementRC_A2("a2_i" + count + "_j" + j); + if (count % 11 == 0) { + a2.changeName("a" + 100); + a2 = new PlacementRC_A2("a10"); + a2.toString(); + } else { + a2.toString(); + + } + } + Runtime.getRuntime().runFinalization(); + synchronized (PlacementRCTest02.lock) { + result += "Method2"; + } + } + + public static void main(String[] args) { + onlyUseInsideLoop(); + defAndUseInsideLoop(); + new PlacementRCTest02().defInsideAndUseOutsideLoop(); + //System.out.println(result); + if(result.contains("Method1") && result.contains("Method2") && result.contains("Method3") && result.contains("End")) + System.out.println("ExpectResult"); + else + System.out.println("Error Result"); + + } + + public void defInsideAndUseOutsideLoop() { + count = 0; + do { + int choice = count % 4; + this.defInsideUseOutside = new PlacementRC_A2("a2_i" + count); + switch (choice) { + case 1: + for (int j = 0; j < 2; j++) { + this.defInsideUseOutside = new PlacementRC_A2("a2_i" + count + "_j" + j); + this.defInsideUseOutside.count = count; + } + if (count == 99) + this.defInsideUseOutside.toString(); + break; + case 2: + for (int j = 0; j < 2; j++) { + this.defInsideUseOutside.changeName("a2_i" + count + "_j" + j); + this.defInsideUseOutside.count = count; + } + break; + case 3: + for (int j = 0; j < 2; j++) { + this.defInsideUseOutside = new PlacementRC_A2("a2_i" + count + "_j" + j); + this.defInsideUseOutside.count = count; + } + if (this.defInsideUseOutside.className.equals("a2_i95_j4")) + System.out.println(this.defInsideUseOutside.className); + break; + default: + this.defInsideUseOutside = new PlacementRC_A2("a2_i" + count); + this.defInsideUseOutside.count = count; + } + count++; + } while (this.defInsideUseOutside.count < 100 && count < 100); + this.defInsideUseOutside.changeName("finish"); + this.defInsideUseOutside = null; + Runtime.getRuntime().runFinalization(); + synchronized (PlacementRCTest02.lock) { + result += "Method3"; + } + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0446-rc-PlacementRC-PlacementRCTest04/PlacementRCTest04.java b/test/testsuite/ouroboros/rc_test/RC0446-rc-PlacementRC-PlacementRCTest04/PlacementRCTest04.java new file mode 100755 index 0000000000000000000000000000000000000000..f6ced0eb8afa4660c1c011834ffb94bde4d5615c --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0446-rc-PlacementRC-PlacementRCTest04/PlacementRCTest04.java @@ -0,0 +1,232 @@ +/* + * -@TestCaseID:PlacementRCTest04.java + * -@TestCaseName:MyselfClassName + * -@RequirementName:[运行时需求]支持自动内存管理 + * -@Title/Destination:检测在多层try-catch的语句中,生命周期结束的局部对象,应该会被立即回收 + * 检测在eh中,生命周期结束的对象,应该会被立即回收 + * -@Condition: no + * -#c1 + * -@Brief:functionTest + * -#step1:run()方法就是多层try-catch嵌套,里面有一些局部对象,声明周期到了之后会被立即释放 + * -@Expect:ExpectResult\n + * -@Priority: High + * -@Source: PlacementRCTest04.java + * -@ExecuteClass: PlacementRCTest04 + * -@ExecuteArgs: + * -@Remark: + */ + +import java.util.IllegalFormatException; + +class PlacementRC_A4 { + public int count = 0; + public String className = "A"; + + public PlacementRC_A4(String name) { + this.className = name; + } + + public void changeName(String name) { + this.className = name; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); + synchronized (PlacementRCTest04.lock) { + PlacementRCTest04.result += "End"; + } + } +} + +public class PlacementRCTest04 { + public static String result = ""; + public static String lock = ""; + static int res = 99; + + public static void main(String[] argv) { + run1(); + Runtime.getRuntime().runFinalization(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // do nothing + } + if (result.contains("run1") && result.contains("run4") && result.contains("run5") && result.contains("run3") + && result.contains("run2") && result.contains("End")) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } + + private static int run1() { + int result = 2; + PlacementRC_A4 place = new PlacementRC_A4("run4"); + try { + place.className = "run1"; + synchronized (PlacementRCTest04.lock) { + PlacementRCTest04.result += "run1"; + } + result = run2(); + } catch (StringIndexOutOfBoundsException e) { + res--; + } + + if (res == 96) { + result = 0; + res--; + } + return result; + } + + private static int run2() { + int result = 2; + try { + PlacementRC_A4 place = new PlacementRC_A4("run4"); + result = run3(); + place.changeName("run2"); + synchronized (PlacementRCTest04.lock) { + PlacementRCTest04.result += "run2"; + } + } catch (ClassCastException e) { + res -= 2; + } + + if (res == 95) { + result = 0; + } + return result; + } + + private static int run3() { + int result = 3; + try { + result = run4(); + PlacementRC_A4 place = new PlacementRC_A4("run4"); + synchronized (PlacementRCTest04.lock) { + place.className = "run3"; + } + PlacementRCTest04.result += place.className; + } catch (IllegalStateException e) { + res -= 3; + } + + if (res == 94) { + result = 0; + } + return result; + } + + private static int run4() { + int result = 4; + try { + PlacementRC_A4 place = new PlacementRC_A4("run4"); + place.className = "run4"; + synchronized (PlacementRCTest04.lock) { + PlacementRCTest04.result += "run4"; + } + result = run5(); + } catch (IllegalFormatException e) { + res -= 4; + } + + if (res == 93) { + result = 0; + } + return result; + } + + private static int run5() { + int result = 5; + try { + result = ExcpCover03330(); + } catch (Exception e) { + res -= 5; + } + PlacementRC_A4 place = new PlacementRC_A4(" "); + if (res == 92) { + result = 0; + } + place.className = "run5"; + synchronized (PlacementRCTest04.lock) { + PlacementRCTest04.result += "run5"; + } + return result; + } + + private static int ExcpCover03330() { + int result1 = 4; + PlacementRC_A4 place4 = new PlacementRC_A4("123#456"); + try { + Integer.parseInt(place4.className); + } catch (IndexOutOfBoundsException e) { + res -= 10; + } catch (IllegalArgumentException e) { + res--; + } finally { + res--; + try { + place4 = new PlacementRC_A4("123#4567"); + res += 100; + try { + place4 = new PlacementRC_A4("123#4568"); + PlacementRC_A4 place09 = new PlacementRC_A4("123#4561"); + res += 100; + place09.count = res; + try { + place4 = new PlacementRC_A4("123#4569"); + PlacementRC_A4 place9 = new PlacementRC_A4("123#4561"); + res += 100; + place9.count = res; + try { + place4 = new PlacementRC_A4("123#4560"); + PlacementRC_A4 place18 = new PlacementRC_A4("123#4561"); + res += 100; + place18.count = res; + place9.count = place18.count; + try { + place4 = new PlacementRC_A4("123#4561"); + PlacementRC_A4 place19 = new PlacementRC_A4("123#4561"); + res += 100; + place19.count = res; + place9.count = place19.count; + System.out.println(place4.className.substring(-5)); + } catch (ClassCastException e) { + place9.className = "catch info 1"; + res -= 10; + } finally { + res -= 100; + } + } catch (ClassCastException e1) { + place4.className = "catch info 2"; + res -= 10; + } finally { + res -= 100; + } + } catch (IllegalStateException e2) { + place09.className = "catch info 3"; + res -= 10; + } finally { + res -= 100; + } + } catch (ClassCastException e3) { + place4.className = "catch info 4"; + res -= 10; + } finally { + res -= 100; + } + } catch (IllegalArgumentException e4) { + place4.className = "catch info 5"; + res -= 10; + } finally { + res -= 100; + } + } + res -= 10; + place4.count = result1; + return place4.count; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0449-rc-RP-FinalizerReferenceTest01/FinalizerReferenceTest01.java b/test/testsuite/ouroboros/rc_test/RC0449-rc-RP-FinalizerReferenceTest01/FinalizerReferenceTest01.java new file mode 100644 index 0000000000000000000000000000000000000000..5c7c10b2acd1e96f7921712bfa25a6e1c4fe8d96 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0449-rc-RP-FinalizerReferenceTest01/FinalizerReferenceTest01.java @@ -0,0 +1,83 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_FinalizerReferenceTest01 + *- @TestCaseName: FinalizerReferenceTest01 + *- @TestCaseType: Function Testing for FinalizerReference Test + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief:测试正常情况下,软引用+FinalizerReference指向的对象内存回收正确。 + * -#step1: 创建带有重构finalize方法的类ReferenceTest01; + * -#step2: 创建一个软引用指向ReferenceTest01的实例,判断无问题。 + * -#step3: oom触发GC,软引用无法通过get获得,finalize方法被调用。 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: FinalizerReferenceTest01.java + *- @ExecuteClass: FinalizerReferenceTest01 + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.SoftReference; +import java.util.ArrayList; + +public class FinalizerReferenceTest01 { + static int check = 3; + + public static void main(String[] args) { + SoftReference softReference = new SoftReference<>(new ReferenceTest01(10)); + ReferenceTest01 rt01 = softReference.get(); + if (rt01.stringArray.length == 10 && rt01.stringArray[9].equals("test9")) { + check--; + } + rt01 = null; + try { + int oom = oomTest(); // 触发oom + } catch (OutOfMemoryError o) { + check--; + } + Runtime.getRuntime().runFinalization(); + if (softReference.get() == null) { + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } + + private static int oomTest() { + int sum = 0; + ArrayList store = new ArrayList(); + byte[] temp; + + for (int i = 1024 * 1024; i <= 1024 * 1024 * 10; ) { + temp = new byte[i]; + store.add(temp); + sum += store.size(); + } + return sum; + } +} + +class ReferenceTest01 { + String[] stringArray; + + public ReferenceTest01(int length) { + stringArray = new String[length]; + for (int i = 0; i < length; i++) { + stringArray[i] = "test" + i; + } + } + + @Override + public void finalize() { + for (int i = 0; i < this.stringArray.length; i++) { + stringArray[i] = null; + } + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0450-rc-RP-FinalizerReferenceTest02/FinalizerReferenceTest02.java b/test/testsuite/ouroboros/rc_test/RC0450-rc-RP-FinalizerReferenceTest02/FinalizerReferenceTest02.java new file mode 100644 index 0000000000000000000000000000000000000000..237df66f9f7b329c5781ee8c3d6c12bd405feede --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0450-rc-RP-FinalizerReferenceTest02/FinalizerReferenceTest02.java @@ -0,0 +1,65 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_FinalizerReferenceTest02 + *- @TestCaseName: FinalizerReferenceTest02 + *- @TestCaseType: Function Testing for FinalizerReference Test + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief:测试正常情况下,弱引用+FinalizerReference指向的对象 + * -#step1: 创建带有重构finalize方法的类ReferenceTest02; + * -#step2: 创建一个弱引用引用指向ReferenceTest02的实例,判断无问题。 + * -#step3: 触发用户GC,弱引用无法通过get获得,finalize方法被调用。 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: FinalizerReferenceTest02.java + *- @ExecuteClass: FinalizerReferenceTest02 + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.WeakReference; + +public class FinalizerReferenceTest02 { + static int check = 2; + + public static void main(String[] args) { + WeakReference weakReference = new WeakReference<>(new ReferenceTest02(10)); + ReferenceTest02 rt02 = weakReference.get(); + if (rt02.stringArray.length == 10 && rt02.stringArray[9].equals("test9")) { + check--; + } + rt02 = null; + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + if (weakReference.get() == null) { + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } +} + +class ReferenceTest02 { + String[] stringArray; + + public ReferenceTest02(int length) { + stringArray = new String[length]; + for (int i = 0; i < length; i++) { + stringArray[i] = "test" + i; + } + } + + @Override + public void finalize() { + for (int i = 0; i < this.stringArray.length; i++) { + stringArray[i] = null; + } + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0451-rc-RP-FinalizerReferenceTest03/FinalizerReferenceTest03.java b/test/testsuite/ouroboros/rc_test/RC0451-rc-RP-FinalizerReferenceTest03/FinalizerReferenceTest03.java new file mode 100644 index 0000000000000000000000000000000000000000..6af77f9ef2657a734cf36323c78afc59b42790e2 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0451-rc-RP-FinalizerReferenceTest03/FinalizerReferenceTest03.java @@ -0,0 +1,61 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_FinalizerReferenceTest03 + *- @TestCaseName: FinalizerReferenceTest03 + *- @TestCaseType: Function Testing for FinalizerReference Test + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief:测试正常情况下,虚引用+FinalizerReference指向的对象 + * -#step1: 创建带有重构finalize方法的类ReferenceTest03; + * -#step2: 创建一个虚引用引用指向ReferenceTest03的实例,判断无问题。 + * -#step3: 触发用户GC,虚引用无法通过get获得,finalize方法被调用。 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: FinalizerReferenceTest03.java + *- @ExecuteClass: FinalizerReferenceTest03 + *- @ExecuteArgs: + */ + +import java.lang.ref.PhantomReference; +import java.lang.ref.ReferenceQueue; + +public class FinalizerReferenceTest03 { + static int check = 1; + + public static void main(String[] args) { + ReferenceQueue referenceQueue = new ReferenceQueue(); + PhantomReference pr = new PhantomReference<>(new ReferenceTest03(10), referenceQueue); + if (pr.get() == null) { + check--; + } + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } +} + +class ReferenceTest03 { + String[] stringArray; + + public ReferenceTest03(int length) { + stringArray = new String[length]; + for (int i = 0; i < length; i++) { + stringArray[i] = "test" + i; + } + } + + @Override + public void finalize() { + for (int i = 0; i < this.stringArray.length; i++) { + stringArray[i] = null; + } + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0452-rc-RP-FinalizerReferenceTest04/FinalizerReferenceTest04.java b/test/testsuite/ouroboros/rc_test/RC0452-rc-RP-FinalizerReferenceTest04/FinalizerReferenceTest04.java new file mode 100644 index 0000000000000000000000000000000000000000..96875430e34031c1f6c4aaf4e41e46cc744e4ab6 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0452-rc-RP-FinalizerReferenceTest04/FinalizerReferenceTest04.java @@ -0,0 +1,52 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_FinalizerReferenceTest04 + *- @TestCaseName: FinalizerReferenceTest04 + *- @TestCaseType: Function Testing for FinalizerReference Test + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief:测试正常情况下,Cleaner+FinalizerReference指向的对象 + * -#step1: 创建带有重构finalize方法的类ReferenceTest04; + * -#step2: 创建一个cleaner引用指向ReferenceTest04的实例。 + * -#step3: 触发用户GC,虚引用无法通过get获得,finalize方法被调用。 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: FinalizerReferenceTest04.java + *- @ExecuteClass: FinalizerReferenceTest04 + *- @ExecuteArgs: + *- @Remark: + */ + +import sun.misc.Cleaner; + +public class FinalizerReferenceTest04 { + static Cleaner cleaner; + + public static void main(String[] args) { + Cleaner.create(new ReferenceTest04(10), null); + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + } +} + +class ReferenceTest04 { + String[] stringArray; + + public ReferenceTest04(int length) { + stringArray = new String[length]; + for (int i = 0; i < length; i++) { + stringArray[i] = "test" + i; + } + } + + @Override + public void finalize() { + for (int i = 0; i < this.stringArray.length; i++) { + stringArray[i] = null; + } + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0453-rc-RP-FinalizerReferenceTest05/FinalizerReferenceTest05.java b/test/testsuite/ouroboros/rc_test/RC0453-rc-RP-FinalizerReferenceTest05/FinalizerReferenceTest05.java new file mode 100644 index 0000000000000000000000000000000000000000..dab5df13f798d495955347666870303afbbba7a8 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0453-rc-RP-FinalizerReferenceTest05/FinalizerReferenceTest05.java @@ -0,0 +1,85 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_FinalizerReferenceTest05 + *- @TestCaseName: FinalizerReferenceTest05 + *- @TestCaseType: Function Testing for FinalizerReference Test + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief:测试正常情况下,软引用+FinalizerReference指向的对象内存回收正确。 + * -#step1: 创建带有重构finalize方法的类ReferenceTest05, + * -#step2: 该实例的对象gc回收时,finalize方法会将其关联到一个软引用上,判断无问题。 + * -#step3: oom触发GC,软引用无法通过get获得finalize方法不再被调用。 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: FinalizerReferenceTest05.java + *- @ExecuteClass: FinalizerReferenceTest05 + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.SoftReference; +import java.util.ArrayList; + +public class FinalizerReferenceTest05 { + static SoftReference sr05; + static int check = 3; + + public static void main(String[] args) { + new ReferenceTest05(10); + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + ReferenceTest05 rt05 = sr05.get(); + if (rt05.stringArray.length == 10 && rt05.stringArray[9].equals("test9")) { + check--; + } + rt05 = null; + try { + int oom = oomTest(); // 触发oom + } catch (OutOfMemoryError o) { + check--; + } + Runtime.getRuntime().runFinalization(); + if (sr05.get() == null) { + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } + + private static int oomTest() { + int sum = 0; + ArrayList store = new ArrayList(); + byte[] temp; + + for (int i = 1024 * 1024; i <= 1024 * 1024 * 10; ) { + temp = new byte[i]; + store.add(temp); + sum += store.size(); + } + return sum; + } +} + +class ReferenceTest05 { + String[] stringArray; + + public ReferenceTest05(int length) { + stringArray = new String[length]; + for (int i = 0; i < length; i++) { + stringArray[i] = "test" + i; + } + } + + @Override + public void finalize() { + System.out.println("ExpectResult"); + FinalizerReferenceTest05.sr05 = new SoftReference(this); + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0454-rc-RP-FinalizerReferenceTest06/FinalizerReferenceTest06.java b/test/testsuite/ouroboros/rc_test/RC0454-rc-RP-FinalizerReferenceTest06/FinalizerReferenceTest06.java new file mode 100644 index 0000000000000000000000000000000000000000..f81e20f3931df789b62a083b4cf8fd69397e1be8 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0454-rc-RP-FinalizerReferenceTest06/FinalizerReferenceTest06.java @@ -0,0 +1,66 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_FinalizerReferenceTest06 + *- @TestCaseName: FinalizerReferenceTest06 + *- @TestCaseType: Function Testing for FinalizerReference Test + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief:测试正常情况下,弱引用+FinalizerReference指向的对象内存回收正确。 + * -#step1: 创建带有重构finalize方法的类ReferenceTest06, + * -#step2: 该实例的对象gc回收时,finalize方法会将其关联到一个弱引用上,判断无问题。 + * -#step3: 触发用户GC,弱引用无法通过get获得finalize方法不再被调用。 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: FinalizerReferenceTest06.java + *- @ExecuteClass: FinalizerReferenceTest06 + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.WeakReference; + +public class FinalizerReferenceTest06 { + static WeakReference sr06; + static int check = 2; + + public static void main(String[] args) { + new ReferenceTest06(10); + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + if (sr06.get() == null) { + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } +} + +class ReferenceTest06 { + String[] stringArray; + + public ReferenceTest06(int length) { + stringArray = new String[length]; + for (int i = 0; i < length; i++) { + stringArray[i] = "test" + i; + } + } + + @Override + public void finalize() { + System.out.println("ExpectResult"); + FinalizerReferenceTest06.sr06 = new WeakReference<>(this); + ReferenceTest06 rt06 = FinalizerReferenceTest06.sr06.get(); + if (rt06.stringArray.length == 10 && rt06.stringArray[9].equals("test9")) { + FinalizerReferenceTest06.check--; + } + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0455-rc-RP-FinalizerReferenceTest07/FinalizerReferenceTest07.java b/test/testsuite/ouroboros/rc_test/RC0455-rc-RP-FinalizerReferenceTest07/FinalizerReferenceTest07.java new file mode 100755 index 0000000000000000000000000000000000000000..a226dcaddaaa8eac56af415d2117a43dfcd834dc --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0455-rc-RP-FinalizerReferenceTest07/FinalizerReferenceTest07.java @@ -0,0 +1,72 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_FinalizerReferenceTest07 + *- @TestCaseName: FinalizerReferenceTest07 + *- @TestCaseType: Function Testing for FinalizerReference Test + *- @RequirementName: 运行时支持GCOnly + *- @Conditon: + * -#c1: 测试环境正常 + *- @Brief:测试正常情况下,虚引用+FinalizerReference指向的对象内存回收正确。 + * -#step1: 创建带有重构finalize方法的类ReferenceTest07, + * -#step2: 该实例的对象gc回收时,finalize方法会将其关联到一个虚引用上,判断无问题。 + * -#step3: 触发用户GC,虚引用无法通过get获得finalize方法不再被调用。 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: FinalizerReferenceTest07.java + *- @ExecuteClass: FinalizerReferenceTest07 + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.PhantomReference; +import java.lang.ref.ReferenceQueue; + +public class FinalizerReferenceTest07 { + static ReferenceQueue referenceQueue = new ReferenceQueue(); + static PhantomReference sr07; + static int check = 2; + + public static void main(String[] args) { + new ReferenceTest07(10); + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + if (sr07.get() == null) { + check--; + } + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // do nothing + } + if (referenceQueue.poll() != null) { + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } +} + +class ReferenceTest07 { + String[] stringArray; + + public ReferenceTest07(int length) { + stringArray = new String[length]; + for (int i = 0; i < length; i++) { + stringArray[i] = "test" + i; + } + } + + @Override + public void finalize() { + System.out.println("ExpectResult"); + FinalizerReferenceTest07.sr07 = new PhantomReference<>(this, FinalizerReferenceTest07.referenceQueue); + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0456-rc-RP-FinalizerReferenceTest08/FinalizerReferenceTest08.java b/test/testsuite/ouroboros/rc_test/RC0456-rc-RP-FinalizerReferenceTest08/FinalizerReferenceTest08.java new file mode 100644 index 0000000000000000000000000000000000000000..6c5139d90c1c84e7e96ef286e2141ad33f5acd7b --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0456-rc-RP-FinalizerReferenceTest08/FinalizerReferenceTest08.java @@ -0,0 +1,54 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_FinalizerReferenceTest08 + *- @TestCaseName: FinalizerReferenceTest08 + *- @TestCaseType: Function Testing for FinalizerReference Test + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief:测试正常情况下,Cleaner+FinalizerReference指向的对象内存回收正确。 + * -#step1: 创建带有重构finalize方法的类ReferenceTest08, + * -#step2: 该实例的对象gc回收时,finalize方法会将其关联到一个虚引用上,判断无问题。 + * -#step3: 触发用户GC,虚引用无法通过get获得finalize方法不再被调用。 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: FinalizerReferenceTest08.java + *- @ExecuteClass: FinalizerReferenceTest08 + *- @ExecuteArgs: + *- @Remark: + */ + +import sun.misc.Cleaner; + +public class FinalizerReferenceTest08 { + static Cleaner cleaner; + static int check = 2; + + public static void main(String[] args) { + new ReferenceTest08(10); + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + } +} + +class ReferenceTest08 { + String[] stringArray; + + public ReferenceTest08(int length) { + stringArray = new String[length]; + for (int i = 0; i < length; i++) { + stringArray[i] = "test" + i; + } + } + + @Override + public void finalize() { + System.out.println("ExpectResult"); + Cleaner.create(this, null); + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0457-rc-GC-TriggerGCTest01/TriggerGCTest01.java b/test/testsuite/ouroboros/rc_test/RC0457-rc-GC-TriggerGCTest01/TriggerGCTest01.java new file mode 100644 index 0000000000000000000000000000000000000000..1ca2bb1eb8696fbfe76e7f623d5fe9c8910c7688 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0457-rc-GC-TriggerGCTest01/TriggerGCTest01.java @@ -0,0 +1,62 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_TriggerGCTest01 + *- @TestCaseName: TriggerGCTest01 + *- @TestCaseType: Function Testing for TriggerGC Test + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief:测试正常情况下,用户通过System.gc()进行内存回收时处理正确。 + * -#step1: 创建一个弱引用,判断该引用可以通过get()正常获得object; + * -#step2: 在一个线程中创建一个60个无RP关联的弱引用,再次判断步骤一里创建的弱引用仍然可以通过get()方法获得对象。 + * -#step3: 用户调用System.gc()触发GC,判断该引用被回收到的RP中。 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: TriggerGCTest01.java + *- @ExecuteClass: TriggerGCTest01 + *- @ExecuteArgs: + *- @Remark: + */ +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; + +public class TriggerGCTest01 { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static int a = 100; + + static void setWeakReference() { + rp = new WeakReference(new Object(), rq); + if (rp.get() == null) { + a++; + } + } + + public static void main(String[] args) throws Exception { + Reference r; + setWeakReference(); + new Thread(new TriggerRP()).start(); + Runtime.getRuntime().gc(); + Thread.sleep(1000); + if (rp.get() != null) { + a++; + } + if (a == 100) { + System.out.println("ExpectResult"); + } + } + + static class TriggerRP implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + WeakReference wr = new WeakReference(new Object()); + try { + Thread.sleep(50); + } catch (Exception e) { + } + } + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f diff --git a/test/testsuite/ouroboros/rc_test/RC0458-rc-GC-TriggerGCTest02/TriggerGCTest02.java b/test/testsuite/ouroboros/rc_test/RC0458-rc-GC-TriggerGCTest02/TriggerGCTest02.java new file mode 100644 index 0000000000000000000000000000000000000000..111cdb97c9fb63da0124da3b170d38d01f0f834c --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0458-rc-GC-TriggerGCTest02/TriggerGCTest02.java @@ -0,0 +1,62 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_TriggerGCTest02 + *- @TestCaseName: TriggerGCTest02 + *- @TestCaseType: Function Testing for TriggerGC Test + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief:测试正常情况下,用户通过Runtime.getRuntime().gc()进行内存回收时处理正确。 + * -#step1: 创建一个弱引用,判断该引用可以通过get()正常获得object; + * -#step2: 在一个线程中创建一个60个无RP关联的弱引用,再次判断步骤一里创建的弱引用仍然可以通过get()方法获得对象。 + * -#step3: 用户调用Runtime.getRuntime().gc()触发GC,判断该引用被回收到的RP中。 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: TriggerGCTest02.java + *- @ExecuteClass: TriggerGCTest02 + *- @ExecuteArgs: + *- @Remark: + */ +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; + +public class TriggerGCTest02 { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static int a = 100; + + static void setWeakReference() { + rp = new WeakReference(new Object(), rq); + if (rp.get() == null) { + a++; + } + } + + public static void main(String[] args) throws Exception { + Reference r; + setWeakReference(); + new Thread(new TriggerRP()).start(); + Runtime.getRuntime().gc(); + if (rp.get() != null) { + a++; + } + if (a == 100) { + System.out.println("ExpectResult"); + } + } + + static class TriggerRP implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + WeakReference wr = new WeakReference(new Object()); + try { + Thread.sleep(50); + } catch (Exception e) { + } + } + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0459-rc-GC-TriggerGCTest03/TriggerGCTest03.java b/test/testsuite/ouroboros/rc_test/RC0459-rc-GC-TriggerGCTest03/TriggerGCTest03.java new file mode 100644 index 0000000000000000000000000000000000000000..caa1fc0e1f1cf3ce17d62eccbcdd5c9f99cd89cf --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0459-rc-GC-TriggerGCTest03/TriggerGCTest03.java @@ -0,0 +1,73 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_TriggerGCTest03 + *- @TestCaseName: TriggerGCTest03 + *- @TestCaseType: Function Testing for TriggerGC Test + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief:测试正常情况下,OOM时会触发GC进行内存回收。 + * -#step1: 创建一个软引用,判断该引用可以通过get()正常获得object; + * -#step2: 用户调用oomTest()触发GC,判断该引用被回收。 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: TriggerGCTest03.java + *- @ExecuteClass: TriggerGCTest03 + *- @ExecuteArgs: + *- @Remark: + */ +import java.lang.ref.SoftReference; +import java.util.ArrayList; + +public class TriggerGCTest03 { + static int check = 3; + + public static void main(String[] args) { + SoftReference softReference = new SoftReference<>(new Reference03(100000)); + Reference03 rt01 = softReference.get(); + if (rt01.stringArray.length == 100000 && rt01.stringArray[9].equals("test9")) { + check--; + } + rt01 = null; + try { + int oom = oomTest(); // 触发oom + } catch (OutOfMemoryError o) { + check--; + Runtime.getRuntime().runFinalization(); + if (softReference.get() == null) { + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } + } + + private static int oomTest() { + int sum = 0; + ArrayList store = new ArrayList(); + byte[] temp; + + for (int i = 1034 * 1034; i <= 1034 * 1034 * 10; ) { + temp = new byte[i]; + store.add(temp); + sum += store.size(); + } + return sum; + } +} + +class Reference03 { + String[] stringArray; + + public Reference03(int length) { + stringArray = new String[length]; + for (int i = 0; i < length; i++) { + stringArray[i] = "test" + i; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0463-rc-GC-TriggerGCTest07/TriggerGCTest07.java b/test/testsuite/ouroboros/rc_test/RC0463-rc-GC-TriggerGCTest07/TriggerGCTest07.java new file mode 100644 index 0000000000000000000000000000000000000000..da3c0c603eedb51d11e55117588323956fda3611 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0463-rc-GC-TriggerGCTest07/TriggerGCTest07.java @@ -0,0 +1,52 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_TriggerGCTest07 + *- @TestCaseName: TriggerGCTest07 + *- @TestCaseType: Function Testing for TriggerGC Test + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief:当前初始阈值是100MB,会隐式触发GC。 + * -#step1:创建一个弱引用,检查它可以通过get()方法获得关联的引用对象。 + * -#step2:通过1个for循环,分配内存到100M。 + * -#step3:验证GC被隐式触发,步骤1中创建的弱引用被回收掉了。 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: TriggerGCTest07.java + *- @ExecuteClass: TriggerGCTest07 + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.WeakReference; +import java.util.ArrayList; + +public class TriggerGCTest07 { + static WeakReference observer; + static int check = 2; + private final static int INIT_MEMORY = 100; // MB + private static ArrayList store = new ArrayList(); + + public static void main(String[] args) throws Exception { + observer = new WeakReference(new Object()); + if (observer.get() != null) { + check--; + } + for (int i = 0; i < INIT_MEMORY; i++) { + byte[] temp = new byte[1024*1024]; + store.add(temp); + } + Thread.sleep(3000); + if (observer.get() == null) { + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult, check should be 0, but now check = " + check); + } + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0464-rc-GC-TriggerGCTest08/TriggerGCTest08.java b/test/testsuite/ouroboros/rc_test/RC0464-rc-GC-TriggerGCTest08/TriggerGCTest08.java new file mode 100644 index 0000000000000000000000000000000000000000..9ed76cdbaaace1f26ac4cff95d334553c1b8185e --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0464-rc-GC-TriggerGCTest08/TriggerGCTest08.java @@ -0,0 +1,59 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_TriggerGCTest08 + *- @TestCaseName: TriggerGCTest08 + *- @TestCaseType: Function Testing for TriggerGC Test + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief:当前初始阈值是100MB,每次已分配内存超过阈值时会将阈值乘以1.5的系数并设为新的阈值。 + * -#step1: 通过1个for循环,分配内存到100M。 + * -#step2:创建一个弱引用,检查它可以通过get()方法获得关联的引用对象。 + * -#step3:再次将内存分配到100*1.5=150M + * -#step4:验证GC被隐式触发,步骤1中创建的弱引用被回收掉了。 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: TriggerGCTest08.java + *- @ExecuteClass: TriggerGCTest08 + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.WeakReference; +import java.util.ArrayList; + +public class TriggerGCTest08 { + static WeakReference observer; + static int check = 2; + private final static int INIT_MEMORY = 100; // MB + private final static int SEC_MEMORY = 150; // MB + private static ArrayList store = new ArrayList(); + + public static void main(String[] args) throws Exception { + for (int i = 0; i < INIT_MEMORY; i++) { + byte[] temp = new byte[1024*1024]; + store.add(temp); + } + Thread.sleep(2000); + observer = new WeakReference(new Object()); + if (observer.get() != null) { + check--; + } + for (int i = INIT_MEMORY; i < SEC_MEMORY; i++) { + byte[] temp = new byte[1024*1024]; + store.add(temp); + } + Thread.sleep(3000); + if (observer.get() == null) { + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult, check should be 0, but now check = " + check); + } + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0465-rc-GC-TriggerGCTest09/TriggerGCTest09.java b/test/testsuite/ouroboros/rc_test/RC0465-rc-GC-TriggerGCTest09/TriggerGCTest09.java new file mode 100644 index 0000000000000000000000000000000000000000..148b75ce119686caf1fcc52e29031401d55766d2 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0465-rc-GC-TriggerGCTest09/TriggerGCTest09.java @@ -0,0 +1,59 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_TriggerGCTest09 + *- @TestCaseName: TriggerGCTest09 + *- @TestCaseType: Function Testing for TriggerGC Test + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief:当前初始阈值是100MB,每次已分配内存超过阈值时会将阈值乘以1.5的系数并设为新的阈值。 + * -#step1: 通过1个for循环,分配内存到150M。 + * -#step2:创建一个弱引用,检查它可以通过get()方法获得关联的引用对象。 + * -#step3:再次将内存分配到150*1.5=225M + * -#step4:验证GC被隐式触发,步骤1中创建的弱引用被回收掉了。 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: TriggerGCTest09.java + *- @ExecuteClass: TriggerGCTest09 + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.WeakReference; +import java.util.ArrayList; + +public class TriggerGCTest09 { + static WeakReference observer; + static int check = 2; + private final static int SEC_MEMORY = 150; // MB + private final static int TRI_MEMORY = 225; // MB + private static ArrayList store = new ArrayList(); + + public static void main(String[] args) throws Exception { + for (int i = 0; i < SEC_MEMORY; i++) { + byte[] temp = new byte[1024*1024]; + store.add(temp); + } + Thread.sleep(2000); + observer = new WeakReference(new Object()); + if (observer.get() != null) { + check--; + } + for (int i = SEC_MEMORY; i < TRI_MEMORY; i++) { + byte[] temp = new byte[1024*1024]; + store.add(temp); + } + Thread.sleep(3000); + if (observer.get() == null) { + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult, check should be 0, but now check = " + check); + } + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0466-rc-GC-TriggerGCTest10/TriggerGCTest10.java b/test/testsuite/ouroboros/rc_test/RC0466-rc-GC-TriggerGCTest10/TriggerGCTest10.java new file mode 100644 index 0000000000000000000000000000000000000000..50ed8e98090d93f3398069fbc3c7e885651d6448 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0466-rc-GC-TriggerGCTest10/TriggerGCTest10.java @@ -0,0 +1,63 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_TriggerGCTest10 + *- @TestCaseName: TriggerGCTest10 + *- @TestCaseType: Function Testing for TriggerGC Test + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief:当前初始阈值是100MB,每次已分配内存超过阈值时会将阈值乘以1.5的系数并设为新的阈值。 + * -#step1: 通过1个for循环,分配内存到225M。 + * -#step2:创建一个弱引用,检查它可以通过get()方法获得关联的引用对象。 + * -#step3:再次将内存分配到350M,因为可能会OOM,加了一个try-catch + * -#step4:验证GC被隐式触发,步骤1中创建的弱引用被回收掉了。 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: TriggerGCTest10.java + *- @ExecuteClass: TriggerGCTest10 + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.WeakReference; +import java.util.ArrayList; + +public class TriggerGCTest10 { + static WeakReference observer; + static int check = 2; + private final static int TRI_MEMORY = 225; // MB + private final static int FOU_MEMORY = 350; // MB + private static ArrayList store = new ArrayList(); + + public static void main(String[] args) throws Exception { + for (int i = 0; i < TRI_MEMORY; i++) { + byte[] temp = new byte[1024*1024]; + store.add(temp); + } + Thread.sleep(2000); + observer = new WeakReference(new Object()); + if (observer.get() != null) { + check--; + } + try { + for (int i = TRI_MEMORY; i < FOU_MEMORY; i++) { + byte[] temp = new byte[1024 * 1024]; + store.add(temp); + } + } catch (OutOfMemoryError e) { + // do nothing + } + Thread.sleep(1000); + if (observer.get() == null) { + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult, check should be 0, but now check = " + check); + } + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0468-rc-BindingMethod-ArrayCloneTest/ArrayCloneTest.java b/test/testsuite/ouroboros/rc_test/RC0468-rc-BindingMethod-ArrayCloneTest/ArrayCloneTest.java new file mode 100644 index 0000000000000000000000000000000000000000..9cee681c3e18496c656717ccc6a2ba6f63ec80f4 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0468-rc-BindingMethod-ArrayCloneTest/ArrayCloneTest.java @@ -0,0 +1,38 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_ArrayCloneTest + *- @TestCaseName: ArrayCloneTest + *- @TestCaseType: Function Testing for MemoryBindingMethod Test + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief:clone()函数专项测试:验证数组的clone()方法的基本功能正常。 + * -#step1:测试正常数组拷贝 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: ArrayCloneTest.java + *- @ExecuteClass: ArrayCloneTest + *- @ExecuteArgs: + *- @Remark: + */ + +public class ArrayCloneTest { + public static void main(String[] args) { + if (functionTest01()) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } + + private static boolean functionTest01() { + String[] test1 = {"test1","test2","test3","test4","test5","test6","test7","test8","test9","test10"}; + String[] test2 = test1.clone(); + if (test2 != test1 && test2.length == 10 && test2[0].equals("test1") && test2[9].equals("test10")) { + return true; + } + return false; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0469-rc-BindingMethod-ArrayCloneTest02/ArrayCloneTest02.java b/test/testsuite/ouroboros/rc_test/RC0469-rc-BindingMethod-ArrayCloneTest02/ArrayCloneTest02.java new file mode 100644 index 0000000000000000000000000000000000000000..9566cb288feabc801991bd7a51a30c66244e5496 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0469-rc-BindingMethod-ArrayCloneTest02/ArrayCloneTest02.java @@ -0,0 +1,52 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_ArrayCloneTest02 + *- @TestCaseName: ArrayCloneTest02 + *- @TestCaseType: Function Testing for MemoryBindingMethod Test + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief:clone()函数专项测试:验证数组的clone()方法的基本功能正常。 + * -#step1:测试数组拷贝时报CloneNotSupportedException异常 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: ArrayCloneTest02.java + *- @ExecuteClass: ArrayCloneTest02 + *- @ExecuteArgs: + *- @Remark: + */ + +public class ArrayCloneTest02 { + private Integer id; + + public ArrayCloneTest02(Integer id) { + this.id = id; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + @Override + public String toString() { + return "CloneTest{" + + "id=" + id + + '}'; + } + + public static void main(String[] args) { + try { + ArrayCloneTest02 cloneTest = new ArrayCloneTest02(1); + ArrayCloneTest02 cloneTest1 = (ArrayCloneTest02) cloneTest.clone(); + System.out.println("ErrorResult"); + } catch (CloneNotSupportedException e) { + System.out.println("ExpectResult"); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0470-rc-BindingMethod-ArrayCopyTest/ArrayCopyTest.java b/test/testsuite/ouroboros/rc_test/RC0470-rc-BindingMethod-ArrayCopyTest/ArrayCopyTest.java new file mode 100644 index 0000000000000000000000000000000000000000..b58ac82695238506ea5e4b9325b07bb1f9362d03 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0470-rc-BindingMethod-ArrayCopyTest/ArrayCopyTest.java @@ -0,0 +1,78 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_ArrayCopyTest + *- @TestCaseName: ArrayCopyTest + *- @TestCaseType: Function Testing for MemoryBindingMethod Test + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief:ArrayCopy函数专项测试:验证ArrayCopy方法的基本功能正常。 + * -#step1:测试正常数组拷贝 + * -#step2:测试拷贝过程中出现ArrayStoreException异常 + * -#step3:测试拷贝过程中出现ArrayIndexOutOfBoundsException异常 + * -#step4:测试拷贝过程中出现NullPointerException异常 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: ArrayCopyTest.java + *- @ExecuteClass: ArrayCopyTest + *- @ExecuteArgs: + *- @Remark: + */ + +public class ArrayCopyTest { + public static void main(String[] args) { + if (functionTest01() && functionTest02() && functionTest03() && functionTest04()) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } + + private static boolean functionTest01() { + String[] test1 = {"test1","test2","test3","test4","test5","test6","test7","test8","test9","test10"}; + String[] test2 = new String[10]; + System.arraycopy(test1,0,test2,0,10); + if (test2[0].equals("test1") && test2[9].equals("test10")) { + return true; + } + return false; + } + + private static boolean functionTest02() { + try { + String[] test1 = {"test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9", "test10"}; + int[] test2 = new int[10]; + System.arraycopy(test1, 0, test2, 0, 10); + + } catch (ArrayStoreException e) { + return true; + } + return false; + } + + private static boolean functionTest03() { + try { + String[] test1 = {"test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9", "test10"}; + String[] test2 = new String[9]; + System.arraycopy(test1, 0, test2, 0, 10); + + } catch (ArrayIndexOutOfBoundsException e) { + return true; + } + return false; + } + + private static boolean functionTest04() { + try { + String[] test1 = {"test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9", "test10"}; + String[] test2 = null; + System.arraycopy(test1, 0, test2, 0, 10); + + } catch (NullPointerException e) { + return true; + } + return false; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0477-rc-StackScan-CB_01/CB_01.java b/test/testsuite/ouroboros/rc_test/RC0477-rc-StackScan-CB_01/CB_01.java new file mode 100644 index 0000000000000000000000000000000000000000..b33abc90f88a4fe62e27f4c8b2247ccd35cf9d91 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0477-rc-StackScan-CB_01/CB_01.java @@ -0,0 +1,431 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_CB01 + *- @TestCaseName: CB_01 + *- @TestCaseType: Function Testing for placementRCTest + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: Cycle is Cycle_a_0038.java;Nocycle is Nocycle_00180.java + *- @Brief:一组有环的对象,他们的field指向一个hashMap,里面装满了对象 + * -#step1: 创建一个环,环的类型参考了Cycle_a_0038.java; + * -#step2: 两个域test1和test2,里面装满了对象,对象格式参考Nocycle_00180.java,这样就构造了一个大对象。 + * -#step3: 验证结果正确,再用GCverify验证无内存泄漏。 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: CB_01.java + *- @ExecuteClass: CB_01 + *- @ExecuteArgs: + *- @Remark: + */ + +import java.util.HashMap; + +class CB_Nolcycle_a_00180_A1 { + CB_Nolcycle_a_00180_B1 b1_0; + CB_Nolcycle_a_00180_D1 d1_0; + int a; + int sum; + String strObjectName; + + CB_Nolcycle_a_00180_A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + b1_0.a + d1_0.a; + } +} + + +class CB_Nolcycle_a_00180_A2 { + CB_Nolcycle_a_00180_B2 b2_0; + int a; + int sum; + String strObjectName; + + CB_Nolcycle_a_00180_A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + b2_0.a; + } +} + + +class CB_Nolcycle_a_00180_A3 { + CB_Nolcycle_a_00180_B2 b2_0; + CB_Nolcycle_a_00180_C2 c2_0; + int a; + int sum; + String strObjectName; + + CB_Nolcycle_a_00180_A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + b2_0.a + c2_0.a; + } +} + +class CB_Nolcycle_a_00180_A4 { + CB_Nolcycle_a_00180_B3 b3_0; + CB_Nolcycle_a_00180_C2 c2_0; + int a; + int sum; + String strObjectName; + + CB_Nolcycle_a_00180_A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + + void add() { + sum = a + b3_0.a + c2_0.a; + } +} + + +class CB_Nolcycle_a_00180_B1 { + CB_Nolcycle_a_00180_D2 d2_0; + int a; + int sum; + String strObjectName; + + CB_Nolcycle_a_00180_B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + + void add() { + sum = a + d2_0.a; + } +} + + +class CB_Nolcycle_a_00180_B2 { + CB_Nolcycle_a_00180_C1 c1_0; + CB_Nolcycle_a_00180_D1 d1_0; + CB_Nolcycle_a_00180_D2 d2_0; + CB_Nolcycle_a_00180_D3 d3_0; + int a; + int sum; + String strObjectName; + + CB_Nolcycle_a_00180_B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } +} + + +class CB_Nolcycle_a_00180_B3 { + CB_Nolcycle_a_00180_C1 c1_0; + int a; + int sum; + String strObjectName; + + CB_Nolcycle_a_00180_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + + void add() { + sum = a + c1_0.a; + } +} + + +class CB_Nolcycle_a_00180_C1 { + CB_Nolcycle_a_00180_D1 d1_0; + int a; + int sum; + String strObjectName; + + CB_Nolcycle_a_00180_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + + void add() { + sum = a + d1_0.a; + } +} + +class CB_Nolcycle_a_00180_C2 { + CB_Nolcycle_a_00180_D2 d2_0; + CB_Nolcycle_a_00180_D3 d3_0; + int a; + int sum; + String strObjectName; + + CB_Nolcycle_a_00180_C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + + void add() { + sum = a + d2_0.a + d3_0.a; + } +} + + +class CB_Nolcycle_a_00180_D1 { + int a; + int sum; + String strObjectName; + + CB_Nolcycle_a_00180_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class CB_Nolcycle_a_00180_D2 { + int a; + int sum; + String strObjectName; + + CB_Nolcycle_a_00180_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +//该树有12个节点 +class CB_Nolcycle_a_00180_D3 { + int a; + int sum; + String strObjectName; + + CB_Nolcycle_a_00180_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class CB_Nolcycle_a_00180 { + public CB_Nolcycle_a_00180() { + CB_Nolcycle_a_00180_A1 a1_main = new CB_Nolcycle_a_00180_A1("a1_main"); + CB_Nolcycle_a_00180_A2 a2_main = new CB_Nolcycle_a_00180_A2("a2_main"); + CB_Nolcycle_a_00180_A3 a3_main = new CB_Nolcycle_a_00180_A3("a3_main"); + CB_Nolcycle_a_00180_A4 a4_main = new CB_Nolcycle_a_00180_A4("a4_main"); + a1_main.b1_0 = new CB_Nolcycle_a_00180_B1("b1_0"); + a1_main.d1_0 = new CB_Nolcycle_a_00180_D1("d1_0"); + a1_main.b1_0.d2_0 = new CB_Nolcycle_a_00180_D2("d2_0"); + + a2_main.b2_0 = new CB_Nolcycle_a_00180_B2("b2_0"); + a2_main.b2_0.c1_0 = new CB_Nolcycle_a_00180_C1("c1_0"); + a2_main.b2_0.d1_0 = new CB_Nolcycle_a_00180_D1("d1_0"); + a2_main.b2_0.d2_0 = new CB_Nolcycle_a_00180_D2("d2_0"); + a2_main.b2_0.d3_0 = new CB_Nolcycle_a_00180_D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = new CB_Nolcycle_a_00180_D1("d1_0"); + + a3_main.b2_0 = new CB_Nolcycle_a_00180_B2("b2_0"); + a3_main.b2_0.c1_0 = new CB_Nolcycle_a_00180_C1("c1_0"); + a3_main.b2_0.c1_0.d1_0 = new CB_Nolcycle_a_00180_D1("d1_0"); + a3_main.b2_0.d1_0 = new CB_Nolcycle_a_00180_D1("d1_0"); + a3_main.b2_0.d2_0 = new CB_Nolcycle_a_00180_D2("d2_0"); + a3_main.b2_0.d3_0 = new CB_Nolcycle_a_00180_D3("d3_0"); + + a3_main.c2_0 = new CB_Nolcycle_a_00180_C2("c2_0"); + a3_main.c2_0.d2_0 = new CB_Nolcycle_a_00180_D2("d2_0"); + a3_main.c2_0.d3_0 = new CB_Nolcycle_a_00180_D3("d3_0"); + + a4_main.b3_0 = new CB_Nolcycle_a_00180_B3("b3_0"); + a4_main.b3_0.c1_0 = new CB_Nolcycle_a_00180_C1("c1_0"); + a4_main.b3_0.c1_0.d1_0 = new CB_Nolcycle_a_00180_D1("d1_0"); + a4_main.c2_0 = new CB_Nolcycle_a_00180_C2("c2_0"); + a4_main.c2_0.d2_0 = new CB_Nolcycle_a_00180_D2("d2_0"); + a4_main.c2_0.d3_0 = new CB_Nolcycle_a_00180_D3("d3_0"); + } +} + +class CB_01_A1 { + static HashMap test1; + static + int a; + CB_01_A2 a2_0; + CB_01_A3 a3_0; + int sum; + String strObjectName; + + CB_01_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); + //System.out.println("A finalize"); + + CB_01.check = this; + + } +} + +class CB_01_A2 { + static CB_01_A1 a1_0; + volatile static HashMap test2; + CB_01_A3 a3_0; + int a; + int sum; + String strObjectName; + + CB_01_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + CB_01_A1.a + a3_0.a; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); + } +} + +class CB_01_A3 { + static CB_Nolcycle_a_00180[] test1; + CB_01_A1 a1_0; + CB_01_A2 a2_0; + int a; + int sum; + String strObjectName; + + CB_01_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + CB_01_A1.a + a2_0.a; + } +} + + +public class CB_01 { + public static CB_01_A1 check = null; + private static CB_01_A1 a1_main = null; + + private CB_01() { + a1_main = new CB_01_A1("a1_main"); + a1_main.a2_0 = new CB_01_A2("a2_0"); + CB_01_A2.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_01_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + } + + private static void test_CB_01(int times) { + CB_01_A1.test1 = new HashMap(); + CB_01_A2.test2 = new HashMap(); + for (int i = 0; i < times; i++) { + CB_01_A1.test1.put(i, new CB_Nolcycle_a_00180()); + CB_01_A2.test2.put(i, new CB_Nolcycle_a_00180()); + } + } + + private static void rc_testcase_main_wrapper() { + CB_01 cb01 = new CB_01(); + test_CB_01(10000); + check = a1_main; + try { + int result = CB_01.check.sum + CB_01.check.a2_0.sum + CB_01.check.a2_0.a3_0.sum + CB_01_A1.test1.size() + CB_01_A2.test2.size(); + if (result == 20918) + System.out.println("ExpectResult"); + } catch (NullPointerException n) { + System.out.println("ErrorResult"); + } + } + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0478-rc-StackScan-CB_02/CB_02.java b/test/testsuite/ouroboros/rc_test/RC0478-rc-StackScan-CB_02/CB_02.java new file mode 100644 index 0000000000000000000000000000000000000000..d3b87a7ac1d381476c6b2af43df602ef8ddffb32 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0478-rc-StackScan-CB_02/CB_02.java @@ -0,0 +1,147 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_CB02 + *- @TestCaseName: CB_02 + *- @TestCaseType: Function Testing for placementRCTest + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: Cycle is Cycle_a_0038.java;Node is String + *- @Brief:一组有环的对象,他们的field指向一个hashMap,里面装满了对象 + * -#step1: 创建一个环,环的类型参考了Cycle_a_0038.java; + * -#step2: 两个域test1和test2,里面装满了对象,对象格式为String类型,这样就构造了一个大对象。 + * -#step3: 验证结果正确,再用GCverify验证无内存泄漏。 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: CB_02.java + *- @ExecuteClass: CB_02 + *- @ExecuteArgs: + *- @Remark: + */ + +import java.util.HashMap; + +class CB_02_A1 { + static HashMap test1; + static + int a; + CB_02_A2 a2_0; + CB_02_A3 a3_0; + int sum; + String strObjectName; + + CB_02_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); + CB_02.check = this; + } +} + +class CB_02_A2 { + volatile static HashMap test2; + CB_02_A1 a1_0; + CB_02_A3 a3_0; + int a; + int sum; + String strObjectName; + + CB_02_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + CB_02_A1.a + a3_0.a; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); + } +} + +class CB_02_A3 { + CB_02_A1 a1_0; + CB_02_A2 a2_0; + int a; + int sum; + String strObjectName; + + CB_02_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + CB_02_A1.a + a2_0.a; + } +} + + +public class CB_02 { + public volatile static CB_02_A1 check = null; + private static CB_02_A1 a1_main = null; + + private CB_02() { + a1_main = new CB_02_A1("a1_main"); + a1_main.a2_0 = new CB_02_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_02_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + } + + private static void test_CB_02(int times) { + CB_02_A1.test1 = new HashMap(); + CB_02_A2.test2 = new HashMap(); + for (int i = 0; i < times; i++) { + CB_02_A1.test1.put(i, "Maple" + i); + CB_02_A2.test2.put(i, "Figo" + i); + } + } + + private static void rc_testcase_main_wrapper() { + CB_02 cb01 = new CB_02(); + test_CB_02(100000); + check = a1_main; + try { + int result = CB_02.check.sum + CB_02.check.a2_0.sum + CB_02.check.a2_0.a3_0.sum + CB_02_A1.test1.size() + CB_02_A2.test2.size(); + if (result == 200918) + System.out.println("ExpectResult"); + } catch (NullPointerException n) { + System.out.println("ErrorResult"); + } + + } + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0479-rc-StackScan-CB_03/CB_03.java b/test/testsuite/ouroboros/rc_test/RC0479-rc-StackScan-CB_03/CB_03.java new file mode 100644 index 0000000000000000000000000000000000000000..df2b8069f3c9f49b1bcd0d10ce8437bc2dc0e938 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0479-rc-StackScan-CB_03/CB_03.java @@ -0,0 +1,142 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_CB03 + *- @TestCaseName: CB_03 + *- @TestCaseType: Function Testing for placementRCTest + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: Cycle is Cycle_a_0038.java;Node is StringBuffer + *- @Brief:一组有环的对象,他们的field指向一个hashMap,里面装满了对象 + * -#step1: 创建一个环,环的类型参考了Cycle_a_0038.java; + * -#step2: 两个域test1和test2,里面装满了对象,对象格式为StringBuffer类型,这样就构造了一个大对象。 + * -#step3: 验证结果正确,再用GCverify验证无内存泄漏。 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: CB_03.java + *- @ExecuteClass: CB_03 + *- @ExecuteArgs: + *- @Remark: + */ + +import java.util.HashMap; + +class CB_03_A1 { + static HashMap test1; + static + int a; + CB_03_A2 a2_0; + CB_03_A3 a3_0; + int sum; + String strObjectName; + + CB_03_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); + CB_03.check = this; + } +} + +class CB_03_A2 { + CB_03_A1 a1_0; + CB_03_A3 a3_0; + volatile HashMap test2; + int a; + int sum; + String strObjectName; + + CB_03_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + CB_03_A1.a + a3_0.a; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); + } +} + +class CB_03_A3 { + CB_03_A1 a1_0; + CB_03_A2 a2_0; + int a; + int sum; + String strObjectName; + + CB_03_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + CB_03_A1.a + a2_0.a; + } +} + + +public class CB_03 { + public volatile static CB_03_A1 check = null; + private static CB_03_A1 a1_main = null; + + private CB_03() { + a1_main = new CB_03_A1("a1_main"); + a1_main.a2_0 = new CB_03_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_03_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + } + + private static void test_CB_03(int times) { + CB_03_A1.test1 = new HashMap(); + a1_main.a2_0.test2 = new HashMap(); + for (int i = 0; i < times; i++) { + CB_03_A1.test1.put(i, new StringBuffer("Maple test").append(i)); + a1_main.a2_0.test2.put(i, new StringBuffer("Figo test").append(i)); + } + } + + private static void rc_testcase_main_wrapper() { + CB_03 cb01 = new CB_03(); + test_CB_03(100000); + check = a1_main; + try { + int result = CB_03.check.sum + CB_03.check.a2_0.sum + CB_03.check.a2_0.a3_0.sum + CB_03_A1.test1.size() + check.a2_0.test2.size(); + if (result == 200918) + System.out.println("ExpectResult"); + } catch (NullPointerException n) { + System.out.println("ErrorResult"); + } + } + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0480-rc-StackScan-CB_04/CB_04.java b/test/testsuite/ouroboros/rc_test/RC0480-rc-StackScan-CB_04/CB_04.java new file mode 100644 index 0000000000000000000000000000000000000000..081645ceb03a82d48d99a289a7fe598da4294cf2 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0480-rc-StackScan-CB_04/CB_04.java @@ -0,0 +1,152 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_CB04 + *- @TestCaseName: CB_04 + *- @TestCaseType: Function Testing for placementRCTest + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: Cycle is Cycle_a_0038.java;Node is StringBuilder + *- @Brief:一组有环的对象,他们的field指向一个hashMap,里面装满了对象 + * -#step1: 创建一个环,环的类型参考了Cycle_a_0038.java; + * -#step2: 两个域test1和test2,里面装满了对象,对象格式为StringBuilder类型,这样就构造了一个大对象。 + * -#step3: 验证结果正确,再用GCverify验证无内存泄漏。 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: CB_04.java + *- @ExecuteClass: CB_04 + *- @ExecuteArgs: + *- @Remark: + */ + +import java.util.HashMap; + +class CB_04_A1 { + static HashMap test1; + static + int a; + CB_04_A2 a2_0; + CB_04_A3 a3_0; + int sum; + String strObjectName; + + CB_04_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); +// System.out.println("A finalize"); + + CB_04.check = this; + + } + +} + +class CB_04_A2 { + volatile static HashMap test2; + CB_04_A1 a1_0; + CB_04_A3 a3_0; + int a; + int sum; + String strObjectName; + + CB_04_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + + void add() { + sum = a + CB_04_A1.a + a3_0.a; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); +// System.out.println("B finalize"); + } +} + +class CB_04_A3 { + CB_04_A1 a1_0; + CB_04_A2 a2_0; + int a; + int sum; + String strObjectName; + + CB_04_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + + void add() { + sum = a + CB_04_A1.a + a2_0.a; + } +} + + +public class CB_04 { + public static CB_04_A1 a1_main = null; + public volatile static CB_04_A1 check = null; + + public CB_04() { + a1_main = new CB_04_A1("a1_main"); + a1_main.a2_0 = new CB_04_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_04_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + } + + public static void test_CB_04(int times) { + CB_04_A1.test1 = new HashMap(); + CB_04_A2.test2 = new HashMap(); + for (int i = 0; i < times; i++) { + CB_04_A1.test1.put(i, new StringBuilder().append(i)); + CB_04_A2.test2.put(i, new StringBuilder().append(times + i)); + } + } + + public static void rc_testcase_main_wrapper() { + CB_04 cb01 = new CB_04(); + test_CB_04(100000); + check = a1_main; + try { + int result = CB_04.check.sum + CB_04.check.a2_0.sum + CB_04.check.a2_0.a3_0.sum + CB_04_A1.test1.size() + CB_04_A2.test2.size(); + if (result == 200918) + System.out.println("ExpectResult"); + } catch (NullPointerException n) { + System.out.println("ErrorResult"); + } + } + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0481-rc-StackScan-CB_05/CB_05.java b/test/testsuite/ouroboros/rc_test/RC0481-rc-StackScan-CB_05/CB_05.java new file mode 100644 index 0000000000000000000000000000000000000000..a930d242cdc712af39598f487dcf287a4d81af09 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0481-rc-StackScan-CB_05/CB_05.java @@ -0,0 +1,145 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_CB05 + *- @TestCaseName: CB_05 + *- @TestCaseType: Function Testing for placementRCTest + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: Cycle is Cycle_a_0038.java;Node is SoftReference + *- @Brief:一组有环的对象,他们的field指向一个hashMap,里面装满了对象 + * -#step1: 创建一个环,环的类型参考了Cycle_a_0038.java; + * -#step2: 两个域test1和test2,里面装满了对象,对象格式为SoftReference类型,这样就构造了一个大对象。 + * -#step3: 验证结果正确,再用GCverify验证无内存泄漏。 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: CB_05.java + *- @ExecuteClass: CB_05 + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.SoftReference; +import java.util.HashMap; + +class CB_05_A1 { + static HashMap test1; + static + int a; + CB_05_A2 a2_0; + CB_05_A3 a3_0; + int sum; + String strObjectName; + + CB_05_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); + CB_05.check = this; + + } +} + +class CB_05_A2 { + volatile static HashMap test2; + CB_05_A1 a1_0; + CB_05_A3 a3_0; + int a; + int sum; + String strObjectName; + + CB_05_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + CB_05_A1.a + a3_0.a; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); + } +} + +class CB_05_A3 { + CB_05_A1 a1_0; + CB_05_A2 a2_0; + int a; + int sum; + String strObjectName; + + CB_05_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + CB_05_A1.a + a2_0.a; + } +} + + +public class CB_05 { + public volatile static CB_05_A1 check = null; + private static CB_05_A1 a1_main = null; + + private CB_05() { + a1_main = new CB_05_A1("a1_main"); + a1_main.a2_0 = new CB_05_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_05_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + } + + private static void test_CB_05(int times) { + CB_05_A1.test1 = new HashMap(); + CB_05_A2.test2 = new HashMap(); + for (int i = 0; i < times; i++) { + CB_05_A1.test1.put(i, new SoftReference<>("maple" + i)); + CB_05_A2.test2.put(i, new SoftReference<>("maple" + times + i)); + } + } + + private static void rc_testcase_main_wrapper() { + CB_05 cb01 = new CB_05(); + test_CB_05(10000); + check = a1_main; + try { + int result = CB_05.check.sum + CB_05.check.a2_0.sum + CB_05.check.a2_0.a3_0.sum + CB_05_A1.test1.size() + CB_05_A2.test2.size(); + if (result == 20918) + System.out.println("ExpectResult"); + } catch (NullPointerException n) { + System.out.println("ErrorResult"); + } + } + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0482-rc-StackScan-CB_06/CB_06.java b/test/testsuite/ouroboros/rc_test/RC0482-rc-StackScan-CB_06/CB_06.java new file mode 100644 index 0000000000000000000000000000000000000000..a1002faf03dfcde1014fe6e13d95e2142ed1d439 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0482-rc-StackScan-CB_06/CB_06.java @@ -0,0 +1,145 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_CB06 + *- @TestCaseName: CB_06 + *- @TestCaseType: Function Testing for placementRCTest + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: Cycle is Cycle_a_0038.java;Node is WeakReference + *- @Brief:一组有环的对象,他们的field指向一个hashMap,里面装满了对象 + * -#step1: 创建一个环,环的类型参考了Cycle_a_0038.java; + * -#step2: 两个域test1和test2,里面装满了对象,对象格式为WeakReference类型,这样就构造了一个大对象。 + * -#step3: 验证结果正确,再用GCverify验证无内存泄漏。 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: CB_06.java + *- @ExecuteClass: CB_06 + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.WeakReference; +import java.util.HashMap; + +class CB_06_A1 { + static HashMap test1; + static + int a; + CB_06_A2 a2_0; + CB_06_A3 a3_0; + int sum; + String strObjectName; + + CB_06_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); + CB_06.check = this; + } +} + +class CB_06_A2 { + volatile static HashMap test2; + CB_06_A1 a1_0; + CB_06_A3 a3_0; + int a; + int sum; + String strObjectName; + + CB_06_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + CB_06_A1.a + a3_0.a; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); + } +} + +class CB_06_A3 { + CB_06_A1 a1_0; + CB_06_A2 a2_0; + int a; + int sum; + String strObjectName; + + CB_06_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + CB_06_A1.a + a2_0.a; + } +} + + +public class CB_06 { + public volatile static CB_06_A1 check = null; + static String str; + private static CB_06_A1 a1_main = null; + + private CB_06() { + a1_main = new CB_06_A1("a1_main"); + a1_main.a2_0 = new CB_06_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_06_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + } + + private static void test_CB_06(int times) { + CB_06_A1.test1 = new HashMap(); + CB_06_A2.test2 = new HashMap(); + for (int i = 0; i < times; i++) { + CB_06_A1.test1.put(i, new WeakReference("Maple" + i)); + CB_06_A2.test2.put(i, new WeakReference("Figo" + i)); + } + } + + private static void rc_testcase_main_wrapper() { + CB_06 cb01 = new CB_06(); + test_CB_06(100000); + check = a1_main; + try { + int result = CB_06.check.sum + CB_06.check.a2_0.sum + CB_06.check.a2_0.a3_0.sum + CB_06_A1.test1.size() + CB_06_A2.test2.size(); + if (result == 200918) + System.out.println("ExpectResult"); + } catch (NullPointerException n) { + System.out.println("ErrorResult"); + } + } + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0483-rc-StackScan-CB_07/CB_07.java b/test/testsuite/ouroboros/rc_test/RC0483-rc-StackScan-CB_07/CB_07.java new file mode 100644 index 0000000000000000000000000000000000000000..480b550a222f65364c72a3a67b9d6f0013d98a3a --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0483-rc-StackScan-CB_07/CB_07.java @@ -0,0 +1,147 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_CB07 + *- @TestCaseName: CB_07 + *- @TestCaseType: Function Testing for placementRCTest + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: Cycle is Cycle_a_0038.java;Node is PhantomReference + *- @Brief:一组有环的对象,他们的field指向一个hashMap,里面装满了对象 + * -#step1: 创建一个环,环的类型参考了Cycle_a_0038.java; + * -#step2: 两个域test1和test2,里面装满了对象,对象格式为PhantomReference类型,这样就构造了一个大对象。 + * -#step3: 验证结果正确,再用GCverify验证无内存泄漏。 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: CB_07.java + *- @ExecuteClass: CB_07 + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.PhantomReference; +import java.lang.ref.ReferenceQueue; +import java.util.HashMap; + +class CB_07_A1 { + static HashMap test1; + static + int a; + CB_07_A2 a2_0; + CB_07_A3 a3_0; + int sum; + String strObjectName; + + CB_07_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); + CB_07.check = this; + } +} + +class CB_07_A2 { + volatile static HashMap test2; + CB_07_A1 a1_0; + CB_07_A3 a3_0; + int a; + int sum; + String strObjectName; + + CB_07_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + CB_07_A1.a + a3_0.a; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); + } +} + +class CB_07_A3 { + CB_07_A1 a1_0; + CB_07_A2 a2_0; + int a; + int sum; + String strObjectName; + + CB_07_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + CB_07_A1.a + a2_0.a; + } +} + + +public class CB_07 { + public volatile static CB_07_A1 check = null; + static ReferenceQueue rq = new ReferenceQueue(); + static String str; + private static CB_07_A1 a1_main = null; + + private CB_07() { + a1_main = new CB_07_A1("a1_main"); + a1_main.a2_0 = new CB_07_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_07_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + } + + private static void test_CB_07(int times) { + CB_07_A1.test1 = new HashMap(); + CB_07_A2.test2 = new HashMap(); + for (int i = 0; i < times; i++) { + CB_07_A1.test1.put(i, new PhantomReference<>("maple" + i, rq)); + CB_07_A2.test2.put(i, new PhantomReference<>("Figo" + times + i, rq)); + } + } + + private static void rc_testcase_main_wrapper() { + CB_07 cb01 = new CB_07(); + test_CB_07(100000); + check = a1_main; + try { + int result = CB_07.check.sum + CB_07.check.a2_0.sum + CB_07.check.a2_0.a3_0.sum + CB_07_A1.test1.size() + CB_07_A2.test2.size(); + if (result == 200918) + System.out.println("ExpectResult"); + } catch (NullPointerException n) { + System.out.println("ErrorResult"); + } + } + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0484-rc-StackScan-CB_08/CB_08.java b/test/testsuite/ouroboros/rc_test/RC0484-rc-StackScan-CB_08/CB_08.java new file mode 100644 index 0000000000000000000000000000000000000000..0b907d5f6df71ccddb431e4fa1bb1e10b0fc42fe --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0484-rc-StackScan-CB_08/CB_08.java @@ -0,0 +1,148 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_CB08 + *- @TestCaseName: CB_08 + *- @TestCaseType: Function Testing for placementRCTest + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: Cycle is Cycle_a_0038.java;Node is OutOfMemoryError + *- @Brief:一组有环的对象,他们的field指向一个hashMap,里面装满了对象 + * -#step1: 创建一个环,环的类型参考了Cycle_a_0038.java; + * -#step2: 两个域test1和test2,里面装满了对象,对象格式为OutOfMemoryError类型,这样就构造了一个大对象。 + * -#step3: 验证结果正确,再用GCverify验证无内存泄漏。 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: CB_08.java + *- @ExecuteClass: CB_08 + *- @ExecuteArgs: + *- @Remark: + */ + +import java.util.HashMap; + +class CB_08_A1 { + static HashMap test1; + static + int a; + CB_08_A2 a2_0; + CB_08_A3 a3_0; + int sum; + String strObjectName; + + CB_08_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); + CB_08.check = this; + } + +} + +class CB_08_A2 { + volatile static HashMap test2; + CB_08_A1 a1_0; + CB_08_A3 a3_0; + int a; + int sum; + String strObjectName; + + CB_08_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + CB_08_A1.a + a3_0.a; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); + } +} + +class CB_08_A3 { + CB_08_A1 a1_0; + CB_08_A2 a2_0; + int a; + int sum; + String strObjectName; + + CB_08_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + CB_08_A1.a + a2_0.a; + } +} + + +public class CB_08 { + public volatile static CB_08_A1 check = null; + private static CB_08_A1 a1_main = null; + private volatile static OutOfMemoryError test1; + private static OutOfMemoryError test2; + + private CB_08() { + a1_main = new CB_08_A1("a1_main"); + a1_main.a2_0 = new CB_08_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_08_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + } + + private static void test_CB_08(int times) { + CB_08_A1.test1 = new HashMap(); + CB_08_A2.test2 = new HashMap(); + for (int i = 0; i < times; i++) { + test1 = new OutOfMemoryError(); + CB_08_A1.test1.put(i, test1); + test2 = new OutOfMemoryError(); + CB_08_A2.test2.put(i, test2); + } + } + + private static void rc_testcase_main_wrapper() { + CB_08 cb01 = new CB_08(); + test_CB_08(100000); + check = a1_main; + try { + int result = CB_08.check.sum + CB_08.check.a2_0.sum + CB_08.check.a2_0.a3_0.sum + CB_08_A1.test1.size() + CB_08_A2.test2.size(); + if (result == 200918) + System.out.println("ExpectResult"); + } catch (NullPointerException n) { + System.out.println("ErrorResult"); + } + } + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0485-rc-StackScan-CB_09/CB_09.java b/test/testsuite/ouroboros/rc_test/RC0485-rc-StackScan-CB_09/CB_09.java new file mode 100644 index 0000000000000000000000000000000000000000..a810103d05b5dc6ca890e8ed371a8ac7b95d1e1c --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0485-rc-StackScan-CB_09/CB_09.java @@ -0,0 +1,146 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_CB09 + *- @TestCaseName: CB_09 + *- @TestCaseType: Function Testing for placementRCTest + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: Cycle is Cycle_a_0038.java;Node is ClassLoader + *- @Brief:一组有环的对象,他们的field指向一个hashMap,里面装满了对象 + * -#step1: 创建一个环,环的类型参考了Cycle_a_0038.java; + * -#step2: 两个域test1和test2,里面装满了对象,对象格式为ClassLoader类型,这样就构造了一个大对象。 + * -#step3: 验证结果正确,再用GCverify验证无内存泄漏。 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: CB_09.java + *- @ExecuteClass: CB_09 + *- @ExecuteArgs: + *- @Remark: + */ + +import java.util.HashMap; + +class CB_09_A1 { + static HashMap test1; + static + int a; + CB_09_A2 a2_0; + CB_09_A3 a3_0; + int sum; + String strObjectName; + + CB_09_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); + CB_09.check = this; + } +} + +class CB_09_A2 { + volatile static HashMap test2; + CB_09_A1 a1_0; + CB_09_A3 a3_0; + int a; + int sum; + String strObjectName; + + CB_09_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + CB_09_A1.a + a3_0.a; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); + } +} + +class CB_09_A3 { + CB_09_A1 a1_0; + CB_09_A2 a2_0; + int a; + int sum; + String strObjectName; + + CB_09_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + CB_09_A1.a + a2_0.a; + } +} + +public class CB_09 { + public static CB_09_A1 a1_main = null; + public volatile static CB_09_A1 check = null; + public volatile static ClassLoader test1; + public static ClassLoader test2; + + public CB_09() { + a1_main = new CB_09_A1("a1_main"); + a1_main.a2_0 = new CB_09_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_09_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + } + + public static void test_CB_09(int times) { + CB_09_A1.test1 = new HashMap(); + CB_09_A2.test2 = new HashMap(); + for (int i = 0; i < times; i++) { + test1 = CB_09_A1.class.getClassLoader(); + CB_09_A1.test1.put(i, test1); + test2 = CB_09_A1.class.getClassLoader(); + CB_09_A2.test2.put(i, test2); + } + } + + public static void rc_testcase_main_wrapper() { + CB_09 cb01 = new CB_09(); + test_CB_09(100000); + check = a1_main; + try { + int result = CB_09.check.sum + CB_09.check.a2_0.sum + CB_09.check.a2_0.a3_0.sum; + if (result == 918) + System.out.println("ExpectResult"); + } catch (NullPointerException n) { + System.out.println("ErrorResult"); + } + } + + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0486-rc-StackScan-CB_Thread_01/CB_Thread_01.java b/test/testsuite/ouroboros/rc_test/RC0486-rc-StackScan-CB_Thread_01/CB_Thread_01.java new file mode 100644 index 0000000000000000000000000000000000000000..6d73061f7476adcb94fb24194b941dc6f4f0003b --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0486-rc-StackScan-CB_Thread_01/CB_Thread_01.java @@ -0,0 +1,419 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_CB_Thread_01 + *- @TestCaseName: CB_Thread_01 + *- @TestCaseType: Function Testing for placementRCTest + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: MultiThreadMode:Cycle is Cycle_a_0038.java;Nocycle is Nocycle_00180.java + *- @Brief:一组有环的对象,他们的field指向一个hashMap,里面装满了对象 + * -#step1: 创建一个环,环的类型参考了Cycle_a_0038.java; + * -#step2: 两个域test1和test2,里面装满了对象,对象格式参考Nocycle_00180.java,这样就构造了一个大对象。 + * -#step3: 验证结果正确,再用GCverify验证无内存泄漏。 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: CB_Thread_01.java + *- @ExecuteClass: CB_Thread_01 + *- @ExecuteArgs: + */ + +import java.util.HashMap; + +class CB_Nocycle_a_00180_A1 { + CB_Nocycle_a_00180_B1 b1_0; + CB_Nocycle_a_00180_D1 d1_0; + int a; + int sum; + String strObjectName; + + CB_Nocycle_a_00180_A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + b1_0.a + d1_0.a; + } +} + +class CB_Nocycle_a_00180_A2 { + CB_Nocycle_a_00180_B2 b2_0; + int a; + int sum; + String strObjectName; + + CB_Nocycle_a_00180_A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + b2_0.a; + } +} + +class CB_Nocycle_a_00180_A3 { + CB_Nocycle_a_00180_B2 b2_0; + CB_Nocycle_a_00180_C2 c2_0; + int a; + int sum; + String strObjectName; + + CB_Nocycle_a_00180_A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + b2_0.a + c2_0.a; + } +} + +class CB_Nocycle_a_00180_A4 { + CB_Nocycle_a_00180_B3 b3_0; + CB_Nocycle_a_00180_C2 c2_0; + int a; + int sum; + String strObjectName; + + CB_Nocycle_a_00180_A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + b3_0.a + c2_0.a; + } +} + +class CB_Nocycle_a_00180_B1 { + CB_Nocycle_a_00180_D2 d2_0; + int a; + int sum; + String strObjectName; + + CB_Nocycle_a_00180_B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + d2_0.a; + } +} + +class CB_Nocycle_a_00180_B2 { + CB_Nocycle_a_00180_C1 c1_0; + CB_Nocycle_a_00180_D1 d1_0; + CB_Nocycle_a_00180_D2 d2_0; + CB_Nocycle_a_00180_D3 d3_0; + int a; + int sum; + String strObjectName; + + CB_Nocycle_a_00180_B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } +} + +class CB_Nocycle_a_00180_B3 { + CB_Nocycle_a_00180_C1 c1_0; + int a; + int sum; + String strObjectName; + + CB_Nocycle_a_00180_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + c1_0.a; + } +} + +class CB_Nocycle_a_00180_C1 { + CB_Nocycle_a_00180_D1 d1_0; + int a; + int sum; + String strObjectName; + + CB_Nocycle_a_00180_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + d1_0.a; + } +} + +class CB_Nocycle_a_00180_C2 { + CB_Nocycle_a_00180_D2 d2_0; + CB_Nocycle_a_00180_D3 d3_0; + int a; + int sum; + String strObjectName; + + CB_Nocycle_a_00180_C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + d2_0.a + d3_0.a; + } +} + +class CB_Nocycle_a_00180_D1 { + int a; + int sum; + String strObjectName; + + CB_Nocycle_a_00180_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a; + } +} + +class CB_Nocycle_a_00180_D2 { + int a; + int sum; + String strObjectName; + + CB_Nocycle_a_00180_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a; + } +} + +// 该树有12个节点 +class CB_Nocycle_a_00180_D3 { + int a; + int sum; + String strObjectName; + + CB_Nocycle_a_00180_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; + // System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class CB_Nocycle_a_00180 { + public CB_Nocycle_a_00180() { + CB_Nocycle_a_00180_A1 a1_main = new CB_Nocycle_a_00180_A1("a1_main"); + CB_Nocycle_a_00180_A2 a2_main = new CB_Nocycle_a_00180_A2("a2_main"); + CB_Nocycle_a_00180_A3 a3_main = new CB_Nocycle_a_00180_A3("a3_main"); + CB_Nocycle_a_00180_A4 a4_main = new CB_Nocycle_a_00180_A4("a4_main"); + a1_main.b1_0 = new CB_Nocycle_a_00180_B1("b1_0"); + a1_main.d1_0 = new CB_Nocycle_a_00180_D1("d1_0"); + a1_main.b1_0.d2_0 = new CB_Nocycle_a_00180_D2("d2_0"); + a2_main.b2_0 = new CB_Nocycle_a_00180_B2("b2_0"); + a2_main.b2_0.c1_0 = new CB_Nocycle_a_00180_C1("c1_0"); + a2_main.b2_0.d1_0 = new CB_Nocycle_a_00180_D1("d1_0"); + a2_main.b2_0.d2_0 = new CB_Nocycle_a_00180_D2("d2_0"); + a2_main.b2_0.d3_0 = new CB_Nocycle_a_00180_D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = new CB_Nocycle_a_00180_D1("d1_0"); + a3_main.b2_0 = new CB_Nocycle_a_00180_B2("b2_0"); + a3_main.b2_0.c1_0 = new CB_Nocycle_a_00180_C1("c1_0"); + a3_main.b2_0.c1_0.d1_0 = new CB_Nocycle_a_00180_D1("d1_0"); + a3_main.b2_0.d1_0 = new CB_Nocycle_a_00180_D1("d1_0"); + a3_main.b2_0.d2_0 = new CB_Nocycle_a_00180_D2("d2_0"); + a3_main.b2_0.d3_0 = new CB_Nocycle_a_00180_D3("d3_0"); + a3_main.c2_0 = new CB_Nocycle_a_00180_C2("c2_0"); + a3_main.c2_0.d2_0 = new CB_Nocycle_a_00180_D2("d2_0"); + a3_main.c2_0.d3_0 = new CB_Nocycle_a_00180_D3("d3_0"); + + a4_main.b3_0 = new CB_Nocycle_a_00180_B3("b3_0"); + a4_main.b3_0.c1_0 = new CB_Nocycle_a_00180_C1("c1_0"); + a4_main.b3_0.c1_0.d1_0 = new CB_Nocycle_a_00180_D1("d1_0"); + a4_main.c2_0 = new CB_Nocycle_a_00180_C2("c2_0"); + a4_main.c2_0.d2_0 = new CB_Nocycle_a_00180_D2("d2_0"); + a4_main.c2_0.d3_0 = new CB_Nocycle_a_00180_D3("d3_0"); + } +} + +class CB_Thread_01_A1 { + static HashMap test1; + static + int a; + CB_Thread_01_A2 a2_0; + CB_Thread_01_A3 a3_0; + int sum; + String strObjectName; + + CB_Thread_01_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + // System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); + // System.out.println("A finalize"); + + CB_Thread_01.check = this; + } +} + +class CB_Thread_01_A2 { + volatile static HashMap test2; + CB_Thread_01_A1 a1_0; + CB_Thread_01_A3 a3_0; + int a; + int sum; + String strObjectName; + + CB_Thread_01_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + CB_Thread_01_A1.a + a3_0.a; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); +// System.out.println("B finalize"); + } +} + +class CB_Thread_01_A3 { + static CB_Nocycle_a_00180[] test1; + CB_Thread_01_A1 a1_0; + CB_Thread_01_A2 a2_0; + int a; + int sum; + String strObjectName; + + CB_Thread_01_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + CB_Thread_01_A1.a + a2_0.a; + } +} + +class CB_Thread_01_test extends Thread { + private static CB_Thread_01_A1 a1_main = null; + + private static void test_CB_Thread_01(int times) { + CB_Thread_01_A1.test1 = new HashMap(); + CB_Thread_01_A2.test2 = new HashMap(); + for (int i = 0; i < times; i++) { + CB_Thread_01_A1.test1.put(i, new CB_Nocycle_a_00180()); + CB_Thread_01_A2.test2.put(i, new CB_Nocycle_a_00180()); + } + } + + public void run() { + a1_main = new CB_Thread_01_A1("a1_main"); + a1_main.a2_0 = new CB_Thread_01_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_Thread_01_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + test_CB_Thread_01(10000); + a1_main = null; + CB_Thread_01.check = null; + } +} + +public class CB_Thread_01 { + public static CB_Thread_01_A1 check = null; + private static CB_Thread_01_A1 a1_main = null; + private static CB_Thread_01_test cbtest1; + private volatile static CB_Thread_01_test cbtest2; + + public static void main(String[] args) { + a1_main = new CB_Thread_01_A1("a1_main"); + a1_main.a2_0 = new CB_Thread_01_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_Thread_01_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main = null; + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + + try { + int result = CB_Thread_01.check.sum + CB_Thread_01.check.a2_0.sum + CB_Thread_01.check.a2_0.a3_0.sum; + if (result == 918) { + System.out.println("ExpectResult"); + } + } catch (NullPointerException n) { + System.out.println("ErrorResult"); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0487-rc-StackScan-CB_Thread_02/CB_Thread_02.java b/test/testsuite/ouroboros/rc_test/RC0487-rc-StackScan-CB_Thread_02/CB_Thread_02.java new file mode 100644 index 0000000000000000000000000000000000000000..78cb667088b077d4f719e1f14754e504ff155355 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0487-rc-StackScan-CB_Thread_02/CB_Thread_02.java @@ -0,0 +1,152 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_CB_Thread_02 + *- @TestCaseName: CB_Thread_02 + *- @TestCaseType: Function Testing for placementRCTest + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: MultiThreadMode:Cycle is Cycle_a_0038.java;Nocycle is String + *- @Brief:一组有环的对象,他们的field指向一个hashMap,里面装满了对象 + * -#step1: 创建一个环,环的类型参考了Cycle_a_0038.java; + * -#step2: 两个域test1和test2,里面装满了对象,对象格式参考String,这样就构造了一个大对象。 + * -#step3: 验证结果正确,再用GCverify验证无内存泄漏。 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: CB_Thread_02.java + *- @ExecuteClass: CB_Thread_02 + *- @ExecuteArgs: + */ + +import java.util.HashMap; + +class CB_Thread_02_A1 { + static HashMap test1; + static + int a; + CB_Thread_02_A2 a2_0; + CB_Thread_02_A3 a3_0; + int sum; + String strObjectName; + + CB_Thread_02_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a2_0.a + a3_0.a; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); + CB_Thread_02_test.check = this; + } +} + +class CB_Thread_02_A2 { + volatile static HashMap test2; + CB_Thread_02_A1 a1_0; + CB_Thread_02_A3 a3_0; + int a; + int sum; + String strObjectName; + + CB_Thread_02_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + CB_Thread_02_A1.a + a3_0.a; + } + + public void finalize() throws Throwable { + super.finalize(); + } +} + +class CB_Thread_02_A3 { + CB_Thread_02_A1 a1_0; + CB_Thread_02_A2 a2_0; + int a; + int sum; + String strObjectName; + + CB_Thread_02_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + CB_Thread_02_A1.a + a2_0.a; + } +} + +class CB_Thread_02_test extends Thread { + public volatile static CB_Thread_02_A1 check = null; + private static CB_Thread_02_A1 a1_main = null; + + private static void test_CB_Thread_02(int times) { + CB_Thread_02_A1.test1 = new HashMap(); + CB_Thread_02_A2.test2 = new HashMap(); + for (int i = 0; i < times; i++) { + CB_Thread_02_A1.test1.put(i, "Maple" + i); + CB_Thread_02_A2.test2.put(i, "Figo" + i); + } + } + + public void run() { + a1_main = new CB_Thread_02_A1("a1_main"); + a1_main.a2_0 = new CB_Thread_02_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_Thread_02_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + test_CB_Thread_02(10000); + a1_main = null; + CB_Thread_02_test.check = null; + } +} + +public class CB_Thread_02 { + private static CB_Thread_02_A1 a1_main = null; + + public static void main(String[] args) { + a1_main = new CB_Thread_02_A1("a1_main"); + a1_main.a2_0 = new CB_Thread_02_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_Thread_02_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main = null; + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + + try { + int result = CB_Thread_02_test.check.sum + CB_Thread_02_test.check.a2_0.sum + + CB_Thread_02_test.check.a2_0.a3_0.sum; + if (result == 918) { + System.out.println("ExpectResult"); + } + } catch (NullPointerException n) { + System.out.println("ErrorResult"); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0488-rc-StackScan-CP_Thread_03/CP_Thread_03.java b/test/testsuite/ouroboros/rc_test/RC0488-rc-StackScan-CP_Thread_03/CP_Thread_03.java new file mode 100644 index 0000000000000000000000000000000000000000..469e61a13de0c534e53e07e07448d4f303b7f0ee --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0488-rc-StackScan-CP_Thread_03/CP_Thread_03.java @@ -0,0 +1,90 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_CP_Thread_03 + *- @TestCaseName: CP_Thread_03 + *- @TestCaseType: Function Testing for placementRCTest + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: MultiThreadMode:Cycle is Cycle_a_0038.java;Nocycle is StringBuffer + *- @Brief:一组有环的对象,他们的field指向一个hashMap,里面装满了对象 + * -#step1: 创建一个环,环的类型参考了Cycle_a_0038.java; + * -#step2: 两个域test1和test2,里面装满了对象,对象格式参考StringBuffer,这样就构造了一个大对象。 + * -#step3: 验证结果正确,再用GCverify验证无内存泄漏。 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: CP_Thread_03.java + *- @ExecuteClass: CP_Thread_03 + *- @ExecuteArgs: + *- @Remark: + */ + +class CP_Thread_03_A1 { + static StringBuffer[] test1; + static + int a; + CP_Thread_03_A1 a2_0; + int sum; + String strObjectName; + + CP_Thread_03_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a; + } +} + +class CP_Thread_03_test extends Thread { + private static CP_Thread_03_A1 a1_main = null; + private volatile static CP_Thread_03_A1 a2 = null; + private volatile static StringBuffer test1; + private static StringBuffer test2; + + private static void test_CP_Thread_03_A1(int times) { + CP_Thread_03_A1.test1 = new StringBuffer[times]; + for (int i = 0; i < times; i++) { + test1 = new StringBuffer("maple" + i); + CP_Thread_03_A1.test1[i] = test1; + } + } + + private static void test_CP_Thread_03_A2(int times) { + CP_Thread_03_A1.test1 = new StringBuffer[times]; + for (int i = 0; i < times; i++) { + test2 = new StringBuffer("maple" + times + i); + CP_Thread_03_A1.test1[i] = test2; + } + } + + public void run() { + a1_main = new CP_Thread_03_A1("a1_main"); + a2 = new CP_Thread_03_A1("a2_0"); + a1_main.a2_0 = a2; + a1_main.a2_0.a2_0 = a2; + a1_main.add(); + a1_main.a2_0.add(); + test_CP_Thread_03_A1(10000); + test_CP_Thread_03_A2(10000); + int result = a1_main.sum + a1_main.a2_0.sum; + if (result == 404) + System.out.println("ExpectResult"); + } +} + +public class CP_Thread_03 { + private static CP_Thread_03_A1 a1_main = null; + private volatile static CP_Thread_03_A1 a2 = null; + + public static void main(String[] args) { + CP_Thread_03_test cptest1 = new CP_Thread_03_test(); + cptest1.run(); + CP_Thread_03_test cptest2 = new CP_Thread_03_test(); + cptest2.run(); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0489-rc-StackScan-CP_Thread_04/CP_Thread_04.java b/test/testsuite/ouroboros/rc_test/RC0489-rc-StackScan-CP_Thread_04/CP_Thread_04.java new file mode 100644 index 0000000000000000000000000000000000000000..ab0641378c70d150ed3241151501370d379920ce --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0489-rc-StackScan-CP_Thread_04/CP_Thread_04.java @@ -0,0 +1,90 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_CP_Thread_04 + *- @TestCaseName: CP_Thread_04 + *- @TestCaseType: Function Testing for placementRCTest + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: MultiThreadMode:Cycle is Cycle_a_0038.java;Nocycle is StringBuffer + *- @Brief:一组有环的对象,他们的field指向一个hashMap,里面装满了对象 + * -#step1: 创建一个环,环的类型参考了Cycle_a_0038.java; + * -#step2: 两个域test1和test2,里面装满了对象,对象格式参考StringBuffer,这样就构造了一个大对象。 + * -#step3: 验证结果正确,再用GCverify验证无内存泄漏。 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: CP_Thread_04.java + *- @ExecuteClass: CP_Thread_04 + *- @ExecuteArgs: + *- @Remark: + */ + +class CP_Thread_04_A1 { + static StringBuilder[] test1; + static + int a; + CP_Thread_04_A1 a2_0; + int sum; + String strObjectName; + + CP_Thread_04_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a; + } +} + +class CP_Thread_04_test extends Thread { + private static CP_Thread_04_A1 a1_main = null; + private volatile static CP_Thread_04_A1 a2 = null; + private volatile static StringBuilder test1; + private static StringBuilder test2; + + private static void test_CP_Thread_04_A1(int times) { + CP_Thread_04_A1.test1 = new StringBuilder[times]; + for (int i = 0; i < times; i++) { + test1 = new StringBuilder("maple" + i); + CP_Thread_04_A1.test1[i] = test1; + } + } + + private static void test_CP_Thread_04_A2(int times) { + CP_Thread_04_A1.test1 = new StringBuilder[times]; + for (int i = 0; i < times; i++) { + test2 = new StringBuilder("maple" + times + i); + CP_Thread_04_A1.test1[i] = test2; + } + } + + public void run() { + a1_main = new CP_Thread_04_A1("a1_main"); + a2 = new CP_Thread_04_A1("a2_0"); + a1_main.a2_0 = a2; + a1_main.a2_0.a2_0 = a2; + a1_main.add(); + a1_main.a2_0.add(); + test_CP_Thread_04_A1(10000); + test_CP_Thread_04_A2(10000); + int result = a1_main.sum + a1_main.a2_0.sum; + if (result == 404) + System.out.println("ExpectResult"); + } +} + +public class CP_Thread_04 { + private static CP_Thread_04_A1 a1_main = null; + private static CP_Thread_04_A1 a2 = null; + + public static void main(String[] args) { + CP_Thread_04_test cptest1 = new CP_Thread_04_test(); + cptest1.run(); + CP_Thread_04_test cptest2 = new CP_Thread_04_test(); + cptest2.run(); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0490-rc-StackScan-CP_Thread_05/CP_Thread_05.java b/test/testsuite/ouroboros/rc_test/RC0490-rc-StackScan-CP_Thread_05/CP_Thread_05.java new file mode 100644 index 0000000000000000000000000000000000000000..56b4943169116bcd89e94a987d98391c99b12645 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0490-rc-StackScan-CP_Thread_05/CP_Thread_05.java @@ -0,0 +1,96 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_CP_Thread_05 + *- @TestCaseName: CP_Thread_05 + *- @TestCaseType: Function Testing for placementRCTest + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: MultiThreadMode:Cycle is Cycle_a_0038.java;Nocycle is SoftReference + *- @Brief:一组有环的对象,他们的field指向一个hashMap,里面装满了对象 + * -#step1: 创建一个环,环的类型参考了Cycle_a_0038.java; + * -#step2: 两个域test1和test2,里面装满了对象,对象格式参考SoftReference,这样就构造了一个大对象。 + * -#step3: 验证结果正确,再用GCverify验证无内存泄漏。 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: CP_Thread_05.java + *- @ExecuteClass: CP_Thread_05 + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.SoftReference; + +class CP_Thread_05_A1 { + static SoftReference[] test1; + static + int a; + CP_Thread_05_A1 a2_0; + int sum; + String strObjectName; + + CP_Thread_05_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a; + } +} + +class CP_Thread_05_test extends Thread { + static String str; + private static CP_Thread_05_A1 a1_main = null; + private volatile static CP_Thread_05_A1 a2 = null; + private volatile static SoftReference test1; + private static SoftReference test2; + + private static void test_CP_Thread_05_A1(int times) { + CP_Thread_05_A1.test1 = new SoftReference[times]; + for (int i = 0; i < times; i++) { + str = "maple" + i; + test1 = new SoftReference<>(str); + CP_Thread_05_A1.test1[i] = test1; + } + } + + private static void test_CP_Thread_05_A2(int times) { + CP_Thread_05_A1.test1 = new SoftReference[times]; + for (int i = 0; i < times; i++) { + test2 = new SoftReference<>("maple" + times + i); + CP_Thread_05_A1.test1[i] = test2; + } + } + + public void run() { + a1_main = new CP_Thread_05_A1("a1_main"); + a2 = new CP_Thread_05_A1("a2_0"); + a1_main.a2_0 = a2; + a1_main.a2_0.a2_0 = a2; + + a1_main.add(); + a1_main.a2_0.add(); + test_CP_Thread_05_A1(10000); + test_CP_Thread_05_A2(10000); + int result = a1_main.sum + a1_main.a2_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 404) + System.out.println("ExpectResult"); + } +} + +public class CP_Thread_05 { + private static CP_Thread_05_A1 a1_main = null; + private static CP_Thread_05_A1 a2 = null; + + public static void main(String[] args) { + CP_Thread_05_test cptest1 = new CP_Thread_05_test(); + cptest1.run(); + CP_Thread_05_test cptest2 = new CP_Thread_05_test(); + cptest2.run(); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0491-rc-StackScan-CP_Thread_06/CP_Thread_06.java b/test/testsuite/ouroboros/rc_test/RC0491-rc-StackScan-CP_Thread_06/CP_Thread_06.java new file mode 100644 index 0000000000000000000000000000000000000000..ae66336159e9d0050cf26bf2bb0997f0d87af159 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0491-rc-StackScan-CP_Thread_06/CP_Thread_06.java @@ -0,0 +1,96 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_CP_Thread_06 + *- @TestCaseName: CP_Thread_06 + *- @TestCaseType: Function Testing for placementRCTest + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: MultiThreadMode:Cycle is Cycle_a_0038.java;Nocycle is WeakReference + *- @Brief:一组有环的对象,他们的field指向一个hashMap,里面装满了对象 + * -#step1: 创建一个环,环的类型参考了Cycle_a_0038.java; + * -#step2: 两个域test1和test2,里面装满了对象,对象格式参考WeakReference,这样就构造了一个大对象。 + * -#step3: 验证结果正确,再用GCverify验证无内存泄漏。 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: CP_Thread_06.java + *- @ExecuteClass: CP_Thread_06 + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.WeakReference; + +class CP_Thread_06_A1 { + static WeakReference[] test1; + static + int a; + CP_Thread_06_A1 a2_0; + int sum; + String strObjectName; + + CP_Thread_06_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a; + } +} + +class CP_Thread_06_test extends Thread { + static String str; + private static CP_Thread_06_A1 a1_main = null; + private volatile static CP_Thread_06_A1 a2 = null; + private volatile static WeakReference test1; + private static WeakReference test2; + + private static void test_CP_Thread_06_A1(int times) { + CP_Thread_06_A1.test1 = new WeakReference[times]; + for (int i = 0; i < times; i++) { + str = "maple" + i; + test1 = new WeakReference<>(str); + CP_Thread_06_A1.test1[i] = test1; + } + } + + private static void test_CP_Thread_06_A2(int times) { + CP_Thread_06_A1.test1 = new WeakReference[times]; + for (int i = 0; i < times; i++) { + test2 = new WeakReference<>("maple" + times + i); + CP_Thread_06_A1.test1[i] = test2; + } + } + + public void run() { + a1_main = new CP_Thread_06_A1("a1_main"); + a2 = new CP_Thread_06_A1("a2_0"); + a1_main.a2_0 = a2; + a1_main.a2_0.a2_0 = a2; + + a1_main.add(); + a1_main.a2_0.add(); + test_CP_Thread_06_A1(10000); + test_CP_Thread_06_A2(10000); + int result = a1_main.sum + a1_main.a2_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 404) + System.out.println("ExpectResult"); + } +} + +public class CP_Thread_06 { + private static CP_Thread_06_A1 a1_main = null; + private static CP_Thread_06_A1 a2 = null; + + public static void main(String[] args) { + CP_Thread_06_test cptest1 = new CP_Thread_06_test(); + cptest1.run(); + CP_Thread_06_test cptest2 = new CP_Thread_06_test(); + cptest2.run(); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0492-rc-StackScan-CP_Thread_07/CP_Thread_07.java b/test/testsuite/ouroboros/rc_test/RC0492-rc-StackScan-CP_Thread_07/CP_Thread_07.java new file mode 100644 index 0000000000000000000000000000000000000000..534a1e6d2cf44023162c747fa664aa6451afabc6 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0492-rc-StackScan-CP_Thread_07/CP_Thread_07.java @@ -0,0 +1,96 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_CP_Thread_07 + *- @TestCaseName: CP_Thread_07 + *- @TestCaseType: Function Testing for placementRCTest + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: MultiThreadMode:Cycle is Cycle_a_0038.java;Nocycle is PhantomReference + *- @Brief:一组有环的对象,他们的field指向一个hashMap,里面装满了对象 + * -#step1: 创建一个环,环的类型参考了Cycle_a_0038.java; + * -#step2: 两个域test1和test2,里面装满了对象,对象格式参考PhantomReference,这样就构造了一个大对象。 + * -#step3: 验证结果正确,再用GCverify验证无内存泄漏。 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: CP_Thread_07.java + *- @ExecuteClass: CP_Thread_07 + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.PhantomReference; +import java.lang.ref.ReferenceQueue; + +class CP_Thread_07_A1 { + static PhantomReference[] test1; + static + int a; + CP_Thread_07_A1 a2_0; + int sum; + String strObjectName; + + CP_Thread_07_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a; + } +} + +class CP_Thread_07_test extends Thread { + static ReferenceQueue rq = new ReferenceQueue(); + static String str; + private static CP_Thread_07_A1 a1_main = null; + private volatile static CP_Thread_07_A1 a2 = null; + + private static void test_CP_Thread_07_A1(int times) { + CP_Thread_07_A1.test1 = new PhantomReference[times]; + for (int i = 0; i < times; i++) { + str = "maple" + i; + PhantomReference temp = new PhantomReference<>(str, rq); + CP_Thread_07_A1.test1[i] = temp; + } + } + + private static void test_CP_Thread_07_A2(int times) { + CP_Thread_07_A1.test1 = new PhantomReference[times]; + for (int i = 0; i < times; i++) { + PhantomReference temp = new PhantomReference<>(str + times + i, rq); + CP_Thread_07_A1.test1[i] = temp; + } + } + + public void run() { + a1_main = new CP_Thread_07_A1("a1_main"); + a2 = new CP_Thread_07_A1("a2_0"); + a1_main.a2_0 = a2; + a1_main.a2_0.a2_0 = a2; + + a1_main.add(); + a1_main.a2_0.add(); + test_CP_Thread_07_A1(10000); + test_CP_Thread_07_A2(10000); + int result = a1_main.sum + a1_main.a2_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 404) + System.out.println("ExpectResult"); + } +} + +public class CP_Thread_07 { + private static CP_Thread_07_A1 a1_main = null; + private static CP_Thread_07_A1 a2 = null; + + public static void main(String[] args) { + CP_Thread_07_test cptest1 = new CP_Thread_07_test(); + cptest1.run(); + CP_Thread_07_test cptest2 = new CP_Thread_07_test(); + cptest2.run(); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0493-rc-StackScan-CP_Thread_08/CP_Thread_08.java b/test/testsuite/ouroboros/rc_test/RC0493-rc-StackScan-CP_Thread_08/CP_Thread_08.java new file mode 100644 index 0000000000000000000000000000000000000000..4d33717c36969758c9383003815e9cf2d820042e --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0493-rc-StackScan-CP_Thread_08/CP_Thread_08.java @@ -0,0 +1,93 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_CP_Thread_08 + *- @TestCaseName: CP_Thread_08 + *- @TestCaseType: Function Testing for placementRCTest + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: MultiThreadMode:Cycle is Cycle_a_0038.java;Nocycle is OutOfMemoryError + *- @Brief:一组有环的对象,他们的field指向一个hashMap,里面装满了对象 + * -#step1: 创建一个环,环的类型参考了Cycle_a_0038.java; + * -#step2: 两个域test1和test2,里面装满了对象,对象格式参考OutOfMemoryError,这样就构造了一个大对象。 + * -#step3: 验证结果正确,再用GCverify验证无内存泄漏。 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: CP_Thread_08.java + *- @ExecuteClass: CP_Thread_08 + *- @ExecuteArgs: + *- @Remark: + */ + +class CP_Thread_08_A1 { + static OutOfMemoryError[] test1; + static + int a; + CP_Thread_08_A1 a2_0; + int sum; + String strObjectName; + + CP_Thread_08_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + + void add() { + sum = a + a; + } +} + +class CP_Thread_08_test extends Thread { + private static CP_Thread_08_A1 a1_main = null; + private volatile static CP_Thread_08_A1 a2 = null; + private volatile static OutOfMemoryError test1; + private static OutOfMemoryError test2; + + private static void test_CP_Thread_08_A1(int times) { + CP_Thread_08_A1.test1 = new OutOfMemoryError[times]; + for (int i = 0; i < times; i++) { + test1 = new OutOfMemoryError(); + CP_Thread_08_A1.test1[i] = test1; + } + } + + private static void test_CP_Thread_08_A2(int times) { + CP_Thread_08_A1.test1 = new OutOfMemoryError[times]; + for (int i = 0; i < times; i++) { + test2 = new OutOfMemoryError(); + CP_Thread_08_A1.test1[i] = test2; + } + } + + public void run() { + a1_main = new CP_Thread_08_A1("a1_main"); + a2 = new CP_Thread_08_A1("a2_0"); + a1_main.a2_0 = a2; + a1_main.a2_0.a2_0 = a2; + + a1_main.add(); + a1_main.a2_0.add(); + test_CP_Thread_08_A1(10000); + test_CP_Thread_08_A2(10000); + int result = a1_main.sum + a1_main.a2_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 404) + System.out.println("ExpectResult"); + } +} + +public class CP_Thread_08 { + private static CP_Thread_08_A1 a1_main = null; + private volatile static CP_Thread_08_A1 a2 = null; + + public static void main(String[] args) { + CP_Thread_08_test cptest1 = new CP_Thread_08_test(); + cptest1.run(); + CP_Thread_08_test cptest2 = new CP_Thread_08_test(); + cptest2.run(); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0494-rc-StackScan-CP_Thread_09/CP_Thread_09.java b/test/testsuite/ouroboros/rc_test/RC0494-rc-StackScan-CP_Thread_09/CP_Thread_09.java new file mode 100644 index 0000000000000000000000000000000000000000..bc0ae8294fc353b0e9dc45e0dee3bb0dc28adf98 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0494-rc-StackScan-CP_Thread_09/CP_Thread_09.java @@ -0,0 +1,92 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_CP_Thread_09 + *- @TestCaseName: CP_Thread_09 + *- @TestCaseType: Function Testing for placementRCTest + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: MultiThreadMode:Cycle is Cycle_a_0038.java;Nocycle is ClassLoader + *- @Brief:一组有环的对象,他们的field指向一个hashMap,里面装满了对象 + * -#step1: 创建一个环,环的类型参考了Cycle_a_0038.java; + * -#step2: 两个域test1和test2,里面装满了对象,对象格式参考ClassLoader,这样就构造了一个大对象。 + * -#step3: 验证结果正确,再用GCverify验证无内存泄漏。 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: CP_Thread_09.java + *- @ExecuteClass: CP_Thread_09 + *- @ExecuteArgs: + *- @Remark: + */ + +class CP_Thread_09_A1 { + static ClassLoader[] test1; + static + int a; + CP_Thread_09_A1 a2_0; + int sum; + String strObjectName; + + CP_Thread_09_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + + void add() { + sum = a + a; + } +} + +class CP_Thread_09_test extends Thread { + private static CP_Thread_09_A1 a1_main = null; + private volatile static CP_Thread_09_A1 a2 = null; + private volatile static ClassLoader test1; + private static ClassLoader test2; + + private static void test_CP_Thread_09_A1(int times) { + CP_Thread_09_A1.test1 = new ClassLoader[times]; + for (int i = 0; i < times; i++) { + test1 = CP_Thread_09_A1.class.getClassLoader(); + CP_Thread_09_A1.test1[i] = test1; + } + } + + private static void test_CP_Thread_09_A2(int times) { + CP_Thread_09_A1.test1 = new ClassLoader[times]; + for (int i = 0; i < times; i++) { + test2 = CP_Thread_09_A1.class.getClassLoader(); + CP_Thread_09_A1.test1[i] = test2; + } + } + + public void run() { + a1_main = new CP_Thread_09_A1("a1_main"); + a2 = new CP_Thread_09_A1("a2_0"); + a1_main.a2_0 = a2; + a1_main.a2_0.a2_0 = a2; + + a1_main.add(); + a1_main.a2_0.add(); + test_CP_Thread_09_A1(10000); + test_CP_Thread_09_A2(10000); + int result = a1_main.sum + a1_main.a2_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 404) + System.out.println("ExpectResult"); + } +} + +public class CP_Thread_09 { + private static CP_Thread_09_A1 a1_main = null; + private volatile static CP_Thread_09_A1 a2 = null; + + public static void main(String[] args) { + CP_Thread_09_test cptest1 = new CP_Thread_09_test(); + cptest1.run(); + CP_Thread_09_test cptest2 = new CP_Thread_09_test(); + cptest2.run(); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0495-rc-GC-TaskQueue-FrequentSystemGC_01/FrequentSystemGC_01.java b/test/testsuite/ouroboros/rc_test/RC0495-rc-GC-TaskQueue-FrequentSystemGC_01/FrequentSystemGC_01.java new file mode 100644 index 0000000000000000000000000000000000000000..2c2b6bf617bb78f45e051f765b57eaee271e3c53 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0495-rc-GC-TaskQueue-FrequentSystemGC_01/FrequentSystemGC_01.java @@ -0,0 +1,81 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_FrequentSystemGC_01 + *- @TestCaseName: FrequentSystemGC_01 + *- @TestCaseType: Function Testing for frequently system.gc() by user + *- @RequirementName: GC队列 + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief:多线程同时显式触发system.gc。 + * -#step1:创建100个线程 + * -#step2:每个线程先sleep不同的时间,依次为1ms,2ms,3ms... + * -#step3:sleep完后分配一个weak, 接着显式触发gc() + * -#step4:每个线程在显式调用Runtime.getRuntime().gc()后,其weak都已经被释放 + *- @Expect:expected.txt + *- @Priority: High + *- @Source: FrequentSystemGC_01.java + *- @ExecuteClass: FrequentSystemGC_01 + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.WeakReference; +import java.util.ArrayList; + +class MyThread extends Thread { + public void run(){ + try { + Thread.sleep(index * FrequentSystemGC_01.THREAD_SLEEP_UNIT); + } catch (Exception e) { + // System.out.println("Exception from thread sleep: " + index); + // do nothing, just continue test... + } + + WeakReference weak = new WeakReference(new Object()); + if (weak.get() == null) { + return; + } + Runtime.getRuntime().gc(); + if (weak.get() != null) { + System.out.println("MyThread" + index + " check fail"); + FrequentSystemGC_01.totalResult = false; + } + } + + public MyThread(int i) { + index = i; + } + + private int index; +} + +public class FrequentSystemGC_01 { + public static final int THREAD_COUNT = 50; + public static boolean totalResult = true; + public static final long THREAD_SLEEP_UNIT = 1; + public static ArrayList threads = new ArrayList<>(); + public static void main(String[] args) { + for (int i = 0; i < THREAD_COUNT; i++) { + Thread t = new MyThread(i); + threads.add(t); + t.start(); + } + + for (int i = 0; i < THREAD_COUNT; i++) { + try { + threads.get(i).join(); + } catch (Exception e) { + System.out.println("Exception from join thread: " + i + " need re-test!"); + return; + } + } + if (FrequentSystemGC_01.totalResult == true) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult, weak is not freed after system.gc() in some thread!"); + } + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0496-rc-GC-TaskQueue-StartupInvoke_01/StartupInvoke_01.java b/test/testsuite/ouroboros/rc_test/RC0496-rc-GC-TaskQueue-StartupInvoke_01/StartupInvoke_01.java new file mode 100644 index 0000000000000000000000000000000000000000..26f060081e6ef98e10d23701a30acb041e944573 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0496-rc-GC-TaskQueue-StartupInvoke_01/StartupInvoke_01.java @@ -0,0 +1,52 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_StartupInvoke_01 + *- @TestCaseName: StartupInvoke_01 + *- @TestCaseType: Function Testing for async TriggerGC at startup + *- @RequirementName: GC队列实现 + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief:当前初始阈值是100MB,会隐式触发GC。 + * -#step1:创建一个弱引用,检查它可以通过get()方法获得关联的引用对象。 + * -#step2:通过1个for循环,分配内存到100M。 + * -#step3:验证GC被隐式触发,步骤1中创建的弱引用被回收掉了。 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: StartupInvoke_01.java + *- @ExecuteClass: StartupInvoke_01 + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.ref.WeakReference; +import java.util.ArrayList; + +public class StartupInvoke_01 { + static WeakReference observer; + static int check = 2; + private final static int INIT_MEMORY = 100; // MB + private static ArrayList store = new ArrayList(); + + public static void main(String[] args) throws Exception { + observer = new WeakReference(new Object()); + if (observer.get() != null) { + check--; + } + for (int i = 0; i < INIT_MEMORY; i++) { + byte[] temp = new byte[1024*1024]; + store.add(temp); + } + Thread.sleep(3000); + if (observer.get() == null) { + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult, check should be 0, but now check = " + check); + } + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0507-JTreg-CheckLoops/CheckLoops.java b/test/testsuite/ouroboros/rc_test/RC0507-JTreg-CheckLoops/CheckLoops.java new file mode 100755 index 0000000000000000000000000000000000000000..57a7c1de463f4a59089649f475dd54b8851fb0bf --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0507-JTreg-CheckLoops/CheckLoops.java @@ -0,0 +1,1071 @@ +/* + * -@TestCaseID: CheckLoops + * -@TestCaseName: CheckLoops + * -@TestCaseType: Function Testing from JTreg + * -@RequirementID: None + * -@RequirementName: some testcases will be moved to FigtoTest when enable JTreg. + * -@Condition:no + * -#c1: 测试环境正常 + * -@Brief:将该用例从JTreg中摘出来,放到CI和组件daily测试中测试。该用例在JTreg连跑中会挂掉 + * -@Expect:ExpectResult\n + * -@Priority: High + * -@Source: CheckLoops.java + * -@ExecuteClass: CheckLoops + * -@ExecuteArgs: + * -@Remark: + */ + +public class CheckLoops { + private static int sResult; + + // + // Various sequence variables used in bound checks. + // + + // CHECK-START: void Main.bubble(int[]) BCE (before) + // CHECK-DAG: BoundsCheck + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.bubble(int[]) BCE (after) + // CHECK-NOT: BoundsCheck + private static void bubble(int[] a) { + for (int i = a.length; --i >= 0; ) { + for (int j = 0; j < i; j++) { + if (a[j] > a[j + 1]) { + int tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + } + + // CHECK-START: int Main.periodicIdiom(int) BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.periodicIdiom(int) BCE (after) + // CHECK-NOT: BoundsCheck + // CHECK-NOT: Deoptimize + private static int periodicIdiom(int tc) { + int[] x = {1, 3}; + // Loop with periodic sequence (0, 1). + int k = 0; + int result = 0; + for (int i = 0; i < tc; i++) { + result += x[k]; + k = 1 - k; + } + return result; + } + + // CHECK-START: int Main.periodicSequence2(int) BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.periodicSequence2(int) BCE (after) + // CHECK-NOT: BoundsCheck + // CHECK-NOT: Deoptimize + private static int periodicSequence2(int tc) { + int[] x = {1, 3}; + // Loop with periodic sequence (0, 1). + int k = 0; + int l = 1; + int result = 0; + for (int i = 0; i < tc; i++) { + result += x[k]; + int t = l; + l = k; + k = t; + } + return result; + } + + // CHECK-START: int Main.periodicSequence4(int) BCE (before) + // CHECK-DAG: BoundsCheck + // CHECK-DAG: BoundsCheck + // CHECK-DAG: BoundsCheck + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.periodicSequence4(int) BCE (after) + // CHECK-NOT: BoundsCheck + // CHECK-NOT: Deoptimize + private static int periodicSequence4(int tc) { + int[] x = {1, 3, 5, 7}; + // Loop with periodic sequence (0, 1, 2, 3). + int k = 0; + int l = 1; + int m = 2; + int n = 3; + int result = 0; + for (int i = 0; i < tc; i++) { + result += x[k] + x[l] + x[m] + x[n]; // all used at once + int t = n; + n = k; + k = l; + l = m; + m = t; + } + return result; + } + + // CHECK-START: int Main.justRightUp1() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.justRightUp1() BCE (after) + // CHECK-NOT: BoundsCheck + // CHECK-NOT: Deoptimize + private static int justRightUp1() { + int[] x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int result = 0; + for (int i = Integer.MAX_VALUE - 10, k = 0; i < Integer.MAX_VALUE; i++) { + result += x[k++]; + } + return result; + } + + // CHECK-START: int Main.justRightUp2() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.justRightUp2() BCE (after) + // CHECK-NOT: BoundsCheck + // CHECK-NOT: Deoptimize + private static int justRightUp2() { + int[] x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int result = 0; + for (int i = Integer.MAX_VALUE - 10; i < Integer.MAX_VALUE; i++) { + result += x[i - Integer.MAX_VALUE + 10]; + } + return result; + } + + // CHECK-START: int Main.justRightUp3() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.justRightUp3() BCE (after) + // CHECK-NOT: BoundsCheck + // CHECK-NOT: Deoptimize + private static int justRightUp3() { + int[] x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int result = 0; + for (int i = Integer.MAX_VALUE - 10, k = 0; i <= Integer.MAX_VALUE - 1; i++) { + result += x[k++]; + } + return result; + } + + // CHECK-START: int Main.justOOBUp() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.justOOBUp() BCE (after) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.justOOBUp() BCE (after) + // CHECK-NOT: Deoptimize + private static int justOOBUp() { + int[] x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int result = 0; + // Infinite loop! + for (int i = Integer.MAX_VALUE - 9, k = 0; i <= Integer.MAX_VALUE; i++) { + result += x[k++]; + } + return result; + } + + // CHECK-START: int Main.justRightDown1() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.justRightDown1() BCE (after) + // CHECK-NOT: BoundsCheck + // CHECK-NOT: Deoptimize + private static int justRightDown1() { + int[] x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int result = 0; + for (int i = Integer.MIN_VALUE + 10, k = 0; i > Integer.MIN_VALUE; i--) { + result += x[k++]; + } + return result; + } + + // CHECK-START: int Main.justRightDown2() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.justRightDown2() BCE (after) + // CHECK-NOT: BoundsCheck + // CHECK-NOT: Deoptimize + private static int justRightDown2() { + int[] x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int result = 0; + for (int i = Integer.MIN_VALUE + 10; i > Integer.MIN_VALUE; i--) { + result += x[Integer.MAX_VALUE + i]; + } + return result; + } + + // CHECK-START: int Main.justRightDown3() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.justRightDown3() BCE (after) + // CHECK-NOT: BoundsCheck + // CHECK-NOT: Deoptimize + private static int justRightDown3() { + int[] x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int result = 0; + for (int i = Integer.MIN_VALUE + 10, k = 0; i >= Integer.MIN_VALUE + 1; i--) { + result += x[k++]; + } + return result; + } + + // CHECK-START: int Main.justOOBDown() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.justOOBDown() BCE (after) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.justOOBDown() BCE (after) + // CHECK-NOT: Deoptimize + private static int justOOBDown() { + int[] x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int result = 0; + // Infinite loop! + for (int i = Integer.MIN_VALUE + 9, k = 0; i >= Integer.MIN_VALUE; i--) { + result += x[k++]; + } + return result; + } + + // CHECK-START: void Main.lowerOOB(int[]) BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.lowerOOB(int[]) BCE (after) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.lowerOOB(int[]) BCE (after) + // CHECK-NOT: Deoptimize + private static void lowerOOB(int[] x) { + // OOB! + for (int i = -1; i < x.length; i++) { + sResult += x[i]; + } + } + + // CHECK-START: void Main.upperOOB(int[]) BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.upperOOB(int[]) BCE (after) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.upperOOB(int[]) BCE (after) + // CHECK-NOT: Deoptimize + private static void upperOOB(int[] x) { + // OOB! + for (int i = 0; i <= x.length; i++) { + sResult += x[i]; + } + } + + // CHECK-START: void Main.doWhileUpOOB() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.doWhileUpOOB() BCE (after) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.doWhileUpOOB() BCE (after) + // CHECK-NOT: Deoptimize + private static void doWhileUpOOB() { + int[] x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int i = 0; + // OOB! + do { + sResult += x[i++]; + } while (i <= x.length); + } + + // CHECK-START: void Main.doWhileDownOOB() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.doWhileDownOOB() BCE (after) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.doWhileDownOOB() BCE (after) + // CHECK-NOT: Deoptimize + private static void doWhileDownOOB() { + int[] x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int i = x.length - 1; + // OOB! + do { + sResult += x[i--]; + } while (-1 <= i); + } + + // CHECK-START: void Main.hiddenOOB1(int) BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.hiddenOOB1(int) BCE (after) + // CHECK-DAG: Deoptimize + // + // CHECK-START: void Main.hiddenOOB1(int) BCE (after) + // CHECK-NOT: BoundsCheck + private static void hiddenOOB1(int lo) { + int[] a = {1}; + for (int i = lo; i <= 10; i++) { + // Dangerous loop where careless static range analysis would yield strict upper bound + // on index j of 5. When, for instance, lo and thus i = -2147483648, the upper bound + // becomes really positive due to arithmetic wrap-around, causing OOB. + // Dynamic BCE is feasible though, since it checks the range. + for (int j = 4; j < i - 5; j++) { + sResult += a[j - 4]; + } + } + } + + // CHECK-START: void Main.hiddenOOB2(int) BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.hiddenOOB2(int) BCE (after) + // CHECK-DAG: Deoptimize + // + // CHECK-START: void Main.hiddenOOB2(int) BCE (after) + // CHECK-NOT: BoundsCheck + private static void hiddenOOB2(int hi) { + int[] a = {1}; + for (int i = 0; i < hi; i++) { + // Dangerous loop where careless static range analysis would yield strict lower bound + // on index j of 5. When, for instance, hi and thus i = 2147483647, the upper bound + // becomes really negative due to arithmetic wrap-around, causing OOB. + // Dynamic BCE is feasible though, since it checks the range. + for (int j = 6; j > i + 5; j--) { + sResult += a[j - 6]; + } + } + } + + // CHECK-START: void Main.hiddenInfiniteOOB() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.hiddenInfiniteOOB() BCE (after) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.hiddenInfiniteOOB() BCE (after) + // CHECK-NOT: Deoptimize + private static void hiddenInfiniteOOB() { + int[] a = {11}; + for (int i = -1; i <= 0; i++) { + // Dangerous loop where careless static range analysis would yield a safe upper bound + // of -3. In reality, due to arithmetic wrap-around (when i = -1, j <= 2147483647; + // whereas when i = 0, j <= -3), this is an infinite loop that goes OOB. + for (int j = -3; j <= 2147483646 * i - 3; j++) { + sResult += a[j + 3]; + } + } + } + + // CHECK-START: void Main.hiddenFiniteOOB() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.hiddenFiniteOOB() BCE (after) + // CHECK-DAG: Deoptimize + // + // CHECK-START: void Main.hiddenFiniteOOB() BCE (after) + // CHECK-NOT: BoundsCheck + private static void hiddenFiniteOOB() { + int[] a = {111}; + for (int i = -1; i <= 0; i++) { + // Dangerous loop similar as above where the loop is now finite, but the + // loop still goes out of bounds for i = -1 due to the large upper bound. + // Dynamic BCE is feasible though, since it checks the range. + for (int j = -4; j < 2147483646 * i - 3; j++) { + sResult += a[j + 4]; + } + } + } + + // CHECK-START: void Main.inductionOOB(int[]) BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.inductionOOB(int[]) BCE (after) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.inductionOOB(int[]) BCE (after) + // CHECK-NOT: Deoptimize + private static void inductionOOB(int[] a) { + // Careless range analysis would remove the bounds check. + // However, the narrower induction b wraps around arithmetically + // before it reaches the end of arrays longer than 127. + byte b = 0; + for (int i = 0; i < a.length; i++) { + a[b++] = i; + } + } + + // CHECK-START: void Main.controlOOB(int[]) BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.controlOOB(int[]) BCE (after) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.controlOOB(int[]) BCE (after) + // CHECK-NOT: Deoptimize + private static void controlOOB(int[] a) { + // As above, but now the loop control also wraps around. + for (byte i = 0; i < a.length; i++) { + a[i] = -i; + } + } + + // CHECK-START: void Main.conversionOOB(int[]) BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.conversionOOB(int[]) BCE (after) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.conversionOOB(int[]) BCE (after) + // CHECK-NOT: Deoptimize + private static void conversionOOB(int[] a) { + // As above, but with wrap around caused by an explicit conversion. + for (int i = 0; i < a.length; ) { + a[i] = i; + i = (byte) (i + 1); + } + } + + // CHECK-START: int[] Main.add() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int[] Main.add() BCE (after) + // CHECK-NOT: BoundsCheck + // CHECK-NOT: Deoptimize + private static int[] add() { + int[] a = new int[10]; + for (int i = 0; i <= 3; i++) { + for (int j = 0; j <= 6; j++) { + a[i + j] += 1; + } + } + return a; + } + + // CHECK-START: int[] Main.multiply1() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int[] Main.multiply1() BCE (after) + // CHECK-NOT: BoundsCheck + // CHECK-NOT: Deoptimize + private static int[] multiply1() { + int[] a = new int[10]; + try { + for (int i = 0; i <= 3; i++) { + for (int j = 0; j <= 3; j++) { + // Range [0,9]: safe. + a[i * j] += 1; + } + } + } catch (Exception e) { + a[0] += 1000; + } + return a; + } + + // CHECK-START: int[] Main.multiply2() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int[] Main.multiply2() BCE (after) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int[] Main.multiply2() BCE (after) + // CHECK-NOT: Deoptimize + private static int[] multiply2() { + int[] a = new int[10]; + try { + for (int i = -3; i <= 3; i++) { + for (int j = -3; j <= 3; j++) { + // Range [-9,9]: unsafe. + a[i * j] += 1; + } + } + } catch (Exception e) { + a[0] += 1000; + } + return a; + } + + // CHECK-START: int Main.linearDynamicBCE1(int[], int, int) BCE (before) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: NullCheck loop:<> + // CHECK-DAG: ArrayLength loop:<> + // CHECK-DAG: BoundsCheck loop:<> + // + // CHECK-START: int Main.linearDynamicBCE1(int[], int, int) BCE (after) + // CHECK-DAG: ArrayGet loop:{{B\d+}} + // CHECK-DAG: Deoptimize loop:none + // + // CHECK-START: int Main.linearDynamicBCE1(int[], int, int) BCE (after) + // CHECK-NOT: NullCheck loop:{{B\d+}} + // CHECK-NOT: ArrayLength loop:{{B\d+}} + // CHECK-NOT: BoundsCheck loop:{{B\d+}} + private static int linearDynamicBCE1(int[] x, int lo, int hi) { + int result = 0; + for (int i = lo; i < hi; i++) { + sResult += x[i]; + } + return result; + } + + // CHECK-START: int Main.linearDynamicBCE2(int[], int, int, int) BCE (before) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: NullCheck loop:<> + // CHECK-DAG: ArrayLength loop:<> + // CHECK-DAG: BoundsCheck loop:<> + // + // CHECK-START: int Main.linearDynamicBCE2(int[], int, int, int) BCE (after) + // CHECK-DAG: ArrayGet loop:{{B\d+}} + // CHECK-DAG: Deoptimize loop:none + // + // CHECK-START: int Main.linearDynamicBCE2(int[], int, int, int) BCE (after) + // CHECK-NOT: NullCheck loop:{{B\d+}} + // CHECK-NOT: ArrayLength loop:{{B\d+}} + // CHECK-NOT: BoundsCheck loop:{{B\d+}} + private static int linearDynamicBCE2(int[] x, int lo, int hi, int offset) { + int result = 0; + for (int i = lo; i < hi; i++) { + sResult += x[offset + i]; + } + return result; + } + + // CHECK-START: int Main.wrapAroundDynamicBCE(int[]) BCE (before) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: NullCheck loop:<> + // CHECK-DAG: ArrayLength loop:<> + // CHECK-DAG: BoundsCheck loop:<> + // + // CHECK-START: int Main.wrapAroundDynamicBCE(int[]) BCE (after) + // CHECK-DAG: ArrayGet loop:{{B\d+}} + // CHECK-DAG: Deoptimize loop:none + // + // CHECK-START: int Main.wrapAroundDynamicBCE(int[]) BCE (after) + // CHECK-NOT: NullCheck loop:{{B\d+}} + // CHECK-NOT: ArrayLength loop:{{B\d+}} + // CHECK-NOT: BoundsCheck loop:{{B\d+}} + private static int wrapAroundDynamicBCE(int[] x) { + int w = 9; + int result = 0; + for (int i = 0; i < 10; i++) { + result += x[w]; + w = i; + } + return result; + } + + // CHECK-START: int Main.periodicDynamicBCE(int[]) BCE (before) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: NullCheck loop:<> + // CHECK-DAG: ArrayLength loop:<> + // CHECK-DAG: BoundsCheck loop:<> + // + // CHECK-START: int Main.periodicDynamicBCE(int[]) BCE (after) + // CHECK-DAG: ArrayGet loop:{{B\d+}} + // CHECK-DAG: Deoptimize loop:none + // + // CHECK-START: int Main.periodicDynamicBCE(int[]) BCE (after) + // CHECK-NOT: NullCheck loop:{{B\d+}} + // CHECK-NOT: ArrayLength loop:{{B\d+}} + // CHECK-NOT: BoundsCheck loop:{{B\d+}} + private static int periodicDynamicBCE(int[] x) { + int k = 0; + int result = 0; + for (int i = 0; i < 10; i++) { + result += x[k]; + k = 1 - k; + } + return result; + } + + // CHECK-START: int Main.dynamicBCEPossiblyInfiniteLoop(int[], int, int) BCE (before) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: NullCheck loop:<> + // CHECK-DAG: ArrayLength loop:<> + // CHECK-DAG: BoundsCheck loop:<> + // + // CHECK-START: int Main.dynamicBCEPossiblyInfiniteLoop(int[], int, int) BCE (after) + // CHECK-DAG: ArrayGet loop:{{B\d+}} + // CHECK-DAG: Deoptimize loop:none + // + // CHECK-START: int Main.dynamicBCEPossiblyInfiniteLoop(int[], int, int) BCE (after) + // CHECK-NOT: NullCheck loop:{{B\d+}} + // CHECK-NOT: ArrayLength loop:{{B\d+}} + // CHECK-NOT: BoundsCheck loop:{{B\d+}} + private static int dynamicBCEPossiblyInfiniteLoop(int[] x, int lo, int hi) { + // This loop could be infinite for hi = max int. Since i is also used + // as subscript, however, dynamic bce can proceed. + int result = 0; + for (int i = lo; i <= hi; i++) { + result += x[i]; + } + return result; + } + + // CHECK-START: int Main.noDynamicBCEPossiblyInfiniteLoop(int[], int, int) BCE (before) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: BoundsCheck loop:<> + // + // CHECK-START: int Main.noDynamicBCEPossiblyInfiniteLoop(int[], int, int) BCE (after) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: BoundsCheck loop:<> + // + // CHECK-START: int Main.noDynamicBCEPossiblyInfiniteLoop(int[], int, int) BCE (after) + // CHECK-NOT: Deoptimize + static int noDynamicBCEPossiblyInfiniteLoop(int[] x, int lo, int hi) { + // As above, but now the index is not used as subscript, + // and dynamic bce is not applied. + int result = 0; + for (int k = 0, i = lo; i <= hi; i++) { + result += x[k++]; + } + return result; + } + + // CHECK-START: int Main.noDynamicBCEMixedInductionTypes(int[], long, long) BCE (before) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: BoundsCheck loop:<> + // + // CHECK-START: int Main.noDynamicBCEMixedInductionTypes(int[], long, long) BCE (after) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: BoundsCheck loop:<> + // + // CHECK-START: int Main.noDynamicBCEMixedInductionTypes(int[], long, long) BCE (after) + // CHECK-NOT: Deoptimize + static int noDynamicBCEMixedInductionTypes(int[] x, long lo, long hi) { + int result = 0; + // Mix of int and long induction. + int k = 0; + for (long i = lo; i < hi; i++) { + result += x[k++]; + } + return result; + } + + // CHECK-START: int Main.dynamicBCEConstantRange(int[]) BCE (before) + // CHECK-DAG: BoundsCheck loop:<> + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: If loop:<> + // CHECK-DAG: If loop:<> + // CHECK-EVAL: "<>" != "<>" + // + // CHECK-START: int Main.dynamicBCEConstantRange(int[]) BCE (after) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: Deoptimize loop:<> + // CHECK-EVAL: "<>" != "<>" + // + // CHECK-START: int Main.dynamicBCEConstantRange(int[]) BCE (after) + // CHECK-NOT: BoundsCheck + // + // No additional top tests were introduced. + // CHECK-START: int Main.dynamicBCEConstantRange(int[]) BCE (after) + // CHECK-DAG: If + // CHECK-DAG: If + // CHECK-NOT: If + static int dynamicBCEConstantRange(int[] x) { + int result = 0; + for (int i = 2; i <= 6; i++) { + // Range analysis sees that innermost loop is finite and always taken. + for (int j = i - 2; j <= i + 2; j++) { + result += x[j]; + } + } + return result; + } + + // CHECK-START: int Main.dynamicBCEAndConstantIndices(int[], int[][], int, int) BCE (before) + // CHECK-DAG: {{l\d+}} ArrayGet loop:<> + // CHECK-DAG: {{l\d+}} ArrayGet loop:<> + // CHECK-DAG: {{l\d+}} ArrayGet loop:<> + // + // CHECK-START: int Main.dynamicBCEAndConstantIndices(int[], int[][], int, int) BCE (after) + // Order matters: + // CHECK: Deoptimize loop:<> + // CHECK-NOT: Goto loop:<> + // CHECK-DAG: {{l\d+}} ArrayGet loop:<> + // CHECK-DAG: {{l\d+}} ArrayGet loop:<> + // CHECK-DAG: {{l\d+}} ArrayGet loop:<> + // CHECK: Goto loop:<> + // + // CHECK-START: int Main.dynamicBCEAndConstantIndices(int[], int[][], int, int) BCE (after) + // CHECK-DAG: Deoptimize loop:none + static int dynamicBCEAndConstantIndices(int[] x, int[][] a, int lo, int hi) { + // Deliberately test array length on a before the loop so that only bounds checks + // on constant subscripts remain, making them a viable candidate for hoisting. + if (a.length == 0) { + return -1; + } + // Loop that allows BCE on x[i]. + int result = 0; + for (int i = lo; i < hi; i++) { + result += x[i]; + if ((i % 10) != 0) { + // None of the subscripts inside a conditional are removed by dynamic bce, + // making them a candidate for deoptimization based on constant indices. + // Compiler should ensure the array loads are not subsequently hoisted + // "above" the deoptimization "barrier" on the bounds. + a[0][i] = 1; + a[1][i] = 2; + a[99][i] = 3; + } + } + return result; + } + + // CHECK-START: int Main.dynamicBCEAndConstantIndicesAllPrimTypes(int[], boolean[], byte[], char[], short[], int[], long[], float[], double[], int, int) BCE (before) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: ArrayGet loop:<> + // For brevity, just test occurrence of at least one of each in the loop: + // CHECK-DAG: NullCheck loop:<> + // CHECK-DAG: ArrayLength loop:<> + // CHECK-DAG: BoundsCheck loop:<> + // + // CHECK-START: int Main.dynamicBCEAndConstantIndicesAllPrimTypes(int[], boolean[], byte[], char[], short[], int[], long[], float[], double[], int, int) BCE (after) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-NOT: ArrayGet loop:<> + // + // CHECK-START: int Main.dynamicBCEAndConstantIndicesAllPrimTypes(int[], boolean[], byte[], char[], short[], int[], long[], float[], double[], int, int) BCE (after) + // CHECK-NOT: NullCheck loop:{{B\d+}} + // CHECK-NOT: ArrayLength loop:{{B\d+}} + // CHECK-NOT: BoundsCheck loop:{{B\d+}} + // + // CHECK-START: int Main.dynamicBCEAndConstantIndicesAllPrimTypes(int[], boolean[], byte[], char[], short[], int[], long[], float[], double[], int, int) BCE (after) + // CHECK-DAG: Deoptimize loop:none + private static int dynamicBCEAndConstantIndicesAllPrimTypes(int[] q, boolean[] r, byte[] s, char[] t, short[] u, int[] v, long[] w, float[] x, double[] y, int lo, int hi) { + int result = 0; + for (int i = lo; i < hi; i++) { + // All constant index array references can be hoisted out of the loop during BCE on q[i]. + result += q[i] + (r[0] ? 1 : 0) + (int) s[0] + (int) t[0] + (int) u[0] + v[0] + (int) w[0] + (int) x[0] + (int) y[0]; + } + return result; + } + + // CHECK-START: int Main.dynamicBCEAndConstantIndexRefType(int[], java.lang.Integer[], int, int) BCE (before) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: NullCheck loop:<> + // CHECK-DAG: ArrayLength loop:<> + // CHECK-DAG: BoundsCheck loop:<> + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: NullCheck loop:<> + // CHECK-DAG: ArrayLength loop:<> + // CHECK-DAG: BoundsCheck loop:<> + // + // CHECK-START: int Main.dynamicBCEAndConstantIndexRefType(int[], java.lang.Integer[], int, int) BCE (after) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: Deoptimize loop:none + // + // CHECK-START: int Main.dynamicBCEAndConstantIndexRefType(int[], java.lang.Integer[], int, int) BCE (after) + // CHECK-NOT: ArrayLength loop:{{B\d+}} + // CHECK-NOT: BoundsCheck loop:{{B\d+}} + private static int dynamicBCEAndConstantIndexRefType(int[] q, Integer[] z, int lo, int hi) { + int result = 0; + for (int i = lo; i < hi; i++) { + // Similar to above, but now implicit call to intValue() may prevent hoisting + // z[0] itself during BCE on q[i]. Therefore, we just check BCE on q[i]. + result += q[i] + z[0]; + } + return result; + } + + // + // Verifier. + // + + public static void main(String[] args) { + // Set to run expensive tests for correctness too. + boolean heavy = false; + + int[] x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + + int[] a200 = new int[200]; + + // Sorting. + int[] sort = {5, 4, 1, 9, 10, 2, 7, 6, 3, 8}; + bubble(sort); + for (int i = 0; i < 10; i++) { + expectEquals(sort[i], x[i]); + } + + // Periodic adds (1, 3), one at the time. + expectEquals(0, periodicIdiom(-1)); + for (int tc = 0; tc < 32; tc++) { + int expected = (tc >> 1) << 2; + if ((tc & 1) != 0) + expected += 1; + expectEquals(expected, periodicIdiom(tc)); + } + + // Periodic adds (1, 3), one at the time. + expectEquals(0, periodicSequence2(-1)); + for (int tc = 0; tc < 32; tc++) { + int expected = (tc >> 1) << 2; + if ((tc & 1) != 0) + expected += 1; + expectEquals(expected, periodicSequence2(tc)); + } + + // Periodic adds (1, 3, 5, 7), all at once. + expectEquals(0, periodicSequence4(-1)); + for (int tc = 0; tc < 32; tc++) { + expectEquals(tc * 16, periodicSequence4(tc)); + } + + // Large bounds. + expectEquals(55, justRightUp1()); + expectEquals(55, justRightUp2()); + expectEquals(55, justRightUp3()); + expectEquals(55, justRightDown1()); + expectEquals(55, justRightDown2()); + expectEquals(55, justRightDown3()); + sResult = 0; + try { + justOOBUp(); + } catch (ArrayIndexOutOfBoundsException e) { + sResult = 1; + } + expectEquals(1, sResult); + sResult = 0; + try { + justOOBDown(); + } catch (ArrayIndexOutOfBoundsException e) { + sResult = 1; + } + expectEquals(1, sResult); + + // Lower bound goes OOB. + sResult = 0; + try { + lowerOOB(x); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1000, sResult); + + // Upper bound goes OOB. + sResult = 0; + try { + upperOOB(x); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1055, sResult); + + // Do while up goes OOB. + sResult = 0; + try { + doWhileUpOOB(); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1055, sResult); + + // Do while down goes OOB. + sResult = 0; + try { + doWhileDownOOB(); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1055, sResult); + + // Hidden OOB. + sResult = 0; + try { + hiddenOOB1(10); // no OOB + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1, sResult); + sResult = 0; + try { + hiddenOOB1(-2147483648); // OOB + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1001, sResult); + sResult = 0; + try { + hiddenOOB2(1); // no OOB + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1, sResult); + if (heavy) { + sResult = 0; + try { + hiddenOOB2(2147483647); // OOB + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1002, sResult); + } + sResult = 0; + try { + hiddenInfiniteOOB(); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1011, sResult); + sResult = 0; + try { + hiddenFiniteOOB(); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1111, sResult); + sResult = 0; + try { + inductionOOB(a200); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1000, sResult); + for (int i = 0; i < 200; i++) { + expectEquals(i < 128 ? i : 0, a200[i]); + } + sResult = 0; + try { + controlOOB(a200); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1000, sResult); + for (int i = 0; i < 200; i++) { + expectEquals(i < 128 ? -i : 0, a200[i]); + } + sResult = 0; + try { + conversionOOB(a200); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1000, sResult); + for (int i = 0; i < 200; i++) { + expectEquals(i < 128 ? i : 0, a200[i]); + } + + // Addition. + { + int[] e1 = {1, 2, 3, 4, 4, 4, 4, 3, 2, 1}; + int[] a1 = add(); + for (int i = 0; i < 10; i++) { + expectEquals(a1[i], e1[i]); + } + } + + // Multiplication. + { + int[] e1 = {7, 1, 2, 2, 1, 0, 2, 0, 0, 1}; + int[] a1 = multiply1(); + for (int i = 0; i < 10; i++) { + expectEquals(a1[i], e1[i]); + } + int[] e2 = {1001, 0, 0, 1, 0, 0, 1, 0, 0, 1}; + int[] a2 = multiply2(); + for (int i = 0; i < 10; i++) { + expectEquals(a2[i], e2[i]); + } + } + + // Dynamic BCE. + sResult = 0; + try { + linearDynamicBCE1(x, -1, x.length); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1000, sResult); + sResult = 0; + linearDynamicBCE1(x, 0, x.length); + expectEquals(55, sResult); + sResult = 0; + try { + linearDynamicBCE1(x, 0, x.length + 1); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1055, sResult); + + // Dynamic BCE with offset. + sResult = 0; + try { + linearDynamicBCE2(x, 0, x.length, -1); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1000, sResult); + sResult = 0; + linearDynamicBCE2(x, 0, x.length, 0); + expectEquals(55, sResult); + sResult = 0; + try { + linearDynamicBCE2(x, 0, x.length, 1); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1054, sResult); + + // Dynamic BCE candidates. + expectEquals(55, wrapAroundDynamicBCE(x)); + expectEquals(15, periodicDynamicBCE(x)); + expectEquals(55, dynamicBCEPossiblyInfiniteLoop(x, 0, 9)); + expectEquals(55, noDynamicBCEPossiblyInfiniteLoop(x, 0, 9)); + expectEquals(55, noDynamicBCEMixedInductionTypes(x, 0, 10)); + expectEquals(125, dynamicBCEConstantRange(x)); + + // Dynamic BCE combined with constant indices. + int[][] a; + a = new int[0][0]; + expectEquals(-1, dynamicBCEAndConstantIndices(x, a, 0, 10)); + a = new int[100][10]; + expectEquals(55, dynamicBCEAndConstantIndices(x, a, 0, 10)); + for (int i = 0; i < 10; i++) { + expectEquals((i % 10) != 0 ? 1 : 0, a[0][i]); + expectEquals((i % 10) != 0 ? 2 : 0, a[1][i]); + expectEquals((i % 10) != 0 ? 3 : 0, a[99][i]); + } + a = new int[2][10]; + sResult = 0; + try { + expectEquals(55, dynamicBCEAndConstantIndices(x, a, 0, 10)); + } catch (ArrayIndexOutOfBoundsException e) { + sResult = 1; + } + expectEquals(1, sResult); + expectEquals(a[0][1], 1); + expectEquals(a[1][1], 2); + + // Dynamic BCE combined with constant indices of all types. + boolean[] x1 = {true}; + byte[] x2 = {2}; + char[] x3 = {3}; + short[] x4 = {4}; + int[] x5 = {5}; + long[] x6 = {6}; + float[] x7 = {7}; + double[] x8 = {8}; + expectEquals(415, dynamicBCEAndConstantIndicesAllPrimTypes(x, x1, x2, x3, x4, x5, x6, x7, x8, 0, 10)); + Integer[] x9 = {9}; + expectEquals(145, dynamicBCEAndConstantIndexRefType(x, x9, 0, 10)); + + System.out.println("ExpectResult"); + } + + private static void expectEquals(int expected, int result) { + if (expected != result) { + throw new Error("Expected: " + expected + ", found: " + result); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0508-JTreg-ConstCharAppend/ConstCharAppend.java b/test/testsuite/ouroboros/rc_test/RC0508-JTreg-ConstCharAppend/ConstCharAppend.java new file mode 100755 index 0000000000000000000000000000000000000000..4cd569695f468d20d65030d445f7e052ad7191a4 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0508-JTreg-ConstCharAppend/ConstCharAppend.java @@ -0,0 +1,29 @@ +/* + * -@TestCaseID: ConstCharAppend + * -@TestCaseName: ConstCharAppend + * -@TestCaseType: Function Testing from JTreg + * -@RequirementID: None + * -@RequirementName: some testcases will be moved to FigtoTest when enable JTreg. + * -@Condition:no + * -#c1: 测试环境正常 + * -@Brief:将该用例从JTreg中摘出来,放到CI和组件daily测试中测试。该用例在JTreg连跑中会挂掉 + * -@Expect:ExpectResult\n + * -@Priority: High + * -@Source: ConstCharAppend.java + * -@ExecuteClass: ConstCharAppend + * -@ExecuteArgs: + * -@Remark: + */ + +public class ConstCharAppend { + public static void main(String[] args) { + if (!("" + 'a' + 'b').equals("ab")) { + System.out.println("append of chars is wrong: 4103959"); + } else { + System.out.println("ExpectResult"); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0509-JTreg-RelaxedArrays/RelaxedArrays.java b/test/testsuite/ouroboros/rc_test/RC0509-JTreg-RelaxedArrays/RelaxedArrays.java new file mode 100755 index 0000000000000000000000000000000000000000..b7f5841d433d6e0e68a5fdd37371a3e13c730e06 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0509-JTreg-RelaxedArrays/RelaxedArrays.java @@ -0,0 +1,40 @@ +/* + * -@TestCaseID: RelaxedArrays + * -@TestCaseName: RelaxedArrays + * -@TestCaseType: Function Testing from JTreg + * -@RequirementID: None + * -@RequirementName: some testcases will be moved to FigtoTest when enable JTreg. + * -@Condition:no + * -#c1: 测试环境正常 + * -@Brief:将该用例从JTreg中摘出来,放到CI和组件daily测试中测试。该用例在JTreg连跑中会挂掉 + * -@Expect:ExpectResult\n + * -@Priority: High + * -@Source: RelaxedArrays.java + * -@ExecuteClass: RelaxedArrays + * -@ExecuteArgs: + * -@Remark: + */ + +import java.util.ArrayList; +import java.util.List; + +public class RelaxedArrays { + static T select(T... tl) { + return tl.length == 0 ? null : tl[tl.length - 1]; + } + + public static void main(String[] args) { + List[] a = new StringList[20]; + if (select("A", "B", "C") != "C") { + System.out.println("error"); + } else { + System.out.println("ExpectResult"); + } + } + + static class StringList extends ArrayList { + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0510-JTreg-T4711694/T4711694.java b/test/testsuite/ouroboros/rc_test/RC0510-JTreg-T4711694/T4711694.java new file mode 100755 index 0000000000000000000000000000000000000000..714cee482ca3cb08cfe82a37005ec7a5f3856771 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0510-JTreg-T4711694/T4711694.java @@ -0,0 +1,47 @@ +/* + * -@TestCaseID: T4711694 + * -@TestCaseName: T4711694 + * -@TestCaseType: Function Testing from JTreg + * -@RequirementID: None + * -@RequirementName: some testcases will be moved to FigtoTest when enable JTreg. + * -@Condition:no + * -#c1: 测试环境正常 + * -@Brief:将该用例从JTreg中摘出来,放到CI和组件daily测试中测试。该用例在JTreg连跑中会挂掉 + * -@Expect:ExpectResult\n + * -@Priority: High + * -@Source: T4711694.java + * -@ExecuteClass: T4711694 + * -@ExecuteArgs: + * -@Remark: + */ + +public class T4711694 { + public static void main(String[] args) { + D.main(args); + System.out.println("ExpectResult"); + } + + interface A { + void f(T u); + } + + static class B { + public void f(Integer i) { + } + } + + static abstract class C extends B implements A { + public void g(T t) { + f(t); + } + } + + static class D extends C { + public static void main(String[] args) { + new D().g(new Integer(3)); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0511-JTreg-T7040104/T7040104.java b/test/testsuite/ouroboros/rc_test/RC0511-JTreg-T7040104/T7040104.java new file mode 100755 index 0000000000000000000000000000000000000000..7b94ef3a3800438e4f3aaf6dca6ae96d76f3f063 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0511-JTreg-T7040104/T7040104.java @@ -0,0 +1,62 @@ +/* + * -@TestCaseID: T7040104 + * -@TestCaseName: T7040104 + * -@TestCaseType: Function Testing from JTreg + * -@RequirementID: None + * -@RequirementName: some testcases will be moved to FigtoTest when enable JTreg. + * -@Condition:no + * -#c1: 测试环境正常 + * -@Brief:将该用例从JTreg中摘出来,放到CI和组件daily测试中测试。该用例在JTreg连跑中会挂掉 + * -@Expect:ExpectResult\n + * -@Priority: High + * -@Source: T7040104.java + * -@ExecuteClass: T7040104 + * -@ExecuteArgs: + * -@Remark: + */ + +public class T7040104 { + int npeCount = 0; + + public static void main(String[] args) { + T7040104 t = new T7040104(); + t.test1(); + t.test2(); + t.test3(); + if (t.npeCount != 3) { + System.out.println("error"); + } else { + System.out.println("ExpectResult"); + } + } + + void test1() { + Object[] a; + try { + Object o = (a = null)[0]; + } catch (NullPointerException npe) { + npeCount++; + } + } + + void test2() { + Object[][] a; + try { + Object o = (a = null)[0][0]; + } catch (NullPointerException npe) { + npeCount++; + } + } + + void test3() { + Object[][][] a; + try { + Object o = (a = null)[0][0][0]; + } catch (NullPointerException npe) { + npeCount++; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0512-JTreg-WrongNew/WrongNew.java b/test/testsuite/ouroboros/rc_test/RC0512-JTreg-WrongNew/WrongNew.java new file mode 100755 index 0000000000000000000000000000000000000000..dd47f1d01bff40544b2ecccfd2b75363b7e91300 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0512-JTreg-WrongNew/WrongNew.java @@ -0,0 +1,40 @@ +/* + * -@TestCaseID: WrongNew + * -@TestCaseName: WrongNew + * -@TestCaseType: Function Testing from JTreg + * -@RequirementID: None + * -@RequirementName: some testcases will be moved to FigtoTest when enable JTreg. + * -@Condition:no + * -#c1: 测试环境正常 + * -@Brief:将该用例从JTreg中摘出来,放到CI和组件daily测试中测试。该用例在JTreg连跑中会概率性挂掉 + * -@Expect:ExpectResult\n + * -@Priority: High + * -@Source: WrongNew.java + * -@ExecuteClass: WrongNew + * -@ExecuteArgs: + * -@Remark: + */ + +class WrongNewList { +} + +class WrongNewArrayList extends WrongNewList { +} + +public class WrongNew { + public static void main(String[] ps) { + WrongNewList list = getList(); + if (list != null) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } + + public static WrongNewList getList() { + return new WrongNewArrayList(); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0513-JTreg-T6481655/T6481655.java b/test/testsuite/ouroboros/rc_test/RC0513-JTreg-T6481655/T6481655.java new file mode 100755 index 0000000000000000000000000000000000000000..948320706dbdd831119d692b63166b4b7f691296 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0513-JTreg-T6481655/T6481655.java @@ -0,0 +1,32 @@ +/* + * -@TestCaseID: T6481655 + * -@TestCaseName: T6481655 + * -@TestCaseType: Function Testing from JTreg + * -@RequirementID: None + * -@RequirementName: some testcases will be moved to FigtoTest when enable JTreg. + * -@Condition:no + * -#c1: 测试环境正常 + * -@Brief:将该用例从JTreg中摘出来,放到CI和组件daily测试中测试。该用例在JTreg连跑中会概率性挂掉 + * -@Expect:ExpectResult\n + * -@Priority: High + * -@Source: T6481655.java + * -@ExecuteClass: T6481655 + * -@ExecuteArgs: + * -@Remark: + */ + +public class T6481655 { + + public static T getT(T t) { + return t; + } + + public static void main(String... s) { + if (T6481655.getT("").equals("") && (T6481655.getT("")).getClass().isInstance("java.lang.String")) { + System.out.println("ExpectResult"); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0514-JTreg-SingleLocalTest/SingleLocalTest.java b/test/testsuite/ouroboros/rc_test/RC0514-JTreg-SingleLocalTest/SingleLocalTest.java new file mode 100755 index 0000000000000000000000000000000000000000..f75e5c5c066e795f56079662965d929d84b1c819 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0514-JTreg-SingleLocalTest/SingleLocalTest.java @@ -0,0 +1,45 @@ +/* + * -@TestCaseID: SingleLocalTest + * -@TestCaseName: SingleLocalTest + * -@TestCaseType: Function Testing from JTreg + * -@RequirementID: None + * -@RequirementName: some testcases will be moved to FigtoTest when enable JTreg. + * -@Condition:no + * -#c1: 测试环境正常 + * -@Brief:将该用例从JTreg中摘出来,放到CI和组件daily测试中测试。该用例在JTreg连跑中会概率性挂掉 + * -@Expect:ExpectResult\n + * -@Priority: High + * -@Source: SingleLocalTest.java + * -@ExecuteClass: SingleLocalTest + * -@ExecuteArgs: + * -@Remark: + */ + +public class SingleLocalTest { + static F f; + + public static void main(String[] args) { + StringBuffer sb = new StringBuffer(); + class Local1 { + public Local1() { + f = () -> new Local1(); + sb.append("1"); + } + } + new Local1(); + f.f(); + String s = sb.toString(); + if (!s.equals("11")) { + System.out.println("Expected '11' got '" + s + "'"); + } else { + System.out.println("ExpectResult"); + } + } + + interface F { + void f(); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0515-GC-FrequentGCTest01/FrequentGCTest01.java b/test/testsuite/ouroboros/rc_test/RC0515-GC-FrequentGCTest01/FrequentGCTest01.java new file mode 100644 index 0000000000000000000000000000000000000000..2527e342052199d1b01bafb417077f8fc96ff3b3 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0515-GC-FrequentGCTest01/FrequentGCTest01.java @@ -0,0 +1,54 @@ +/* + *- @TestCaseID: GC-TaskQueue-FrequentGCTest01 + *- @TestCaseName: GC-TaskQueue-FrequentGCTest01 + *- @TestCaseType: FunctionTest + *- @RequirementName: 添加GC队列及Runtime.GC正确性保证 + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief: 验证频繁调用Runtime.getRuntime.gc(),GC队列仍然能保证GC的正确性。 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: FrequentGCTest01.java + *- @ExecuteClass: FrequentGCTest01 + *- @ExecuteArgs: + *- @Remark: + *- @Author: + */ + + +import java.lang.ref.WeakReference; + +public class FrequentGCTest01 { + static int a = 100; + + public static void main(String[] args) throws Exception { + for (int i = 0; i < 100; i++) { + WeakReference rp = new WeakReference(new Object()); + if (rp.get() == null) { + a++; + } + new Thread(new TriggerRP()).start(); + Runtime.getRuntime().gc(); + Thread.sleep(100); + if (rp.get() != null) { + a++; + } + if (a != 100) { + System.out.println("ErrorResult"); + return; + } + } + System.out.println("ExpectResult"); + } + + static class TriggerRP implements Runnable { + public void run() { + for (int i = 0; i < 10; i++) { + WeakReference wr = new WeakReference(new Object()); + } + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/RC0516-GC-FrequentGCTest02/FrequentGCTest02.java b/test/testsuite/ouroboros/rc_test/RC0516-GC-FrequentGCTest02/FrequentGCTest02.java new file mode 100644 index 0000000000000000000000000000000000000000..7fd2faec4037bb0aef53947e1b1961fd77523eec --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/RC0516-GC-FrequentGCTest02/FrequentGCTest02.java @@ -0,0 +1,44 @@ +/* + *- @TestCaseID: GC-TaskQueue-FrequentGCTest02 + *- @TestCaseName: GC-TaskQueue-FrequentGCTest02 + *- @TestCaseType: FunctionTest + *- @RequirementName: 添加GC队列及Runtime.GC正确性保证 + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief: art/maple的system.gc()里会限制频繁调用Runtime.getRuntime.gc().验证在程序初期内存充足的情况下,system.gc()不会实际执行垃圾回收操作。 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: FrequentGCTest02.java + *- @ExecuteClass: FrequentGCTest02 + *- @ExecuteArgs: + *- @Remark:该用例不能测试RC,只能测试GCOnly。原因是RC会直接将WeakReference清理掉。 + *- @Author: + */ + + +import java.lang.ref.WeakReference; + +public class FrequentGCTest02 { + static int a = 100; + + public static void main(String[] args) { + for (int i = 0; i < 100; i++) { + WeakReference rp = new WeakReference(new Object()); + if (rp.get() == null) { + a++; + } + System.gc(); + if (rp.get() == null) { + a++; + } + if (a != 100) { + System.out.println("ErrorResult"); + return; + } + } + System.out.println("ExpectResult"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/common_test/RC0305-rc-function-SubsumeRC01/SubsumeRC01.java b/test/testsuite/ouroboros/rc_test/common_test/RC0305-rc-function-SubsumeRC01/SubsumeRC01.java new file mode 100644 index 0000000000000000000000000000000000000000..cb32d91735861106eb71fc49512e6ddea33d1ca8 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/common_test/RC0305-rc-function-SubsumeRC01/SubsumeRC01.java @@ -0,0 +1,41 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/SubsumeRC01.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: test subsumerc for RC, return a field directly + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: SubsumeRC01.java + *- @ExecuteClass: SubsumeRC01 + *- @ExecuteArgs: + *- @Remark: + *- @ExpectMplCode: + *- callassigned &MRT_LoadRefField_NaiveRCFast ( + *- regread ref %2, + *- iaddrof ref <* <$LSubsumeRC01_3B>> 4 (regread ref %2)) { regassign ptr %1} + *- regassign ref %3 (regread ptr %1) + *- dassign %Reg0_R71 0 (regread ref %3) + *- intrinsiccall MPL_CLEANUP_LOCALREFVARS_SKIP (dread ref %Reg0_R71) + *- return (regread ref %3) + */ +public class SubsumeRC01 { + private String str; + + public String testfunc() { + return str; + } + + public static void main(String[] args){ + SubsumeRC01 temp = new SubsumeRC01(); + temp.testfunc(); + System.out.println("ExpectResult"); + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/common_test/RC0306-rc-function-SubsumeRC02/SubsumeRC02.java b/test/testsuite/ouroboros/rc_test/common_test/RC0306-rc-function-SubsumeRC02/SubsumeRC02.java new file mode 100755 index 0000000000000000000000000000000000000000..453b73c93c80b7fd760d7d58f8604c112bfb299b --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/common_test/RC0306-rc-function-SubsumeRC02/SubsumeRC02.java @@ -0,0 +1,43 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/SubsumeRC02.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: test subsumerc for RC, assign a value returned by function call to a field + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: SubsumeRC02.java + *- @ExecuteClass: SubsumeRC02 + *- @ExecuteArgs: + *- @Remark: + *- @ExpectMplCode: + *- callassigned &Native_java_lang_StringFactory_newStringFromString__Ljava_lang_String_2 (iread ref <* <* <$Ljava_2Flang_2FString_3B>>> 0 (addrof ptr $_PTR_C_STR_7400650073007400)) { regassign ref %1} + *- call &CC_WriteRefFieldNoInc ( + *- regread ref %2, + *- iaddrof ref <* <$LSubsumeRC02_3B>> 4 (regread ref %2), + *- regread ref %1) + */ +public class SubsumeRC02 { + private String str; + + public SubsumeRC02() { + } + + public void testfunc() { + str = new String("test"); + return ; + } + + public static void main(String[] args){ + SubsumeRC02 temp = new SubsumeRC02(); + temp.testfunc(); + System.out.println("ExpectResult"); + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/common_test/RC0307-rc-function-SubsumeRC03/SubsumeRC03.java b/test/testsuite/ouroboros/rc_test/common_test/RC0307-rc-function-SubsumeRC03/SubsumeRC03.java new file mode 100755 index 0000000000000000000000000000000000000000..bf3bfe36443184959a02411cfdbb81bc2374ff48 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/common_test/RC0307-rc-function-SubsumeRC03/SubsumeRC03.java @@ -0,0 +1,46 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/SubsumeRC03.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: test subsumerc for RC, assign another object's field to a field + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: SubsumeRC03.java + *- @ExecuteClass: SubsumeRC03 + *- @ExecuteArgs: + *- @Remark: + *- @ExpectMplCode: + *- callassigned &MRT_LoadRefField_NaiveRCFast ( + *- regread ref %2, + *- iaddrof ref <* <$LSubsumeRC03_3B>> 4 (regread ref %2)) { regassign ref %1} + *- call &CC_WriteRefFieldNoInc ( + *- regread ref %3, + *- iaddrof ref <* <$LSubsumeRC03_3B>> 4 (regread ref %3), + *- regread ref %1) + */ +public class SubsumeRC03 { + private String str; + + public SubsumeRC03() { + } + + public void testfunc(SubsumeRC03 t) { + str = t.str; + return ; + } + + public static void main(String[] args){ + SubsumeRC03 temp0 = new SubsumeRC03(); + SubsumeRC03 temp1 = new SubsumeRC03(); + temp1.testfunc(temp0); + System.out.println("ExpectResult"); + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/common_test/RC0308-rc-function-CondBasedRC01/CondBasedRC01.java b/test/testsuite/ouroboros/rc_test/common_test/RC0308-rc-function-CondBasedRC01/CondBasedRC01.java new file mode 100755 index 0000000000000000000000000000000000000000..e2aac95169dcd1c60cfaefff3b6fb888e4883922 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/common_test/RC0308-rc-function-CondBasedRC01/CondBasedRC01.java @@ -0,0 +1,54 @@ +/* + *- @TestCaseID:maple/runtime/rc/function/CondBasedRC01.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: test condbasedrc for RC, decref can be omitted if ref is null can be guaranteed + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: CondBasedRC01.java + *- @ExecuteClass: CondBasedRC01 + *- @ExecuteArgs: + *- @Remark: + */ +public class CondBasedRC01 { + private String str1; + public static String str2; + + public CondBasedRC01() { + } + + public String testfunc(String s) { + if (s == null) { + s = str1; + } + return s; + } + + public String strfunc() { + return str1; + } + + public String testfunc1() { + String t = strfunc(); + if (t == null) { + t = str1; + } + return t; + } + + public static void main(String[] args){ + CondBasedRC01 temp1 = new CondBasedRC01(); + String s = new String("test"); + str2 = temp1.testfunc(s); + str2 = temp1.testfunc1(); + System.out.println("ExpectResult"); + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/common_test/RC0427-rc-Annotation-RCMixTest/RCMixTest.java b/test/testsuite/ouroboros/rc_test/common_test/RC0427-rc-Annotation-RCMixTest/RCMixTest.java new file mode 100755 index 0000000000000000000000000000000000000000..27b04bdd102f0c566a00ce412a28eb08187f6e5c --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/common_test/RC0427-rc-Annotation-RCMixTest/RCMixTest.java @@ -0,0 +1,112 @@ +/* + *- @TestCaseID:maple/runtime/rc/annotation/Permanent/RCPermanentTest6 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:Weak 或Unowned和Permanent一起用在一个对象的case,验证是否能够正常被释放 + *- @Condition: + * -#c1: + *- @Brief:functionTest + * -#step1: + * Weak 或Unowned和Permanent一起用在一个对象的case,验证是否能够正常被释放 + *- @Expect:ExpectResult\nExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: RCMixTest.java + *- @ExecuteClass: RCMixTest + *- @ExecuteArgs: + *- @Remark: + *- @Author:liuweiqing l00481345 + */ + +import com.huawei.ark.annotation.*; + +import java.lang.reflect.Field; + + +public class RCMixTest { + + + public static void main(String[] args) { + + new Test_A_Weak().test(); + new Test_A_Unowned().test(); + Runtime.getRuntime().gc(); + } +} + +class Test_A_Weak { + @Weak + Test_B_Weak bb; + Test_B_Weak bb2; + + public void test() { + foo(); + try { + Thread.sleep(5000); + } catch (Exception e) { + e.printStackTrace(); + } + try { + bb.run(); + } catch (NullPointerException e) { + System.out.println("NullPointerException"); + } + bb2.run(); + } + + private void foo() { + bb = new @Permanent Test_B_Weak(); + bb2 = new Test_B_Weak(); + } +} + +class Test_B_Weak { + public void run() { + System.out.println("ExpectResult"); + } +} + + +class Test_B_Unowned { + @Unowned + Test_A_Unowned aa ; + + // add volatile will crash + // static Test_A a1; + + protected void finalize() { + System.out.println("ExpectResult"); + } +} + +class Test_A_Unowned { + Test_B_Unowned bb; + + public void test() { + setReferences(); + System.runFinalization(); + } + + private void setReferences() { + @Unowned + Test_A_Unowned ta; + ta = new @Permanent Test_A_Unowned(); + ta.bb = new Test_B_Unowned(); + //ta.bb.aa = ta; + + try { + Field m = Test_B_Unowned.class.getDeclaredField("aa"); + m.set(ta.bb, ta); + Test_A_Unowned a_temp = (Test_A_Unowned) m.get(ta.bb); + if (a_temp != ta) { + System.out.println("error"); + } + } catch (Exception e) { + System.out.println(e); + } + + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/common_test/RC0428-rc-Annotation-RCMixThreadTest/RCMixThreadTest.java b/test/testsuite/ouroboros/rc_test/common_test/RC0428-rc-Annotation-RCMixThreadTest/RCMixThreadTest.java new file mode 100755 index 0000000000000000000000000000000000000000..338de8f0c7f44e2e462c68bde6f721acbca5d646 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/common_test/RC0428-rc-Annotation-RCMixThreadTest/RCMixThreadTest.java @@ -0,0 +1,99 @@ +/* + *- @TestCaseID:maple/runtime/rc/annotation/Permanent/RCMixThreadTest + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:多线程下调用Weak 或Unowned和Permanent一起用在一个对象的case,验证是否能够正常被释放 + *- @Condition: + * -#c1: + *- @Brief:functionTest + * -#step1: + * 多线程下调用Weak 或Unowned和Permanent一起用在一个对象的case,验证是否能够正常被释放 + *- @Expect:ExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: RCMixThreadTest.java + *- @ExecuteClass: RCMixThreadTest + *- @ExecuteArgs: + *- @Remark: + */ + +import java.lang.reflect.Field; +import java.util.ArrayList; + +import com.huawei.ark.annotation.*; + + +public class RCMixThreadTest { + public static void main(String[] args) throws InterruptedException { + rc_testcase_main_wrapper(); + } + + public static void rc_testcase_main_wrapper() throws InterruptedException { + RCMixTest_Weak rcMixTest_weak = new RCMixTest_Weak(); + RCMixTest_Weak rcMixTest_weak2 = new RCMixTest_Weak(); + RCMixTest_Weak rcMixTest_weak3 = new RCMixTest_Weak(); + RCMixTest_Weak rcMixTest_weak4 = new RCMixTest_Weak(); + RCMixTest_Weak rcMixTest_weak5 = new RCMixTest_Weak(); + + rcMixTest_weak.start(); + rcMixTest_weak2.start(); + rcMixTest_weak3.start(); + rcMixTest_weak4.start(); + rcMixTest_weak5.start(); + + rcMixTest_weak.join(); + rcMixTest_weak2.join(); + rcMixTest_weak3.join(); + rcMixTest_weak4.join(); + rcMixTest_weak5.join(); + } +} + + +class RCMixTest_Weak extends Thread { + + public void run() { + new Test_A_Weak().test(); + } +} + + + +class Test_A_Weak { + @Weak + Test_B_Weak bb; + Test_B_Weak bb2; + + public void test() { + foo(); + try { + Thread.sleep(5000); + } catch (Exception e) { + e.printStackTrace(); + } + try { + bb.run(); + } catch (NullPointerException e) { + System.out.println("NullPointerException"); + } + bb2.run(); + } + + private void foo() { + bb = new @Permanent Test_B_Weak(); + bb2 = new Test_B_Weak(); + } +} + +class Test_B_Weak { + public void run() { + System.out.println("ExpectResult"); + } +} + + + + + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/common_test/RC0434-rc-SoftRef-SoftRefTest04/SoftRefTest04.java b/test/testsuite/ouroboros/rc_test/common_test/RC0434-rc-SoftRef-SoftRefTest04/SoftRefTest04.java new file mode 100755 index 0000000000000000000000000000000000000000..4561c5164012525cd46a04b8c760e78fb340b711 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/common_test/RC0434-rc-SoftRef-SoftRefTest04/SoftRefTest04.java @@ -0,0 +1,78 @@ +/* + * -@TestCaseID:SoftRefTest04.java + * -@TestCaseName:MyselfClassName + * -@RequirementName:[运行时需求]支持自动内存管理 + * -@Title/Destination: 通过OOM 触发gc时,SoftReference对象会被回收掉 + * -@Condition: no + * -#c1 + * -@Brief:functionTest + * -#step1:创建一个SoftReference对象,并将其放到ReferneceQueue中,该对象不应该被释放; + * -#step2:通过制造OOM进行GC + * -#step3:再次确认该对象应该被释放,且它所在的ReferenceQueue中有这个即将回收的Reference对象 + * -@Expect:ExpectResult\n + * -@Priority: High + * -@Source: SoftRefTest04.java + * -@ExecuteClass: SoftRefTest04 + * -@ExecuteArgs: + * -@Remark: + * + */ + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.SoftReference; +import java.util.ArrayList; + +public class SoftRefTest04 { + private static Reference rp; + private static ReferenceQueue rq = new ReferenceQueue(); + private static int a = 100; + private static ArrayList store; + + static void setSoftReference() { + rp = new SoftReference(new Object(), rq); + if (rp.get() == null) { + System.out.println("Error Result when first check "); + a++; + } + } + + private static int oomTest() { + int sum = 0; + store = new ArrayList(); + byte[] temp; + for (int i = 1024 * 1024; i <= 1024 * 1024 * 10; ) { + temp = new byte[i]; + store.add(temp); + sum += store.size(); + } + return sum; + } + + public static void main(String[] args) throws Exception { + setSoftReference(); + try { + int Result = oomTest(); + } catch (OutOfMemoryError o) { + // do nothing + } + if (rp.get() != null) { + System.out.println("Error Result when second check "); + a++; + } + Thread.sleep(500); + Reference r = rq.poll(); + if (r == null) { + System.out.println("Error Result when checking ReferenceQueue"); + a++; + } + if (a == 100) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult finally"); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/common_test/RC0436-rc-SoftRef-SoftRefTest06/SoftRefTest06.java b/test/testsuite/ouroboros/rc_test/common_test/RC0436-rc-SoftRef-SoftRefTest06/SoftRefTest06.java new file mode 100755 index 0000000000000000000000000000000000000000..ec0c4b7260174f254258dcb730ca7f6c640e42a2 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/common_test/RC0436-rc-SoftRef-SoftRefTest06/SoftRefTest06.java @@ -0,0 +1,81 @@ +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.SoftReference; +import java.util.ArrayList; + +/* + * -@TestCaseID:SoftRefTest06.java + * -@TestCaseName:MyselfClassName + * -@RequirementName:[运行时需求]支持自动内存管理 + * -@Title/Destination: SoftReference指向的对象在回收的时候,会触发自己的finalize方法。 + * -@Condition: no + * -#c1 + * -@Brief:functionTest + * -#step1:SoftReference指向一个软引用,该对象声明周期结束后,会立刻被回收; + * -#step2:执行一次后,进行一遍gc,进行环的自学习; + * -#step3:再执行一次后,判断环关联的软对象不应该被释放。 + * -@Expect:ExpectResult1\nExpectResult2\n + * -@Priority: High + * -@Source: SoftRefTest06.java + * -@ExecuteClass: SoftRefTest06 + * -@ExecuteArgs: + * -@Remark: + * + */ + +public class SoftRefTest06 { + private static Reference rp; + private static ReferenceQueue rq = new ReferenceQueue(); + private static ArrayList store; + private static int count = 1; + + // 生命周期结束的软指针指向的对象,应该被释放,放到它的ReferenceQueue里 + public static void objectDeadNormally() { + Reference sr = new SoftReference(new SoftRefTest06(), rq); + if (sr.get() == null) { + System.out.println("ErrorResult"); + } + // sr will die now. + } + + private static int oomTest() { + int sum = 0; + store = new ArrayList(); + byte[] temp; + for (int i = 1024 * 1024; i <= 1024 * 1024 * 10; ) { + temp = new byte[i]; + store.add(temp); + sum += store.size(); + } + return sum; + } + + private static void setSoftRef() { + // oom出发,回收软引用对象使用的内存 + rp = new SoftReference(new SoftRefTest06(), rq); + } + + public static void main(String[] args) { + objectDeadNormally(); + Runtime.getRuntime().runFinalization(); + setSoftRef(); + try { + int oom = oomTest(); + } catch (OutOfMemoryError ofm) { + // do nothing + } + if (rp.get() != null) { + System.out.println("Error Result when second check "); + } + Runtime.getRuntime().runFinalization(); + } + + @Override + public void finalize() { + System.out.println("ExpectResult" + count); + count++; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult1\nExpectResult2\n diff --git a/test/testsuite/ouroboros/rc_test/common_test/RC0437-rc-RCHeader-RCHeaderTest/RCHeaderTest.java b/test/testsuite/ouroboros/rc_test/common_test/RC0437-rc-RCHeader-RCHeaderTest/RCHeaderTest.java new file mode 100755 index 0000000000000000000000000000000000000000..d629ac0c62bba147ca0d830b9337d3122a5be553 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/common_test/RC0437-rc-RCHeader-RCHeaderTest/RCHeaderTest.java @@ -0,0 +1,66 @@ +/* + *- @TestCaseID:RCHeaderTest.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: 可以在不触发RP的情况下,及时回收cleaner referent引用的资源和对象 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1:在方法体内为一个强引用加上一个Cleaner指向它; + * -#step2:强引用声明周期结束后,可以在不触发RP的情况下,应该会被立刻释放该对象占用的内存(Cleaner没有缓存语义) + *- @Expect:ExpectResult\nExpectResultEnd\n + *- @Priority: High + *- @Source: RCHeaderTest.java + *- @ExecuteClass: RCHeaderTest + *- @ExecuteArgs: + *- @Remark: + * + */ + +import sun.misc.Cleaner; + +class RCRunner implements Runnable { + public void run() { + RCHeaderTest.iArray = null; + } +} + +class Resource { + + @Override + public void finalize() { + System.out.println("ExpectResult"); + } +} + + +public class RCHeaderTest { + static int[] iArray; + static Cleaner c = null; + Resource res; + + public RCHeaderTest() { + iArray = new int[4]; + res = new Resource(); + } + + static void foo() { + RCHeaderTest rcht = new RCHeaderTest(); + c = Cleaner.create(rcht, new RCRunner()); + if (c == null) { + System.out.println("Cleaner create failly"); + } + } + + public static void main(String[] args) { + foo(); + Runtime.getRuntime().runFinalization(); + System.out.println("ExpectResultEnd"); //ReleaseEnd + + } +} + + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResultEnd\n diff --git a/test/testsuite/ouroboros/rc_test/common_test/RC0438-rc-RCHeader-RCHeaderTest02/RCHeaderTest02.java b/test/testsuite/ouroboros/rc_test/common_test/RC0438-rc-RCHeader-RCHeaderTest02/RCHeaderTest02.java new file mode 100755 index 0000000000000000000000000000000000000000..d81849e841b3ecf62d4ad6ee71b7f577429f9c31 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/common_test/RC0438-rc-RCHeader-RCHeaderTest02/RCHeaderTest02.java @@ -0,0 +1,87 @@ +/* + *- @TestCaseID:RCHeaderTest02.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: 软指针指向的对象生命周期结束后,仍及时回收cleaner referent引用的资源和对象 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1:在方法体内为一个具有缓存语义的软引用rcht.sr加上一个Cleaner指向它; + * -#step2:该软引用生命周期结束后,应该会立刻释放该对象占用的内存(Cleaner没有缓存语义) + *- @Expect:ExpectResult\nExpectResultEnd\n + *- @Priority: High + *- @Source: RCHeaderTest02.java + *- @ExecuteClass: RCHeaderTest02 + *- @ExecuteArgs: + *- @Remark: + * + */ + +import sun.misc.Cleaner; +import java.util.ArrayList; +import java.lang.ref.SoftReference; + +class RCRunner02 implements Runnable { + public void run() { + RCHeaderTest02.iArray = null; + } +} + +class Resource02 { + + @Override + public void finalize() { + System.out.println("ExpectResult"); + } +} + + +public class RCHeaderTest02 { + private static ArrayList store; + static int[] iArray; + static Cleaner c = null; + Resource02 res02 = null; + + public RCHeaderTest02() { + iArray = new int[4]; + res02 = new Resource02(); + + } + + //方法退出后,sr_rcht02声明周期结束,触发对SoftReference的处理,它指向的对象占用空间被释放。 + static void foo() { + SoftReference sr_rcht02 = new SoftReference<>(new RCHeaderTest02()); + c = Cleaner.create(sr_rcht02, new RCRunner02()); + if (sr_rcht02.get() == null || c == null) { + System.out.println("SoftReference error or Cleaner create failly"); + } + } + + private static int oomTest() { + int sum = 0; + store = new ArrayList(); + byte[] temp; + + for (int i = 1024 * 1024; i <= 1024 * 1024 * 10; ) { + temp = new byte[i]; + store.add(temp); + sum += store.size(); + } + return sum; + } + + public static void main(String[] args) { + foo(); + try { + int oom = oomTest(); + } catch (OutOfMemoryError ofm) {} + Runtime.getRuntime().runFinalization(); + System.out.println("ExpectResultEnd"); //ReleaseEnd + } +} + + + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResultEnd\n diff --git a/test/testsuite/ouroboros/rc_test/common_test/RC0439-rc-RCHeader-RCHeaderTest03/RCHeaderTest03.java b/test/testsuite/ouroboros/rc_test/common_test/RC0439-rc-RCHeader-RCHeaderTest03/RCHeaderTest03.java new file mode 100644 index 0000000000000000000000000000000000000000..20ba4e87ffce7e5c2de1a01c8e368e0d7def2e34 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/common_test/RC0439-rc-RCHeader-RCHeaderTest03/RCHeaderTest03.java @@ -0,0 +1,94 @@ +/* + *- @TestCaseID:RCHeaderTest03.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: 软指针指向的对象声明周期结束后,cleaner referent和Weak Annotation referent引用的资源和对象是会释放的 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1:在方法体内为一个具有缓存语义的软引用rcht.sr加上一个Cleaner和一个Weak Annotation指向它; + * -#step2:该软引用生命回收后,应该会立刻释放该对象占用的内存(Cleaner和Weak Annotation对象没有缓存语义) + *- @Expect:oom occured\nSR release\nExpectResult\n + *- @Priority: High + *- @Source: RCHeaderTest03.java + *- @ExecuteClass: RCHeaderTest03 + *- @ExecuteArgs: + *- @Remark: + * + */ + +import sun.misc.Cleaner; +import java.util.ArrayList; +import java.lang.ref.SoftReference; + +import com.huawei.ark.annotation.Weak; + +class RCRunner03 implements Runnable { + public void run() { + RCHeaderTest03.iArray = null; + } +} + + +public class RCHeaderTest03 { + static String[] iArray; + private static ArrayList store; + String @Weak [] wr_annotation = null; + Cleaner c = null; + SoftReference sr = null; + + public RCHeaderTest03() { + iArray = new String[4]; + String[] temp = {"1", "2", "3", "4"}; + wr_annotation = temp; + sr = new SoftReference<>(temp); + } + + //方法退出后,实例变量sr声明周期结束,触发对SoftReference的处理,它指向的数组占用空间被释放。 + void foo() { + c = Cleaner.create(wr_annotation, new RCRunner03()); + if (c == null || wr_annotation.length != 4) { + System.out.println("Cleaner create failly"); + } + } + + private static int oomTest() { + int sum = 0; + store = new ArrayList(); + byte[] temp; + + for (int i = 1024 * 1024; i <= 1024 * 1024 * 10; ) { + temp = new byte[i]; + store.add(temp); + sum += store.size(); + } + return sum; + } + + public static void main(String[] args) { + RCHeaderTest03 rcht = new RCHeaderTest03(); + rcht.foo(); + try { + int oom = oomTest(); + } catch (OutOfMemoryError ofm) { + System.out.println("oom occured"); + } + Runtime.getRuntime().gc(); + if (rcht.sr.get() == null ) { + System.out.println("SR release"); + } + try { + Thread.sleep(5000); + } catch (Exception e) { + e.printStackTrace(); + } + if (rcht.wr_annotation == null) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full oom occured\nSR release\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/common_test/RC0441-rc-RCHeader-RCHeaderTest06/RCHeaderTest06.java b/test/testsuite/ouroboros/rc_test/common_test/RC0441-rc-RCHeader-RCHeaderTest06/RCHeaderTest06.java new file mode 100755 index 0000000000000000000000000000000000000000..f0db267cf08a0438fe7a1ebfc5f580549296aac5 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/common_test/RC0441-rc-RCHeader-RCHeaderTest06/RCHeaderTest06.java @@ -0,0 +1,69 @@ +/* + *- @TestCaseID:RCHeaderTest06.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: 可以在不触发RP的情况下,及时回收Weak Annoatation referent和Cleaner 共同引用的资源和Finalize对象 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1:在方法体内为一个强引用加上一个Weak Annoatation referent指向它; + * -#step2:强引用声明周期结束后,可以在不触发RP的情况下,应该会被立刻释放该对象占用的内存(Weak Annoatation referent没有缓存语义) + *- @Expect:ExpectResult\nExpectResultEnd\n + *- @Priority: High + *- @Source: RCHeaderTest06.java + *- @ExecuteClass: RCHeaderTest06 + *- @ExecuteArgs: + *- @Remark: + * + */ + +import sun.misc.Cleaner; + +import com.huawei.ark.annotation.Weak; +class RCRunner06 implements Runnable { + public void run() { + RCHeaderTest06.iArray = null; + } +} + +class Resource06 { + + + @Override + public void finalize() { + System.out.println("ExpectResult"); + } +} + + +public class RCHeaderTest06 { + static int[] iArray; + static Cleaner cleaner = null; + @Weak + Resource06 c = null; + + public RCHeaderTest06() { + iArray = new int[4]; + c = new Resource06(); + } + + static void foo() { + RCHeaderTest06 rcht = new RCHeaderTest06(); + RCHeaderTest06.cleaner = Cleaner.create(rcht.c, new RCRunner06()); + if (cleaner == null) { + System.out.println("Weak Annotation Object shouldn't be null"); + } + } + + public static void main(String[] args) { + foo(); + Runtime.getRuntime().runFinalization(); + System.out.println("ExpectResultEnd"); + + } +} + + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResultEnd\n diff --git a/test/testsuite/ouroboros/rc_test/common_test/RC0442-rc-RCHeader-RCHeaderTest07/RCHeaderTest07.java b/test/testsuite/ouroboros/rc_test/common_test/RC0442-rc-RCHeader-RCHeaderTest07/RCHeaderTest07.java new file mode 100755 index 0000000000000000000000000000000000000000..bd9e6292f3761a61c2a9b8eaf9161717be5e541a --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/common_test/RC0442-rc-RCHeader-RCHeaderTest07/RCHeaderTest07.java @@ -0,0 +1,66 @@ +/* + *- @TestCaseID:RCHeaderTest07.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination: 可以在不触发RP的情况下,及时回收cleaner referent引用的资源和Finalize对象 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1:在方法体内为一个强引用的finalize对象域加上一个Cleaner指向它; + * -#step2:强引用声明周期结束后,可以在不触发RP的情况下,应该会被立刻释放该对象占用的内存(Cleaner没有缓存语义) + *- @Expect:ExpectResult\nExpectResultEnd\n + *- @Priority: High + *- @Source: RCHeaderTest07.java + *- @ExecuteClass: RCHeaderTest07 + *- @ExecuteArgs: + *- @Remark: + * + */ + +import sun.misc.Cleaner; +class RCRunner07 implements Runnable { + public void run() { + RCHeaderTest07.iArray = null; + } +} + +class Resource07 { + + + @Override + public void finalize() { + System.out.println("ExpectResult"); + } +} + + +public class RCHeaderTest07 { + static int[] iArray; + static Cleaner c = null; + Resource07 res; + + public RCHeaderTest07() { + iArray = new int[4]; + res = new Resource07(); + } + + static void foo() { + RCHeaderTest07 rcht = new RCHeaderTest07(); + c = Cleaner.create(rcht.res, new RCRunner07()); + if (c == null) { + System.out.println("Cleaner create failly"); + } + } + + public static void main(String[] args) { + foo(); + Runtime.getRuntime().runFinalization(); + System.out.println("ExpectResultEnd"); + } +} + + + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResultEnd\n diff --git a/test/testsuite/ouroboros/rc_test/common_test/RC0445-rc-PlacementRC-PlacementRCTest03/PlacementRCTest03.java b/test/testsuite/ouroboros/rc_test/common_test/RC0445-rc-PlacementRC-PlacementRCTest03/PlacementRCTest03.java new file mode 100755 index 0000000000000000000000000000000000000000..7b1fc2a93ef102ee8987c2fcbcea07aa61375b23 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/common_test/RC0445-rc-PlacementRC-PlacementRCTest03/PlacementRCTest03.java @@ -0,0 +1,176 @@ +/* + *- @TestCaseID:PlacementRCTest03.java + *- @TestCaseName:MyselfClassName + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:检测在跳转语句(break, continue, return)控制流中,生命周期结束的对象,应该会被立即回收 + *- @Condition: no + * -#c1 + *- @Brief:functionTest + * -#step1:函数1做在continue ; continue tag的跳转for循环里,检查局部变量的及时回收情况 + * -#step2:函数2做在return的跳转for循环里,检查局部变量的及时回收情况 + * -#step3:函数3做在break的跳转do-while循环里,检查局部变量的及时回收情况 + *- @Expect:a10\na2_i91_j4\nExpect Result\n + *- @Priority: High + *- @Source: PlacementRCTest03.java + *- @ExecuteClass: PlacementRCTest03 + *- @ExecuteArgs: + *- @Remark: + * + * + */ + + +class PlacementRC_A3 { + public int count = 0; + public String className = "temp"; + + public PlacementRC_A3(String name) { + this.className = name; + } + + public void changeName(String name) { + this.className = name; + } + + @Override + public void finalize() throws Throwable { + super.finalize(); + synchronized (PlacementRCTest03.lock) { + if (this.count % 25 == 0) { + PlacementRCTest03.result += ("End" + count); + } + } + } + +} + +public class PlacementRCTest03 { + public static String result = new String(); + public static String lock = ""; + private volatile static int count = 0; + private PlacementRC_A3 defInsideUseOutside = null; + + //def outside, only use inside loop + public static void onlyUseInsideLoop() { + PlacementRC_A3 a1 = new PlacementRC_A3("a1"); + continueTag: + for (count = 0; count < 100; count++) { + a1.changeName("a" + count); + a1.count = count; + if (count % 95 == 0) { + count = 100; + continue continueTag; + } + if (count % 4 == 0) { + if (count % 8 == 0) + continue; + a1.changeName("a" + 100); + a1 = new PlacementRC_A3("a10"); + a1.toString(); + } + if (count >= 95) + System.out.println("Wrong Result"); + } + Runtime.getRuntime().runFinalization(); + synchronized (PlacementRCTest03.lock) { + result += "Method1"; + } + } + + public static PlacementRC_A3 defAndUseInsideLoop() { + for (count = 0; count < 100; count++) { + PlacementRC_A3 a2 = new PlacementRC_A3("a2_i" + count); + a2.count = count; + a2.changeName("null"); + for (int j = 0; j < 2; j++) + a2 = new PlacementRC_A3("a2_i" + count + "_j" + j); + if (count % 4 == 0) { + a2.changeName("a" + 100); + a2 = new PlacementRC_A3("a10"); + if (count == 96) { + Runtime.getRuntime().runFinalization(); + synchronized (PlacementRCTest03.lock) { + result += "Method2"; + } + return a2; + } + a2.toString(); + } else { + a2.toString(); + + } + } + Runtime.getRuntime().runFinalization(); + synchronized (PlacementRCTest03.lock) { + result += "Method2"; + } + return new PlacementRC_A3("wrong"); + } + + public static void main(String[] args) { + onlyUseInsideLoop(); + System.out.println(defAndUseInsideLoop().className); + new PlacementRCTest03().defInsideAndUseOutsideLoop(); + //System.out.println(result); + if(result.contains("Method1") && result.contains("Method2") && result.contains("Method3") && result.contains("End")) + System.out.println("Expect Result"); + else + System.out.println("Error Result"); + + } + + public void defInsideAndUseOutsideLoop() { + count = 0; + breakTag: + do { + int choice = count % 4; + this.defInsideUseOutside = new PlacementRC_A3("a2_i" + count); + switch (choice) { + case 1: + for (int j = 0; j < 5; j++) { + this.defInsideUseOutside = new PlacementRC_A3("a2_i" + count + "_j" + j); + this.defInsideUseOutside.count = count; + } + if (count == 99) + this.defInsideUseOutside.toString(); + break; + case 2: + for (int j = 0; j < 2; j++) { + this.defInsideUseOutside.changeName("a2_i" + count + "_j" + j); + this.defInsideUseOutside.count = count; + } + break; + case 3: + for (int j = 0; j < 5; j++) { + this.defInsideUseOutside = new PlacementRC_A3("a2_i" + count + "_j" + j); + this.defInsideUseOutside.count = count; + } + if (this.defInsideUseOutside.className.equals("a2_i91_j4")) { + System.out.println(this.defInsideUseOutside.className); + break breakTag; + } + if (this.defInsideUseOutside.className.equals("a2_i99_j4")) { + System.out.println(this.defInsideUseOutside.className); + break breakTag; + } + + break; + default: + this.defInsideUseOutside = new PlacementRC_A3("a2_i" + count); + this.defInsideUseOutside.count = count; + } + count++; + } while (this.defInsideUseOutside.count < 100 && count < 100); + this.defInsideUseOutside.changeName("finish"); + this.defInsideUseOutside = null; + Runtime.getRuntime().runFinalization(); + synchronized (PlacementRCTest03.lock) { + result += "Method3"; + } + } +} + + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full a10\na2_i91_j4\nExpect Result\n diff --git a/test/testsuite/ouroboros/rc_test/common_test/RC0471-rc-BindingMethod-UnsafeTest01/UnsafeTest01.java b/test/testsuite/ouroboros/rc_test/common_test/RC0471-rc-BindingMethod-UnsafeTest01/UnsafeTest01.java new file mode 100644 index 0000000000000000000000000000000000000000..8166eb533058c647062307822fd95cfa4f744afd --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/common_test/RC0471-rc-BindingMethod-UnsafeTest01/UnsafeTest01.java @@ -0,0 +1,82 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_UnsafeTest01 + *- @TestCaseName: UnsafeTest01 + *- @TestCaseType: Function Testing for MemoryBindingMethod Test + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief:unsafe.compareAndSwapObject()函数专项测试:验证compareAndSwapObject()方法的基本功能正常。 + * -#step1: + *- @Expect:0\n + *- @Priority: High + *- @Source:UnsafeTest01.java + *- @ExecuteClass:UnsafeTest01 + *- @ExecuteArgs: + *- @Remark: + */ + +import sun.misc.Unsafe; +import java.io.PrintStream; +import java.lang.reflect.Field; + +public class UnsafeTest01 { + private static int res = 99; + public static void main(String[] args){ + System.out.println(run(args, System.out)); + } + + private static int run(String[] args, PrintStream out){ + int result = 2/*STATUS_FAILED*/; + try { + result = UnsafecompareAndSwapObjectTest_1(); + } catch(Exception e){ + e.printStackTrace(); + UnsafeTest01.res = UnsafeTest01.res - 10; + } + if (result == 3 && UnsafeTest01.res == 97){ + result =0; + } + return result; + } + + private static int UnsafecompareAndSwapObjectTest_1(){ + Unsafe unsafe; + Field field; + Field param; + Object obj; + long offset; + Object result; + try{ + field = Unsafe.class.getDeclaredField("theUnsafe"); + field.setAccessible(true); + unsafe = (Unsafe)field.get(null); + obj = new Billie5(); + param = Billie5.class.getDeclaredField("owner"); + offset = unsafe.objectFieldOffset(param); + unsafe.compareAndSwapObject(obj, offset, "Me", "billie5"); + result = unsafe.getObject(obj, offset); + if(result.equals("billie5")){ + UnsafeTest01.res -= 2; + } + }catch (NoSuchFieldException e){ + e.printStackTrace(); + return 40; + }catch (IllegalAccessException e){ + e.printStackTrace(); + return 41; + } + return 3; + } +} + +class Billie5{ + public int height = 8; + private String[] color = {"black","white"}; + private String owner = "Me"; + private byte length = 0x7; + private String[] water = {"day","wet"}; + private long weight = 100L; +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/test/testsuite/ouroboros/rc_test/common_test/RC0472-rc-BindingMethod-UnsafeTest02/UnsafeTest02.java b/test/testsuite/ouroboros/rc_test/common_test/RC0472-rc-BindingMethod-UnsafeTest02/UnsafeTest02.java new file mode 100644 index 0000000000000000000000000000000000000000..a093f1a2c855467933acf37ecb20d69e19eca28b --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/common_test/RC0472-rc-BindingMethod-UnsafeTest02/UnsafeTest02.java @@ -0,0 +1,85 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_UnsafeTest02 + *- @TestCaseName: UnsafeTest02 + *- @TestCaseType: Function Testing for MemoryBindingMethod Test + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief:unsafe.getObjectVolatile()函数专项测试:验证getObjectVolatile()方法的基本功能正常。 + * -#step1: + *- @Expect:0\n + *- @Priority: High + *- @Source:UnsafeTest02.java + *- @ExecuteClass:UnsafeTest02 + *- @ExecuteArgs: + *- @Remark: + */ + +import sun.misc.Unsafe; +import java.io.PrintStream; +import java.lang.reflect.Field; + +public class UnsafeTest02 { + private static int res = 99; + public static void main(String[] args){ + System.out.println(run(args, System.out)); + } + + private static int run(String[] args, PrintStream out){ + int result = 2/*STATUS_FAILED*/; + try { + result = UnsafegetObjectVolatileTest_1(); + } catch(Exception e){ + e.printStackTrace(); + UnsafeTest02.res -= 2; + } + + if (result == 3 && UnsafeTest02.res == 97){ + result =0; + } + return result; + } + + private static int UnsafegetObjectVolatileTest_1(){ + Unsafe unsafe; + Field field; + Long offset; + Field param; + Object obj; + Object result; + try{ + field = Unsafe.class.getDeclaredField("theUnsafe"); + field.setAccessible(true); + unsafe = (Unsafe)field.get(null); + param = Billie10.class.getDeclaredField("lastname"); + offset = unsafe.objectFieldOffset(param); + obj = new Billie10(); + result = unsafe.getObjectVolatile(obj, offset); + if(result.equals("eilish")){ + UnsafeTest02.res -= 2; + } + }catch (NoSuchFieldException e){ + e.printStackTrace(); + return 40; + }catch (IllegalAccessException e){ + e.printStackTrace(); + return 41; + } + return 3; + } +} + +class Billie10{ + public int height = 8; + private String[] color = {"black","white"}; + private String owner = "Me"; + private byte length = 0x7; + private String[] water = {"day","wet"}; + private long weight = 100L; + private volatile int age = 18; + private volatile long birth = 20010214L; + private volatile String lastname = "eilish"; +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/test/testsuite/ouroboros/rc_test/common_test/RC0473-rc-BindingMethod-UnsafeTest03/UnsafeTest03.java b/test/testsuite/ouroboros/rc_test/common_test/RC0473-rc-BindingMethod-UnsafeTest03/UnsafeTest03.java new file mode 100644 index 0000000000000000000000000000000000000000..3f49ea7787a57fb372cbd09305ffec263eb026ff --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/common_test/RC0473-rc-BindingMethod-UnsafeTest03/UnsafeTest03.java @@ -0,0 +1,85 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_UnsafeTest03 + *- @TestCaseName: UnsafeTest03 + *- @TestCaseType: Function Testing for MemoryBindingMethod Test + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief:unsafe.getObject()函数专项测试:验证getObject()方法的基本功能正常。 + * -#step1: + *- @Expect:0\n + *- @Priority: High + *- @Source:UnsafeTest03.java + *- @ExecuteClass:UnsafeTest03 + *- @ExecuteArgs: + *- @Remark: + */ + +import sun.misc.Unsafe; +import java.io.PrintStream; +import java.lang.reflect.Field; + +public class UnsafeTest03 { + private static int res = 99; + public static void main(String[] args){ + System.out.println(run(args, System.out)); + } + + private static int run(String[] args, PrintStream out){ + int result = 2/*STATUS_FAILED*/; + try { + result = UnsafegetObjectTest_1(); + } catch(Exception e){ + e.printStackTrace(); + UnsafeTest03.res -= 2; + } + if (result == 3 && UnsafeTest03.res == 97){ + result =0; + } + return result; + } + + private static int UnsafegetObjectTest_1(){ + Unsafe unsafe; + Field field; + Long offset; + Field param; + Object obj; + Object result; + try{ + field = Unsafe.class.getDeclaredField("theUnsafe"); + field.setAccessible(true); + unsafe = (Unsafe)field.get(null); + param = Billie18.class.getDeclaredField("owner"); + offset = unsafe.objectFieldOffset(param); + obj = new Billie18(); + result = unsafe.getObject(obj, offset); + if(result.equals("Me")){ + UnsafeTest03.res -= 2; + } + }catch (NoSuchFieldException e){ + e.printStackTrace(); + return 40; + }catch (IllegalAccessException e){ + e.printStackTrace(); + return 41; + } + return 3; + } +} + +class Billie18{ + public int height = 8; + private String[] color = {"black","white"}; + private String owner = "Me"; + private byte length = 0x7; + private String[] water = {"day","wet"}; + private long weight = 100L; + private volatile int age = 18; + private volatile long birth = 20010214L; + private volatile String lastname = "eilish"; +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/test/testsuite/ouroboros/rc_test/common_test/RC0474-rc-BindingMethod-UnsafeTest04/UnsafeTest04.java b/test/testsuite/ouroboros/rc_test/common_test/RC0474-rc-BindingMethod-UnsafeTest04/UnsafeTest04.java new file mode 100644 index 0000000000000000000000000000000000000000..3e5d35a44eebceee149c181d53c6cd7bbfbe9e06 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/common_test/RC0474-rc-BindingMethod-UnsafeTest04/UnsafeTest04.java @@ -0,0 +1,86 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_UnsafeTest04 + *- @TestCaseName: UnsafeTest04 + *- @TestCaseType: Function Testing for MemoryBindingMethod Test + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief:unsafe.putObject()函数专项测试:验证putObject()方法的基本功能正常。 + * -#step1: + *- @Expect:0\n + *- @Priority: High + *- @Source:UnsafeTest04.java + *- @ExecuteClass:UnsafeTest04 + *- @ExecuteArgs: + *- @Remark: + */ + +import sun.misc.Unsafe; +import java.io.PrintStream; +import java.lang.reflect.Field; + +public class UnsafeTest04 { + private static int res = 99; + public static void main(String[] args){ + System.out.println(run(args, System.out)); + } + + private static int run(String[] args, PrintStream out){ + int result = 2/*STATUS_FAILED*/; + try { + result = UnsafeputObjectTest_1(); + } catch(Exception e){ + e.printStackTrace(); + UnsafeTest04.res -= 2; + } + if (result == 3 && UnsafeTest04.res == 97){ + result =0; + } + return result; + } + + private static int UnsafeputObjectTest_1(){ + Unsafe unsafe; + Field field; + Long offset; + Field param; + Object obj; + Object result; + try{ + field = Unsafe.class.getDeclaredField("theUnsafe"); + field.setAccessible(true); + unsafe = (Unsafe)field.get(null); + param = Billie19.class.getDeclaredField("owner"); + offset = unsafe.objectFieldOffset(param); + obj = new Billie19(); + result = unsafe.getObject(obj, offset); + unsafe.putObject(obj, offset, "she"); + result = unsafe.getObject(obj,offset); + if(result.equals("she")){ + UnsafeTest04.res -= 2; + } + }catch (NoSuchFieldException e){ + e.printStackTrace(); + return 40; + }catch (IllegalAccessException e){ + e.printStackTrace(); + return 41; + } + return 3; + } +} + +class Billie19{ + public int height = 8; + private String[] color = {"black","white"}; + private String owner = "Me"; + private byte length = 0x7; + private String[] water = {"day","wet"}; + private long weight = 100L; + private volatile int age = 18; + private volatile long birth = 20010214L; + private volatile String lastname = "eilish"; +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/test/testsuite/ouroboros/rc_test/common_test/RC0475-rc-BindingMethod-UnsafeTest05/UnsafeTest05.java b/test/testsuite/ouroboros/rc_test/common_test/RC0475-rc-BindingMethod-UnsafeTest05/UnsafeTest05.java new file mode 100644 index 0000000000000000000000000000000000000000..e77f56ad633ae3167ade34f367827238ef40e75a --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/common_test/RC0475-rc-BindingMethod-UnsafeTest05/UnsafeTest05.java @@ -0,0 +1,86 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_UnsafeTest05 + *- @TestCaseName: UnsafeTest05 + *- @TestCaseType: Function Testing for MemoryBindingMethod Test + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief:unsafe.putObjectVolatile()函数专项测试:验证putObjectVolatile()方法的基本功能正常。 + * -#step1: + *- @Expect:0\n + *- @Priority: High + *- @Source:UnsafeTest05.java + *- @ExecuteClass:UnsafeTest05 + *- @ExecuteArgs: + *- @Remark: + */ + +import sun.misc.Unsafe; +import java.io.PrintStream; +import java.lang.reflect.Field; + +public class UnsafeTest05 { + private static int res = 99; + public static void main(String[] args){ + System.out.println(run(args, System.out)); + } + + private static int run(String[] args, PrintStream out){ + int result = 2/*STATUS_FAILED*/; + try { + result = UnsafeputObjectVolatileTest_1(); + } catch(Exception e){ + e.printStackTrace(); + UnsafeTest05.res -= 2; + } + if (result == 3 && UnsafeTest05.res == 97){ + result =0; + } + return result; + } + + private static int UnsafeputObjectVolatileTest_1(){ + Unsafe unsafe; + Field field; + Long offset; + Field param; + Object obj; + Object result; + try{ + field = Unsafe.class.getDeclaredField("theUnsafe"); + field.setAccessible(true); + unsafe = (Unsafe)field.get(null); + param = Billie11.class.getDeclaredField("lastname"); + offset = unsafe.objectFieldOffset(param); + obj = new Billie11(); + result = unsafe.getObjectVolatile(obj, offset); + unsafe.putObjectVolatile(obj, offset, "Eilish"); + result = unsafe.getObjectVolatile(obj, offset); + if(result.equals("Eilish")){ + UnsafeTest05.res -= 2; + } + }catch (NoSuchFieldException e){ + e.printStackTrace(); + return 40; + }catch (IllegalAccessException e){ + e.printStackTrace(); + return 41; + } + return 3; + } +} + +class Billie11{ + public int height = 8; + private String[] color = {"black","white"}; + private String owner = "Me"; + private byte length = 0x7; + private String[] water = {"day","wet"}; + private long weight = 100L; + private volatile int age = 18; + private volatile long birth = 20010214L; + private volatile String lastname = "eilish"; +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/test/testsuite/ouroboros/rc_test/common_test/RC0476-rc-BindingMethod-UnsafeTest06/UnsafeTest06.java b/test/testsuite/ouroboros/rc_test/common_test/RC0476-rc-BindingMethod-UnsafeTest06/UnsafeTest06.java new file mode 100644 index 0000000000000000000000000000000000000000..09e9d8021e1b74b092083ce305c94058f66060dc --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/common_test/RC0476-rc-BindingMethod-UnsafeTest06/UnsafeTest06.java @@ -0,0 +1,86 @@ +/* + *- @TestCaseID: Maple_MemoryManagement2.0_UnsafeTest06 + *- @TestCaseName: UnsafeTest06 + *- @TestCaseType: Function Testing for MemoryBindingMethod Test + *- @RequirementName: 运行时支持GCOnly + *- @Condition:no + * -#c1: 测试环境正常 + *- @Brief:unsafe.putOrderedObject()函数专项测试:验证putOrderedObject()方法的基本功能正常。 + * -#step1: + *- @Expect:0\n + *- @Priority: High + *- @Source:UnsafeTest06.java + *- @ExecuteClass:UnsafeTest06 + *- @ExecuteArgs: + *- @Remark: + */ + +import sun.misc.Unsafe; +import java.io.PrintStream; +import java.lang.reflect.Field; + +public class UnsafeTest06 { + private static int res = 99; + public static void main(String[] args){ + System.out.println(run(args, System.out)); + } + + private static int run(String[] args, PrintStream out){ + int result = 2/*STATUS_FAILED*/; + try { + result = UnsafeputOrderedObjectTest_1(); + } catch(Exception e){ + e.printStackTrace(); + UnsafeTest06.res -= 2; + } + if (result == 3 && UnsafeTest06.res == 97){ + result =0; + } + return result; + } + + private static int UnsafeputOrderedObjectTest_1(){ + Unsafe unsafe; + Field field; + Long offset; + Field param; + Object obj; + Object result; + try{ + field = Unsafe.class.getDeclaredField("theUnsafe"); + field.setAccessible(true); + unsafe = (Unsafe)field.get(null); + param = Billie20.class.getDeclaredField("owner"); + offset = unsafe.objectFieldOffset(param); + obj = new Billie20(); + result = unsafe.getObject(obj, offset); + unsafe.putOrderedObject(obj, offset, "she"); + result = unsafe.getObject(obj,offset); + if(result.equals("she")){ + UnsafeTest06.res -= 2; + } + }catch (NoSuchFieldException e){ + e.printStackTrace(); + return 40; + }catch (IllegalAccessException e){ + e.printStackTrace(); + return 41; + } + return 3; + } +} + +class Billie20{ + public int height = 8; + private String[] color = {"black","white"}; + private String owner = "Me"; + private byte length = 0x7; + private String[] water = {"day","wet"}; + private long weight = 100L; + private volatile int age = 18; + private volatile long birth = 20010214L; + private volatile String lastname = "eilish"; +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/test/testsuite/ouroboros/rc_test/native_test/RC0411-rc-Annotation-RCPermanentTest/RCPermanentTest.java b/test/testsuite/ouroboros/rc_test/native_test/RC0411-rc-Annotation-RCPermanentTest/RCPermanentTest.java new file mode 100755 index 0000000000000000000000000000000000000000..a087aac5ad761c1c8d2c14486af0729e033d6360 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/native_test/RC0411-rc-Annotation-RCPermanentTest/RCPermanentTest.java @@ -0,0 +1,210 @@ +/* + *- @TestCaseID:maple/runtime/rc/annotation/Permanent/RCPermanentTest + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:添加/没有Permanent annotation的数组,验证是否经过RC策略以及是否为堆内存 + *- @Condition: + * -#c1: + *- @Brief:functionTest + * -#step1: + * 添加/没有Permanent annotation的普通数组,验证是否经过RC策略以及是否为堆内存 + * 添加/没有Permanent annotation的Interger数组,验证是否经过RC策略以及是否为堆内存 + * 添加/没有Permanent annotation的arraylist数组,验证是否经过RC策略以及是否为堆内存 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCPermanentTest.java jniTestHelper.cpp + *- @ExecuteClass: RCPermanentTest + *- @ExecuteArgs: + *- @Remark: + *- @Author:liuweiqing l00481345 + */ + +import java.util.ArrayList; + +import com.huawei.ark.annotation.Permanent; + +import java.lang.ref.WeakReference; + +public class RCPermanentTest { + + public static native boolean isHeapObject(Object obj); + + public static native int refCount(Object obj); + + public static int checkNum = 0; + + static Object owner; + + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + //System.out.printf("rc:%-5s heap:%-5s %s%n", !skipRC, isHeapObject(obj), title); + } + + /* + 验证new int @Permanent [8] + */ + static void method1(Object obj) { + obj = new int @Permanent [8]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new int @Permanent [8];in method1"); + } + } + + /* + 验证new int [8] + */ + static void method2(Object obj) { + obj = new int[8]; + boolean result1 = checkRC(obj); + if (result1 == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in new int [8];in method2"); + } + } + + /* + 验证new @Permanent int[8] + */ + static void method3(Object obj) { + obj = new @Permanent int[1]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new @Permanent int[8];in method3"); + } + } + + /* + 验证new Integer @Permanent [10] + */ + static void method4(Object obj) { + Integer[] arr = new Integer @Permanent [10]; + boolean result1 = checkRC(obj); + noleak.add(arr); // let leak check happy + arr[0] = new Integer(10000); + arr[9] = new Integer(20000); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new Integer @Permanent [10];in method4"); + } + } + + /* + 验证new @Permanent Integer [10] + */ + static void method5(Object obj) { + Integer[] arr = new @Permanent Integer[10]; + boolean result1 = checkRC(obj); + noleak.add(arr); // let leak check happy + arr[0] = new Integer(10000); + arr[9] = new Integer(20000); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new @Permanent Integer [10];in method5"); + } + } + + /* + 验证new Integer[10]; + */ + static void method6(Object obj) { + obj = new Integer[10]; + boolean result1 = checkRC(obj); + + if (result1 == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in new Integer[10];in method6"); + } + } + + /* + 验证new @Permanent ArrayList[]{}; + */ + static void method7(Object obj) { + obj = new @Permanent ArrayList[]{}; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new @Permanent ArrayList[]{};in method7"); + } + } + + /* + 验证new ArrayList @Permanent []{}; + */ + static void method8(Object obj) { + obj = new ArrayList @Permanent []{}; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new ArrayList @Permanent []{};in method8"); + } + } + + /* + 验证new ArrayList []{}; + */ + static void method9(Object obj) { + obj = new ArrayList[]{}; + boolean result1 = checkRC(obj); + if (result1 == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in new ArrayList []{}; method9"); + } + } + + + static ArrayList noleak = new ArrayList<>(); + + public static int NUM = 5; + public static void main(String[] args) { + for(int i=0;i +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +} /* extern "C" */ diff --git a/test/testsuite/ouroboros/rc_test/native_test/RC0412-rc-Annotation-RCPermanentTest2/RCPermanentTest2.java b/test/testsuite/ouroboros/rc_test/native_test/RC0412-rc-Annotation-RCPermanentTest2/RCPermanentTest2.java new file mode 100755 index 0000000000000000000000000000000000000000..e124d9876f5262977f161afdedc7669977f5f79b --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/native_test/RC0412-rc-Annotation-RCPermanentTest2/RCPermanentTest2.java @@ -0,0 +1,214 @@ +/* + *- @TestCaseID:maple/runtime/rc/annotation/Permanent/RCPermanentTest2 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:添加/没有Permanent annotation的field,验证是否经过RC策略以及是否为堆内存 + *- @Condition: + * -#c1: + *- @Brief:functionTest + * -#step1: + * 添加/没有Permanent annotation的常量,验证是否经过RC策略以及是否为堆内存 + * 添加/没有Permanent annotation的局部变量,验证是否经过RC策略以及是否为堆内存 + * 添加/没有Permanent annotation的static field,验证是否经过RC策略以及是否为堆内存 + * 添加/没有Permanent annotation的static volatile field,验证是否经过RC策略以及是否为堆内存 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCPermanentTest2.java jniTestHelper.cpp + *- @ExecuteClass: RCPermanentTest2 + *- @ExecuteArgs: + *- @Remark: + *- @Author:liuweiqing l00481345 + */ + +import java.util.ArrayList; + +import com.huawei.ark.annotation.Permanent; + +import java.lang.ref.WeakReference; + +public class RCPermanentTest2 { + public static native boolean isHeapObject(Object obj); + + public static native int refCount(Object obj); + + public static int checkNum = 0; + + static Object owner; + + public static Integer INT = new @Permanent Integer(100); + public static Integer INT2 = new Integer(100); + static String STRING = new @Permanent String("test"); + static Long LONG = new @Permanent Long(522222); + static Long LONG2 = null; + + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + } + + /* + 验证public final static Integer INT = new @Permanent Integer(100); + */ + static void method1() { + boolean result = checkRC(INT); + boolean heapResult = isHeapObject(INT); + + if ((result == false) && (heapResult == false)) { + checkNum++; + } else { + System.out.println("error in method1"); + System.out.println("result:" + result + " isHeap:" + heapResult); + System.out.println(String.valueOf(result)); + System.out.println(String.valueOf(heapResult)); + } + } + + /* + 验证public final static Integer INT2 = new Integer(100); + */ + static void method2() { + boolean result = checkRC(INT2); + if (result == true && isHeapObject(INT2) == true) { + checkNum++; + } else { + System.out.println("error in method2"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(INT2)); + } + } + + /* + 验证static String STRING = new @Permanent String("test"); + */ + static void method3() { + // static String STRING = new @Permanent String("test"); + boolean result = checkRC(STRING); + if (result == true && isHeapObject(STRING) == true) { + checkNum++; + } else { + System.out.println("error in method3"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(STRING)); + } + } + + /* + 验证static Long LONG2 = new Long("test4"); + */ + static void method4() { + LONG2 = new Long(2222222); + boolean result = checkRC(LONG2); + if (result == true && isHeapObject(LONG2) == true) { + checkNum++; + } else { + System.out.println("error in method4"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(LONG2)); + } + } + + /* + 验证String obj = new @Permanent Long("test5"); + */ + static void method5() { + //String obj = new @Permanent String("test5"); + Double obj = new @Permanent Double(3333.3); + boolean result = checkRC(obj); + if (result == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in method5"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(obj)); + } + } + + /* + 验证String obj = new String("test6"); + */ + static void method6() { + Double obj = new Double(3333.3); + boolean result = checkRC(obj); + if (result == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in method6"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(obj)); + } + } + + /* + 验证obj = new @Permanent Integer("test"); + */ + static volatile Integer obj = null; + + static void method7() { + obj = new @Permanent Integer(123); + boolean result = checkRC(obj); + if (result == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in method7"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(obj)); + } + } + + /* + 验证obj = new @Permanent Integer("test"); + */ + static void method8() { + obj = new Integer(123); + boolean result = checkRC(obj); + if (result == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in method8"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(obj)); + } + } + /* + 验证static Long LONG = new @Permanent Long(522222); + */ + static void method9() { + boolean result = checkRC(LONG); + if (result == false && isHeapObject(LONG) == false) { + checkNum++; + } else { + System.out.println("error in method3"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(LONG)); + } + } + + + public static void main(String[] args) { + method1(); + method2(); + method3(); + method4(); + method5(); + method6(); + method7(); + method8(); + method9(); + + if (checkNum == 9) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("checkNum:" + checkNum); + } + } +} +// DEPENDENCE: jniTestHelper.cpp +// EXEC:%maple %f jniTestHelper.cpp %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/native_test/RC0412-rc-Annotation-RCPermanentTest2/jniTestHelper.cpp b/test/testsuite/ouroboros/rc_test/native_test/RC0412-rc-Annotation-RCPermanentTest2/jniTestHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7fd2b8ad8b97f1aafd1b2df3b55212eb79c77f5a --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/native_test/RC0412-rc-Annotation-RCPermanentTest2/jniTestHelper.cpp @@ -0,0 +1,19 @@ +#include +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest2_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest2_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +} /* extern "C" */ diff --git a/test/testsuite/ouroboros/rc_test/native_test/RC0413-rc-Annotation-RCPermanentTest3/RCPermanentTest3.java b/test/testsuite/ouroboros/rc_test/native_test/RC0413-rc-Annotation-RCPermanentTest3/RCPermanentTest3.java new file mode 100755 index 0000000000000000000000000000000000000000..744cff7dcab65d2f0ec94e29ffec0152052115fe --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/native_test/RC0413-rc-Annotation-RCPermanentTest3/RCPermanentTest3.java @@ -0,0 +1,108 @@ +/* + *- @TestCaseID:maple/runtime/rc/annotation/Permanent/RCPermanentTest3 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:添加/没有Permanent annotation的arraylist,验证是否经过RC策略以及是否为堆内存 + *- @Condition: + * -#c1: + *- @Brief:functionTest + * -#step1: + * 添加/没有Permanent annotation的arraylist,验证是否经过RC策略以及是否为堆内存 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCPermanentTest3.java jniTestHelper.cpp + *- @ExecuteClass: RCPermanentTest3 + *- @ExecuteArgs: + *- @Remark: + *- @Author:liuweiqing l00481345 + */ + +import java.util.ArrayList; + +import com.huawei.ark.annotation.Permanent; + +import java.lang.ref.WeakReference; + +public class RCPermanentTest3 { + public static native boolean isHeapObject(Object obj); + + public static native int refCount(Object obj); + + public static int checkNum = 0; + + static Object owner; + + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + //System.out.printf("rc:%-5s heap:%-5s %s%n", !skipRC, isHeapObject(obj), title); + } + + /* + 验证new int @Permanent [8] + */ + static void method1() { + ArrayList list = null; + list = new @Permanent ArrayList<>(); + boolean result1 = checkRC(list); + boolean result2 = isHeapObject(list); + if (String.valueOf(result1).equals("false") && String.valueOf(result2).equals("true")) { + //if (result1 == false && result2 == true) { + checkNum++; + } else { + System.out.println("error in method1"); + System.out.println("result1:" + result1 + " is Heap:" + result2); + } + } + + static void method2() { + ArrayList list = null; + list = new ArrayList(); + list.add("test"); + boolean result1 = checkRC(list); + boolean result2 = isHeapObject(list); + if (String.valueOf(result1).equals("true") && String.valueOf(result2).equals("true")) { + //if (result1 == false && result2 == true) { + checkNum++; + } else { + System.out.println("error in method2"); + System.out.println("result1:" + result1 + " is Heap:" + result2); + } + } + + + public static void main(String[] args) { + + method1(); + Runtime.getRuntime().gc(); + method1(); + + method2(); + Runtime.getRuntime().gc(); + method2(); + + if (checkNum == 4) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("checkNum:" + checkNum); + } + } +} +// DEPENDENCE: jniTestHelper.cpp +// EXEC:%maple %f jniTestHelper.cpp %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/native_test/RC0413-rc-Annotation-RCPermanentTest3/jniTestHelper.cpp b/test/testsuite/ouroboros/rc_test/native_test/RC0413-rc-Annotation-RCPermanentTest3/jniTestHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6e2013f9c903aba014bfe63c14304cf4827b25fd --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/native_test/RC0413-rc-Annotation-RCPermanentTest3/jniTestHelper.cpp @@ -0,0 +1,19 @@ +#include +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest3_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest3_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +} /* extern "C" */ diff --git a/test/testsuite/ouroboros/rc_test/native_test/RC0414-rc-Annotation-RCPermanentTest4/RCPermanentTest4.java b/test/testsuite/ouroboros/rc_test/native_test/RC0414-rc-Annotation-RCPermanentTest4/RCPermanentTest4.java new file mode 100755 index 0000000000000000000000000000000000000000..706dbd4a8c46c14be3d742560e217762590db0d7 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/native_test/RC0414-rc-Annotation-RCPermanentTest4/RCPermanentTest4.java @@ -0,0 +1,136 @@ +/* + *- @TestCaseID:maple/runtime/rc/annotation/Permanent/RCPermanentTest4 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:对环中的一个对象添加Permanent annotation,验证是否经过RC策略以及是否为堆内存 + *- @Condition: + * -#c1: + *- @Brief:functionTest + * -#step1: + * 对环中的一个对象添加Permanent annotation,验证是否经过RC策略以及是否为堆内存 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCPermanentTest4.java jniTestHelper.cpp + *- @ExecuteClass: RCPermanentTest4 + *- @ExecuteArgs: + *- @Remark: + *- @Author:liuweiqing l00481345 + */ + +import java.util.ArrayList; + +import com.huawei.ark.annotation.Permanent; + +import java.lang.ref.WeakReference; + +public class RCPermanentTest4 { + public static native boolean isHeapObject(Object obj); + + public static native int refCount(Object obj); + + public static int checkNum = 0; + + static Object owner; + + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + } + + /* + 验证环场景 + */ + static void method1() { + Cycle_A a = new Cycle_A(); + a.b = null; + a.b = new @Permanent Cycle_B(); + a.b.a = a; + int result = a.add() + a.b.add(); + if (result == 16) { + checkNum++; + } else { + System.out.println("result:" + result); + } + boolean resultA1 = checkRC(a); + boolean resultA2 = isHeapObject(a); + boolean resultB1 = checkRC(a.b); + boolean resultB2 = isHeapObject(a.b); + if (String.valueOf(resultA1).equals("true") && String.valueOf(resultA2).equals("true") && String.valueOf(resultB1).equals("false") && String.valueOf(resultB2).equals("true")) { + //if (result1 == false && result2 == true) { + checkNum++; + } else { + System.out.println("error"); + System.out.println("CycleA_checkRC:" + resultA1); + System.out.println("CycleA_isHeap:" + resultA2); + System.out.println("CycleB_checkRC:" + resultB1); + System.out.println("CycleB_isHeap:" + resultB2); + //System.out.println("result1:" + result1 + " is Heap:" + result2); + } + + } + + + public static void main(String[] args) { + + method1(); + + + if (checkNum == 2) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("checkNum:" + checkNum); + } + } +} + + +class Cycle_A { + Cycle_B b; + static int sum; + static int a; + + Cycle_A() { + a = 3; + } + + int add() { + sum = a + b.b; + return sum; + } + +} + +class Cycle_B { + Cycle_A a; + static int sum; + static int b; + + Cycle_B() { + b = 5; + + } + + int add() { + sum = a.a + b; + return sum; + } + +} +// DEPENDENCE: jniTestHelper.cpp +// EXEC:%maple %f jniTestHelper.cpp %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/native_test/RC0414-rc-Annotation-RCPermanentTest4/jniTestHelper.cpp b/test/testsuite/ouroboros/rc_test/native_test/RC0414-rc-Annotation-RCPermanentTest4/jniTestHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..036f28224664943235d5f19e837824d62eb4c722 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/native_test/RC0414-rc-Annotation-RCPermanentTest4/jniTestHelper.cpp @@ -0,0 +1,19 @@ +#include +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest4_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest4_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +} /* extern "C" */ diff --git a/test/testsuite/ouroboros/rc_test/native_test/RC0415-rc-Annotation-RCPermanentTest5/RCPermanentTest5.java b/test/testsuite/ouroboros/rc_test/native_test/RC0415-rc-Annotation-RCPermanentTest5/RCPermanentTest5.java new file mode 100755 index 0000000000000000000000000000000000000000..0b68294fdb9d0a8ffa414d6e202791c5b337b003 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/native_test/RC0415-rc-Annotation-RCPermanentTest5/RCPermanentTest5.java @@ -0,0 +1,137 @@ +/* + *- @TestCaseID:maple/runtime/rc/annotation/Permanent/RCPermanentTest5 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:添加/没有Permanent annotation的Reference和有finalize方法的对象,验证是否经过RC策略以及是否为堆内存 + *- @Condition: + * -#c1: + *- @Brief:functionTest + * -#step1: + * 添加/没有Permanent annotation的soft/weak/phantom Reference,验证是否经过RC策略以及是否为堆内存 + * 添加/没有Permanent annotation的有finalize方法的对象,验证是否经过RC策略以及是否为堆内存 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: RCPermanentTest5.java jniTestHelper.cpp + *- @ExecuteClass: RCPermanentTest5 + *- @ExecuteArgs: + *- @Remark: + *- @Author:liuweiqing l00481345 + */ + +import java.util.ArrayList; + +import com.huawei.ark.annotation.Permanent; +import sun.misc.Cleaner; + +import java.lang.ref.*; + +import static java.lang.Thread.sleep; + + +class FinalizableObject { + // static int value; + + public void finalize() { + System.out.println("ExpectResult"); + } +} + +public class RCPermanentTest5 { + public static native boolean isHeapObject(Object obj); + + public static native int refCount(Object obj); + + static Object owner; + static int checkSum; + static Object referent = new Object(); + + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + } + + + static void methodRef1(Object obj) { + obj = new @Permanent WeakReference(referent); + boolean result1 = checkRC(obj); + boolean result2 = isHeapObject(obj); + if (String.valueOf(result1).equals("true") && String.valueOf(result2).equals("true")) { + checkSum++; + } else { + System.out.println("resultRC:" + result1); + System.out.println("result_isHeap:" + result2); + } + } + + static void methodRef2(Object obj) { + obj = new @Permanent SoftReference(referent); + boolean result1 = checkRC(obj); + boolean result2 = isHeapObject(obj); + if (String.valueOf(result1).equals("true") && String.valueOf(result2).equals("true")) { + checkSum++; + } else { + System.out.println("resultRC:" + result1); + System.out.println("result_isHeap:" + result2); + } + } + + static void methodRef3(Object obj) { + ReferenceQueue rq = new ReferenceQueue(); + obj = new @Permanent PhantomReference(referent, rq); + boolean result1 = checkRC(obj); + boolean result2 = isHeapObject(obj); + if (String.valueOf(result1).equals("true") && String.valueOf(result2).equals("true")) { + checkSum++; + } else { + System.out.println("resultRC:" + result1); + System.out.println("result_isHeap:" + result2); + } + } + + static void methodFinal(Object obj) throws InterruptedException { + obj = new @Permanent FinalizableObject(); + sleep(3000); + boolean result1 = checkRC(obj); + boolean result2 = isHeapObject(obj); + if (String.valueOf(result1).equals("true") && String.valueOf(result2).equals("true")) { + checkSum++; + } else { + System.out.println("resultRC:" + result1); + System.out.println("result_isHeap:" + result2); + } + } + + + public static void main(String[] args) throws InterruptedException { + Object obj = null; + methodRef1(obj); + methodRef2(obj); + methodRef3(obj); + methodFinal(obj); + + if (checkSum == 4) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("checkNum:" + checkSum); + } + + } +} +// DEPENDENCE: jniTestHelper.cpp +// EXEC:%maple %f jniTestHelper.cpp %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/native_test/RC0415-rc-Annotation-RCPermanentTest5/jniTestHelper.cpp b/test/testsuite/ouroboros/rc_test/native_test/RC0415-rc-Annotation-RCPermanentTest5/jniTestHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..05ef52c6c16b38fe40cb3f4839f2bcc6fc9f09f3 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/native_test/RC0415-rc-Annotation-RCPermanentTest5/jniTestHelper.cpp @@ -0,0 +1,19 @@ +#include +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest5_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest5_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +} /* extern "C" */ diff --git a/test/testsuite/ouroboros/rc_test/native_test/RC0416-rc-Annotation-RCPermanentThread/RCPermanentThread.java b/test/testsuite/ouroboros/rc_test/native_test/RC0416-rc-Annotation-RCPermanentThread/RCPermanentThread.java new file mode 100755 index 0000000000000000000000000000000000000000..299104faff1b9d66bec5e127acc0f5d8686adee6 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/native_test/RC0416-rc-Annotation-RCPermanentThread/RCPermanentThread.java @@ -0,0 +1,744 @@ +/* + *- @TestCaseID:maple/runtime/rc/annotation/Permanent/RCPermanentThread + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:多线程下调用PermanentTest的case,验证是否经过RC策略以及是否为堆内存 + *- @Condition: + * -#c1: + *- @Brief:functionTest + * -#step1: + * 多线程下调用PermanentTest的case,包括caseRC0411,RC0412,RC0413,RC0414,RC0415,验证是否经过RC策略以及是否为堆内存 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: RCPermanentThread.java jniTestHelper.cpp + *- @ExecuteClass: RCPermanentThread + *- @ExecuteArgs: + *- @Remark: + *- @Author:liuweiqing l00481345 + */ +import java.util.ArrayList; + +import com.huawei.ark.annotation.Permanent; +import sun.misc.Cleaner; + +import java.lang.ref.*; + +public class RCPermanentThread { + public static void main(String[] args) throws InterruptedException { + rc_testcase_main_wrapper(); + } + + private static void rc_testcase_main_wrapper() throws InterruptedException { + RCPermanentTest rcPermanentTest = new RCPermanentTest(); + RCPermanentTest2 rcPermanentTest2 = new RCPermanentTest2(); + RCPermanentTest3 rcPermanentTest3 = new RCPermanentTest3(); + RCPermanentTest4 rcPermanentTest4 = new RCPermanentTest4(); + RCPermanentTest5 rcPermanentTest5 = new RCPermanentTest5(); + + rcPermanentTest.start(); + rcPermanentTest2.start(); + rcPermanentTest3.start(); + rcPermanentTest4.start(); + rcPermanentTest5.start(); + + rcPermanentTest.join(); + rcPermanentTest2.join(); + rcPermanentTest3.join(); + rcPermanentTest4.join(); + rcPermanentTest5.join(); + + if (rcPermanentTest.check() && rcPermanentTest2.check() && rcPermanentTest3.check() && rcPermanentTest4.check() && rcPermanentTest5.check()) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("rcPermanentTest.check() :" + rcPermanentTest.check()); + System.out.println("rcPermanentTest2.check() :" + rcPermanentTest2.check()); + System.out.println("rcPermanentTest3.check() :" + rcPermanentTest3.check()); + System.out.println("rcPermanentTest4.check() :" + rcPermanentTest4.check()); + System.out.println("rcPermanentTest5.check() :" + rcPermanentTest5.check()); + } + } +} + + +class RCPermanentTest extends Thread { + public boolean checkout; + + public static native boolean isHeapObject(Object obj); + + public static native int refCount(Object obj); + + public static int checkNum = 0; + + static Object owner; + + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + //System.out.printf("rc:%-5s heap:%-5s %s%n", !skipRC, isHeapObject(obj), title); + } + + /* + 验证new int @Permanent [8] + */ + static void method1(Object obj) { + obj = new int@Permanent[8]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new int @Permanent [8];in method1"); + } + } + + /* + 验证new int [8] + */ + static void method2(Object obj) { + obj = new int[8]; + boolean result1 = checkRC(obj); + if (result1 == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in new int [8];in method2"); + } + } + + /* + 验证new @Permanent int[8] + */ + static void method3(Object obj) { + obj = new @Permanent int[1]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new @Permanent int[8];in method3"); + } + } + + /* + 验证new Integer @Permanent [10] + */ + static void method4(Object obj) { + Integer[] arr = new Integer@Permanent[10]; + boolean result1 = checkRC(obj); + noleak.add(arr); // let leak check happy + arr[0] = new Integer(10000); + arr[9] = new Integer(20000); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new Integer @Permanent [10];in method4"); + } + } + + /* + 验证new @Permanent Integer [10] + */ + static void method5(Object obj) { + Integer[] arr = new @Permanent Integer[10]; + boolean result1 = checkRC(obj); + noleak.add(arr); // let leak check happy + arr[0] = new Integer(10000); + arr[9] = new Integer(20000); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new @Permanent Integer [10];in method5"); + } + } + + /* + 验证new Integer[10]; + */ + static void method6(Object obj) { + obj = new Integer[10]; + boolean result1 = checkRC(obj); + + if (result1 == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in new Integer[10];in method6"); + } + } + + /* + 验证new @Permanent ArrayList[]{}; + */ + static void method7(Object obj) { + obj = new @Permanent ArrayList[]{}; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new @Permanent ArrayList[]{};in method7"); + } + } + + /* + 验证new ArrayList @Permanent []{}; + */ + static void method8(Object obj) { + obj = new ArrayList@Permanent[]{}; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new ArrayList @Permanent []{};in method8"); + } + } + + /* + 验证new ArrayList []{}; + */ + static void method9(Object obj) { + obj = new ArrayList[]{}; + boolean result1 = checkRC(obj); + if (result1 == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in new ArrayList []{}; method9"); + } + } + + + static ArrayList noleak = new ArrayList<>(); + + public void run( + ) { + Object obj = null; + method1(obj); + method2(obj); + method3(obj); + method4(obj); + method5(obj); + method6(obj); + method7(obj); + method8(obj); + method9(obj); + + if (checkNum == 9) { + checkout = true; + } else { + checkout = false; + System.out.println(checkNum); + } + } + + public boolean check() { + return checkout; + } +} + +class RCPermanentTest2 extends Thread { + public boolean checkout; + + public static native boolean isHeapObject(Object obj); + + public static native int refCount(Object obj); + + public static int checkNum = 0; + + static Object owner; + + public static Integer INT = new @Permanent Integer(100); + public static Integer INT2 = new Integer(100); + static String STRING = new @Permanent String("test"); + static Long LONG = new @Permanent Long(23534); + static Long LONG2 = null; + + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + } + + /* + 验证public final static Integer INT = new @Permanent Integer(100); + */ + static void method1() { + boolean result = checkRC(INT); + boolean heapResult = isHeapObject(INT); + + if ((result == false) && (heapResult == false)) { + checkNum++; + } else { + System.out.println("error in method1"); + System.out.println("result:" + result + " isHeap:" + heapResult); + System.out.println(String.valueOf(result)); + System.out.println(String.valueOf(heapResult)); + } + } + + /* + 验证public final static Integer INT2 = new Integer(100); + */ + static void method2() { + boolean result = checkRC(INT2); + if (result == true && isHeapObject(INT2) == true) { + checkNum++; + } else { + System.out.println("error in method2"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(INT2)); + } + } + + /* + 验证static String STRING = new @Permanent String("test"); + */ + static void method3() { + // STRING = new @Permanent (454555); + boolean result = checkRC(STRING); + if (result == true && isHeapObject(STRING) == true) { + checkNum++; + } else { + System.out.println("error in method3"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(STRING)); + } + } + + /* + 验证static Long LONG2 = new Long("test4"); + */ + static void method4() { + LONG2 = new Long(2222222); + boolean result = checkRC(LONG2); + if (result == true && isHeapObject(LONG2) == true) { + checkNum++; + } else { + System.out.println("error in method4"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(LONG2)); + } + } + + /* + 验证String obj = new @Permanent Long("test5"); + */ + static void method5() { + //String obj = new @Permanent String("test5"); + Double obj = new @Permanent Double(3333.3); + boolean result = checkRC(obj); + if (result == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in method5"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(obj)); + } + } + + /* + 验证String obj = new String("test6"); + */ + static void method6() { + Double obj = new Double(3333.3); + boolean result = checkRC(obj); + if (result == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in method6"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(obj)); + } + } + + /* + 验证obj = new @Permanent Integer("test"); + */ + static volatile Integer obj = null; + + static void method7() { + obj = new @Permanent Integer(123); + boolean result = checkRC(obj); + if (result == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in method7"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(obj)); + } + } + + /* + 验证obj = new @Permanent Integer("test"); + */ + static void method8() { + obj = new Integer(123); + boolean result = checkRC(obj); + if (result == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in method8"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(obj)); + } + } + + /* + 验证static long LONG = new @Permanent long(23534); + */ + static void method9() { + boolean result = checkRC(LONG); + if (result == false && isHeapObject(LONG) == false) { + checkNum++; + } else { + System.out.println("error in method9"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(LONG)); + } + } + + + public void run() { + method1(); + method2(); + method3(); + method4(); + method5(); + method6(); + method7(); + method8(); + method9(); + //System.out.println(checkNum); + if (checkNum == 9) { + checkout = true; + } else { + checkout = false; + System.out.println(checkNum); + } + } + + public boolean check() { + return checkout; + } +} + +class RCPermanentTest3 extends Thread { + public boolean checkout; + + public static native boolean isHeapObject(Object obj); + + public static native int refCount(Object obj); + + public static int checkNum = 0; + + static Object owner; + + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + //System.out.printf("rc:%-5s heap:%-5s %s%n", !skipRC, isHeapObject(obj), title); + } + + /* + 验证new int @Permanent [8] + */ + static void method1() { + ArrayList list = null; + list = new @Permanent ArrayList<>(); + boolean result1 = checkRC(list); + boolean result2 = isHeapObject(list); + if (String.valueOf(result1).equals("false") && String.valueOf(result2).equals("true")) { + //if (result1 == false && result2 == true) { + checkNum++; + } else { + System.out.println("error in method1"); + System.out.println("result1:" + result1 + " is Heap:" + result2); + } + } + + static void method2() { + ArrayList list = null; + list = new ArrayList(); + list.add("test"); + boolean result1 = checkRC(list); + boolean result2 = isHeapObject(list); + if (String.valueOf(result1).equals("true") && String.valueOf(result2).equals("true")) { + //if (result1 == false && result2 == true) { + checkNum++; + } else { + System.out.println("error in method2"); + System.out.println("result1:" + result1 + " is Heap:" + result2); + } + } + + + public void run() { + + method1(); + Runtime.getRuntime().gc(); + method1(); + + method2(); + Runtime.getRuntime().gc(); + method2(); + + if (checkNum == 4) { + checkout = true; + } else { + checkout = false; + System.out.println(checkNum); + } + } + + public boolean check() { + return checkout; + } +} + +class RCPermanentTest4 extends Thread { + public boolean checkout; + + public static native boolean isHeapObject(Object obj); + + public static native int refCount(Object obj); + + public static int checkNum = 0; + + static Object owner; + + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + } + + /* + 验证环场景 + */ + static void method1() { + Cycle_A a = new Cycle_A(); + a.b = null; + a.b = new @Permanent Cycle_B(); + a.b.a = a; + int result = a.add() + a.b.add(); + if (result == 16) { + checkNum++; + } else { + System.out.println("result:" + result); + } + boolean resultA1 = checkRC(a); + boolean resultA2 = isHeapObject(a); + boolean resultB1 = checkRC(a.b); + boolean resultB2 = isHeapObject(a.b); + if (String.valueOf(resultA1).equals("true") && String.valueOf(resultA2).equals("true") && String.valueOf(resultB1).equals("false") && String.valueOf(resultB2).equals("true")) { + //if (result1 == false && result2 == true) { + checkNum++; + } else { + System.out.println("error"); + System.out.println("CycleA_checkRC:" + resultA1); + System.out.println("CycleA_isHeap:" + resultA2); + System.out.println("CycleB_checkRC:" + resultB1); + System.out.println("CycleB_isHeap:" + resultB2); + //System.out.println("result1:" + result1 + " is Heap:" + result2); + } + + } + + public void run() { + + method1(); + + if (checkNum == 2) { + checkout = true; + } else { + System.out.println(checkNum); + checkout = false; + + } + } + + public boolean check() { + return checkout; + } +} + + +class Cycle_A { + Cycle_B b; + static int sum; + static int a; + + Cycle_A() { + a = 3; + } + + int add() { + sum = a + b.b; + return sum; + } + +} + +class Cycle_B { + Cycle_A a; + static int sum; + static int b; + + Cycle_B() { + b = 5; + + } + + int add() { + sum = a.a + b; + return sum; + } + +} + + +class RCPermanentTest5 extends Thread { + public boolean checkout; + + public static native boolean isHeapObject(Object obj); + + public static native int refCount(Object obj); + + static Object owner; + static Object referent = new Object(); + static int checkSum; + + public void run() { + Object obj = null; + methodRef1(obj); + methodRef2(obj); + methodRef3(obj); + methodFinal(obj); + + if (checkSum == 4) { + checkout = true; + } else { + checkout = false; + System.out.println(checkSum); + } + } + + public boolean check() { + return checkout; + } + + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + } + + + static void methodRef1(Object obj) { + obj = new @Permanent WeakReference(referent); + boolean result1 = checkRC(obj); + boolean result2 = isHeapObject(obj); + if (String.valueOf(result1).equals("true") && String.valueOf(result2).equals("true")) { + checkSum++; + } else { + System.out.println("resultRC:" + result1); + System.out.println("result_isHeap:" + result2); + } + } + + static void methodRef2(Object obj) { + obj = new @Permanent SoftReference(referent); + boolean result1 = checkRC(obj); + boolean result2 = isHeapObject(obj); + if (String.valueOf(result1).equals("true") && String.valueOf(result2).equals("true")) { + checkSum++; + } else { + System.out.println("resultRC:" + result1); + System.out.println("result_isHeap:" + result2); + } + } + + static void methodRef3(Object obj) { + ReferenceQueue rq = new ReferenceQueue(); + obj = new @Permanent PhantomReference(referent, rq); + boolean result1 = checkRC(obj); + boolean result2 = isHeapObject(obj); + if (String.valueOf(result1).equals("true") && String.valueOf(result2).equals("true")) { + checkSum++; + } else { + System.out.println("resultRC:" + result1); + System.out.println("result_isHeap:" + result2); + } + } + + static void methodFinal(Object obj) { + obj = new @Permanent FinalizableObject(); + boolean result1 = checkRC(obj); + boolean result2 = isHeapObject(obj); + if (String.valueOf(result1).equals("true") && String.valueOf(result2).equals("true")) { + checkSum++; + } else { + System.out.println("resultRC:" + result1); + System.out.println("result_isHeap:" + result2); + } + } + + +} + +class FinalizableObject { + // static int value; + + public void finalize() { + System.out.println("ExpectResult"); + } +} +// DEPENDENCE: jniTestHelper.cpp +// EXEC:%maple %f jniTestHelper.cpp %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/native_test/RC0416-rc-Annotation-RCPermanentThread/jniTestHelper.cpp b/test/testsuite/ouroboros/rc_test/native_test/RC0416-rc-Annotation-RCPermanentThread/jniTestHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c3dd79c74a48a56118894192c963efd6fc0b1c61 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/native_test/RC0416-rc-Annotation-RCPermanentThread/jniTestHelper.cpp @@ -0,0 +1,69 @@ +#include +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentThread_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentThread_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest2_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest2_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest3_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest3_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest4_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest4_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest5_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest5_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +} /* extern "C" */ diff --git a/test/testsuite/ouroboros/rc_test/native_test/RC0423-rc-Annotation-RCPermanentTest6/RCPermanentTest6.java b/test/testsuite/ouroboros/rc_test/native_test/RC0423-rc-Annotation-RCPermanentTest6/RCPermanentTest6.java new file mode 100755 index 0000000000000000000000000000000000000000..9dc8983d44b2889726a832555c71f81db010684f --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/native_test/RC0423-rc-Annotation-RCPermanentTest6/RCPermanentTest6.java @@ -0,0 +1,125 @@ +/* + *- @TestCaseID:maple/runtime/rc/annotation/Permanent/RCPermanentTest6 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:@Permanent &@Unowned 在同个case中使用。添加Permanent annotation的数组,验证是否经过RC策略以及是否为堆内存;添加Unowned annotation,确认被正常释放 + *- @Condition: + * -#c1: + *- @Brief:functionTest + * -#step1: + * 添加Permanent annotation的普通数组,验证是否经过RC策略以及是否为堆内存 + * 添加Unowned annotation,确认被正常释放 + *- @Expect:ExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: RCPermanentTest6.java jniTestHelper.cpp + *- @ExecuteClass: RCPermanentTest6 + *- @ExecuteArgs: + *- @Remark: + *- @Author:liuweiqing l00481345 + */ + +import java.lang.reflect.Field; +import java.util.ArrayList; + +import com.huawei.ark.annotation.*; + +import java.lang.ref.WeakReference; + +public class RCPermanentTest6 { + public static native boolean isHeapObject(Object obj); + + public static native int refCount(Object obj); + + public static int checkNum = 0; + + static Object owner; + + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + //System.out.printf("rc:%-5s heap:%-5s %s%n", !skipRC, isHeapObject(obj), title); + } + + /* + 验证new int @Permanent [8] + */ + static void method1(Object obj) { + obj = new int@Permanent[8]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new int @Permanent [8];in method1"); + } + } + + + public static void main(String[] args) { + Object obj = null; + method1(obj); + new Test_A().test(); + if (checkNum == 1) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("checkNum:" + checkNum); + } + } +} + +class Test_B { + @Unowned + Test_A aa; + + // add volatile will crash + // static Test_A a1; + + protected void finalize() { + System.out.println("ExpectResult"); + } +} + +class Test_A { + Test_B bb; + + public void test() { + setReferences(); + System.runFinalization(); + } + + private void setReferences() { + Test_A ta = new Test_A(); + ta.bb = new Test_B(); + //ta.bb.aa = ta; + + try { + Field m = Test_B.class.getDeclaredField("aa"); + m.set(ta.bb, ta); + Test_A a_temp = (Test_A) m.get(ta.bb); + if (a_temp != ta) { + System.out.println("error"); + } + //Field m1 = Test_B.class.getDeclaredField("a1"); + //m1.set(null, ta); + } catch (Exception e) { + System.out.println(e); + } + } +} +// DEPENDENCE: jniTestHelper.cpp +// EXEC:%maple %f jniTestHelper.cpp %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/native_test/RC0423-rc-Annotation-RCPermanentTest6/jniTestHelper.cpp b/test/testsuite/ouroboros/rc_test/native_test/RC0423-rc-Annotation-RCPermanentTest6/jniTestHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c7c9aaccdebb4aeb5e51ebb76f8ab46a5265581a --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/native_test/RC0423-rc-Annotation-RCPermanentTest6/jniTestHelper.cpp @@ -0,0 +1,19 @@ +#include +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest6_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest6_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +} /* extern "C" */ diff --git a/test/testsuite/ouroboros/rc_test/native_test/RC0424-rc-Annotation-RCPermanentThread2/RCPermanentThread2.java b/test/testsuite/ouroboros/rc_test/native_test/RC0424-rc-Annotation-RCPermanentThread2/RCPermanentThread2.java new file mode 100755 index 0000000000000000000000000000000000000000..0df9e20b6169b5cbc8f913ba62d44bfc608e0a2f --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/native_test/RC0424-rc-Annotation-RCPermanentThread2/RCPermanentThread2.java @@ -0,0 +1,330 @@ +/* + *- @TestCaseID:maple/runtime/rc/annotation/Permanent/RCPermanentThread2 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:多线程下调用:@Permanent &@Unowned 在同个case中使用。添加Permanent annotation的数组,验证是否经过RC策略以及是否为堆内存;添加Unowned annotation,确认被正常释放 + *- @Condition: + * -#c1: + *- @Brief:functionTest + * -#step1: + * 多线程下调用:@Permanent &@Unowned 在同个case中使用。添加Permanent annotation的数组,验证是否经过RC策略以及是否为堆内存;添加Unowned annotation,确认被正常释放 + *- @Expect:ExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: RCPermanentThread2.java jniTestHelper.cpp + *- @ExecuteClass: RCPermanentThread2 + *- @ExecuteArgs: + *- @Remark: + *- @Author:liuweiqing l00481345 + */ + +import java.lang.reflect.Field; +import java.util.ArrayList; + +import com.huawei.ark.annotation.*; + + +public class RCPermanentThread2 { + public static void main(String[] args) throws InterruptedException { + rc_testcase_main_wrapper(); + rc_testcase_main_wrapper2(); + } + + private static void rc_testcase_main_wrapper() throws InterruptedException { + RCPermanentTest rcPermanentTest = new RCPermanentTest(); + RCPermanentTest rcPermanentTest2 = new RCPermanentTest(); + RCPermanentTest rcPermanentTest3 = new RCPermanentTest(); + RCPermanentTest rcPermanentTest4 = new RCPermanentTest(); + RCPermanentTest rcPermanentTest5 = new RCPermanentTest(); + + rcPermanentTest.start(); + rcPermanentTest.join(); + + rcPermanentTest2.start(); + rcPermanentTest2.join(); + + rcPermanentTest3.start(); + rcPermanentTest3.join(); + + rcPermanentTest4.start(); + rcPermanentTest4.join(); + + rcPermanentTest5.start(); + rcPermanentTest5.join(); + + // rcPermanentTest.join(); + // rcPermanentTest2.join(); + // rcPermanentTest3.join(); + // rcPermanentTest4.join(); + // rcPermanentTest5.join(); + + if (rcPermanentTest.check() && rcPermanentTest2.check() && rcPermanentTest3.check() && rcPermanentTest4.check() && rcPermanentTest5.check()) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("rcPermanentTest.check() :" + rcPermanentTest.check()); + System.out.println("rcPermanentTest2.check() :" + rcPermanentTest2.check()); + System.out.println("rcPermanentTest3.check() :" + rcPermanentTest3.check()); + System.out.println("rcPermanentTest4.check() :" + rcPermanentTest4.check()); + System.out.println("rcPermanentTest5.check() :" + rcPermanentTest5.check()); + + } + } + + private static void rc_testcase_main_wrapper2() throws InterruptedException { + RCUnownedTest rcUnownedTest = new RCUnownedTest(); + RCUnownedTest rcUnownedTest2 = new RCUnownedTest(); + RCUnownedTest rcUnownedTest3 = new RCUnownedTest(); + RCUnownedTest rcUnownedTest4 = new RCUnownedTest(); + RCUnownedTest rcUnownedTest5 = new RCUnownedTest(); + + rcUnownedTest.start(); + rcUnownedTest2.start(); + rcUnownedTest3.start(); + rcUnownedTest4.start(); + rcUnownedTest5.start(); + + rcUnownedTest.join(); + rcUnownedTest2.join(); + rcUnownedTest3.join(); + rcUnownedTest4.join(); + rcUnownedTest5.join(); + } +} + + +class RCPermanentTest extends Thread { + public boolean checkout; + + public static native boolean isHeapObject(Object obj); + + public static native int refCount(Object obj); + + public static int checkNum = 0; + + static Object owner; + + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + //System.out.printf("rc:%-5s heap:%-5s %s%n", !skipRC, isHeapObject(obj), title); + } + + /* + 验证new int @Permanent [8] + */ + static void method1(Object obj) { + obj = new int@Permanent[8]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new int @Permanent [8];in method1"); + } + } + + /* + 验证new int [8] + */ + static void method2(Object obj) { + obj = new int[8]; + boolean result1 = checkRC(obj); + if (result1 == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in new int [8];in method2"); + } + } + + /* + 验证new @Permanent int[8] + */ + static void method3(Object obj) { + obj = new @Permanent int[1]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new @Permanent int[8];in method3"); + } + } + + /* + 验证new Integer @Permanent [10] + */ + static void method4(Object obj) { + Integer[] arr = new Integer@Permanent[10]; + boolean result1 = checkRC(obj); + noleak.add(arr); // let leak check happy + arr[0] = new Integer(10000); + arr[9] = new Integer(20000); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new Integer @Permanent [10];in method4"); + } + } + + /* + 验证new @Permanent Integer [10] + */ + static void method5(Object obj) { + Integer[] arr = new @Permanent Integer[10]; + boolean result1 = checkRC(obj); + noleak.add(arr); // let leak check happy + arr[0] = new Integer(10000); + arr[9] = new Integer(20000); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new @Permanent Integer [10];in method5"); + } + } + + /* + 验证new Integer[10]; + */ + static void method6(Object obj) { + obj = new Integer[10]; + boolean result1 = checkRC(obj); + + if (result1 == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in new Integer[10];in method6"); + System.out.println("checkRC(obj):" + result1 + " isHeapObject(obj):" + isHeapObject(obj)); + } + } + + /* + 验证new @Permanent ArrayList[]{}; + */ + static void method7(Object obj) { + obj = new @Permanent ArrayList[]{}; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new @Permanent ArrayList[]{};in method7"); + } + } + + /* + 验证new ArrayList @Permanent []{}; + */ + static void method8(Object obj) { + obj = new ArrayList@Permanent[]{}; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new ArrayList @Permanent []{};in method8"); + } + } + + /* + 验证new ArrayList []{}; + */ + static void method9(Object obj) { + obj = new ArrayList[]{}; + boolean result1 = checkRC(obj); + if (result1 == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in new ArrayList []{}; method9"); + } + } + + + static ArrayList noleak = new ArrayList<>(); + + public void run( + ) { + checkNum = 0; + Object obj = null; + method1(obj); + method2(obj); + method3(obj); + method4(obj); + method5(obj); + method6(obj); + method7(obj); + method8(obj); + method9(obj); + // System.out.println(checkNum); + if (checkNum == 9) { + checkout = true; + } else { + checkout = false; + System.out.println("checkout== false,checkNum:"+checkNum); + } + } + + public boolean check() { + return checkout; + } +} + +class RCUnownedTest extends Thread { + public void run() { + new Test_A().test(); + + } +} + +class Test_A { + Test_B bb; + + public void test() { + setReferences(); + System.runFinalization(); + } + + private void setReferences() { + Test_A ta = new Test_A(); + ta.bb = new Test_B(); + //ta.bb.aa = ta; + + try { + Field m = Test_B.class.getDeclaredField("aa"); + m.set(ta.bb, ta); + Test_A a_temp = (Test_A) m.get(ta.bb); + if (a_temp != ta) { + System.out.println("error"); + } + //Field m1 = Test_B.class.getDeclaredField("a1"); + //m1.set(null, ta); + } catch (Exception e) { + System.out.println(e); + } + } +} + +class Test_B { + @Unowned + Test_A aa; + + // add volatile will crash + // static Test_A a1; + + protected void finalize() { + System.out.println("ExpectResult"); + } + +} +// DEPENDENCE: jniTestHelper.cpp +// EXEC:%maple %f jniTestHelper.cpp %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/native_test/RC0424-rc-Annotation-RCPermanentThread2/jniTestHelper.cpp b/test/testsuite/ouroboros/rc_test/native_test/RC0424-rc-Annotation-RCPermanentThread2/jniTestHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..31811eb73638c3784e8db250533d3bce19a8aa6c --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/native_test/RC0424-rc-Annotation-RCPermanentThread2/jniTestHelper.cpp @@ -0,0 +1,29 @@ +#include +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentThread2_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentThread2_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +} /* extern "C" */ diff --git a/test/testsuite/ouroboros/rc_test/native_test/RC0425-rc-Annotation-RCPermanentTest7/RCPermanentTest7.java b/test/testsuite/ouroboros/rc_test/native_test/RC0425-rc-Annotation-RCPermanentTest7/RCPermanentTest7.java new file mode 100755 index 0000000000000000000000000000000000000000..b790bcc880435951c750bb3680afdc72d0a8338f --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/native_test/RC0425-rc-Annotation-RCPermanentTest7/RCPermanentTest7.java @@ -0,0 +1,113 @@ +/* + *- @TestCaseID:maple/runtime/rc/annotation/Permanent/RCPermanentTest7 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:@Permanent &@Weak在同个case中使用。添加Permanent annotation的数组,验证是否经过RC策略以及是否为堆内存;添加Weak annotation,确认被正常释放 + *- @Condition: + * -#c1: + *- @Brief:functionTest + * -#step1: + * 添加Permanent annotation的普通数组,验证是否经过RC策略以及是否为堆内存 + * 添加Weak annotation,确认被正常释放 + *- @Expect:ExpectResult\nExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: RCPermanentTest7.java jniTestHelper.cpp + *- @ExecuteClass: RCPermanentTest7 + *- @ExecuteArgs: + *- @Remark: + *- @Author:liuweiqing l00481345 + */ + +import com.huawei.ark.annotation.*; + + +public class RCPermanentTest7 { + public static native boolean isHeapObject(Object obj); + + public static native int refCount(Object obj); + + public static int checkNum = 0; + + static Object owner; + + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + //System.out.printf("rc:%-5s heap:%-5s %s%n", !skipRC, isHeapObject(obj), title); + } + + /* + 验证new int @Permanent [8] + */ + static void method1(Object obj) { + obj = new int@Permanent[8]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new int @Permanent [8];in method1"); + } + } + + + public static void main(String[] args) { + Object obj = null; + method1(obj); + new Test_A().test(); + if (checkNum == 1) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("checkNum:" + checkNum); + } + } +} + +class Test_A { + @Weak + Test_B bb; + Test_B bb2; + + public void test() { + foo(); + try { + Thread.sleep(5000); + } catch (Exception e) { + e.printStackTrace(); + } + try { + bb.run(); + } catch (NullPointerException e) { + System.out.println("ExpectResult"); + } + bb2.run(); + } + + private void foo() { + bb = new Test_B(); + bb2 = new Test_B(); + } +} + +class Test_B { + public void run() { + System.out.println("ExpectResult"); + } +} +// DEPENDENCE: jniTestHelper.cpp +// EXEC:%maple %f jniTestHelper.cpp %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/native_test/RC0425-rc-Annotation-RCPermanentTest7/jniTestHelper.cpp b/test/testsuite/ouroboros/rc_test/native_test/RC0425-rc-Annotation-RCPermanentTest7/jniTestHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..24c07934365baf4609c0545da7560102d6c89fd5 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/native_test/RC0425-rc-Annotation-RCPermanentTest7/jniTestHelper.cpp @@ -0,0 +1,19 @@ +#include +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest7_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest7_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +} /* extern "C" */ diff --git a/test/testsuite/ouroboros/rc_test/native_test/RC0426-rc-Annotation-RCPermanentThread3/RCPermanentThread3.java b/test/testsuite/ouroboros/rc_test/native_test/RC0426-rc-Annotation-RCPermanentThread3/RCPermanentThread3.java new file mode 100755 index 0000000000000000000000000000000000000000..5e58e1ca019a773485db8a53355b5a46ea969e95 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/native_test/RC0426-rc-Annotation-RCPermanentThread3/RCPermanentThread3.java @@ -0,0 +1,320 @@ +/* + *- @TestCaseID:maple/runtime/rc/annotation/Permanent/RCPermanentThread3 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:多线程下调用:@Permanent &@Weak在同个case中使用。添加Permanent annotation的数组,验证是否经过RC策略以及是否为堆内存;添加Weak annotation,确认被正常释放 + *- @Condition: + * -#c1: + *- @Brief:functionTest + * -#step1: + * 多线程下调用:@Permanent &@Weak在同个case中使用。添加Permanent annotation的数组,验证是否经过RC策略以及是否为堆内存;添加Weak annotation,确认被正常释放 + *- @Expect:ExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\n + *- @Priority: High + *- @Source: RCPermanentThread3.java jniTestHelper.cpp + *- @ExecuteClass: RCPermanentThread3 + *- @ExecuteArgs: + *- @Remark: + *- @Author:liuweiqing l00481345 + */ + +import java.lang.reflect.Field; +import java.util.ArrayList; + +import com.huawei.ark.annotation.*; + + +public class RCPermanentThread3 { + public static void main(String[] args) throws InterruptedException { + rc_testcase_main_wrapper(); + rc_testcase_main_wrapper2(); + } + + private static void rc_testcase_main_wrapper() throws InterruptedException { + RCPermanentTest rcPermanentTest = new RCPermanentTest(); + RCPermanentTest rcPermanentTest2 = new RCPermanentTest(); + RCPermanentTest rcPermanentTest3 = new RCPermanentTest(); + RCPermanentTest rcPermanentTest4 = new RCPermanentTest(); + RCPermanentTest rcPermanentTest5 = new RCPermanentTest(); + + rcPermanentTest.start(); + rcPermanentTest.join(); + + rcPermanentTest2.start(); + rcPermanentTest2.join(); + + rcPermanentTest3.start(); + rcPermanentTest3.join(); + + rcPermanentTest4.start(); + rcPermanentTest4.join(); + + rcPermanentTest5.start(); + rcPermanentTest5.join(); + + // rcPermanentTest.join(); + // rcPermanentTest2.join(); + // rcPermanentTest3.join(); + // rcPermanentTest4.join(); + // rcPermanentTest5.join(); + + if (rcPermanentTest.check() && rcPermanentTest2.check() && rcPermanentTest3.check() && rcPermanentTest4.check() && rcPermanentTest5.check()) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("rcPermanentTest.check() :" + rcPermanentTest.check()); + System.out.println("rcPermanentTest2.check() :" + rcPermanentTest2.check()); + System.out.println("rcPermanentTest3.check() :" + rcPermanentTest3.check()); + System.out.println("rcPermanentTest4.check() :" + rcPermanentTest4.check()); + System.out.println("rcPermanentTest5.check() :" + rcPermanentTest5.check()); + + } + } + + private static void rc_testcase_main_wrapper2() throws InterruptedException { + RCWeakTest rcWeakTest = new RCWeakTest(); + RCWeakTest rcWeakTest2 = new RCWeakTest(); + RCWeakTest rcWeakTest3 = new RCWeakTest(); + RCWeakTest rcWeakTest4 = new RCWeakTest(); + RCWeakTest rcWeakTest5 = new RCWeakTest(); + + rcWeakTest.start(); + rcWeakTest2.start(); + rcWeakTest3.start(); + rcWeakTest4.start(); + rcWeakTest5.start(); + + rcWeakTest.join(); + rcWeakTest2.join(); + rcWeakTest3.join(); + rcWeakTest4.join(); + rcWeakTest5.join(); + } +} + + +class RCPermanentTest extends Thread { + public boolean checkout; + + public static native boolean isHeapObject(Object obj); + + public static native int refCount(Object obj); + + public static int checkNum = 0; + + static Object owner; + + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + //System.out.printf("rc:%-5s heap:%-5s %s%n", !skipRC, isHeapObject(obj), title); + } + + /* + 验证new int @Permanent [8] + */ + static void method1(Object obj) { + obj = new int@Permanent[8]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new int @Permanent [8];in method1"); + } + } + + /* + 验证new int [8] + */ + static void method2(Object obj) { + obj = new int[8]; + boolean result1 = checkRC(obj); + if (result1 == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in new int [8];in method2"); + } + } + + /* + 验证new @Permanent int[8] + */ + static void method3(Object obj) { + obj = new @Permanent int[1]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new @Permanent int[8];in method3"); + } + } + + /* + 验证new Integer @Permanent [10] + */ + static void method4(Object obj) { + Integer[] arr = new Integer@Permanent[10]; + boolean result1 = checkRC(obj); + noleak.add(arr); // let leak check happy + arr[0] = new Integer(10000); + arr[9] = new Integer(20000); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new Integer @Permanent [10];in method4"); + } + } + + /* + 验证new @Permanent Integer [10] + */ + static void method5(Object obj) { + Integer[] arr = new @Permanent Integer[10]; + boolean result1 = checkRC(obj); + noleak.add(arr); // let leak check happy + arr[0] = new Integer(10000); + arr[9] = new Integer(20000); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new @Permanent Integer [10];in method5"); + } + } + + /* + 验证new Integer[10]; + */ + static void method6(Object obj) { + obj = new Integer[10]; + boolean result1 = checkRC(obj); + + if (result1 == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in new Integer[10];in method6"); + System.out.println("checkRC(obj):" + result1 + " isHeapObject(obj):" + isHeapObject(obj)); + } + } + + /* + 验证new @Permanent ArrayList[]{}; + */ + static void method7(Object obj) { + obj = new @Permanent ArrayList[]{}; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new @Permanent ArrayList[]{};in method7"); + } + } + + /* + 验证new ArrayList @Permanent []{}; + */ + static void method8(Object obj) { + obj = new ArrayList@Permanent[]{}; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new ArrayList @Permanent []{};in method8"); + } + } + + /* + 验证new ArrayList []{}; + */ + static void method9(Object obj) { + obj = new ArrayList[]{}; + boolean result1 = checkRC(obj); + if (result1 == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in new ArrayList []{}; method9"); + } + } + + + static ArrayList noleak = new ArrayList<>(); + + public void run( + ) { + checkNum = 0; + Object obj = null; + method1(obj); + method2(obj); + method3(obj); + method4(obj); + method5(obj); + method6(obj); + method7(obj); + method8(obj); + method9(obj); + // System.out.println(checkNum); + if (checkNum == 9) { + checkout = true; + } else { + checkout = false; + System.out.println("checkout== false,checkNum:"+checkNum); + } + } + + public boolean check() { + return checkout; + } +} + +class RCWeakTest extends Thread { + public void run() { + new Test_A().test(); + } +} + +class Test_A { + @Weak + Test_B bb; + Test_B bb2; + + public void test() { + foo(); + try { + Thread.sleep(5000); + } catch (Exception e) { + e.printStackTrace(); + } + try { + bb.run(); + } catch (NullPointerException e) { + System.out.println("ExpectResult"); + } + bb2.run(); + } + + private void foo() { + bb = new Test_B(); + bb2 = new Test_B(); + } +} + +class Test_B { + public void run() { + System.out.println("ExpectResult"); + } +} +// DEPENDENCE: jniTestHelper.cpp +// EXEC:%maple %f jniTestHelper.cpp %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\nExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/native_test/RC0426-rc-Annotation-RCPermanentThread3/jniTestHelper.cpp b/test/testsuite/ouroboros/rc_test/native_test/RC0426-rc-Annotation-RCPermanentThread3/jniTestHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2cfe702b8b682caaef6b63e0d752c019ef8f98db --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/native_test/RC0426-rc-Annotation-RCPermanentThread3/jniTestHelper.cpp @@ -0,0 +1,29 @@ +#include +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentThread3_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentThread3_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +} /* extern "C" */ diff --git a/test/testsuite/ouroboros/rc_test/native_test/RC0429-rc-Annotation-RCPermanentTest8/RCPermanentTest8.java b/test/testsuite/ouroboros/rc_test/native_test/RC0429-rc-Annotation-RCPermanentTest8/RCPermanentTest8.java new file mode 100755 index 0000000000000000000000000000000000000000..45bebd8a7f553b464b165bda07505c529513eced --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/native_test/RC0429-rc-Annotation-RCPermanentTest8/RCPermanentTest8.java @@ -0,0 +1,88 @@ +/* + *- @TestCaseID:maple/runtime/rc/annotation/Permanent/RCPermanentTest8 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:在try/catch中添加Permanent annotation的字段,验证是否经过RC策略以及是否为堆内存 + *- @Condition: + * -#c1: + *- @Brief:functionTest + * -#step1: + * 在try/catch中使用注解,验证是否经过RC策略以及是否为堆内存 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCPermanentTest8.java jniTestHelper.cpp + *- @ExecuteClass: RCPermanentTest8 + *- @ExecuteArgs: + *- @Remark: + *- @Author:liuweiqing l00481345 + */ + +import java.util.ArrayList; + +import com.huawei.ark.annotation.Permanent; + +import java.lang.ref.WeakReference; + +public class RCPermanentTest8 { + public static native boolean isHeapObject(Object obj); + + public static native int refCount(Object obj); + + public static int checkNum = 0; + + static Object owner; + + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + //System.out.printf("rc:%-5s heap:%-5s %s%n", !skipRC, isHeapObject(obj), title); + } + + /* + 验证new int @Permanent [8] + */ + static void method1(Object obj) { + try { + obj = new int@Permanent[8]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new int @Permanent [8];in method1"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + + public static void main(String[] args) { + + Object obj = null; + method1(obj); + + if (checkNum == 1) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("checkNum:" + checkNum); + } + } +} +// DEPENDENCE: jniTestHelper.cpp +// EXEC:%maple %f jniTestHelper.cpp %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/native_test/RC0429-rc-Annotation-RCPermanentTest8/jniTestHelper.cpp b/test/testsuite/ouroboros/rc_test/native_test/RC0429-rc-Annotation-RCPermanentTest8/jniTestHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b56c4a1840d0e5e1541f7abf5c161dad77721031 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/native_test/RC0429-rc-Annotation-RCPermanentTest8/jniTestHelper.cpp @@ -0,0 +1,19 @@ +#include +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest8_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest8_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +} /* extern "C" */ diff --git a/test/testsuite/ouroboros/rc_test/native_test/RC0430-rc-Annotation-RCPermanentThread4/RCPermanentThread4.java b/test/testsuite/ouroboros/rc_test/native_test/RC0430-rc-Annotation-RCPermanentThread4/RCPermanentThread4.java new file mode 100755 index 0000000000000000000000000000000000000000..8f8c25fc49599da267e391f76d03c9d5bbbfee83 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/native_test/RC0430-rc-Annotation-RCPermanentThread4/RCPermanentThread4.java @@ -0,0 +1,214 @@ +/* + *- @TestCaseID:maple/runtime/rc/annotation/Permanent/RCPermanentThread4 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:多线程下调用RC0429,以及在synchronized代码块中使用@Permanent,验证是否经过RC策略以及是否为堆内存 + *- @Condition: + * -#c1: + *- @Brief:functionTest + * -#step1: + * 多线程下调用PermanentTest的caseRC0429,以及在synchronized代码块中使用@Permanent,验证是否经过RC策略以及是否为堆内存 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCPermanentThread4.java jniTestHelper.cpp + *- @ExecuteClass: RCPermanentThread4 + *- @ExecuteArgs: + *- @Remark: + *- @Author:liuweiqing l00481345 + */ + +import com.huawei.ark.annotation.Permanent; + + +public class RCPermanentThread4 { + public static void main(String[] args) throws InterruptedException { + rc_testcase_main_wrapper(); + } + + private static void rc_testcase_main_wrapper() throws InterruptedException { + RCPermanentTest rcPermanentTest = new RCPermanentTest(); + RCPermanentTest rcPermanentTest2 = new RCPermanentTest(); + RCPermanentTest rcPermanentTest3 = new RCPermanentTest(); + RCPermanentTest rcPermanentTest4 = new RCPermanentTest(); + RCPermanentTest rcPermanentTest5 = new RCPermanentTest(); + + rcPermanentTest.start(); + rcPermanentTest.join(); + + rcPermanentTest2.start(); + rcPermanentTest2.join(); + + rcPermanentTest3.start(); + rcPermanentTest3.join(); + + rcPermanentTest4.start(); + rcPermanentTest4.join(); + + rcPermanentTest5.start(); + rcPermanentTest5.join(); + + if (rcPermanentTest.check() && rcPermanentTest2.check() && rcPermanentTest3.check() && rcPermanentTest4.check() && rcPermanentTest5.check()) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("rcPermanentTest.check() :" + rcPermanentTest.check()); + System.out.println("rcPermanentTest2.check() :" + rcPermanentTest2.check()); + System.out.println("rcPermanentTest3.check() :" + rcPermanentTest3.check()); + System.out.println("rcPermanentTest4.check() :" + rcPermanentTest4.check()); + System.out.println("rcPermanentTest5.check() :" + rcPermanentTest5.check()); + } + } + + private static void rc_testcase_main_wrapper2() throws InterruptedException { + SyncTest syncTest = new SyncTest(); + SyncTest syncTest1 = new SyncTest(); + SyncTest syncTest2 = new SyncTest(); + SyncTest syncTest3 = new SyncTest(); + SyncTest syncTest4 = new SyncTest(); + + syncTest.start(); + syncTest.join(); + + syncTest1.start(); + syncTest1.join(); + + syncTest2.start(); + syncTest2.join(); + + syncTest3.start(); + syncTest3.join(); + + syncTest4.start(); + syncTest4.join(); + + if (syncTest.check() && syncTest1.check() && syncTest2.check() && syncTest3.check() && syncTest4.check()) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("rcPermanentTest.check() :" + syncTest.check()); + System.out.println("rcPermanentTest2.check() :" + syncTest1.check()); + System.out.println("rcPermanentTest3.check() :" + syncTest2.check()); + System.out.println("rcPermanentTest4.check() :" + syncTest3.check()); + System.out.println("rcPermanentTest5.check() :" + syncTest4.check()); + } + } +} + + +class RCPermanentTest extends Thread { + public boolean checkout; + + public static native boolean isHeapObject(Object obj); + + public static native int refCount(Object obj); + + public static int checkNum = 0; + + static Object owner; + + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + //System.out.printf("rc:%-5s heap:%-5s %s%n", !skipRC, isHeapObject(obj), title); + } + + /* + 验证new int @Permanent [8] + */ + static void method1(Object obj) { + try { + obj = new int@Permanent[8]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new int @Permanent [8];in method1"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + + public void run() { + checkNum = 0; + Object obj = null; + method1(obj); + if (checkNum == 1) { + checkout = true; + } else { + checkout = false; + System.out.println(checkNum); + } + } + + public boolean check() { + return checkout; + } +} + + +class SyncTest extends Thread { + public boolean checkout; + + public static native boolean isHeapObject(Object obj); + + public static native int refCount(Object obj); + + static Object owner; + + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + //System.out.printf("rc:%-5s heap:%-5s %s%n", !skipRC, isHeapObject(obj), title); + } + + public void run() { + synchronized (this) { + Object obj = null; + obj = new int@Permanent[8]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkout = true; + } else { + checkout = false; + System.out.println("error in new int @Permanent [8];in method1"); + } + } + } + + + public boolean check() { + return checkout; + } + +} +// DEPENDENCE: jniTestHelper.cpp +// EXEC:%maple %f jniTestHelper.cpp %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/native_test/RC0430-rc-Annotation-RCPermanentThread4/jniTestHelper.cpp b/test/testsuite/ouroboros/rc_test/native_test/RC0430-rc-Annotation-RCPermanentThread4/jniTestHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e0fe46b017c93caa103afea3aa0e8e652d3cdac2 --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/native_test/RC0430-rc-Annotation-RCPermanentThread4/jniTestHelper.cpp @@ -0,0 +1,20 @@ +#include +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + + +} /* extern "C" */ diff --git a/test/testsuite/ouroboros/rc_test/native_test/RC0448-rc-Annotation-RCPermanentLimit2/RCPermanentLimit2.java b/test/testsuite/ouroboros/rc_test/native_test/RC0448-rc-Annotation-RCPermanentLimit2/RCPermanentLimit2.java new file mode 100755 index 0000000000000000000000000000000000000000..6b16a0c5b667eabeb3bf3a67da122b6b251fb02a --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/native_test/RC0448-rc-Annotation-RCPermanentLimit2/RCPermanentLimit2.java @@ -0,0 +1,129 @@ +/* + *- @TestCaseID:maple/runtime/rc/annotation/Permanent/RCPermanentTest8 + *- @TestCaseName:MyselfClassName + *- @RequirementID:SR-10620538 + *- @RequirementName:[运行时需求]支持自动内存管理 + *- @Title/Destination:添加Permanent annotation的对象,验证申请内存大于64k的情况是否正常,验证是否经过RC策略以及是否为堆内存 + *- @Condition: + * -#c1: + *- @Brief:functionTest + * -#step1: + * 使用注解的对象申请内存大于64K,验证是否经过RC策略以及是否为堆内存 + *- @Expect:ExpectResult\n + *- @Priority: High + *- @Source: RCPermanentLimit2.java jniTestHelper.cpp + *- @ExecuteClass: RCPermanentLimit2 + *- @ExecuteArgs: + *- @Remark: + *- @Author:liuweiqing l00481345 + */ + +import java.util.ArrayList; + +import com.huawei.ark.annotation.Permanent; + + +public class RCPermanentLimit2 { + public static native boolean isHeapObject(Object obj); + + public static native int refCount(Object obj); + + public static int checkNum = 0; + + static Object owner; + + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + //System.out.printf("rc:%-5s heap:%-5s %s%n", !skipRC, isHeapObject(obj), title); + } + + /* + 验证加了注解Permanent,申请的内存为64K+1byte的情况 + */ + static void method1(Object obj) { + try { + obj = new @Permanent ArrayList(); + + for (int i = 0; i < 64 * 1024+1; i++) { + byte tmp = 2; + ((ArrayList) obj).add(tmp); + } +// int check_size = ((ArrayList) obj).size(); +// System.out.println(check_size); + boolean result1 = checkRC(obj); + boolean result2 =isHeapObject(obj); + if (result1 == false && result2 == true) { + checkNum++; + } else { + System.out.println("result1:" + result1); + System.out.println("isHeapObject:" + result2); + System.out.println("error in new int test1;in method1"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + /* + 验证加了注解Permanent,申请的内存为128K的情况 + */ + static void method2(Object obj) { + try { + obj = new @Permanent ArrayList(); + + for (int i = 0; i < 128 * 1024; i++) { + byte tmp = 2; + ((ArrayList) obj).add(tmp); + } +// int check_size = ((ArrayList) obj).size(); +// System.out.println(check_size); + boolean result1 = checkRC(obj); + boolean result2 =isHeapObject(obj); + if (result1 == false && result2 == true) { + checkNum++; + } else { + System.out.println("result1:" + result1); + System.out.println("isHeapObject:" + result2); + System.out.println("error in new int test1;in method1"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void main(String[] args) { + + Object obj = null; + method1(obj); + Runtime.getRuntime().gc(); + method1(obj); + + method2(obj); + Runtime.getRuntime().gc(); + method2(obj); + + if (checkNum == 4) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("checkNum:" + checkNum); + } + } +} + +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full ExpectResult\n diff --git a/test/testsuite/ouroboros/rc_test/native_test/RC0448-rc-Annotation-RCPermanentLimit2/jniTestHelper.cpp b/test/testsuite/ouroboros/rc_test/native_test/RC0448-rc-Annotation-RCPermanentLimit2/jniTestHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..38b8ea6b916ecde5e414c577864746291199560b --- /dev/null +++ b/test/testsuite/ouroboros/rc_test/native_test/RC0448-rc-Annotation-RCPermanentLimit2/jniTestHelper.cpp @@ -0,0 +1,19 @@ +#include +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentLimit2_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentLimit2_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +} /* extern "C" */ diff --git a/test/testsuite/ouroboros/testlist b/test/testsuite/ouroboros/testlist index 7bc631a5da1a6186ace40997936afa40a2bf38da..dc1bd85edb6cfb532fae430ae2cda734bac08249 100644 --- a/test/testsuite/ouroboros/testlist +++ b/test/testsuite/ouroboros/testlist @@ -1,11 +1,11 @@ [ALL-TEST-CASE] arrayboundary_test clinit_test - compact_test eh_test fuzzapi_test other_test parent_test + rc_test reflection_test stmtpre_test string_test @@ -20,4 +20,43 @@ reflection_test/issue-0000-rt-Reflection-ReflectionforName2 memory_management/MemoryTest/RC0410-rc-Memory-stressTestCase29 thread_test/RT0180-rt-thread-MonitorTestCase8 - compact_test/RT0199-rt-compact-AnnotationPackageSetTest + rc_test/RC0249-rc-function-RC_Finalize_03 + rc_test/RC0433-rc-SoftRef-SoftRefTest03 + rc_test/RC0440-rc-RCHeader-RCHeaderTest04 + rc_test/RC0443-rc-PlacementRC-PlacementRCTest01 + rc_test/RC0449-rc-RP-FinalizerReferenceTest01 + rc_test/RC0450-rc-RP-FinalizerReferenceTest02 + rc_test/RC0451-rc-RP-FinalizerReferenceTest03 + rc_test/RC0453-rc-RP-FinalizerReferenceTest05 + rc_test/RC0454-rc-RP-FinalizerReferenceTest06 + rc_test/RC0455-rc-RP-FinalizerReferenceTest07 + rc_test/RC0456-rc-RP-FinalizerReferenceTest08 + rc_test/RC0458-rc-GC-TriggerGCTest02 + rc_test/RC0459-rc-GC-TriggerGCTest03 + rc_test/RC0463-rc-GC-TriggerGCTest07 + rc_test/RC0464-rc-GC-TriggerGCTest08 + rc_test/RC0465-rc-GC-TriggerGCTest09 + rc_test/RC0466-rc-GC-TriggerGCTest10 + rc_test/RC0486-rc-StackScan-CB_Thread_01 + rc_test/RC0487-rc-StackScan-CB_Thread_02 + rc_test/RC0495-rc-GC-TaskQueue-FrequentSystemGC_01 + rc_test/RC0496-rc-GC-TaskQueue-StartupInvoke_01 + rc_test/RC0515-GC-FrequentGCTest01 + rc_test/common_test/RC0434-rc-SoftRef-SoftRefTest04 + rc_test/common_test/RC0436-rc-SoftRef-SoftRefTest06 + rc_test/common_test/RC0437-rc-RCHeader-RCHeaderTest + rc_test/common_test/RC0438-rc-RCHeader-RCHeaderTest02 + rc_test/common_test/RC0439-rc-RCHeader-RCHeaderTest03 + rc_test/common_test/RC0441-rc-RCHeader-RCHeaderTest06 + rc_test/common_test/RC0442-rc-RCHeader-RCHeaderTest07 + rc_test/common_test/RC0445-rc-PlacementRC-PlacementRCTest03 + rc_test/native_test/RC0411-rc-Annotation-RCPermanentTest + rc_test/native_test/RC0412-rc-Annotation-RCPermanentTest2 + rc_test/native_test/RC0416-rc-Annotation-RCPermanentThread + rc_test/native_test/RC0423-rc-Annotation-RCPermanentTest6 + rc_test/native_test/RC0424-rc-Annotation-RCPermanentThread2 + rc_test/native_test/RC0425-rc-Annotation-RCPermanentTest7 + rc_test/native_test/RC0426-rc-Annotation-RCPermanentThread3 + rc_test/native_test/RC0429-rc-Annotation-RCPermanentTest8 + rc_test/native_test/RC0430-rc-Annotation-RCPermanentThread4 + rc_test/native_test/RC0448-rc-Annotation-RCPermanentLimit2