├── .classpath ├── .gitattributes ├── .gitignore ├── .project ├── Documentation ├── About.txt ├── Detailed Report with User Manual.pdf ├── Technical Document.pdf └── User Manual.pdf ├── LICENSE ├── README.md ├── resources ├── appIcon.ico ├── icon16.png └── logo.png ├── src ├── codeBeautifier │ ├── BlankLineRemover.java │ ├── CmdExecutor.java │ ├── CodeBeautifier.java │ ├── CommentRemover.java │ ├── LineRemover.java │ └── package-info.java ├── controlFlowGraphBuilder │ ├── CFGBuilder.java │ ├── Node.java │ └── package-info.java ├── database │ ├── DatabaseLoader.java │ └── package-info.java ├── io │ ├── CustomFileReader.java │ ├── CustomFileWriter.java │ ├── InputFileCopyMachine.java │ └── package-info.java ├── main │ ├── MainController.java │ ├── MainView.fxml │ ├── Start.java │ ├── application.css │ └── package-info.java ├── parser │ ├── CParser.java │ ├── ComponentSeparator.java │ ├── MethodParser.java │ ├── components │ │ ├── Component.java │ │ ├── Directive.java │ │ ├── Method.java │ │ ├── ObjectFile.java │ │ ├── UserDefinedData.java │ │ ├── Variable.java │ │ └── package-info.java │ └── package-info.java ├── result │ ├── FileResult.java │ └── package-info.java └── symbolicSolver │ ├── SMTSolver.java │ ├── SymbolicSolver.java │ └── package-info.java ├── test ├── 1.c ├── Mini Project in C Bank Management System │ ├── Readme.docx │ └── bank management system.c ├── Mini Project in C Library Management System │ ├── Readme.docx │ └── library management system.c ├── custom.c ├── darknet │ └── src │ │ ├── activation_kernels.cu │ │ ├── activation_layer.c │ │ ├── activation_layer.h │ │ ├── activations.c │ │ ├── activations.h │ │ ├── avgpool_layer.c │ │ ├── avgpool_layer.h │ │ ├── avgpool_layer_kernels.cu │ │ ├── batchnorm_layer.c │ │ ├── batchnorm_layer.h │ │ ├── blas.c │ │ ├── blas.h │ │ ├── blas_kernels.cu │ │ ├── box.c │ │ ├── box.h │ │ ├── classifier.h │ │ ├── col2im.c │ │ ├── col2im.h │ │ ├── col2im_kernels.cu │ │ ├── compare.c │ │ ├── connected_layer.c │ │ ├── connected_layer.h │ │ ├── convolutional_kernels.cu │ │ ├── convolutional_layer.c │ │ ├── convolutional_layer.h │ │ ├── cost_layer.c │ │ ├── cost_layer.h │ │ ├── crnn_layer.c │ │ ├── crnn_layer.h │ │ ├── crop_layer.c │ │ ├── crop_layer.h │ │ ├── crop_layer_kernels.cu │ │ ├── cuda.c │ │ ├── cuda.h │ │ ├── data.c │ │ ├── data.h │ │ ├── deconvolutional_kernels.cu │ │ ├── deconvolutional_layer.c │ │ ├── deconvolutional_layer.h │ │ ├── demo.c │ │ ├── demo.h │ │ ├── detection_layer.c │ │ ├── detection_layer.h │ │ ├── dropout_layer.c │ │ ├── dropout_layer.h │ │ ├── dropout_layer_kernels.cu │ │ ├── gemm.c │ │ ├── gemm.h │ │ ├── gru_layer.c │ │ ├── gru_layer.h │ │ ├── im2col.c │ │ ├── im2col.h │ │ ├── im2col_kernels.cu │ │ ├── image.c │ │ ├── image.h │ │ ├── image_opencv.cpp │ │ ├── iseg_layer.c │ │ ├── iseg_layer.h │ │ ├── l2norm_layer.c │ │ ├── l2norm_layer.h │ │ ├── layer.c │ │ ├── layer.h │ │ ├── list.c │ │ ├── list.h │ │ ├── local_layer.c │ │ ├── local_layer.h │ │ ├── logistic_layer.c │ │ ├── logistic_layer.h │ │ ├── lstm_layer.c │ │ ├── lstm_layer.h │ │ ├── matrix.c │ │ ├── matrix.h │ │ ├── maxpool_layer.c │ │ ├── maxpool_layer.h │ │ ├── maxpool_layer_kernels.cu │ │ ├── network.c │ │ ├── network.h │ │ ├── normalization_layer.c │ │ ├── normalization_layer.h │ │ ├── option_list.c │ │ ├── option_list.h │ │ ├── parser.c │ │ ├── parser.h │ │ ├── region_layer.c │ │ ├── region_layer.h │ │ ├── reorg_layer.c │ │ ├── reorg_layer.h │ │ ├── rnn_layer.c │ │ ├── rnn_layer.h │ │ ├── route_layer.c │ │ ├── route_layer.h │ │ ├── shortcut_layer.c │ │ ├── shortcut_layer.h │ │ ├── softmax_layer.c │ │ ├── softmax_layer.h │ │ ├── stb_image.h │ │ ├── stb_image_write.h │ │ ├── tree.c │ │ ├── tree.h │ │ ├── upsample_layer.c │ │ ├── upsample_layer.h │ │ ├── utils.c │ │ ├── utils.h │ │ ├── yolo_layer.c │ │ └── yolo_layer.h └── test │ └── me.c └── z3 ├── LICENSE.txt ├── bin ├── Microsoft.Z3.dll ├── Microsoft.Z3.xml ├── com.microsoft.z3.jar ├── libz3.dll ├── libz3.lib ├── libz3java.dll ├── libz3java.lib ├── python │ ├── example.py │ └── z3 │ │ ├── __init__.py │ │ ├── __init__.pyc │ │ ├── z3.py │ │ ├── z3.pyc │ │ ├── z3consts.py │ │ ├── z3consts.pyc │ │ ├── z3core.py │ │ ├── z3core.pyc │ │ ├── z3num.py │ │ ├── z3num.pyc │ │ ├── z3poly.py │ │ ├── z3poly.pyc │ │ ├── z3printer.py │ │ ├── z3printer.pyc │ │ ├── z3rcf.py │ │ ├── z3rcf.pyc │ │ ├── z3types.py │ │ ├── z3types.pyc │ │ ├── z3util.py │ │ └── z3util.pyc ├── z3++.h ├── z3.exe ├── z3.h ├── z3_algebraic.h ├── z3_api.h ├── z3_ast_containers.h ├── z3_fixedpoint.h ├── z3_fpa.h ├── z3_interp.h ├── z3_macros.h ├── z3_optimization.h ├── z3_polynomial.h ├── z3_rcf.h ├── z3_spacer.h └── z3_v1.h └── include ├── z3++.h ├── z3.h ├── z3_algebraic.h ├── z3_api.h ├── z3_ast_containers.h ├── z3_fixedpoint.h ├── z3_fpa.h ├── z3_interp.h ├── z3_macros.h ├── z3_optimization.h ├── z3_polynomial.h ├── z3_rcf.h ├── z3_spacer.h └── z3_v1.h /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.metadata/ 2 | /.recommenders/ 3 | /bin/ 4 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | C Path Finder 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /Documentation/About.txt: -------------------------------------------------------------------------------- 1 | C Path Finder v1.0.1 2 | 3 | Developer: Sajed Jalil 4 | Developer Mail: bsse0714@iit.du.ac.bd 5 | 6 | ************************************************************** 7 | 8 | About 9 | 10 | C Path Finder is an automatic test case generator for C projects. 11 | 12 | For more, please visit us at https://github.com/Sajed49/C-Path-Finder 13 | -------------------------------------------------------------------------------- /Documentation/Detailed Report with User Manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sajedjalil/C-Path-Finder/ee748c939fbad4fd0d8aa2647abca411f320e734/Documentation/Detailed Report with User Manual.pdf -------------------------------------------------------------------------------- /Documentation/Technical Document.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sajedjalil/C-Path-Finder/ee748c939fbad4fd0d8aa2647abca411f320e734/Documentation/Technical Document.pdf -------------------------------------------------------------------------------- /Documentation/User Manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sajedjalil/C-Path-Finder/ee748c939fbad4fd0d8aa2647abca411f320e734/Documentation/User Manual.pdf -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Sajed Jalil 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # C-Path-Finder 2 | 3 | An automatic unit test case generator for C source code using Memorized Symbolic Execution & z3 solver 4 | -------------------------------------------------------------------------------- /resources/appIcon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sajedjalil/C-Path-Finder/ee748c939fbad4fd0d8aa2647abca411f320e734/resources/appIcon.ico -------------------------------------------------------------------------------- /resources/icon16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sajedjalil/C-Path-Finder/ee748c939fbad4fd0d8aa2647abca411f320e734/resources/icon16.png -------------------------------------------------------------------------------- /resources/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sajedjalil/C-Path-Finder/ee748c939fbad4fd0d8aa2647abca411f320e734/resources/logo.png -------------------------------------------------------------------------------- /src/codeBeautifier/BlankLineRemover.java: -------------------------------------------------------------------------------- 1 | package codeBeautifier; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class BlankLineRemover { 6 | 7 | public static ArrayList removeBlankLines( ArrayList fileText){ 8 | 9 | ArrayList temp = new ArrayList(); 10 | 11 | for(String s: fileText) { 12 | if( s.trim().length() > 0 ) { 13 | temp.add(s); 14 | } 15 | } 16 | 17 | return temp; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/codeBeautifier/CmdExecutor.java: -------------------------------------------------------------------------------- 1 | package codeBeautifier; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.BufferedWriter; 5 | import java.io.File; 6 | import java.io.FileWriter; 7 | import java.io.IOException; 8 | import java.io.InputStreamReader; 9 | import java.util.ArrayList; 10 | 11 | public class CmdExecutor { 12 | 13 | public CmdExecutor(String directory, String inputFileName, String outputFileName) { 14 | 15 | 16 | removeCommentsGCC( new File(directory), inputFileName, outputFileName); 17 | } 18 | 19 | public CmdExecutor(String directory, String inputFilePath) { 20 | this(directory, inputFilePath, inputFilePath); 21 | } 22 | 23 | private void removeCommentsGCC(File directory, String inputFileName, String outputFileName) { 24 | 25 | inputFileName = "\"" +inputFileName + "\""; 26 | 27 | //System.out.println(directory.getPath() + " "+ inputFileName); 28 | try { 29 | 30 | Process p = Runtime.getRuntime().exec("cmd /C gcc -fpreprocessed -dD -E " 31 | + inputFileName, null, directory); 32 | 33 | BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); 34 | 35 | ArrayList temp = new ArrayList(); 36 | 37 | String line = null; 38 | while ((line = in.readLine()) != null) temp.add(line); 39 | in.close(); 40 | 41 | BufferedWriter out = new BufferedWriter(new FileWriter(directory+"\\"+outputFileName)); 42 | 43 | for(String s: temp) { 44 | out.write(s); 45 | out.newLine(); 46 | } 47 | 48 | temp.clear(); 49 | out.close(); 50 | 51 | } catch (IOException e ) { 52 | e.printStackTrace(); 53 | } 54 | 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/codeBeautifier/CodeBeautifier.java: -------------------------------------------------------------------------------- 1 | package codeBeautifier; 2 | 3 | import java.io.File; 4 | import java.util.ArrayList; 5 | 6 | import io.CustomFileReader; 7 | import io.CustomFileWriter; 8 | 9 | public class CodeBeautifier { 10 | 11 | public CodeBeautifier(File sourceFilesDirectory) { 12 | 13 | directorySearcher(sourceFilesDirectory); 14 | } 15 | 16 | public void beautify(File currentFile) { 17 | 18 | ArrayList lines = CustomFileReader.readAfile(currentFile); 19 | 20 | /**Faster Approach 21 | * Manual parsing 22 | */ 23 | lines = CommentRemover.removeComments(lines); 24 | lines = BlankLineRemover.removeBlankLines(lines); 25 | 26 | CustomFileWriter.writeAFile(currentFile, lines); 27 | 28 | /** 29 | * Slower almost 15 times 30 | * GCC implementation invoke 31 | */ 32 | //LineRemover.removeIncludeStatementLine(a); 33 | //new CmdExecutor(currentDirectory.getPath(), a.getName(), a.getName()); 34 | //LineRemover.removeUnnecessaryLine(a); 35 | } 36 | 37 | private void directorySearcher(File currentDirectory) { 38 | 39 | for(File file: currentDirectory.listFiles()) { 40 | 41 | if(file.isDirectory()) { 42 | directorySearcher(file); 43 | } 44 | else if(file.isFile()) { 45 | 46 | beautify(file); 47 | } 48 | } 49 | } 50 | 51 | 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/codeBeautifier/CommentRemover.java: -------------------------------------------------------------------------------- 1 | package codeBeautifier; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class CommentRemover { 6 | 7 | public CommentRemover() { 8 | 9 | } 10 | 11 | public static ArrayList removeComments( ArrayList fileText){ 12 | 13 | ArrayList temp = new ArrayList(); 14 | 15 | int multipleLineCommentFlag = 0; 16 | int doubleQuoteFlag = 0; 17 | int multipleCommentLineStart = 0; 18 | 19 | 20 | for(int line=0; line 0 && (int)s.charAt( s.length()-1 ) == 34 ) doubleQuoteFlag = (doubleQuoteFlag+1)%2; 65 | 66 | temp.add(s); 67 | } 68 | 69 | return temp; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/codeBeautifier/LineRemover.java: -------------------------------------------------------------------------------- 1 | package codeBeautifier; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.nio.file.Files; 6 | import java.nio.file.StandardOpenOption; 7 | import java.util.List; 8 | import java.util.stream.Collectors; 9 | 10 | class LineRemover { 11 | 12 | 13 | public static void removeIncludeStatementLine(File inputFile) { 14 | 15 | List out; 16 | try { 17 | out = Files.lines(inputFile.toPath()) 18 | .filter(line -> ifIncludeStatementJunk(line) ) 19 | .collect(Collectors.toList()); 20 | 21 | 22 | 23 | Files.write(inputFile.toPath(), out, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING); 24 | } catch (IOException e) { 25 | // TODO Auto-generated catch block 26 | e.printStackTrace(); 27 | } 28 | 29 | } 30 | 31 | private static Boolean ifIncludeStatementJunk(String line) { 32 | 33 | if( line.trim().length() == 0) return false; 34 | 35 | String [] temp = line.split(" "); 36 | 37 | if( temp.length > 0 ) { 38 | if( temp[0].startsWith("#include")) return false; //removes #include lines 39 | } 40 | 41 | return true; 42 | } 43 | 44 | 45 | 46 | public static void removeUnnecessaryLine(File inputFile) { 47 | 48 | List out; 49 | try { 50 | out = Files.lines(inputFile.toPath()) 51 | .filter(line -> ifOtherJunk(line) ) 52 | .collect(Collectors.toList()); 53 | 54 | 55 | 56 | Files.write(inputFile.toPath(), out, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING); 57 | } catch (IOException e) { 58 | // TODO Auto-generated catch block 59 | e.printStackTrace(); 60 | } 61 | 62 | } 63 | 64 | private static Boolean ifOtherJunk(String line) { 65 | 66 | if( line.trim().length() == 0) return false; 67 | 68 | String [] temp = line.split(" "); 69 | 70 | if( temp.length > 0 ) { 71 | if( temp[0].startsWith("#") && !temp[0].startsWith("#define")) return false; //removes #include lines 72 | else if( temp[0].startsWith("#") && !temp[0].startsWith("#typedef")) return false; 73 | } 74 | 75 | return true; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/codeBeautifier/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Sajed Jalil 3 | * @email bsse0714@iit.du.ac.bd 4 | * @year 2018 5 | * @location Dhaka 6 | * 7 | */ 8 | package codeBeautifier; -------------------------------------------------------------------------------- /src/controlFlowGraphBuilder/Node.java: -------------------------------------------------------------------------------- 1 | package controlFlowGraphBuilder; 2 | 3 | public class Node { 4 | 5 | public int leftChildID = -1; //null initially 6 | public int rightChildID = -1; //null initially 7 | 8 | public Node leftChild; 9 | public Node rightChild; 10 | 11 | public int id, level; 12 | public String content; 13 | public String conditions = ""; 14 | public Boolean ifAssignmentStatement = false; 15 | 16 | private void setIfAssignmentStatement() { 17 | if( content.contains(" = ") ) ifAssignmentStatement = true; 18 | } 19 | 20 | public Node(int id, String content, int level) { 21 | this.id = id; 22 | this.content = content; 23 | this.level = level; 24 | //System.out.println(content+" "+id); 25 | getConditions(); 26 | setIfAssignmentStatement(); 27 | } 28 | 29 | 30 | private void getConditions() { 31 | 32 | String temp = ""; 33 | int flag = 0; 34 | int len = content.length(); 35 | 36 | if( content.startsWith("if") || content.startsWith("else if") ) { 37 | 38 | for(int i=0; i 0 ) temp += content.charAt(i); 50 | } 51 | } 52 | 53 | //there exists a condition 54 | if( temp.trim().isEmpty() == false) { 55 | conditions = temp.trim(); 56 | //System.out.println(conditions); 57 | } 58 | } 59 | 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/controlFlowGraphBuilder/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Sajed Jalil 3 | * @email bsse0714@iit.du.ac.bd 4 | * @year 2018 5 | * @location Dhaka 6 | * 7 | */ 8 | package controlFlowGraphBuilder; -------------------------------------------------------------------------------- /src/database/DatabaseLoader.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sajedjalil/C-Path-Finder/ee748c939fbad4fd0d8aa2647abca411f320e734/src/database/DatabaseLoader.java -------------------------------------------------------------------------------- /src/database/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Sajed Jalil 3 | * @email bsse0714@iit.du.ac.bd 4 | * @year 2018 5 | * @location Dhaka 6 | * 7 | */ 8 | package database; -------------------------------------------------------------------------------- /src/io/CustomFileReader.java: -------------------------------------------------------------------------------- 1 | package io; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.File; 5 | import java.io.FileNotFoundException; 6 | import java.io.FileReader; 7 | import java.io.IOException; 8 | import java.util.ArrayList; 9 | 10 | public class CustomFileReader { 11 | 12 | public static ArrayList readAfile( File currentFile){ 13 | 14 | ArrayList temp = new ArrayList(); 15 | 16 | BufferedReader br = null; 17 | FileReader fr = null; 18 | 19 | try { 20 | 21 | 22 | fr = new FileReader(currentFile); 23 | br = new BufferedReader(fr); 24 | 25 | String line; 26 | 27 | while ((line = br.readLine()) != null) { 28 | temp.add(line); 29 | } 30 | 31 | } catch (FileNotFoundException e) { 32 | 33 | System.out.println("Could not found "+currentFile.getName()+" in "+currentFile.getPath()); 34 | 35 | } 36 | catch (IOException e) { 37 | 38 | System.out.println("Error in reading file in "+currentFile.getName()+" in "+currentFile.getPath()); 39 | 40 | } finally { 41 | 42 | try { 43 | 44 | if (br != null) 45 | br.close(); 46 | 47 | if (fr != null) 48 | fr.close(); 49 | 50 | } catch (IOException ex) { 51 | 52 | ex.printStackTrace(); 53 | 54 | } 55 | 56 | } 57 | 58 | return temp; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/io/CustomFileWriter.java: -------------------------------------------------------------------------------- 1 | package io; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.File; 5 | import java.io.FileWriter; 6 | import java.io.IOException; 7 | import java.util.ArrayList; 8 | 9 | public class CustomFileWriter { 10 | 11 | public static void writeAFile(File currentFile ,ArrayList lines) { 12 | 13 | BufferedWriter bw = null; 14 | FileWriter fw = null; 15 | 16 | try { 17 | 18 | 19 | fw = new FileWriter(currentFile); 20 | bw = new BufferedWriter(fw); 21 | 22 | for(String s: lines) { 23 | bw.write(s); 24 | bw.newLine(); 25 | } 26 | 27 | } catch (IOException e) { 28 | 29 | e.printStackTrace(); 30 | 31 | } finally { 32 | 33 | try { 34 | 35 | if (bw != null) 36 | bw.close(); 37 | 38 | if (fw != null) 39 | fw.close(); 40 | 41 | } catch (IOException ex) { 42 | 43 | ex.printStackTrace(); 44 | 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/io/InputFileCopyMachine.java: -------------------------------------------------------------------------------- 1 | 2 | package io; 3 | 4 | import java.io.File; 5 | import java.io.IOException; 6 | import java.nio.file.Files; 7 | import java.nio.file.Path; 8 | import java.nio.file.Paths; 9 | import java.nio.file.StandardCopyOption; 10 | 11 | public class InputFileCopyMachine { 12 | 13 | public InputFileCopyMachine(String sourcePath, String destinationPath) { 14 | 15 | makeMainOutputDirectory(destinationPath); 16 | copyDirectory(sourcePath, destinationPath); 17 | } 18 | 19 | 20 | 21 | private void makeMainOutputDirectory(String destinationPath) { 22 | 23 | File dir = new File(destinationPath); 24 | dir.mkdirs(); 25 | } 26 | 27 | 28 | 29 | 30 | private void copyDirectory(String sourcePath, String destinationPath) { 31 | 32 | 33 | File source = new File(sourcePath); 34 | 35 | 36 | for(File a : source.listFiles()) { 37 | 38 | Path s = Paths.get(a.getPath()); 39 | Path d = Paths.get(destinationPath+"\\"+a.getName()); 40 | 41 | 42 | if( a.isDirectory() ) { 43 | 44 | try { 45 | 46 | if(!Files.exists(d)) 47 | Files.copy(s, d, StandardCopyOption.REPLACE_EXISTING ); 48 | 49 | copyDirectory(a.getPath(), destinationPath+"\\"+a.getName()); 50 | 51 | } catch (IOException e) { e.printStackTrace(); } 52 | 53 | 54 | } 55 | else if( a.isFile() && (a.getName().endsWith(".c") || a.getName().endsWith(".h")) ) { 56 | 57 | try { 58 | Files.copy(s, d, StandardCopyOption.REPLACE_EXISTING ); 59 | } catch (IOException e) { 60 | // TODO Auto-generated catch block 61 | e.printStackTrace(); 62 | } 63 | } 64 | } 65 | 66 | } 67 | 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/io/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Sajed Jalil 3 | * @email bsse0714@iit.du.ac.bd 4 | * @year 2018 5 | * @location Dhaka 6 | * 7 | */ 8 | package io; -------------------------------------------------------------------------------- /src/main/MainController.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import java.awt.Desktop; 4 | import java.io.File; 5 | import java.io.IOException; 6 | import java.util.ArrayList; 7 | import java.util.concurrent.ExecutorService; 8 | import java.util.concurrent.Executors; 9 | import java.util.concurrent.Future; 10 | import java.util.concurrent.TimeUnit; 11 | import java.util.concurrent.TimeoutException; 12 | 13 | import javafx.application.Platform; 14 | import javafx.fxml.FXML; 15 | import javafx.scene.control.Button; 16 | import javafx.scene.control.ProgressBar; 17 | import javafx.scene.text.Text; 18 | import javafx.stage.DirectoryChooser; 19 | import parser.CParser; 20 | 21 | public class MainController { 22 | 23 | @FXML Button openFileButton; 24 | @FXML Button runButton; 25 | @FXML Button openResultButton; 26 | 27 | @FXML Text openFilePath; 28 | @FXML ProgressBar runProgress; 29 | @FXML Text status; 30 | @FXML Text resultDirectory; 31 | @FXML Text copyright; 32 | 33 | @FXML 34 | private void selectFiles() { 35 | 36 | DirectoryChooser directoryChooser = new DirectoryChooser(); 37 | File selectedDirectory = directoryChooser.showDialog(Start.primaryStage); 38 | 39 | if(selectedDirectory == null){ 40 | System.out.println("null"); 41 | }else{ 42 | 43 | openFilePath.setText(selectedDirectory.getAbsolutePath()); 44 | 45 | openFileButton.setText("Change"); 46 | runButton.setText("Run"); 47 | 48 | Start.inputPath = selectedDirectory.getAbsolutePath(); 49 | 50 | runButton.setVisible(true); 51 | 52 | } 53 | } 54 | 55 | 56 | @FXML 57 | private void runFiles() { 58 | 59 | runProgress.setProgress(0.00); 60 | status.setText("Processing Source Files"); 61 | 62 | runProgress.setVisible(true); 63 | status.setVisible(true); 64 | 65 | 66 | 67 | 68 | 69 | 70 | new Thread(){ 71 | public void run() { 72 | 73 | ArrayList changedFiles = Start.runInit(); 74 | Platform.runLater(() -> runProgress.setProgress( 0.1)); 75 | 76 | 77 | final double step = 0.9 / changedFiles.size(); 78 | 79 | for(int i=0; i f = service.submit(() -> { 87 | new CParser(changedFiles.get(temp)); 88 | Thread.sleep(100); // Simulate some delay 89 | return "42"; 90 | }); 91 | 92 | System.out.println(f.get(10, TimeUnit.SECONDS)); 93 | } catch (final TimeoutException e) { 94 | System.err.println("Calculation took to long"); 95 | } catch (final Exception e) { 96 | throw new RuntimeException(e); 97 | } finally { 98 | service.shutdown(); 99 | } 100 | 101 | 102 | final double adder = (i+1)*step; 103 | 104 | Platform.runLater(() -> runProgress.setProgress( 0.1 + adder )); 105 | status.setText("Analyzing: "+changedFiles.get(i)); 106 | 107 | } 108 | 109 | Platform.runLater(() -> runProgress.setProgress( 1.0 )); 110 | status.setText("Done"); 111 | Start.deleteTempFiles(); 112 | Platform.runLater(() -> runButton.setText("Re-Run") ); 113 | 114 | openResultButton.setVisible(true); 115 | resultDirectory.setVisible(true); 116 | 117 | } 118 | }.start(); 119 | 120 | 121 | 122 | 123 | } 124 | 125 | 126 | @FXML 127 | private void changeOutputDirectory() { 128 | 129 | DirectoryChooser directoryChooser = new DirectoryChooser(); 130 | File selectedDirectory = directoryChooser.showDialog(Start.primaryStage); 131 | 132 | if(selectedDirectory == null){ 133 | System.out.println("null"); 134 | }else{ 135 | 136 | System.out.println(selectedDirectory.getAbsolutePath()); 137 | CParser.testCaseOutputDirectory = selectedDirectory.getAbsolutePath(); 138 | 139 | resultDirectory.setText(CParser.testCaseOutputDirectory); 140 | } 141 | 142 | } 143 | 144 | 145 | @FXML 146 | private void openOutputDirectory() { 147 | 148 | Desktop desktop = Desktop.getDesktop(); 149 | try { 150 | desktop.open( new File(CParser.testCaseOutputDirectory) ); 151 | } catch (IOException e) { 152 | // TODO Auto-generated catch block 153 | e.printStackTrace(); 154 | } 155 | 156 | } 157 | 158 | @FXML 159 | private void exitProgram() { 160 | 161 | System.exit(0); 162 | 163 | } 164 | 165 | @FXML 166 | private void openAbout() { 167 | 168 | if (Desktop.isDesktopSupported()) { 169 | try { 170 | File myFile = new File("Documentation\\About.txt"); 171 | Desktop.getDesktop().open(myFile); 172 | } catch (IOException ex) { 173 | // no application registered for PDFs 174 | } 175 | } 176 | } 177 | 178 | 179 | @FXML 180 | private void openTutorial() { 181 | 182 | if (Desktop.isDesktopSupported()) { 183 | try { 184 | File myFile = new File("Documentation\\User Manual.pdf"); 185 | Desktop.getDesktop().open(myFile); 186 | } catch (IOException ex) { 187 | // no application registered for PDFs 188 | } 189 | } 190 | } 191 | } 192 | -------------------------------------------------------------------------------- /src/main/MainView.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 |