@@ -95,8 +95,8 @@ void KleeRunner::runKlee(const std::vector<tests::TestMethod> &testMethods,
9595        std::stringstream logStream;
9696        if  (LogUtils::isMaxVerbosity ()) {
9797            logStream << " Processing batch: " 
98-             for  (const  auto  &[methodName, bitcodeFile, sourceFilepath]  : batch) {
99-                 logStream << methodName << " , " 
98+             for  (const  auto  &method  : batch) {
99+                 logStream << method. methodName  << " , " 
100100            }
101101            LOG_S (MAX) << logStream.str ();
102102        }
@@ -207,30 +207,18 @@ static void processMethod(MethodKtests &ktestChunk,
207207    }
208208}
209209
210- void  KleeRunner::processBatchWithoutInteractive (const  std::vector<tests::TestMethod> &testMethods,
211-                                                 tests::Tests &tests,
212-                                                 std::vector<tests::MethodKtests> &ktests) {
213-     if  (!tests.isFilePresentedInArtifact  || testMethods.empty ()) {
214-         return ;
215-     }
216- 
217-     for  (const  auto  &testMethod : testMethods) {
218-         if  (testMethod.sourceFilePath  != tests.sourceFilePath ) {
219-             std::string message = StringUtils::stringFormat (
220-                 " While generating tests for source file: %s tried to generate tests for method %s " 
221-                 " from another source file: %s. This can cause invalid generation.\n " 
222-                 tests.sourceFilePath , testMethod.methodName , testMethod.sourceFilePath );
223-             LOG_S (WARNING) << message;
224-         }
225- 
226-     std::string entryPoint = KleeUtils::entryPointFunction (tests, testMethod.methodName , true );
227-     std::string entryPointFlag = StringUtils::stringFormat (" --entry-point=%s" 
228-     auto  kleeOut = Paths::kleeOutDirForEntrypoints (projectContext, projectTmpPath, testMethod.sourceFilePath ,
229-                                                    testMethod.methodName );
210+ std::pair<std::vector<std::string>, fs::path>
211+ KleeRunner::createKleeParams (const  tests::TestMethod &testMethod,
212+                              const  tests::Tests &tests,
213+                              const  std::string &methodNameOrEmptyForFolder) {
214+     fs::path kleeOut = Paths::kleeOutDirForEntrypoints (projectContext,
215+                                                        projectTmpPath,
216+                                                        tests.sourceFilePath ,
217+                                                        methodNameOrEmptyForFolder);
230218    fs::create_directories (kleeOut.parent_path ());
231-     std::string outputDir =  " --output-dir= "  + kleeOut. string (); 
219+ 
232220    std::vector<std::string> argvData = { " klee" 
233-                                           entryPointFlag ,
221+                                           " --entry-point= "  +  KleeUtils::entryPointFunction (tests, testMethod. methodName ,  true ) ,
234222                                          " --libc=klee" 
235223                                          " --utbot" 
236224                                          " --posix-runtime" 
@@ -245,20 +233,49 @@ void KleeRunner::processBatchWithoutInteractive(const std::vector<tests::TestMet
245233                                          " --check-div-zero=false" 
246234                                          " --check-overshift=false" 
247235                                          " --skip-not-lazy-and-symbolic-pointers" 
248-                                           outputDir  };
236+                                           " --output-dir= "  + kleeOut. string () };
249237    if  (settingsContext.useDeterministicSearcher ) {
250238        argvData.emplace_back (" --search=dfs" 
251239    }
252-     argvData.push_back (testMethod.bitcodeFilePath );
240+     if  (testMethod.is32bits ) {
241+         //  32bit project
242+         argvData.emplace_back (" --allocate-determ-size=" std::to_string (1 ));
243+         argvData.emplace_back (" --allocate-determ-start-address=" std::to_string (0x10000 ));
244+     }
245+     return  {argvData, kleeOut};
246+ }
247+ 
248+ void  KleeRunner::addTailKleeInitParams (std::vector<std::string> &argvData, const  std::string &bitcodeFilePath)
249+ {
250+     argvData.emplace_back (bitcodeFilePath);
253251    argvData.emplace_back (" --sym-stdin" 
254252    argvData.emplace_back (std::to_string (types::Type::symStdinSize));
253+ }
255254
256-     {
257-         std::vector<char  *> cargv, cenvp;
258-         std::vector<std::string> tmp;
259-         ExecUtils::toCArgumentsPtr (argvData, tmp, cargv, cenvp, false );
260-         LOG_S (DEBUG) << " Klee command :: " StringUtils::joinWith (argvData, "  " 
261-         MEASURE_FUNCTION_EXECUTION_TIME
255+ void  KleeRunner::processBatchWithoutInteractive (const  std::vector<tests::TestMethod> &testMethods,
256+                                                 tests::Tests &tests,
257+                                                 std::vector<tests::MethodKtests> &ktests) {
258+     if  (!tests.isFilePresentedInArtifact  || testMethods.empty ()) {
259+         return ;
260+     }
261+ 
262+     for  (const  auto  &testMethod : testMethods) {
263+         if  (testMethod.sourceFilePath  != tests.sourceFilePath ) {
264+             std::string message = StringUtils::stringFormat (
265+                 " While generating tests for source file: %s tried to generate tests for method %s " 
266+                 " from another source file: %s. This can cause invalid generation.\n " 
267+                 tests.sourceFilePath , testMethod.methodName , testMethod.sourceFilePath );
268+             LOG_S (WARNING) << message;
269+         }
270+ 
271+         auto  [argvData, kleeOut] = createKleeParams (testMethod, tests, testMethod.methodName );
272+         addTailKleeInitParams (argvData, testMethod.bitcodeFilePath );
273+         {
274+             std::vector<char  *> cargv, cenvp;
275+             std::vector<std::string> tmp;
276+             ExecUtils::toCArgumentsPtr (argvData, tmp, cargv, cenvp, false );
277+             LOG_S (DEBUG) << " Klee command :: " StringUtils::joinWith (argvData, "  " 
278+             MEASURE_FUNCTION_EXECUTION_TIME
262279
263280            RunKleeTask task (cargv.size (), cargv.data (), settingsContext.timeoutPerFunction );
264281            ExecUtils::ExecutionResult result __attribute__ ((unused)) = task.run ();
@@ -288,51 +305,26 @@ void KleeRunner::processBatchWithInteractive(const std::vector<tests::TestMethod
288305        }
289306    }
290307
291-     TestMethod testMethod = testMethods[0 ];
292-     std::string entryPoint = KleeUtils::entryPointFunction (tests, testMethod.methodName , true );
293-     std::string entryPointFlag = StringUtils::stringFormat (" --entry-point=%s" 
294-     auto  kleeOut = Paths::kleeOutDirForEntrypoints (projectContext, projectTmpPath, tests.sourceFilePath );
295-     fs::create_directories (kleeOut.parent_path ());
296- 
297-     fs::path entrypoints = kleeOut.parent_path () / " entrypoints.txt" 
298-     std::ofstream of (entrypoints);
299-     for  (const  auto  &method : testMethods) {
300-         of << KleeUtils::entryPointFunction (tests, method.methodName , true ) << std::endl;
301-     }
302-     of.close ();
303-     std::string entrypointsArg = " --entrypoints-file=" string ();
304- 
305-     std::string outputDir = " --output-dir=" string ();
306-     std::vector<std::string> argvData = { " klee" 
307-                                           entryPointFlag,
308-                                           " --libc=klee" 
309-                                           " --utbot" 
310-                                           " --posix-runtime" 
311-                                           " --fp-runtime" 
312-                                           " --only-output-states-covering-new" 
313-                                           " --allocate-determ" 
314-                                           " --external-calls=all" 
315-                                           " --timer-interval=1000ms" 
316-                                           " --bcov-check-interval=6s" 
317-                                           " -istats-write-interval=5s" 
318-                                           " --disable-verify" 
319-                                           " --check-div-zero=false" 
320-                                           " --check-overshift=false" 
321-                                           " --skip-not-lazy-and-symbolic-pointers" 
322-                                           " --interactive" 
323-                                           KleeUtils::processNumberOption (),
324-                                           entrypointsArg,
325-                                           outputDir };
326-     if  (settingsContext.timeoutPerFunction .has_value ()) {
327-         argvData.push_back (StringUtils::stringFormat (" --timeout-per-function=%d" timeoutPerFunction .value ()));
328-     }
329-     if  (settingsContext.useDeterministicSearcher ) {
330-         argvData.emplace_back (" --search=dfs" 
308+     auto  [argvData, kleeOut] = createKleeParams (testMethods[0 ], tests, " " 
309+     {
310+         //  additional KLEE arguments
311+         argvData.emplace_back (" --interactive" 
312+         argvData.emplace_back (KleeUtils::processNumberOption ());
313+         {
314+             //  entrypoints
315+             fs::path entrypoints = kleeOut.parent_path () / " entrypoints.txt" 
316+             std::ofstream of (entrypoints);
317+             for  (const  auto  &method : testMethods) {
318+                 of << KleeUtils::entryPointFunction (tests, method.methodName , true ) << std::endl;
319+             }
320+             argvData.emplace_back (" --entrypoints-file=" string ());
321+         }
322+         if  (settingsContext.timeoutPerFunction .has_value ()) {
323+             argvData.emplace_back (StringUtils::stringFormat (
324+                 " --timeout-per-function=%d" timeoutPerFunction .value ()));
325+         }
326+         addTailKleeInitParams (argvData, testMethods[0 ].bitcodeFilePath );
331327    }
332-     argvData.push_back (testMethod.bitcodeFilePath );
333-     argvData.emplace_back (" --sym-stdin" 
334-     argvData.emplace_back (std::to_string (types::Type::symStdinSize));
335- 
336328    {
337329        std::vector<char  *> cargv, cenvp;
338330        std::vector<std::string> tmp;
0 commit comments