Skip to content

Commit 525926f

Browse files
committed
First effort to consolidate v2.0 - Fix #65 - MultiThread not working
1 parent 5173de7 commit 525926f

File tree

11 files changed

+302
-251
lines changed

11 files changed

+302
-251
lines changed

src/main/java/edu/uniandes/tsdl/mutapk/MutAPK.java

Lines changed: 208 additions & 178 deletions
Large diffs are not rendered by default.

src/main/java/edu/uniandes/tsdl/mutapk/helper/APKToolWrapper.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ public static String openAPK(String path, String extraPath) throws IOException,
1818
tempFolder.delete();
1919
}
2020
tempFolder.mkdirs();
21-
System.out.println(Paths.get(decodedPath,extraPath,"apktool.jar").toAbsolutePath().toString());
2221
Process ps = Runtime.getRuntime().exec(new String[]{"java","-jar",Paths.get(decodedPath,extraPath,"apktool.jar").toAbsolutePath().toString(),"d",Paths.get(decodedPath,path).toAbsolutePath().toString(),"-o",Paths.get(decodedPath,"temp").toAbsolutePath().toString(),"-f"});
23-
System.out.println("Processing your APK...");
22+
System.out.println("> Processing your APK... ");
2423
ps.waitFor();
25-
System.out.println("Wow... that was an amazing APK to proccess!!! :D");
24+
System.out.println("> Wow... that was an amazing APK to proccess!!! :D");
25+
System.out.println("");
2626
return tempFolder.getAbsolutePath();
2727
// InputStream es = ps.getErrorStream();
2828
// byte e[] = new byte[es.available()];

src/main/java/edu/uniandes/tsdl/mutapk/operators/OperatorBundle.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,14 @@ public int getAmountOfSelectedOperators() {
8383
public String printSelectedOperators() {
8484

8585
Set<String> ids = bundle.keySet();
86-
String selectedOperators = "Selected Operators: " + ids.size() + "\n";
86+
String selectedOperators = "Id | MutOperatorName\n";
87+
selectedOperators += "----------------|--------------\n";
8788

8889
for (String id : ids) {
89-
selectedOperators += id + " " + bundle.getString(id) + "\n";
90+
selectedOperators += id + " | " + bundle.getString(id) + "\n";
9091
}
91-
selectedOperators += "------------\n";
92+
selectedOperators += "\nAmount Selected Operators: " + ids.size() + "\n\n";
93+
selectedOperators += "-------------------------------------------\n";
9294

9395
return selectedOperators;
9496
}

src/main/java/edu/uniandes/tsdl/mutapk/processors/MutationsProcessor.java

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void process(List<MutationLocation> locations, String extraPath, String a
5959
new FileWriter(getMutantsRootFolder() + File.separator + getAppName() + "-mutants.log"));
6060
BufferedWriter wwriter = new BufferedWriter(
6161
new FileWriter(getMutantsRootFolder() + File.separator + getAppName() + "-times.csv"));
62-
wwriter.write("mutantIndex;mutantType;mutationTime;buildingTime");
62+
wwriter.write("mutantIndex;mutantType;mutationTime;buildingTime;itCompiles");
6363
wwriter.newLine();
6464
wwriter.flush();
6565
for (MutationLocation mutationLocation : locations) {
@@ -102,7 +102,6 @@ private void verifyDuplicateMutants(String extraPath, String apkName, int mutant
102102

103103
ApkHashSeparator apkHashSeparatorDuplicate = ApkHashOrder.getInstance()
104104
.setApkHashSeparator(apkHashSeparator);
105-
System.out.println("AQUIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
106105
if (apkHashSeparatorDuplicate != null) {
107106
System.out.println("El operado es: " + mutationLocation.getType().toString());
108107
int compare = apkHashSeparatorDuplicate.getId();
@@ -138,7 +137,7 @@ private void generateMutant(String extraPath, String apkName, int mutantIndex, S
138137
Long buildEnd = System.currentTimeMillis();
139138
Long buildingTime = buildEnd - mutationEnd;
140139
wwriter.write(mutantIndex + ";" + mutationLocation.getType().getId() + ";" + mutationTime + ";"
141-
+ buildingTime);
140+
+ buildingTime + ";" + (result?"1":"0"));
142141
wwriter.newLine();
143142
wwriter.flush();
144143
}
@@ -153,7 +152,7 @@ public ApkHashSeparator generateApkHashSeparator(File manifest, File smali, File
153152
}
154153

155154
public void processMultithreaded(List<MutationLocation> locations, final String extraPath, final String apkName)
156-
throws IOException, NullPointerException, Exception {
155+
throws IOException, NullPointerException {
157156

158157
final BufferedWriter writer = new BufferedWriter(
159158
new FileWriter(getMutantsRootFolder() + File.separator + getAppName() + "-mutants.log"));
@@ -210,20 +209,6 @@ public String call() throws NullPointerException, Exception {
210209
System.out.println("The length of hasmap is: " + ApkHashOrder.getInstance().getLength());
211210
System.out.println("------------------------------------------------------------------------------------");
212211

213-
// If more output for single operator is needed
214-
// FileOutputStream out = new
215-
// FileOutputStream(getMutantsRootFolder()+File.separator+getAppName()+"-process.log");
216-
// PrintStream pout = new PrintStream(out);
217-
// for (Future<String> result : results) {
218-
// try {
219-
// pout.print(result.get());
220-
// } catch (Exception e) {
221-
// e.printStackTrace();
222-
// }
223-
// }
224-
// pout.flush();
225-
// pout.close();
226-
227212
executor.shutdown();
228213
if (executor.isTerminated()) {
229214
writer.close();

src/main/resources/parameters.json

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
{
2-
"APKPath": ".\\apk\\com.evancharlton.mileage_3110.apk",
3-
"PackageName": "com.evancharlton.mileage",
4-
"MutanPath": ".\\mutants",
5-
"BinariesPath": ".\\extra",
6-
"DirectoryOfOperator.properties": ".\\",
7-
"MultithreadGeneration": "true",
8-
"SelectorType": "ALL",
9-
"AmountMutants":"60",
10-
"ConfidenceLevel":{
11-
"Individual":"false",
12-
"ConfidenceLevel":"85",
13-
"MarginError":"10"
14-
},
15-
"APKVersions":{
16-
"OldAPKPath":"1",
17-
"NewAPKPath":"1"
2+
"apkPath": "./apk/com.evancharlton.mileage_3110.apk",
3+
"appName": "com.evancharlton.mileage",
4+
"mutantsFolder": "./mutants",
5+
"operatorsDir": "./",
6+
"multithreadExec": "true",
7+
"extraPath": "./extra",
8+
"selectionStrategy": "all",
9+
"selectionParameters":{
10+
"amountMutants":"60",
11+
"perOperator":"false",
12+
"confidenceLevel":"85",
13+
"marginError":"10",
14+
"baseAPKPath":"./"
1815
}
1916
}

test/MutAPK-1.0.0.jar

18.9 MB
Binary file not shown.

test/operators.properties

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
#1 = ActivityNotDefined
2-
#2 = DifferentActivityIntentDefinition
1+
1 = ActivityNotDefined
2+
2 = DifferentActivityIntentDefinition
33
3 = InvalidActivityPATH
4-
#4 = InvalidKeyIntentPutExtra
5-
#5 = InvalidLabel
6-
#6 = NullIntent
7-
#7 = NullValueIntentPutExtra
8-
#8 = WrongMainActivity
9-
#9 = MissingPermissionManifest
10-
#10 = WrongStringResource
11-
#12 = SDKVersion
12-
#13 = LengthyBackEndService
13-
#14 = LongConnectionTimeOut
14-
#15 = BluetoothAdapterAlwaysEnabled
15-
#16 = NullBluetoothAdapter
16-
#17 = InvalidURI
17-
#18 = NullGPSLocation
18-
#19 = InvalidDate
19-
#20 = NullBackEndServiceReturn
20-
#22 = NullMethodCallArgument
21-
#23 = ClosingNullCursor
22-
#24 = InvalidIndexQueryParameter
23-
#25 = InvalidSQLQuery
24-
#26 = ViewComponentNotVisible
25-
#27 = FindViewByIdReturnsNull
26-
#28 = InvalidColor
27-
#29 = InvalidViewFocus
28-
#31 = InvalidIDFindView
29-
#32 = InvalidFilePath
30-
#33 = NullInputStream
31-
#35 = OOMLargeImage
32-
#36 = LengthyGUIListener
33-
#37 = NullOutputStream
34-
#38 = LengthyGUICreation
4+
4 = InvalidKeyIntentPutExtra
5+
5 = InvalidLabel
6+
6 = NullIntent
7+
7 = NullValueIntentPutExtra
8+
8 = WrongMainActivity
9+
9 = MissingPermissionManifest
10+
10 = WrongStringResource
11+
12 = SDKVersion
12+
13 = LengthyBackEndService
13+
14 = LongConnectionTimeOut
14+
15 = BluetoothAdapterAlwaysEnabled
15+
16 = NullBluetoothAdapter
16+
17 = InvalidURI
17+
18 = NullGPSLocation
18+
19 = InvalidDate
19+
20 = NullBackEndServiceReturn
20+
22 = NullMethodCallArgument
21+
23 = ClosingNullCursor
22+
24 = InvalidIndexQueryParameter
23+
25 = InvalidSQLQuery
24+
26 = ViewComponentNotVisible
25+
27 = FindViewByIdReturnsNull
26+
28 = InvalidColor
27+
29 = InvalidViewFocus
28+
31 = InvalidIDFindView
29+
32 = InvalidFilePath
30+
33 = NullInputStream
31+
35 = OOMLargeImage
32+
36 = LengthyGUIListener
33+
37 = NullOutputStream
34+
38 = LengthyGUICreation

test/parameters.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"apkPath": "./apk/com.evancharlton.mileage_3110.apk",
3+
"appName": "com.evancharlton.mileage",
4+
"mutantsFolder": "./mutants",
5+
"operatorsDir": "./",
6+
"multithreadExec": "false",
7+
"extraPath": "./extra",
8+
"selectionStrategy": "amountMutants",
9+
"selectionParameters":{
10+
"amountMutants":"34",
11+
"perOperator":"false",
12+
"confidenceLevel":"85",
13+
"marginError":"10",
14+
"baseAPKPath":"./"
15+
}
16+
}

test/prueba.txt

Whitespace-only changes.

test/result.md

9.31 KB

Parameters provided via config file:

Name Value
apkPath ./apk/com.evancharlton.mileage_3110.apk
appName com.evancharlton.mileage
mutantsFolder ./mutants
extraPath ./extra
operatorsDir ./
multithread false
selectionStrategy amountMutants
amountMutants 34

Selected Mutation Operators:

Id MutOperatorName
22 NullMethodCallArgument
23 ClosingNullCursor
24 InvalidIndexQueryParameter
25 InvalidSQLQuery
26 ViewComponentNotVisible
27 FindViewByIdReturnsNull
28 InvalidColor
29 InvalidViewFocus
31 InvalidIDFindView
32 InvalidFilePath
10 WrongStringResource
33 NullInputStream
12 SDKVersion
35 OOMLargeImage
13 LengthyBackEndService
36 LengthyGUIListener
14 LongConnectionTimeOut
37 NullOutputStream
15 BluetoothAdapterAlwaysEnabled
38 LengthyGUICreation
16 NullBluetoothAdapter
17 InvalidURI
18 NullGPSLocation
19 InvalidDate
1 ActivityNotDefined
2 DifferentActivityIntentDefinition
3 InvalidActivityPATH
4 InvalidKeyIntentPutExtra
5 InvalidLabel
6 NullIntent
7 NullValueIntentPutExtra
8 WrongMainActivity
9 MissingPermissionManifest
20 NullBackEndServiceReturn

Amount Selected Operators: 34


Processing your APK...
Wow... that was an amazing APK to proccess!!! :D

Amount of Potential Fault Locations per Mutation Operator

Amount Mutants Mutation Operator
12 INVALID_DATE
1 NULL_GPS_LOCATION
29 NULL_INTENT
0 SDK_VERSION
3635 NULL_METHOD_CALL_ARGUMENT
318 WRONG_STRING_RESOURCE
14 NULL_INPUT_STREAM
17 CLOSING_NULL_CURSOR
25 LENGTHY_GUI_CREATION
25 INVALID_VIEW_FOCUS
29 DIFFERENT_ACTIVITY_INTENT_DEFINITION
1 WRONG_MAIN_ACTIVITY
50 ACTIVITY_NOT_DEFINED
3 MISSING_PERMISSION_MANIFEST
104 FINDVIEWBYID_RETURNS_NULL
25 VIEW_COMPONENT_NOT_VISIBLE
19 NULL_VALUE_INTENT_PUT_EXTRA
0 INVALID_COLOR
5 INVALID_FILE_PATH
50 INVALID_ACTIVITY_PATH
104 INVALID_ID_FINDVIEW
49 INVALID_LABEL
14 LENGTHY_GUI_LISTENER
19 INVALID_KEY_INTENT_PUT_EXTRA

Total Locations: 4548


Mutation Process Log

0 HashCode: 1135790254
Creating folder for mutant 1
Copying app information into mutant 1 folder
Mutant: 1 - Type: INVALID_DATE
Mutant 1 has survived the mutation process. Now its source code has been modified.
1 HashCode: -1134521134
Se genero el mutante con id: 1
Building mutant 1...
Signing mutant 1...
SUCCESS: The 1 mutant APK has been generated.
Creating folder for mutant 2
Copying app information into mutant 2 folder
Mutant: 2 - Type: NULL_GPS_LOCATION
Mutant 2 has survived the mutation process. Now its source code has been modified.
2 HashCode: -1617989216
Se genero el mutante con id: 2
Building mutant 2...
Signing mutant 2...
SUCCESS: The 2 mutant APK has been generated.
Creating folder for mutant 3
Copying app information into mutant 3 folder
Mutant: 3 - Type: NULL_INTENT
Mutant 3 has survived the mutation process. Now its source code has been modified.
3 HashCode: -1115483208
Se genero el mutante con id: 3
Building mutant 3...
Signing mutant 3...
SUCCESS: The 3 mutant APK has been generated.
Creating folder for mutant 4
Copying app information into mutant 4 folder
Mutant: 4 - Type: NULL_METHOD_CALL_ARGUMENT
Mutant 4 has survived the mutation process. Now its source code has been modified.
4 HashCode: 2089892849
Se genero el mutante con id: 4
Building mutant 4...
Signing mutant 4...
SUCCESS: The 4 mutant APK has been generated.
Creating folder for mutant 5
Copying app information into mutant 5 folder
Mutant: 5 - Type: WRONG_STRING_RESOURCE
Mutant 5 has survived the mutation process. Now its source code has been modified.
5 HashCode: -1218747368
Se genero el mutante con id: 5
Building mutant 5...
Signing mutant 5...
SUCCESS: The 5 mutant APK has been generated.
Creating folder for mutant 6
Copying app information into mutant 6 folder
Mutant: 6 - Type: NULL_INPUT_STREAM
Mutant 6 has survived the mutation process. Now its source code has been modified.
6 HashCode: -256324410
Se genero el mutante con id: 6
Building mutant 6...
Signing mutant 6...
SUCCESS: The 6 mutant APK has been generated.
Creating folder for mutant 7
Copying app information into mutant 7 folder
Mutant: 7 - Type: CLOSING_NULL_CURSOR
Mutant 7 has survived the mutation process. Now its source code has been modified.

0 commit comments

Comments
 (0)