@@ -32,6 +32,45 @@ printer::KleePrinter::KleePrinter(const types::TypesHandler *typesHandler,
3232    : Printer(srcLanguage), typesHandler(typesHandler), buildDatabase(std::move(buildDatabase)) {
3333}
3434
35+ void  KleePrinter::writePosixWrapper (const  Tests &tests,
36+                                     const  tests::Tests::MethodDescription &testMethod) {
37+     declTestEntryPoint (tests, testMethod, false );
38+     strFunctionCall (PrinterUtils::POSIX_INIT, {" &" " &" 
39+     std::string entryPoint = KleeUtils::entryPointFunction (tests, testMethod.name , false , true );
40+     strDeclareVar (" int" constrFunctionCall (entryPoint,
41+                         {PrinterUtils::UTBOT_ARGC, PrinterUtils::UTBOT_ARGV, PrinterUtils::UTBOT_ENVP},
42+                         " " nullopt , false ));
43+     strFunctionCall (PrinterUtils::POSIX_CHECK_STDIN_READ, {});
44+     strReturn (KleeUtils::RESULT_VARIABLE_NAME);
45+     closeBrackets (1 );
46+     ss << NL;
47+ }
48+ 
49+ void  KleePrinter::writeTestedFunction (const  Tests &tests,
50+                                       const  tests::Tests::MethodDescription &testMethod,
51+                                       const  std::optional<LineInfo::PredicateInfo> &predicateInfo,
52+                                       const  std::string &testedMethod,
53+                                       bool  onlyForOneEntity,
54+                                       bool  isWrapped) {
55+     writeStubsForFunctionParams (typesHandler, testMethod, true );
56+     declTestEntryPoint (tests, testMethod, isWrapped);
57+     genGlobalParamsDeclarations (testMethod);
58+     genParamsDeclarations (testMethod);
59+     genPostGlobalSymbolicVariables (testMethod);
60+     genPostParamsSymbolicVariables (testMethod);
61+     if  (types::TypesHandler::skipTypeInReturn (testMethod.returnType )) {
62+         genVoidFunctionAssumes (testMethod, predicateInfo, testedMethod, onlyForOneEntity);
63+     } else  {
64+         genNonVoidFunctionAssumes (testMethod, predicateInfo, testedMethod,
65+                                   onlyForOneEntity);
66+     }
67+     genGlobalsKleeAssumes (testMethod);
68+     genPostParamsKleeAssumes (testMethod);
69+     strReturn (" 0" 
70+     closeBrackets (1 );
71+     ss << NL;
72+ }
73+ 
3574fs::path KleePrinter::writeTmpKleeFile (
3675    const  Tests &tests,
3776    const  std::string &buildDir,
@@ -92,22 +131,12 @@ fs::path KleePrinter::writeTmpKleeFile(
92131            continue ;
93132        }
94133        try  {
95-             writeStubsForFunctionParams (typesHandler, testMethod, true );
96-             declTestEntryPoint (tests, testMethod);
97-             genGlobalParamsDeclarations (testMethod);
98-             genParamsDeclarations (testMethod);
99-             genPostGlobalSymbolicVariables (testMethod);
100-             genPostParamsSymbolicVariables (testMethod);
101-             if  (types::TypesHandler::skipTypeInReturn (testMethod.returnType )) {
102-                 genVoidFunctionAssumes (testMethod, predicateInfo, testedMethod, onlyForOneEntity);
134+             if  (srcLanguage == utbot::Language::C) {
135+                 writeTestedFunction (tests, testMethod, predicateInfo, testedMethod, onlyForOneEntity, true );
136+                 writePosixWrapper (tests, testMethod);
103137            } else  {
104-                 genNonVoidFunctionAssumes (testMethod, predicateInfo, testedMethod,
105-                                           onlyForOneEntity);
138+                 writeTestedFunction (tests, testMethod, predicateInfo, testedMethod, onlyForOneEntity, false );
106139            }
107-             genGlobalsKleeAssumes (testMethod);
108-             genPostParamsKleeAssumes (testMethod);
109-             strReturn (" 0" 
110-             closeBrackets (1 );
111140        } catch  (const  UnImplementedException &e) {
112141            std::string message =
113142                " Could not generate klee code for method \' " " \' , skipping it. " 
@@ -121,11 +150,13 @@ fs::path KleePrinter::writeTmpKleeFile(
121150}
122151
123152void  KleePrinter::declTestEntryPoint (const  Tests &tests,
124-                                      const  Tests::MethodDescription &testMethod) {
125-     std::string entryPoint = KleeUtils::entryPointFunction (tests, testMethod.name );
153+                                      const  Tests::MethodDescription &testMethod,
154+                                      bool  isWrapped) {
155+     std::string entryPoint = KleeUtils::entryPointFunction (tests, testMethod.name , false , isWrapped);
126156    auto  argvType = types::Type::createSimpleTypeFromName (" char" 2 );
127157    //  if change args in next line also change cpp mangledPath in kleeUtils.cpp
128-     strFunctionDecl (" int" types::Type::intType (), argvType, argvType}, {" utbot_argc" " utbot_argv" " utbot_envp" " " LB ();
158+     strFunctionDecl (" int" types::Type::intType (), argvType, argvType},
159+                     {PrinterUtils::UTBOT_ARGC, PrinterUtils::UTBOT_ARGV, PrinterUtils::UTBOT_ENVP}, " " LB ();
129160}
130161
131162Tests::MethodParam KleePrinter::getKleeMethodParam (tests::Tests::MethodParam const  ¶m) {
0 commit comments